Inline jump tables in parsed br_table instructions (#5755)

As jump tables are used by at most one br_table instruction, inline their definition in those instructions instead of requiring them to be declared as function-level metadata.
This commit is contained in:
Trevor Elliott
2023-02-09 14:24:04 -08:00
committed by GitHub
parent 202d3af16a
commit 15fe9c7c93
23 changed files with 54 additions and 200 deletions

View File

@@ -82,11 +82,6 @@ pub trait FuncWriter {
}
}
for (jt, jt_data) in &func.stencil.dfg.jump_tables {
any = true;
self.write_entity_definition(w, func, jt.into(), jt_data)?;
}
for (&cref, cval) in func.dfg.constants.iter() {
any = true;
self.write_entity_definition(w, func, cref.into(), cval)?;
@@ -377,6 +372,7 @@ fn write_instruction(
/// Write the operands of `inst` to `w` with a prepended space.
pub fn write_operands(w: &mut dyn Write, dfg: &DataFlowGraph, inst: Inst) -> fmt::Result {
let pool = &dfg.value_lists;
let jump_tables = &dfg.jump_tables;
use crate::ir::instructions::InstructionData::*;
match dfg.insts[inst] {
AtomicRmw { op, args, .. } => write!(w, " {} {}, {}", op, args[0], args[1]),
@@ -430,7 +426,7 @@ pub fn write_operands(w: &mut dyn Write, dfg: &DataFlowGraph, inst: Inst) -> fmt
destination,
table,
..
} => write!(w, " {}, {}, {}", arg, destination, table),
} => write!(w, " {}, {}, {}", arg, destination, jump_tables[table]),
Call {
func_ref, ref args, ..
} => write!(w, " {}({})", func_ref, DisplayValues(args.as_slice(pool))),