ruby-changes:73103
From: Maxime <ko1@a...>
Date: Tue, 30 Aug 2022 00:45:24 +0900 (JST)
Subject: [ruby-changes:73103] 7753b6b8b6 (master): Removed String opnd so that we can derive Copy for Opnd
https://git.ruby-lang.org/ruby.git/commit/?id=7753b6b8b6 From 7753b6b8b6a011d048a6b3aaf912d1dad7995b7b Mon Sep 17 00:00:00 2001 From: Maxime Chevalier-Boisvert <maxime.chevalierboisvert@s...> Date: Fri, 13 May 2022 15:58:36 -0400 Subject: Removed String opnd so that we can derive Copy for Opnd --- yjit/src/ir.rs | 28 ++++++++++++++++++++-------- 1 file changed, 20 insertions(+), 8 deletions(-) diff --git a/yjit/src/ir.rs b/yjit/src/ir.rs index fde942212d..c632368b7a 100644 --- a/yjit/src/ir.rs +++ b/yjit/src/ir.rs @@ -196,7 +196,7 @@ pub struct Mem https://github.com/ruby/ruby/blob/trunk/yjit/src/ir.rs#L196 } /// Operand to an IR instruction -#[derive(Clone, PartialEq, Eq, Debug)] +#[derive(Clone, Copy, PartialEq, Eq, Debug)] pub enum Opnd { None, // For insns with no output @@ -205,7 +205,6 @@ pub enum Opnd https://github.com/ruby/ruby/blob/trunk/yjit/src/ir.rs#L205 Local(u16), // Local variable (idx, do we need depth too?) Value(VALUE), // Immediate Ruby value, may be GC'd, movable InsnOut(usize), // Output of a preceding instruction in this block - String(String), // String constant, used for comments // Low-level operands, for lowering Imm(i64), // Raw signed immediate @@ -287,11 +286,15 @@ enum Target https://github.com/ruby/ruby/blob/trunk/yjit/src/ir.rs#L286 } /// YJIT IR instruction +#[derive(Clone, Debug)] pub struct Insn { // Opcode for the instruction op: Op, + // Optional string for comments and labels + text: Option<String>, + // List of input operands/values opnds: Vec<Opnd>, @@ -324,6 +327,7 @@ impl Assembler https://github.com/ruby/ruby/blob/trunk/yjit/src/ir.rs#L327 let insn = Insn { op: op, + text: None, opnds: opnds, target: target, pos: None @@ -334,6 +338,19 @@ impl Assembler https://github.com/ruby/ruby/blob/trunk/yjit/src/ir.rs#L338 Opnd::InsnOut(insn_idx) } + // Add a comment at the current position + fn comment(&mut self, text: &str) + { + let insn = Insn { + op: Op::Comment, + text: Some(text.to_owned()), + opnds: vec![], + target: None, + pos: None + }; + self.insns.push(insn); + } + // Add a label at the current position fn label(&mut self, name: &str) -> Target { @@ -341,6 +358,7 @@ impl Assembler https://github.com/ruby/ruby/blob/trunk/yjit/src/ir.rs#L358 let insn = Insn { op: Op::Label, + text: Some(name.to_owned()), opnds: vec![], target: None, pos: None @@ -370,12 +388,6 @@ impl Assembler https://github.com/ruby/ruby/blob/trunk/yjit/src/ir.rs#L388 impl Assembler { - // Add a comment, no output operand - fn comment(&mut self, text: &str) - { - self.push_insn(Op::Add, vec![ Opnd::String(text.to_owned()) ], None); - } - // Jump if not zero fn jnz(&mut self, target: Target) { -- cgit v1.2.1 -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/