diff options
| author | joachimschmidt557 <joachim.schmidt557@outlook.com> | 2022-02-12 14:31:25 +0100 |
|---|---|---|
| committer | joachimschmidt557 <joachim.schmidt557@outlook.com> | 2022-02-14 22:09:44 +0100 |
| commit | 3a33f313347f3fa151ba3a90c1c3b14eee3d1d1e (patch) | |
| tree | 364f538c243c4e9f7af05770d535c7e84ab947df /src/arch/aarch64/CodeGen.zig | |
| parent | edb2a75982a011dc883678ca57efa8c3f6be5466 (diff) | |
| download | zig-3a33f313347f3fa151ba3a90c1c3b14eee3d1d1e.tar.gz zig-3a33f313347f3fa151ba3a90c1c3b14eee3d1d1e.zip | |
stage2 AArch64: implement cond_br for other MCValues
Diffstat (limited to 'src/arch/aarch64/CodeGen.zig')
| -rw-r--r-- | src/arch/aarch64/CodeGen.zig | 32 |
1 files changed, 24 insertions, 8 deletions
diff --git a/src/arch/aarch64/CodeGen.zig b/src/arch/aarch64/CodeGen.zig index 7c207039b9..fade038eb0 100644 --- a/src/arch/aarch64/CodeGen.zig +++ b/src/arch/aarch64/CodeGen.zig @@ -923,12 +923,12 @@ fn airNot(self: *Self, inst: Air.Inst.Index) !void { }; break :result r; }, - else => {}, + else => { + return self.fail("TODO implement NOT for {}", .{self.target.cpu.arch}); + }, } - - return self.fail("TODO implement NOT for {}", .{self.target.cpu.arch}); }; - _ = result; + return self.finishAir(inst, result, .{ ty_op.operand, .none, .none }); } fn airMin(self: *Self, inst: Air.Inst.Index) !void { @@ -1411,7 +1411,7 @@ fn airSliceLen(self: *Self, inst: Air.Inst.Index) !void { .dead, .unreach => unreachable, .register => unreachable, // a slice doesn't fit in one register .stack_offset => |off| { - break :result MCValue{ .stack_offset = off + 8 }; + break :result MCValue{ .stack_offset = off }; }, .memory => |addr| { break :result MCValue{ .memory = addr + 8 }; @@ -2425,7 +2425,22 @@ fn airCondBr(self: *Self, inst: Air.Inst.Index) !void { }, }, }), - else => return self.fail("TODO implement condbr when condition is {s}", .{@tagName(cond)}), + else => blk: { + const reg = switch (cond) { + .register => |r| r, + else => try self.copyToTmpRegister(Type.bool, cond), + }; + + break :blk try self.addInst(.{ + .tag = .cbz, + .data = .{ + .r_inst = .{ + .rt = reg, + .inst = undefined, // populated later through performReloc + }, + }, + }); + }, }; // Capture the state of register and stack allocation state so that we can revert to it. @@ -2770,8 +2785,9 @@ fn airSwitch(self: *Self, inst: Air.Inst.Index) !void { fn performReloc(self: *Self, inst: Mir.Inst.Index) !void { const tag = self.mir_instructions.items(.tag)[inst]; switch (tag) { - .b_cond => self.mir_instructions.items(.data)[inst].inst_cond.inst = @intCast(Air.Inst.Index, self.mir_instructions.len), - .b => self.mir_instructions.items(.data)[inst].inst = @intCast(Air.Inst.Index, self.mir_instructions.len), + .cbz => self.mir_instructions.items(.data)[inst].r_inst.inst = @intCast(Mir.Inst.Index, self.mir_instructions.len), + .b_cond => self.mir_instructions.items(.data)[inst].inst_cond.inst = @intCast(Mir.Inst.Index, self.mir_instructions.len), + .b => self.mir_instructions.items(.data)[inst].inst = @intCast(Mir.Inst.Index, self.mir_instructions.len), else => unreachable, } } |
