Skip to content

Commit 4117da3

Browse files
authored
Merge pull request #461 from johannst/rv64-muldi3
2 parents 19d53ba + 4baa36e commit 4117da3

File tree

3 files changed

+19
-2
lines changed

3 files changed

+19
-2
lines changed

src/int/mul.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -100,6 +100,7 @@ impl_signed_mulo!(i128_overflowing_mul, i128, u128);
100100
intrinsics! {
101101
#[maybe_use_optimized_c_shim]
102102
#[arm_aeabi_alias = __aeabi_lmul]
103+
#[cfg(any(not(any(target_arch = "riscv32", target_arch = "riscv64")), target_feature = "m"))]
103104
pub extern "C" fn __muldi3(a: u64, b: u64) -> u64 {
104105
a.mul(b)
105106
}

src/lib.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -60,8 +60,8 @@ pub mod arm;
6060
))]
6161
pub mod arm_linux;
6262

63-
#[cfg(any(target_arch = "riscv32"))]
64-
pub mod riscv32;
63+
#[cfg(any(target_arch = "riscv32", target_arch = "riscv64"))]
64+
pub mod riscv;
6565

6666
#[cfg(target_arch = "x86")]
6767
pub mod x86;

src/riscv32.rs renamed to src/riscv.rs

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,4 +15,20 @@ intrinsics! {
1515

1616
r
1717
}
18+
19+
#[cfg(not(target_feature = "m"))]
20+
pub extern "C" fn __muldi3(a: u64, b: u64) -> u64 {
21+
let (mut a, mut b) = (a, b);
22+
let mut r = 0;
23+
24+
while a > 0 {
25+
if a & 1 > 0 {
26+
r += b;
27+
}
28+
a >>= 1;
29+
b <<= 1;
30+
}
31+
32+
r
33+
}
1834
}

0 commit comments

Comments
 (0)