Skip to content

Commit

Permalink
Merge pull request #9 from lambdaclass/progress
Browse files Browse the repository at this point in the history
structure
  • Loading branch information
edg-l authored Dec 9, 2024
2 parents 024c3ff + 3c4938f commit 7f6a40b
Show file tree
Hide file tree
Showing 12 changed files with 32 additions and 6 deletions.
9 changes: 8 additions & 1 deletion docs/src/SUMMARY.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,11 @@

- [Workshop Intro: About MLIR and LLVM](./about.md)
- [MLIR Basics](./mlir_basics.md)
- [Implementing the language: Part 1](./lang_1.md)
- [Workshop: Setup](./workshop_p1.md)
- [Workshop: Walk through the prepared codebase](./workshop_p2.md)
- [Workshop: Compiling Expressions](./workshop_p3.md)
- [Workshop: Compiling Let](./workshop_p4.md)
- [Workshop: Compiling Return](./workshop_p5.md)
- [Workshop: Compiling If/Else](./workshop_p6.md)
- [Workshop: Compiling Function calls](./workshop_p7.md)
- [Workshop: Extras](./workshop_p8.md)
4 changes: 2 additions & 2 deletions docs/src/about.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# About this Workshop

In this workshop you will learn a bit about what is LLVM and MLIR, by implementing a really simple programming language compiler. This language only has variables of type u64, and only supports simple functions with arguments, basic arithmetic operations and if else statements.
In this workshop you will learn a bit about what is LLVM and MLIR, by implementing a really simple programming language compiler. This language only has variables of type i64, and only supports simple functions with arguments, basic arithmetic operations and if else statements.

# What is LLVM?

Expand Down Expand Up @@ -127,7 +127,7 @@ In our case, we want to have a compiled program, so LLVM IR will be our target,

# Other Learning Resources

These are extra resources, they aren't meant to be read now in the workshop but they are here for your convenience.
> These are extra resources, they aren't meant to be read now in the workshop but they are here for your convenience.
Resources marked with **** are best.

Expand Down
8 changes: 6 additions & 2 deletions docs/src/lang_1.md → docs/src/workshop_p1.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Implementing the language: 1
# Workshop: Setup

## Project Setup

Expand All @@ -23,4 +23,8 @@ export LLVM_SYS_191_PREFIX="$(brew --prefix llvm@19)"
export TABLEGEN_190_PREFIX="$(brew --prefix llvm@19)"
```

TODO
Verify you can build the project:

```bash
cargo build
```
1 change: 1 addition & 0 deletions docs/src/workshop_p2.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
# Workshop: Walkthrough the prepared codebase
1 change: 1 addition & 0 deletions docs/src/workshop_p3.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
# Workshop: Compiling Expressions
1 change: 1 addition & 0 deletions docs/src/workshop_p4.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
# Workshop: Compiling Let
1 change: 1 addition & 0 deletions docs/src/workshop_p5.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
# Workshop: Compiling Return
1 change: 1 addition & 0 deletions docs/src/workshop_p6.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
# Workshop: Compiling If/Else
1 change: 1 addition & 0 deletions docs/src/workshop_p7.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
# Workshop: Compiling Function calls
1 change: 1 addition & 0 deletions docs/src/workshop_p8.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
# Workshop: Extras
2 changes: 1 addition & 1 deletion src/ast.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#[derive(Debug, Clone)]
pub enum Expr {
Number(i32),
Number(i64),
Variable(String),
Op(Box<Expr>, Opcode, Box<Expr>),
}
Expand Down
8 changes: 8 additions & 0 deletions src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,9 @@ use clap::Parser;
use codegen::{compile_program, ModuleCtx};
use lalrpop_util::lalrpop_mod;
use melior::{
dialect::DialectRegistry,
ir::{Location, Module},
utility::register_all_dialects,
Context,
};

Expand Down Expand Up @@ -38,7 +40,13 @@ fn main() {
let source = fs::read_to_string(&args.input).unwrap();
let program = grammar::ProgramParser::new().parse(&source).unwrap();

// We need a registry to hold all the dialects
let registry = DialectRegistry::new();
// Register all dialects that come with MLIR.
register_all_dialects(&registry);
let context = Context::new();
context.append_dialect_registry(&registry);
context.load_all_available_dialects();
let ctx = ModuleCtx {
ctx: &context,
module: Module::new(Location::unknown(&context)),
Expand Down

0 comments on commit 7f6a40b

Please sign in to comment.