1 / 17

Code Generation

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.

admon
Télécharger la présentation

Code Generation

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Code Generation Tiger Compiler Project By Mu Li

  2. Phases Li, Mu(limu.cn@gmail.com)

  3. Book chapter • Chapter 9-12 • Codes about chapter 8 are provided Li, Mu(limu.cn@gmail.com)

  4. 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)

  5. MIPSRegisters Li, Mu(limu.cn@gmail.com)

  6. Instruction selection Li, Mu(limu.cn@gmail.com)

  7. Package tiger.assem • Machine independent Li, Mu(limu.cn@gmail.com)

  8. Code Generation • Algorithm: Maximal Munch Li, Mu(limu.cn@gmail.com)

  9. Package tiger.mips • Codegen generates assemble codes from IR tree, which implements Maximal Munch Li, Mu(limu.cn@gmail.com)

  10. Liveness Analysis Li, Mu(limu.cn@gmail.com)

  11. Register Allocation • NP-hard • Using a simple greed algorithm to get proper solution • Spilling is optional Li, Mu(limu.cn@gmail.com)

  12. Packages Li, Mu(limu.cn@gmail.com)

  13. Implement steps • Construct AssemFlowGraph by InstrList • Liveness analysis • Generate InterferenceGraph • Coloring Li, Mu(limu.cn@gmail.com)

  14. Putting it all togerater • Add runtime.s at end of your codes Li, Mu(limu.cn@gmail.com)

  15. Interview • 1. 我发现你在XX包内写了一个YY变量,请问这个变量干什么用的? • 2(a) 如果我要增加一种ZZ语句,你打算? • 2(b) 请你说说你是怎么翻译initArray的? • 3(a) 杀手题…… • 3(b) 为什么你和张三的程序如此像? Li, Mu(limu.cn@gmail.com)

  16. Final submit • Deadline is 30th June • NO cheating! • ftp://compiler:compiler@202.120.61.1/Final/ Li, Mu(limu.cn@gmail.com)

  17. The end • Plz find out the comments written by Qian, Feng Li, Mu(limu.cn@gmail.com)

More Related