EECS 665 Compiler Construction 1
EECS 665 – Introduction
Background and Future Concepts Introduced in Chapter 1
– Phases – Compiler Construction Tools – Front Ends and Back Ends – Analysis-Synthesis Model – Assemblers – Linkers and Loaders
EECS 665 Introduction Background and Future Concepts Introduced in - - PowerPoint PPT Presentation
EECS 665 Introduction Background and Future Concepts Introduced in Chapter 1 Phases Compiler Construction Tools Front Ends and Back Ends Analysis-Synthesis Model Assemblers Linkers and Loaders 1 EECS 665
EECS 665 Compiler Construction 1
Background and Future Concepts Introduced in Chapter 1
– Phases – Compiler Construction Tools – Front Ends and Back Ends – Analysis-Synthesis Model – Assemblers – Linkers and Loaders
EECS 665 Compiler Construction 2
EECS 665 Compiler Construction 3
– Most programming in assembly language
– Grace Hopper writes first compiler for the A-0
– John Backus and team writes first Fortran compiler – Optimization was an integral component of the
EECS 665 Compiler Construction 4
– Teaches us a lot about how to handle complex
– Performance of generated code still important – Applications of compilers in security, safety, trust-
– Multicore
EECS 665 Compiler Construction 5
EECS 665 Compiler Construction 6
skeletal source program source program target assembly program relocatable machine code absolute machine code library, relocatable object files
EECS 665 Compiler Construction 7
– Interpreters – Structure Editors – Pretty Printers – Static Checkers – Debuggers
– Text Formatters – Silicon Compilers – Query Interpreters
EECS 665 Compiler Construction 8
source program target program
input
input source program
EECS 665 Compiler Construction 9
EECS 665 Compiler Construction 10
source program target program
EECS 665 Compiler Construction 11
– Scanner Generators: Lex – Parser Generators: Yacc – Syntax-Directed Translation Engines
– Automatic Code Generators – Peephole Optimizer Construction Tools
EECS 665 Compiler Construction 12
EECS 665 Compiler Construction 13
– Breaks up the source program into pieces and creates
– Constructs a target program from the intermediate
EECS 665 Compiler Construction 14
– Read a stream of characters and group into tokens.
– Group tokens into hierarchical structures.
– Perform certain checks to ensure that the program
EECS 665 Compiler Construction 15
EECS 665 Compiler Construction 16
EECS 665 Compiler Construction 17
– Consistent use of types. – Variables declared before referenced.
EECS 665 Compiler Construction 18
– machine-independent – easy to translate to the target machine language
EECS 665 Compiler Construction 19
– Make program run faster. – Make program take up less space. – Make program use less power.
EECS 665 Compiler Construction 20
EECS 665 Compiler Construction 21
position = initial + rate * 60
id1 = id2 + id3 * 60
= id1 + id2 * id3 60
= id1 + id2 * id3 60 inttoreal
temp1 = inttoreal(60) temp2 = id3 * temp1 temp3 = id2 + temp2 id1 = temp3
temp1 = id3 * 60.0 id1 = id2 + temp1
MOVF id3, R2 MULF #60.0, R2 MOVF id2, R1 ADDF R2, R1 MOVF R1, id1 position ... initial ... rate ...
symbol table
EECS 665 Compiler Construction 22
– definitions and macros
– file inclusion
– conditional compilation
– line numbering
EECS 665 Compiler Construction 23
– Pass 1: Stores all of the identifiers representing tokens
– Pass 2: Translates the instructions and data into bits for
EECS 665 Compiler Construction 24
– Produces an executable file. – Resolves external references. – Includes appropriate libraries.
– Creates a process from the executable. – Loads the process (or a portion of it) into main
– Produces absolute machine code.