From 884cbaabd9c15cdc85809cf713c1be755ea70cf7 Mon Sep 17 00:00:00 2001 From: Maxime Chevalier-Boisvert Date: Thu, 12 May 2022 14:16:09 -0400 Subject: [PATCH] Change push insn macros --- yjit/src/ir.rs | 37 +++++++++++++++++++++---------------- 1 file changed, 21 insertions(+), 16 deletions(-) diff --git a/yjit/src/ir.rs b/yjit/src/ir.rs index 13f81f0af7..f206d5c392 100644 --- a/yjit/src/ir.rs +++ b/yjit/src/ir.rs @@ -399,6 +399,9 @@ impl Assembler // Register allocation // Generic lowering pass // Platform-specific lowering + + // Question: should this method return machine code? + // How do we go from lowered/optimized insn to an array of bytes? } } @@ -410,18 +413,6 @@ impl Assembler self.push_insn(Op::Add, vec![ Opnd::String(text.to_owned()) ], None); } - // Low-level, no output operand - fn test(&mut self, opnd0: Opnd, opnd1: Opnd) - { - self.push_insn(Op::Add, vec![opnd0, opnd1], None); - } - - // Low-level, no output operand - fn mov(&mut self, opnd0: Opnd, opnd1: Opnd) - { - self.push_insn(Op::Add, vec![opnd0, opnd1], None); - } - // Jump if not zero fn jnz(&mut self, target: Target) { @@ -429,7 +420,7 @@ impl Assembler } } -macro_rules! def_push_insn_2_opnd { +macro_rules! def_push_2_opnd { ($op_name:ident, $opcode:expr) => { impl Assembler { @@ -441,9 +432,23 @@ macro_rules! def_push_insn_2_opnd { }; } -def_push_insn_2_opnd!(add, Op::Add); -def_push_insn_2_opnd!(sub, Op::Sub); -def_push_insn_2_opnd!(and, Op::And); +macro_rules! def_push_2_opnd_no_out { + ($op_name:ident, $opcode:expr) => { + impl Assembler + { + fn $op_name(&mut self, opnd0: Opnd, opnd1: Opnd) + { + self.push_insn($opcode, vec![opnd0, opnd1], None); + } + } + }; +} + +def_push_2_opnd!(add, Op::Add); +def_push_2_opnd!(sub, Op::Sub); +def_push_2_opnd!(and, Op::And); +def_push_2_opnd_no_out!(test, Op::Test); +def_push_2_opnd_no_out!(mov, Op::Mov); // NOTE: these methods are temporary and will likely move // to context.rs later