refactor(mir): phase260 p0 edge-args plumbing (strangler) + ssot api + docs

This commit is contained in:
2025-12-21 04:34:22 +09:00
parent 4496b6243d
commit 4dfe3349bf
42 changed files with 1044 additions and 187 deletions

View File

@ -233,12 +233,15 @@ pub fn try_parse_v1_to_module(json: &str) -> Result<Option<MirModule>, String> {
condition: ValueId::new(cond),
then_bb: BasicBlockId::new(then_bb),
else_bb: BasicBlockId::new(else_bb),
then_edge_args: None,
else_edge_args: None,
});
}
"jump" => {
let target = require_u64(inst, "target", "jump target")? as u32;
block_ref.add_instruction(MirInstruction::Jump {
target: BasicBlockId::new(target),
edge_args: None,
});
}
"phi" => {

View File

@ -512,10 +512,11 @@ pub fn emit_mir_json_for_harness(
condition,
then_bb,
else_bb,
..
} => {
insts.push(json!({"op":"branch","cond": condition.as_u32(), "then": then_bb.as_u32(), "else": else_bb.as_u32()}));
}
I::Jump { target } => {
I::Jump { target, .. } => {
insts.push(json!({"op":"jump","target": target.as_u32()}));
}
I::Return { value } => {
@ -528,8 +529,8 @@ pub fn emit_mir_json_for_harness(
if let Some(term) = &bb.terminator {
match term {
I::Return { value } => insts.push(json!({"op":"ret","value": value.map(|v| v.as_u32())})),
I::Jump { target } => insts.push(json!({"op":"jump","target": target.as_u32()})),
I::Branch { condition, then_bb, else_bb } => insts.push(json!({"op":"branch","cond": condition.as_u32(), "then": then_bb.as_u32(), "else": else_bb.as_u32()})),
I::Jump { target, .. } => insts.push(json!({"op":"jump","target": target.as_u32()})),
I::Branch { condition, then_bb, else_bb, .. } => insts.push(json!({"op":"branch","cond": condition.as_u32(), "then": then_bb.as_u32(), "else": else_bb.as_u32()})),
_ => {}
}
}
@ -874,10 +875,11 @@ pub fn emit_mir_json_for_harness_bin(
condition,
then_bb,
else_bb,
..
} => {
insts.push(json!({"op":"branch","cond": condition.as_u32(), "then": then_bb.as_u32(), "else": else_bb.as_u32()}));
}
I::Jump { target } => {
I::Jump { target, .. } => {
insts.push(json!({"op":"jump","target": target.as_u32()}));
}
I::Return { value } => {
@ -890,8 +892,8 @@ pub fn emit_mir_json_for_harness_bin(
if let Some(term) = &bb.terminator {
match term {
I::Return { value } => insts.push(json!({"op":"ret","value": value.map(|v| v.as_u32())})),
I::Jump { target } => insts.push(json!({"op":"jump","target": target.as_u32()})),
I::Branch { condition, then_bb, else_bb } => insts.push(json!({"op":"branch","cond": condition.as_u32(), "then": then_bb.as_u32(), "else": else_bb.as_u32()})),
I::Jump { target, .. } => insts.push(json!({"op":"jump","target": target.as_u32()})),
I::Branch { condition, then_bb, else_bb, .. } => insts.push(json!({"op":"branch","cond": condition.as_u32(), "then": then_bb.as_u32(), "else": else_bb.as_u32()})),
_ => {} }
}
blocks.push(json!({"id": bid.as_u32(), "instructions": insts}));

View File

@ -144,12 +144,15 @@ pub fn parse_mir_v0_to_module(json: &str) -> Result<MirModule, String> {
condition: ValueId::new(cond),
then_bb: BasicBlockId::new(then_bb),
else_bb: BasicBlockId::new(else_bb),
then_edge_args: None,
else_edge_args: None,
});
}
"jump" => {
let target = require_u64(inst, "target", "jump target")? as u32;
block_ref.add_instruction(MirInstruction::Jump {
target: BasicBlockId::new(target),
edge_args: None,
});
}
"phi" => {