diff options
Diffstat (limited to 'vendor/compiler_builtins/src/riscv.rs')
-rw-r--r-- | vendor/compiler_builtins/src/riscv.rs | 34 |
1 files changed, 34 insertions, 0 deletions
diff --git a/vendor/compiler_builtins/src/riscv.rs b/vendor/compiler_builtins/src/riscv.rs new file mode 100644 index 000000000..ee78b9dba --- /dev/null +++ b/vendor/compiler_builtins/src/riscv.rs @@ -0,0 +1,34 @@ +intrinsics! { + // Implementation from gcc + // https://raw.githubusercontent.com/gcc-mirror/gcc/master/libgcc/config/epiphany/mulsi3.c + pub extern "C" fn __mulsi3(a: u32, b: u32) -> u32 { + 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 + } + + #[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 + } +} |