[前][次][番号順一覧][スレッド一覧]

ruby-changes:73115

From: Maxime <ko1@a...>
Date: Tue, 30 Aug 2022 00:51:38 +0900 (JST)
Subject: [ruby-changes:73115] 564f950360 (master): Make assembler methods public, sketch gen_dup with new backend

https://git.ruby-lang.org/ruby.git/commit/?id=564f950360

From 564f9503603ae261561193f69f1fbdef6a140aa1 Mon Sep 17 00:00:00 2001
From: Maxime Chevalier-Boisvert <maxime.chevalierboisvert@s...>
Date: Thu, 19 May 2022 13:32:56 -0400
Subject: Make assembler methods public, sketch gen_dup with new backend

---
 yjit/src/backend/ir.rs | 18 +++++++++---------
 yjit/src/codegen.rs    | 36 ++++++++++++++++++++++++++++++++++++
 2 files changed, 45 insertions(+), 9 deletions(-)

diff --git a/yjit/src/backend/ir.rs b/yjit/src/backend/ir.rs
index 7971f69842..d26eb289c6 100644
--- a/yjit/src/backend/ir.rs
+++ b/yjit/src/backend/ir.rs
@@ -311,7 +311,7 @@ pub struct Assembler https://github.com/ruby/ruby/blob/trunk/yjit/src/backend/ir.rs#L311
 
 impl Assembler
 {
-    fn new() -> Assembler {
+    pub fn new() -> Assembler {
         Assembler {
             insns: Vec::default(),
             live_ranges: Vec::default()
@@ -348,7 +348,7 @@ impl Assembler https://github.com/ruby/ruby/blob/trunk/yjit/src/backend/ir.rs#L348
     }
 
     /// Add a comment at the current position
-    fn comment(&mut self, text: &str)
+    pub fn comment(&mut self, text: &str)
     {
         let insn = Insn {
             op: Op::Comment,
@@ -363,7 +363,7 @@ impl Assembler https://github.com/ruby/ruby/blob/trunk/yjit/src/backend/ir.rs#L363
     }
 
     /// Add a label at the current position
-    fn label(&mut self, name: &str) -> Target
+    pub fn label(&mut self, name: &str) -> Target
     {
         let insn_idx = self.insns.len();
 
@@ -553,7 +553,7 @@ impl Assembler https://github.com/ruby/ruby/blob/trunk/yjit/src/backend/ir.rs#L553
     }
 
     // Optimize and compile the stored instructions
-    fn compile(self, cb: &mut CodeBlock)
+    pub fn compile(self, cb: &mut CodeBlock)
     {
         // NOTE: for arm we're going to want to split loads but also stores
         // This can be done in a platform-agnostic way, but the set of passes
@@ -577,12 +577,12 @@ impl fmt::Debug for Assembler { https://github.com/ruby/ruby/blob/trunk/yjit/src/backend/ir.rs#L577
 impl Assembler
 {
     // Jump if not zero
-    fn jnz(&mut self, target: Target)
+    pub fn jnz(&mut self, target: Target)
     {
         self.push_insn(Op::Jnz, vec![], Some(target));
     }
 
-    fn jbe(&mut self, target: Target)
+    pub fn jbe(&mut self, target: Target)
     {
         self.push_insn(Op::Jbe, vec![], Some(target));
     }
@@ -592,7 +592,7 @@ macro_rules! def_push_1_opnd { https://github.com/ruby/ruby/blob/trunk/yjit/src/backend/ir.rs#L592
     ($op_name:ident, $opcode:expr) => {
         impl Assembler
         {
-            fn $op_name(&mut self, opnd0: Opnd) -> Opnd
+            pub fn $op_name(&mut self, opnd0: Opnd) -> Opnd
             {
                 self.push_insn($opcode, vec![opnd0], None)
             }
@@ -604,7 +604,7 @@ macro_rules! def_push_2_opnd { https://github.com/ruby/ruby/blob/trunk/yjit/src/backend/ir.rs#L604
     ($op_name:ident, $opcode:expr) => {
         impl Assembler
         {
-            fn $op_name(&mut self, opnd0: Opnd, opnd1: Opnd) -> Opnd
+            pub fn $op_name(&mut self, opnd0: Opnd, opnd1: Opnd) -> Opnd
             {
                 self.push_insn($opcode, vec![opnd0, opnd1], None)
             }
@@ -616,7 +616,7 @@ macro_rules! def_push_2_opnd_no_out { https://github.com/ruby/ruby/blob/trunk/yjit/src/backend/ir.rs#L616
     ($op_name:ident, $opcode:expr) => {
         impl Assembler
         {
-            fn $op_name(&mut self, opnd0: Opnd, opnd1: Opnd)
+            pub fn $op_name(&mut self, opnd0: Opnd, opnd1: Opnd)
             {
                 self.push_insn($opcode, vec![opnd0, opnd1], None);
             }
diff --git a/yjit/src/codegen.rs b/yjit/src/codegen.rs
index 67d3ecd573..22e3c45438 100644
--- a/yjit/src/codegen.rs
+++ b/yjit/src/codegen.rs
@@ -901,6 +901,42 @@ fn gen_dup( https://github.com/ruby/ruby/blob/trunk/yjit/src/codegen.rs#L901
     KeepCompiling
 }
 
+
+
+
+
+
+
+use crate::backend::ir::*;
+
+#[allow(dead_code)]
+fn gen_dup_ir(
+    _jit: &mut JITState,
+    ctx: &mut Context,
+    cb: &mut CodeBlock,
+    _ocb: &mut OutlinedCb,
+) -> CodegenStatus {
+
+    let mut asm = Assembler::new();
+
+    let dup_val = ctx.ir_stack_pop(0);
+    let (mapping, tmp_type) = ctx.get_opnd_mapping(StackOpnd(0));
+
+    let loc0 = ctx.ir_stack_push_mapping((mapping, tmp_type));
+    asm.mov(loc0, dup_val);
+
+    asm.compile(cb);
+
+    KeepCompiling
+}
+
+
+
+
+
+
+
+
 // duplicate stack top n elements
 fn gen_dupn(
     jit: &mut JITState,
-- 
cgit v1.2.1


--
ML: ruby-changes@q...
Info: http://www.atdot.net/~ko1/quickml/

[前][次][番号順一覧][スレッド一覧]