@@ -16,7 +16,7 @@ struct Function {
16
16
name : & ' static str ,
17
17
arguments : & ' static [ & ' static Type ] ,
18
18
ret : Option < & ' static Type > ,
19
- target_feature : & ' static str ,
19
+ target_feature : Option < & ' static str > ,
20
20
instrs : & ' static [ & ' static str ] ,
21
21
file : & ' static str ,
22
22
}
@@ -41,6 +41,9 @@ static M256: Type = Type::M256;
41
41
static M256I : Type = Type :: M256I ;
42
42
static M256D : Type = Type :: M256D ;
43
43
44
+ static TUPLE : Type = Type :: Tuple ;
45
+ static CPUID : Type = Type :: CpuidResult ;
46
+
44
47
#[ derive( Debug ) ]
45
48
enum Type {
46
49
PrimFloat ( u8 ) ,
@@ -55,6 +58,8 @@ enum Type {
55
58
M256D ,
56
59
M256I ,
57
60
Bool ,
61
+ Tuple ,
62
+ CpuidResult ,
58
63
}
59
64
60
65
x86_functions ! ( static FUNCTIONS ) ;
@@ -84,6 +89,23 @@ struct Instruction {
84
89
name : String ,
85
90
}
86
91
92
+ fn skip_intrinsic ( name : & str ) -> bool {
93
+ match name {
94
+ // This intrinsic has multiple definitions in the XML, so just
95
+ // ignore it.
96
+ "_mm_prefetch" => true ,
97
+
98
+ // FIXME(#307)
99
+ "__readeflags" |
100
+ "__writeeflags" => true ,
101
+ "__cpuid_count" => true ,
102
+ "__cpuid" => true ,
103
+ "__get_cpuid_max" => true ,
104
+
105
+ _ => false ,
106
+ }
107
+ }
108
+
87
109
#[ test]
88
110
fn verify_all_signatures ( ) {
89
111
// This XML document was downloaded from Intel's site. To update this you
@@ -101,10 +123,8 @@ fn verify_all_signatures() {
101
123
serde_xml_rs:: deserialize ( xml) . expect ( "failed to deserialize xml" ) ;
102
124
let mut map = HashMap :: new ( ) ;
103
125
for intrinsic in & data. intrinsics {
104
- // This intrinsic has multiple definitions in the XML, so just ignore
105
- // it.
106
- if intrinsic. name == "_mm_prefetch" {
107
- continue ;
126
+ if skip_intrinsic ( & intrinsic. name ) {
127
+ continue
108
128
}
109
129
110
130
// These'll need to get added eventually, but right now they have some
@@ -117,16 +137,15 @@ fn verify_all_signatures() {
117
137
}
118
138
119
139
for rust in FUNCTIONS {
120
- // This was ignored above, we ignore it here as well.
121
- if rust. name == "_mm_prefetch" {
140
+ if skip_intrinsic ( & rust. name ) {
122
141
continue ;
123
142
}
124
143
125
144
// these are all AMD-specific intrinsics
126
- if rust. target_feature . contains ( "sse4a" )
127
- || rust . target_feature . contains ( "tbm" )
128
- {
129
- continue ;
145
+ if let Some ( feature ) = rust. target_feature {
146
+ if feature . contains ( "sse4a" ) || feature . contains ( "tbm" ) {
147
+ continue ;
148
+ }
130
149
}
131
150
132
151
let intel = match map. get ( rust. name ) {
@@ -137,14 +156,25 @@ fn verify_all_signatures() {
137
156
// Verify that all `#[target_feature]` annotations are correct,
138
157
// ensuring that we've actually enabled the right instruction
139
158
// set for this intrinsic.
140
- assert ! ( !intel. cpuid. is_empty( ) , "missing cpuid for {}" , rust. name) ;
159
+ match rust. name {
160
+ "_bswap" => { }
161
+ "_bswap64" => { }
162
+ _ => {
163
+ assert ! ( !intel. cpuid. is_empty( ) , "missing cpuid for {}" , rust. name) ;
164
+ }
165
+ }
141
166
for cpuid in & intel. cpuid {
142
167
// this is needed by _xsave and probably some related intrinsics,
143
168
// but let's just skip it for now.
144
169
if * cpuid == "XSS" {
145
170
continue ;
146
171
}
147
172
173
+ // FIXME(#308)
174
+ if * cpuid == "TSC" || * cpuid == "RDTSCP" {
175
+ continue ;
176
+ }
177
+
148
178
let cpuid = cpuid
149
179
. chars ( )
150
180
. flat_map ( |c| c. to_lowercase ( ) )
@@ -158,11 +188,13 @@ fn verify_all_signatures() {
158
188
cpuid
159
189
} ;
160
190
191
+ let rust_feature = rust. target_feature
192
+ . expect ( & format ! ( "no target feature listed for {}" , rust. name) ) ;
161
193
assert ! (
162
- rust . target_feature . contains( & cpuid) ,
194
+ rust_feature . contains( & cpuid) ,
163
195
"intel cpuid `{}` not in `{}` for {}" ,
164
196
cpuid,
165
- rust . target_feature ,
197
+ rust_feature ,
166
198
rust. name
167
199
) ;
168
200
}
@@ -228,8 +260,6 @@ fn verify_all_signatures() {
228
260
match * arg {
229
261
Type :: PrimSigned ( 64 ) |
230
262
Type :: PrimUnsigned ( 64 ) => true ,
231
- // Type::Ptr(&Type::PrimSigned(64)) |
232
- // Type::Ptr(&Type::PrimUnsigned(64)) => true,
233
263
_ => false ,
234
264
}
235
265
} ) ;
@@ -254,6 +284,10 @@ fn verify_all_signatures() {
254
284
"_mm256_setr_epi64x" |
255
285
"_mm256_set1_epi64x" => true ,
256
286
287
+ // FIXME(#308)
288
+ "_rdtsc" |
289
+ "__rdtscp" => true ,
290
+
257
291
_ => false ,
258
292
} ;
259
293
if any_i64 && !any_i64_exempt {
0 commit comments