-
-
Notifications
You must be signed in to change notification settings - Fork 2.9k
#23909 adds __addvsi3, __subvsi3, __mulvsi3, subvdi3 to compiler_rt #24000
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
13 commits
Select commit
Hold shift + click to select a range
eb00d65
#23909 adds __addvsi3, __subvsi3, __mulvsi3, subvdi3 to compiler_rt
e98b84e
adds addvsi, subvsi, subvdi, mulvsi to compiler_rt.zig and CMakeList.txt
02b6380
__addvsi3 is now based on __addosi4
796fa79
fixes typos, thanks to jayschwa
7129e16
Merge branch 'master' into #23909
hi7 75a62b7
sorted subs
4d00a78
the other functions are now based on subo and mulo
6c31044
Merge branch 'ziglang:master' into #23909
hi7 f5e7546
moves tests into the files containing the function
3eb5cec
Merge branch 'ziglang:master' into #23909
hi7 ce8791d
moves addvsi3 four lines down to match alphabet
c7b6207
changes == 1 check into != 0 to match abi
e80095e
Merge branch 'master' into #23909
hi7 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
const addv = @import("addo.zig"); | ||
const common = @import("./common.zig"); | ||
const testing = @import("std").testing; | ||
|
||
pub const panic = common.panic; | ||
|
||
comptime { | ||
@export(&__addvsi3, .{ .name = "__addvsi3", .linkage = common.linkage, .visibility = common.visibility }); | ||
} | ||
|
||
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"); | ||
return sum; | ||
} | ||
|
||
test "addvsi3" { | ||
// const min: i32 = -2147483648 | ||
// const max: i32 = 2147483647 | ||
// TODO write panic handler for testing panics | ||
// try test__addvsi3(-2147483648, -1, -1); // panic | ||
// try test__addvsi3(2147483647, 1, 1); // panic | ||
try testing.expectEqual(-2147483648, __addvsi3(-2147483647, -1)); | ||
try testing.expectEqual(2147483647, __addvsi3(2147483646, 1)); | ||
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
const mulv = @import("mulo.zig"); | ||
const common = @import("./common.zig"); | ||
const testing = @import("std").testing; | ||
|
||
pub const panic = common.panic; | ||
|
||
comptime { | ||
@export(&__mulvsi3, .{ .name = "__mulvsi3", .linkage = common.linkage, .visibility = common.visibility }); | ||
} | ||
|
||
pub fn __mulvsi3(a: i32, b: i32) callconv(.c) i32 { | ||
var overflow: c_int = 0; | ||
const sum = mulv.__mulosi4(a, b, &overflow); | ||
if (overflow != 0) @panic("compiler-rt: integer overflow"); | ||
return sum; | ||
} | ||
|
||
test "mulvsi3" { | ||
// min i32 = -2147483648 | ||
// max i32 = 2147483647 | ||
// TODO write panic handler for testing panics | ||
// try test__mulvsi3(-2147483648, -1, -1); // panic | ||
// try test__mulvsi3(2147483647, 1, 1); // panic | ||
try testing.expectEqual(-2147483648, __mulvsi3(-1073741824, 2)); | ||
try testing.expectEqual(2147483646, __mulvsi3(1073741823, 2)); // one too less for corner case 2147483647 | ||
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
const subv = @import("subo.zig"); | ||
const common = @import("./common.zig"); | ||
const testing = @import("std").testing; | ||
|
||
pub const panic = common.panic; | ||
|
||
comptime { | ||
@export(&__subvdi3, .{ .name = "__subvdi3", .linkage = common.linkage, .visibility = common.visibility }); | ||
} | ||
|
||
pub fn __subvdi3(a: i64, b: i64) callconv(.c) i64 { | ||
var overflow: c_int = 0; | ||
const sum = subv.__subodi4(a, b, &overflow); | ||
if (overflow != 0) @panic("compiler-rt: integer overflow"); | ||
return sum; | ||
} | ||
|
||
test "subvdi3" { | ||
// min i64 = -9223372036854775808 | ||
// max i64 = 9223372036854775807 | ||
// TODO write panic handler for testing panics | ||
// try test__subvdi3(-9223372036854775808, -1, -1); // panic | ||
// try test__addvdi3(9223372036854775807, 1, 1); // panic | ||
try testing.expectEqual(-9223372036854775808, __subvdi3(-9223372036854775807, 1)); | ||
try testing.expectEqual(9223372036854775807, __subvdi3(9223372036854775806, -1)); | ||
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
const subv = @import("subo.zig"); | ||
const common = @import("./common.zig"); | ||
const testing = @import("std").testing; | ||
|
||
pub const panic = common.panic; | ||
|
||
comptime { | ||
@export(&__subvsi3, .{ .name = "__subvsi3", .linkage = common.linkage, .visibility = common.visibility }); | ||
} | ||
|
||
pub fn __subvsi3(a: i32, b: i32) callconv(.c) i32 { | ||
var overflow: c_int = 0; | ||
const sum = subv.__subosi4(a, b, &overflow); | ||
if (overflow != 0) @panic("compiler-rt: integer overflow"); | ||
return sum; | ||
} | ||
|
||
test "subvsi3" { | ||
// min i32 = -2147483648 | ||
// max i32 = 2147483647 | ||
// TODO write panic handler for testing panics | ||
// try test__subvsi3(-2147483648, -1, -1); // panic | ||
// try test__subvsi3(2147483647, 1, 1); // panic | ||
try testing.expectEqual(-2147483648, __subvsi3(-2147483647, 1)); | ||
try testing.expectEqual(2147483647, __subvsi3(2147483646, -1)); | ||
} |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.