| ... | ... | @@ -2785,7 +2785,7 @@ fn store(self: *Self, ptr: MCValue, value: MCValue, ptr_ty: Type, value_ty: Type |
| 2785 | 2785 | // introduce new MIR tag specifically for mov [reg + 0], imm |
| 2786 | 2786 | const payload = try self.addExtra(Mir.ImmPair{ |
| 2787 | 2787 | .dest_off = 0, |
| 2788 | | .operand = @intCast(u32, imm), |
| 2788 | .operand = @truncate(u32, imm), |
| 2789 | 2789 | }); |
| 2790 | 2790 | _ = try self.addInst(.{ |
| 2791 | 2791 | .tag = .mov_mem_imm, |
| ... | ... | @@ -5385,31 +5385,33 @@ fn genSetStackArg(self: *Self, ty: Type, stack_offset: i32, mcv: MCValue) InnerE |
| 5385 | 5385 | return self.genSetStackArg(ty, stack_offset, .{ .register = reg }); |
| 5386 | 5386 | }, |
| 5387 | 5387 | .immediate => |imm| { |
| 5388 | _ = imm; |
| 5388 | 5389 | switch (abi_size) { |
| 5389 | | 1, 2, 4 => { |
| 5390 | | // We have a positive stack offset value but we want a twos complement negative |
| 5391 | | // offset from rbp, which is at the top of the stack frame. |
| 5392 | | // mov [rbp+offset], immediate |
| 5393 | | const flags: u2 = switch (abi_size) { |
| 5394 | | 1 => 0b00, |
| 5395 | | 2 => 0b01, |
| 5396 | | 4 => 0b10, |
| 5397 | | else => unreachable, |
| 5398 | | }; |
| 5399 | | const payload = try self.addExtra(Mir.ImmPair{ |
| 5400 | | .dest_off = -stack_offset, |
| 5401 | | .operand = @intCast(u32, imm), |
| 5402 | | }); |
| 5403 | | _ = try self.addInst(.{ |
| 5404 | | .tag = .mov_mem_imm, |
| 5405 | | .ops = Mir.Inst.Ops.encode(.{ |
| 5406 | | .reg1 = .rsp, |
| 5407 | | .flags = flags, |
| 5408 | | }), |
| 5409 | | .data = .{ .payload = payload }, |
| 5410 | | }); |
| 5411 | | }, |
| 5412 | | 8 => { |
| 5390 | // TODO |
| 5391 | // 1, 2, 4 => { |
| 5392 | // // We have a positive stack offset value but we want a twos complement negative |
| 5393 | // // offset from rbp, which is at the top of the stack frame. |
| 5394 | // // mov [rbp+offset], immediate |
| 5395 | // const flags: u2 = switch (abi_size) { |
| 5396 | // 1 => 0b00, |
| 5397 | // 2 => 0b01, |
| 5398 | // 4 => 0b10, |
| 5399 | // else => unreachable, |
| 5400 | // }; |
| 5401 | // const payload = try self.addExtra(Mir.ImmPair{ |
| 5402 | // .dest_off = -stack_offset, |
| 5403 | // .operand = @intCast(u32, imm), |
| 5404 | // }); |
| 5405 | // _ = try self.addInst(.{ |
| 5406 | // .tag = .mov_mem_imm, |
| 5407 | // .ops = Mir.Inst.Ops.encode(.{ |
| 5408 | // .reg1 = .rsp, |
| 5409 | // .flags = flags, |
| 5410 | // }), |
| 5411 | // .data = .{ .payload = payload }, |
| 5412 | // }); |
| 5413 | // }, |
| 5414 | 1, 2, 4, 8 => { |
| 5413 | 5415 | const reg = try self.copyToTmpRegister(ty, mcv); |
| 5414 | 5416 | return self.genSetStackArg(ty, stack_offset, MCValue{ .register = reg }); |
| 5415 | 5417 | }, |
| ... | ... | @@ -5543,7 +5545,7 @@ fn genSetStack(self: *Self, ty: Type, stack_offset: i32, mcv: MCValue, opts: Inl |
| 5543 | 5545 | assert(ty.isError()); |
| 5544 | 5546 | const payload = try self.addExtra(Mir.ImmPair{ |
| 5545 | 5547 | .dest_off = -stack_offset, |
| 5546 | | .operand = @intCast(u32, x_big), |
| 5548 | .operand = @truncate(u32, x_big), |
| 5547 | 5549 | }); |
| 5548 | 5550 | _ = try self.addInst(.{ |
| 5549 | 5551 | .tag = .mov_mem_imm, |
| ... | ... | @@ -5557,7 +5559,7 @@ fn genSetStack(self: *Self, ty: Type, stack_offset: i32, mcv: MCValue, opts: Inl |
| 5557 | 5559 | 1, 2, 4 => { |
| 5558 | 5560 | const payload = try self.addExtra(Mir.ImmPair{ |
| 5559 | 5561 | .dest_off = -stack_offset, |
| 5560 | | .operand = @intCast(u32, x_big), |
| 5562 | .operand = @truncate(u32, x_big), |
| 5561 | 5563 | }); |
| 5562 | 5564 | _ = try self.addInst(.{ |
| 5563 | 5565 | .tag = .mov_mem_imm, |
| ... | ... | @@ -7020,7 +7022,7 @@ fn truncateRegister(self: *Self, ty: Type, reg: Register) !void { |
| 7020 | 7022 | .unsigned => { |
| 7021 | 7023 | const shift = @intCast(u6, max_reg_bit_width - int_info.bits); |
| 7022 | 7024 | const mask = (~@as(u64, 0)) >> shift; |
| 7023 | | if (int_info.bits <= 32) { |
| 7025 | if (int_info.bits < 32) { |
| 7024 | 7026 | try self.genBinOpMir(.@"and", Type.usize, .{ .register = reg }, .{ .immediate = mask }); |
| 7025 | 7027 | } else { |
| 7026 | 7028 | const tmp_reg = try self.copyToTmpRegister(Type.usize, .{ .immediate = mask }); |