diff options
| author | joachimschmidt557 <joachim.schmidt557@outlook.com> | 2022-02-20 20:16:44 +0100 |
|---|---|---|
| committer | joachimschmidt557 <joachim.schmidt557@outlook.com> | 2022-02-21 22:54:14 +0100 |
| commit | 2ba1ef165aa3fb5da40d05fed9a120630b2529d2 (patch) | |
| tree | a57611866e4f857483ff03fb666f82fb3a4aba3f | |
| parent | ec62e764551557bfaef2bc0daa0398307420257e (diff) | |
| download | zig-2ba1ef165aa3fb5da40d05fed9a120630b2529d2.tar.gz zig-2ba1ef165aa3fb5da40d05fed9a120630b2529d2.zip | |
stage2 AArch64: implement genSetReg for ptr_stack_offset
| -rw-r--r-- | src/arch/aarch64/CodeGen.zig | 23 | ||||
| -rw-r--r-- | test/behavior/align.zig | 2 | ||||
| -rw-r--r-- | test/behavior/basic.zig | 1 | ||||
| -rw-r--r-- | test/behavior/cast.zig | 1 | ||||
| -rw-r--r-- | test/behavior/optional.zig | 1 |
5 files changed, 20 insertions, 8 deletions
diff --git a/src/arch/aarch64/CodeGen.zig b/src/arch/aarch64/CodeGen.zig index b6d921f33a..0f013ae673 100644 --- a/src/arch/aarch64/CodeGen.zig +++ b/src/arch/aarch64/CodeGen.zig @@ -3057,8 +3057,6 @@ fn genSetStack(self: *Self, ty: Type, stack_offset: u32, mcv: MCValue) InnerErro const abi_size = ty.abiSize(self.target.*); switch (mcv) { .dead => unreachable, - .ptr_stack_offset => unreachable, - .ptr_embedded_in_code => unreachable, .unreach, .none => return, // Nothing to do. .undef => { if (!self.wantSafety()) @@ -3075,6 +3073,8 @@ fn genSetStack(self: *Self, ty: Type, stack_offset: u32, mcv: MCValue) InnerErro .compare_flags_unsigned, .compare_flags_signed, .immediate, + .ptr_stack_offset, + .ptr_embedded_in_code, => { const reg = try self.copyToTmpRegister(ty, mcv); return self.genSetStack(ty, stack_offset, MCValue{ .register = reg }); @@ -3179,7 +3179,6 @@ fn genSetStack(self: *Self, ty: Type, stack_offset: u32, mcv: MCValue) InnerErro fn genSetReg(self: *Self, ty: Type, reg: Register, mcv: MCValue) InnerError!void { switch (mcv) { .dead => unreachable, - .ptr_stack_offset => unreachable, .ptr_embedded_in_code => unreachable, .unreach, .none => return, // Nothing to do. .undef => { @@ -3192,6 +3191,24 @@ fn genSetReg(self: *Self, ty: Type, reg: Register, mcv: MCValue) InnerError!void else => unreachable, // unexpected register size } }, + .ptr_stack_offset => |unadjusted_off| { + // TODO: maybe addressing from sp instead of fp + const elem_ty = ty.childType(); + const abi_size = elem_ty.abiSize(self.target.*); + const adj_off = unadjusted_off + abi_size; + + const imm12 = math.cast(u12, adj_off) catch + return self.fail("TODO larger stack offsets", .{}); + + _ = try self.addInst(.{ + .tag = .sub_immediate, + .data = .{ .rr_imm12_sh = .{ + .rd = reg, + .rn = .x29, + .imm12 = imm12, + } }, + }); + }, .compare_flags_unsigned, .compare_flags_signed, => |op| { diff --git a/test/behavior/align.zig b/test/behavior/align.zig index 22cbce8261..98a18c5b3b 100644 --- a/test/behavior/align.zig +++ b/test/behavior/align.zig @@ -27,7 +27,6 @@ test "default alignment allows unspecified in type syntax" { } test "implicitly decreasing pointer alignment" { - if (builtin.zig_backend == .stage2_aarch64) return error.SkipZigTest; const a: u32 align(4) = 3; const b: u32 align(8) = 4; try expect(addUnaligned(&a, &b) == 7); @@ -38,7 +37,6 @@ fn addUnaligned(a: *align(1) const u32, b: *align(1) const u32) u32 { } test "@alignCast pointers" { - if (builtin.zig_backend == .stage2_aarch64) return error.SkipZigTest; var x: u32 align(4) = 1; expectsOnly1(&x); try expect(x == 2); diff --git a/test/behavior/basic.zig b/test/behavior/basic.zig index bd862a7ef9..873e41827f 100644 --- a/test/behavior/basic.zig +++ b/test/behavior/basic.zig @@ -327,7 +327,6 @@ const FnPtrWrapper = struct { }; test "const ptr from var variable" { - if (builtin.zig_backend == .stage2_aarch64) return error.SkipZigTest; if (builtin.zig_backend == .stage2_arm) return error.SkipZigTest; var x: u64 = undefined; diff --git a/test/behavior/cast.zig b/test/behavior/cast.zig index 75d470b21f..b234255600 100644 --- a/test/behavior/cast.zig +++ b/test/behavior/cast.zig @@ -211,7 +211,6 @@ test "implicit cast from *[N]T to [*c]T" { } test "*usize to *void" { - if (builtin.zig_backend == .stage2_aarch64) return error.SkipZigTest; var i = @as(usize, 0); var v = @ptrCast(*void, &i); v.* = {}; diff --git a/test/behavior/optional.zig b/test/behavior/optional.zig index 78788d6556..71f34d0096 100644 --- a/test/behavior/optional.zig +++ b/test/behavior/optional.zig @@ -36,7 +36,6 @@ test "optional pointer to size zero struct" { } test "equality compare optional pointers" { - if (builtin.zig_backend == .stage2_aarch64) return error.SkipZigTest; if (builtin.zig_backend == .stage2_arm) return error.SkipZigTest; // TODO if (builtin.zig_backend == .stage2_x86_64) return error.SkipZigTest; // TODO |
