Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/lucaanza/myfirstllvm_compiler

Creating a Compiler for the Kaleidoscope Programming Language using LLVM16.
https://github.com/lucaanza/myfirstllvm_compiler

bison compiler flex kaleidoscope llvm

Last synced: 29 days ago
JSON representation

Creating a Compiler for the Kaleidoscope Programming Language using LLVM16.

Awesome Lists containing this project

README

        

# My First LLVM Compiler

In this repository you can find the implementation of a compiler.

The compiler is divided into Front-End and Middle-End.

The Back-End part is not implemented đŸšĢ

## Introduction

### What is the purpose of a compiler?

A compiler translates code written in a high-level programming language into machine code that a computer can understand. In more detail, a compiler is a special type of software that serves as a translator between the programmer and the computer.

### Anatomy of a compiler




### Compiler toolchain


## Dependencies ⚙ī¸
The Front-End and Middle-End have different versions of LLVM and different dependencies.

- Each project directory contains a README.md file that specifies the requirements.


## Middle-end 📁

In this directory you can find some optimizations on IR Code.

Each optimization is made modifying LLVM source code or creating a new pass.


_middle-end function:_

---

### Which optimizations or analysis?

#### Assignment1(optimization-LLVM)

- Algebric Identity.
- Strengh Reduction.
- Multi Instructions opt.

#### Assignment2(analiysis)

->Data Flow Analysis on three different case:

- Constant Propagation.
- Dominator Analysis.
- Very Busy Expressions.

#### Assignment3(optimization-LLVM)

- LICM (Loop Invariant Code Motion).

#### Assignment4(optimization-LLVM)

- LI (Loop Fusion).



## Front-End 📁

Given the following compilation stages:

fasi

In this part of the project, we will analyze and produce a working example of the first 4 phases (Front-End).
The phases are as follows:

1. Lexical analyzer.
2. Syntax analyzer.
3. Semantic analyzer.
4. Intermediate code generator.


Front-End structure

explain img

- Lexer is implemented using [Flex](https://github.com/westes/flex) (open source tool)
- Parser is implemented using [Bison](https://www.gnu.org/software/bison/) (open source tool)
- Code generator is implemented in a file .cpp called `driver.cpp`.



ℹī¸ More details of the programming language implemented is on `/Front-End/Progetto_finale/`