Intermediate Representation (IR)
An intermediate representation is an internal code representation used by compilers to maintain independence between source languages and target machines. The compiler's front-end translates the source program into code that the back-end can understand, while the back-end converts this code into machine-appropriate instructions. This intermediate code serves as the bridge between these two phases and is essential for implementing compiler optimizations.
Types of IR
- Three-address codeA format that specifies two input memory addresses or registers and one output address. This is why it's called "three-address code."
- Operators use at most three addresses
- Introduces temporary variables (interior nodes in AST)
- Can be represented as quadruple: an array or linked list of 4-tuple structures
- Can be represented as triple: operations implicitly define temporary variables
- Stack-machine code typeExamples include:
- U-Code
- P-code
- JVM Byte Code
Intermediate Representation Notion

Seonglae Cho