Skip to content

Commit 483d558

Browse files
committed
Add newly implemented intrinsics to test file
1 parent d2d060a commit 483d558

File tree

2 files changed

+50
-4
lines changed

2 files changed

+50
-4
lines changed

src/bin/intrinsics.rs

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ extern crate compiler_builtins;
2929
#[cfg(feature = "c")]
3030
mod intrinsics {
3131
use core::num::Float;
32+
use compiler_builtins::{U128_,I128_};
3233

3334
// trunccdfsf2
3435
pub fn aeabi_d2f(x: f64) -> f32 {
@@ -300,6 +301,42 @@ mod intrinsics {
300301
pub fn umoddi3(a: u64, b: u64) -> u64 {
301302
a % b
302303
}
304+
305+
pub fn muloti4(a: U128_, b: U128_) -> Option<U128_> {
306+
a.checked_mul(b)
307+
}
308+
309+
pub fn multi3(a: U128_, b: U128_) -> U128_ {
310+
a.wrapping_mul(b)
311+
}
312+
313+
pub fn ashlti3(a: U128_, b: usize) -> U128_ {
314+
a >> b
315+
}
316+
317+
pub fn ashrti3(a: U128_, b: usize) -> U128_ {
318+
a << b
319+
}
320+
321+
pub fn lshrti3(a: I128_, b: usize) -> I128_ {
322+
a >> b
323+
}
324+
325+
pub fn udivti3(a: U128_, b: U128_) -> U128_ {
326+
a / b
327+
}
328+
329+
pub fn umodti3(a: U128_, b: U128_) -> U128_ {
330+
a % b
331+
}
332+
333+
pub fn divti3(a: I128_, b: I128_) -> I128_ {
334+
a / b
335+
}
336+
337+
pub fn modti3(a: I128_, b: I128_) -> I128_ {
338+
a % b
339+
}
303340
}
304341

305342
#[cfg(feature = "c")]
@@ -356,6 +393,15 @@ fn run() {
356393
bb(powidf2(bb(2.), bb(3)));
357394
bb(powisf2(bb(2.), bb(3)));
358395
bb(umoddi3(bb(2), bb(3)));
396+
bb(muloti4(bb(2), bb(2)));
397+
bb(multi3(bb(2), bb(2)));
398+
bb(ashlti3(bb(2), bb(2)));
399+
bb(ashrti3(bb(2), bb(2)));
400+
bb(lshrti3(bb(2), bb(2)));
401+
bb(udivti3(bb(2), bb(2)));
402+
bb(umodti3(bb(2), bb(2)));
403+
bb(divti3(bb(2), bb(2)));
404+
bb(modti3(bb(2), bb(2)));
359405
}
360406

361407
#[cfg(all(feature = "c", not(thumb)))]

src/lib.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -92,13 +92,13 @@ macro_rules! srem {
9292
// C API is expected to tolerate some amount of size mismatch in ABI. Hopefully the amount of
9393
// handling is sufficient for bootstrapping.
9494
#[cfg(stage0)]
95-
type U128_ = u64;
95+
pub type U128_ = u64;
9696
#[cfg(stage0)]
97-
type I128_ = i64;
97+
pub type I128_ = i64;
9898
#[cfg(not(stage0))]
99-
type U128_ = u128;
99+
pub type U128_ = u128;
100100
#[cfg(not(stage0))]
101-
type I128_ = i128;
101+
pub type I128_ = i128;
102102

103103
// Hack for LLVM expectations for ABI on windows
104104
#[cfg(all(windows, target_pointer_width="64"))]

0 commit comments

Comments
 (0)