diff options
| author | Andrew Kelley <andrew@ziglang.org> | 2023-02-18 09:33:27 -0700 |
|---|---|---|
| committer | Andrew Kelley <andrew@ziglang.org> | 2023-02-18 09:33:27 -0700 |
| commit | efdc94c10712f610e7de5e49fd9cd6f88b4bbbae (patch) | |
| tree | 4b66ec30176843b0efd87b73199c75aa2fba675d /lib/compiler_rt/shift.zig | |
| parent | 06df842e4d313e81444063803deff306602e0a17 (diff) | |
| parent | c32171991b25b323cd68ff96c294bf5a6fa753b8 (diff) | |
| download | zig-efdc94c10712f610e7de5e49fd9cd6f88b4bbbae.tar.gz zig-efdc94c10712f610e7de5e49fd9cd6f88b4bbbae.zip | |
Merge remote-tracking branch 'origin/master' into llvm16
Diffstat (limited to 'lib/compiler_rt/shift.zig')
| -rw-r--r-- | lib/compiler_rt/shift.zig | 32 |
1 files changed, 21 insertions, 11 deletions
diff --git a/lib/compiler_rt/shift.zig b/lib/compiler_rt/shift.zig index 6d711ee553..df6ce82059 100644 --- a/lib/compiler_rt/shift.zig +++ b/lib/compiler_rt/shift.zig @@ -7,6 +7,11 @@ const common = @import("common.zig"); pub const panic = common.panic; comptime { + // symbol compatibility with libgcc + @export(__ashlsi3, .{ .name = "__ashlsi3", .linkage = common.linkage, .visibility = common.visibility }); + @export(__ashrsi3, .{ .name = "__ashrsi3", .linkage = common.linkage, .visibility = common.visibility }); + @export(__lshrsi3, .{ .name = "__lshrsi3", .linkage = common.linkage, .visibility = common.visibility }); + @export(__ashlti3, .{ .name = "__ashlti3", .linkage = common.linkage, .visibility = common.visibility }); @export(__ashrti3, .{ .name = "__ashrti3", .linkage = common.linkage, .visibility = common.visibility }); @export(__lshrti3, .{ .name = "__lshrti3", .linkage = common.linkage, .visibility = common.visibility }); @@ -37,7 +42,7 @@ fn Dwords(comptime T: type, comptime signed_half: bool) type { }; } -// Arithmetic shift left +// Arithmetic shift left: shift in 0 from right to left // Precondition: 0 <= b < bits_in_dword inline fn ashlXi3(comptime T: type, a: T, b: i32) T { const dwords = Dwords(T, false); @@ -60,7 +65,7 @@ inline fn ashlXi3(comptime T: type, a: T, b: i32) T { return output.all; } -// Arithmetic shift right +// Arithmetic shift right: shift in 1 from left to right // Precondition: 0 <= b < T.bit_count inline fn ashrXi3(comptime T: type, a: T, b: i32) T { const dwords = Dwords(T, true); @@ -87,7 +92,7 @@ inline fn ashrXi3(comptime T: type, a: T, b: i32) T { return output.all; } -// Logical shift right +// Logical shift right: shift in 0 from left to right // Precondition: 0 <= b < T.bit_count inline fn lshrXi3(comptime T: type, a: T, b: i32) T { const dwords = Dwords(T, false); @@ -110,6 +115,18 @@ inline fn lshrXi3(comptime T: type, a: T, b: i32) T { return output.all; } +pub fn __ashlsi3(a: i32, b: i32) callconv(.C) i32 { + return ashlXi3(i32, a, b); +} + +pub fn __ashrsi3(a: i32, b: i32) callconv(.C) i32 { + return ashrXi3(i32, a, b); +} + +pub fn __lshrsi3(a: i32, b: i32) callconv(.C) i32 { + return lshrXi3(i32, a, b); +} + pub fn __ashldi3(a: i64, b: i32) callconv(.C) i64 { return ashlXi3(i64, a, b); } @@ -144,12 +161,5 @@ pub fn __lshrti3(a: i128, b: i32) callconv(.C) i128 { } test { - _ = @import("ashrdi3_test.zig"); - _ = @import("ashrti3_test.zig"); - - _ = @import("ashldi3_test.zig"); - _ = @import("ashlti3_test.zig"); - - _ = @import("lshrdi3_test.zig"); - _ = @import("lshrti3_test.zig"); + _ = @import("shift_test.zig"); } |
