Skip to content

Commit

Permalink
support never type in stdsimd-verify and white-list ud2 intrinsic
Browse files Browse the repository at this point in the history
  • Loading branch information
gnzlbg committed Nov 11, 2018
1 parent 7c93a23 commit e020398
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 9 deletions.
3 changes: 2 additions & 1 deletion crates/stdsimd-verify/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ fn to_type(t: &syn::Type) -> proc_macro2::TokenStream {
"u64" => quote! { &U64 },
"u8" => quote! { &U8 },
"CpuidResult" => quote! { &CPUID },
s => panic!("unspported type: {}", s),
s => panic!("unspported type: \"{}\"", s),
}
}
syn::Type::Ptr(syn::TypePtr { ref elem, .. })
Expand All @@ -124,6 +124,7 @@ fn to_type(t: &syn::Type) -> proc_macro2::TokenStream {
syn::Type::Slice(_) => panic!("unsupported slice"),
syn::Type::Array(_) => panic!("unsupported array"),
syn::Type::Tuple(_) => quote! { &TUPLE },
syn::Type::Never(_) => quote! { &NEVER },
_ => panic!("unsupported type"),
}
}
Expand Down
24 changes: 16 additions & 8 deletions crates/stdsimd-verify/tests/x86-intel.rs
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@ static M256D: Type = Type::M256D;

static TUPLE: Type = Type::Tuple;
static CPUID: Type = Type::CpuidResult;
static NEVER: Type = Type::Never;

#[derive(Debug)]
enum Type {
Expand All @@ -73,6 +74,7 @@ enum Type {
M256I,
Tuple,
CpuidResult,
Never,
}

x86_functions!(static FUNCTIONS);
Expand Down Expand Up @@ -135,14 +137,20 @@ fn verify_all_signatures() {
let mut all_valid = true;
'outer: for rust in FUNCTIONS {
match rust.name {
// These aren't defined by Intel but they're defined by what
// appears to be all other compilers. For more
// information see rust-lang-nursery/stdsimd#307, and
// otherwise these signatures have all been manually
// verified.
"__readeflags" | "__writeeflags" | "__cpuid_count" | "__cpuid"
| "__get_cpuid_max" => continue,

// These aren't defined by Intel but they're defined by what appears
// to be all other compilers. For more information see
// rust-lang-nursery/stdsimd#307, and otherwise these signatures
// have all been manually verified.
"__readeflags" |
"__writeeflags" |
"__cpuid_count" |
"__cpuid" |
"__get_cpuid_max" |
// The UD2 intrinsic is not defined by Intel, but it was agreed on
// in the RFC Issue 2512:
// https://github.com/rust-lang/rfcs/issues/2512
"ud2"
=> continue,
_ => {}
}

Expand Down

0 comments on commit e020398

Please sign in to comment.