Remove switch_to_block's jump_args argument.

switch_to_block doesn't need its jump_args argument, since jump
arguments are handled by the `jump` instruction and others, rather
than on the switch to a new ebb itself.
This commit is contained in:
Dan Gohman
2017-11-06 16:38:13 -08:00
parent f76640778c
commit cce2384ede
4 changed files with 14 additions and 16 deletions

View File

@@ -266,7 +266,7 @@ where
/// When inserting the terminator instruction (which doesn't have a falltrough to its immediate
/// successor), the block will be declared filled and it will not be possible to append
/// instructions to it.
pub fn switch_to_block(&mut self, ebb: Ebb, jump_args: &[Value]) -> &[Value] {
pub fn switch_to_block(&mut self, ebb: Ebb) {
if !self.params_values_initialized {
self.fill_function_params_values(ebb);
}
@@ -286,8 +286,6 @@ where
let basic_block = self.builder.ssa.header_block(ebb);
// Then we change the cursor position.
self.position = Position { ebb, basic_block };
self.ebb_params_adjustment(ebb, jump_args);
self.func.dfg.ebb_params(ebb)
}
/// Declares that all the predecessors of this block are known.
@@ -706,7 +704,7 @@ mod tests {
builder.declare_var(y, I32);
builder.declare_var(z, I32);
builder.switch_to_block(block0, &[]);
builder.switch_to_block(block0);
if !lazy_seal {
builder.seal_block(block0);
}
@@ -726,7 +724,7 @@ mod tests {
}
builder.ins().jump(block1, &[]);
builder.switch_to_block(block1, &[]);
builder.switch_to_block(block1);
{
let arg1 = builder.use_var(y);
let arg2 = builder.use_var(z);
@@ -748,7 +746,7 @@ mod tests {
builder.ins().return_(&[arg]);
}
builder.switch_to_block(block2, &[]);
builder.switch_to_block(block2);
if !lazy_seal {
builder.seal_block(block2);
}

View File

@@ -76,7 +76,7 @@
//! builder.declare_var(y, I32);
//! builder.declare_var(z, I32);
//!
//! builder.switch_to_block(block0, &[]);
//! builder.switch_to_block(block0);
//! builder.seal_block(block0);
//! {
//! let tmp = builder.param_value(0);
@@ -94,7 +94,7 @@
//! }
//! builder.ins().jump(block1, &[]);
//!
//! builder.switch_to_block(block1, &[]);
//! builder.switch_to_block(block1);
//! {
//! let arg1 = builder.use_var(y);
//! let arg2 = builder.use_var(z);
@@ -116,7 +116,7 @@
//! builder.ins().return_(&[arg]);
//! }
//!
//! builder.switch_to_block(block2, &[]);
//! builder.switch_to_block(block2);
//! builder.seal_block(block2);
//!
//! {

View File

@@ -133,7 +133,7 @@ pub fn translate_operator<FE: FuncEnvironment + ?Sized>(
}
builder.ins().jump(loop_body, &[]);
state.push_loop(loop_body, next, num_return_values(ty));
builder.switch_to_block(loop_body, &[]);
builder.switch_to_block(loop_body);
}
Operator::If { ty } => {
let val = state.pop1();
@@ -170,7 +170,7 @@ pub fn translate_operator<FE: FuncEnvironment + ?Sized>(
let else_ebb = builder.create_ebb();
builder.change_jump_destination(branch_inst, else_ebb);
builder.seal_block(else_ebb);
builder.switch_to_block(else_ebb, &[]);
builder.switch_to_block(else_ebb);
}
Operator::End => {
let frame = state.control_stack.pop().unwrap();
@@ -181,7 +181,7 @@ pub fn translate_operator<FE: FuncEnvironment + ?Sized>(
state.peekn(return_count),
);
}
builder.switch_to_block(frame.following_code(), state.peekn(return_count));
builder.switch_to_block(frame.following_code());
builder.seal_block(frame.following_code());
// If it is a loop we also have to seal the body loop block
match frame {
@@ -316,7 +316,7 @@ pub fn translate_operator<FE: FuncEnvironment + ?Sized>(
.br_destination();
builder.ins().jump(default_ebb, state.peekn(return_count));
for (depth, dest_ebb) in dest_ebbs {
builder.switch_to_block(dest_ebb, &[]);
builder.switch_to_block(dest_ebb);
builder.seal_block(dest_ebb);
let i = state.control_stack.len() - 1 - depth;
let real_dest_ebb = {
@@ -856,7 +856,7 @@ fn translate_unreachable_operator(
// a jump instruction since the code is still unreachable
let frame = control_stack.pop().unwrap();
builder.switch_to_block(frame.following_code(), &[]);
builder.switch_to_block(frame.following_code());
builder.seal_block(frame.following_code());
match frame {
// If it is a loop we also have to seal the body loop block
@@ -900,7 +900,7 @@ fn translate_unreachable_operator(
let else_ebb = builder.create_ebb();
builder.change_jump_destination(branch_inst, else_ebb);
builder.seal_block(else_ebb);
builder.switch_to_block(else_ebb, &[]);
builder.switch_to_block(else_ebb);
// Now we have to split off the stack the values not used
// by unreachable code that hasn't been translated
stack.truncate(original_stack_size);

View File

@@ -82,7 +82,7 @@ impl FuncTranslator {
// This clears the `ILBuilder`.
let mut builder = FunctionBuilder::new(func, &mut self.il_builder);
let entry_block = builder.create_ebb();
builder.switch_to_block(entry_block, &[]); // This also creates values for the arguments.
builder.switch_to_block(entry_block); // This also creates values for the arguments.
builder.seal_block(entry_block);
// Make sure the entry block is inserted in the layout before we make any callbacks to
// `environ`. The callback functions may need to insert things in the entry block.