summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMaxime Chevalier-Boisvert <maxime.chevalierboisvert@shopify.com>2022-07-07 12:35:18 -0400
committerTakashi Kokubun <takashikkbn@gmail.com>2022-08-29 08:46:59 -0700
commit580f26959eb31d523ac21d640e21ddbe70779512 (patch)
tree8a2ae18c1ebe1e24b961d0696db85a73f30ad3ea
parent65019ed60c635b34337ea35978e931d09ab0181b (diff)
Get started on branchunless port
-rw-r--r--yjit/src/backend/ir.rs6
-rw-r--r--yjit/src/codegen.rs29
2 files changed, 27 insertions, 8 deletions
diff --git a/yjit/src/backend/ir.rs b/yjit/src/backend/ir.rs
index bdefe1c6bc..2d68936db1 100644
--- a/yjit/src/backend/ir.rs
+++ b/yjit/src/backend/ir.rs
@@ -251,6 +251,12 @@ impl From<u64> for Opnd {
}
}
+impl From<i64> for Opnd {
+ fn from(value: i64) -> Self {
+ Opnd::Imm(value.try_into().unwrap())
+ }
+}
+
impl From<i32> for Opnd {
fn from(value: i32) -> Self {
Opnd::Imm(value.try_into().unwrap())
diff --git a/yjit/src/codegen.rs b/yjit/src/codegen.rs
index 6c8fd950a6..06c7756c7a 100644
--- a/yjit/src/codegen.rs
+++ b/yjit/src/codegen.rs
@@ -3256,19 +3256,20 @@ fn gen_branchif(
EndBlock
}
+*/
fn gen_branchunless_branch(
- cb: &mut CodeBlock,
+ asm: &mut Assembler,
target0: CodePtr,
target1: Option<CodePtr>,
shape: BranchShape,
) {
match shape {
- BranchShape::Next0 => jnz_ptr(cb, target1.unwrap()),
- BranchShape::Next1 => jz_ptr(cb, target0),
+ BranchShape::Next0 => asm.jnz(target1.unwrap().into()),
+ BranchShape::Next1 => asm.jz(target0.into()),
BranchShape::Default => {
- jz_ptr(cb, target0);
- jmp_ptr(cb, target1.unwrap());
+ asm.jz(target0.into());
+ asm.jmp(target1.unwrap().into());
}
}
}
@@ -3276,7 +3277,7 @@ fn gen_branchunless_branch(
fn gen_branchunless(
jit: &mut JITState,
ctx: &mut Context,
- cb: &mut CodeBlock,
+ asm: &mut Assembler,
ocb: &mut OutlinedCb,
) -> CodegenStatus {
let jump_offset = jit_get_arg(jit, 0).as_i32();
@@ -3284,14 +3285,15 @@ fn gen_branchunless(
// Check for interrupts, but only on backward branches that may create loops
if jump_offset < 0 {
let side_exit = get_side_exit(jit, ocb, ctx);
- gen_check_ints(cb, side_exit);
+ gen_check_ints(asm, side_exit);
}
// Test if any bit (outside of the Qnil bit) is on
// RUBY_Qfalse /* ...0000 0000 */
// RUBY_Qnil /* ...0000 1000 */
let val_opnd = ctx.stack_pop(1);
- test(cb, val_opnd, imm_opnd(!Qnil.as_i64()));
+ let not_qnil = !Qnil.as_i64();
+ asm.test(val_opnd, not_qnil.into());
// Get the branch target instruction offsets
let next_idx = jit_next_insn_idx(jit) as i32;
@@ -3305,6 +3307,13 @@ fn gen_branchunless(
idx: jump_idx.try_into().unwrap(),
};
+
+
+
+ // TODO: port gen_branch logic
+ todo!("complete branchunless implementation");
+
+ /*
// Generate the branch instructions
gen_branch(
jit,
@@ -3319,8 +3328,12 @@ fn gen_branchunless(
);
EndBlock
+ */
+
+
}
+/*
fn gen_branchnil_branch(
cb: &mut CodeBlock,
target0: CodePtr,