. Medium level IR
- reflects range of features in a set of source languages
- language independent
- good for code generation for a number of architectures
- appropriate for most of the optimizations
- normally three address code
. Low level IR
- corresponds one to one to target machine instructions
- architecture dependent
. Multi-level IR
- has features of MIR and LIR
- may also have some features of HIR
MIR
Many optimizations are based on this level of representation. It is characterized by the following:
. Source-language and target-machine independent: this is the commonly claimed advantage of MIR.
. Machine independent representation for program variables and temporaries.
. Simplified control flow construct.
. Portable (immediate outcome of source and target independence). Hence, good for code generation for a number of architectures.
. Sufficient in many optimizing compilers: MIR, Sun-IR, etc.
LIR
Key characteristics:
. One-to-one correspondence with machine instructions (this is not 100% accurate, but is a major design issue).
. Deviations from machine language: alternative code for non-primitive operations (e.g., MULTIPLY); addressing modes; side effects (e.g., auto-increment by the machine that is not suitably represented).
. It is machine dependant. However, appropriate compiler data structures can hide machine dependence, for example: register allocation can be kept for the very last phase, thus we can still use symbolic register.
Multi-level IR
Key characteristics:
. Combining multiple representations levels in the same language: this way we hope to benefit from the advantages of some IRs for different optimization needs.
. Compromise computation exposure and high-level description (clearly, since we take some from high and low levels).
. Examples: in SUN-IR arrays can be represented with multiple subscripts; in SLLIC, MULTIPLY and DIVIDE operations exist.
|