Merge pull request #461 from johannst/rv64-muldi3

This commit is contained in:
Amanieu d'Antras 2022-05-12 00:44:18 +02:00 committed by GitHub
commit 7b90df962d
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 19 additions and 2 deletions

View file

@ -100,6 +100,7 @@ impl_signed_mulo!(i128_overflowing_mul, i128, u128);
intrinsics! {
#[maybe_use_optimized_c_shim]
#[arm_aeabi_alias = __aeabi_lmul]
#[cfg(any(not(any(target_arch = "riscv32", target_arch = "riscv64")), target_feature = "m"))]
pub extern "C" fn __muldi3(a: u64, b: u64) -> u64 {
a.mul(b)
}

View file

@ -60,8 +60,8 @@ pub mod arm;
))]
pub mod arm_linux;
#[cfg(any(target_arch = "riscv32"))]
pub mod riscv32;
#[cfg(any(target_arch = "riscv32", target_arch = "riscv64"))]
pub mod riscv;
#[cfg(target_arch = "x86")]
pub mod x86;

View file

@ -15,4 +15,20 @@ intrinsics! {
r
}
#[cfg(not(target_feature = "m"))]
pub extern "C" fn __muldi3(a: u64, b: u64) -> u64 {
let (mut a, mut b) = (a, b);
let mut r = 0;
while a > 0 {
if a & 1 > 0 {
r += b;
}
a >>= 1;
b <<= 1;
}
r
}
}