authorgravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2021-04-11 18:59:31-07:00
committergravatar for noreply@github.comGitHub <noreply@github.com> 2021-04-11 18:59:31-07:00
logc5e662d860f7b77350a06938ca2e40993eb70a3c
tree02702cf20b904d85bb7d86c8aa6a5423c8946fa7
parent82a31aac9b955213f47ff3b2a2c7eb932fdbe294
parent44f8ce690ddd406fc1a9caa63d9c0741f4afb3a0
signaturebadge-question-mark Signed by PGP key 4AEE18F83AFDEB23

Merge pull request #8497 from LemonBoy/some-ppc-fixes

Improve Improve PowerPC support

5 files changed, 43 insertions(+), 8 deletions(-)

lib/std/os/linux/tls.zig+9-2
...@@ -69,7 +69,7 @@ const tls_tcb_size = switch (builtin.arch) {...@@ -69,7 +69,7 @@ const tls_tcb_size = switch (builtin.arch) {
6969
70// Controls if the TP points to the end of the TCB instead of its beginning70// Controls if the TP points to the end of the TCB instead of its beginning
71const tls_tp_points_past_tcb = switch (builtin.arch) {71const tls_tp_points_past_tcb = switch (builtin.arch) {
72 .riscv32, .riscv64, .mips, .mipsel, .powerpc64, .powerpc64le => true,72 .riscv32, .riscv64, .mips, .mipsel, .powerpc, .powerpc64, .powerpc64le => true,
73 else => false,73 else => false,
74};74};
7575
...@@ -165,7 +165,14 @@ pub fn setThreadPointer(addr: usize) void {...@@ -165,7 +165,14 @@ pub fn setThreadPointer(addr: usize) void {
165 const rc = std.os.linux.syscall1(.set_thread_area, addr);165 const rc = std.os.linux.syscall1(.set_thread_area, addr);
166 assert(rc == 0);166 assert(rc == 0);
167 },167 },
168 .powerpc, .powerpc64, .powerpc64le => {168 .powerpc => {
169 asm volatile (
170 \\ mr 2, %[addr]
171 :
172 : [addr] "r" (addr)
173 );
174 },
175 .powerpc64, .powerpc64le => {
169 asm volatile (176 asm volatile (
170 \\ mr 13, %[addr]177 \\ mr 13, %[addr]
171 :178 :
lib/std/special/c.zig+1-1
...@@ -939,7 +939,7 @@ export fn sqrt(x: f64) f64 {...@@ -939,7 +939,7 @@ export fn sqrt(x: f64) f64 {
939939
940 r = sign;940 r = sign;
941 while (r != 0) {941 while (r != 0) {
942 t = s1 +% r;942 t1 = s1 +% r;
943 t = s0;943 t = s0;
944 if (t < ix0 or (t == ix0 and t1 <= ix1)) {944 if (t < ix0 or (t == ix0 and t1 <= ix1)) {
945 s1 = t1 +% r;945 s1 = t1 +% r;
lib/std/special/compiler_rt.zig+27
...@@ -296,6 +296,33 @@ comptime {...@@ -296,6 +296,33 @@ comptime {
296 @export(@import("compiler_rt/sparc.zig")._Qp_qtod, .{ .name = "_Qp_qtod", .linkage = linkage });296 @export(@import("compiler_rt/sparc.zig")._Qp_qtod, .{ .name = "_Qp_qtod", .linkage = linkage });
297 }297 }
298298
299 if (builtin.arch == .powerpc or builtin.arch.isPPC64()) {
300 @export(@import("compiler_rt/addXf3.zig").__addtf3, .{ .name = "__addkf3", .linkage = linkage });
301 @export(@import("compiler_rt/addXf3.zig").__subtf3, .{ .name = "__subkf3", .linkage = linkage });
302 @export(@import("compiler_rt/mulXf3.zig").__multf3, .{ .name = "__mulkf3", .linkage = linkage });
303 @export(@import("compiler_rt/divtf3.zig").__divtf3, .{ .name = "__divkf3", .linkage = linkage });
304 @export(@import("compiler_rt/extendXfYf2.zig").__extendsftf2, .{ .name = "__extendsfkf2", .linkage = linkage });
305 @export(@import("compiler_rt/extendXfYf2.zig").__extenddftf2, .{ .name = "__extenddfkf2", .linkage = linkage });
306 @export(@import("compiler_rt/truncXfYf2.zig").__trunctfsf2, .{ .name = "__trunckfsf2", .linkage = linkage });
307 @export(@import("compiler_rt/truncXfYf2.zig").__trunctfdf2, .{ .name = "__trunckfdf2", .linkage = linkage });
308 @export(@import("compiler_rt/fixtfdi.zig").__fixtfdi, .{ .name = "__fixkfdi", .linkage = linkage });
309 @export(@import("compiler_rt/fixtfsi.zig").__fixtfsi, .{ .name = "__fixkfsi", .linkage = linkage });
310 @export(@import("compiler_rt/fixunstfsi.zig").__fixunstfsi, .{ .name = "__fixunskfsi", .linkage = linkage });
311 @export(@import("compiler_rt/fixunstfdi.zig").__fixunstfdi, .{ .name = "__fixunskfdi", .linkage = linkage });
312 @export(@import("compiler_rt/floatsiXf.zig").__floatsitf, .{ .name = "__floatsikf", .linkage = linkage });
313 @export(@import("compiler_rt/floatditf.zig").__floatditf, .{ .name = "__floatdikf", .linkage = linkage });
314 @export(@import("compiler_rt/floatunditf.zig").__floatunditf, .{ .name = "__floatundikf", .linkage = linkage });
315 @export(@import("compiler_rt/floatunsitf.zig").__floatunsitf, .{ .name = "__floatunsikf", .linkage = linkage });
316
317 @export(@import("compiler_rt/compareXf2.zig").__letf2, .{ .name = "__eqkf2", .linkage = linkage });
318 @export(@import("compiler_rt/compareXf2.zig").__letf2, .{ .name = "__nekf2", .linkage = linkage });
319 @export(@import("compiler_rt/compareXf2.zig").__getf2, .{ .name = "__gekf2", .linkage = linkage });
320 @export(@import("compiler_rt/compareXf2.zig").__letf2, .{ .name = "__ltkf2", .linkage = linkage });
321 @export(@import("compiler_rt/compareXf2.zig").__letf2, .{ .name = "__lekf2", .linkage = linkage });
322 @export(@import("compiler_rt/compareXf2.zig").__getf2, .{ .name = "__gtkf2", .linkage = linkage });
323 @export(@import("compiler_rt/compareXf2.zig").__unordtf2, .{ .name = "__unordkf2", .linkage = linkage });
324 }
325
299 if (builtin.os.tag == .windows) {326 if (builtin.os.tag == .windows) {
300 // Default stack-probe functions emitted by LLVM327 // Default stack-probe functions emitted by LLVM
301 if (is_mingw) {328 if (is_mingw) {
test/stage1/behavior/bugs/920.zig+1-1
...@@ -60,6 +60,6 @@ test "bug 920 fixed" {...@@ -60,6 +60,6 @@ test "bug 920 fixed" {
60 };60 };
6161
62 for (NormalDist1.f) |_, i| {62 for (NormalDist1.f) |_, i| {
63 std.testing.expect(NormalDist1.f[i] == NormalDist.f[i]);63 std.testing.expectEqual(NormalDist1.f[i], NormalDist.f[i]);
64 }64 }
65}65}
test/stage1/behavior/cast.zig+5-4
...@@ -17,14 +17,15 @@ test "integer literal to pointer cast" {...@@ -17,14 +17,15 @@ test "integer literal to pointer cast" {
17}17}
1818
19test "pointer reinterpret const float to int" {19test "pointer reinterpret const float to int" {
20 // https://github.com/ziglang/zig/issues/334520 // The hex representation is 0x3fe3333333333303.
21 if (std.Target.current.cpu.arch == .mips) return error.SkipZigTest;
22
23 const float: f64 = 5.99999999999994648725e-01;21 const float: f64 = 5.99999999999994648725e-01;
24 const float_ptr = &float;22 const float_ptr = &float;
25 const int_ptr = @ptrCast(*const i32, float_ptr);23 const int_ptr = @ptrCast(*const i32, float_ptr);
26 const int_val = int_ptr.*;24 const int_val = int_ptr.*;
27 expect(int_val == 858993411);25 if (std.builtin.endian == .Little)
26 expect(int_val == 0x33333303)
27 else
28 expect(int_val == 0x3fe33333);
28}29}
2930
30test "implicitly cast indirect pointer to maybe-indirect pointer" {31test "implicitly cast indirect pointer to maybe-indirect pointer" {