Background
- When implementing mem2reg, I have to patch koopa and add this method to
DataFlowGraph
- there are some existing discussion on the current design, see https://pku-minic.github.io/online-doc/#/lv9p-reincarnation/ssa-form
Proposal
#[must_use = "must fix arguments in predecessors' terminators to match the params"]
pub fn append_bb_param(&mut self, bb: BasicBlock, ty: crate::ir::Type) -> Value {
assert!(!ty.is_unit(), "parameter type must not be `unit`!");
let index = self.bb(bb).params().len();
let value = self.new_value_data(crate::ir::values::BlockArgRef::new_data(index, ty));
self.bb_mut(bb).params_mut().push(value);
value
}
I think it's a reasonable design, otherwise user might have to clone a brand new BB just to add one BasicBlock param/Phi, or they should patch their own koopa.
We could apply this API to FunctionArgRef if it's wanted
Background
DataFlowGraphProposal
I think it's a reasonable design, otherwise user might have to clone a brand new BB just to add one BasicBlock param/Phi, or they should patch their own koopa.
We could apply this API to
FunctionArgRefif it's wanted