1+ use std:: collections:: HashMap ;
12use std:: fmt;
23use std:: ops:: Deref ;
34use std:: str:: FromStr ;
@@ -18,21 +19,22 @@ pub enum TypeKind {
1819 Char ( bool ) ,
1920 Poly ,
2021 Void ,
22+ Mask ,
2123}
2224
2325impl FromStr for TypeKind {
2426 type Err = String ;
2527
2628 fn from_str ( s : & str ) -> Result < Self , Self :: Err > {
2729 match s {
28- "bfloat" => Ok ( Self :: BFloat ) ,
29- "float" => Ok ( Self :: Float ) ,
30- "double" => Ok ( Self :: Float ) ,
31- "int" | "long" | "short" => Ok ( Self :: Int ( true ) ) ,
30+ "bfloat" | "BF16" => Ok ( Self :: BFloat ) ,
31+ "float" | "double" | "FP16" | "FP32" | "FP64" => Ok ( Self :: Float ) ,
32+ "int" | "long" | "short" | "SI8" | "SI16" | "SI32" | "SI64" => Ok ( Self :: Int ( true ) ) ,
3233 "poly" => Ok ( Self :: Poly ) ,
3334 "char" => Ok ( Self :: Char ( true ) ) ,
34- "uint" | "unsigned" => Ok ( Self :: Int ( false ) ) ,
35+ "uint" | "unsigned" | "UI8" | "UI16" | "UI32" | "UI64" => Ok ( Self :: Int ( false ) ) ,
3536 "void" => Ok ( Self :: Void ) ,
37+ "MASK" => Ok ( Self :: Mask ) ,
3638 _ => Err ( format ! ( "Impossible to parse argument kind {s}" ) ) ,
3739 }
3840 }
@@ -52,6 +54,7 @@ impl fmt::Display for TypeKind {
5254 Self :: Void => "void" ,
5355 Self :: Char ( true ) => "char" ,
5456 Self :: Char ( false ) => "unsigned char" ,
57+ Self :: Mask => "mask" ,
5558 }
5659 )
5760 }
@@ -107,7 +110,8 @@ pub struct IntrinsicType {
107110 /// A value of `None` can be assumed to be 1 though.
108111 pub vec_len : Option < u32 > ,
109112
110- pub target : String ,
113+ // pub target: String,
114+ pub metadata : HashMap < String , String > ,
111115}
112116
113117impl IntrinsicType {
@@ -151,6 +155,10 @@ impl IntrinsicType {
151155 self . vec_len = value;
152156 }
153157
158+ pub fn set_metadata ( & mut self , key : String , value : String ) {
159+ self . metadata . insert ( key, value) ;
160+ }
161+
154162 pub fn c_scalar_type ( & self ) -> String {
155163 match self {
156164 IntrinsicType {
@@ -322,7 +330,7 @@ pub trait IntrinsicTypeDefinition: Deref<Target = IntrinsicType> {
322330 fn get_lane_function ( & self ) -> String ;
323331
324332 /// can be implemented in an `impl` block
325- fn from_c ( _s : & str , _target : & String ) -> Result < Self , String >
333+ fn from_c ( _s : & str ) -> Result < Self , String >
326334 where
327335 Self : Sized ;
328336
0 commit comments