# stage2,x86_64: fix genBinMathOp and clarify callee-saved regs · gitcafe/zig

[View on GitCafe](https://git.cafe/gitcafe/zig/commit/bc59a630ab7814ac0ca5487c780a03d7492648f7)

Repository: [gitcafe/zig](https://git.cafe/gitcafe/zig)

Visibility: public

Requested revision: bc59a630ab7814ac0ca5487c780a03d7492648f7

Requested commit: bc59a630ab7814ac0ca5487c780a03d7492648f7

Commit: bc59a630ab7814ac0ca5487c780a03d7492648f7

Tree: 7a998dd9f553f346636fb1103fd38627bdeab328

Author: Jakub Konka

Committer: Jakub Konka

## Message

```
stage2,x86_64: fix genBinMathOp and clarify callee-saved regs

Previously, we have confused callee-saved with caller-saved registers
(the actual register sets were swapped). This commit fixes that
for both `.x86` and `.x86_64` native backends.

This commit also fixes the register allocation logic in `genBinMathOp`
for `.x86_64` native backend where in a situation such that we require
to spill a register, we would end up spilling the register that is
already involved in the instruction as the other operand. In such a
case, we make a note of this and spill a subsequent register instead.

```

## Parents

- [149bc79486907745c8ffb12a69f65189b26c6dbe](https://git.cafe/gitcafe/zig/commit/149bc79486907745c8ffb12a69f65189b26c6dbe?format=markdown)

[Source at this commit](https://git.cafe/gitcafe/zig/tree/bc59a630ab7814ac0ca5487c780a03d7492648f7?format=markdown)
