summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMaxime Chevalier-Boisvert <maxime.chevalierboisvert@shopify.com>2025-02-06 11:09:47 -0500
committerTakashi Kokubun <takashikkbn@gmail.com>2025-04-18 21:52:55 +0900
commit6e9cc0e7bdfb5ed9a63a8eeebe5feb2b513b9acc (patch)
treef1d51c13cf7948f8bffef22e4854843a5a8b0bd1
parent30e688ca14c5bcab58974cea468c24bdd55bee54 (diff)
Derive block default
Notes
Notes: Merged: https://github.com/ruby/ruby/pull/13131
-rw-r--r--zjit/src/ir.rs15
1 files changed, 9 insertions, 6 deletions
diff --git a/zjit/src/ir.rs b/zjit/src/ir.rs
index ff1cbace9a..2bc93b4c3a 100644
--- a/zjit/src/ir.rs
+++ b/zjit/src/ir.rs
@@ -6,6 +6,7 @@ pub struct InsnId(usize);
#[derive(Copy, Clone, Eq, PartialEq, Hash, Debug)]
pub struct BlockId(usize);
+/// Instruction operand
#[derive(Debug, PartialEq)]
enum Opnd {
Const(VALUE),
@@ -14,20 +15,18 @@ enum Opnd {
#[derive(Debug, PartialEq)]
enum Insn {
+ // SSA block parameter
Param { idx: usize },
Return { val: Opnd },
}
-#[derive(Debug, PartialEq)]
+#[derive(Default, Debug, PartialEq)]
struct Block {
params: Vec<InsnId>,
insns: Vec<InsnId>,
}
impl Block {
- fn new() -> Block {
- Block { params: vec![], insns: vec![] }
- }
}
#[derive(Debug, PartialEq)]
@@ -39,13 +38,13 @@ struct Function {
impl Function {
fn new() -> Function {
- Function { blocks: vec![Block::new()], insns: vec![], entry_block: BlockId(0) }
+ Function { blocks: vec![Block::default()], insns: vec![], entry_block: BlockId(0) }
}
+ // Add an instruction to an SSA block
fn push_insn(&mut self, block: BlockId, insn: Insn) -> InsnId {
let id = InsnId(self.insns.len());
self.insns.push(insn);
- // Add the insn to the block
self.blocks[block.0].insns.push(id);
id
}
@@ -58,6 +57,10 @@ enum RubyOpcode {
}
struct FrameState {
+ // TODO:
+ // Ruby bytecode instruction pointer
+ // pc:
+
stack: Vec<Opnd>,
}