Something went wrong. Try again.
🌱 A minimal programming language and compiler. git.urbach.dev/cli/q
high-performance programming-language compiler
Something went wrong. Try again.
12345678910111213141516171819202122232425262728293031323334353637package codegen
import ( "git.urbach.dev/cli/q/src/ssa")
// hintDestination recommends the destination register to its inputs.func (f *Function) hintDestination(step *Step) { if step.Register == -1 { return }
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) } case *ssa.UnaryOp: f.ValueToStep[instr.Operand].hint(step.Register) }}