Docsity

Syntax Tree, Back End - Compiler Construction - Lecture Slides, Slides of Compiler Construction

Partial preview of the text

Download Syntax Tree, Back End - Compiler Construction - Lecture Slides and more Slides Compiler Construction in PDF only on Docsity!

Compiler

Construction

Lecture 3

2

Syntax Tree

x+2-y

goal

expr

expr op term

expr op term

term

  • (^) <id,y>

<id,x>

+ <number, 2>

4

Abstract Syntax Trees

 This is much more concise

<id,y>

<id,x> <number,2>

5

Abstract Syntax Trees

 AST summarizes grammatical

structure without the details of

derivation

<id,y>

<id,x> <number,2>

7

Instruction selection

IR (^) machine

code

errors

Register allocation

Instruction scheduling

IR IR

8

 Translate IR into target

machine code.

 Choose machine (assembly)

instructions to implement each

IR operation

10

Instruction Selection:

 Produce fast, compact code.

Instruction selection

IR (^) machine code

errors

Register allocation

Instruction scheduling

IR IR

11

Instruction Selection:

 Take advantage of target

features such as addressing modes.

Instruction selection

IR (^) machine code

errors

Register allocation

Instruction scheduling

IR IR

13

Instruction Selection:

 Spurred by PDP-11 to VAX-

  • CISC.

Instruction selection

IR (^) machine code

errors

Register allocation

Instruction scheduling

IR IR

14

Instruction Selection:

 RISC architecture simplified

this problem.

Instruction selection

IR (^) machine code

errors

Register allocation

Instruction scheduling

IR IR

16

Register Allocation:

 Manage a limited set of

resources – register file.

Instruction selection

IR (^) machine code

errors

Register allocation

Instruction scheduling

IR IR

17

Register Allocation:

 Can change instruction choices

and insert LOADs and STOREs.

Instruction selection

IR (^) machine code

errors

Register allocation

Instruction scheduling

IR IR

19

Instruction Scheduling:

 Avoid hardware stalls and

interlocks.

Instruction selection

IR (^) machine code

errors

Register allocation

Instruction scheduling

IR IR

20

Instruction Scheduling:

 Use all functional units

productively.

Instruction selection

IR (^) machine code

errors

Register allocation

Instruction scheduling

IR IR