make llvm tests work again

This commit is contained in:
Folkert 2023-09-11 22:24:50 +02:00
parent 59af059912
commit 5ca3d3bcf1
No known key found for this signature in database
GPG key ID: 1F17F6FFD112B97C
13 changed files with 244 additions and 132 deletions

View file

@ -1125,6 +1125,10 @@ pub fn fromF64C(arg: f64) callconv(.C) i128 {
return if (@call(.{ .modifier = always_inline }, RocDec.fromF64, .{arg})) |dec| dec.num else @panic("TODO runtime exception failing convert f64 to RocDec");
}
pub fn fromU64C(arg: u64) callconv(.C) i128 {
return @call(.{ .modifier = always_inline }, RocDec.fromU64, .{arg}).toI128();
}
pub fn toI128(arg: RocDec) callconv(.C) i128 {
return @call(.{ .modifier = always_inline }, RocDec.toI128, .{arg});
}

View file

@ -21,6 +21,7 @@ comptime {
exportDecFn(dec.fromStr, "from_str");
exportDecFn(dec.toStr, "to_str");
exportDecFn(dec.fromF64C, "from_f64");
exportDecFn(dec.fromU64C, "from_u64");
exportDecFn(dec.toI128, "to_i128");
exportDecFn(dec.eqC, "eq");
exportDecFn(dec.neqC, "neq");
@ -82,6 +83,19 @@ comptime {
exportNumFn(num.shiftRightZeroFillI128, "shift_right_zero_fill.i128");
exportNumFn(num.shiftRightZeroFillU128, "shift_right_zero_fill.u128");
exportNumFn(num.compareI128, "compare.i128");
exportNumFn(num.compareU128, "compare.u128");
exportNumFn(num.lessThanI128, "less_than.i128");
exportNumFn(num.lessThanOrEqualI128, "less_than_or_equal.i128");
exportNumFn(num.greaterThanI128, "greater_than.i128");
exportNumFn(num.greaterThanOrEqualI128, "greater_than_or_equal.i128");
exportNumFn(num.lessThanU128, "less_than.u128");
exportNumFn(num.lessThanOrEqualU128, "less_than_or_equal.u128");
exportNumFn(num.greaterThanU128, "greater_than.u128");
exportNumFn(num.greaterThanOrEqualU128, "greater_than_or_equal.u128");
inline for (INTEGERS) |T, i| {
num.exportPow(T, ROC_BUILTINS ++ "." ++ NUM ++ ".pow_int.");
num.exportDivCeil(T, ROC_BUILTINS ++ "." ++ NUM ++ ".div_ceil.");

View file

@ -4,6 +4,7 @@ const math = std.math;
const RocList = @import("list.zig").RocList;
const RocStr = @import("str.zig").RocStr;
const WithOverflow = @import("utils.zig").WithOverflow;
const Ordering = @import("utils.zig").Ordering;
const roc_panic = @import("panic.zig").panic_help;
pub fn NumParseResult(comptime T: type) type {
@ -558,6 +559,58 @@ pub fn shiftRightZeroFillU128(self: u128, other: u8) callconv(.C) u128 {
}
}
pub fn compareI128(self: i128, other: i128) callconv(.C) Ordering {
if (self == other) {
return Ordering.EQ;
} else if (self < other) {
return Ordering.LT;
} else {
return Ordering.GT;
}
}
pub fn compareU128(self: u128, other: u128) callconv(.C) Ordering {
if (self == other) {
return Ordering.EQ;
} else if (self < other) {
return Ordering.LT;
} else {
return Ordering.GT;
}
}
pub fn lessThanI128(self: i128, other: i128) callconv(.C) bool {
return self < other;
}
pub fn lessThanOrEqualI128(self: i128, other: i128) callconv(.C) bool {
return self <= other;
}
pub fn greaterThanI128(self: i128, other: i128) callconv(.C) bool {
return self > other;
}
pub fn greaterThanOrEqualI128(self: i128, other: i128) callconv(.C) bool {
return self >= other;
}
pub fn lessThanU128(self: u128, other: u128) callconv(.C) bool {
return self < other;
}
pub fn lessThanOrEqualU128(self: u128, other: u128) callconv(.C) bool {
return self <= other;
}
pub fn greaterThanU128(self: u128, other: u128) callconv(.C) bool {
return self > other;
}
pub fn greaterThanOrEqualU128(self: u128, other: u128) callconv(.C) bool {
return self >= other;
}
pub fn exportMulOrPanic(comptime T: type, comptime W: type, comptime name: []const u8) void {
comptime var f = struct {
fn func(self: T, other: T) callconv(.C) T {