From 01d38b057d14eee3bd4d65ac161b20c56cede694 Mon Sep 17 00:00:00 2001 From: ziyizhang-1 Date: Fri, 26 Jul 2024 04:06:18 -0400 Subject: [PATCH] add usize as a x86-intel primitive --- crates/core_arch/src/x86_64/amx.rs | 12 ++++++------ crates/stdarch-verify/src/lib.rs | 1 + crates/stdarch-verify/tests/x86-intel.rs | 7 +++++-- 3 files changed, 12 insertions(+), 8 deletions(-) diff --git a/crates/core_arch/src/x86_64/amx.rs b/crates/core_arch/src/x86_64/amx.rs index a48a39f47f..576a0645c5 100644 --- a/crates/core_arch/src/x86_64/amx.rs +++ b/crates/core_arch/src/x86_64/amx.rs @@ -32,7 +32,7 @@ pub unsafe fn _tile_storeconfig(mem_addr: *mut i8) { #[rustc_legacy_const_generics(0)] #[target_feature(enable = "amx-tile")] #[unstable(feature = "x86_amx_intrinsics", issue = "126622")] -pub unsafe fn _tile_loadd(base: *const i8, stride: i64) { +pub unsafe fn _tile_loadd(base: *const i8, stride: usize) { static_assert_uimm_bits!(dst, 3); tileloadd64(dst, base, stride); } @@ -55,7 +55,7 @@ pub unsafe fn _tile_release() { #[rustc_legacy_const_generics(0)] #[target_feature(enable = "amx-tile")] #[unstable(feature = "x86_amx_intrinsics", issue = "126622")] -pub unsafe fn _tile_stored(base: *mut i8, stride: i64) { +pub unsafe fn _tile_stored(base: *mut i8, stride: usize) { static_assert_uimm_bits!(dst, 3); tilestored64(dst, base, stride); } @@ -70,7 +70,7 @@ pub unsafe fn _tile_stored(base: *mut i8, stride: i64) { #[rustc_legacy_const_generics(0)] #[target_feature(enable = "amx-tile")] #[unstable(feature = "x86_amx_intrinsics", issue = "126622")] -pub unsafe fn _tile_stream_loadd(base: *const i8, stride: i64) { +pub unsafe fn _tile_stream_loadd(base: *const i8, stride: usize) { static_assert_uimm_bits!(dst, 3); tileloaddt164(dst, base, stride); } @@ -244,13 +244,13 @@ extern "C" { #[link_name = "llvm.x86.sttilecfg"] fn sttilecfg(mem_addr: *mut i8); #[link_name = "llvm.x86.tileloadd64"] - fn tileloadd64(dst: i8, base: *const i8, stride: i64); + fn tileloadd64(dst: i8, base: *const i8, stride: usize); #[link_name = "llvm.x86.tileloaddt164"] - fn tileloaddt164(dst: i8, base: *const i8, stride: i64); + fn tileloaddt164(dst: i8, base: *const i8, stride: usize); #[link_name = "llvm.x86.tilerelease"] fn tilerelease(); #[link_name = "llvm.x86.tilestored64"] - fn tilestored64(dst: i8, base: *mut i8, stride: i64); + fn tilestored64(dst: i8, base: *mut i8, stride: usize); #[link_name = "llvm.x86.tilezero"] fn tilezero(dst: i8); #[link_name = "llvm.x86.tdpbf16ps"] diff --git a/crates/stdarch-verify/src/lib.rs b/crates/stdarch-verify/src/lib.rs index 347dd8d124..b53a73ea4e 100644 --- a/crates/stdarch-verify/src/lib.rs +++ b/crates/stdarch-verify/src/lib.rs @@ -212,6 +212,7 @@ fn to_type(t: &syn::Type) -> proc_macro2::TokenStream { "u32" => quote! { &U32 }, "u64" => quote! { &U64 }, "u128" => quote! { &U128 }, + "usize" => quote! { &USIZE }, "u8" => quote! { &U8 }, "p8" => quote! { &P8 }, "p16" => quote! { &P16 }, diff --git a/crates/stdarch-verify/tests/x86-intel.rs b/crates/stdarch-verify/tests/x86-intel.rs index 0eabb1af7e..3aa2436336 100644 --- a/crates/stdarch-verify/tests/x86-intel.rs +++ b/crates/stdarch-verify/tests/x86-intel.rs @@ -4,12 +4,14 @@ use std::collections::{BTreeMap, HashMap, HashSet}; use std::fs::File; use std::io; use std::io::{BufWriter, Write}; +use std::usize; use serde::Deserialize; const PRINT_INSTRUCTION_VIOLATIONS: bool = false; const PRINT_MISSING_LISTS: bool = false; const PRINT_MISSING_LISTS_MARKDOWN: bool = false; +const SS: u8 = (8 * core::mem::size_of::()) as u8; struct Function { name: &'static str, @@ -35,6 +37,7 @@ static U16: Type = Type::PrimUnsigned(16); static U32: Type = Type::PrimUnsigned(32); static U64: Type = Type::PrimUnsigned(64); static U128: Type = Type::PrimUnsigned(128); +static USIZE: Type = Type::PrimUnsigned(SS); static ORDERING: Type = Type::Ordering; static M128: Type = Type::M128; @@ -716,7 +719,7 @@ fn equate( (&Type::PrimSigned(8), "__int8" | "constexpr int" | "char") => {} (&Type::PrimSigned(16), "__int16" | "short") => {} (&Type::PrimSigned(32), "__int32" | "const int" | "int") => {} - (&Type::PrimSigned(64), "__int64" | "long long" | "size_t") => {} + (&Type::PrimSigned(64), "__int64" | "long long") => {} (&Type::PrimUnsigned(8), "unsigned char") => {} (&Type::PrimUnsigned(16), "unsigned short") => {} (&Type::BFloat16, "__bfloat16") => {} @@ -724,7 +727,7 @@ fn equate( &Type::PrimUnsigned(32), "unsigned __int32" | "unsigned int" | "unsigned long" | "const unsigned int", ) => {} - (&Type::PrimUnsigned(64), "unsigned __int64") => {} + (&Type::PrimUnsigned(64), "unsigned __int64" | "size_t") => {} (&Type::M128, "__m128") => {} (&Type::M128BH, "__m128bh") => {}