diff --git a/crates/core_arch/src/riscv32/zk.rs b/crates/core_arch/src/riscv32/zk.rs index b32054c11a..4c090c5cd0 100644 --- a/crates/core_arch/src/riscv32/zk.rs +++ b/crates/core_arch/src/riscv32/zk.rs @@ -1,15 +1,6 @@ #[cfg(test)] use stdarch_test::assert_instr; -macro_rules! static_assert_imm2 { - ($imm:ident) => { - static_assert!( - $imm < 4, - "Immediate value allowed to be a constant from 0 up to including 3" - ) - }; -} - extern "unadjusted" { #[link_name = "llvm.riscv.aes32esi"] fn _aes32esi(rs1: i32, rs2: i32, bs: i32) -> i32; @@ -71,10 +62,10 @@ extern "unadjusted" { /// This function is safe to use if the `zkne` target feature is present. #[target_feature(enable = "zkne")] #[rustc_legacy_const_generics(2)] -#[cfg_attr(test, assert_instr(aes32esi))] +#[cfg_attr(test, assert_instr(aes32esi, BS = 0))] #[inline] pub unsafe fn aes32esi(rs1: u32, rs2: u32) -> u32 { - static_assert_imm2!(BS); + static_assert!(BS < 4); _aes32esi(rs1 as i32, rs2 as i32, BS as i32) as u32 } @@ -102,10 +93,10 @@ pub unsafe fn aes32esi(rs1: u32, rs2: u32) -> u32 { /// This function is safe to use if the `zkne` target feature is present. #[target_feature(enable = "zkne")] #[rustc_legacy_const_generics(2)] -#[cfg_attr(test, assert_instr(aes32esmi))] +#[cfg_attr(test, assert_instr(aes32esmi, BS = 0))] #[inline] pub unsafe fn aes32esmi(rs1: u32, rs2: u32) -> u32 { - static_assert_imm2!(BS); + static_assert!(BS < 4); _aes32esmi(rs1 as i32, rs2 as i32, BS as i32) as u32 } @@ -132,10 +123,10 @@ pub unsafe fn aes32esmi(rs1: u32, rs2: u32) -> u32 { /// This function is safe to use if the `zknd` target feature is present. #[target_feature(enable = "zknd")] #[rustc_legacy_const_generics(2)] -#[cfg_attr(test, assert_instr(aes32dsi))] +#[cfg_attr(test, assert_instr(aes32dsi, BS = 0))] #[inline] pub unsafe fn aes32dsi(rs1: u32, rs2: u32) -> u32 { - static_assert_imm2!(BS); + static_assert!(BS < 4); _aes32dsi(rs1 as i32, rs2 as i32, BS as i32) as u32 } @@ -163,10 +154,10 @@ pub unsafe fn aes32dsi(rs1: u32, rs2: u32) -> u32 { /// This function is safe to use if the `zknd` target feature is present. #[target_feature(enable = "zknd")] #[rustc_legacy_const_generics(2)] -#[cfg_attr(test, assert_instr(aes32dsmi))] +#[cfg_attr(test, assert_instr(aes32dsmi, BS = 0))] #[inline] pub unsafe fn aes32dsmi(rs1: u32, rs2: u32) -> u32 { - static_assert_imm2!(BS); + static_assert!(BS < 4); _aes32dsmi(rs1 as i32, rs2 as i32, BS as i32) as u32 } diff --git a/crates/core_arch/src/riscv64/zk.rs b/crates/core_arch/src/riscv64/zk.rs index 5df9cb80d1..bdceb9a268 100644 --- a/crates/core_arch/src/riscv64/zk.rs +++ b/crates/core_arch/src/riscv64/zk.rs @@ -1,15 +1,6 @@ #[cfg(test)] use stdarch_test::assert_instr; -macro_rules! static_assert_imm_0_until_10 { - ($imm:ident) => { - static_assert!( - $imm <= 10, - "Immediate value allowed to be a constant from 0 up to including 10" - ) - }; -} - extern "unadjusted" { #[link_name = "llvm.riscv.aes64es"] fn _aes64es(rs1: i64, rs2: i64) -> i64; @@ -157,10 +148,10 @@ pub unsafe fn aes64dsm(rs1: u64, rs2: u64) -> u64 { /// This function is safe to use if the `zkne` or `zknd` target feature is present. #[target_feature(enable = "zkne", enable = "zknd")] #[rustc_legacy_const_generics(1)] -#[cfg_attr(test, assert_instr(aes64ks1i))] +#[cfg_attr(test, assert_instr(aes64ks1i, RNUM = 0))] #[inline] pub unsafe fn aes64ks1i(rs1: u64) -> u64 { - static_assert_imm_0_until_10!(RNUM); + static_assert!(RNUM <= 10); _aes64ks1i(rs1 as i64, RNUM as i32) as u64 } diff --git a/crates/core_arch/src/riscv_shared/zk.rs b/crates/core_arch/src/riscv_shared/zk.rs index beda7cd763..5fc5b4cdaf 100644 --- a/crates/core_arch/src/riscv_shared/zk.rs +++ b/crates/core_arch/src/riscv_shared/zk.rs @@ -1,15 +1,6 @@ #[cfg(test)] use stdarch_test::assert_instr; -macro_rules! static_assert_imm2 { - ($imm:ident) => { - static_assert!( - $imm < 4, - "Immediate value allowed to be a constant from 0 up to including 3" - ) - }; -} - extern "unadjusted" { #[link_name = "llvm.riscv.sm4ed"] fn _sm4ed(rs1: i32, rs2: i32, bs: i32) -> i32; @@ -291,10 +282,10 @@ pub unsafe fn sha256sum1(rs1: u32) -> u32 { /// ``` #[target_feature(enable = "zksed")] #[rustc_legacy_const_generics(2)] -#[cfg_attr(test, assert_instr(sm4ed))] +#[cfg_attr(test, assert_instr(sm4ed, BS = 0))] #[inline] pub unsafe fn sm4ed(rs1: u32, rs2: u32) -> u32 { - static_assert_imm2!(BS); + static_assert!(BS < 4); _sm4ed(rs1 as i32, rs2 as i32, BS as i32) as u32 } @@ -370,10 +361,10 @@ pub unsafe fn sm4ed(rs1: u32, rs2: u32) -> u32 { /// ``` #[target_feature(enable = "zksed")] #[rustc_legacy_const_generics(2)] -#[cfg_attr(test, assert_instr(sm4ks))] +#[cfg_attr(test, assert_instr(sm4ks, BS = 0))] #[inline] pub unsafe fn sm4ks(rs1: u32, rs2: u32) -> u32 { - static_assert_imm2!(BS); + static_assert!(BS < 4); _sm4ks(rs1 as i32, rs2 as i32, BS as i32) as u32 }