| ... | @@ -423,6 +423,14 @@ fn asmCmovccRegisterRegister(self: *Self, reg1: Register, reg2: Register, cc: bi | ... | @@ -423,6 +423,14 @@ fn asmCmovccRegisterRegister(self: *Self, reg1: Register, reg2: Register, cc: bi |
| 423 | }); | 423 | }); |
| 424 | } | 424 | } |
| 425 | | 425 | |
| | 426 | fn asmJmpReloc(self: *Self, target: Mir.Inst.Index) !Mir.Inst.Index { |
| | 427 | return self.addInst(.{ |
| | 428 | .tag = .jmp_reloc, |
| | 429 | .ops = undefined, |
| | 430 | .data = .{ .inst = target }, |
| | 431 | }); |
| | 432 | } |
| | 433 | |
| 426 | fn asmNone(self: *Self, tag: Mir.Inst.Tag) !void { | 434 | fn asmNone(self: *Self, tag: Mir.Inst.Tag) !void { |
| 427 | _ = try self.addInst(.{ | 435 | _ = try self.addInst(.{ |
| 428 | .tag = tag, | 436 | .tag = tag, |
| ... | @@ -4145,11 +4153,7 @@ fn airRet(self: *Self, inst: Air.Inst.Index) !void { | ... | @@ -4145,11 +4153,7 @@ fn airRet(self: *Self, inst: Air.Inst.Index) !void { |
| 4145 | // TODO when implementing defer, this will need to jump to the appropriate defer expression. | 4153 | // TODO when implementing defer, this will need to jump to the appropriate defer expression. |
| 4146 | // TODO optimization opportunity: figure out when we can emit this as a 2 byte instruction | 4154 | // TODO optimization opportunity: figure out when we can emit this as a 2 byte instruction |
| 4147 | // which is available if the jump is 127 bytes or less forward. | 4155 | // which is available if the jump is 127 bytes or less forward. |
| 4148 | const jmp_reloc = try self.addInst(.{ | 4156 | const jmp_reloc = try self.asmJmpReloc(undefined); |
| 4149 | .tag = .jmp_reloc, | | |
| 4150 | .ops = .inst, | | |
| 4151 | .data = .{ .inst = undefined }, | | |
| 4152 | }); | | |
| 4153 | try self.exitlude_jump_relocs.append(self.gpa, jmp_reloc); | 4157 | try self.exitlude_jump_relocs.append(self.gpa, jmp_reloc); |
| 4154 | return self.finishAir(inst, .dead, .{ un_op, .none, .none }); | 4158 | return self.finishAir(inst, .dead, .{ un_op, .none, .none }); |
| 4155 | } | 4159 | } |
| ... | @@ -4181,11 +4185,7 @@ fn airRetLoad(self: *Self, inst: Air.Inst.Index) !void { | ... | @@ -4181,11 +4185,7 @@ fn airRetLoad(self: *Self, inst: Air.Inst.Index) !void { |
| 4181 | // TODO when implementing defer, this will need to jump to the appropriate defer expression. | 4185 | // TODO when implementing defer, this will need to jump to the appropriate defer expression. |
| 4182 | // TODO optimization opportunity: figure out when we can emit this as a 2 byte instruction | 4186 | // TODO optimization opportunity: figure out when we can emit this as a 2 byte instruction |
| 4183 | // which is available if the jump is 127 bytes or less forward. | 4187 | // which is available if the jump is 127 bytes or less forward. |
| 4184 | const jmp_reloc = try self.addInst(.{ | 4188 | const jmp_reloc = try self.asmJmpReloc(undefined); |
| 4185 | .tag = .jmp_reloc, | | |
| 4186 | .ops = .inst, | | |
| 4187 | .data = .{ .inst = undefined }, | | |
| 4188 | }); | | |
| 4189 | try self.exitlude_jump_relocs.append(self.gpa, jmp_reloc); | 4189 | try self.exitlude_jump_relocs.append(self.gpa, jmp_reloc); |
| 4190 | return self.finishAir(inst, .dead, .{ un_op, .none, .none }); | 4190 | return self.finishAir(inst, .dead, .{ un_op, .none, .none }); |
| 4191 | } | 4191 | } |
| ... | @@ -4722,11 +4722,7 @@ fn airLoop(self: *Self, inst: Air.Inst.Index) !void { | ... | @@ -4722,11 +4722,7 @@ fn airLoop(self: *Self, inst: Air.Inst.Index) !void { |
| 4722 | const body = self.air.extra[loop.end..][0..loop.data.body_len]; | 4722 | const body = self.air.extra[loop.end..][0..loop.data.body_len]; |
| 4723 | const jmp_target = @intCast(u32, self.mir_instructions.len); | 4723 | const jmp_target = @intCast(u32, self.mir_instructions.len); |
| 4724 | try self.genBody(body); | 4724 | try self.genBody(body); |
| 4725 | _ = try self.addInst(.{ | 4725 | _ = try self.asmJmpReloc(jmp_target); |
| 4726 | .tag = .jmp_reloc, | | |
| 4727 | .ops = .inst, | | |
| 4728 | .data = .{ .inst = jmp_target }, | | |
| 4729 | }); | | |
| 4730 | return self.finishAirBookkeeping(); | 4726 | return self.finishAirBookkeeping(); |
| 4731 | } | 4727 | } |
| 4732 | | 4728 | |
| ... | @@ -5062,11 +5058,7 @@ fn brVoid(self: *Self, block: Air.Inst.Index) !void { | ... | @@ -5062,11 +5058,7 @@ fn brVoid(self: *Self, block: Air.Inst.Index) !void { |
| 5062 | // Emit a jump with a relocation. It will be patched up after the block ends. | 5058 | // Emit a jump with a relocation. It will be patched up after the block ends. |
| 5063 | try block_data.relocs.ensureUnusedCapacity(self.gpa, 1); | 5059 | try block_data.relocs.ensureUnusedCapacity(self.gpa, 1); |
| 5064 | // Leave the jump offset undefined | 5060 | // Leave the jump offset undefined |
| 5065 | const jmp_reloc = try self.addInst(.{ | 5061 | const jmp_reloc = try self.asmJmpReloc(undefined); |
| 5066 | .tag = .jmp_reloc, | | |
| 5067 | .ops = .inst, | | |
| 5068 | .data = .{ .inst = undefined }, | | |
| 5069 | }); | | |
| 5070 | block_data.relocs.appendAssumeCapacity(jmp_reloc); | 5062 | block_data.relocs.appendAssumeCapacity(jmp_reloc); |
| 5071 | } | 5063 | } |
| 5072 | | 5064 | |
| ... | @@ -5656,13 +5648,7 @@ fn genInlineMemcpy( | ... | @@ -5656,13 +5648,7 @@ fn genInlineMemcpy( |
| 5656 | }), tmp_reg.to8()); | 5648 | }), tmp_reg.to8()); |
| 5657 | try self.asmRegisterImmediate(.add, index_reg, Immediate.u(1)); | 5649 | try self.asmRegisterImmediate(.add, index_reg, Immediate.u(1)); |
| 5658 | try self.asmRegisterImmediate(.sub, count_reg, Immediate.u(1)); | 5650 | try self.asmRegisterImmediate(.sub, count_reg, Immediate.u(1)); |
| 5659 | | 5651 | _ = try self.asmJmpReloc(loop_start); |
| 5660 | _ = try self.addInst(.{ | | |
| 5661 | .tag = .jmp_reloc, | | |
| 5662 | .ops = .inst, | | |
| 5663 | .data = .{ .inst = loop_start }, | | |
| 5664 | }); | | |
| 5665 | | | |
| 5666 | try self.performReloc(loop_reloc); | 5652 | try self.performReloc(loop_reloc); |
| 5667 | } | 5653 | } |
| 5668 | | 5654 | |
| ... | @@ -5750,13 +5736,7 @@ fn genInlineMemset( | ... | @@ -5750,13 +5736,7 @@ fn genInlineMemset( |
| 5750 | } | 5736 | } |
| 5751 | | 5737 | |
| 5752 | try self.asmRegisterImmediate(.sub, index_reg, Immediate.u(1)); | 5738 | try self.asmRegisterImmediate(.sub, index_reg, Immediate.u(1)); |
| 5753 | | 5739 | _ = try self.asmJmpReloc(loop_start); |
| 5754 | _ = try self.addInst(.{ | | |
| 5755 | .tag = .jmp_reloc, | | |
| 5756 | .ops = .inst, | | |
| 5757 | .data = .{ .inst = loop_start }, | | |
| 5758 | }); | | |
| 5759 | | | |
| 5760 | try self.performReloc(loop_reloc); | 5740 | try self.performReloc(loop_reloc); |
| 5761 | } | 5741 | } |
| 5762 | | 5742 | |