This commit is contained in:
Edgar 2024-02-09 09:06:20 +01:00
parent 0d7ab09531
commit 49a48995d5
No known key found for this signature in database
GPG key ID: 70ADAE8F35904387
10 changed files with 9 additions and 49 deletions

4
Cargo.lock generated
View file

@ -325,7 +325,7 @@ dependencies = [
]
[[package]]
name = "edlang_codegen_mlir"
name = "edlang_codegen_llvm"
version = "0.1.0"
dependencies = [
"bumpalo",
@ -348,7 +348,7 @@ dependencies = [
"color-eyre",
"edlang_ast",
"edlang_check",
"edlang_codegen_mlir",
"edlang_codegen_llvm",
"edlang_ir",
"edlang_lowering",
"edlang_parser",

View file

@ -1,7 +1,7 @@
[workspace]
resolver = "2"
members = [ "bin/edlang", "lib/edlang_ast", "lib/edlang_check", "lib/edlang_codegen_mlir", "lib/edlang_driver", "lib/edlang_ir", "lib/edlang_lowering","lib/edlang_parser", "lib/edlang_session", "lib/edlang_span"]
members = [ "bin/edlang", "lib/edlang_ast", "lib/edlang_check", "lib/edlang_codegen_llvm", "lib/edlang_driver", "lib/edlang_ir", "lib/edlang_lowering","lib/edlang_parser", "lib/edlang_session", "lib/edlang_span"]
[profile.release]
lto = true

View file

@ -1,8 +1,8 @@
[package]
name = "edlang_codegen_mlir"
name = "edlang_codegen_llvm"
version = "0.1.0"
authors = ["Edgar Luque <edgar@edgarluque.com>"]
description = "edlang MLIR codegen"
description = "edlang LLVM codegen"
edition = "2021"
keywords = ["llvm", "compiler"]
license = "AGPL-3.0-only"

View file

@ -8,8 +8,7 @@ use inkwell::{
builder::{Builder, BuilderError},
context::Context,
debug_info::{
AsDIScope, DICompileUnit, DIFile, DIFlagsConstants, DILexicalBlock, DILocation, DIScope,
DISubprogram, DIType, DebugInfoBuilder,
AsDIScope, DICompileUnit, DIFlagsConstants, DILocation, DIScope, DIType, DebugInfoBuilder,
},
module::Module,
targets::{InitializationConfig, Target, TargetData, TargetMachine},

View file

@ -1,16 +0,0 @@
use std::env::var;
fn main() {
let mlir_path = var("MLIR_SYS_170_PREFIX").expect("MLIR path should be set.");
cc::Build::new()
.cpp(true)
.flag("-std=c++17")
.flag_if_supported("-Wno-unused-parameter")
.flag_if_supported("-Wno-comment")
.include(&format!("{mlir_path}/include"))
.file("src/wrappers.cpp")
.compile("ffi");
println!("cargo:rerun-if-changed=src/wrappers.cpp");
}

View file

@ -1,23 +0,0 @@
#include <llvm-c/Support.h>
#include <llvm/IR/LLVMContext.h>
#include <llvm/IR/Module.h>
#include <mlir/CAPI/IR.h>
#include <mlir/CAPI/Support.h>
#include <mlir/CAPI/Wrap.h>
#include <mlir/Dialect/LLVMIR/LLVMTypes.h>
#include <mlir/IR/Types.h>
#include <mlir/Target/LLVMIR/ModuleTranslation.h>
extern "C" LLVMModuleRef mlirTranslateModuleToLLVMIR(MlirOperation module,
LLVMContextRef context) {
mlir::Operation *moduleOp = unwrap(module);
llvm::LLVMContext *ctx = llvm::unwrap(context);
std::unique_ptr<llvm::Module> llvmModule = mlir::translateModuleToLLVMIR(
moduleOp, *ctx);
LLVMModuleRef moduleRef = llvm::wrap(llvmModule.release());
return moduleRef;
}

View file

@ -16,7 +16,7 @@ clap = { version = "4.4.16", features = ["derive"] }
color-eyre = "0.6.2"
edlang_ast = { version = "0.1.0", path = "../edlang_ast" }
edlang_check = { version = "0.1.0", path = "../edlang_check" }
edlang_codegen_mlir = { version = "0.1.0", path = "../edlang_codegen_mlir" }
edlang_codegen_llvm = { version = "0.1.0", path = "../edlang_codegen_llvm" }
edlang_ir = { version = "0.1.0", path = "../edlang_ir" }
edlang_lowering = { version = "0.1.0", path = "../edlang_lowering" }
edlang_parser = { version = "0.1.0", path = "../edlang_parser" }

View file

@ -2,7 +2,7 @@ use std::{error::Error, path::PathBuf, time::Instant};
use ariadne::Source;
use clap::Parser;
use edlang_codegen_mlir::linker::{link_binary, link_shared_lib};
use edlang_codegen_llvm::linker::{link_binary, link_shared_lib};
use edlang_lowering::lower_modules;
use edlang_session::{DebugInfo, OptLevel, Session};
@ -95,7 +95,7 @@ pub fn main() -> Result<(), Box<dyn Error>> {
return Ok(());
}
let object_path = edlang_codegen_mlir::compile(&session, &program_ir)?;
let object_path = edlang_codegen_llvm::compile(&session, &program_ir)?;
if session.library {
link_shared_lib(&object_path, &session.output_file.with_extension("so"))?;