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

ruby-changes:73150

From: Maxime <ko1@a...>
Date: Tue, 30 Aug 2022 00:55:40 +0900 (JST)
Subject: [ruby-changes:73150] e743e3bf20 (master): Remove unused code, add backend asm test

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

From e743e3bf20a38d44888383393823b8776c2d1e90 Mon Sep 17 00:00:00 2001
From: Maxime Chevalier-Boisvert <maxime.chevalierboisvert@s...>
Date: Tue, 14 Jun 2022 16:32:54 -0400
Subject: Remove unused code, add backend asm test

---
 yjit/src/backend/ir.rs | 56 +++++++++++++++++++++-----------------------------
 1 file changed, 23 insertions(+), 33 deletions(-)

diff --git a/yjit/src/backend/ir.rs b/yjit/src/backend/ir.rs
index 86e590e846..1fca3a5b87 100644
--- a/yjit/src/backend/ir.rs
+++ b/yjit/src/backend/ir.rs
@@ -153,7 +153,7 @@ impl Opnd https://github.com/ruby/ruby/blob/trunk/yjit/src/backend/ir.rs#L153
                     disp: disp,
                 })
             },
-            _ => unreachable!()
+            _ => unreachable!("memory operand with non-register base")
         }
     }
 
@@ -169,42 +169,22 @@ impl From<usize> for Opnd { https://github.com/ruby/ruby/blob/trunk/yjit/src/backend/ir.rs#L169
     }
 }
 
-impl From<VALUE> for Opnd {
-    fn from(value: VALUE) -> Self {
-        let VALUE(uimm) = value;
-        Opnd::UImm(uimm as u64)
+impl From<u64> for Opnd {
+    fn from(value: u64) -> Self {
+        Opnd::UImm(value.try_into().unwrap())
     }
 }
 
-/// NOTE: this is useful during the port but can probably be removed once
-/// Context returns ir::Opnd instead of X86Opnd
-///
-/// Method to convert from an X86Opnd to an IR Opnd
-impl From<X86Opnd> for Opnd {
-    fn from(opnd: X86Opnd) -> Self {
-        match opnd {
-            X86Opnd::None => Opnd::None,
-            X86Opnd::UImm(X86UImm{ value, .. }) => Opnd::UImm(value),
-            X86Opnd::Imm(X86Imm{ value, .. }) => Opnd::Imm(value),
-
-            // General-purpose register
-            X86Opnd::Reg(reg) => {
-                Opnd::Reg(reg)
-            }
-
-            // Memory operand with displacement
-            X86Opnd::Mem(X86Mem{ num_bits, base_reg_no, disp, idx_reg_no: None, scale_exp: 0 }) => {
-                let base_reg = Reg { num_bits: 64, reg_no: base_reg_no, reg_type: RegType::GP };
-
-                Opnd::Mem(Mem {
-                    base_reg: base_reg,
-                    disp,
-                    num_bits
-                })
-            }
+impl From<i32> for Opnd {
+    fn from(value: i32) -> Self {
+        Opnd::Imm(value.try_into().unwrap())
+    }
+}
 
-            _ => panic!("unsupported x86 operand type")
-        }
+impl From<VALUE> for Opnd {
+    fn from(value: VALUE) -> Self {
+        let VALUE(uimm) = value;
+        Opnd::UImm(uimm as u64)
     }
 }
 
@@ -874,6 +854,16 @@ mod tests { https://github.com/ruby/ruby/blob/trunk/yjit/src/backend/ir.rs#L854
         asm.compile_with_regs(&mut cb, regs);
     }
 
+    // 64-bit values can't be written directly to memory,
+    // need to be split into one or more register movs first
+    #[test]
+    fn test_store_u64()
+    {
+        let (mut asm, mut cb, regs) = setup_asm(1);
+        asm.store(Opnd::mem(64, SP, 0), u64::MAX.into());
+        asm.compile_with_regs(&mut cb, regs);
+    }
+
     #[test]
     fn test_c_call()
     {
-- 
cgit v1.2.1


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

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