To set multiple attributes, you can use the llvm::AttrBuilder class. The other way to provide additional information is to use…

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…

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…

In general, you translate expressions, as shown in Chapter 2, The Structure of a Compiler. The only interesting part is…

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…