Commit ee6e9b3c48

Jakub Konka <kubkon@jakubkonka.com>
2022-01-05 23:40:53
stage2: fix airStructFieldPtr and airStructFieldVal
This finally fixes `zig test`.
1 parent b215241
Changed files (1)
src
arch
src/arch/x86_64/CodeGen.zig
@@ -1699,7 +1699,7 @@ fn structFieldPtr(self: *Self, inst: Air.Inst.Index, operand: Air.Inst.Ref, inde
 
         switch (mcv) {
             .ptr_stack_offset => |off| {
-                const ptr_stack_offset = off - struct_size + struct_field_offset + struct_field_size;
+                const ptr_stack_offset = off + struct_size - struct_field_offset - struct_field_size;
                 break :result MCValue{ .ptr_stack_offset = ptr_stack_offset };
             },
             else => return self.fail("TODO implement codegen struct_field_ptr for {}", .{mcv}),
@@ -1722,7 +1722,7 @@ fn airStructFieldVal(self: *Self, inst: Air.Inst.Index) !void {
 
         switch (mcv) {
             .stack_offset => |off| {
-                const stack_offset = off - struct_size + struct_field_offset + struct_field_size;
+                const stack_offset = off + struct_size - struct_field_offset - struct_field_size;
                 break :result MCValue{ .stack_offset = stack_offset };
             },
             else => return self.fail("TODO implement codegen struct_field_val for {}", .{mcv}),