From e9f2812c6773fa0afa64e8b1ed4b0b26fd721cce Mon Sep 17 00:00:00 2001 From: Bee Date: Tue, 24 Nov 2026 04:03:00 +0000 Subject: [PATCH] Remove packed struct workaround for LLVM intrinsic returns --- crates/core_arch/src/aarch64/rand.rs | 15 +-- crates/core_arch/src/s390x/vector.rs | 131 ++++++++++++--------------- crates/core_arch/src/x86/kl.rs | 72 +++++++-------- 3 files changed, 99 insertions(+), 119 deletions(-) diff --git a/crates/core_arch/src/aarch64/rand.rs b/crates/core_arch/src/aarch64/rand.rs index f0ce18389c..f92a54748b 100644 --- a/crates/core_arch/src/aarch64/rand.rs +++ b/crates/core_arch/src/aarch64/rand.rs @@ -5,18 +5,13 @@ #[cfg(test)] use stdarch_test::assert_instr; +#[expect(improper_ctypes)] unsafe extern "llvm-intrinsic" { #[link_name = "llvm.aarch64.rndr"] - fn rndr_() -> Tuple; + fn rndr_() -> (u64, bool); #[link_name = "llvm.aarch64.rndrrs"] - fn rndrrs_() -> Tuple; -} - -#[repr(C)] -struct Tuple { - bits: u64, - status: bool, + fn rndrrs_() -> (u64, bool); } /// Stores a 64-bit random number into the object pointed to by the argument and returns @@ -28,7 +23,7 @@ struct Tuple { #[cfg_attr(test, assert_instr(mrs))] #[unstable(feature = "stdarch_aarch64_rand", issue = "153514")] pub unsafe fn __rndr(value: *mut u64) -> i32 { - let Tuple { bits, status } = rndr_(); + let (bits, status) = rndr_(); unsafe { *value = bits }; status as i32 } @@ -42,7 +37,7 @@ pub unsafe fn __rndr(value: *mut u64) -> i32 { #[cfg_attr(test, assert_instr(mrs))] #[unstable(feature = "stdarch_aarch64_rand", issue = "153514")] pub unsafe fn __rndrrs(value: *mut u64) -> i32 { - let Tuple { bits, status } = rndrrs_(); + let (bits, status) = rndrrs_(); unsafe { *value = bits }; status as i32 } diff --git a/crates/core_arch/src/s390x/vector.rs b/crates/core_arch/src/s390x/vector.rs index 8fd9fd83a6..0278e26216 100644 --- a/crates/core_arch/src/s390x/vector.rs +++ b/crates/core_arch/src/s390x/vector.rs @@ -99,13 +99,7 @@ impl From for m32x4 { } } -#[repr(C, packed)] -struct PackedTuple { - x: T, - y: U, -} - -#[allow(improper_ctypes)] +#[expect(improper_ctypes)] #[rustfmt::skip] unsafe extern "llvm-intrinsic" { #[link_name = "llvm.nearbyint.v4f32"] fn nearbyint_v4f32(a: vector_float) -> vector_float; @@ -157,13 +151,13 @@ unsafe extern "llvm-intrinsic" { #[link_name = "llvm.s390.vfaezh"] fn vfaezh(a: vector_signed_short, b: vector_signed_short, c: i32) -> vector_signed_short; #[link_name = "llvm.s390.vfaezf"] fn vfaezf(a: vector_signed_int, b: vector_signed_int, c: i32) -> vector_signed_int; - #[link_name = "llvm.s390.vfaebs"] fn vfaebs(a: vector_signed_char, b: vector_signed_char, c: i32) -> PackedTuple; - #[link_name = "llvm.s390.vfaehs"] fn vfaehs(a: vector_signed_short, b: vector_signed_short, c: i32) -> PackedTuple; - #[link_name = "llvm.s390.vfaefs"] fn vfaefs(a: vector_signed_int, b: vector_signed_int, c: i32) -> PackedTuple; + #[link_name = "llvm.s390.vfaebs"] fn vfaebs(a: vector_signed_char, b: vector_signed_char, c: i32) -> (vector_signed_char, i32); + #[link_name = "llvm.s390.vfaehs"] fn vfaehs(a: vector_signed_short, b: vector_signed_short, c: i32) -> (vector_signed_short, i32); + #[link_name = "llvm.s390.vfaefs"] fn vfaefs(a: vector_signed_int, b: vector_signed_int, c: i32) -> (vector_signed_int, i32); - #[link_name = "llvm.s390.vfaezbs"] fn vfaezbs(a: vector_signed_char, b: vector_signed_char, c: i32) -> PackedTuple; - #[link_name = "llvm.s390.vfaezhs"] fn vfaezhs(a: vector_signed_short, b: vector_signed_short, c: i32) -> PackedTuple; - #[link_name = "llvm.s390.vfaezfs"] fn vfaezfs(a: vector_signed_int, b: vector_signed_int, c: i32) -> PackedTuple; + #[link_name = "llvm.s390.vfaezbs"] fn vfaezbs(a: vector_signed_char, b: vector_signed_char, c: i32) -> (vector_signed_char, i32); + #[link_name = "llvm.s390.vfaezhs"] fn vfaezhs(a: vector_signed_short, b: vector_signed_short, c: i32) -> (vector_signed_short, i32); + #[link_name = "llvm.s390.vfaezfs"] fn vfaezfs(a: vector_signed_int, b: vector_signed_int, c: i32) -> (vector_signed_int, i32); #[link_name = "llvm.s390.vll"] fn vll(a: u32, b: *const u8) -> vector_signed_char; #[link_name = "llvm.s390.vstl"] fn vstl(a: vector_signed_char, b: u32, c: *mut u8); @@ -182,13 +176,13 @@ unsafe extern "llvm-intrinsic" { #[link_name = "llvm.s390.vpklsf"] fn vpklsf(a: vector_signed_int, b: vector_signed_int) -> vector_unsigned_short; #[link_name = "llvm.s390.vpklsg"] fn vpklsg(a: vector_signed_long_long, b: vector_signed_long_long) -> vector_unsigned_int; - #[link_name = "llvm.s390.vpkshs"] fn vpkshs(a: vector_signed_short, b: vector_signed_short) -> PackedTuple; - #[link_name = "llvm.s390.vpksfs"] fn vpksfs(a: vector_signed_int, b: vector_signed_int) -> PackedTuple; - #[link_name = "llvm.s390.vpksgs"] fn vpksgs(a: vector_signed_long_long, b: vector_signed_long_long) -> PackedTuple; + #[link_name = "llvm.s390.vpkshs"] fn vpkshs(a: vector_signed_short, b: vector_signed_short) -> (vector_signed_char, i32); + #[link_name = "llvm.s390.vpksfs"] fn vpksfs(a: vector_signed_int, b: vector_signed_int) -> (vector_signed_short, i32); + #[link_name = "llvm.s390.vpksgs"] fn vpksgs(a: vector_signed_long_long, b: vector_signed_long_long) -> (vector_signed_int, i32); - #[link_name = "llvm.s390.vpklshs"] fn vpklshs(a: vector_unsigned_short, b: vector_unsigned_short) -> PackedTuple; - #[link_name = "llvm.s390.vpklsfs"] fn vpklsfs(a: vector_unsigned_int, b: vector_unsigned_int) -> PackedTuple; - #[link_name = "llvm.s390.vpklsgs"] fn vpklsgs(a: vector_unsigned_long_long, b: vector_unsigned_long_long) -> PackedTuple; + #[link_name = "llvm.s390.vpklshs"] fn vpklshs(a: vector_unsigned_short, b: vector_unsigned_short) -> (vector_unsigned_char, i32); + #[link_name = "llvm.s390.vpklsfs"] fn vpklsfs(a: vector_unsigned_int, b: vector_unsigned_int) -> (vector_unsigned_short, i32); + #[link_name = "llvm.s390.vpklsgs"] fn vpklsgs(a: vector_unsigned_long_long, b: vector_unsigned_long_long) -> (vector_unsigned_int, i32); #[link_name = "llvm.s390.vavgb"] fn vavgb(a: vector_signed_char, b: vector_signed_char) -> vector_signed_char; #[link_name = "llvm.s390.vavgh"] fn vavgh(a: vector_signed_short, b: vector_signed_short) -> vector_signed_short; @@ -254,26 +248,26 @@ unsafe extern "llvm-intrinsic" { #[link_name = "llvm.s390.vbperm"] fn vbperm(a: vector_unsigned_char, b: vector_unsigned_char) -> vector_unsigned_long_long; - #[link_name = "llvm.s390.vftcisb"] fn vftcisb(a: vector_float, b: u32) -> PackedTuple; - #[link_name = "llvm.s390.vftcidb"] fn vftcidb(a: vector_double, b: u32) -> PackedTuple; + #[link_name = "llvm.s390.vftcisb"] fn vftcisb(a: vector_float, b: u32) -> (vector_bool_int, i32); + #[link_name = "llvm.s390.vftcidb"] fn vftcidb(a: vector_double, b: u32) -> (vector_bool_long_long, i32); #[link_name = "llvm.s390.vtm"] fn vtm(a: i8x16, b: i8x16) -> i32; - #[link_name = "llvm.s390.vstrsb"] fn vstrsb(a: vector_unsigned_char, b: vector_unsigned_char, c: vector_unsigned_char) -> PackedTuple; - #[link_name = "llvm.s390.vstrsh"] fn vstrsh(a: vector_unsigned_short, b: vector_unsigned_short, c: vector_unsigned_char) -> PackedTuple; - #[link_name = "llvm.s390.vstrsf"] fn vstrsf(a: vector_unsigned_int, b: vector_unsigned_int, c: vector_unsigned_char) -> PackedTuple; + #[link_name = "llvm.s390.vstrsb"] fn vstrsb(a: vector_unsigned_char, b: vector_unsigned_char, c: vector_unsigned_char) -> (vector_unsigned_char, i32); + #[link_name = "llvm.s390.vstrsh"] fn vstrsh(a: vector_unsigned_short, b: vector_unsigned_short, c: vector_unsigned_char) -> (vector_unsigned_char, i32); + #[link_name = "llvm.s390.vstrsf"] fn vstrsf(a: vector_unsigned_int, b: vector_unsigned_int, c: vector_unsigned_char) -> (vector_unsigned_char, i32); - #[link_name = "llvm.s390.vstrszb"] fn vstrszb(a: vector_unsigned_char, b: vector_unsigned_char, c: vector_unsigned_char) -> PackedTuple; - #[link_name = "llvm.s390.vstrszh"] fn vstrszh(a: vector_unsigned_short, b: vector_unsigned_short, c: vector_unsigned_char) -> PackedTuple; - #[link_name = "llvm.s390.vstrszf"] fn vstrszf(a: vector_unsigned_int, b: vector_unsigned_int, c: vector_unsigned_char) -> PackedTuple; + #[link_name = "llvm.s390.vstrszb"] fn vstrszb(a: vector_unsigned_char, b: vector_unsigned_char, c: vector_unsigned_char) -> (vector_unsigned_char, i32); + #[link_name = "llvm.s390.vstrszh"] fn vstrszh(a: vector_unsigned_short, b: vector_unsigned_short, c: vector_unsigned_char) -> (vector_unsigned_char, i32); + #[link_name = "llvm.s390.vstrszf"] fn vstrszf(a: vector_unsigned_int, b: vector_unsigned_int, c: vector_unsigned_char) -> (vector_unsigned_char, i32); #[link_name = "llvm.s390.vistrb"] fn vistrb(a: vector_unsigned_char) -> vector_unsigned_char; #[link_name = "llvm.s390.vistrh"] fn vistrh(a: vector_unsigned_short) -> vector_unsigned_short; #[link_name = "llvm.s390.vistrf"] fn vistrf(a: vector_unsigned_int) -> vector_unsigned_int; - #[link_name = "llvm.s390.vistrbs"] fn vistrbs(a: vector_unsigned_char) -> PackedTuple; - #[link_name = "llvm.s390.vistrhs"] fn vistrhs(a: vector_unsigned_short) -> PackedTuple; - #[link_name = "llvm.s390.vistrfs"] fn vistrfs(a: vector_unsigned_int) -> PackedTuple; + #[link_name = "llvm.s390.vistrbs"] fn vistrbs(a: vector_unsigned_char) -> (vector_unsigned_char, i32); + #[link_name = "llvm.s390.vistrhs"] fn vistrhs(a: vector_unsigned_short) -> (vector_unsigned_short, i32); + #[link_name = "llvm.s390.vistrfs"] fn vistrfs(a: vector_unsigned_int) -> (vector_unsigned_int, i32); #[link_name = "llvm.s390.vmslg"] fn vmslg(a: vector_unsigned_long_long, b: vector_unsigned_long_long, c: u128, d: u32) -> u128; @@ -281,17 +275,17 @@ unsafe extern "llvm-intrinsic" { #[link_name = "llvm.s390.vstrch"] fn vstrch(a: vector_unsigned_short, b: vector_unsigned_short, c: vector_unsigned_short, d: u32) -> vector_bool_short; #[link_name = "llvm.s390.vstrcf"] fn vstrcf(a: vector_unsigned_int, b: vector_unsigned_int, c: vector_unsigned_int, d: u32) -> vector_bool_int; - #[link_name = "llvm.s390.vstrcbs"] fn vstrcbs(a: vector_unsigned_char, b: vector_unsigned_char, c: vector_unsigned_char, d: u32) -> PackedTuple; - #[link_name = "llvm.s390.vstrchs"] fn vstrchs(a: vector_unsigned_short, b: vector_unsigned_short, c: vector_unsigned_short, d: u32) -> PackedTuple; - #[link_name = "llvm.s390.vstrcfs"] fn vstrcfs(a: vector_unsigned_int, b: vector_unsigned_int, c: vector_unsigned_int, d: u32) -> PackedTuple; + #[link_name = "llvm.s390.vstrcbs"] fn vstrcbs(a: vector_unsigned_char, b: vector_unsigned_char, c: vector_unsigned_char, d: u32) -> (vector_bool_char, i32); + #[link_name = "llvm.s390.vstrchs"] fn vstrchs(a: vector_unsigned_short, b: vector_unsigned_short, c: vector_unsigned_short, d: u32) -> (vector_bool_short, i32); + #[link_name = "llvm.s390.vstrcfs"] fn vstrcfs(a: vector_unsigned_int, b: vector_unsigned_int, c: vector_unsigned_int, d: u32) -> (vector_bool_int, i32); #[link_name = "llvm.s390.vstrczb"] fn vstrczb(a: vector_unsigned_char, b: vector_unsigned_char, c: vector_unsigned_char, d: u32) -> vector_bool_char; #[link_name = "llvm.s390.vstrczh"] fn vstrczh(a: vector_unsigned_short, b: vector_unsigned_short, c: vector_unsigned_short, d: u32) -> vector_bool_short; #[link_name = "llvm.s390.vstrczf"] fn vstrczf(a: vector_unsigned_int, b: vector_unsigned_int, c: vector_unsigned_int, d: u32) -> vector_bool_int; - #[link_name = "llvm.s390.vstrczbs"] fn vstrczbs(a: vector_unsigned_char, b: vector_unsigned_char, c: vector_unsigned_char, d: u32) -> PackedTuple; - #[link_name = "llvm.s390.vstrczhs"] fn vstrczhs(a: vector_unsigned_short, b: vector_unsigned_short, c: vector_unsigned_short, d: u32) -> PackedTuple; - #[link_name = "llvm.s390.vstrczfs"] fn vstrczfs(a: vector_unsigned_int, b: vector_unsigned_int, c: vector_unsigned_int, d: u32) -> PackedTuple; + #[link_name = "llvm.s390.vstrczbs"] fn vstrczbs(a: vector_unsigned_char, b: vector_unsigned_char, c: vector_unsigned_char, d: u32) -> (vector_bool_char, i32); + #[link_name = "llvm.s390.vstrczhs"] fn vstrczhs(a: vector_unsigned_short, b: vector_unsigned_short, c: vector_unsigned_short, d: u32) -> (vector_bool_short, i32); + #[link_name = "llvm.s390.vstrczfs"] fn vstrczfs(a: vector_unsigned_int, b: vector_unsigned_int, c: vector_unsigned_int, d: u32) -> (vector_bool_int, i32); #[link_name = "llvm.s390.vfeeb"] fn vfeeb(a: i8x16, b: i8x16) -> i8x16; #[link_name = "llvm.s390.vfeeh"] fn vfeeh(a: i16x8, b: i16x8) -> i16x8; @@ -301,13 +295,13 @@ unsafe extern "llvm-intrinsic" { #[link_name = "llvm.s390.vfeezh"] fn vfeezh(a: i16x8, b: i16x8) -> i16x8; #[link_name = "llvm.s390.vfeezf"] fn vfeezf(a: i32x4, b: i32x4) -> i32x4; - #[link_name = "llvm.s390.vfeebs"] fn vfeebs(a: i8x16, b: i8x16) -> PackedTuple; - #[link_name = "llvm.s390.vfeehs"] fn vfeehs(a: i16x8, b: i16x8) -> PackedTuple; - #[link_name = "llvm.s390.vfeefs"] fn vfeefs(a: i32x4, b: i32x4) -> PackedTuple; + #[link_name = "llvm.s390.vfeebs"] fn vfeebs(a: i8x16, b: i8x16) -> (i8x16, i32); + #[link_name = "llvm.s390.vfeehs"] fn vfeehs(a: i16x8, b: i16x8) -> (i16x8, i32); + #[link_name = "llvm.s390.vfeefs"] fn vfeefs(a: i32x4, b: i32x4) -> (i32x4, i32); - #[link_name = "llvm.s390.vfeezbs"] fn vfeezbs(a: i8x16, b: i8x16) -> PackedTuple; - #[link_name = "llvm.s390.vfeezhs"] fn vfeezhs(a: i16x8, b: i16x8) -> PackedTuple; - #[link_name = "llvm.s390.vfeezfs"] fn vfeezfs(a: i32x4, b: i32x4) -> PackedTuple; + #[link_name = "llvm.s390.vfeezbs"] fn vfeezbs(a: i8x16, b: i8x16) -> (i8x16, i32); + #[link_name = "llvm.s390.vfeezhs"] fn vfeezhs(a: i16x8, b: i16x8) -> (i16x8, i32); + #[link_name = "llvm.s390.vfeezfs"] fn vfeezfs(a: i32x4, b: i32x4) -> (i32x4, i32); #[link_name = "llvm.s390.vfeneb"] fn vfeneb(a: i8x16, b: i8x16) -> i8x16; #[link_name = "llvm.s390.vfeneh"] fn vfeneh(a: i16x8, b: i16x8) -> i16x8; @@ -317,13 +311,13 @@ unsafe extern "llvm-intrinsic" { #[link_name = "llvm.s390.vfenezh"] fn vfenezh(a: i16x8, b: i16x8) -> i16x8; #[link_name = "llvm.s390.vfenezf"] fn vfenezf(a: i32x4, b: i32x4) -> i32x4; - #[link_name = "llvm.s390.vfenebs"] fn vfenebs(a: i8x16, b: i8x16) -> PackedTuple; - #[link_name = "llvm.s390.vfenehs"] fn vfenehs(a: i16x8, b: i16x8) -> PackedTuple; - #[link_name = "llvm.s390.vfenefs"] fn vfenefs(a: i32x4, b: i32x4) -> PackedTuple; + #[link_name = "llvm.s390.vfenebs"] fn vfenebs(a: i8x16, b: i8x16) -> (i8x16, i32); + #[link_name = "llvm.s390.vfenehs"] fn vfenehs(a: i16x8, b: i16x8) -> (i16x8, i32); + #[link_name = "llvm.s390.vfenefs"] fn vfenefs(a: i32x4, b: i32x4) -> (i32x4, i32); - #[link_name = "llvm.s390.vfenezbs"] fn vfenezbs(a: i8x16, b: i8x16) -> PackedTuple; - #[link_name = "llvm.s390.vfenezhs"] fn vfenezhs(a: i16x8, b: i16x8) -> PackedTuple; - #[link_name = "llvm.s390.vfenezfs"] fn vfenezfs(a: i32x4, b: i32x4) -> PackedTuple; + #[link_name = "llvm.s390.vfenezbs"] fn vfenezbs(a: i8x16, b: i8x16) -> (i8x16, i32); + #[link_name = "llvm.s390.vfenezhs"] fn vfenezhs(a: i16x8, b: i16x8) -> (i16x8, i32); + #[link_name = "llvm.s390.vfenezfs"] fn vfenezfs(a: i32x4, b: i32x4) -> (i32x4, i32); #[link_name = "llvm.s390.vclfnhs"] fn vclfnhs(a: vector_signed_short, immarg: i32) -> vector_float; #[link_name = "llvm.s390.vclfnls"] fn vclfnls(a: vector_signed_short, immarg: i32) -> vector_float; @@ -2042,7 +2036,7 @@ mod sealed { #[inline] #[target_feature(enable = "vector")] unsafe fn $m(self, b: Self) -> (Self::Result, i32) { - let PackedTuple { x, y } = $fun::<{ FindImm::$imm as i32 }>(transmute(self), transmute(b)); + let (x, y) = $fun::<{ FindImm::$imm as i32 }>(transmute(self), transmute(b)); (transmute(x), y) } } @@ -2071,7 +2065,7 @@ mod sealed { #[inline] #[target_feature(enable = "vector")] unsafe fn $m(self, b: Self) -> (Self::Result, i32) { - let PackedTuple { x, y } = $fun::<{ FindImm::$imm as i32 }>(transmute(self), transmute(b)); + let (x, y) = $fun::<{ FindImm::$imm as i32 }>(transmute(self), transmute(b)); (transmute(x), y) } } @@ -2216,7 +2210,7 @@ mod sealed { unsafe fn $name( a: $ty, b: $ty, - ) -> PackedTuple<$ty, i32> { + ) -> ($ty, i32) { super::$name(a, b, IMM) } )* @@ -2533,8 +2527,7 @@ mod sealed { a: $ty, b: $ty, ) -> ($outty, i32) { - let PackedTuple { x, y } = super::$intr(a, b); - (x, y) + super::$intr(a, b) } #[unstable(feature = "stdarch_s390x", issue = "135681")] @@ -3184,8 +3177,7 @@ mod sealed { #[inline] #[target_feature(enable = "vector")] unsafe fn vec_fp_test_data_class(self) -> (Self::Result, i32) { - let PackedTuple { x, y } = vftcisb(self, CLASS); - (x, y) + vftcisb(self, CLASS) } } @@ -3196,8 +3188,7 @@ mod sealed { #[inline] #[target_feature(enable = "vector")] unsafe fn vec_fp_test_data_class(self) -> (Self::Result, i32) { - let PackedTuple { x, y } = vftcidb(self, CLASS); - (x, y) + vftcidb(self, CLASS) } } @@ -3321,15 +3312,13 @@ mod sealed { #[inline] #[target_feature(enable = "vector-enhancements-2")] unsafe fn vec_search_string_cc(self, b: Self, c: vector_unsigned_char) -> (vector_unsigned_char, i32) { - let PackedTuple { x,y } = $intr_s(transmute(self), transmute(b), c); - (x, y) + $intr_s(transmute(self), transmute(b), c) } #[inline] #[target_feature(enable = "vector-enhancements-2")] unsafe fn vec_search_string_until_zero_cc(self, b: Self, c: vector_unsigned_char) -> (vector_unsigned_char, i32) { - let PackedTuple { x,y } = $intr_sz(transmute(self), transmute(b), c); - (x, y) + $intr_sz(transmute(self), transmute(b), c) } } @@ -3549,9 +3538,9 @@ mod sealed { unsafe fn vec_cp_until_zero_cc(self) -> (Self, i32); } - test_impl! { vec_vistrbs (a: vector_unsigned_char) -> PackedTuple [vistrbs, vistrbs] } - test_impl! { vec_vistrhs (a: vector_unsigned_short) -> PackedTuple [vistrhs, vistrhs] } - test_impl! { vec_vistrfs (a: vector_unsigned_int) -> PackedTuple [vistrfs, vistrfs] } + test_impl! { vec_vistrbs (a: vector_unsigned_char) -> (vector_unsigned_char, i32) [vistrbs, vistrbs] } + test_impl! { vec_vistrhs (a: vector_unsigned_short) -> (vector_unsigned_short, i32) [vistrhs, vistrhs] } + test_impl! { vec_vistrfs (a: vector_unsigned_int) -> (vector_unsigned_int, i32) [vistrfs, vistrfs] } macro_rules! impl_vec_copy_until_zero_cc { ($($intr:ident $ty:ident)*) => { @@ -3561,7 +3550,7 @@ mod sealed { #[inline] #[target_feature(enable = "vector")] unsafe fn vec_cp_until_zero_cc(self) -> (Self, i32) { - let PackedTuple { x,y } = $intr(transmute(self)); + let (x, y) = $intr(transmute(self)); (transmute(x), y) } } @@ -3728,7 +3717,7 @@ mod sealed { #[target_feature(enable = "vector")] unsafe fn vstrcs(self, b: Self, c: Self) -> (Self::Result, i32) { const { validate_compare_range_imm }; - let PackedTuple { x, y } = $vstrcs(self, b, c, IMM); + let (x, y) = $vstrcs(self, b, c, IMM); (x,y) } @@ -3736,7 +3725,7 @@ mod sealed { #[target_feature(enable = "vector")] unsafe fn vstrczs(self, b: Self, c: Self) -> (Self::Result, i32) { const { validate_compare_range_imm }; - let PackedTuple { x, y } = $vstrczs(self, b, c, IMM); + let (x, y) = $vstrczs(self, b, c, IMM); (x,y) } } @@ -3910,28 +3899,28 @@ mod sealed { #[inline] #[target_feature(enable = "vector")] unsafe fn vec_cmpeq_idx_cc(self, other: Self) -> (Self::Result, i32) { - let PackedTuple { x, y } = $cmpeq_cc(transmute(self), transmute(other)); + let (x, y) = $cmpeq_cc(transmute(self), transmute(other)); (transmute(x), y) } #[inline] #[target_feature(enable = "vector")] unsafe fn vec_cmpne_idx_cc(self, other: Self) -> (Self::Result, i32) { - let PackedTuple { x, y } = $cmpne_cc(transmute(self), transmute(other)); + let (x, y) = $cmpne_cc(transmute(self), transmute(other)); (transmute(x),y) } #[inline] #[target_feature(enable = "vector")] unsafe fn vec_cmpeq_or_0_idx_cc(self, other: Self) -> (Self::Result, i32) { - let PackedTuple { x, y } = $cmpeq_or_0_cc(transmute(self), transmute(other)); + let (x, y) = $cmpeq_or_0_cc(transmute(self), transmute(other)); (transmute(x), y) } #[inline] #[target_feature(enable = "vector")] unsafe fn vec_cmpne_or_0_idx_cc(self, other: Self) -> (Self::Result, i32) { - let PackedTuple { x, y } = $cmpne_or_0_cc(transmute(self), transmute(other)); + let (x, y) = $cmpne_or_0_cc(transmute(self), transmute(other)); (transmute(x),y) } } diff --git a/crates/core_arch/src/x86/kl.rs b/crates/core_arch/src/x86/kl.rs index 5c8a6de383..3e7d7bff9d 100644 --- a/crates/core_arch/src/x86/kl.rs +++ b/crates/core_arch/src/x86/kl.rs @@ -8,26 +8,7 @@ use crate::ptr; #[cfg(test)] use stdarch_test::assert_instr; -#[repr(C, packed)] -struct EncodeKey128Output(u32, __m128i, __m128i, __m128i, __m128i, __m128i, __m128i); - -#[repr(C, packed)] -struct EncodeKey256Output( - u32, - __m128i, - __m128i, - __m128i, - __m128i, - __m128i, - __m128i, - __m128i, -); - -#[repr(C, packed)] -struct AesOutput(u8, __m128i); - -#[repr(C, packed)] -struct WideAesOutput( +type WideAesOutput = ( u8, __m128i, __m128i, @@ -39,24 +20,40 @@ struct WideAesOutput( __m128i, ); -#[allow(improper_ctypes)] +#[expect(improper_ctypes)] unsafe extern "llvm-intrinsic" { #[link_name = "llvm.x86.loadiwkey"] fn loadiwkey(integrity_key: __m128i, key_lo: __m128i, key_hi: __m128i, control: u32); #[link_name = "llvm.x86.encodekey128"] - fn encodekey128(key_metadata: u32, key: __m128i) -> EncodeKey128Output; + fn encodekey128( + key_metadata: u32, + key: __m128i, + ) -> (u32, __m128i, __m128i, __m128i, __m128i, __m128i, __m128i); #[link_name = "llvm.x86.encodekey256"] - fn encodekey256(key_metadata: u32, key_lo: __m128i, key_hi: __m128i) -> EncodeKey256Output; + fn encodekey256( + key_metadata: u32, + key_lo: __m128i, + key_hi: __m128i, + ) -> ( + u32, + __m128i, + __m128i, + __m128i, + __m128i, + __m128i, + __m128i, + __m128i, + ); #[link_name = "llvm.x86.aesenc128kl"] - fn aesenc128kl(data: __m128i, handle: *const u8) -> AesOutput; + fn aesenc128kl(data: __m128i, handle: *const u8) -> (u8, __m128i); #[link_name = "llvm.x86.aesdec128kl"] - fn aesdec128kl(data: __m128i, handle: *const u8) -> AesOutput; + fn aesdec128kl(data: __m128i, handle: *const u8) -> (u8, __m128i); #[link_name = "llvm.x86.aesenc256kl"] - fn aesenc256kl(data: __m128i, handle: *const u8) -> AesOutput; + fn aesenc256kl(data: __m128i, handle: *const u8) -> (u8, __m128i); #[link_name = "llvm.x86.aesdec256kl"] - fn aesdec256kl(data: __m128i, handle: *const u8) -> AesOutput; + fn aesdec256kl(data: __m128i, handle: *const u8) -> (u8, __m128i); #[link_name = "llvm.x86.aesencwide128kl"] fn aesencwide128kl( @@ -156,7 +153,7 @@ pub unsafe fn _mm_loadiwkey( #[stable(feature = "keylocker_x86", since = "1.89.0")] #[cfg_attr(test, assert_instr(encodekey128))] pub unsafe fn _mm_encodekey128_u32(key_params: u32, key: __m128i, handle: *mut u8) -> u32 { - let EncodeKey128Output(control, key0, key1, key2, _, _, _) = encodekey128(key_params, key); + let (control, key0, key1, key2, _, _, _) = encodekey128(key_params, key); ptr::write_unaligned(handle.cast(), [key0, key1, key2]); control } @@ -184,8 +181,7 @@ pub unsafe fn _mm_encodekey256_u32( key_hi: __m128i, handle: *mut u8, ) -> u32 { - let EncodeKey256Output(control, key0, key1, key2, key3, _, _, _) = - encodekey256(key_params, key_lo, key_hi); + let (control, key0, key1, key2, key3, _, _, _) = encodekey256(key_params, key_lo, key_hi); ptr::write_unaligned(handle.cast(), [key0, key1, key2, key3]); control } @@ -201,7 +197,7 @@ pub unsafe fn _mm_encodekey256_u32( #[stable(feature = "keylocker_x86", since = "1.89.0")] #[cfg_attr(test, assert_instr(aesenc128kl))] pub unsafe fn _mm_aesenc128kl_u8(output: *mut __m128i, input: __m128i, handle: *const u8) -> u8 { - let AesOutput(status, result) = aesenc128kl(input, handle); + let (status, result) = aesenc128kl(input, handle); *output = result; status } @@ -217,7 +213,7 @@ pub unsafe fn _mm_aesenc128kl_u8(output: *mut __m128i, input: __m128i, handle: * #[stable(feature = "keylocker_x86", since = "1.89.0")] #[cfg_attr(test, assert_instr(aesdec128kl))] pub unsafe fn _mm_aesdec128kl_u8(output: *mut __m128i, input: __m128i, handle: *const u8) -> u8 { - let AesOutput(status, result) = aesdec128kl(input, handle); + let (status, result) = aesdec128kl(input, handle); *output = result; status } @@ -233,7 +229,7 @@ pub unsafe fn _mm_aesdec128kl_u8(output: *mut __m128i, input: __m128i, handle: * #[stable(feature = "keylocker_x86", since = "1.89.0")] #[cfg_attr(test, assert_instr(aesenc256kl))] pub unsafe fn _mm_aesenc256kl_u8(output: *mut __m128i, input: __m128i, handle: *const u8) -> u8 { - let AesOutput(status, result) = aesenc256kl(input, handle); + let (status, result) = aesenc256kl(input, handle); *output = result; status } @@ -249,7 +245,7 @@ pub unsafe fn _mm_aesenc256kl_u8(output: *mut __m128i, input: __m128i, handle: * #[stable(feature = "keylocker_x86", since = "1.89.0")] #[cfg_attr(test, assert_instr(aesdec256kl))] pub unsafe fn _mm_aesdec256kl_u8(output: *mut __m128i, input: __m128i, handle: *const u8) -> u8 { - let AesOutput(status, result) = aesdec256kl(input, handle); + let (status, result) = aesdec256kl(input, handle); *output = result; status } @@ -270,7 +266,7 @@ pub unsafe fn _mm_aesencwide128kl_u8( handle: *const u8, ) -> u8 { let input = &*ptr::slice_from_raw_parts(input, 8); - let WideAesOutput(status, out0, out1, out2, out3, out4, out5, out6, out7) = aesencwide128kl( + let (status, out0, out1, out2, out3, out4, out5, out6, out7) = aesencwide128kl( handle, input[0], input[1], input[2], input[3], input[4], input[5], input[6], input[7], ); *output.cast() = [out0, out1, out2, out3, out4, out5, out6, out7]; @@ -293,7 +289,7 @@ pub unsafe fn _mm_aesdecwide128kl_u8( handle: *const u8, ) -> u8 { let input = &*ptr::slice_from_raw_parts(input, 8); - let WideAesOutput(status, out0, out1, out2, out3, out4, out5, out6, out7) = aesdecwide128kl( + let (status, out0, out1, out2, out3, out4, out5, out6, out7) = aesdecwide128kl( handle, input[0], input[1], input[2], input[3], input[4], input[5], input[6], input[7], ); *output.cast() = [out0, out1, out2, out3, out4, out5, out6, out7]; @@ -316,7 +312,7 @@ pub unsafe fn _mm_aesencwide256kl_u8( handle: *const u8, ) -> u8 { let input = &*ptr::slice_from_raw_parts(input, 8); - let WideAesOutput(status, out0, out1, out2, out3, out4, out5, out6, out7) = aesencwide256kl( + let (status, out0, out1, out2, out3, out4, out5, out6, out7) = aesencwide256kl( handle, input[0], input[1], input[2], input[3], input[4], input[5], input[6], input[7], ); *output.cast() = [out0, out1, out2, out3, out4, out5, out6, out7]; @@ -339,7 +335,7 @@ pub unsafe fn _mm_aesdecwide256kl_u8( handle: *const u8, ) -> u8 { let input = &*ptr::slice_from_raw_parts(input, 8); - let WideAesOutput(status, out0, out1, out2, out3, out4, out5, out6, out7) = aesdecwide256kl( + let (status, out0, out1, out2, out3, out4, out5, out6, out7) = aesdecwide256kl( handle, input[0], input[1], input[2], input[3], input[4], input[5], input[6], input[7], ); *output.cast() = [out0, out1, out2, out3, out4, out5, out6, out7];