2017-12-29 11:52:27 -06:00
|
|
|
#![allow(bad_style)]
|
2019-07-09 00:23:00 +02:00
|
|
|
#![allow(unused)]
|
2018-12-20 14:11:26 -06:00
|
|
|
#![allow(
|
|
|
|
|
clippy::shadow_reuse,
|
|
|
|
|
clippy::cast_lossless,
|
|
|
|
|
clippy::match_same_arms,
|
|
|
|
|
clippy::nonminimal_bool,
|
|
|
|
|
clippy::print_stdout,
|
|
|
|
|
clippy::use_debug,
|
|
|
|
|
clippy::eq_op,
|
|
|
|
|
clippy::useless_format
|
2018-06-06 00:17:14 +02:00
|
|
|
)]
|
2017-12-29 11:52:27 -06:00
|
|
|
|
2018-02-02 16:08:27 +01:00
|
|
|
use std::collections::{BTreeMap, HashMap};
|
2017-12-29 11:52:27 -06:00
|
|
|
|
2018-12-20 14:11:26 -06:00
|
|
|
use serde::Deserialize;
|
2017-12-29 11:52:27 -06:00
|
|
|
|
2018-01-29 08:27:46 -08:00
|
|
|
const PRINT_INSTRUCTION_VIOLATIONS: bool = false;
|
|
|
|
|
const PRINT_MISSING_LISTS: bool = false;
|
|
|
|
|
const PRINT_MISSING_LISTS_MARKDOWN: bool = false;
|
|
|
|
|
|
2017-12-29 11:52:27 -06:00
|
|
|
struct Function {
|
|
|
|
|
name: &'static str,
|
|
|
|
|
arguments: &'static [&'static Type],
|
|
|
|
|
ret: Option<&'static Type>,
|
2018-01-28 23:59:44 -06:00
|
|
|
target_feature: Option<&'static str>,
|
2017-12-29 11:52:27 -06:00
|
|
|
instrs: &'static [&'static str],
|
2018-01-28 22:31:31 -06:00
|
|
|
file: &'static str,
|
2018-02-11 10:24:33 -06:00
|
|
|
required_const: &'static [usize],
|
2019-08-17 21:14:54 +02:00
|
|
|
has_test: bool,
|
2017-12-29 11:52:27 -06:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static F32: Type = Type::PrimFloat(32);
|
|
|
|
|
static F64: Type = Type::PrimFloat(64);
|
2020-11-22 10:10:25 -05:00
|
|
|
static I8: Type = Type::PrimSigned(8);
|
2017-12-29 11:52:27 -06:00
|
|
|
static I16: Type = Type::PrimSigned(16);
|
|
|
|
|
static I32: Type = Type::PrimSigned(32);
|
|
|
|
|
static I64: Type = Type::PrimSigned(64);
|
2020-11-22 10:10:25 -05:00
|
|
|
static U8: Type = Type::PrimUnsigned(8);
|
2017-12-29 11:52:27 -06:00
|
|
|
static U16: Type = Type::PrimUnsigned(16);
|
|
|
|
|
static U32: Type = Type::PrimUnsigned(32);
|
|
|
|
|
static U64: Type = Type::PrimUnsigned(64);
|
2018-12-14 13:28:23 -06:00
|
|
|
static U128: Type = Type::PrimUnsigned(128);
|
|
|
|
|
static ORDERING: Type = Type::Ordering;
|
2018-01-19 12:11:21 -06:00
|
|
|
|
|
|
|
|
static M64: Type = Type::M64;
|
|
|
|
|
static M128: Type = Type::M128;
|
|
|
|
|
static M128I: Type = Type::M128I;
|
|
|
|
|
static M128D: Type = Type::M128D;
|
|
|
|
|
static M256: Type = Type::M256;
|
|
|
|
|
static M256I: Type = Type::M256I;
|
|
|
|
|
static M256D: Type = Type::M256D;
|
2018-12-14 09:44:26 -06:00
|
|
|
static M512: Type = Type::M512;
|
|
|
|
|
static M512I: Type = Type::M512I;
|
|
|
|
|
static M512D: Type = Type::M512D;
|
2020-05-27 22:35:36 +00:00
|
|
|
static MMASK8: Type = Type::MMASK8;
|
2018-12-14 09:44:26 -06:00
|
|
|
static MMASK16: Type = Type::MMASK16;
|
2020-11-22 10:10:25 -05:00
|
|
|
static MMASK32: Type = Type::MMASK32;
|
|
|
|
|
static MMASK64: Type = Type::MMASK64;
|
2020-06-16 12:49:21 -04:00
|
|
|
static MM_CMPINT_ENUM: Type = Type::MM_CMPINT_ENUM;
|
2020-09-11 17:26:39 -04:00
|
|
|
static MM_MANTISSA_NORM_ENUM: Type = Type::MM_MANTISSA_NORM_ENUM;
|
|
|
|
|
static MM_MANTISSA_SIGN_ENUM: Type = Type::MM_MANTISSA_SIGN_ENUM;
|
2020-09-19 17:16:01 -04:00
|
|
|
static MM_PERM_ENUM: Type = Type::MM_PERM_ENUM;
|
2017-12-29 11:52:27 -06:00
|
|
|
|
2018-01-28 23:59:44 -06:00
|
|
|
static TUPLE: Type = Type::Tuple;
|
|
|
|
|
static CPUID: Type = Type::CpuidResult;
|
2018-11-11 13:03:08 +01:00
|
|
|
static NEVER: Type = Type::Never;
|
2018-01-28 23:59:44 -06:00
|
|
|
|
2017-12-29 11:52:27 -06:00
|
|
|
#[derive(Debug)]
|
|
|
|
|
enum Type {
|
|
|
|
|
PrimFloat(u8),
|
|
|
|
|
PrimSigned(u8),
|
|
|
|
|
PrimUnsigned(u8),
|
2019-04-26 09:04:41 +02:00
|
|
|
MutPtr(&'static Type),
|
|
|
|
|
ConstPtr(&'static Type),
|
2018-01-19 12:11:21 -06:00
|
|
|
M64,
|
|
|
|
|
M128,
|
|
|
|
|
M128D,
|
|
|
|
|
M128I,
|
|
|
|
|
M256,
|
|
|
|
|
M256D,
|
|
|
|
|
M256I,
|
2018-12-14 09:44:26 -06:00
|
|
|
M512,
|
|
|
|
|
M512D,
|
|
|
|
|
M512I,
|
2020-05-27 22:35:36 +00:00
|
|
|
MMASK8,
|
2018-12-14 09:44:26 -06:00
|
|
|
MMASK16,
|
2020-11-22 10:10:25 -05:00
|
|
|
MMASK32,
|
|
|
|
|
MMASK64,
|
2020-06-16 12:49:21 -04:00
|
|
|
MM_CMPINT_ENUM,
|
2020-09-11 17:26:39 -04:00
|
|
|
MM_MANTISSA_NORM_ENUM,
|
|
|
|
|
MM_MANTISSA_SIGN_ENUM,
|
2020-09-19 17:16:01 -04:00
|
|
|
MM_PERM_ENUM,
|
2018-01-28 23:59:44 -06:00
|
|
|
Tuple,
|
|
|
|
|
CpuidResult,
|
2018-11-11 13:03:08 +01:00
|
|
|
Never,
|
2018-12-14 13:28:23 -06:00
|
|
|
Ordering,
|
2017-12-29 11:52:27 -06:00
|
|
|
}
|
|
|
|
|
|
2019-07-08 23:21:37 +02:00
|
|
|
stdarch_verify::x86_functions!(static FUNCTIONS);
|
2017-12-29 11:52:27 -06:00
|
|
|
|
|
|
|
|
#[derive(Deserialize)]
|
|
|
|
|
struct Data {
|
2018-02-02 16:08:27 +01:00
|
|
|
#[serde(rename = "intrinsic", default)]
|
|
|
|
|
intrinsics: Vec<Intrinsic>,
|
2017-12-29 11:52:27 -06:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#[derive(Deserialize)]
|
|
|
|
|
struct Intrinsic {
|
2020-06-09 11:27:10 +02:00
|
|
|
#[serde(rename = "return")]
|
|
|
|
|
return_: Return,
|
2017-12-29 11:52:27 -06:00
|
|
|
name: String,
|
2018-02-02 16:08:27 +01:00
|
|
|
#[serde(rename = "CPUID", default)]
|
|
|
|
|
cpuid: Vec<String>,
|
|
|
|
|
#[serde(rename = "parameter", default)]
|
|
|
|
|
parameters: Vec<Parameter>,
|
|
|
|
|
#[serde(default)]
|
|
|
|
|
instruction: Vec<Instruction>,
|
2017-12-29 11:52:27 -06:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#[derive(Deserialize)]
|
|
|
|
|
struct Parameter {
|
2018-02-02 16:08:27 +01:00
|
|
|
#[serde(rename = "type")]
|
|
|
|
|
type_: String,
|
2017-12-29 11:52:27 -06:00
|
|
|
}
|
|
|
|
|
|
2020-06-09 11:27:10 +02:00
|
|
|
#[derive(Deserialize)]
|
|
|
|
|
struct Return {
|
|
|
|
|
#[serde(rename = "type")]
|
|
|
|
|
type_: String,
|
|
|
|
|
}
|
|
|
|
|
|
2018-01-02 12:28:48 -08:00
|
|
|
#[derive(Deserialize, Debug)]
|
2017-12-29 11:52:27 -06:00
|
|
|
struct Instruction {
|
|
|
|
|
name: String,
|
|
|
|
|
}
|
|
|
|
|
|
2018-01-29 08:27:46 -08:00
|
|
|
macro_rules! bail {
|
|
|
|
|
($($t:tt)*) => (return Err(format!($($t)*)))
|
2018-01-28 23:59:44 -06:00
|
|
|
}
|
|
|
|
|
|
2017-12-29 11:52:27 -06:00
|
|
|
#[test]
|
|
|
|
|
fn verify_all_signatures() {
|
|
|
|
|
// This XML document was downloaded from Intel's site. To update this you
|
|
|
|
|
// can visit intel's intrinsics guide online documentation:
|
|
|
|
|
//
|
|
|
|
|
// https://software.intel.com/sites/landingpage/IntrinsicsGuide/#
|
|
|
|
|
//
|
|
|
|
|
// Open up the network console and you'll see an xml file was downloaded
|
|
|
|
|
// (currently called data-3.4.xml). That's the file we downloaded
|
|
|
|
|
// here.
|
|
|
|
|
let xml = include_bytes!("../x86-intel.xml");
|
|
|
|
|
|
|
|
|
|
let xml = &xml[..];
|
2019-01-21 15:25:39 +01:00
|
|
|
let data: Data = serde_xml_rs::from_reader(xml).expect("failed to deserialize xml");
|
2017-12-29 11:52:27 -06:00
|
|
|
let mut map = HashMap::new();
|
2018-01-04 17:15:23 +01:00
|
|
|
for intrinsic in &data.intrinsics {
|
2018-02-02 16:08:27 +01:00
|
|
|
map.entry(&intrinsic.name[..])
|
|
|
|
|
.or_insert_with(Vec::new)
|
|
|
|
|
.push(intrinsic);
|
2017-12-29 11:52:27 -06:00
|
|
|
}
|
|
|
|
|
|
2018-01-29 08:27:46 -08:00
|
|
|
let mut all_valid = true;
|
2018-02-02 16:08:27 +01:00
|
|
|
'outer: for rust in FUNCTIONS {
|
2019-08-17 21:14:54 +02:00
|
|
|
if !rust.has_test {
|
|
|
|
|
// FIXME: this list should be almost empty
|
|
|
|
|
let skip = [
|
|
|
|
|
"__readeflags",
|
|
|
|
|
"__readeflags",
|
|
|
|
|
"__writeeflags",
|
|
|
|
|
"__writeeflags",
|
|
|
|
|
"_mm_comige_ss",
|
|
|
|
|
"_mm_cvt_ss2si",
|
|
|
|
|
"_mm_cvtt_ss2si",
|
|
|
|
|
"_mm_cvt_si2ss",
|
|
|
|
|
"_mm_set_ps1",
|
|
|
|
|
"_mm_load_ps1",
|
|
|
|
|
"_mm_store_ps1",
|
|
|
|
|
"_mm_getcsr",
|
|
|
|
|
"_mm_setcsr",
|
|
|
|
|
"_MM_GET_EXCEPTION_MASK",
|
|
|
|
|
"_MM_GET_EXCEPTION_STATE",
|
|
|
|
|
"_MM_GET_FLUSH_ZERO_MODE",
|
|
|
|
|
"_MM_GET_ROUNDING_MODE",
|
|
|
|
|
"_MM_SET_EXCEPTION_MASK",
|
|
|
|
|
"_MM_SET_EXCEPTION_STATE",
|
|
|
|
|
"_MM_SET_FLUSH_ZERO_MODE",
|
|
|
|
|
"_MM_SET_ROUNDING_MODE",
|
|
|
|
|
"_mm_prefetch",
|
|
|
|
|
"_mm_undefined_ps",
|
|
|
|
|
"_m_pmaxsw",
|
|
|
|
|
"_m_pmaxub",
|
|
|
|
|
"_m_pminsw",
|
|
|
|
|
"_m_pminub",
|
|
|
|
|
"_m_pavgb",
|
|
|
|
|
"_m_pavgw",
|
|
|
|
|
"_m_psadbw",
|
|
|
|
|
"_mm_cvt_pi2ps",
|
|
|
|
|
"_m_maskmovq",
|
|
|
|
|
"_m_pextrw",
|
|
|
|
|
"_m_pinsrw",
|
|
|
|
|
"_m_pmovmskb",
|
|
|
|
|
"_m_pshufw",
|
|
|
|
|
"_mm_cvtt_ps2pi",
|
|
|
|
|
"_mm_cvt_ps2pi",
|
|
|
|
|
"__cpuid_count",
|
|
|
|
|
"__cpuid",
|
|
|
|
|
"__get_cpuid_max",
|
|
|
|
|
"_xsave",
|
|
|
|
|
"_xrstor",
|
|
|
|
|
"_xsetbv",
|
|
|
|
|
"_xgetbv",
|
|
|
|
|
"_xsaveopt",
|
|
|
|
|
"_xsavec",
|
|
|
|
|
"_xsaves",
|
|
|
|
|
"_xrstors",
|
|
|
|
|
"_mm_bslli_si128",
|
|
|
|
|
"_mm_bsrli_si128",
|
|
|
|
|
"_mm_undefined_pd",
|
|
|
|
|
"_mm_undefined_si128",
|
|
|
|
|
"_mm_cvtps_ph",
|
|
|
|
|
"_mm256_cvtps_ph",
|
|
|
|
|
"_rdtsc",
|
|
|
|
|
"__rdtscp",
|
|
|
|
|
"_mm256_castps128_ps256",
|
|
|
|
|
"_mm256_castpd128_pd256",
|
|
|
|
|
"_mm256_castsi128_si256",
|
|
|
|
|
"_mm256_undefined_ps",
|
|
|
|
|
"_mm256_undefined_pd",
|
|
|
|
|
"_mm256_undefined_si256",
|
|
|
|
|
"_bextr2_u32",
|
|
|
|
|
"_mm_tzcnt_32",
|
|
|
|
|
"_m_paddb",
|
|
|
|
|
"_m_paddw",
|
|
|
|
|
"_m_paddd",
|
|
|
|
|
"_m_paddsb",
|
|
|
|
|
"_m_paddsw",
|
|
|
|
|
"_m_paddusb",
|
|
|
|
|
"_m_paddusw",
|
|
|
|
|
"_m_psubb",
|
|
|
|
|
"_m_psubw",
|
|
|
|
|
"_m_psubd",
|
|
|
|
|
"_m_psubsb",
|
|
|
|
|
"_m_psubsw",
|
|
|
|
|
"_m_psubusb",
|
|
|
|
|
"_m_psubusw",
|
|
|
|
|
"_mm_set_pi16",
|
|
|
|
|
"_mm_set_pi32",
|
|
|
|
|
"_mm_set_pi8",
|
|
|
|
|
"_mm_set1_pi16",
|
|
|
|
|
"_mm_set1_pi32",
|
|
|
|
|
"_mm_set1_pi8",
|
|
|
|
|
"_mm_setr_pi16",
|
|
|
|
|
"_mm_setr_pi32",
|
|
|
|
|
"_mm_setr_pi8",
|
|
|
|
|
"ud2",
|
|
|
|
|
"_mm_min_epi8",
|
|
|
|
|
"_mm_min_epi32",
|
|
|
|
|
"_xbegin",
|
|
|
|
|
"_xend",
|
|
|
|
|
"_rdrand16_step",
|
|
|
|
|
"_rdrand32_step",
|
|
|
|
|
"_rdseed16_step",
|
|
|
|
|
"_rdseed32_step",
|
|
|
|
|
"_fxsave",
|
|
|
|
|
"_fxrstor",
|
|
|
|
|
"_t1mskc_u64",
|
|
|
|
|
"_mm256_shuffle_epi32",
|
|
|
|
|
"_mm256_bslli_epi128",
|
|
|
|
|
"_mm256_bsrli_epi128",
|
|
|
|
|
"_mm256_unpackhi_epi8",
|
|
|
|
|
"_mm256_unpacklo_epi8",
|
|
|
|
|
"_mm256_unpackhi_epi16",
|
|
|
|
|
"_mm256_unpacklo_epi16",
|
|
|
|
|
"_mm256_unpackhi_epi32",
|
|
|
|
|
"_mm256_unpacklo_epi32",
|
|
|
|
|
"_mm256_unpackhi_epi64",
|
|
|
|
|
"_mm256_unpacklo_epi64",
|
|
|
|
|
"_xsave64",
|
|
|
|
|
"_xrstor64",
|
|
|
|
|
"_xsaveopt64",
|
|
|
|
|
"_xsavec64",
|
|
|
|
|
"_xsaves64",
|
|
|
|
|
"_xrstors64",
|
|
|
|
|
"_mm_cvtsi64x_si128",
|
|
|
|
|
"_mm_cvtsi128_si64x",
|
|
|
|
|
"_mm_cvtsi64x_sd",
|
|
|
|
|
"cmpxchg16b",
|
|
|
|
|
"_rdrand64_step",
|
|
|
|
|
"_rdseed64_step",
|
|
|
|
|
"_bextr2_u64",
|
|
|
|
|
"_mm_tzcnt_64",
|
|
|
|
|
"_fxsave64",
|
|
|
|
|
"_fxrstor64",
|
2020-07-11 11:02:07 +03:00
|
|
|
"_mm512_undefined_ps",
|
|
|
|
|
"_mm512_undefined_pd",
|
2020-10-10 12:14:15 -04:00
|
|
|
"_mm512_undefined_epi32",
|
|
|
|
|
"_mm512_undefined",
|
2019-08-17 21:14:54 +02:00
|
|
|
];
|
|
|
|
|
if !skip.contains(&rust.name) {
|
|
|
|
|
println!(
|
|
|
|
|
"missing run-time test named `test_{}` for `{}`",
|
|
|
|
|
{
|
|
|
|
|
let mut id = rust.name;
|
|
|
|
|
while id.starts_with('_') {
|
|
|
|
|
id = &id[1..];
|
|
|
|
|
}
|
|
|
|
|
id
|
|
|
|
|
},
|
|
|
|
|
rust.name
|
|
|
|
|
);
|
|
|
|
|
all_valid = false;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2018-01-29 08:27:46 -08:00
|
|
|
match rust.name {
|
2018-11-11 13:03:08 +01:00
|
|
|
// These aren't defined by Intel but they're defined by what appears
|
|
|
|
|
// to be all other compilers. For more information see
|
2019-07-08 23:21:37 +02:00
|
|
|
// rust-lang/stdarch#307, and otherwise these signatures
|
2018-11-11 13:03:08 +01:00
|
|
|
// have all been manually verified.
|
|
|
|
|
"__readeflags" |
|
|
|
|
|
"__writeeflags" |
|
|
|
|
|
"__cpuid_count" |
|
|
|
|
|
"__cpuid" |
|
|
|
|
|
"__get_cpuid_max" |
|
2018-12-14 13:28:23 -06:00
|
|
|
// Not listed with intel, but manually verified
|
|
|
|
|
"cmpxchg16b" |
|
2018-11-11 13:03:08 +01:00
|
|
|
// 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,
|
2018-11-03 12:41:02 +01:00
|
|
|
// Intel requires the mask argument for _mm_shuffle_ps to be an
|
|
|
|
|
// unsigned integer, but all other _mm_shuffle_.. intrinsics
|
|
|
|
|
// take a signed-integer. This breaks `_MM_SHUFFLE` for
|
|
|
|
|
// `_mm_shuffle_ps`:
|
|
|
|
|
"_mm_shuffle_ps" => continue,
|
2018-01-29 08:27:46 -08:00
|
|
|
_ => {}
|
2017-12-29 11:52:27 -06:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// these are all AMD-specific intrinsics
|
2018-01-28 23:59:44 -06:00
|
|
|
if let Some(feature) = rust.target_feature {
|
|
|
|
|
if feature.contains("sse4a") || feature.contains("tbm") {
|
|
|
|
|
continue;
|
|
|
|
|
}
|
2017-12-29 11:52:27 -06:00
|
|
|
}
|
|
|
|
|
|
2018-01-29 08:27:46 -08:00
|
|
|
let intel = match map.remove(rust.name) {
|
2017-12-29 11:52:27 -06:00
|
|
|
Some(i) => i,
|
|
|
|
|
None => panic!("missing intel definition for {}", rust.name),
|
|
|
|
|
};
|
|
|
|
|
|
2018-01-29 08:27:46 -08:00
|
|
|
let mut errors = Vec::new();
|
|
|
|
|
for intel in intel {
|
2018-02-02 16:08:27 +01:00
|
|
|
match matches(rust, intel) {
|
2018-01-29 08:27:46 -08:00
|
|
|
Ok(()) => continue 'outer,
|
|
|
|
|
Err(e) => errors.push(e),
|
2018-01-28 23:59:44 -06:00
|
|
|
}
|
|
|
|
|
}
|
2018-01-29 08:27:46 -08:00
|
|
|
println!("failed to verify `{}`", rust.name);
|
|
|
|
|
for error in errors {
|
|
|
|
|
println!(" * {}", error);
|
|
|
|
|
}
|
|
|
|
|
all_valid = false;
|
|
|
|
|
}
|
|
|
|
|
assert!(all_valid);
|
|
|
|
|
|
|
|
|
|
let mut missing = BTreeMap::new();
|
2018-02-02 16:08:27 +01:00
|
|
|
for (name, intel) in &map {
|
2018-01-29 08:27:46 -08:00
|
|
|
// currently focused mainly on missing SIMD intrinsics, but there's
|
|
|
|
|
// definitely some other assorted ones that we're missing.
|
|
|
|
|
if !name.starts_with("_mm") {
|
2018-02-02 16:08:27 +01:00
|
|
|
continue;
|
2018-01-29 08:27:46 -08:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// we'll get to avx-512 later
|
|
|
|
|
// let avx512 = intel.iter().any(|i| {
|
|
|
|
|
// i.name.starts_with("_mm512") || i.cpuid.iter().any(|c| {
|
|
|
|
|
// c.contains("512")
|
|
|
|
|
// })
|
|
|
|
|
// });
|
|
|
|
|
// if avx512 {
|
|
|
|
|
// continue
|
|
|
|
|
// }
|
|
|
|
|
|
|
|
|
|
for intel in intel {
|
2018-02-02 16:08:27 +01:00
|
|
|
missing
|
|
|
|
|
.entry(&intel.cpuid)
|
|
|
|
|
.or_insert_with(Vec::new)
|
2018-01-29 08:27:46 -08:00
|
|
|
.push(intel);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// generate a bulleted list of missing intrinsics
|
|
|
|
|
if PRINT_MISSING_LISTS || PRINT_MISSING_LISTS_MARKDOWN {
|
|
|
|
|
for (k, v) in missing {
|
|
|
|
|
if PRINT_MISSING_LISTS_MARKDOWN {
|
|
|
|
|
println!("\n<details><summary>{:?}</summary><p>\n", k);
|
|
|
|
|
for intel in v {
|
2018-02-02 16:08:27 +01:00
|
|
|
let url = format!(
|
|
|
|
|
"https://software.intel.com/sites/landingpage\
|
|
|
|
|
/IntrinsicsGuide/#text={}&expand=5236",
|
|
|
|
|
intel.name
|
|
|
|
|
);
|
2018-01-29 08:27:46 -08:00
|
|
|
println!(" * [ ] [`{}`]({})", intel.name, url);
|
|
|
|
|
}
|
|
|
|
|
println!("</p></details>\n");
|
|
|
|
|
} else {
|
|
|
|
|
println!("\n{:?}\n", k);
|
|
|
|
|
for intel in v {
|
|
|
|
|
println!("\t{}", intel.name);
|
|
|
|
|
}
|
2017-12-29 11:52:27 -06:00
|
|
|
}
|
2018-01-29 08:27:46 -08:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
2017-12-29 11:52:27 -06:00
|
|
|
|
2018-01-29 08:27:46 -08:00
|
|
|
fn matches(rust: &Function, intel: &Intrinsic) -> Result<(), String> {
|
|
|
|
|
// Verify that all `#[target_feature]` annotations are correct,
|
|
|
|
|
// ensuring that we've actually enabled the right instruction
|
|
|
|
|
// set for this intrinsic.
|
|
|
|
|
match rust.name {
|
2019-01-07 10:04:38 -06:00
|
|
|
"_bswap" | "_bswap64" => {}
|
|
|
|
|
|
|
|
|
|
// These don't actually have a target feature unlike their brethren with
|
|
|
|
|
// the `x` inside the name which requires adx
|
|
|
|
|
"_addcarry_u32" | "_addcarry_u64" | "_subborrow_u32" | "_subborrow_u64" => {}
|
|
|
|
|
|
2019-03-07 01:26:24 -08:00
|
|
|
"_bittest"
|
|
|
|
|
| "_bittestandset"
|
|
|
|
|
| "_bittestandreset"
|
|
|
|
|
| "_bittestandcomplement"
|
|
|
|
|
| "_bittest64"
|
|
|
|
|
| "_bittestandset64"
|
|
|
|
|
| "_bittestandreset64"
|
|
|
|
|
| "_bittestandcomplement64" => {}
|
|
|
|
|
|
2018-01-29 08:27:46 -08:00
|
|
|
_ => {
|
|
|
|
|
if intel.cpuid.is_empty() {
|
|
|
|
|
bail!("missing cpuid for {}", rust.name);
|
2018-01-28 23:59:44 -06:00
|
|
|
}
|
2018-01-29 08:27:46 -08:00
|
|
|
}
|
|
|
|
|
}
|
2018-01-28 23:59:44 -06:00
|
|
|
|
2018-01-29 08:27:46 -08:00
|
|
|
for cpuid in &intel.cpuid {
|
2019-03-18 20:11:18 +01:00
|
|
|
// The pause intrinsic is in the SSE2 module, but it is backwards
|
|
|
|
|
// compatible with CPUs without SSE2, and it therefore does not need the
|
|
|
|
|
// target-feature attribute.
|
|
|
|
|
if rust.name == "_mm_pause" {
|
|
|
|
|
continue;
|
|
|
|
|
}
|
2018-01-29 08:27:46 -08:00
|
|
|
// this is needed by _xsave and probably some related intrinsics,
|
|
|
|
|
// but let's just skip it for now.
|
|
|
|
|
if *cpuid == "XSS" {
|
|
|
|
|
continue;
|
|
|
|
|
}
|
2017-12-29 11:52:27 -06:00
|
|
|
|
2018-01-29 08:36:10 -08:00
|
|
|
// these flags on the rdtsc/rtdscp intrinsics we don't test for right
|
|
|
|
|
// now, but we may wish to add these one day!
|
|
|
|
|
//
|
|
|
|
|
// For more info see #308
|
2018-01-29 08:27:46 -08:00
|
|
|
if *cpuid == "TSC" || *cpuid == "RDTSCP" {
|
|
|
|
|
continue;
|
2017-12-29 11:52:27 -06:00
|
|
|
}
|
|
|
|
|
|
2018-01-29 08:27:46 -08:00
|
|
|
let cpuid = cpuid
|
|
|
|
|
.chars()
|
|
|
|
|
.flat_map(|c| c.to_lowercase())
|
|
|
|
|
.collect::<String>();
|
|
|
|
|
|
2019-04-23 10:24:46 +02:00
|
|
|
// Fix mismatching feature names:
|
2019-02-06 20:08:48 -08:00
|
|
|
let fixup_cpuid = |cpuid: String| match cpuid.as_ref() {
|
2019-04-23 10:24:46 +02:00
|
|
|
// The XML file names IFMA as "avx512ifma52", while Rust calls
|
|
|
|
|
// it "avx512ifma".
|
2019-02-06 20:08:48 -08:00
|
|
|
"avx512ifma52" => String::from("avx512ifma"),
|
2020-12-09 01:28:58 +01:00
|
|
|
// The XML file names BITALG as "avx512_bitalg", while Rust calls
|
|
|
|
|
// it "avx512bitalg".
|
|
|
|
|
"avx512_bitalg" => String::from("avx512bitalg"),
|
2020-06-16 12:49:21 -04:00
|
|
|
// Some AVX512f intrinsics are also supported by Knight's Corner.
|
|
|
|
|
// The XML lists them as avx512f/kncni, but we are solely gating
|
|
|
|
|
// them behind avx512f since we don't have a KNC feature yet.
|
|
|
|
|
"avx512f/kncni" => String::from("avx512f"),
|
2019-07-08 23:21:37 +02:00
|
|
|
// See: https://github.com/rust-lang/stdarch/issues/738
|
2019-04-24 16:24:24 +02:00
|
|
|
// The intrinsics guide calls `f16c` `fp16c` in disagreement with
|
|
|
|
|
// Intel's architecture manuals.
|
|
|
|
|
"fp16c" => String::from("f16c"),
|
2019-02-06 20:08:48 -08:00
|
|
|
_ => cpuid,
|
|
|
|
|
};
|
|
|
|
|
let fixed_cpuid = fixup_cpuid(cpuid);
|
|
|
|
|
|
2018-06-06 00:17:14 +02:00
|
|
|
let rust_feature = rust
|
|
|
|
|
.target_feature
|
2020-11-01 19:53:39 -05:00
|
|
|
.unwrap_or_else(|| panic!("no target feature listed for {}", rust.name));
|
2019-02-06 20:08:48 -08:00
|
|
|
|
|
|
|
|
if rust_feature.contains(&fixed_cpuid) {
|
2018-02-02 16:08:27 +01:00
|
|
|
continue;
|
2018-01-29 08:27:46 -08:00
|
|
|
}
|
|
|
|
|
bail!(
|
|
|
|
|
"intel cpuid `{}` not in `{}` for {}",
|
2019-02-06 20:08:48 -08:00
|
|
|
fixed_cpuid,
|
2018-01-29 08:27:46 -08:00
|
|
|
rust_feature,
|
|
|
|
|
rust.name
|
|
|
|
|
)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if PRINT_INSTRUCTION_VIOLATIONS {
|
2018-01-02 12:28:48 -08:00
|
|
|
if rust.instrs.is_empty() {
|
2018-02-02 16:08:27 +01:00
|
|
|
if !intel.instruction.is_empty() {
|
|
|
|
|
println!(
|
|
|
|
|
"instruction not listed for `{}`, but intel lists {:?}",
|
|
|
|
|
rust.name, intel.instruction
|
|
|
|
|
);
|
2018-01-02 12:28:48 -08:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// If intel doesn't list any instructions and we do then don't
|
|
|
|
|
// bother trying to look for instructions in intel, we've just got
|
|
|
|
|
// some extra assertions on our end.
|
|
|
|
|
} else if !intel.instruction.is_empty() {
|
|
|
|
|
for instr in rust.instrs {
|
2018-12-13 17:26:22 -06:00
|
|
|
let asserting = intel.instruction.iter().any(|a| a.name.starts_with(instr));
|
2018-01-02 12:28:48 -08:00
|
|
|
if !asserting {
|
|
|
|
|
println!(
|
2018-01-04 17:15:23 +01:00
|
|
|
"intel failed to list `{}` as an instruction for `{}`",
|
2018-02-02 16:08:27 +01:00
|
|
|
instr, rust.name
|
2018-01-04 17:15:23 +01:00
|
|
|
);
|
2017-12-29 11:52:27 -06:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
2018-01-29 08:27:46 -08:00
|
|
|
}
|
2017-12-29 11:52:27 -06:00
|
|
|
|
2018-01-29 08:27:46 -08:00
|
|
|
// Make sure we've got the right return type.
|
|
|
|
|
if let Some(t) = rust.ret {
|
2020-06-09 11:27:10 +02:00
|
|
|
equate(t, &intel.return_.type_, rust.name, false)?;
|
|
|
|
|
} else if intel.return_.type_ != "" && intel.return_.type_ != "void" {
|
2018-01-29 08:27:46 -08:00
|
|
|
bail!(
|
|
|
|
|
"{} returns `{}` with intel, void in rust",
|
|
|
|
|
rust.name,
|
2020-06-09 11:27:10 +02:00
|
|
|
intel.return_.type_
|
2018-01-29 08:27:46 -08:00
|
|
|
)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// If there's no arguments on Rust's side intel may list one "void"
|
|
|
|
|
// argument, so handle that here.
|
|
|
|
|
if rust.arguments.is_empty() && intel.parameters.len() == 1 {
|
|
|
|
|
if intel.parameters[0].type_ != "void" {
|
|
|
|
|
bail!("rust has 0 arguments, intel has one for")
|
|
|
|
|
}
|
|
|
|
|
} else {
|
|
|
|
|
// Otherwise we want all parameters to be exactly the same
|
|
|
|
|
if rust.arguments.len() != intel.parameters.len() {
|
|
|
|
|
bail!("wrong number of arguments on {}", rust.name)
|
|
|
|
|
}
|
2018-12-13 17:26:22 -06:00
|
|
|
for (i, (a, b)) in intel.parameters.iter().zip(rust.arguments).enumerate() {
|
2018-02-11 10:24:33 -06:00
|
|
|
let is_const = rust.required_const.contains(&i);
|
|
|
|
|
equate(b, &a.type_, &intel.name, is_const)?;
|
2017-12-29 11:52:27 -06:00
|
|
|
}
|
2018-01-29 08:27:46 -08:00
|
|
|
}
|
2017-12-29 11:52:27 -06:00
|
|
|
|
2018-12-13 17:26:22 -06:00
|
|
|
let any_i64 = rust
|
|
|
|
|
.arguments
|
|
|
|
|
.iter()
|
|
|
|
|
.cloned()
|
|
|
|
|
.chain(rust.ret)
|
2020-11-01 19:53:39 -05:00
|
|
|
.any(|arg| matches!(*arg, Type::PrimSigned(64) | Type::PrimUnsigned(64)));
|
2018-01-29 08:27:46 -08:00
|
|
|
let any_i64_exempt = match rust.name {
|
|
|
|
|
// These intrinsics have all been manually verified against Clang's
|
|
|
|
|
// headers to be available on x86, and the u64 arguments seem
|
|
|
|
|
// spurious I guess?
|
2018-12-13 17:26:22 -06:00
|
|
|
"_xsave" | "_xrstor" | "_xsetbv" | "_xgetbv" | "_xsaveopt" | "_xsavec" | "_xsaves"
|
|
|
|
|
| "_xrstors" => true,
|
2018-01-29 08:27:46 -08:00
|
|
|
|
|
|
|
|
// Apparently all of clang/msvc/gcc accept these intrinsics on
|
|
|
|
|
// 32-bit, so let's do the same
|
2020-10-10 12:14:15 -04:00
|
|
|
"_mm_set_epi64x"
|
|
|
|
|
| "_mm_set1_epi64x"
|
|
|
|
|
| "_mm256_set_epi64x"
|
|
|
|
|
| "_mm256_setr_epi64x"
|
|
|
|
|
| "_mm256_set1_epi64x"
|
|
|
|
|
| "_mm512_set1_epi64"
|
|
|
|
|
| "_mm512_set4_epi64"
|
|
|
|
|
| "_mm512_setr4_epi64"
|
|
|
|
|
| "_mm512_set_epi64"
|
|
|
|
|
| "_mm512_setr_epi64"
|
2020-10-16 20:14:41 -04:00
|
|
|
| "_mm512_reduce_add_epi64"
|
|
|
|
|
| "_mm512_mask_reduce_add_epi64"
|
|
|
|
|
| "_mm512_reduce_mul_epi64"
|
|
|
|
|
| "_mm512_mask_reduce_mul_epi64"
|
|
|
|
|
| "_mm512_reduce_max_epi64"
|
|
|
|
|
| "_mm512_mask_reduce_max_epi64"
|
|
|
|
|
| "_mm512_reduce_max_epu64"
|
|
|
|
|
| "_mm512_mask_reduce_max_epu64"
|
|
|
|
|
| "_mm512_reduce_min_epi64"
|
|
|
|
|
| "_mm512_mask_reduce_min_epi64"
|
|
|
|
|
| "_mm512_reduce_min_epu64"
|
|
|
|
|
| "_mm512_mask_reduce_min_epu64"
|
|
|
|
|
| "_mm512_reduce_and_epi64"
|
|
|
|
|
| "_mm512_mask_reduce_and_epi64"
|
|
|
|
|
| "_mm512_reduce_or_epi64"
|
|
|
|
|
| "_mm512_mask_reduce_or_epi64"
|
|
|
|
|
| "_mm512_mask_set1_epi64"
|
2020-11-06 19:14:05 -05:00
|
|
|
| "_mm512_maskz_set1_epi64"
|
|
|
|
|
| "_mm_cvt_roundss_si64"
|
|
|
|
|
| "_mm_cvt_roundss_i64"
|
|
|
|
|
| "_mm_cvt_roundss_u64"
|
|
|
|
|
| "_mm_cvtss_i64"
|
|
|
|
|
| "_mm_cvtss_u64"
|
|
|
|
|
| "_mm_cvt_roundsd_si64"
|
|
|
|
|
| "_mm_cvt_roundsd_i64"
|
|
|
|
|
| "_mm_cvt_roundsd_u64"
|
|
|
|
|
| "_mm_cvtsd_i64"
|
|
|
|
|
| "_mm_cvtsd_u64"
|
|
|
|
|
| "_mm_cvt_roundi64_ss"
|
|
|
|
|
| "_mm_cvt_roundi64_sd"
|
|
|
|
|
| "_mm_cvt_roundsi64_ss"
|
|
|
|
|
| "_mm_cvt_roundsi64_sd"
|
|
|
|
|
| "_mm_cvt_roundu64_ss"
|
|
|
|
|
| "_mm_cvt_roundu64_sd"
|
|
|
|
|
| "_mm_cvti64_ss"
|
|
|
|
|
| "_mm_cvti64_sd"
|
|
|
|
|
| "_mm_cvtt_roundss_si64"
|
|
|
|
|
| "_mm_cvtt_roundss_i64"
|
|
|
|
|
| "_mm_cvtt_roundss_u64"
|
|
|
|
|
| "_mm_cvttss_i64"
|
|
|
|
|
| "_mm_cvttss_u64"
|
|
|
|
|
| "_mm_cvtt_roundsd_si64"
|
|
|
|
|
| "_mm_cvtt_roundsd_i64"
|
|
|
|
|
| "_mm_cvtt_roundsd_u64"
|
|
|
|
|
| "_mm_cvttsd_i64"
|
|
|
|
|
| "_mm_cvttsd_u64"
|
|
|
|
|
| "_mm_cvtu64_ss"
|
|
|
|
|
| "_mm_cvtu64_sd" => true,
|
2018-01-29 08:27:46 -08:00
|
|
|
|
2018-01-29 08:36:10 -08:00
|
|
|
// These return a 64-bit argument but they're assembled from other
|
|
|
|
|
// 32-bit registers, so these work on 32-bit just fine. See #308 for
|
|
|
|
|
// more info.
|
2018-02-02 16:08:27 +01:00
|
|
|
"_rdtsc" | "__rdtscp" => true,
|
2017-12-29 11:52:27 -06:00
|
|
|
|
2018-01-29 08:27:46 -08:00
|
|
|
_ => false,
|
|
|
|
|
};
|
2018-02-02 16:08:27 +01:00
|
|
|
if any_i64 && !any_i64_exempt && !rust.file.contains("x86_64") {
|
|
|
|
|
bail!(
|
|
|
|
|
"intrinsic `{}` uses a 64-bit bare type but may be \
|
|
|
|
|
available on 32-bit platforms",
|
|
|
|
|
rust.name
|
|
|
|
|
)
|
2017-12-29 11:52:27 -06:00
|
|
|
}
|
2018-01-29 08:27:46 -08:00
|
|
|
Ok(())
|
2017-12-29 11:52:27 -06:00
|
|
|
}
|
|
|
|
|
|
2018-12-13 17:26:22 -06:00
|
|
|
fn equate(t: &Type, intel: &str, intrinsic: &str, is_const: bool) -> Result<(), String> {
|
2019-04-26 09:04:41 +02:00
|
|
|
// Make pointer adjacent to the type: float * foo => float* foo
|
|
|
|
|
let mut intel = intel.replace(" *", "*");
|
|
|
|
|
// Make mutability modifier adjacent to the pointer:
|
|
|
|
|
// float const * foo => float const* foo
|
|
|
|
|
intel = intel.replace("const *", "const*");
|
|
|
|
|
// Normalize mutability modifier to after the type:
|
|
|
|
|
// const float* foo => float const*
|
2020-11-01 19:53:39 -05:00
|
|
|
if intel.starts_with("const") && intel.ends_with('*') {
|
2019-04-26 09:04:41 +02:00
|
|
|
intel = intel.replace("const ", "");
|
|
|
|
|
intel = intel.replace("*", " const*");
|
|
|
|
|
}
|
2018-02-11 10:24:33 -06:00
|
|
|
let require_const = || {
|
|
|
|
|
if is_const {
|
Prepare portable packed vector types for RFCs (#338)
* Prepare portable packed SIMD vector types for RFCs
This commit cleans up the implementation of the Portable Packed Vector Types
(PPTV), adds some new features, and makes some breaking changes.
The implementation is moved to `coresimd/src/ppvt` (they are
still exposed via `coresimd::simd`).
As before, the vector types of a certain width are implemented in the `v{width}`
submodules. The `macros.rs` file has been rewritten as an `api` module that
exposes the macros to implement each API.
It should now hopefully be really clear where each API is implemented, and which types
implement these APIs. It should also now be really clear which APIs are tested and how.
- boolean vectors of the form `b{element_size}x{number_of_lanes}`.
- reductions: arithmetic, bitwise, min/max, and boolean - only the facade,
and a naive working implementation. These need to be implemented
as `llvm.experimental.vector.reduction.{...}` but this needs rustc support first.
- FromBits trait analogous to `{f32,f64}::from_bits` that perform "safe" transmutes.
Instead of writing `From::from`/`x.into()` (see below for breaking changes) now you write
`FromBits::from_bits`/`x.into_bits()`.
- portable vector types implement `Default` and `Hash`
- tests for all portable vector types and all portable operations (~2000 new tests).
- (hopefully) comprehensive implementation of bitwise transmutes and lane-wise
casts (before `From` and the `.as_...` methods where implemented "when they were needed".
- documentation for PPTV (not great yet, but better than nothing)
- conversions/transmutes from/to x86 architecture specific vector types
- `store/load` API has been replaced with `{store,load}_{aligned,unaligned}`
- `eq,ne,lt,le,gt,ge` APIs now return boolean vectors
- The `.as_{...}` methods have been removed. Lane-wise casts are now performed by `From`.
- `From` now perform casts (see above). It used to perform bitwise transmutes.
- `simd` vectors' `replace` method's result is now `#[must_use]`.
* enable backtrace and nocapture
* unalign load/store fail test by 1 byte
* update arm and aarch64 neon modules
* fix arm example
* fmt
* clippy and read example that rustfmt swallowed
* reductions should take self
* rename add/mul -> sum/product; delete other arith reductions
* clean up fmt::LowerHex impl
* revert incorret doc change
* make Hash equivalent to [T; lanes()]
* use travis_wait to increase timeout limit to 20 minutes
* remove travis_wait; did not help
* implement reductions on top of the llvm.experimental.vector.reduction intrinsics
* implement cmp for boolean vectors
* add missing eq impl file
* implement default
* rename llvm intrinsics
* fix aarch64 example error
* replace #[inline(always)] with #[inline]
* remove cargo clean from run.sh
* workaround broken product in aarch64
* make boolean vector constructors const fn
* fix more reductions on aarch64
* fix min/max reductions on aarch64
* remove whitespace
* remove all boolean vector types except for b8xN
* use a sum reduction fallback on aarch64
* disable llvm add reduction for aarch64
* rename the llvm intrinsics to use llvm names
* remove old macros.rs file
2018-03-05 21:32:35 +01:00
|
|
|
return Ok(());
|
2018-02-11 10:24:33 -06:00
|
|
|
}
|
2018-06-06 00:17:14 +02:00
|
|
|
Err(format!("argument required to be const but isn't"))
|
2018-02-11 10:24:33 -06:00
|
|
|
};
|
2017-12-29 11:52:27 -06:00
|
|
|
match (t, &intel[..]) {
|
|
|
|
|
(&Type::PrimFloat(32), "float") => {}
|
|
|
|
|
(&Type::PrimFloat(64), "double") => {}
|
|
|
|
|
(&Type::PrimSigned(16), "__int16") => {}
|
|
|
|
|
(&Type::PrimSigned(16), "short") => {}
|
|
|
|
|
(&Type::PrimSigned(32), "__int32") => {}
|
2018-02-11 10:24:33 -06:00
|
|
|
(&Type::PrimSigned(32), "const int") => require_const()?,
|
2017-12-29 11:52:27 -06:00
|
|
|
(&Type::PrimSigned(32), "int") => {}
|
|
|
|
|
(&Type::PrimSigned(64), "__int64") => {}
|
|
|
|
|
(&Type::PrimSigned(64), "long long") => {}
|
|
|
|
|
(&Type::PrimSigned(8), "__int8") => {}
|
|
|
|
|
(&Type::PrimSigned(8), "char") => {}
|
|
|
|
|
(&Type::PrimUnsigned(16), "unsigned short") => {}
|
|
|
|
|
(&Type::PrimUnsigned(32), "unsigned int") => {}
|
2019-04-23 09:01:07 -07:00
|
|
|
(&Type::PrimUnsigned(32), "const unsigned int") => {}
|
2017-12-29 11:52:27 -06:00
|
|
|
(&Type::PrimUnsigned(64), "unsigned __int64") => {}
|
|
|
|
|
(&Type::PrimUnsigned(8), "unsigned char") => {}
|
2019-04-26 09:04:41 +02:00
|
|
|
(&Type::M64, "__m64") => {}
|
|
|
|
|
(&Type::M128, "__m128") => {}
|
|
|
|
|
(&Type::M128I, "__m128i") => {}
|
|
|
|
|
(&Type::M128D, "__m128d") => {}
|
|
|
|
|
(&Type::M256, "__m256") => {}
|
|
|
|
|
(&Type::M256I, "__m256i") => {}
|
|
|
|
|
(&Type::M256D, "__m256d") => {}
|
|
|
|
|
(&Type::M512, "__m512") => {}
|
|
|
|
|
(&Type::M512I, "__m512i") => {}
|
|
|
|
|
(&Type::M512D, "__m512d") => {}
|
2020-12-01 04:43:01 -05:00
|
|
|
(&Type::MMASK64, "__mmask64") => {}
|
|
|
|
|
(&Type::MMASK32, "__mmask32") => {}
|
|
|
|
|
(&Type::MMASK16, "__mmask16") => {}
|
|
|
|
|
(&Type::MMASK8, "__mmask8") => {}
|
2019-04-26 09:04:41 +02:00
|
|
|
|
|
|
|
|
(&Type::MutPtr(&Type::PrimFloat(32)), "float*") => {}
|
|
|
|
|
(&Type::MutPtr(&Type::PrimFloat(64)), "double*") => {}
|
2020-07-11 11:02:07 +03:00
|
|
|
(&Type::MutPtr(&Type::PrimFloat(32)), "void*") => {}
|
|
|
|
|
(&Type::MutPtr(&Type::PrimFloat(64)), "void*") => {}
|
2020-10-10 12:14:15 -04:00
|
|
|
(&Type::MutPtr(&Type::PrimSigned(32)), "void*") => {}
|
2020-11-22 10:10:25 -05:00
|
|
|
(&Type::MutPtr(&Type::PrimSigned(16)), "void*") => {}
|
|
|
|
|
(&Type::MutPtr(&Type::PrimSigned(8)), "void*") => {}
|
2019-04-26 09:04:41 +02:00
|
|
|
(&Type::MutPtr(&Type::PrimSigned(32)), "int*") => {}
|
|
|
|
|
(&Type::MutPtr(&Type::PrimSigned(32)), "__int32*") => {}
|
2020-10-10 12:14:15 -04:00
|
|
|
(&Type::MutPtr(&Type::PrimSigned(64)), "void*") => {}
|
2019-04-26 09:04:41 +02:00
|
|
|
(&Type::MutPtr(&Type::PrimSigned(64)), "__int64*") => {}
|
|
|
|
|
(&Type::MutPtr(&Type::PrimSigned(8)), "char*") => {}
|
|
|
|
|
(&Type::MutPtr(&Type::PrimUnsigned(16)), "unsigned short*") => {}
|
|
|
|
|
(&Type::MutPtr(&Type::PrimUnsigned(32)), "unsigned int*") => {}
|
|
|
|
|
(&Type::MutPtr(&Type::PrimUnsigned(64)), "unsigned __int64*") => {}
|
|
|
|
|
(&Type::MutPtr(&Type::PrimUnsigned(8)), "void*") => {}
|
2020-12-01 04:43:01 -05:00
|
|
|
(&Type::MutPtr(&Type::PrimUnsigned(32)), "__mmask32*") => {}
|
|
|
|
|
(&Type::MutPtr(&Type::PrimUnsigned(64)), "__mmask64*") => {}
|
2019-04-26 09:04:41 +02:00
|
|
|
(&Type::MutPtr(&Type::M64), "__m64*") => {}
|
|
|
|
|
(&Type::MutPtr(&Type::M128), "__m128*") => {}
|
|
|
|
|
(&Type::MutPtr(&Type::M128I), "__m128i*") => {}
|
|
|
|
|
(&Type::MutPtr(&Type::M128D), "__m128d*") => {}
|
|
|
|
|
(&Type::MutPtr(&Type::M256), "__m256*") => {}
|
|
|
|
|
(&Type::MutPtr(&Type::M256I), "__m256i*") => {}
|
|
|
|
|
(&Type::MutPtr(&Type::M256D), "__m256d*") => {}
|
|
|
|
|
(&Type::MutPtr(&Type::M512), "__m512*") => {}
|
|
|
|
|
(&Type::MutPtr(&Type::M512I), "__m512i*") => {}
|
|
|
|
|
(&Type::MutPtr(&Type::M512D), "__m512d*") => {}
|
|
|
|
|
|
|
|
|
|
(&Type::ConstPtr(&Type::PrimFloat(32)), "float const*") => {}
|
|
|
|
|
(&Type::ConstPtr(&Type::PrimFloat(64)), "double const*") => {}
|
2020-07-11 11:02:07 +03:00
|
|
|
(&Type::ConstPtr(&Type::PrimFloat(32)), "void const*") => {}
|
|
|
|
|
(&Type::ConstPtr(&Type::PrimFloat(64)), "void const*") => {}
|
2019-04-26 09:04:41 +02:00
|
|
|
(&Type::ConstPtr(&Type::PrimSigned(32)), "int const*") => {}
|
|
|
|
|
(&Type::ConstPtr(&Type::PrimSigned(32)), "__int32 const*") => {}
|
2020-11-22 10:10:25 -05:00
|
|
|
(&Type::ConstPtr(&Type::PrimSigned(8)), "void const*") => {}
|
|
|
|
|
(&Type::ConstPtr(&Type::PrimSigned(16)), "void const*") => {}
|
2020-10-10 12:14:15 -04:00
|
|
|
(&Type::ConstPtr(&Type::PrimSigned(32)), "void const*") => {}
|
|
|
|
|
(&Type::ConstPtr(&Type::PrimSigned(64)), "void const*") => {}
|
2020-11-22 10:10:25 -05:00
|
|
|
(&Type::ConstPtr(&Type::PrimSigned(64)), "__int64 const*") => {}
|
2019-04-26 09:04:41 +02:00
|
|
|
(&Type::ConstPtr(&Type::PrimSigned(8)), "char const*") => {}
|
|
|
|
|
(&Type::ConstPtr(&Type::PrimUnsigned(16)), "unsigned short const*") => {}
|
|
|
|
|
(&Type::ConstPtr(&Type::PrimUnsigned(32)), "unsigned int const*") => {}
|
|
|
|
|
(&Type::ConstPtr(&Type::PrimUnsigned(64)), "unsigned __int64 const*") => {}
|
|
|
|
|
(&Type::ConstPtr(&Type::PrimUnsigned(8)), "void const*") => {}
|
2020-12-01 04:43:01 -05:00
|
|
|
(&Type::ConstPtr(&Type::PrimUnsigned(32)), "void const*") => {}
|
2019-04-26 09:04:41 +02:00
|
|
|
(&Type::ConstPtr(&Type::M64), "__m64 const*") => {}
|
|
|
|
|
(&Type::ConstPtr(&Type::M128), "__m128 const*") => {}
|
|
|
|
|
(&Type::ConstPtr(&Type::M128I), "__m128i const*") => {}
|
|
|
|
|
(&Type::ConstPtr(&Type::M128D), "__m128d const*") => {}
|
|
|
|
|
(&Type::ConstPtr(&Type::M256), "__m256 const*") => {}
|
|
|
|
|
(&Type::ConstPtr(&Type::M256I), "__m256i const*") => {}
|
|
|
|
|
(&Type::ConstPtr(&Type::M256D), "__m256d const*") => {}
|
|
|
|
|
(&Type::ConstPtr(&Type::M512), "__m512 const*") => {}
|
|
|
|
|
(&Type::ConstPtr(&Type::M512I), "__m512i const*") => {}
|
|
|
|
|
(&Type::ConstPtr(&Type::M512D), "__m512d const*") => {}
|
2020-12-01 04:43:01 -05:00
|
|
|
(&Type::ConstPtr(&Type::PrimUnsigned(32)), "__mmask32*") => {}
|
|
|
|
|
(&Type::ConstPtr(&Type::PrimUnsigned(64)), "__mmask64*") => {}
|
2018-12-14 09:44:26 -06:00
|
|
|
|
2020-06-16 12:49:21 -04:00
|
|
|
(&Type::MM_CMPINT_ENUM, "_MM_CMPINT_ENUM") => {}
|
2020-09-11 17:26:39 -04:00
|
|
|
(&Type::MM_MANTISSA_NORM_ENUM, "_MM_MANTISSA_NORM_ENUM") => {}
|
|
|
|
|
(&Type::MM_MANTISSA_SIGN_ENUM, "_MM_MANTISSA_SIGN_ENUM") => {}
|
2020-09-19 17:16:01 -04:00
|
|
|
(&Type::MM_PERM_ENUM, "_MM_PERM_ENUM") => {}
|
2018-12-14 09:44:26 -06:00
|
|
|
|
2018-01-04 17:15:23 +01:00
|
|
|
// This is a macro (?) in C which seems to mutate its arguments, but
|
|
|
|
|
// that means that we're taking pointers to arguments in rust
|
|
|
|
|
// as we're not exposing it as a macro.
|
2019-04-26 09:04:41 +02:00
|
|
|
(&Type::MutPtr(&Type::M128), "__m128") if intrinsic == "_MM_TRANSPOSE4_PS" => {}
|
2017-12-29 11:52:27 -06:00
|
|
|
|
2019-04-26 08:11:42 +02:00
|
|
|
// The _rdtsc intrinsic uses a __int64 return type, but this is a bug in
|
2019-07-08 23:21:37 +02:00
|
|
|
// the intrinsics guide: https://github.com/rust-lang/stdarch/issues/559
|
2019-04-26 08:11:42 +02:00
|
|
|
// We have manually fixed the bug by changing the return type to `u64`.
|
|
|
|
|
(&Type::PrimUnsigned(64), "__int64") if intrinsic == "_rdtsc" => {}
|
|
|
|
|
|
2019-04-26 09:04:41 +02:00
|
|
|
// The _bittest and _bittest64 intrinsics takes a mutable pointer in the
|
|
|
|
|
// intrinsics guide even though it never writes through the pointer:
|
|
|
|
|
(&Type::ConstPtr(&Type::PrimSigned(32)), "__int32*") if intrinsic == "_bittest" => {}
|
|
|
|
|
(&Type::ConstPtr(&Type::PrimSigned(64)), "__int64*") if intrinsic == "_bittest64" => {}
|
|
|
|
|
// The _xrstor, _fxrstor, _xrstor64, _fxrstor64 intrinsics take a
|
|
|
|
|
// mutable pointer in the intrinsics guide even though they never write
|
|
|
|
|
// through the pointer:
|
|
|
|
|
(&Type::ConstPtr(&Type::PrimUnsigned(8)), "void*")
|
|
|
|
|
if intrinsic == "_xrstor"
|
|
|
|
|
|| intrinsic == "_xrstor64"
|
|
|
|
|
|| intrinsic == "_fxrstor"
|
|
|
|
|
|| intrinsic == "_fxrstor64" => {}
|
|
|
|
|
|
2018-02-02 16:08:27 +01:00
|
|
|
_ => bail!(
|
|
|
|
|
"failed to equate: `{}` and {:?} for {}",
|
|
|
|
|
intel,
|
|
|
|
|
t,
|
|
|
|
|
intrinsic
|
|
|
|
|
),
|
2017-12-29 11:52:27 -06:00
|
|
|
}
|
2018-01-29 08:27:46 -08:00
|
|
|
Ok(())
|
2017-12-29 11:52:27 -06:00
|
|
|
}
|