From 6adea3a38ff3bf0eca805555ae72eb11acc78966 Mon Sep 17 00:00:00 2001 From: Edgar Luque Date: Mon, 9 Dec 2024 19:03:11 -0300 Subject: [PATCH] makefile --- .gitignore | 2 ++ Makefile | 9 +++++++++ docs/src/workshop_p1.md | 13 ++++++++++++- env.sh | 3 +++ src/codegen/ifelse_stmt.rs | 9 +++------ src/codegen/let_stmt.rs | 2 +- src/main.rs | 6 +++--- 7 files changed, 33 insertions(+), 11 deletions(-) create mode 100644 Makefile create mode 100644 env.sh diff --git a/.gitignore b/.gitignore index ea8c4bf..90fe663 100644 --- a/.gitignore +++ b/.gitignore @@ -1 +1,3 @@ /target + +out.a diff --git a/Makefile b/Makefile new file mode 100644 index 0000000..26e363a --- /dev/null +++ b/Makefile @@ -0,0 +1,9 @@ +.PHONY: deps +deps: + brew install -q llvm@19 + +build: + cargo build + +run: + cargo run -- test.prog -o out.a diff --git a/docs/src/workshop_p1.md b/docs/src/workshop_p1.md index 03735b3..41f6889 100644 --- a/docs/src/workshop_p1.md +++ b/docs/src/workshop_p1.md @@ -2,10 +2,21 @@ ## Project Setup -### Dependencies +### Easy way + +```bash +git clone https://github.com/lambdaclass/mlir-workshop +cd mlir-workshop +make deps +source env.sh +make build +``` + +### Dependencies (manual way) - Rust - LLVM and MLIR + To install LLVM and MLIR you can do so through brew: `brew install llvm@19` (This workshop uses LLVM/MLIR 19) diff --git a/env.sh b/env.sh new file mode 100644 index 0000000..7ddbf3d --- /dev/null +++ b/env.sh @@ -0,0 +1,3 @@ +export MLIR_SYS_190_PREFIX="$(brew --prefix llvm@19)" +export LLVM_SYS_191_PREFIX="$(brew --prefix llvm@19)" +export TABLEGEN_190_PREFIX="$(brew --prefix llvm@19)" diff --git a/src/codegen/ifelse_stmt.rs b/src/codegen/ifelse_stmt.rs index ab3771a..b1af956 100644 --- a/src/codegen/ifelse_stmt.rs +++ b/src/codegen/ifelse_stmt.rs @@ -1,13 +1,10 @@ -use std::{collections::HashMap, ops::Deref}; +use std::collections::HashMap; -use melior::{ - dialect::scf, - ir::{Block, BlockRef, Region, Value}, -}; +use melior::ir::{Block, Value}; use crate::ast::IfStmt; -use super::{expressions::compile_expr, ModuleCtx}; +use super::ModuleCtx; pub fn compile_if<'ctx, 'parent>( ctx: &ModuleCtx<'ctx>, diff --git a/src/codegen/let_stmt.rs b/src/codegen/let_stmt.rs index a2a2f37..b18b03a 100644 --- a/src/codegen/let_stmt.rs +++ b/src/codegen/let_stmt.rs @@ -4,7 +4,7 @@ use melior::ir::{Block, Value}; use crate::ast::LetStmt; -use super::{expressions::compile_expr, ModuleCtx}; +use super::ModuleCtx; pub fn compile_let<'ctx: 'parent, 'parent>( ctx: &ModuleCtx<'ctx>, diff --git a/src/main.rs b/src/main.rs index 7e900e9..365b84d 100644 --- a/src/main.rs +++ b/src/main.rs @@ -31,8 +31,8 @@ struct Args { output: PathBuf, /// Number of times to greet - #[arg(short, long, default_value_t = 3)] - optlevel: u8, + #[arg(long, default_value_t = 3)] + opt_level: u8, } fn main() { @@ -54,5 +54,5 @@ fn main() { module: &module, }; - compile_program(&ctx, &program, args.optlevel.into(), &args.output); + compile_program(&ctx, &program, args.opt_level.into(), &args.output); }