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.
123456789101112131415161718192021222324252627282930313233343536373839package codegen
import ( "slices"
"git.urbach.dev/cli/q/src/config" "git.urbach.dev/cli/q/src/ssa")
// CompileToAssembly converts the SSA IR to assembler instructions.func (f *Function) CompileToAssembly(ir ssa.IR, build *config.Build, hasStackFrame bool, hasExternCalls bool) { f.hasStackFrame = hasStackFrame f.hasExternCalls = hasExternCalls f.needsFramePointer = (hasStackFrame || hasExternCalls) && !f.IsExit f.arch = newArch(build) f.IR = createSteps(ir)
for _, step := range slices.Backward(f.Steps) { f.hintABI(step) f.createLiveRanges(step) }
for _, step := range slices.Backward(f.Steps) { if step.Register == -1 && f.needsRegister(step) { f.assignFreeRegister(step) }
f.hintDestination(step) }
f.reorderParameters() f.fixRegisterConflicts() f.addPreservedRegisters() f.enter()
for _, step := range f.Steps { f.execute(step) }}