Web page for IU Compiler Course for Fall 2020
View the Project on GitHub IUCompilerCourse/IU-P423-P523-E313-E513-Fall-2020
Changes ProgramDefsExp
to ProgramDefs
by adding a definition for
the main
function.
Changes (Var f)
to (FunRef f)
when f
is the name of a function.
For functions with more than 6 parameters, reduce the number of parameters to 6 by packing parameter 6 and higher into a vector.
Def
pass parameter 6 and higher in a vectorVar
replace some parameters with vector-refsApply
and FunRef
are complex.
New auxiliary function rco-def
.
Add cases for Apply
and FunRef
.
New auxiliary function explicate-control-def
.
FunRef
to leaq
Call
move arguments into registers, indirect call, move rax to lhs
TailCall
move arguments into registers, TailJmp
(see functions_tests_21.rkt
)
Return
as usual, jump to conclusion
but need to
add function name to conclusion
label.
New auxiliary function select-instr-def
.
Def
remove parameters, initial them from registers
Add function name to start
label
Update free-vars
to handle FunRef
.
Update read-vars
and write-vars
to handle
IndirectCallq
, TailJmp
, and leaq
.
Callq
and IndirectCallq
, add edges between live vectors and
callee-saved registersNew auxiliary function allocate-registers-def
.
Def
Perform register allocation separately for each function definition.
Adapt the code for Program
in the past assignments.
leaq
destination in a register
TailJmp
target in rax
New auxiliary function patch-instr-def
.
FunRef
to PC-relative addressIndirectCallq
to callq *
TailJmp
insert conclusion
indirect jump
(see functions_tests_21.s
)
print-x86-def
, for Def
prelude:
.global
and .align
directives followed
by the label for the function.rbp
to the stack and set rbp
to current stack
pointer.rsp
down by the size of the stack
frame for this function, which depends on the number of regular
spills. (Aligned to 16 bytes.)r15
up by the size of the
root-stack frame for this function, which depends on the number of
spilled vectors.The prelude of the main
function has one additional task: call the
initialize
function to set up the garbage collector and move the
value of the global rootstack_begin
in r15
. This should happen
before step 5 above, which depends on r15
.
conclusion:
rbp
by popping it from the stack.retq
instruction.