ruby-changes:73099
From: Maxime <ko1@a...>
Date: Tue, 30 Aug 2022 00:45:19 +0900 (JST)
Subject: [ruby-changes:73099] 884cbaabd9 (master): Change push insn macros
https://git.ruby-lang.org/ruby.git/commit/?id=884cbaabd9 From 884cbaabd9c15cdc85809cf713c1be755ea70cf7 Mon Sep 17 00:00:00 2001 From: Maxime Chevalier-Boisvert <maxime.chevalierboisvert@s...> Date: Thu, 12 May 2022 14:16:09 -0400 Subject: 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 https://github.com/ruby/ruby/blob/trunk/yjit/src/ir.rs#L399 // 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 https://github.com/ruby/ruby/blob/trunk/yjit/src/ir.rs#L413 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 https://github.com/ruby/ruby/blob/trunk/yjit/src/ir.rs#L420 } } -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 { https://github.com/ruby/ruby/blob/trunk/yjit/src/ir.rs#L432 }; } -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 -- cgit v1.2.1 -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/