-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Use
Identifier
as key to AttributeDict
Also move `ConstantOp` to the LLVM, and test dialects separately.
- Loading branch information
1 parent
f1f70b0
commit 9c14df9
Showing
16 changed files
with
629 additions
and
369 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,53 @@ | ||
use pliron::result::Result; | ||
use std::{path::PathBuf, process::ExitCode}; | ||
|
||
pub fn main() -> Result<()> { | ||
todo!() | ||
use inkwell::{context::Context as IWContext, module::Module as IWModule}; | ||
|
||
use clap::Parser; | ||
use pliron::{arg_error_noloc, context::Context, printable::Printable, result::Result}; | ||
use pliron_llvm::from_inkwell; | ||
|
||
#[derive(Parser)] | ||
#[command(version, about="LLVM Optimizer", long_about = None)] | ||
struct Cli { | ||
/// Input LLVM file | ||
#[arg(short, value_name = "FILE")] | ||
input: PathBuf, | ||
|
||
/// Output LLVM file | ||
#[arg(short, value_name = "FILE")] | ||
output: PathBuf, | ||
|
||
/// Emit text LLVM-IR | ||
#[arg(short = 'S', default_value_t = false)] | ||
text_output: bool, | ||
} | ||
|
||
fn run(cli: Cli, ctx: &mut Context) -> Result<()> { | ||
let context = IWContext::create(); | ||
let module = IWModule::parse_bitcode_from_path(cli.input, &context) | ||
.map_err(|err| arg_error_noloc!("{}", err))?; | ||
|
||
let pliron_module = from_inkwell::convert_module(ctx, &module)?; | ||
println!("{}", pliron_module.disp(ctx)); | ||
|
||
if cli.text_output { | ||
module | ||
.print_to_file(&cli.output) | ||
.map_err(|err| arg_error_noloc!("{}", err.to_string()))?; | ||
} else { | ||
module.write_bitcode_to_path(&cli.output); | ||
} | ||
Ok(()) | ||
} | ||
|
||
pub fn main() -> ExitCode { | ||
let cli = Cli::parse(); | ||
let ctx = &mut Context::default(); | ||
match run(cli, ctx) { | ||
Ok(_) => ExitCode::SUCCESS, | ||
Err(e) => { | ||
eprintln!("{}", e.disp(ctx)); | ||
ExitCode::FAILURE | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.