| ... | @@ -1505,8 +1505,14 @@ fn Function(comptime arch: std.Target.Cpu.Arch) type { | ... | @@ -1505,8 +1505,14 @@ fn Function(comptime arch: std.Target.Cpu.Arch) type { |
| 1505 | /// ADD, SUB, XOR, OR, AND | 1505 | /// ADD, SUB, XOR, OR, AND |
| 1506 | fn genX8664BinMath(self: *Self, inst: *ir.Inst, op_lhs: *ir.Inst, op_rhs: *ir.Inst) !MCValue { | 1506 | fn genX8664BinMath(self: *Self, inst: *ir.Inst, op_lhs: *ir.Inst, op_rhs: *ir.Inst) !MCValue { |
| 1507 | // We'll handle these ops in two steps. | 1507 | // We'll handle these ops in two steps. |
| 1508 | // 1) Prepare an output register, and put one of the arguments in it | 1508 | // 1) Prepare an output location (register or memory) |
| | 1509 | // This location will be the location of the operand that dies (if one exists) |
| | 1510 | // or just a temporary register (if one doesn't exist) |
| 1509 | // 2) Perform the op with the other argument | 1511 | // 2) Perform the op with the other argument |
| | 1512 | // 3) Sometimes, the output location is memory but the op doesn't support it. |
| | 1513 | // In this case, copy that location to a register, then perform the op to that register instead. |
| | 1514 | // |
| | 1515 | // TODO: make this algorithm less bad |
| 1510 | | 1516 | |
| 1511 | try self.code.ensureCapacity(self.code.items.len + 8); | 1517 | try self.code.ensureCapacity(self.code.items.len + 8); |
| 1512 | | 1518 | |