23-01-2013, 12:07 PM
Intermediate Code Generation
Intermediate Code.ppt (Size: 665 KB / Downloads: 24)
Intermediate Representations
Graphical representations (e.g. AST)
Postfix notation: operations on values stored on operand stack (similar to JVM bytecode)
Three-address code: (e.g. triples and quads) x := y op z
Two-address code: x := op ywhich is the same as x := x op y
The postfix notation
If E is a variable or constant, then the postfix notation for E is E itself
If E is an expression of the form E1 op E2 then postfix notation for E is E1’ E2’ op, here E1’ and E2’ are the postfix notations for E1and E2, respectively
the form (E), then the postfix notation for E is the same as the postfix notation for E.
For unary operation –E the postfix is E-
postfix notation for 9- (5+2) is 952+-
Directed Acyclic Graphs for Expressions
DAG has leaves corresponding to atomic operands and interior codes corresponding to operators
Difference is that a node N in a DAG has more than one parent if N