authorgravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2022-06-16 14:18:08-07:00
committergravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2022-06-17 16:38:59-07:00
log25671f5a973c209bdf75f8be567cc5e441a865cb
tree0f34046f069cb51058fcb9643774973e36d1ceb3
parentc99c085d70c9347ec9a15d9a4f73c19e628912b7

compiler-rt: move SPARC functions into appropriate compilation units


24 files changed, 170 insertions(+), 167 deletions(-)

CMakeLists.txt-1
...@@ -619,7 +619,6 @@ set(ZIG_STAGE2_SOURCES...@@ -619,7 +619,6 @@ set(ZIG_STAGE2_SOURCES
619 "${CMAKE_SOURCE_DIR}/lib/compiler_rt/shift.zig"619 "${CMAKE_SOURCE_DIR}/lib/compiler_rt/shift.zig"
620 "${CMAKE_SOURCE_DIR}/lib/compiler_rt/sin.zig"620 "${CMAKE_SOURCE_DIR}/lib/compiler_rt/sin.zig"
621 "${CMAKE_SOURCE_DIR}/lib/compiler_rt/sincos.zig"621 "${CMAKE_SOURCE_DIR}/lib/compiler_rt/sincos.zig"
622 "${CMAKE_SOURCE_DIR}/lib/compiler_rt/sparc.zig"
623 "${CMAKE_SOURCE_DIR}/lib/compiler_rt/sqrt.zig"622 "${CMAKE_SOURCE_DIR}/lib/compiler_rt/sqrt.zig"
624 "${CMAKE_SOURCE_DIR}/lib/compiler_rt/stack_probe.zig"623 "${CMAKE_SOURCE_DIR}/lib/compiler_rt/stack_probe.zig"
625 "${CMAKE_SOURCE_DIR}/lib/compiler_rt/subo.zig"624 "${CMAKE_SOURCE_DIR}/lib/compiler_rt/subo.zig"
lib/compiler_rt.zig-2
...@@ -179,6 +179,4 @@ comptime {...@@ -179,6 +179,4 @@ comptime {
179 _ = @import("compiler_rt/aulldiv.zig");179 _ = @import("compiler_rt/aulldiv.zig");
180 _ = @import("compiler_rt/aullrem.zig");180 _ = @import("compiler_rt/aullrem.zig");
181 _ = @import("compiler_rt/clear_cache.zig");181 _ = @import("compiler_rt/clear_cache.zig");
182
183 _ = @import("compiler_rt/sparc.zig");
184}182}
lib/compiler_rt/addtf3.zig+6
...@@ -6,6 +6,8 @@ pub const panic = common.panic;...@@ -6,6 +6,8 @@ pub const panic = common.panic;
6comptime {6comptime {
7 if (common.want_ppc_abi) {7 if (common.want_ppc_abi) {
8 @export(__addkf3, .{ .name = "__addkf3", .linkage = common.linkage });8 @export(__addkf3, .{ .name = "__addkf3", .linkage = common.linkage });
9 } else if (common.want_sparc_abi) {
10 @export(_Qp_add, .{ .name = "_Qp_add", .linkage = common.linkage });
9 } else {11 } else {
10 @export(__addtf3, .{ .name = "__addtf3", .linkage = common.linkage });12 @export(__addtf3, .{ .name = "__addtf3", .linkage = common.linkage });
11 }13 }
...@@ -18,3 +20,7 @@ fn __addtf3(a: f128, b: f128) callconv(.C) f128 {...@@ -18,3 +20,7 @@ fn __addtf3(a: f128, b: f128) callconv(.C) f128 {
18fn __addkf3(a: f128, b: f128) callconv(.C) f128 {20fn __addkf3(a: f128, b: f128) callconv(.C) f128 {
19 return addf3(f128, a, b);21 return addf3(f128, a, b);
20}22}
23
24fn _Qp_add(c: *f128, a: *f128, b: *f128) callconv(.C) void {
25 c.* = addf3(f128, a.*, b.*);
26}
lib/compiler_rt/cmptf2.zig+49
...@@ -11,6 +11,14 @@ comptime {...@@ -11,6 +11,14 @@ comptime {
11 @export(__nekf2, .{ .name = "__nekf2", .linkage = common.linkage });11 @export(__nekf2, .{ .name = "__nekf2", .linkage = common.linkage });
12 @export(__ltkf2, .{ .name = "__ltkf2", .linkage = common.linkage });12 @export(__ltkf2, .{ .name = "__ltkf2", .linkage = common.linkage });
13 @export(__lekf2, .{ .name = "__lekf2", .linkage = common.linkage });13 @export(__lekf2, .{ .name = "__lekf2", .linkage = common.linkage });
14 } else if (common.want_sparc_abi) {
15 @export(_Qp_cmp, .{ .name = "_Qp_cmp", .linkage = common.linkage });
16 @export(_Qp_feq, .{ .name = "_Qp_feq", .linkage = common.linkage });
17 @export(_Qp_fne, .{ .name = "_Qp_fne", .linkage = common.linkage });
18 @export(_Qp_flt, .{ .name = "_Qp_flt", .linkage = common.linkage });
19 @export(_Qp_fle, .{ .name = "_Qp_fle", .linkage = common.linkage });
20 @export(_Qp_fgt, .{ .name = "_Qp_fgt", .linkage = common.linkage });
21 @export(_Qp_fge, .{ .name = "_Qp_fge", .linkage = common.linkage });
14 } else {22 } else {
15 @export(__eqtf2, .{ .name = "__eqtf2", .linkage = common.linkage });23 @export(__eqtf2, .{ .name = "__eqtf2", .linkage = common.linkage });
16 @export(__netf2, .{ .name = "__netf2", .linkage = common.linkage });24 @export(__netf2, .{ .name = "__netf2", .linkage = common.linkage });
...@@ -71,3 +79,44 @@ fn __ltkf2(a: f128, b: f128) callconv(.C) i32 {...@@ -71,3 +79,44 @@ fn __ltkf2(a: f128, b: f128) callconv(.C) i32 {
71fn __lekf2(a: f128, b: f128) callconv(.C) i32 {79fn __lekf2(a: f128, b: f128) callconv(.C) i32 {
72 return __cmptf2(a, b);80 return __cmptf2(a, b);
73}81}
82
83const SparcFCMP = enum(i32) {
84 Equal = 0,
85 Less = 1,
86 Greater = 2,
87 Unordered = 3,
88};
89
90fn _Qp_cmp(a: *const f128, b: *const f128) callconv(.C) i32 {
91 return @enumToInt(comparef.cmpf2(f128, SparcFCMP, a.*, b.*));
92}
93
94fn _Qp_feq(a: *const f128, b: *const f128) callconv(.C) bool {
95 return @intToEnum(SparcFCMP, _Qp_cmp(a, b)) == .Equal;
96}
97
98fn _Qp_fne(a: *const f128, b: *const f128) callconv(.C) bool {
99 return @intToEnum(SparcFCMP, _Qp_cmp(a, b)) != .Equal;
100}
101
102fn _Qp_flt(a: *const f128, b: *const f128) callconv(.C) bool {
103 return @intToEnum(SparcFCMP, _Qp_cmp(a, b)) == .Less;
104}
105
106fn _Qp_fgt(a: *const f128, b: *const f128) callconv(.C) bool {
107 return @intToEnum(SparcFCMP, _Qp_cmp(a, b)) == .Greater;
108}
109
110fn _Qp_fge(a: *const f128, b: *const f128) callconv(.C) bool {
111 return switch (@intToEnum(SparcFCMP, _Qp_cmp(a, b))) {
112 .Equal, .Greater => true,
113 .Less, .Unordered => false,
114 };
115}
116
117fn _Qp_fle(a: *const f128, b: *const f128) callconv(.C) bool {
118 return switch (@intToEnum(SparcFCMP, _Qp_cmp(a, b))) {
119 .Equal, .Less => true,
120 .Greater, .Unordered => false,
121 };
122}
lib/compiler_rt/common.zig+1
...@@ -8,6 +8,7 @@ pub const want_aeabi = builtin.cpu.arch.isARM() or builtin.cpu.arch.isThumb();...@@ -8,6 +8,7 @@ pub const want_aeabi = builtin.cpu.arch.isARM() or builtin.cpu.arch.isThumb();
8pub const want_ppc_abi = builtin.cpu.arch.isPPC() or builtin.cpu.arch.isPPC64();8pub const want_ppc_abi = builtin.cpu.arch.isPPC() or builtin.cpu.arch.isPPC64();
9pub const want_msvc_abi = builtin.abi == .msvc;9pub const want_msvc_abi = builtin.abi == .msvc;
10pub const want_gnu_abi = builtin.abi.isGnu();10pub const want_gnu_abi = builtin.abi.isGnu();
11pub const want_sparc_abi = builtin.cpu.arch.isSPARC();
1112
12// Avoid dragging in the runtime safety mechanisms into this .o file,13// Avoid dragging in the runtime safety mechanisms into this .o file,
13// unless we're trying to test compiler-rt.14// unless we're trying to test compiler-rt.
lib/compiler_rt/divtf3.zig+18-13
...@@ -1,30 +1,35 @@...@@ -1,30 +1,35 @@
1const std = @import("std");1const std = @import("std");
2const builtin = @import("builtin");2const builtin = @import("builtin");
3const arch = builtin.cpu.arch;
4const is_test = builtin.is_test;
5const linkage: std.builtin.GlobalLinkage = if (builtin.is_test) .Internal else .Weak;
63
7const common = @import("common.zig");4const common = @import("common.zig");
8const normalize = common.normalize;5const normalize = common.normalize;
9const wideMultiply = common.wideMultiply;6const wideMultiply = common.wideMultiply;
7
10pub const panic = common.panic;8pub const panic = common.panic;
119
12comptime {10comptime {
13 @export(__divtf3, .{ .name = "__divtf3", .linkage = linkage });11 if (common.want_ppc_abi) {
1412 @export(__divkf3, .{ .name = "__divkf3", .linkage = common.linkage });
15 if (!is_test) {13 } else if (common.want_sparc_abi) {
16 if (arch.isPPC() or arch.isPPC64()) {14 @export(_Qp_div, .{ .name = "_Qp_div", .linkage = common.linkage });
17 @export(__divkf3, .{ .name = "__divkf3", .linkage = linkage });15 } else {
18 }16 @export(__divtf3, .{ .name = "__divtf3", .linkage = common.linkage });
19 }17 }
20}18}
2119
22pub fn __divkf3(a: f128, b: f128) callconv(.C) f128 {20fn __divkf3(a: f128, b: f128) callconv(.C) f128 {
23 return @call(.{ .modifier = .always_inline }, __divtf3, .{ a, b });21 return div(a, b);
22}
23
24fn _Qp_div(c: *f128, a: *const f128, b: *const f128) callconv(.C) void {
25 c.* = div(a.*, b.*);
26}
27
28fn __divtf3(a: f128, b: f128) callconv(.C) f128 {
29 return div(a, b);
24}30}
2531
26pub fn __divtf3(a: f128, b: f128) callconv(.C) f128 {32inline fn div(a: f128, b: f128) f128 {
27 @setRuntimeSafety(builtin.is_test);
28 const Z = std.meta.Int(.unsigned, 128);33 const Z = std.meta.Int(.unsigned, 128);
2934
30 const significandBits = std.math.floatMantissaBits(f128);35 const significandBits = std.math.floatMantissaBits(f128);
lib/compiler_rt/extenddftf2.zig+7
...@@ -6,6 +6,8 @@ pub const panic = common.panic;...@@ -6,6 +6,8 @@ pub const panic = common.panic;
6comptime {6comptime {
7 if (common.want_ppc_abi) {7 if (common.want_ppc_abi) {
8 @export(__extenddfkf2, .{ .name = "__extenddfkf2", .linkage = common.linkage });8 @export(__extenddfkf2, .{ .name = "__extenddfkf2", .linkage = common.linkage });
9 } else if (common.want_sparc_abi) {
10 @export(_Qp_dtoq, .{ .name = "_Qp_dtoq", .linkage = common.linkage });
9 } else {11 } else {
10 @export(__extenddftf2, .{ .name = "__extenddftf2", .linkage = common.linkage });12 @export(__extenddftf2, .{ .name = "__extenddftf2", .linkage = common.linkage });
11 }13 }
...@@ -18,3 +20,8 @@ fn __extenddftf2(a: f64) callconv(.C) f128 {...@@ -18,3 +20,8 @@ fn __extenddftf2(a: f64) callconv(.C) f128 {
18fn __extenddfkf2(a: f64) callconv(.C) f128 {20fn __extenddfkf2(a: f64) callconv(.C) f128 {
19 return extendf(f128, f64, @bitCast(u64, a));21 return extendf(f128, f64, @bitCast(u64, a));
20}22}
23
24fn _Qp_dtoq(c: *f128, a: f64) callconv(.C) void {
25 c.* = @import("extendXfYf2.zig").__extenddftf2(a);
26 c.* = extendf(f128, f64, @bitCast(u64, a));
27}
lib/compiler_rt/extendsftf2.zig+6
...@@ -6,6 +6,8 @@ pub const panic = common.panic;...@@ -6,6 +6,8 @@ pub const panic = common.panic;
6comptime {6comptime {
7 if (common.want_ppc_abi) {7 if (common.want_ppc_abi) {
8 @export(__extendsfkf2, .{ .name = "__extendsfkf2", .linkage = common.linkage });8 @export(__extendsfkf2, .{ .name = "__extendsfkf2", .linkage = common.linkage });
9 } else if (common.want_sparc_abi) {
10 @export(_Qp_stoq, .{ .name = "_Qp_stoq", .linkage = common.linkage });
9 } else {11 } else {
10 @export(__extendsftf2, .{ .name = "__extendsftf2", .linkage = common.linkage });12 @export(__extendsftf2, .{ .name = "__extendsftf2", .linkage = common.linkage });
11 }13 }
...@@ -18,3 +20,7 @@ fn __extendsftf2(a: f32) callconv(.C) f128 {...@@ -18,3 +20,7 @@ fn __extendsftf2(a: f32) callconv(.C) f128 {
18fn __extendsfkf2(a: f32) callconv(.C) f128 {20fn __extendsfkf2(a: f32) callconv(.C) f128 {
19 return extendf(f128, f32, @bitCast(u32, a));21 return extendf(f128, f32, @bitCast(u32, a));
20}22}
23
24fn _Qp_stoq(c: *f128, a: f32) callconv(.C) void {
25 c.* = extendf(f128, f32, @bitCast(u32, a));
26}
lib/compiler_rt/fixtfdi.zig+6
...@@ -6,6 +6,8 @@ pub const panic = common.panic;...@@ -6,6 +6,8 @@ pub const panic = common.panic;
6comptime {6comptime {
7 if (common.want_ppc_abi) {7 if (common.want_ppc_abi) {
8 @export(__fixkfdi, .{ .name = "__fixkfdi", .linkage = common.linkage });8 @export(__fixkfdi, .{ .name = "__fixkfdi", .linkage = common.linkage });
9 } else if (common.want_sparc_abi) {
10 @export(_Qp_qtox, .{ .name = "_Qp_qtox", .linkage = common.linkage });
9 } else {11 } else {
10 @export(__fixtfdi, .{ .name = "__fixtfdi", .linkage = common.linkage });12 @export(__fixtfdi, .{ .name = "__fixtfdi", .linkage = common.linkage });
11 }13 }
...@@ -18,3 +20,7 @@ fn __fixtfdi(a: f128) callconv(.C) i64 {...@@ -18,3 +20,7 @@ fn __fixtfdi(a: f128) callconv(.C) i64 {
18fn __fixkfdi(a: f128) callconv(.C) i64 {20fn __fixkfdi(a: f128) callconv(.C) i64 {
19 return floatToInt(i64, a);21 return floatToInt(i64, a);
20}22}
23
24fn _Qp_qtox(a: *const f128) callconv(.C) i64 {
25 return floatToInt(i64, a.*);
26}
lib/compiler_rt/fixtfsi.zig+6
...@@ -6,6 +6,8 @@ pub const panic = common.panic;...@@ -6,6 +6,8 @@ pub const panic = common.panic;
6comptime {6comptime {
7 if (common.want_ppc_abi) {7 if (common.want_ppc_abi) {
8 @export(__fixkfsi, .{ .name = "__fixkfsi", .linkage = common.linkage });8 @export(__fixkfsi, .{ .name = "__fixkfsi", .linkage = common.linkage });
9 } else if (common.want_sparc_abi) {
10 @export(_Qp_qtoi, .{ .name = "_Qp_qtoi", .linkage = common.linkage });
9 } else {11 } else {
10 @export(__fixtfsi, .{ .name = "__fixtfsi", .linkage = common.linkage });12 @export(__fixtfsi, .{ .name = "__fixtfsi", .linkage = common.linkage });
11 }13 }
...@@ -18,3 +20,7 @@ fn __fixtfsi(a: f128) callconv(.C) i32 {...@@ -18,3 +20,7 @@ fn __fixtfsi(a: f128) callconv(.C) i32 {
18fn __fixkfsi(a: f128) callconv(.C) i32 {20fn __fixkfsi(a: f128) callconv(.C) i32 {
19 return floatToInt(i32, a);21 return floatToInt(i32, a);
20}22}
23
24fn _Qp_qtoi(a: *const f128) callconv(.C) i32 {
25 return floatToInt(i32, a.*);
26}
lib/compiler_rt/fixunstfdi.zig+6
...@@ -6,6 +6,8 @@ pub const panic = common.panic;...@@ -6,6 +6,8 @@ pub const panic = common.panic;
6comptime {6comptime {
7 if (common.want_ppc_abi) {7 if (common.want_ppc_abi) {
8 @export(__fixunskfdi, .{ .name = "__fixunskfdi", .linkage = common.linkage });8 @export(__fixunskfdi, .{ .name = "__fixunskfdi", .linkage = common.linkage });
9 } else if (common.want_sparc_abi) {
10 @export(_Qp_qtoux, .{ .name = "_Qp_qtoux", .linkage = common.linkage });
9 } else {11 } else {
10 @export(__fixunstfdi, .{ .name = "__fixunstfdi", .linkage = common.linkage });12 @export(__fixunstfdi, .{ .name = "__fixunstfdi", .linkage = common.linkage });
11 }13 }
...@@ -18,3 +20,7 @@ fn __fixunstfdi(a: f128) callconv(.C) u64 {...@@ -18,3 +20,7 @@ fn __fixunstfdi(a: f128) callconv(.C) u64 {
18fn __fixunskfdi(a: f128) callconv(.C) u64 {20fn __fixunskfdi(a: f128) callconv(.C) u64 {
19 return floatToInt(u64, a);21 return floatToInt(u64, a);
20}22}
23
24fn _Qp_qtoux(a: *const f128) callconv(.C) u64 {
25 return floatToInt(u64, a.*);
26}
lib/compiler_rt/fixunstfsi.zig+6
...@@ -6,6 +6,8 @@ pub const panic = common.panic;...@@ -6,6 +6,8 @@ pub const panic = common.panic;
6comptime {6comptime {
7 if (common.want_ppc_abi) {7 if (common.want_ppc_abi) {
8 @export(__fixunskfsi, .{ .name = "__fixunskfsi", .linkage = common.linkage });8 @export(__fixunskfsi, .{ .name = "__fixunskfsi", .linkage = common.linkage });
9 } else if (common.want_sparc_abi) {
10 @export(_Qp_qtoui, .{ .name = "_Qp_qtoui", .linkage = common.linkage });
9 } else {11 } else {
10 @export(__fixunstfsi, .{ .name = "__fixunstfsi", .linkage = common.linkage });12 @export(__fixunstfsi, .{ .name = "__fixunstfsi", .linkage = common.linkage });
11 }13 }
...@@ -18,3 +20,7 @@ fn __fixunstfsi(a: f128) callconv(.C) u32 {...@@ -18,3 +20,7 @@ fn __fixunstfsi(a: f128) callconv(.C) u32 {
18fn __fixunskfsi(a: f128) callconv(.C) u32 {20fn __fixunskfsi(a: f128) callconv(.C) u32 {
19 return floatToInt(u32, a);21 return floatToInt(u32, a);
20}22}
23
24fn _Qp_qtoui(a: *const f128) callconv(.C) u32 {
25 return floatToInt(u32, a.*);
26}
lib/compiler_rt/floatditf.zig+6
...@@ -6,6 +6,8 @@ pub const panic = common.panic;...@@ -6,6 +6,8 @@ pub const panic = common.panic;
6comptime {6comptime {
7 if (common.want_ppc_abi) {7 if (common.want_ppc_abi) {
8 @export(__floatdikf, .{ .name = "__floatdikf", .linkage = common.linkage });8 @export(__floatdikf, .{ .name = "__floatdikf", .linkage = common.linkage });
9 } else if (common.want_sparc_abi) {
10 @export(_Qp_xtoq, .{ .name = "_Qp_xtoq", .linkage = common.linkage });
9 } else {11 } else {
10 @export(__floatditf, .{ .name = "__floatditf", .linkage = common.linkage });12 @export(__floatditf, .{ .name = "__floatditf", .linkage = common.linkage });
11 }13 }
...@@ -18,3 +20,7 @@ fn __floatditf(a: i64) callconv(.C) f128 {...@@ -18,3 +20,7 @@ fn __floatditf(a: i64) callconv(.C) f128 {
18fn __floatdikf(a: i64) callconv(.C) f128 {20fn __floatdikf(a: i64) callconv(.C) f128 {
19 return intToFloat(f128, a);21 return intToFloat(f128, a);
20}22}
23
24fn _Qp_xtoq(c: *f128, a: i64) callconv(.C) void {
25 c.* = intToFloat(f128, a);
26}
lib/compiler_rt/floatsitf.zig+6
...@@ -6,6 +6,8 @@ pub const panic = common.panic;...@@ -6,6 +6,8 @@ pub const panic = common.panic;
6comptime {6comptime {
7 if (common.want_ppc_abi) {7 if (common.want_ppc_abi) {
8 @export(__floatsikf, .{ .name = "__floatsikf", .linkage = common.linkage });8 @export(__floatsikf, .{ .name = "__floatsikf", .linkage = common.linkage });
9 } else if (common.want_sparc_abi) {
10 @export(_Qp_itoq, .{ .name = "_Qp_itoq", .linkage = common.linkage });
9 } else {11 } else {
10 @export(__floatsitf, .{ .name = "__floatsitf", .linkage = common.linkage });12 @export(__floatsitf, .{ .name = "__floatsitf", .linkage = common.linkage });
11 }13 }
...@@ -18,3 +20,7 @@ fn __floatsitf(a: i32) callconv(.C) f128 {...@@ -18,3 +20,7 @@ fn __floatsitf(a: i32) callconv(.C) f128 {
18fn __floatsikf(a: i32) callconv(.C) f128 {20fn __floatsikf(a: i32) callconv(.C) f128 {
19 return intToFloat(f128, a);21 return intToFloat(f128, a);
20}22}
23
24fn _Qp_itoq(c: *f128, a: i32) callconv(.C) void {
25 c.* = intToFloat(f128, a);
26}
lib/compiler_rt/floatunditf.zig+6
...@@ -6,6 +6,8 @@ pub const panic = common.panic;...@@ -6,6 +6,8 @@ pub const panic = common.panic;
6comptime {6comptime {
7 if (common.want_ppc_abi) {7 if (common.want_ppc_abi) {
8 @export(__floatundikf, .{ .name = "__floatundikf", .linkage = common.linkage });8 @export(__floatundikf, .{ .name = "__floatundikf", .linkage = common.linkage });
9 } else if (common.want_sparc_abi) {
10 @export(_Qp_uxtoq, .{ .name = "_Qp_uxtoq", .linkage = common.linkage });
9 } else {11 } else {
10 @export(__floatunditf, .{ .name = "__floatunditf", .linkage = common.linkage });12 @export(__floatunditf, .{ .name = "__floatunditf", .linkage = common.linkage });
11 }13 }
...@@ -18,3 +20,7 @@ fn __floatunditf(a: u64) callconv(.C) f128 {...@@ -18,3 +20,7 @@ fn __floatunditf(a: u64) callconv(.C) f128 {
18fn __floatundikf(a: u64) callconv(.C) f128 {20fn __floatundikf(a: u64) callconv(.C) f128 {
19 return intToFloat(f128, a);21 return intToFloat(f128, a);
20}22}
23
24fn _Qp_uxtoq(c: *f128, a: u64) callconv(.C) void {
25 c.* = intToFloat(f128, a);
26}
lib/compiler_rt/floatunsitf.zig+6
...@@ -6,6 +6,8 @@ pub const panic = common.panic;...@@ -6,6 +6,8 @@ pub const panic = common.panic;
6comptime {6comptime {
7 if (common.want_ppc_abi) {7 if (common.want_ppc_abi) {
8 @export(__floatunsikf, .{ .name = "__floatunsikf", .linkage = common.linkage });8 @export(__floatunsikf, .{ .name = "__floatunsikf", .linkage = common.linkage });
9 } else if (common.want_sparc_abi) {
10 @export(_Qp_uitoq, .{ .name = "_Qp_uitoq", .linkage = common.linkage });
9 } else {11 } else {
10 @export(__floatunsitf, .{ .name = "__floatunsitf", .linkage = common.linkage });12 @export(__floatunsitf, .{ .name = "__floatunsitf", .linkage = common.linkage });
11 }13 }
...@@ -18,3 +20,7 @@ fn __floatunsitf(a: u32) callconv(.C) f128 {...@@ -18,3 +20,7 @@ fn __floatunsitf(a: u32) callconv(.C) f128 {
18fn __floatunsikf(a: u32) callconv(.C) f128 {20fn __floatunsikf(a: u32) callconv(.C) f128 {
19 return intToFloat(f128, a);21 return intToFloat(f128, a);
20}22}
23
24fn _Qp_uitoq(c: *f128, a: u32) callconv(.C) void {
25 c.* = intToFloat(f128, a);
26}
lib/compiler_rt/getf2.zig+3
...@@ -9,6 +9,9 @@ comptime {...@@ -9,6 +9,9 @@ comptime {
9 if (common.want_ppc_abi) {9 if (common.want_ppc_abi) {
10 @export(__gekf2, .{ .name = "__gekf2", .linkage = common.linkage });10 @export(__gekf2, .{ .name = "__gekf2", .linkage = common.linkage });
11 @export(__gtkf2, .{ .name = "__gtkf2", .linkage = common.linkage });11 @export(__gtkf2, .{ .name = "__gtkf2", .linkage = common.linkage });
12 } else if (common.want_sparc_abi) {
13 // These exports are handled in cmptf2.zig because gt and ge on sparc
14 // are based on calling _Qp_cmp.
12 } else {15 } else {
13 @export(__getf2, .{ .name = "__getf2", .linkage = common.linkage });16 @export(__getf2, .{ .name = "__getf2", .linkage = common.linkage });
14 @export(__gttf2, .{ .name = "__gttf2", .linkage = common.linkage });17 @export(__gttf2, .{ .name = "__gttf2", .linkage = common.linkage });
lib/compiler_rt/multf3.zig+6
...@@ -6,6 +6,8 @@ pub const panic = common.panic;...@@ -6,6 +6,8 @@ pub const panic = common.panic;
6comptime {6comptime {
7 if (common.want_ppc_abi) {7 if (common.want_ppc_abi) {
8 @export(__mulkf3, .{ .name = "__mulkf3", .linkage = common.linkage });8 @export(__mulkf3, .{ .name = "__mulkf3", .linkage = common.linkage });
9 } else if (common.want_sparc_abi) {
10 @export(_Qp_mul, .{ .name = "_Qp_mul", .linkage = common.linkage });
9 } else {11 } else {
10 @export(__multf3, .{ .name = "__multf3", .linkage = common.linkage });12 @export(__multf3, .{ .name = "__multf3", .linkage = common.linkage });
11 }13 }
...@@ -18,3 +20,7 @@ fn __multf3(a: f128, b: f128) callconv(.C) f128 {...@@ -18,3 +20,7 @@ fn __multf3(a: f128, b: f128) callconv(.C) f128 {
18fn __mulkf3(a: f128, b: f128) callconv(.C) f128 {20fn __mulkf3(a: f128, b: f128) callconv(.C) f128 {
19 return mulf3(f128, a, b);21 return mulf3(f128, a, b);
20}22}
23
24fn _Qp_mul(c: *f128, a: *const f128, b: *const f128) callconv(.C) void {
25 c.* = mulf3(f128, a.*, b.*);
26}
lib/compiler_rt/sparc.zig deleted-148
...@@ -1,148 +0,0 @@
1//
2// SPARC uses a different naming scheme for its support routines so we map it here to the x86 name.
3
4const std = @import("std");
5const builtin = @import("builtin");
6const arch = builtin.cpu.arch;
7const linkage: std.builtin.GlobalLinkage = if (builtin.is_test) .Internal else .Weak;
8pub const panic = @import("common.zig").panic;
9
10comptime {
11 if (arch.isSPARC()) {
12 // SPARC systems use a different naming scheme
13 @export(_Qp_add, .{ .name = "_Qp_add", .linkage = linkage });
14 @export(_Qp_div, .{ .name = "_Qp_div", .linkage = linkage });
15 @export(_Qp_mul, .{ .name = "_Qp_mul", .linkage = linkage });
16 @export(_Qp_sub, .{ .name = "_Qp_sub", .linkage = linkage });
17
18 @export(_Qp_cmp, .{ .name = "_Qp_cmp", .linkage = linkage });
19 @export(_Qp_feq, .{ .name = "_Qp_feq", .linkage = linkage });
20 @export(_Qp_fne, .{ .name = "_Qp_fne", .linkage = linkage });
21 @export(_Qp_flt, .{ .name = "_Qp_flt", .linkage = linkage });
22 @export(_Qp_fle, .{ .name = "_Qp_fle", .linkage = linkage });
23 @export(_Qp_fgt, .{ .name = "_Qp_fgt", .linkage = linkage });
24 @export(_Qp_fge, .{ .name = "_Qp_fge", .linkage = linkage });
25
26 @export(_Qp_itoq, .{ .name = "_Qp_itoq", .linkage = linkage });
27 @export(_Qp_uitoq, .{ .name = "_Qp_uitoq", .linkage = linkage });
28 @export(_Qp_xtoq, .{ .name = "_Qp_xtoq", .linkage = linkage });
29 @export(_Qp_uxtoq, .{ .name = "_Qp_uxtoq", .linkage = linkage });
30 @export(_Qp_stoq, .{ .name = "_Qp_stoq", .linkage = linkage });
31 @export(_Qp_dtoq, .{ .name = "_Qp_dtoq", .linkage = linkage });
32 @export(_Qp_qtoi, .{ .name = "_Qp_qtoi", .linkage = linkage });
33 @export(_Qp_qtoui, .{ .name = "_Qp_qtoui", .linkage = linkage });
34 @export(_Qp_qtox, .{ .name = "_Qp_qtox", .linkage = linkage });
35 @export(_Qp_qtoux, .{ .name = "_Qp_qtoux", .linkage = linkage });
36 @export(_Qp_qtos, .{ .name = "_Qp_qtos", .linkage = linkage });
37 @export(_Qp_qtod, .{ .name = "_Qp_qtod", .linkage = linkage });
38 }
39}
40
41// The SPARC Architecture Manual, Version 9:
42// A.13 Floating-Point Compare
43const FCMP = enum(i32) {
44 Equal = 0,
45 Less = 1,
46 Greater = 2,
47 Unordered = 3,
48};
49
50// Basic arithmetic
51
52pub fn _Qp_add(c: *f128, a: *f128, b: *f128) callconv(.C) void {
53 c.* = @import("addf3.zig").__addtf3(a.*, b.*);
54}
55
56pub fn _Qp_div(c: *f128, a: *f128, b: *f128) callconv(.C) void {
57 c.* = @import("divtf3.zig").__divtf3(a.*, b.*);
58}
59
60pub fn _Qp_mul(c: *f128, a: *f128, b: *f128) callconv(.C) void {
61 c.* = @import("mulf3.zig").__multf3(a.*, b.*);
62}
63
64pub fn _Qp_sub(c: *f128, a: *f128, b: *f128) callconv(.C) void {
65 c.* = @import("addf3.zig").__subtf3(a.*, b.*);
66}
67
68// Comparison
69
70pub fn _Qp_cmp(a: *f128, b: *f128) callconv(.C) i32 {
71 return @enumToInt(@import("compareXf2.zig").cmp(f128, FCMP, a.*, b.*));
72}
73
74pub fn _Qp_feq(a: *f128, b: *f128) callconv(.C) bool {
75 return _Qp_cmp(a, b) == @enumToInt(FCMP.Equal);
76}
77
78pub fn _Qp_fne(a: *f128, b: *f128) callconv(.C) bool {
79 return _Qp_cmp(a, b) != @enumToInt(FCMP.Equal);
80}
81
82pub fn _Qp_flt(a: *f128, b: *f128) callconv(.C) bool {
83 return _Qp_cmp(a, b) == @enumToInt(FCMP.Less);
84}
85
86pub fn _Qp_fle(a: *f128, b: *f128) callconv(.C) bool {
87 const cmp = _Qp_cmp(a, b);
88 return cmp == @enumToInt(FCMP.Less) or cmp == @enumToInt(FCMP.Equal);
89}
90
91pub fn _Qp_fgt(a: *f128, b: *f128) callconv(.C) bool {
92 return _Qp_cmp(a, b) == @enumToInt(FCMP.Greater);
93}
94
95pub fn _Qp_fge(a: *f128, b: *f128) callconv(.C) bool {
96 const cmp = _Qp_cmp(a, b);
97 return cmp == @enumToInt(FCMP.Greater) or cmp == @enumToInt(FCMP.Equal);
98}
99
100// Conversion
101
102pub fn _Qp_itoq(c: *f128, a: i32) callconv(.C) void {
103 c.* = @import("floatXiYf.zig").__floatsitf(a);
104}
105
106pub fn _Qp_uitoq(c: *f128, a: u32) callconv(.C) void {
107 c.* = @import("floatXiYf.zig").__floatunsitf(a);
108}
109
110pub fn _Qp_xtoq(c: *f128, a: i64) callconv(.C) void {
111 c.* = @import("floatXiYf.zig").__floatditf(a);
112}
113
114pub fn _Qp_uxtoq(c: *f128, a: u64) callconv(.C) void {
115 c.* = @import("floatXiYf.zig").__floatunditf(a);
116}
117
118pub fn _Qp_stoq(c: *f128, a: f32) callconv(.C) void {
119 c.* = @import("extendXfYf2.zig").__extendsftf2(a);
120}
121
122pub fn _Qp_dtoq(c: *f128, a: f64) callconv(.C) void {
123 c.* = @import("extendXfYf2.zig").__extenddftf2(a);
124}
125
126pub fn _Qp_qtoi(a: *f128) callconv(.C) i32 {
127 return @import("fixXfYi.zig").__fixtfsi(a.*);
128}
129
130pub fn _Qp_qtoui(a: *f128) callconv(.C) u32 {
131 return @import("fixXfYi.zig").__fixunstfsi(a.*);
132}
133
134pub fn _Qp_qtox(a: *f128) callconv(.C) i64 {
135 return @import("fixXfYi.zig").__fixtfdi(a.*);
136}
137
138pub fn _Qp_qtoux(a: *f128) callconv(.C) u64 {
139 return @import("fixXfYi.zig").__fixunstfdi(a.*);
140}
141
142pub fn _Qp_qtos(a: *f128) callconv(.C) f32 {
143 return @import("truncXfYf2.zig").__trunctfsf2(a.*);
144}
145
146pub fn _Qp_qtod(a: *f128) callconv(.C) f64 {
147 return @import("truncXfYf2.zig").__trunctfdf2(a.*);
148}
lib/compiler_rt/subtf3.zig+11-2
...@@ -5,17 +5,26 @@ pub const panic = common.panic;...@@ -5,17 +5,26 @@ pub const panic = common.panic;
5comptime {5comptime {
6 if (common.want_ppc_abi) {6 if (common.want_ppc_abi) {
7 @export(__subkf3, .{ .name = "__subkf3", .linkage = common.linkage });7 @export(__subkf3, .{ .name = "__subkf3", .linkage = common.linkage });
8 } else if (common.want_sparc_abi) {
9 @export(_Qp_sub, .{ .name = "_Qp_sub", .linkage = common.linkage });
8 } else {10 } else {
9 @export(__subtf3, .{ .name = "__subtf3", .linkage = common.linkage });11 @export(__subtf3, .{ .name = "__subtf3", .linkage = common.linkage });
10 }12 }
11}13}
1214
13fn __subtf3(a: f128, b: f128) callconv(.C) f128 {15fn __subtf3(a: f128, b: f128) callconv(.C) f128 {
14 const neg_b = @bitCast(f128, @bitCast(u128, b) ^ (@as(u128, 1) << 127));16 return sub(a, b);
15 return a + neg_b;
16}17}
1718
18fn __subkf3(a: f128, b: f128) callconv(.C) f128 {19fn __subkf3(a: f128, b: f128) callconv(.C) f128 {
20 return sub(a, b);
21}
22
23fn _Qp_sub(c: *f128, a: *const f128, b: *const f128) callconv(.C) void {
24 c.* = sub(a.*, b.*);
25}
26
27inline fn sub(a: f128, b: f128) f128 {
19 const neg_b = @bitCast(f128, @bitCast(u128, b) ^ (@as(u128, 1) << 127));28 const neg_b = @bitCast(f128, @bitCast(u128, b) ^ (@as(u128, 1) << 127));
20 return a + neg_b;29 return a + neg_b;
21}30}
lib/compiler_rt/trunctfdf2.zig+6
...@@ -6,6 +6,8 @@ pub const panic = common.panic;...@@ -6,6 +6,8 @@ pub const panic = common.panic;
6comptime {6comptime {
7 if (common.want_ppc_abi) {7 if (common.want_ppc_abi) {
8 @export(__trunckfdf2, .{ .name = "__trunckfdf2", .linkage = common.linkage });8 @export(__trunckfdf2, .{ .name = "__trunckfdf2", .linkage = common.linkage });
9 } else if (common.want_sparc_abi) {
10 @export(_Qp_qtod, .{ .name = "_Qp_qtod", .linkage = common.linkage });
9 } else {11 } else {
10 @export(__trunctfdf2, .{ .name = "__trunctfdf2", .linkage = common.linkage });12 @export(__trunctfdf2, .{ .name = "__trunctfdf2", .linkage = common.linkage });
11 }13 }
...@@ -18,3 +20,7 @@ fn __trunctfdf2(a: f128) callconv(.C) f64 {...@@ -18,3 +20,7 @@ fn __trunctfdf2(a: f128) callconv(.C) f64 {
18fn __trunckfdf2(a: f128) callconv(.C) f64 {20fn __trunckfdf2(a: f128) callconv(.C) f64 {
19 return truncf(f64, f128, a);21 return truncf(f64, f128, a);
20}22}
23
24fn _Qp_qtod(a: *const f128) callconv(.C) f64 {
25 return truncf(f64, f128, a.*);
26}
lib/compiler_rt/trunctfsf2.zig+6
...@@ -6,6 +6,8 @@ pub const panic = common.panic;...@@ -6,6 +6,8 @@ pub const panic = common.panic;
6comptime {6comptime {
7 if (common.want_ppc_abi) {7 if (common.want_ppc_abi) {
8 @export(__trunckfsf2, .{ .name = "__trunckfsf2", .linkage = common.linkage });8 @export(__trunckfsf2, .{ .name = "__trunckfsf2", .linkage = common.linkage });
9 } else if (common.want_sparc_abi) {
10 @export(_Qp_qtos, .{ .name = "_Qp_qtos", .linkage = common.linkage });
9 } else {11 } else {
10 @export(__trunctfsf2, .{ .name = "__trunctfsf2", .linkage = common.linkage });12 @export(__trunctfsf2, .{ .name = "__trunctfsf2", .linkage = common.linkage });
11 }13 }
...@@ -18,3 +20,7 @@ fn __trunctfsf2(a: f128) callconv(.C) f32 {...@@ -18,3 +20,7 @@ fn __trunctfsf2(a: f128) callconv(.C) f32 {
18fn __trunckfsf2(a: f128) callconv(.C) f32 {20fn __trunckfsf2(a: f128) callconv(.C) f32 {
19 return truncf(f32, f128, a);21 return truncf(f32, f128, a);
20}22}
23
24fn _Qp_qtos(a: *const f128) callconv(.C) f32 {
25 return truncf(f32, f128, a.*);
26}
lib/compiler_rt/unordtf2.zig+3
...@@ -6,6 +6,9 @@ pub const panic = common.panic;...@@ -6,6 +6,9 @@ pub const panic = common.panic;
6comptime {6comptime {
7 if (common.want_ppc_abi) {7 if (common.want_ppc_abi) {
8 @export(__unordkf2, .{ .name = "__unordkf2", .linkage = common.linkage });8 @export(__unordkf2, .{ .name = "__unordkf2", .linkage = common.linkage });
9 } else if (common.want_sparc_abi) {
10 // These exports are handled in cmptf2.zig because unordered comparisons
11 // are based on calling _Qp_cmp.
9 } else {12 } else {
10 @export(__unordtf2, .{ .name = "__unordtf2", .linkage = common.linkage });13 @export(__unordtf2, .{ .name = "__unordtf2", .linkage = common.linkage });
11 }14 }
src/compiler_rt.zig-1
...@@ -228,6 +228,5 @@ const sources = &[_][]const u8{...@@ -228,6 +228,5 @@ const sources = &[_][]const u8{
228 "compiler_rt/arm.zig",228 "compiler_rt/arm.zig",
229 "compiler_rt/aulldiv.zig",229 "compiler_rt/aulldiv.zig",
230 "compiler_rt/aullrem.zig",230 "compiler_rt/aullrem.zig",
231 "compiler_rt/sparc.zig",
232 "compiler_rt/clear_cache.zig",231 "compiler_rt/clear_cache.zig",
233};232};