EECS 665 Compiler Construction 1
Concepts Introduced in Chapter 6
- types of intermediate code representations
- translation of
– declarations – arithmetic expressions – boolean expressions – flow-of-control statements
- backpatching
Concepts Introduced in Chapter 6 types of intermediate code - - PowerPoint PPT Presentation
Concepts Introduced in Chapter 6 types of intermediate code representations translation of declarations arithmetic expressions boolean expressions flow-of-control statements backpatching 1 EECS 665 Compiler Construction
EECS 665 Compiler Construction 1
– declarations – arithmetic expressions – boolean expressions – flow-of-control statements
EECS 665 Compiler Construction 2
EECS 665 Compiler Construction 3
– facilitates retargeting – allows a machine independent optimization pass to be
EECS 665 Compiler Construction 4
– nodes represent language constructs – children represent components of the construct
– represents each common subexpression only once in the
– helps compiler optimize the generated code
followed by Fig. 6.3, 6.4, 6.6
EECS 665 Compiler Construction 5
– general form: x = y op z (2 source, 1 destination) – widely used form of intermediate representation – Types of three-address code
– 0 operands (just an operator) – all operands are on a compiler-generated stack
followed by Fig. 6.8
EECS 665 Compiler Construction 6
– x := op y – where x := x op y is implied
– op x – where ac := ac op x is implied and ac is an accumulator
EECS 665 Compiler Construction 7
– has 4 fields, called op, arg1, arg2, and result – often used in compilers that perform global optimization
– easy to rearrange code since result names are explicit.
followed by Fig. 6.10
EECS 665 Compiler Construction 8
– similar to quadruples, but implicit results and temporary
– result of an operation is referred to by its position – triples avoid symbol table entries for temporaries, but
– indirect triples allow rearrangement of code since they
followed by Fig. 6.11, 6.12
EECS 665 Compiler Construction 9
– an increasing popular format in optimizing compilers – all assignments in SSA are to variables with a distinct
– see Figure 6.13
followed by Fig. 6.13
EECS 665 Compiler Construction 10
EECS 665 Compiler Construction 11
EECS 665 Compiler Construction 12
EECS 665 Compiler Construction 13
– determine the amount of storage (integer – 4 bytes,
– assign each variable a relative offset from the start of the
followed by Fig. 6.17, 6.15, 6.16
EECS 665 Compiler Construction 14
EECS 665 Compiler Construction 15
– ! – NOT (highest precedence) – && – AND (mid precedence, left associative) – || – OR (lowest precedence, left associative) – <, <=, >, >=, =, !=, are relational operators
– B1 || B2, if B1 true, then don't evaluate B2 – B1 && B2, if B1 false, then don't evaluate B2
followed by Fig. 6.37
EECS 665 Compiler Construction 16
– if statement – if statement else statement – while statement
followed by Fig. 6.35, 6.36
EECS 665 Compiler Construction 17
EECS 665 Compiler Construction 18
EECS 665 Compiler Construction 19
EECS 665 Compiler Construction 20
EECS 665 Compiler Construction 21
EECS 665 Compiler Construction 22
EECS 665 Compiler Construction 23
EECS 665 Compiler Construction 24
EECS 665 Compiler Construction 25
EECS 665 Compiler Construction 26
EECS 665 Compiler Construction 27
EECS 665 Compiler Construction 28
EECS 665 Compiler Construction 29
EECS 665 Compiler Construction 30
followed by Fig. 6.49, 6.50
EECS 665 Compiler Construction 31
– low=5, base=addr(A[5]), width=4
EECS 665 Compiler Construction 32
EECS 665 Compiler Construction 33
EECS 665 Compiler Construction 34
EECS 665 Compiler Construction 35
EECS 665 Compiler Construction 36
EECS 665 Compiler Construction 37
EECS 665 Compiler Construction 38
EECS 665 Compiler Construction 39
– boolean, char, integer, real in Pascal
– arrays, records, pointers, classes
EECS 665 Compiler Construction 40
EECS 665 Compiler Construction 41
EECS 665 Compiler Construction 42
– assign type expression to all source language
– determine conformance to the language type system
EECS 665 Compiler Construction 43
– build up type of expression from types of subexpressions
– determine type of a construct from the way it is used
EECS 665 Compiler Construction 44
EECS 665 Compiler Construction 45
EECS 665 Compiler Construction 46
– assignments – operands to arithmetic and logical operators – parameter passing – return values
EECS 665 Compiler Construction 47
– operators '+', '-' etc., are overloaded to work with
– function overloading resolved by looking at the
EECS 665 Compiler Construction 48
– function length can be called with different types of lists
– templates in C++
– using the object class in Java