Docsity

Compiler Construction: Syntax Trees and the Back End, Cheat Sheet of Compiler Construction

Partial preview of the text

Download Compiler Construction: Syntax Trees and the Back End and more Cheat Sheet Compiler Construction in PDF only on Docsity!

Compiler

Construction

Lecture 3

Syntax Tree

x+2-y goal expr op^ term expr expr op term term

  • <id,y> <id,x> + <number, 2>

Abstract Syntax Trees

  • (^) This is much more concise

     <id,y> 

<id,x> <number,2> +

Abstract Syntax Trees

  • (^) AST summarizes grammatical structure without the details of derivation - <id,y> <id,x> <number,2> +

Instruction selection IR (^) machine code errors Register allocation Instruction scheduling

IR IR

  • (^) Translate IR into target machine code.
  • (^) Choose machine (assembly) instructions to implement each IR operation

Instruction Selection:

  • Produce fast, compact code. Instruction selection IR (^) machine code errors Register allocation Instruction scheduling

IR IR

Instruction Selection:

  • (^) Take advantage of target features such as addressing modes. Instruction selection IR (^) machine code errors Register allocation Instruction scheduling

IR IR

Instruction Selection:

  • Spurred by PDP-11 to VAX-11 - CISC. Instruction selection IR (^) machine code errors Register allocation Instruction scheduling

IR IR

Instruction Selection:

  • RISC architecture simplified this problem. Instruction selection IR (^) machine code errors Register allocation Instruction scheduling

IR IR

Register Allocation:

  • Manage a limited set of resources
    • register file. Instruction selection IR (^) machine code errors Register allocation Instruction scheduling

IR IR

Register Allocation:

  • (^) Can change instruction choices and insert LOADs and STOREs. Instruction selection IR (^) machine code errors Register allocation Instruction scheduling

IR IR

Instruction Scheduling:

  • Avoid hardware stalls and interlocks. Instruction selection IR (^) machine code errors Register allocation Instruction scheduling

IR IR

Instruction Scheduling:

  • Use all functional units productively. Instruction selection IR (^) machine code errors Register allocation Instruction scheduling

IR IR