May 2015
Intermediate to advanced
296 pages
5h 10m
English
Now, since the AST is ready with all the necessary information in its data structure, the next phase is to generate LLVM IR. LLVM APIs are used in this code generation. LLVM IR has a predefined format that is generated by the inbuilt APIs of LLVM.
You must have created the AST from any input code of the TOY language.
In order to generate LLVM IR, a virtual CodeGen function is defined in each AST class (the AST classes were defined earlier in the AST section; these functions are additional to those classes) as follows:
toy.cpp file as follows:$ vi toy.cpp
BaseAST class defined earlier, append the Codegen() functions as follows:class BaseAST { … … virtual ...Read now
Unlock full access