IR -> IR Optimization -> Code Generation(Register allocation/Instruction selection) Assembly
1.top-of-stack caching (1-TOSCA)
2.init garbage collector
1.similar to C++ inheritance
2.gc in COOL runtime
3.Class Tag, Object Size, Dispatch table pointer (similar to C++ vptr), Dispatch table (similar to C++ vtable)
4.register allocation is Graph coloring
(Linear-Scan Register Allocation
is another way to allocate registers)
1.Three-address code (it doesn't be implemented in this course)
1.it contains a concurrent garbage collector
2.the management of application memory
3.how the program accesses variables, mechanisms for passing parameters between procedures
4.interfacing with the operating system
5.The compiler makes assumptions depending on the specific runtime system to generate correct code.
gc is also part of the program
1.gc in runtime
2.how gc works
3.stack-based virtual machine -> register-based virtual machine (?
4.code generation
4-1. stack based machine
4-2. register based machine
-> register allocation and assignment
-> instruction selection/instruction scheduling
5. how to verify and test compiler?
mips note
.align
3
=> that's pow(2,3
) = 8 bytes, which means align multiple of 81.Records the cause of the exception
2.Jumps to the exception handler at instruction address
0x80000180
3.Returns to program
lb/lbu (load a byte signed/load a byte unsigned)
e.g. t1 其值為
0x56FE
,則0(t1) =>
0xFE
(-2或254如果是非符號數)1(t2) =>
0x56
(96 signed/unsigned)The MIPS calling convention
$v
registers are for function returns$a
registers are for function arguments$t
variables are temporary caller saved registers$s
registers are callee savedcaller-saved vs. callee-saved
Caller-save: If necessary… ($t0 .. $t9)
• save before calling anything; restore after it returns
Callee-save: Always… ($s0 .. $s7)
• save before modifying; restore before returning
Caller-save registers are responsibility of the caller
• Caller-save register values saved only if used after call/return
• The callee function can use caller-saved registers
Callee-save register are the responsibility of the callee
• Values must be saved by callee before they can be used
• Caller can assume that these registers will be restored
Source: Calling Conventions
nor a b c
=> a = not (a or b)execute mips online
i can modify register values
It executes line by line even it has
label
or.global
(unlessjump
)