With the addition of arrays and records to the code generator, you can note that sometimes, the generated code does…

The getelementptr instruction is the workhorse for address calculations. As such, it needs some more explanation. The first operand, [8…

For almost all applications, basic types such as INTEGER are not sufficient. For example, to represent mathematical objects such as…

High-level languages today usually make use of aggregate data types and object-oriented programming (OOP) constructs. LLVM IR has some support…

With all this preparation done, emitting the file boils down to a single function call: PM.run(*M); The ToolOutputFile class automatically…

The IR module is the brace around all elements we generate for a compilation unit. At the global level, we…

How can we optimize a phi instruction and why should we do it? Although the SSA form is advantageous for…

If the current basic block we are looking at has only one predecessor, then we search there for the value…

To generate IR code in SSA form from the AST, we can use an approach called AST numbering. The basic…

The conceptual idea of a basic block is that it is a linear sequence of instructions that are executed in…