@@ -12,8 +12,12 @@ use super::values::value_for_array;
1212pub  enum  TypeKind  { 
1313    BFloat , 
1414    Float , 
15-     Int , 
16-     UInt , 
15+     Double , 
16+  
17+     // if signed, then the inner value is true 
18+     Int ( bool ) , 
19+     Char ( bool ) , 
20+     Short ( bool ) , 
1721    Poly , 
1822    Void , 
1923} 
@@ -25,9 +29,10 @@ impl FromStr for TypeKind {
2529        match  s { 
2630            "bfloat"  => Ok ( Self :: BFloat ) , 
2731            "float"  => Ok ( Self :: Float ) , 
28-             "int"  => Ok ( Self :: Int ) , 
32+             "int"  => Ok ( Self :: Int ( true ) ) , 
2933            "poly"  => Ok ( Self :: Poly ) , 
30-             "uint"  | "unsigned"  => Ok ( Self :: UInt ) , 
34+             "char"  => Ok ( Self :: Char ( true ) ) , 
35+             "uint"  | "unsigned"  => Ok ( Self :: Int ( false ) ) , 
3136            "void"  => Ok ( Self :: Void ) , 
3237            _ => Err ( format ! ( "Impossible to parse argument kind {s}" ) ) , 
3338        } 
@@ -42,10 +47,15 @@ impl fmt::Display for TypeKind {
4247            match  self  { 
4348                Self :: BFloat  => "bfloat" , 
4449                Self :: Float  => "float" , 
45-                 Self :: Int  => "int" , 
46-                 Self :: UInt  => "uint" , 
50+                 Self :: Double  => "double" , 
51+                 Self :: Int ( true )  => "int" , 
52+                 Self :: Int ( false )  => "uint" , 
4753                Self :: Poly  => "poly" , 
4854                Self :: Void  => "void" , 
55+                 Self :: Char ( true )  => "char" , 
56+                 Self :: Char ( false )  => "unsigned char" , 
57+                 Self :: Short ( true )  => "short" , 
58+                 Self :: Short ( false )  => "unsigned short" , 
4959            } 
5060        ) 
5161    } 
@@ -56,9 +66,11 @@ impl TypeKind {
5666     pub  fn  c_prefix ( & self )  -> & str  { 
5767        match  self  { 
5868            Self :: Float  => "float" , 
59-             Self :: Int  => "int" , 
60-             Self :: UInt  => "uint" , 
69+             Self :: Int ( true )  => "int" , 
70+             Self :: Int ( false )  => "uint" , 
6171            Self :: Poly  => "poly" , 
72+             Self :: Char ( true )  => "char" , 
73+             Self :: Char ( false )  => "unsigned char" , 
6274            _ => unreachable ! ( "Not used: {:#?}" ,  self ) , 
6375        } 
6476    } 
@@ -67,8 +79,8 @@ impl TypeKind {
6779     pub  fn  rust_prefix ( & self )  -> & str  { 
6880        match  self  { 
6981            Self :: Float  => "f" , 
70-             Self :: Int  => "i" , 
71-             Self :: UInt  => "u" , 
82+             Self :: Int ( true )  => "i" , 
83+             Self :: Int ( false )  => "u" , 
7284            Self :: Poly  => "u" , 
7385            _ => unreachable ! ( "Unused type kind: {:#?}" ,  self ) , 
7486        } 
@@ -132,6 +144,18 @@ impl IntrinsicType {
132144        self . ptr 
133145    } 
134146
147+     pub  fn  set_bit_len ( & mut  self ,  value :  Option < u32 > )  { 
148+         self . bit_len  = value; 
149+     } 
150+ 
151+     pub  fn  set_simd_len ( & mut  self ,  value :  Option < u32 > )  { 
152+         self . simd_len  = value; 
153+     } 
154+ 
155+     pub  fn  set_vec_len ( & mut  self ,  value :  Option < u32 > )  { 
156+         self . vec_len  = value; 
157+     } 
158+ 
135159    pub  fn  c_scalar_type ( & self )  -> String  { 
136160        format ! ( 
137161            "{prefix}{bits}_t" , 
@@ -155,8 +179,8 @@ impl IntrinsicType {
155179                bit_len :  Some ( 8 ) , 
156180                ..
157181            }  => match  kind { 
158-                 TypeKind :: Int  => "(int)" , 
159-                 TypeKind :: UInt  => "(unsigned int)" , 
182+                 TypeKind :: Int ( true )  => "(int)" , 
183+                 TypeKind :: Int ( false )  => "(unsigned int)" , 
160184                TypeKind :: Poly  => "(unsigned int)(uint8_t)" , 
161185                _ => "" , 
162186            } , 
@@ -185,7 +209,7 @@ impl IntrinsicType {
185209        match  self  { 
186210            IntrinsicType  { 
187211                bit_len :  Some ( bit_len @ ( 8  | 16  | 32  | 64 ) ) , 
188-                 kind :  kind @ ( TypeKind :: Int  |  TypeKind :: UInt  | TypeKind :: Poly ) , 
212+                 kind :  kind @ ( TypeKind :: Int ( _ )  | TypeKind :: Poly ) , 
189213                simd_len, 
190214                vec_len, 
191215                ..
@@ -201,7 +225,7 @@ impl IntrinsicType {
201225                        . format_with( ",\n " ,  |i,  fmt| { 
202226                            let  src = value_for_array( * bit_len,  i) ; 
203227                            assert!( src == 0  || src. ilog2( )  < * bit_len) ; 
204-                             if  * kind == TypeKind :: Int  && ( src >> ( * bit_len - 1 ) )  != 0  { 
228+                             if  * kind == TypeKind :: Int ( true )  && ( src >> ( * bit_len - 1 ) )  != 0  { 
205229                                // `src` is a two's complement representation of a negative value. 
206230                                let  mask = !0u64  >> ( 64  - * bit_len) ; 
207231                                let  ones_compl = src ^ mask; 
@@ -257,7 +281,7 @@ impl IntrinsicType {
257281                ..
258282            }  => false , 
259283            IntrinsicType  { 
260-                 kind :  TypeKind :: Int  |  TypeKind :: UInt  | TypeKind :: Poly , 
284+                 kind :  TypeKind :: Int ( _ )  | TypeKind :: Poly , 
261285                ..
262286            }  => true , 
263287            _ => unimplemented ! ( ) , 
0 commit comments