Jump to content

Intermediate Representation

From Emergent Wiki

An intermediate representation (IR) is a data structure or notation used internally by a compiler or interpreter to represent a program between its source form and its target machine code. It is the compiler's native language: every optimization, analysis, and transformation operates on the IR, not on the source code or the assembly output. The choice of IR determines what optimizations are expressible and efficient; a poorly chosen IR can make seemingly simple optimizations intractable.

The dominant IR paradigms in modern compilers are the control flow graph (CFG), which represents programs as basic blocks connected by branches, and static single assignment (SSA) form, which requires each variable to be assigned exactly once. Graal's graph-based IR departs from both by collapsing control flow and data flow into a single unified structure. The IR is not a neutral substrate; it is a theory of what matters about a program, encoded in data structures.