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:
@@ -67,11 +67,11 @@ fn legalize_entry_arguments(func: &mut Function, entry: Ebb) {
|
||||
// Keep track of the argument types in the ABI-legalized signature.
|
||||
let mut abi_arg = 0;
|
||||
|
||||
// Process the EBB arguments one at a time, possibly replacing one argument with multiple new
|
||||
// ones. We do this by detaching the entry EBB arguments first.
|
||||
let ebb_args = pos.func.dfg.detach_ebb_args(entry);
|
||||
// Process the EBB parameters one at a time, possibly replacing one argument with multiple new
|
||||
// ones. We do this by detaching the entry EBB parameters first.
|
||||
let ebb_params = pos.func.dfg.detach_ebb_params(entry);
|
||||
let mut old_arg = 0;
|
||||
while let Some(arg) = ebb_args.get(old_arg, &pos.func.dfg.value_lists) {
|
||||
while let Some(arg) = ebb_params.get(old_arg, &pos.func.dfg.value_lists) {
|
||||
old_arg += 1;
|
||||
|
||||
let abi_type = pos.func.signature.argument_types[abi_arg];
|
||||
@@ -79,7 +79,7 @@ fn legalize_entry_arguments(func: &mut Function, entry: Ebb) {
|
||||
if arg_type == abi_type.value_type {
|
||||
// No value translation is necessary, this argument matches the ABI type.
|
||||
// Just use the original EBB argument value. This is the most common case.
|
||||
pos.func.dfg.attach_ebb_arg(entry, arg);
|
||||
pos.func.dfg.attach_ebb_param(entry, arg);
|
||||
match abi_type.purpose {
|
||||
ArgumentPurpose::Normal => {}
|
||||
ArgumentPurpose::StructReturn => {
|
||||
@@ -108,7 +108,7 @@ fn legalize_entry_arguments(func: &mut Function, entry: Ebb) {
|
||||
);
|
||||
if ty == abi_type.value_type {
|
||||
abi_arg += 1;
|
||||
Ok(func.dfg.append_ebb_arg(entry, ty))
|
||||
Ok(func.dfg.append_ebb_param(entry, ty))
|
||||
} else {
|
||||
Err(abi_type)
|
||||
}
|
||||
@@ -155,7 +155,7 @@ fn legalize_entry_arguments(func: &mut Function, entry: Ebb) {
|
||||
|
||||
// Just create entry block values to match here. We will use them in `handle_return_abi()`
|
||||
// below.
|
||||
pos.func.dfg.append_ebb_arg(entry, arg.value_type);
|
||||
pos.func.dfg.append_ebb_param(entry, arg.value_type);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -584,7 +584,7 @@ pub fn handle_return_abi(inst: Inst, func: &mut Function, cfg: &ControlFlowGraph
|
||||
.expect("No matching special purpose argument.");
|
||||
// Get the corresponding entry block value and add it to the return instruction's
|
||||
// arguments.
|
||||
let val = pos.func.dfg.ebb_args(
|
||||
let val = pos.func.dfg.ebb_params(
|
||||
pos.func.layout.entry_block().unwrap(),
|
||||
)
|
||||
[idx];
|
||||
@@ -611,7 +611,9 @@ pub fn handle_return_abi(inst: Inst, func: &mut Function, cfg: &ControlFlowGraph
|
||||
/// stack slot already during legalization.
|
||||
fn spill_entry_arguments(func: &mut Function, entry: Ebb) {
|
||||
for (abi, &arg) in func.signature.argument_types.iter().zip(
|
||||
func.dfg.ebb_args(entry),
|
||||
func.dfg.ebb_params(
|
||||
entry,
|
||||
),
|
||||
)
|
||||
{
|
||||
if let ArgumentLoc::Stack(offset) = abi.location {
|
||||
|
||||
@@ -26,19 +26,10 @@ pub fn expand_global_addr(inst: ir::Inst, func: &mut ir::Function, _cfg: &mut Co
|
||||
|
||||
/// Expand a `global_addr` instruction for a vmctx global.
|
||||
fn vmctx_addr(inst: ir::Inst, func: &mut ir::Function, offset: i64) {
|
||||
// Find the incoming `vmctx` function argument. Start searching from the back since the special
|
||||
// arguments are appended by signature legalization.
|
||||
//
|
||||
// This argument must exist; `vmctx` global variables can not be used in functions with calling
|
||||
// conventions that don't add a `vmctx` argument.
|
||||
let argidx = func.signature
|
||||
.argument_types
|
||||
.iter()
|
||||
.rposition(|abi| abi.purpose == ir::ArgumentPurpose::VMContext)
|
||||
.expect("Need vmctx argument for vmctx global");
|
||||
|
||||
// Get the value representing the `vmctx` argument.
|
||||
let vmctx = func.dfg.ebb_args(func.layout.entry_block().unwrap())[argidx];
|
||||
let vmctx = func.special_arg(ir::ArgumentPurpose::VMContext).expect(
|
||||
"Missing vmctx parameter",
|
||||
);
|
||||
|
||||
// Simply replace the `global_addr` instruction with an `iadd_imm`, reusing the result value.
|
||||
func.dfg.replace(inst).iadd_imm(vmctx, offset);
|
||||
|
||||
@@ -201,7 +201,7 @@ fn expand_select(inst: ir::Inst, func: &mut ir::Function, cfg: &mut ControlFlowG
|
||||
let result = func.dfg.first_result(inst);
|
||||
func.dfg.clear_results(inst);
|
||||
let new_ebb = func.dfg.make_ebb();
|
||||
func.dfg.attach_ebb_arg(new_ebb, result);
|
||||
func.dfg.attach_ebb_param(new_ebb, result);
|
||||
|
||||
func.dfg.replace(inst).brnz(ctrl, new_ebb, &[tval]);
|
||||
let mut pos = FuncCursor::new(func).after_inst(inst);
|
||||
|
||||
@@ -194,7 +194,7 @@ fn split_value(
|
||||
let mut reuse = None;
|
||||
|
||||
match pos.func.dfg.value_def(value) {
|
||||
ValueDef::Res(inst, num) => {
|
||||
ValueDef::Result(inst, num) => {
|
||||
// This is an instruction result. See if the value was created by a `concat`
|
||||
// instruction.
|
||||
if let InstructionData::Binary { opcode, args, .. } = pos.func.dfg[inst] {
|
||||
@@ -204,11 +204,11 @@ fn split_value(
|
||||
}
|
||||
}
|
||||
}
|
||||
ValueDef::Arg(ebb, num) => {
|
||||
// This is an EBB argument. We can split the argument value unless this is the entry
|
||||
ValueDef::Param(ebb, num) => {
|
||||
// This is an EBB parameter. We can split the parameter value unless this is the entry
|
||||
// block.
|
||||
if pos.func.layout.entry_block() != Some(ebb) {
|
||||
// We are going to replace the argument at `num` with two new arguments.
|
||||
// We are going to replace the parameter at `num` with two new arguments.
|
||||
// Determine the new value types.
|
||||
let ty = pos.func.dfg.value_type(value);
|
||||
let split_type = match concat {
|
||||
@@ -217,20 +217,20 @@ fn split_value(
|
||||
_ => panic!("Unhandled concat opcode: {}", concat),
|
||||
};
|
||||
|
||||
// Since the `repairs` stack potentially contains other argument numbers for `ebb`,
|
||||
// avoid shifting and renumbering EBB arguments. It could invalidate other
|
||||
// Since the `repairs` stack potentially contains other parameter numbers for
|
||||
// `ebb`, avoid shifting and renumbering EBB parameters. It could invalidate other
|
||||
// `repairs` entries.
|
||||
//
|
||||
// Replace the original `value` with the low part, and append the high part at the
|
||||
// end of the argument list.
|
||||
let lo = pos.func.dfg.replace_ebb_arg(value, split_type);
|
||||
let hi_num = pos.func.dfg.num_ebb_args(ebb);
|
||||
let hi = pos.func.dfg.append_ebb_arg(ebb, split_type);
|
||||
let lo = pos.func.dfg.replace_ebb_param(value, split_type);
|
||||
let hi_num = pos.func.dfg.num_ebb_params(ebb);
|
||||
let hi = pos.func.dfg.append_ebb_param(ebb, split_type);
|
||||
reuse = Some((lo, hi));
|
||||
|
||||
|
||||
// Now the original value is dangling. Insert a concatenation instruction that can
|
||||
// compute it from the two new arguments. This also serves as a record of what we
|
||||
// compute it from the two new parameters. This also serves as a record of what we
|
||||
// did so a future call to this function doesn't have to redo the work.
|
||||
//
|
||||
// Note that it is safe to move `pos` here since `reuse` was set above, so we don't
|
||||
@@ -243,7 +243,7 @@ fn split_value(
|
||||
hi,
|
||||
);
|
||||
|
||||
// Finally, splitting the EBB argument is not enough. We also have to repair all
|
||||
// Finally, splitting the EBB parameter is not enough. We also have to repair all
|
||||
// of the predecessor instructions that branch here.
|
||||
add_repair(concat, split_type, ebb, num, hi_num, repairs);
|
||||
}
|
||||
@@ -299,7 +299,7 @@ fn resolve_splits(dfg: &ir::DataFlowGraph, value: Value) -> Value {
|
||||
let split_res;
|
||||
let concat_opc;
|
||||
let split_arg;
|
||||
if let ValueDef::Res(inst, num) = dfg.value_def(value) {
|
||||
if let ValueDef::Result(inst, num) = dfg.value_def(value) {
|
||||
split_res = num;
|
||||
concat_opc = match dfg[inst].opcode() {
|
||||
Opcode::Isplit => Opcode::Iconcat,
|
||||
@@ -312,7 +312,7 @@ fn resolve_splits(dfg: &ir::DataFlowGraph, value: Value) -> Value {
|
||||
}
|
||||
|
||||
// See if split_arg is defined by a concatenation instruction.
|
||||
if let ValueDef::Res(inst, _) = dfg.value_def(split_arg) {
|
||||
if let ValueDef::Result(inst, _) = dfg.value_def(split_arg) {
|
||||
if dfg[inst].opcode() == concat_opc {
|
||||
return dfg.inst_args(inst)[split_res];
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user