This is a toy programming language and its compiler made with LLVM and C++. I have implemented all of the frontend components the language needs:
- Lexing
- Abstract Syntax Tree (AST)
- Parsing
Along with the code the generation to generate the LLVM IR (LLVM Intermediate Representation). Also I added a JIT Driver so I can see the IR generated, and the evaluated results.
And Finally I Added additional Optimizers to the compiler such as:
- Constant Folding & Constant Propagation
- Common Subexpression Elimination
- Peephole Optimization
- Dead-Code Elimination
This screenshot shows the corresponding LLVM IR for the function I defined, the function basically computes
This screenshot shows the IR for the same function definition from earlier after I added the Common Subexpression Elimination optimization:
This is just something I made to teach myself more about compilers in general and the LLVM compiler infrastructure in particular, so I didn't follow software engineering best practices and its not production ready.