Three Address code generator
- It is a step in intermediate code generation phase of the compiler
- The purpose of the ICG is to provide platform-independent representation of the SC
- Three address code is common form of intermediate representation.
- It allows for machine independent code optimization between high level and SC and lowlevel Machine code
- Optimizations can be applied without needing to know the specifics of the target machien
- Done by breaking down complex instructions and expressions into a sequence of elementary operations
- Each instruction of 3AC involves ATMOST 3 addresses
- two for operands and one for result
quadruples:
- each instruction is represented by 4 fields:
- an operator, two operands and one result field
Triplets:
- triplets are similar to quads but omit result field
- reduces compelexit
Indirect Triplets:
- use a list of pointers that point to the triplets.
- better because easier rearrangement of code during OPT as you only need to reaggange the pointers rather than the triplets themselves