Intermediate Representation

Creator
Creator
Seonglae ChoSeonglae Cho
Created
Created
2021 May 5 16:0
Editor
Edited
Edited
2025 Oct 22 23:58
Refs
Refs

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

  1. 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
  1. Stack-machine code typeExamples include:
      • U-Code
      • P-code
      • JVM Byte Code
Intermediate Representation Notion
 
 
 
 
 
 

Recommendations