@@ -6,22 +6,13 @@ use crate::common::intrinsic_helpers::{IntrinsicType, IntrinsicTypeDefinition, T
6
6
7
7
impl IntrinsicTypeDefinition for ArmIntrinsicType {
8
8
/// 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
9
11
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 ( )
25
16
}
26
17
27
18
fn c_single_vector_type ( & self ) -> String {
@@ -129,6 +120,8 @@ impl IntrinsicTypeDefinition for ArmIntrinsicType {
129
120
130
121
fn from_c ( s : & str ) -> Result < Self , String > {
131
122
const CONST_STR : & str = "const" ;
123
+ let mut metadata: HashMap < String , String > = HashMap :: new ( ) ;
124
+ metadata. insert ( "type" . to_string ( ) , s. to_string ( ) ) ;
132
125
if let Some ( s) = s. strip_suffix ( '*' ) {
133
126
let ( s, constant) = match s. trim ( ) . strip_suffix ( CONST_STR ) {
134
127
Some ( stripped) => ( stripped, true ) ,
@@ -176,7 +169,7 @@ impl IntrinsicTypeDefinition for ArmIntrinsicType {
176
169
bit_len : Some ( bit_len) ,
177
170
simd_len,
178
171
vec_len,
179
- metadata : HashMap :: new ( ) ,
172
+ metadata,
180
173
} ) )
181
174
} else {
182
175
let kind = start. parse :: < TypeKind > ( ) ?;
@@ -192,7 +185,7 @@ impl IntrinsicTypeDefinition for ArmIntrinsicType {
192
185
bit_len,
193
186
simd_len : None ,
194
187
vec_len : None ,
195
- metadata : HashMap :: new ( ) ,
188
+ metadata,
196
189
} ) )
197
190
}
198
191
}
0 commit comments