May 2015
Intermediate to advanced
296 pages
5h 10m
English
In this recipe, you will see how IR code gets generated for an expression using the compiler frontend.
To implement LLVM IR code generation for our TOY language, proceed with the following code flow:
toy.cpp file as follows:$ vi toy.cpp
Value *NumericAST::Codegen() {
return ConstantInt::get(Type::getInt32Ty(getGlobalContext()), numeric_val);
}In LLVM IR, integer constants are represented by the ConstantInt class whose numeric value is held by the APInt class.
Value *VariableAST::Codegen() { Value *V = Named_Values[Var_Name]; return V ? ...Read now
Unlock full access