authorgravatar for kubkon@jakubkonka.comJakub Konka <kubkon@jakubkonka.com> 2022-03-24 16:38:04+01:00
committergravatar for kubkon@jakubkonka.comJakub Konka <kubkon@jakubkonka.com> 2022-03-24 17:02:29+01:00
log9d2ff7ed161ff0880818002fb75391be336b44ac
tree758f51a4bc527ab90589bd6efc802fc8e0c8d1e1
parent77352c5bea7e328006394b93bc239c3e34b464c9

x64: fix struct_field_val for structs fitting in register


1 files changed, 5 insertions(+), 1 deletions(-)

src/arch/x86_64/CodeGen.zig+5-1
...@@ -2884,6 +2884,8 @@ fn airStructFieldVal(self: *Self, inst: Air.Inst.Index) !void {...@@ -2884,6 +2884,8 @@ fn airStructFieldVal(self: *Self, inst: Air.Inst.Index) !void {
2884 break :blk dst_mcv;2884 break :blk dst_mcv;
2885 }2885 }
2886 };2886 };
2887 dst_mcv.freezeIfRegister(&self.register_manager);
2888 defer dst_mcv.unfreezeIfRegister(&self.register_manager);
28872889
2888 // Shift by struct_field_offset.2890 // Shift by struct_field_offset.
2889 const shift = @intCast(u8, struct_field_offset * @sizeOf(usize));2891 const shift = @intCast(u8, struct_field_offset * @sizeOf(usize));
...@@ -2893,7 +2895,9 @@ fn airStructFieldVal(self: *Self, inst: Air.Inst.Index) !void {...@@ -2893,7 +2895,9 @@ fn airStructFieldVal(self: *Self, inst: Air.Inst.Index) !void {
2893 const max_reg_bit_width = Register.rax.size();2895 const max_reg_bit_width = Register.rax.size();
2894 const mask_shift = @intCast(u6, (max_reg_bit_width - struct_field_ty.bitSize(self.target.*)));2896 const mask_shift = @intCast(u6, (max_reg_bit_width - struct_field_ty.bitSize(self.target.*)));
2895 const mask = (~@as(u64, 0)) >> mask_shift;2897 const mask = (~@as(u64, 0)) >> mask_shift;
2896 try self.genBinMathOpMir(.@"and", Type.usize, dst_mcv, .{ .immediate = mask });2898
2899 const tmp_reg = try self.copyToTmpRegister(Type.usize, .{ .immediate = mask });
2900 try self.genBinMathOpMir(.@"and", Type.usize, dst_mcv, .{ .register = tmp_reg });
28972901
2898 break :result dst_mcv;2902 break :result dst_mcv;
2899 },2903 },