mirror of
https://github.com/ruby/ruby.git
synced 2025-09-16 00:54:01 +02:00
ZJIT: Add option to dump LIR (#13139)
Now we can dump HIR, optimized HIR, LIR, and assembly.
This commit is contained in:
parent
87d00142d2
commit
9fc5a5dbed
Notes:
git
2025-04-22 16:17:50 +00:00
Merged-By: k0kubun <takashikkbn@gmail.com>
2 changed files with 11 additions and 0 deletions
|
@ -10,6 +10,7 @@ use crate::backend::lir::{self, asm_comment, Assembler, Opnd, Target, CFP, C_ARG
|
|||
use crate::hir::{iseq_to_hir, Block, BlockId, BranchEdge, CallInfo};
|
||||
use crate::hir::{Const, FrameState, Function, Insn, InsnId};
|
||||
use crate::hir_type::{types::Fixnum, Type};
|
||||
use crate::options::get_option;
|
||||
|
||||
/// Ephemeral code generation state
|
||||
struct JITState {
|
||||
|
@ -223,6 +224,10 @@ fn gen_function(cb: &mut CodeBlock, iseq: IseqPtr, function: &Function) -> Optio
|
|||
}
|
||||
}
|
||||
|
||||
if get_option!(dump_lir) {
|
||||
println!("LIR:\nfn {}:\n{:?}", iseq_name(iseq), asm);
|
||||
}
|
||||
|
||||
// Generate code if everything can be compiled
|
||||
asm.compile(cb).map(|(start_ptr, _)| (start_ptr, jit.branch_iseqs))
|
||||
}
|
||||
|
|
|
@ -27,6 +27,9 @@ pub struct Options {
|
|||
/// Dump High-level IR after optimization, right before codegen.
|
||||
pub dump_hir_opt: Option<DumpHIR>,
|
||||
|
||||
/// Dump low-level IR
|
||||
pub dump_lir: bool,
|
||||
|
||||
/// Dump all compiled machine code.
|
||||
pub dump_disasm: bool,
|
||||
}
|
||||
|
@ -70,6 +73,7 @@ pub fn init_options() -> Options {
|
|||
debug: false,
|
||||
dump_hir_init: None,
|
||||
dump_hir_opt: None,
|
||||
dump_lir: false,
|
||||
dump_disasm: false,
|
||||
}
|
||||
}
|
||||
|
@ -127,6 +131,8 @@ fn parse_option(options: &mut Options, str_ptr: *const std::os::raw::c_char) ->
|
|||
("dump-hir-init", "all") => options.dump_hir_init = Some(DumpHIR::All),
|
||||
("dump-hir-init", "debug") => options.dump_hir_init = Some(DumpHIR::Debug),
|
||||
|
||||
("dump-lir", "") => options.dump_lir = true,
|
||||
|
||||
("dump-disasm", "") => options.dump_disasm = true,
|
||||
|
||||
_ => return None, // Option name not recognized
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue