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) {
6969
7070// Controls if the TP points to the end of the TCB instead of its beginning
7171const 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,
7373 else => false,
7474};
7575
......@@ -165,7 +165,14 @@ pub fn setThreadPointer(addr: usize) void {
165165 const rc = std.os.linux.syscall1(.set_thread_area, addr);
166166 assert(rc == 0);
167167 },
168 .powerpc, .powerpc64, .powerpc64le => {
168 .powerpc => {
169 asm volatile (
170 \\ mr 2, %[addr]
171 :
172 : [addr] "r" (addr)
173 );
174 },
175 .powerpc64, .powerpc64le => {
169176 asm volatile (
170177 \\ mr 13, %[addr]
171178 :
lib/std/special/c.zig+1-1
......@@ -939,7 +939,7 @@ export fn sqrt(x: f64) f64 {
939939
940940 r = sign;
941941 while (r != 0) {
942 t = s1 +% r;
942 t1 = s1 +% r;
943943 t = s0;
944944 if (t < ix0 or (t == ix0 and t1 <= ix1)) {
945945 s1 = t1 +% r;
lib/std/special/compiler_rt.zig+27
......@@ -296,6 +296,33 @@ comptime {
296296 @export(@import("compiler_rt/sparc.zig")._Qp_qtod, .{ .name = "_Qp_qtod", .linkage = linkage });
297297 }
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
299326 if (builtin.os.tag == .windows) {
300327 // Default stack-probe functions emitted by LLVM
301328 if (is_mingw) {
test/stage1/behavior/bugs/920.zig+1-1
......@@ -60,6 +60,6 @@ test "bug 920 fixed" {
6060 };
6161
6262 for (NormalDist1.f) |_, i| {
63 std.testing.expect(NormalDist1.f[i] == NormalDist.f[i]);
63 std.testing.expectEqual(NormalDist1.f[i], NormalDist.f[i]);
6464 }
6565}
test/stage1/behavior/cast.zig+5-4
......@@ -17,14 +17,15 @@ test "integer literal to pointer cast" {
1717}
1818
1919test "pointer reinterpret const float to int" {
20 // https://github.com/ziglang/zig/issues/3345
21 if (std.Target.current.cpu.arch == .mips) return error.SkipZigTest;
22
20 // The hex representation is 0x3fe3333333333303.
2321 const float: f64 = 5.99999999999994648725e-01;
2422 const float_ptr = &float;
2523 const int_ptr = @ptrCast(*const i32, float_ptr);
2624 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);
2829}
2930
3031test "implicitly cast indirect pointer to maybe-indirect pointer" {