From 77ca77cf144e3f7e8be53b6e4220a4efc313628b Mon Sep 17 00:00:00 2001 From: joachimschmidt557 Date: Fri, 7 Jan 2022 22:52:52 +0100 Subject: [PATCH] stage2 ARM: make Mir.Inst.cond = .al default --- src/arch/arm/CodeGen.zig | 59 ---------------------------------------- src/arch/arm/Mir.zig | 2 +- 2 files changed, 1 insertion(+), 60 deletions(-) diff --git a/src/arch/arm/CodeGen.zig b/src/arch/arm/CodeGen.zig index cbd75cc192527a8e99fe86b310f1853438036d47..9fbd661f02050978fa04e9264ca246bf9a842394 100644 --- a/src/arch/arm/CodeGen.zig +++ b/src/arch/arm/CodeGen.zig @@ -338,7 +338,6 @@ fn addInst(self: *Self, inst: Mir.Inst) error{OutOfMemory}!Mir.Inst.Index { fn addNop(self: *Self) error{OutOfMemory}!Mir.Inst.Index { return try self.addInst(.{ .tag = .nop, - .cond = .al, .data = .{ .nop = {} }, }); } @@ -371,7 +370,6 @@ fn gen(self: *Self) !void { // mov fp, sp _ = try self.addInst(.{ .tag = .mov, - .cond = .al, .data = .{ .rr_op = .{ .rd = .fp, .rn = .r0, @@ -405,7 +403,6 @@ fn gen(self: *Self) !void { self.mir_instructions.set(push_reloc, .{ .tag = .push, - .cond = .al, .data = .{ .register_list = saved_regs }, }); @@ -416,7 +413,6 @@ fn gen(self: *Self) !void { if (Instruction.Operand.fromU32(stack_size)) |op| { self.mir_instructions.set(sub_reloc, .{ .tag = .sub, - .cond = .al, .data = .{ .rr_op = .{ .rd = .sp, .rn = .sp, .op = op } }, }); } else { @@ -440,7 +436,6 @@ fn gen(self: *Self) !void { } else for (self.exitlude_jump_relocs.items) |jmp_reloc| { self.mir_instructions.set(jmp_reloc, .{ .tag = .b, - .cond = .al, .data = .{ .inst = @intCast(u32, self.mir_instructions.len) }, }); } @@ -452,7 +447,6 @@ fn gen(self: *Self) !void { // mov sp, fp _ = try self.addInst(.{ .tag = .mov, - .cond = .al, .data = .{ .rr_op = .{ .rd = .sp, .rn = .r0, @@ -463,7 +457,6 @@ fn gen(self: *Self) !void { // pop {fp, pc} _ = try self.addInst(.{ .tag = .pop, - .cond = .al, .data = .{ .register_list = saved_regs }, }); } else { @@ -1251,7 +1244,6 @@ fn airSliceElemVal(self: *Self, inst: Air.Inst.Index) !void { _ = try self.addInst(.{ .tag = tag, - .cond = .al, .data = .{ .rr_offset = .{ .rt = dst_reg, .rn = base_mcv.register, @@ -1262,7 +1254,6 @@ fn airSliceElemVal(self: *Self, inst: Air.Inst.Index) !void { 2 => { _ = try self.addInst(.{ .tag = .ldrh, - .cond = .al, .data = .{ .rr_extra_offset = .{ .rt = dst_reg, .rn = base_mcv.register, @@ -1406,7 +1397,6 @@ fn load(self: *Self, dst_mcv: MCValue, ptr: MCValue, ptr_ty: Type) InnerError!vo .register => |dst_reg| { _ = try self.addInst(.{ .tag = .ldr, - .cond = .al, .data = .{ .rr_offset = .{ .rt = dst_reg, .rn = reg, @@ -1430,7 +1420,6 @@ fn load(self: *Self, dst_mcv: MCValue, ptr: MCValue, ptr_ty: Type) InnerError!vo const tmp_regs = try self.register_manager.allocRegs(2, .{ null, null }, &.{reg}); _ = try self.addInst(.{ .tag = .ldr, - .cond = .al, .data = .{ .rr_offset = .{ .rt = tmp_regs[0], .rn = reg, @@ -1439,7 +1428,6 @@ fn load(self: *Self, dst_mcv: MCValue, ptr: MCValue, ptr_ty: Type) InnerError!vo }); _ = try self.addInst(.{ .tag = .ldr, - .cond = .al, .data = .{ .rr_offset = .{ .rt = tmp_regs[1], .rn = reg, @@ -1465,7 +1453,6 @@ fn load(self: *Self, dst_mcv: MCValue, ptr: MCValue, ptr_ty: Type) InnerError!vo }; _ = try self.addInst(.{ .tag = .sub, - .cond = .al, .data = .{ .rr_op = .{ .rd = dst_reg, .rn = .fp, @@ -1479,7 +1466,6 @@ fn load(self: *Self, dst_mcv: MCValue, ptr: MCValue, ptr_ty: Type) InnerError!vo }; _ = try self.addInst(.{ .tag = .mov, - .cond = .al, .data = .{ .rr_op = .{ .rd = len_reg, .rn = .r0, @@ -1560,7 +1546,6 @@ fn store(self: *Self, ptr: MCValue, value: MCValue, ptr_ty: Type, value_ty: Type .register => |value_reg| { _ = try self.addInst(.{ .tag = .str, - .cond = .al, .data = .{ .rr_offset = .{ .rt = value_reg, .rn = addr_reg, @@ -1866,7 +1851,6 @@ fn genArmBinOpCode( _ = try self.addInst(.{ .tag = tag, - .cond = .al, .data = .{ .rr_op = .{ .rd = dst_reg, .rn = op1, @@ -1879,7 +1863,6 @@ fn genArmBinOpCode( _ = try self.addInst(.{ .tag = tag, - .cond = .al, .data = .{ .rr_op = .{ .rd = dst_reg, .rn = op1, @@ -1890,7 +1873,6 @@ fn genArmBinOpCode( .cmp_eq => { _ = try self.addInst(.{ .tag = .cmp, - .cond = .al, .data = .{ .rr_op = .{ .rd = .r0, .rn = op1, @@ -1916,7 +1898,6 @@ fn genArmBinOpCode( _ = try self.addInst(.{ .tag = tag, - .cond = .al, .data = .{ .rr_shift = .{ .rd = dst_reg, .rm = op1, @@ -1993,7 +1974,6 @@ fn genArmMul(self: *Self, inst: Air.Inst.Index, op_lhs: Air.Inst.Ref, op_rhs: Ai _ = try self.addInst(.{ .tag = .mul, - .cond = .al, .data = .{ .rrr = .{ .rd = dst_mcv.register, .rn = lhs_mcv.register, @@ -2045,7 +2025,6 @@ fn genArmMulConstant(self: *Self, inst: Air.Inst.Index, op: Air.Inst.Ref, op_ind _ = try self.addInst(.{ .tag = .mul, - .cond = .al, .data = .{ .rrr = .{ .rd = dst_mcv.register, .rn = lhs_mcv.register, @@ -2066,7 +2045,6 @@ fn genArmInlineMemcpy( // mov count, #0 _ = try self.addInst(.{ .tag = .mov, - .cond = .al, .data = .{ .rr_op = .{ .rd = count, .rn = .r0, @@ -2078,7 +2056,6 @@ fn genArmInlineMemcpy( // cmp count, len _ = try self.addInst(.{ .tag = .cmp, - .cond = .al, .data = .{ .rr_op = .{ .rd = .r0, .rn = count, @@ -2096,7 +2073,6 @@ fn genArmInlineMemcpy( // ldrb tmp, [src, count] _ = try self.addInst(.{ .tag = .ldrb, - .cond = .al, .data = .{ .rr_offset = .{ .rt = tmp, .rn = src, @@ -2107,7 +2083,6 @@ fn genArmInlineMemcpy( // strb tmp, [src, count] _ = try self.addInst(.{ .tag = .strb, - .cond = .al, .data = .{ .rr_offset = .{ .rt = tmp, .rn = dst, @@ -2118,7 +2093,6 @@ fn genArmInlineMemcpy( // add count, count, #1 _ = try self.addInst(.{ .tag = .add, - .cond = .al, .data = .{ .rr_op = .{ .rd = count, .rn = count, @@ -2129,7 +2103,6 @@ fn genArmInlineMemcpy( // b loop _ = try self.addInst(.{ .tag = .b, - .cond = .al, .data = .{ .inst = @intCast(u32, self.mir_instructions.len - 5) }, }); @@ -2236,7 +2209,6 @@ fn airArg(self: *Self, inst: Air.Inst.Index) !void { fn airBreakpoint(self: *Self) !void { _ = try self.addInst(.{ .tag = .bkpt, - .cond = .al, .data = .{ .imm16 = 0 }, }); return self.finishAirBookkeeping(); @@ -2348,14 +2320,12 @@ fn airCall(self: *Self, inst: Air.Inst.Index) !void { if (Target.arm.featureSetHas(self.target.cpu.features, .has_v5t)) { _ = try self.addInst(.{ .tag = .blx, - .cond = .al, .data = .{ .reg = .lr }, }); } else { return self.fail("TODO fix blx emulation for ARM > 16), @@ -3375,7 +3327,6 @@ fn genSetReg(self: *Self, ty: Type, reg: Register, mcv: MCValue) InnerError!void // orr reg, reg, #0xdd, 8 _ = try self.addInst(.{ .tag = .mov, - .cond = .al, .data = .{ .rr_op = .{ .rd = reg, .rn = .r0, @@ -3384,7 +3335,6 @@ fn genSetReg(self: *Self, ty: Type, reg: Register, mcv: MCValue) InnerError!void }); _ = try self.addInst(.{ .tag = .orr, - .cond = .al, .data = .{ .rr_op = .{ .rd = reg, .rn = reg, @@ -3393,7 +3343,6 @@ fn genSetReg(self: *Self, ty: Type, reg: Register, mcv: MCValue) InnerError!void }); _ = try self.addInst(.{ .tag = .orr, - .cond = .al, .data = .{ .rr_op = .{ .rd = reg, .rn = reg, @@ -3402,7 +3351,6 @@ fn genSetReg(self: *Self, ty: Type, reg: Register, mcv: MCValue) InnerError!void }); _ = try self.addInst(.{ .tag = .orr, - .cond = .al, .data = .{ .rr_op = .{ .rd = reg, .rn = reg, @@ -3420,7 +3368,6 @@ fn genSetReg(self: *Self, ty: Type, reg: Register, mcv: MCValue) InnerError!void // mov reg, src_reg _ = try self.addInst(.{ .tag = .mov, - .cond = .al, .data = .{ .rr_op = .{ .rd = reg, .rn = .r0, @@ -3434,7 +3381,6 @@ fn genSetReg(self: *Self, ty: Type, reg: Register, mcv: MCValue) InnerError!void try self.genSetReg(ty, reg, .{ .immediate = @intCast(u32, addr) }); _ = try self.addInst(.{ .tag = .ldr, - .cond = .al, .data = .{ .rr_offset = .{ .rt = reg, .rn = reg, @@ -3461,7 +3407,6 @@ fn genSetReg(self: *Self, ty: Type, reg: Register, mcv: MCValue) InnerError!void _ = try self.addInst(.{ .tag = tag, - .cond = .al, .data = .{ .rr_offset = .{ .rt = reg, .rn = .fp, @@ -3479,7 +3424,6 @@ fn genSetReg(self: *Self, ty: Type, reg: Register, mcv: MCValue) InnerError!void _ = try self.addInst(.{ .tag = .ldrh, - .cond = .al, .data = .{ .rr_extra_offset = .{ .rt = reg, .rn = .fp, @@ -3507,7 +3451,6 @@ fn genSetReg(self: *Self, ty: Type, reg: Register, mcv: MCValue) InnerError!void _ = try self.addInst(.{ .tag = tag, - .cond = .al, .data = .{ .r_stack_offset = .{ .rt = reg, .stack_offset = @intCast(u32, adj_off), @@ -3551,7 +3494,6 @@ fn genSetStackArgument(self: *Self, ty: Type, stack_offset: u32, mcv: MCValue) I _ = try self.addInst(.{ .tag = tag, - .cond = .al, .data = .{ .rr_offset = .{ .rt = reg, .rn = .sp, @@ -3566,7 +3508,6 @@ fn genSetStackArgument(self: *Self, ty: Type, stack_offset: u32, mcv: MCValue) I _ = try self.addInst(.{ .tag = .strh, - .cond = .al, .data = .{ .rr_extra_offset = .{ .rt = reg, .rn = .sp, diff --git a/src/arch/arm/Mir.zig b/src/arch/arm/Mir.zig index 13aa1bbe59465667d7306cc6ead6e07be53ec5d4..b19186e003e424236f5df7eed1e0fa1926238dd6 100644 --- a/src/arch/arm/Mir.zig +++ b/src/arch/arm/Mir.zig @@ -20,7 +20,7 @@ extra: []const u32, pub const Inst = struct { tag: Tag, - cond: bits.Condition, + cond: bits.Condition = .al, /// The meaning of this depends on `tag`. data: Data, -- 2.54.0