From 98d249ec6e7a222c502247c8fd4896270e6af975 Mon Sep 17 00:00:00 2001 From: Clemens Tiedt Date: Thu, 14 Sep 2023 16:30:17 +0200 Subject: [PATCH] move llvm ir in debug.rs --- compiler/cli/src/debug.rs | 37 +++++++++++++++++++------------------ 1 file changed, 19 insertions(+), 18 deletions(-) diff --git a/compiler/cli/src/debug.rs b/compiler/cli/src/debug.rs index 4998c2f19..7ab1f64f8 100644 --- a/compiler/cli/src/debug.rs +++ b/compiler/cli/src/debug.rs @@ -60,15 +60,16 @@ pub(crate) enum Options { /// Low-Level Intermediate Representation Lir(PathAndTracing), - /// LLVM Intermediate Representation - #[cfg(feature = "inkwell")] - LlvmIr(OnlyPath), - + /// Optimized Low-Level Intermediate Representation OptimizedLir(PathAndTracing), - + /// VM Byte Code VmByteCode(PathAndTracing), + + /// LLVM Intermediate Representation + #[cfg(feature = "inkwell")] + LlvmIr(OnlyPath), #[command(subcommand)] Gold(Gold), @@ -150,18 +151,12 @@ pub(crate) fn debug(options: Options) -> ProgramResult { lir.ok() .map(|(lir, _)| RichIr::for_lir(&module, &lir, &tracing)) } - #[cfg(feature = "inkwell")] - Options::LlvmIr(options) => { - let module = module_for_path(options.path.clone())?; - let llvm_ir = db.llvm_ir(module.clone()); - llvm_ir.ok() - } Options::OptimizedLir(options) => { let module = module_for_path(options.path.clone())?; let tracing = options.to_tracing_config(); let lir = db.optimized_lir(module.clone(), tracing.clone()); lir.ok() - .map(|(lir, _)| RichIr::for_lir(&module, &lir, &tracing)) + .map(|(lir, _)| RichIr::for_lir(&module, &lir, &tracing)) } Options::VmByteCode(options) => { let module = module_for_path(options.path.clone())?; @@ -169,6 +164,12 @@ pub(crate) fn debug(options: Options) -> ProgramResult { let (vm_byte_code, _) = compile_byte_code(&db, module.clone(), tracing.clone()); Some(RichIr::for_byte_code(&module, &vm_byte_code, &tracing)) } + #[cfg(feature = "inkwell")] + Options::LlvmIr(options) => { + let module = module_for_path(options.path.clone())?; + let llvm_ir = db.llvm_ir(module.clone()); + llvm_ir.ok() + } Options::Gold(options) => return options.run(&db), }; @@ -356,12 +357,6 @@ impl GoldOptions { let lir = RichIr::for_lir(&module, &lir, &Self::TRACING_CONFIG); visit("LIR", lir.text); - #[cfg(feature = "inkwell")] - { - let llvm_ir = db.llvm_ir(module.clone()).unwrap(); - visit("LLVM IR", llvm_ir.text); - } - let (optimized_lir, _) = db .optimized_lir(module.clone(), Self::TRACING_CONFIG.clone()) .unwrap(); @@ -376,6 +371,12 @@ impl GoldOptions { "VM Byte Code", Self::format_byte_code(&vm_byte_code, &vm_byte_code_rich_ir), ); + + #[cfg(feature = "inkwell")] + { + let llvm_ir = db.llvm_ir(module.clone()).unwrap(); + visit("LLVM IR", llvm_ir.text); + } } Ok(()) }