code generation

Post on 02-Feb-2016

70 Views

Category:

Documents

0 Downloads

Preview:

Click to see full reader

DESCRIPTION

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. - PowerPoint PPT Presentation

TRANSCRIPT

Tiger Compiler Project

By Mu LiBy Mu Li

2007-6-6Li, Mu(limu.cn@gmail.com) 2

Chapter 9-12 Codes about chapter 8 are provided

2007-6-6Li, Mu(limu.cn@gmail.com) 3

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”

2007-6-6Li, Mu(limu.cn@gmail.com) 4

2007-6-6Li, Mu(limu.cn@gmail.com) 5

2007-6-6Li, Mu(limu.cn@gmail.com) 6

2007-6-6Li, Mu(limu.cn@gmail.com) 7

Machine independent

Algorithm: Maximal Munch

2007-6-6Li, Mu(limu.cn@gmail.com) 8

2007-6-6Li, Mu(limu.cn@gmail.com) 9

Codegen generates assemble codes from IR tree, which implements Maximal Munch

2007-6-6Li, Mu(limu.cn@gmail.com) 10

NP-hard Using a simple greed algorithm to get proper solution

Spilling is optional

2007-6-6Li, Mu(limu.cn@gmail.com) 11

2007-6-6Li, Mu(limu.cn@gmail.com) 12

Construct AssemFlowGraph by InstrList

Liveness analysis Generate InterferenceGraph Coloring

2007-6-6Li, Mu(limu.cn@gmail.com) 13

Add runtime.s at end of your codes

2007-6-6Li, Mu(limu.cn@gmail.com) 14

1. 我发现你在 XX包内写了一个 YY变量,请问这个变量干什么用的 ?

2(a) 如果我要增加一种 ZZ语句,你打算 ?

2(b) 请你说说你是怎么翻译 initArray的 ?

3(a) 杀手题…… 3(b) 为什么你和张三的程序如此像 ?

2007-6-6Li, Mu(limu.cn@gmail.com) 15

Deadline is 30th June NO cheating!

ftp://compiler:compiler@202.120.61.1/Final/

2007-6-6Li, Mu(limu.cn@gmail.com) 16

Plz find out the comments written by Qian, Feng

2007-6-6Li, Mu(limu.cn@gmail.com) 17

top related