180 likes | 318 Views
Code Generation. Tiger Compiler Project. By Mu Li. Phases. Book chapter. Chapter 9-12 Codes about chapter 8 are provided. MIPS. move sw, lw add, sub, mul, div and, or jal, j, beq, bne, bgt… li, la addi, subi, … (optional) more refer to “The MIPS Info Sheet”. MIPS Registers.
E N D
Code Generation Tiger Compiler Project By Mu Li
Phases Li, Mu(limu.cn@gmail.com)
Book chapter • Chapter 9-12 • Codes about chapter 8 are provided Li, Mu(limu.cn@gmail.com)
MIPS • move • sw, lw • add, sub, mul, div • and, or • jal, j, beq, bne, bgt… • li, la • addi, subi, … (optional) • more refer to “The MIPS Info Sheet” Li, Mu(limu.cn@gmail.com)
MIPSRegisters Li, Mu(limu.cn@gmail.com)
Instruction selection Li, Mu(limu.cn@gmail.com)
Package tiger.assem • Machine independent Li, Mu(limu.cn@gmail.com)
Code Generation • Algorithm: Maximal Munch Li, Mu(limu.cn@gmail.com)
Package tiger.mips • Codegen generates assemble codes from IR tree, which implements Maximal Munch Li, Mu(limu.cn@gmail.com)
Liveness Analysis Li, Mu(limu.cn@gmail.com)
Register Allocation • NP-hard • Using a simple greed algorithm to get proper solution • Spilling is optional Li, Mu(limu.cn@gmail.com)
Packages Li, Mu(limu.cn@gmail.com)
Implement steps • Construct AssemFlowGraph by InstrList • Liveness analysis • Generate InterferenceGraph • Coloring Li, Mu(limu.cn@gmail.com)
Putting it all togerater • Add runtime.s at end of your codes Li, Mu(limu.cn@gmail.com)
Interview • 1. 我发现你在XX包内写了一个YY变量,请问这个变量干什么用的? • 2(a) 如果我要增加一种ZZ语句,你打算? • 2(b) 请你说说你是怎么翻译initArray的? • 3(a) 杀手题…… • 3(b) 为什么你和张三的程序如此像? Li, Mu(limu.cn@gmail.com)
Final submit • Deadline is 30th June • NO cheating! • ftp://compiler:compiler@202.120.61.1/Final/ Li, Mu(limu.cn@gmail.com)
The end • Plz find out the comments written by Qian, Feng Li, Mu(limu.cn@gmail.com)