Add branchif, jump
This commit is contained in:
parent
5b5d54f886
commit
464e74f20c
Notes:
git
2025-04-18 13:49:13 +00:00
@ -99,7 +99,7 @@ pub enum Insn {
|
|||||||
Jump(BranchEdge),
|
Jump(BranchEdge),
|
||||||
|
|
||||||
// Conditional branch instructions
|
// Conditional branch instructions
|
||||||
IfTrue { val: Opnd, branch: BranchEdge },
|
IfTrue { val: Opnd, target: BranchEdge },
|
||||||
IfFalse { val: Opnd, target: BranchEdge },
|
IfFalse { val: Opnd, target: BranchEdge },
|
||||||
|
|
||||||
// Call a C function
|
// Call a C function
|
||||||
@ -393,15 +393,24 @@ pub fn iseq_to_ssa(iseq: *const rb_iseq_t) -> Result<Function, ParseError> {
|
|||||||
let val = state.pop()?;
|
let val = state.pop()?;
|
||||||
let test_id = fun.push_insn(block, Insn::Test { val });
|
let test_id = fun.push_insn(block, Insn::Test { val });
|
||||||
// TODO(max): Check interrupts
|
// TODO(max): Check interrupts
|
||||||
let _branch_id = fun.push_insn(block,
|
let target = insn_idx_to_block[&insn_idx_at_offset(insn_idx, offset)];
|
||||||
Insn::IfFalse {
|
// TODO(max): Merge locals/stack for bb arguments
|
||||||
val: Opnd::Insn(test_id),
|
let _branch_id = fun.push_insn(block, Insn::IfFalse { val: Opnd::Insn(test_id), target: BranchEdge { target, args: vec![] } });
|
||||||
target: BranchEdge {
|
}
|
||||||
target: insn_idx_to_block[&insn_idx_at_offset(insn_idx, offset)],
|
YARVINSN_branchif => {
|
||||||
// TODO(max): Merge locals/stack for bb arguments
|
let offset = get_arg(pc, 0).as_i64();
|
||||||
args: vec![],
|
let val = state.pop()?;
|
||||||
}
|
let test_id = fun.push_insn(block, Insn::Test { val });
|
||||||
});
|
// TODO(max): Check interrupts
|
||||||
|
let target = insn_idx_to_block[&insn_idx_at_offset(insn_idx, offset)];
|
||||||
|
// TODO(max): Merge locals/stack for bb arguments
|
||||||
|
let _branch_id = fun.push_insn(block, Insn::IfTrue { val: Opnd::Insn(test_id), target: BranchEdge { target, args: vec![] } });
|
||||||
|
}
|
||||||
|
YARVINSN_jump => {
|
||||||
|
let offset = get_arg(pc, 0).as_i64();
|
||||||
|
// TODO(max): Check interrupts
|
||||||
|
let target = insn_idx_to_block[&insn_idx_at_offset(insn_idx, offset)];
|
||||||
|
let _branch_id = fun.push_insn(block, Insn::Jump(BranchEdge { target, args: vec![] }));
|
||||||
}
|
}
|
||||||
YARVINSN_opt_nil_p => {
|
YARVINSN_opt_nil_p => {
|
||||||
let recv = state.pop()?;
|
let recv = state.pop()?;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user