Rework br_table to use BlockCall (#5731)
Rework br_table to use BlockCall, allowing us to avoid adding new nodes during ssa construction to hold block arguments. Additionally, many places where we previously matched on InstructionData to extract branch destinations can be replaced with a use of branch_destination or branch_destination_mut.
This commit is contained in:
@@ -287,6 +287,7 @@ fn verify_format(inst_name: &str, operands_in: &[Operand], format: &InstructionF
|
||||
// - its number and names of input immediate operands,
|
||||
// - whether it has a value list or not.
|
||||
let mut num_values = 0;
|
||||
let mut num_blocks = 0;
|
||||
let mut num_immediates = 0;
|
||||
|
||||
for operand in operands_in.iter() {
|
||||
@@ -301,7 +302,9 @@ fn verify_format(inst_name: &str, operands_in: &[Operand], format: &InstructionF
|
||||
if operand.is_value() {
|
||||
num_values += 1;
|
||||
}
|
||||
if operand.is_immediate_or_entityref() {
|
||||
if operand.kind.is_block() {
|
||||
num_blocks += 1;
|
||||
} else if operand.is_immediate_or_entityref() {
|
||||
if let Some(format_field) = format.imm_fields.get(num_immediates) {
|
||||
assert_eq!(
|
||||
format_field.kind.rust_field_name,
|
||||
@@ -325,6 +328,13 @@ fn verify_format(inst_name: &str, operands_in: &[Operand], format: &InstructionF
|
||||
inst_name, format.name
|
||||
);
|
||||
|
||||
assert_eq!(
|
||||
num_blocks, format.num_block_operands,
|
||||
"inst {} doesn't have as many block input operands as its format {} declares; you may need \
|
||||
to use a different format.",
|
||||
inst_name, format.name,
|
||||
);
|
||||
|
||||
assert_eq!(
|
||||
num_immediates,
|
||||
format.imm_fields.len(),
|
||||
|
||||
@@ -79,7 +79,8 @@ fn define_control_flow(
|
||||
|
||||
Use ``x`` as an unsigned index into the jump table ``JT``. If a jump
|
||||
table entry is found, branch to the corresponding block. If no entry was
|
||||
found or the index is out-of-bounds, branch to the given default block.
|
||||
found or the index is out-of-bounds, branch to the default block of the
|
||||
table.
|
||||
|
||||
Note that this branch instruction can't pass arguments to the targeted
|
||||
blocks. Split critical edges as needed to work around this.
|
||||
|
||||
Reference in New Issue
Block a user