Fix: Add constant for assert_instr

This commit is contained in:
Gijs Burghoorn 2023-08-29 20:10:22 +02:00 committed by Amanieu d'Antras
parent 0b5a5ce567
commit f669624b6f
3 changed files with 14 additions and 41 deletions

View file

@ -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<const BS: u8>(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<const BS: u8>(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<const BS: u8>(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<const BS: u8>(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<const BS: u8>(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<const BS: u8>(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<const BS: u8>(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
}

View file

@ -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<const RNUM: u8>(rs1: u64) -> u64 {
static_assert_imm_0_until_10!(RNUM);
static_assert!(RNUM <= 10);
_aes64ks1i(rs1 as i64, RNUM as i32) as u64
}

View file

@ -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<const BS: u8>(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<const BS: u8>(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<const BS: u8>(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
}