Use the term "EBB parameter" everywhere.

Add EBB parameter and EBB argument to the langref glossary to clarify
the distinction between formal EBB parameter values and arguments passed
to branches.

- Replace "ebb_arg" with "ebb_param" in function names that deal with
  EBB parameters.
- Rename the ValueDef variants to Result and Param.
- A bunch of other small langref fixes.

No functional changes intended.
This commit is contained in:
Jakob Stoklund Olesen
2017-10-19 14:15:23 -07:00
parent ea68a69f8b
commit 921bcc6c25
30 changed files with 392 additions and 366 deletions

View File

@@ -136,7 +136,7 @@ impl<'short, 'long, Variable> InstBuilderBase<'short> for FuncInstBuilder<'short
}
_ => panic!("should not happen"),
};
self.builder.ebb_args_adjustment(dest_ebb, &args_types);
self.builder.ebb_params_adjustment(dest_ebb, &args_types);
self.builder.declare_successor(dest_ebb, inst);
}
None => {
@@ -273,8 +273,8 @@ where
let basic_block = self.builder.ssa.header_block(ebb);
// Then we change the cursor position.
self.position = Position { ebb, basic_block };
self.ebb_args_adjustment(ebb, jump_args);
self.func.dfg.ebb_args(ebb)
self.ebb_params_adjustment(ebb, jump_args);
self.func.dfg.ebb_params(ebb)
}
/// Declares that all the predecessors of this block are known.
@@ -411,10 +411,10 @@ impl<'a, Variable> FunctionBuilder<'a, Variable>
where
Variable: EntityRef + Default,
{
/// Retrieves all the arguments for an `Ebb` currently inferred from the jump instructions
/// Retrieves all the parameters for an `Ebb` currently inferred from the jump instructions
/// inserted that target it and the SSA construction.
pub fn ebb_args(&self, ebb: Ebb) -> &[Value] {
self.func.dfg.ebb_args(ebb)
pub fn ebb_params(&self, ebb: Ebb) -> &[Value] {
self.func.dfg.ebb_params(ebb)
}
/// Retrieves the signature with reference `sigref` previously added with `import_signature`.
@@ -422,14 +422,14 @@ where
self.func.dfg.signatures.get(sigref)
}
/// Creates an argument for a specific `Ebb` by appending it to the list of already existing
/// arguments.
/// Creates a parameter for a specific `Ebb` by appending it to the list of already existing
/// parameters.
///
/// **Note:** this function has to be called at the creation of the `Ebb` before adding
/// instructions to it, otherwise this could interfere with SSA construction.
pub fn append_ebb_arg(&mut self, ebb: Ebb, ty: Type) -> Value {
pub fn append_ebb_param(&mut self, ebb: Ebb, ty: Type) -> Value {
debug_assert!(self.builder.ebbs[ebb].pristine);
self.func.dfg.append_ebb_arg(ebb, ty)
self.func.dfg.append_ebb_param(ebb, ty)
}
/// Returns the result values of an instruction.
@@ -547,14 +547,14 @@ where
debug_assert!(self.pristine);
for argtyp in &self.func.signature.argument_types {
self.builder.function_args_values.push(
self.func.dfg.append_ebb_arg(ebb, argtyp.value_type),
self.func.dfg.append_ebb_param(ebb, argtyp.value_type),
);
}
self.pristine = false;
}
fn ebb_args_adjustment(&mut self, dest_ebb: Ebb, jump_args: &[Value]) {
fn ebb_params_adjustment(&mut self, dest_ebb: Ebb, jump_args: &[Value]) {
if self.builder.ssa.predecessors(dest_ebb).is_empty() ||
self.builder.ebbs[dest_ebb].pristine
{
@@ -562,12 +562,12 @@ where
// so the jump arguments supplied here are this Ebb' arguments
// However some of the arguments might already be there
// in the Ebb so we have to check they're consistent
let dest_ebb_args_len = {
let dest_ebb_args = self.func.dfg.ebb_args(dest_ebb);
let dest_ebb_params_len = {
let dest_ebb_params = self.func.dfg.ebb_params(dest_ebb);
debug_assert!(
dest_ebb_args
dest_ebb_params
.iter()
.zip(jump_args.iter().take(dest_ebb_args.len()))
.zip(jump_args.iter().take(dest_ebb_params.len()))
.all(|(dest_arg, jump_arg)| {
self.func.dfg.value_type(*jump_arg) ==
self.func.dfg.value_type(*dest_arg)
@@ -575,12 +575,12 @@ where
"the jump argument supplied has not the \
same type as the corresponding dest ebb argument"
);
dest_ebb_args.len()
dest_ebb_params.len()
};
self.builder.ebbs[dest_ebb].user_arg_count = jump_args.len();
for val in jump_args.iter().skip(dest_ebb_args_len) {
for val in jump_args.iter().skip(dest_ebb_params_len) {
let ty = self.func.dfg.value_type(*val);
self.func.dfg.append_ebb_arg(dest_ebb, ty);
self.func.dfg.append_ebb_param(dest_ebb, ty);
}
} else {
// The Ebb already has predecessors
@@ -595,7 +595,7 @@ where
debug_assert!(
jump_args
.iter()
.zip(self.func.dfg.ebb_args(dest_ebb).iter().take(
.zip(self.func.dfg.ebb_params(dest_ebb).iter().take(
self.builder.ebbs[dest_ebb].user_arg_count,
))
.all(|(jump_arg, dest_arg)| {

View File

@@ -210,7 +210,7 @@ enum Call {
/// call `seal_ebb_header_block` on it with the `Function` that you are building.
///
/// This API will give you the correct SSA values to use as arguments of your instructions,
/// as well as modify the jump instruction and `Ebb` headers arguments to account for the SSA
/// as well as modify the jump instruction and `Ebb` headers parameters to account for the SSA
/// Phi functions.
///
impl<Variable> SSABuilder<Variable>
@@ -261,18 +261,18 @@ where
fn use_var_nonlocal(&mut self, func: &mut Function, var: Variable, ty: Type, block: Block) {
let case = match self.blocks[block] {
BlockData::EbbHeader(ref mut data) => {
// The block has multiple predecessors so we append an Ebb argument that
// The block has multiple predecessors so we append an Ebb parameter that
// will serve as a value.
if data.sealed {
if data.predecessors.len() == 1 {
// Only one predecessor, straightforward case
UseVarCases::SealedOnePredecessor(data.predecessors[0].0)
} else {
let val = func.dfg.append_ebb_arg(data.ebb, ty);
let val = func.dfg.append_ebb_param(data.ebb, ty);
UseVarCases::SealedMultiplePredecessors(val, data.ebb)
}
} else {
let val = func.dfg.append_ebb_arg(data.ebb, ty);
let val = func.dfg.append_ebb_param(data.ebb, ty);
data.undef_variables.push((var, val));
UseVarCases::Unsealed(val)
}
@@ -285,7 +285,7 @@ where
self.calls.push(Call::FinishSealedOnePredecessor(block));
self.calls.push(Call::UseVar(pred));
}
// The block has multiple predecessors, we register the ebb argument as the current
// The block has multiple predecessors, we register the EBB parameter as the current
// definition for the variable.
UseVarCases::Unsealed(val) => {
self.def_var(var, val, block);
@@ -293,7 +293,7 @@ where
}
UseVarCases::SealedMultiplePredecessors(val, ebb) => {
// If multiple predecessor we look up a use_var in each of them:
// if they all yield the same value no need for an Ebb argument
// if they all yield the same value no need for an EBB parameter
self.def_var(var, val, block);
self.begin_predecessors_lookup(val, ebb);
}
@@ -385,7 +385,7 @@ where
}
};
// For each undef var we look up values in the predecessors and create an Ebb argument
// For each undef var we look up values in the predecessors and create an EBB parameter
// only if necessary.
for (var, val) in undef_vars {
let ty = func.dfg.value_type(val);
@@ -443,7 +443,7 @@ where
}
/// Examine the values from the predecessors and compute a result value, creating
/// block arguments as needed.
/// block parameters as needed.
fn finish_predecessors_lookup(
&mut self,
func: &mut Function,
@@ -499,7 +499,7 @@ where
// so we don't need to have it as an ebb argument.
// We need to replace all the occurences of val with pred_val but since
// we can't afford a re-writing pass right now we just declare an alias.
func.dfg.remove_ebb_arg(temp_arg_val);
func.dfg.remove_ebb_param(temp_arg_val);
func.dfg.change_to_alias(temp_arg_val, pred_val);
pred_val
}
@@ -908,8 +908,8 @@ mod tests {
ssa.declare_ebb_predecessor(ebb1, block3, jump_ebb2_ebb1);
ssa.seal_ebb_header_block(ebb1, &mut func);
assert_eq!(func.dfg.ebb_args(ebb1)[0], z2);
assert_eq!(func.dfg.ebb_args(ebb1)[1], y3);
assert_eq!(func.dfg.ebb_params(ebb1)[0], z2);
assert_eq!(func.dfg.ebb_params(ebb1)[1], y3);
assert_eq!(func.dfg.resolve_aliases(x3), x1);
}
@@ -1027,9 +1027,9 @@ mod tests {
let block1 = ssa.declare_ebb_header_block(ebb1);
ssa.declare_ebb_predecessor(ebb1, block0, jump_inst);
let z2 = ssa.use_var(&mut func, z_var, I32, block1).0;
assert_eq!(func.dfg.ebb_args(ebb1)[0], z2);
assert_eq!(func.dfg.ebb_params(ebb1)[0], z2);
let x2 = ssa.use_var(&mut func, x_var, I32, block1).0;
assert_eq!(func.dfg.ebb_args(ebb1)[1], x2);
assert_eq!(func.dfg.ebb_params(ebb1)[1], x2);
let x3 = {
let mut cur = FuncCursor::new(&mut func).at_bottom(ebb1);
cur.ins().iadd(x2, z2)
@@ -1037,7 +1037,7 @@ mod tests {
ssa.def_var(x_var, x3, block1);
let x4 = ssa.use_var(&mut func, x_var, I32, block1).0;
let y3 = ssa.use_var(&mut func, y_var, I32, block1).0;
assert_eq!(func.dfg.ebb_args(ebb1)[2], y3);
assert_eq!(func.dfg.ebb_params(ebb1)[2], y3);
let y4 = {
let mut cur = FuncCursor::new(&mut func).at_bottom(ebb1);
cur.ins().isub(y3, x4)
@@ -1051,7 +1051,7 @@ mod tests {
ssa.seal_ebb_header_block(ebb1, &mut func);
// At sealing the "z" argument disappear but the remaining "x" and "y" args have to be
// in the right order.
assert_eq!(func.dfg.ebb_args(ebb1)[1], y3);
assert_eq!(func.dfg.ebb_args(ebb1)[0], x2);
assert_eq!(func.dfg.ebb_params(ebb1)[1], y3);
assert_eq!(func.dfg.ebb_params(ebb1)[0], x2);
}
}