Don't attach a first result in make_inst().
That is now the job of make_inst_results().
This commit is contained in:
@@ -322,13 +322,9 @@ impl DataFlowGraph {
|
|||||||
/// The type of the first result is indicated by `data.ty`. If the instruction produces
|
/// The type of the first result is indicated by `data.ty`. If the instruction produces
|
||||||
/// multiple results, also call `make_inst_results` to allocate value table entries.
|
/// multiple results, also call `make_inst_results` to allocate value table entries.
|
||||||
pub fn make_inst(&mut self, data: InstructionData) -> Inst {
|
pub fn make_inst(&mut self, data: InstructionData) -> Inst {
|
||||||
let ty = data.first_type();
|
let n = self.num_insts() + 1;
|
||||||
let inst = self.insts.push(data);
|
self.results.resize(n);
|
||||||
let res = self.results.ensure(inst);
|
self.insts.push(data)
|
||||||
if !ty.is_void() {
|
|
||||||
res.push(Value::new_direct(inst), &mut self.value_lists);
|
|
||||||
}
|
|
||||||
inst
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Get the instruction reference that will be assigned to the next instruction created by
|
/// Get the instruction reference that will be assigned to the next instruction created by
|
||||||
@@ -392,9 +388,8 @@ impl DataFlowGraph {
|
|||||||
|
|
||||||
/// Create result values for an instruction that produces multiple results.
|
/// Create result values for an instruction that produces multiple results.
|
||||||
///
|
///
|
||||||
/// Instructions that produce 0 or 1 result values only need to be created with `make_inst`. If
|
/// Instructions that produce no result values only need to be created with `make_inst`,
|
||||||
/// the instruction may produce more than 1 result, call `make_inst_results` to allocate
|
/// otherwise call `make_inst_results` to allocate value table entries for the results.
|
||||||
/// value table entries for the additional results.
|
|
||||||
///
|
///
|
||||||
/// The result value types are determined from the instruction's value type constraints and the
|
/// The result value types are determined from the instruction's value type constraints and the
|
||||||
/// provided `ctrl_typevar` type for polymorphic instructions. For non-polymorphic
|
/// provided `ctrl_typevar` type for polymorphic instructions. For non-polymorphic
|
||||||
@@ -838,9 +833,10 @@ mod tests {
|
|||||||
|
|
||||||
let idata = InstructionData::Nullary {
|
let idata = InstructionData::Nullary {
|
||||||
opcode: Opcode::Iconst,
|
opcode: Opcode::Iconst,
|
||||||
ty: types::I32,
|
ty: types::VOID,
|
||||||
};
|
};
|
||||||
let inst = dfg.make_inst(idata);
|
let inst = dfg.make_inst(idata);
|
||||||
|
dfg.make_inst_results(inst, types::I32);
|
||||||
assert_eq!(inst.to_string(), "inst0");
|
assert_eq!(inst.to_string(), "inst0");
|
||||||
assert_eq!(dfg.display_inst(inst).to_string(), "v0 = iconst.i32");
|
assert_eq!(dfg.display_inst(inst).to_string(), "v0 = iconst.i32");
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user