Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 1 addition & 2 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -211,10 +211,10 @@ set(ZIG_STAGE2_SOURCES
lib/compiler_rt/absvti2.zig
lib/compiler_rt/adddf3.zig
lib/compiler_rt/addf3.zig
lib/compiler_rt/addo.zig
lib/compiler_rt/addsf3.zig
lib/compiler_rt/addtf3.zig
lib/compiler_rt/addvsi3.zig
lib/compiler_rt/addvdi3.zig
lib/compiler_rt/addxf3.zig
lib/compiler_rt/arm.zig
lib/compiler_rt/atomics.zig
Expand Down Expand Up @@ -354,7 +354,6 @@ set(ZIG_STAGE2_SOURCES
lib/compiler_rt/sqrt.zig
lib/compiler_rt/stack_probe.zig
lib/compiler_rt/subdf3.zig
lib/compiler_rt/subo.zig
lib/compiler_rt/subsf3.zig
lib/compiler_rt/subtf3.zig
lib/compiler_rt/subvdi3.zig
Expand Down
5 changes: 3 additions & 2 deletions lib/compiler_rt.zig
Original file line number Diff line number Diff line change
Expand Up @@ -28,12 +28,13 @@ comptime {
_ = @import("compiler_rt/negv.zig");

_ = @import("compiler_rt/addvsi3.zig");
_ = @import("compiler_rt/addvdi3.zig");

_ = @import("compiler_rt/subvsi3.zig");
_ = @import("compiler_rt/subvdi3.zig");

_ = @import("compiler_rt/mulvsi3.zig");

_ = @import("compiler_rt/addo.zig");
_ = @import("compiler_rt/subo.zig");
_ = @import("compiler_rt/mulo.zig");

// Float routines
Expand Down
46 changes: 0 additions & 46 deletions lib/compiler_rt/addo.zig

This file was deleted.

77 changes: 0 additions & 77 deletions lib/compiler_rt/addodi4_test.zig

This file was deleted.

78 changes: 0 additions & 78 deletions lib/compiler_rt/addosi4_test.zig

This file was deleted.

80 changes: 0 additions & 80 deletions lib/compiler_rt/addoti4_test.zig

This file was deleted.

26 changes: 26 additions & 0 deletions lib/compiler_rt/addvdi3.zig
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
const common = @import("./common.zig");
const testing = @import("std").testing;

pub const panic = common.panic;

comptime {
@export(&__addvdi3, .{ .name = "__addvdi3", .linkage = common.linkage, .visibility = common.visibility });
}

pub fn __addvdi3(a: i64, b: i64) callconv(.c) i64 {
const sum = a +% b;
// Overflow occurred iff both operands have the same sign, and the sign of the sum does
// not match it. In other words, iff the sum sign is not the sign of either operand.
if (((sum ^ a) & (sum ^ b)) < 0) @panic("compiler-rt: integer overflow");
return sum;
}

test "addvdi3" {
// const min: i64 = -9223372036854775808
// const max: i64 = 9223372036854775807
// TODO write panic handler for testing panics
// try test__addvdi3(-9223372036854775808, -1, -1); // panic
// try test__addvdi3(9223372036854775807, 1, 1); // panic
try testing.expectEqual(-9223372036854775808, __addvdi3(-9223372036854775807, -1));
try testing.expectEqual(9223372036854775807, __addvdi3(9223372036854775806, 1));
}
8 changes: 4 additions & 4 deletions lib/compiler_rt/addvsi3.zig
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
const addv = @import("addo.zig");
const common = @import("./common.zig");
const testing = @import("std").testing;

Expand All @@ -9,9 +8,10 @@ comptime {
}

pub fn __addvsi3(a: i32, b: i32) callconv(.c) i32 {
var overflow: c_int = 0;
const sum = addv.__addosi4(a, b, &overflow);
if (overflow != 0) @panic("compiler-rt: integer overflow");
const sum = a +% b;
// Overflow occurred iff both operands have the same sign, and the sign of the sum does
// not match it. In other words, iff the sum sign is not the sign of either operand.
if (((sum ^ a) & (sum ^ b)) < 0) @panic("compiler-rt: integer overflow");
return sum;
}

Expand Down
Loading
Loading