diff options
| author | Maxime Chevalier-Boisvert <maxime.chevalierboisvert@shopify.com> | 2022-06-08 15:01:13 -0400 |
|---|---|---|
| committer | Takashi Kokubun <takashikkbn@gmail.com> | 2022-08-29 08:46:55 -0700 |
| commit | 77383b3958a90c3e6c257e3c4431fed54a9de10b (patch) | |
| tree | 974a95f9cbbeeccc16d8b666a56bd15030a844dd /yjit/src/backend/ir.rs | |
| parent | b63f8bb45619c891ce45466031012c0a48defefe (diff) | |
Add conditional jumps
Diffstat (limited to 'yjit/src/backend/ir.rs')
| -rw-r--r-- | yjit/src/backend/ir.rs | 29 |
1 files changed, 17 insertions, 12 deletions
diff --git a/yjit/src/backend/ir.rs b/yjit/src/backend/ir.rs index 09ce6b4d6c..e5bcd78932 100644 --- a/yjit/src/backend/ir.rs +++ b/yjit/src/backend/ir.rs @@ -78,8 +78,9 @@ pub enum Op Cmp, // Low-level conditional jump instructions - Jnz, Jbe, + Je, + Jnz, // C function call with N arguments (variadic) CCall, @@ -636,17 +637,6 @@ impl fmt::Debug for Assembler { impl Assembler { - // Jump if not zero - pub fn jnz(&mut self, target: Target) - { - self.push_insn(Op::Jnz, vec![], Some(target)); - } - - pub fn jbe(&mut self, target: Target) - { - self.push_insn(Op::Jbe, vec![], Some(target)); - } - pub fn ccall(&mut self, fptr: *const u8, opnds: Vec<Opnd>) -> Opnd { let target = Target::FunPtr(fptr); @@ -654,6 +644,18 @@ impl Assembler } } +macro_rules! def_push_jcc { + ($op_name:ident, $opcode:expr) => { + impl Assembler + { + pub fn $op_name(&mut self, target: Target) + { + self.push_insn($opcode, vec![], Some(target)); + } + } + }; +} + macro_rules! def_push_1_opnd { ($op_name:ident, $opcode:expr) => { impl Assembler @@ -702,6 +704,9 @@ macro_rules! def_push_2_opnd_no_out { }; } +def_push_jcc!(je, Op::Je); +def_push_jcc!(jbe, Op::Jbe); +def_push_jcc!(jnz, Op::Jnz); def_push_2_opnd!(add, Op::Add); def_push_2_opnd!(sub, Op::Sub); def_push_2_opnd!(and, Op::And); |
