@@ -6,22 +6,13 @@ use crate::common::intrinsic_helpers::{IntrinsicType, IntrinsicTypeDefinition, T
66
77impl  IntrinsicTypeDefinition  for  ArmIntrinsicType  { 
88    /// Gets a string containing the typename for this type in C format. 
9+      /// This assumes that the metadata hashmap contains this value at the 
10+      /// "type" key 
911     fn  c_type ( & self )  -> String  { 
10-         let  prefix = self . 0 . kind . c_prefix ( ) ; 
11-         let  const_prefix = if  self . 0 . constant  {  "const "  }  else  {  ""  } ; 
12- 
13-         if  let  ( Some ( bit_len) ,  simd_len,  vec_len)  =
14-             ( self . 0 . bit_len ,  self . 0 . simd_len ,  self . 0 . vec_len ) 
15-         { 
16-             match  ( simd_len,  vec_len)  { 
17-                 ( None ,  None )  => format ! ( "{const_prefix}{prefix}{bit_len}_t" ) , 
18-                 ( Some ( simd) ,  None )  => format ! ( "{prefix}{bit_len}x{simd}_t" ) , 
19-                 ( Some ( simd) ,  Some ( vec) )  => format ! ( "{prefix}{bit_len}x{simd}x{vec}_t" ) , 
20-                 ( None ,  Some ( _) )  => todo ! ( "{:#?}" ,  self ) ,  // Likely an invalid case 
21-             } 
22-         }  else  { 
23-             todo ! ( "{:#?}" ,  self ) 
24-         } 
12+         self . metadata 
13+             . get ( "type" ) 
14+             . expect ( "Failed to extract the C typename in Aarch!" ) 
15+             . to_string ( ) 
2516    } 
2617
2718    fn  c_single_vector_type ( & self )  -> String  { 
@@ -129,6 +120,8 @@ impl IntrinsicTypeDefinition for ArmIntrinsicType {
129120
130121    fn  from_c ( s :  & str )  -> Result < Self ,  String >  { 
131122        const  CONST_STR :  & str  = "const" ; 
123+         let  mut  metadata:  HashMap < String ,  String >  = HashMap :: new ( ) ; 
124+         metadata. insert ( "type" . to_string ( ) ,  s. to_string ( ) ) ; 
132125        if  let  Some ( s)  = s. strip_suffix ( '*' )  { 
133126            let  ( s,  constant)  = match  s. trim ( ) . strip_suffix ( CONST_STR )  { 
134127                Some ( stripped)  => ( stripped,  true ) , 
@@ -176,7 +169,7 @@ impl IntrinsicTypeDefinition for ArmIntrinsicType {
176169                    bit_len :  Some ( bit_len) , 
177170                    simd_len, 
178171                    vec_len, 
179-                     metadata :   HashMap :: new ( ) , 
172+                     metadata, 
180173                } ) ) 
181174            }  else  { 
182175                let  kind = start. parse :: < TypeKind > ( ) ?; 
@@ -192,7 +185,7 @@ impl IntrinsicTypeDefinition for ArmIntrinsicType {
192185                    bit_len, 
193186                    simd_len :  None , 
194187                    vec_len :  None , 
195-                     metadata :   HashMap :: new ( ) , 
188+                     metadata, 
196189                } ) ) 
197190            } 
198191        } 
0 commit comments