Skip to content

Commit b274247

Browse files
committed
Impr: Remove pack instructions as instrinsics
1 parent 36154d7 commit b274247

File tree

2 files changed

+0
-67
lines changed

2 files changed

+0
-67
lines changed

crates/core_arch/src/riscv64/zk.rs

-34
Original file line numberDiff line numberDiff line change
@@ -189,40 +189,6 @@ pub unsafe fn aes64ks2(rs1: u64, rs2: u64) -> u64 {
189189
_aes64ks2(rs1 as i64, rs2 as i64) as u64
190190
}
191191

192-
/// Pack the low 16-bits of rs1 and rs2 into rd on RV64
193-
///
194-
/// This instruction packs the low 16 bits of rs1 and rs2 into the 32 least-significant bits of
195-
/// rd, sign extending the 32-bit result to the rest of rd. This instruction only exists on
196-
/// RV64 based systems.
197-
///
198-
/// Source: RISC-V Cryptography Extensions Volume I: Scalar & Entropy Source Instructions
199-
///
200-
/// Version: v1.0.1
201-
///
202-
/// Section: 3.26
203-
///
204-
/// # Safety
205-
///
206-
/// This function is safe to use if the `zbkb` target feature is present.
207-
#[target_feature(enable = "zbkb")]
208-
#[cfg_attr(test, assert_instr(packw))]
209-
#[inline]
210-
pub unsafe fn packw(rs1: u64, rs2: u64) -> u64 {
211-
// Note: There is no LLVM intrinsic for this instruction currently.
212-
213-
let value: u64;
214-
unsafe {
215-
asm!(
216-
"packw {rd},{rs1},{rs2}",
217-
rd = lateout(reg) value,
218-
rs1 = in(reg) rs1,
219-
rs2 = in(reg) rs2,
220-
options(pure, nomem, nostack),
221-
)
222-
}
223-
value
224-
}
225-
226192
/// Implements the Sigma0 transformation function as used in the SHA2-512 hash function \[49\]
227193
/// (Section 4.1.3).
228194
///

crates/core_arch/src/riscv_shared/zk.rs

-33
Original file line numberDiff line numberDiff line change
@@ -56,39 +56,6 @@ extern "unadjusted" {
5656
fn _xperm4_64(rs1: i64, rs2: i64) -> i64;
5757
}
5858

59-
/// Pack the low bytes of rs1 and rs2 into rd.
60-
///
61-
/// And the packh instruction packs the least-significant bytes of rs1 and rs2 into the 16
62-
/// least-significant bits of rd, zero extending the rest of rd.
63-
///
64-
/// Source: RISC-V Cryptography Extensions Volume I: Scalar & Entropy Source Instructions
65-
///
66-
/// Version: v1.0.1
67-
///
68-
/// Section: 3.18
69-
///
70-
/// # Safety
71-
///
72-
/// This function is safe to use if the `zbkb` target feature is present.
73-
#[target_feature(enable = "zbkb")]
74-
#[cfg_attr(test, assert_instr(packh))]
75-
#[inline]
76-
pub unsafe fn packh(rs1: usize, rs2: usize) -> usize {
77-
// Note: There is no LLVM intrinsic for this instruction currently.
78-
79-
let value: usize;
80-
unsafe {
81-
asm!(
82-
"packh {rd},{rs1},{rs2}",
83-
rd = lateout(reg) value,
84-
rs1 = in(reg) rs1,
85-
rs2 = in(reg) rs2,
86-
options(pure, nomem, nostack),
87-
)
88-
}
89-
value
90-
}
91-
9259
/// Byte-wise lookup of indicies into a vector in registers.
9360
///
9461
/// The xperm8 instruction operates on bytes. The rs1 register contains a vector of XLEN/8

0 commit comments

Comments
 (0)