-
Notifications
You must be signed in to change notification settings - Fork 8
Expand file tree
/
Copy pathhintDestination.go
More file actions
31 lines (27 loc) · 837 Bytes
/
hintDestination.go
File metadata and controls
31 lines (27 loc) · 837 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
package codegen
import (
"git.urbach.dev/cli/q/src/ssa"
)
// hintDestination recommends the destination register to its inputs.
func (f *Function) hintDestination(step *Step) {
switch instr := step.Value.(type) {
case *ssa.BinaryOp:
if instr.Op.IsComparison() {
return
}
// For operations that allow reordering, reorder the operands
// so that the left operator matches the destination register.
f.reorderOperands(step, instr)
// For x86-64 it is advantageous to use the destination register
// as the register for the left operand.
f.ValueToStep[instr.Left].hint(step.Register)
case *ssa.Copy:
f.ValueToStep[instr.Value].hint(step.Register)
case *ssa.Phi:
for variant := range instr.DefinedArguments {
variant := f.ValueToStep[variant]
variant.Phis.Add(step)
variant.hint(step.Register)
}
}
}