cranelift: Add a conditional branch instruction with two targets (#5446)
Add a conditional branch instruction with two targets: brif. This instruction will eventually replace brz and brnz, as it encompasses the behavior of both. This PR also changes the InstructionData layout for instruction formats that hold BlockCall values, taking the same approach we use for Value arguments. This allows branch_destination to return a slice to the BlockCall values held in the instruction, rather than requiring that we pattern match on InstructionData to fetch the then/else blocks. Function generation for fuzzing has been updated to generate uses of brif, and I've run the cranelift-fuzzgen target locally for hours without triggering any new failures.
This commit is contained in:
@@ -691,9 +691,10 @@ impl DataFlowGraph {
|
||||
self.inst_args_mut(inst)[i] = body(self, arg);
|
||||
}
|
||||
|
||||
for mut block in self.insts[inst].branch_destination().into_iter() {
|
||||
for block_ix in 0..self.insts[inst].branch_destination().len() {
|
||||
// We aren't changing the size of the args list, so we won't need to write the branch
|
||||
// back to the instruction.
|
||||
let mut block = self.insts[inst].branch_destination()[block_ix];
|
||||
for i in 0..block.args_slice(&self.value_lists).len() {
|
||||
let arg = block.args_slice(&self.value_lists)[i];
|
||||
block.args_slice_mut(&mut self.value_lists)[i] = body(self, arg);
|
||||
@@ -712,7 +713,8 @@ impl DataFlowGraph {
|
||||
*arg = values.next().unwrap();
|
||||
}
|
||||
|
||||
for mut block in self.insts[inst].branch_destination().into_iter() {
|
||||
for block_ix in 0..self.insts[inst].branch_destination().len() {
|
||||
let mut block = self.insts[inst].branch_destination()[block_ix];
|
||||
for arg in block.args_slice_mut(&mut self.value_lists) {
|
||||
*arg = values.next().unwrap();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user