| author | |
| committer | |
| log | 110c18588688e4c03010e372668bbb0ab90e4735 |
| tree | 94b6ff036bb2c2c723fdd258cf3a7280e49348c1 |
| parent | c6b4fe00660d00d0748dc01f660ed7ac24f54db0 |
If we don't touch the stack, ellide `sub rsp, imm32` to `nop`.3 files changed, 15 insertions(+), 0 deletions(-)
src/arch/x86_64/CodeGen.zig+6| ... | ... | @@ -405,6 +405,12 @@ fn gen(self: *Self) InnerError!void { |
| 405 | 405 | const aligned_stack_end = mem.alignForward(stack_end, self.stack_align); |
| 406 | 406 | if (aligned_stack_end > 0) { |
| 407 | 407 | self.mir_instructions.items(.data)[backpatch_reloc].imm = @intCast(i32, aligned_stack_end); |
| 408 | } else { | |
| 409 | self.mir_instructions.set(backpatch_reloc, .{ | |
| 410 | .tag = .nop, | |
| 411 | .ops = undefined, | |
| 412 | .data = undefined, | |
| 413 | }); | |
| 408 | 414 | } |
| 409 | 415 | |
| 410 | 416 | if (self.exitlude_jump_relocs.items.len == 1) { |
src/arch/x86_64/Emit.zig+6| ... | ... | @@ -134,6 +134,7 @@ pub fn emitMir(emit: *Emit) InnerError!void { |
| 134 | 134 | .@"test" => try emit.mirTest(inst), |
| 135 | 135 | |
| 136 | 136 | .brk => try emit.mirBrk(), |
| 137 | .nop => try emit.mirNop(), | |
| 137 | 138 | |
| 138 | 139 | .call_extern => try emit.mirCallExtern(inst), |
| 139 | 140 | |
| ... | ... | @@ -185,6 +186,11 @@ fn mirBrk(emit: *Emit) InnerError!void { |
| 185 | 186 | encoder.opcode_1byte(0xcc); |
| 186 | 187 | } |
| 187 | 188 | |
| 189 | fn mirNop(emit: *Emit) InnerError!void { | |
| 190 | const encoder = try Encoder.init(emit.code, 1); | |
| 191 | encoder.opcode_1byte(0x90); | |
| 192 | } | |
| 193 | ||
| 188 | 194 | fn mirSyscall(emit: *Emit) InnerError!void { |
| 189 | 195 | const encoder = try Encoder.init(emit.code, 2); |
| 190 | 196 | encoder.opcode_2byte(0x0f, 0x05); |
src/arch/x86_64/Mir.zig+3| ... | ... | @@ -247,6 +247,9 @@ pub const Inst = struct { |
| 247 | 247 | /// Breakpoint |
| 248 | 248 | brk, |
| 249 | 249 | |
| 250 | /// Nop | |
| 251 | nop, | |
| 252 | ||
| 250 | 253 | /// Pseudo-instructions |
| 251 | 254 | /// call extern function |
| 252 | 255 | /// Notes: |