diff options
| author | Andrew Kelley <andrew@ziglang.org> | 2022-06-17 18:10:00 -0700 |
|---|---|---|
| committer | Andrew Kelley <andrew@ziglang.org> | 2022-06-17 18:10:00 -0700 |
| commit | 0556a2ba53b8bbb1a60ff31d8dcdde78a8b16727 (patch) | |
| tree | c691076f8f43db00ba0c6e58afebb1300ea4093e /lib/compiler_rt/divdf3.zig | |
| parent | 3efc229bbf8aaec9de54a702054b091bf890d56e (diff) | |
| download | zig-0556a2ba53b8bbb1a60ff31d8dcdde78a8b16727.tar.gz zig-0556a2ba53b8bbb1a60ff31d8dcdde78a8b16727.zip | |
compiler-rt: finish cleanups
Finishes cleanups that I started in other commits in this branch.
* Use common.linkage for all exports instead of redoing the logic in
each file.
* Remove pointless `@setRuntimeSafety` calls.
* Avoid redundantly exporting multiple versions of functions. For
example, if PPC wants `ceilf128` then don't also export `ceilq`;
similarly if ARM wants `__aeabi_ddiv` then don't also export
`__divdf3`.
* Use `inline` for helper functions instead of making inline calls at
callsites.
Diffstat (limited to 'lib/compiler_rt/divdf3.zig')
| -rw-r--r-- | lib/compiler_rt/divdf3.zig | 34 |
1 files changed, 17 insertions, 17 deletions
diff --git a/lib/compiler_rt/divdf3.zig b/lib/compiler_rt/divdf3.zig index 6d626272b5..dd22f4836c 100644 --- a/lib/compiler_rt/divdf3.zig +++ b/lib/compiler_rt/divdf3.zig @@ -1,30 +1,35 @@ -// Ported from: -// -// https://github.com/llvm/llvm-project/commit/d674d96bc56c0f377879d01c9d8dfdaaa7859cdb/compiler-rt/lib/builtins/divdf3.c +//! Ported from: +//! +//! https://github.com/llvm/llvm-project/commit/d674d96bc56c0f377879d01c9d8dfdaaa7859cdb/compiler-rt/lib/builtins/divdf3.c const std = @import("std"); const builtin = @import("builtin"); const arch = builtin.cpu.arch; const is_test = builtin.is_test; -const linkage: std.builtin.GlobalLinkage = if (builtin.is_test) .Internal else .Weak; - const common = @import("common.zig"); + const normalize = common.normalize; const wideMultiply = common.wideMultiply; + pub const panic = common.panic; comptime { - @export(__divdf3, .{ .name = "__divdf3", .linkage = linkage }); - - if (!is_test) { - if (arch.isARM() or arch.isThumb()) { - @export(__aeabi_ddiv, .{ .name = "__aeabi_ddiv", .linkage = linkage }); - } + if (common.want_aeabi) { + @export(__aeabi_ddiv, .{ .name = "__aeabi_ddiv", .linkage = common.linkage }); + } else { + @export(__divdf3, .{ .name = "__divdf3", .linkage = common.linkage }); } } pub fn __divdf3(a: f64, b: f64) callconv(.C) f64 { - @setRuntimeSafety(builtin.is_test); + return div(a, b); +} + +fn __aeabi_ddiv(a: f64, b: f64) callconv(.AAPCS) f64 { + return div(a, b); +} + +inline fn div(a: f64, b: f64) f64 { const Z = std.meta.Int(.unsigned, 64); const SignedZ = std.meta.Int(.signed, 64); @@ -220,11 +225,6 @@ pub fn __divdf3(a: f64, b: f64) callconv(.C) f64 { } } -pub fn __aeabi_ddiv(a: f64, b: f64) callconv(.AAPCS) f64 { - @setRuntimeSafety(false); - return @call(.{ .modifier = .always_inline }, __divdf3, .{ a, b }); -} - test { _ = @import("divdf3_test.zig"); } |
