Skip to content

Commit f42a8e7

Browse files
authored
Merge pull request #1915 from heiher/fix-signatures
loongarch: Align intrinsic signatures with LLVM
2 parents f48e68d + 7cabd71 commit f42a8e7

File tree

3 files changed

+20
-16
lines changed

3 files changed

+20
-16
lines changed

crates/core_arch/src/loongarch32/mod.rs

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,9 +17,10 @@ unsafe extern "unadjusted" {
1717
/// Generates the cache operation instruction
1818
#[inline]
1919
#[unstable(feature = "stdarch_loongarch", issue = "117427")]
20-
pub unsafe fn cacop<const IMM12: i32>(a: i32, b: i32) {
21-
static_assert_simm_bits!(IMM12, 12);
22-
__cacop(a, b, IMM12);
20+
pub unsafe fn cacop<const IMM5: i32, const IMM_S12: i32>(b: i32) {
21+
static_assert_uimm_bits!(IMM5, 5);
22+
static_assert_simm_bits!(IMM_S12, 12);
23+
__cacop(IMM5, b, IMM_S12);
2324
}
2425

2526
/// Reads the CSR

crates/core_arch/src/loongarch64/mod.rs

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -64,9 +64,10 @@ pub fn crcc_w_d_w(a: i64, b: i32) -> i32 {
6464
/// Generates the cache operation instruction
6565
#[inline]
6666
#[unstable(feature = "stdarch_loongarch", issue = "117427")]
67-
pub unsafe fn cacop<const IMM12: i64>(a: i64, b: i64) {
68-
static_assert_simm_bits!(IMM12, 12);
69-
__cacop(a, b, IMM12);
67+
pub unsafe fn cacop<const IMM5: i64, const IMM_S12: i64>(b: i64) {
68+
static_assert_uimm_bits!(IMM5, 5);
69+
static_assert_simm_bits!(IMM_S12, 12);
70+
__cacop(IMM5, b, IMM_S12);
7071
}
7172

7273
/// Reads the CSR
@@ -125,14 +126,16 @@ pub unsafe fn asrtgt(a: i64, b: i64) {
125126
#[inline]
126127
#[rustc_legacy_const_generics(1)]
127128
#[unstable(feature = "stdarch_loongarch", issue = "117427")]
128-
pub unsafe fn lddir<const B: i64>(a: i64) -> i64 {
129-
__lddir(a, B)
129+
pub unsafe fn lddir<const IMM8: i64>(a: i64) -> i64 {
130+
static_assert_uimm_bits!(IMM8, 8);
131+
__lddir(a, IMM8)
130132
}
131133

132134
/// Loads the page table entry
133135
#[inline]
134136
#[rustc_legacy_const_generics(1)]
135137
#[unstable(feature = "stdarch_loongarch", issue = "117427")]
136-
pub unsafe fn ldpte<const B: i64>(a: i64) {
137-
__ldpte(a, B)
138+
pub unsafe fn ldpte<const IMM8: i64>(a: i64) {
139+
static_assert_uimm_bits!(IMM8, 8);
140+
__ldpte(a, IMM8)
138141
}

crates/core_arch/src/loongarch_shared/mod.rs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -131,17 +131,17 @@ pub fn ibar<const IMM15: i32>() {
131131
/// Moves data from a GPR to the FCSR
132132
#[inline]
133133
#[unstable(feature = "stdarch_loongarch", issue = "117427")]
134-
pub unsafe fn movgr2fcsr<const IMM5: i32>(a: i32) {
135-
static_assert_uimm_bits!(IMM5, 5);
136-
__movgr2fcsr(IMM5, a);
134+
pub unsafe fn movgr2fcsr<const IMM2: i32>(a: i32) {
135+
static_assert_uimm_bits!(IMM2, 2);
136+
__movgr2fcsr(IMM2, a);
137137
}
138138

139139
/// Moves data from a FCSR to the GPR
140140
#[inline]
141141
#[unstable(feature = "stdarch_loongarch", issue = "117427")]
142-
pub fn movfcsr2gr<const IMM5: i32>() -> i32 {
143-
static_assert_uimm_bits!(IMM5, 5);
144-
unsafe { __movfcsr2gr(IMM5) }
142+
pub fn movfcsr2gr<const IMM2: i32>() -> i32 {
143+
static_assert_uimm_bits!(IMM2, 2);
144+
unsafe { __movfcsr2gr(IMM2) }
145145
}
146146

147147
/// Reads the 8-bit IO-CSR

0 commit comments

Comments
 (0)