Prefix fixed_results/fixed_value_arguments with num to indicate they return a usize;
This commit is contained in:
committed by
Dan Gohman
parent
e13b0886dc
commit
f896bfb946
@@ -201,8 +201,14 @@ where
|
||||
|
||||
// We theoretically allow for call instructions that return a number of fixed results before
|
||||
// the call return values. In practice, it doesn't happen.
|
||||
let fixed_results = pos.func.dfg[call].opcode().constraints().fixed_results();
|
||||
debug_assert_eq!(fixed_results, 0, "Fixed results on calls not supported");
|
||||
debug_assert_eq!(
|
||||
pos.func.dfg[call]
|
||||
.opcode()
|
||||
.constraints()
|
||||
.num_fixed_results(),
|
||||
0,
|
||||
"Fixed results on calls not supported"
|
||||
);
|
||||
|
||||
let results = pos.func.dfg.detach_results(call);
|
||||
let mut next_res = 0;
|
||||
@@ -440,11 +446,11 @@ fn legalize_inst_arguments<ArgType>(
|
||||
// The value list contains all arguments to the instruction, including the callee on an
|
||||
// indirect call which isn't part of the call arguments that must match the ABI signature.
|
||||
// Figure out how many fixed values are at the front of the list. We won't touch those.
|
||||
let fixed_values = pos.func.dfg[inst]
|
||||
let num_fixed_values = pos.func.dfg[inst]
|
||||
.opcode()
|
||||
.constraints()
|
||||
.fixed_value_arguments();
|
||||
let have_args = vlist.len(&pos.func.dfg.value_lists) - fixed_values;
|
||||
.num_fixed_value_arguments();
|
||||
let have_args = vlist.len(&pos.func.dfg.value_lists) - num_fixed_values;
|
||||
|
||||
// Grow the value list to the right size and shift all the existing arguments to the right.
|
||||
// This lets us write the new argument values into the list without overwriting the old
|
||||
@@ -472,11 +478,11 @@ fn legalize_inst_arguments<ArgType>(
|
||||
// [FFFFNNNNNNNNNNNNNNNNNNNN]
|
||||
//
|
||||
vlist.grow_at(
|
||||
fixed_values,
|
||||
num_fixed_values,
|
||||
abi_args - have_args,
|
||||
&mut pos.func.dfg.value_lists,
|
||||
);
|
||||
let old_arg_offset = fixed_values + abi_args - have_args;
|
||||
let old_arg_offset = num_fixed_values + abi_args - have_args;
|
||||
|
||||
let mut abi_arg = 0;
|
||||
for old_arg in 0..have_args {
|
||||
@@ -487,7 +493,7 @@ fn legalize_inst_arguments<ArgType>(
|
||||
let abi_type = get_abi_type(func, abi_arg);
|
||||
if func.dfg.value_type(arg) == abi_type.value_type {
|
||||
// This is the argument type we need.
|
||||
vlist.as_mut_slice(&mut func.dfg.value_lists)[fixed_values + abi_arg] = arg;
|
||||
vlist.as_mut_slice(&mut func.dfg.value_lists)[num_fixed_values + abi_arg] = arg;
|
||||
abi_arg += 1;
|
||||
Ok(())
|
||||
} else {
|
||||
|
||||
@@ -133,14 +133,14 @@ fn split_any(
|
||||
"Predecessor not a branch: {}",
|
||||
pos.func.dfg.display_inst(inst, None)
|
||||
);
|
||||
let fixed_args = branch_opc.constraints().fixed_value_arguments();
|
||||
let num_fixed_args = branch_opc.constraints().num_fixed_value_arguments();
|
||||
let mut args = pos.func.dfg[inst]
|
||||
.take_value_list()
|
||||
.expect("Branches must have value lists.");
|
||||
let num_args = args.len(&pos.func.dfg.value_lists);
|
||||
// Get the old value passed to the EBB argument we're repairing.
|
||||
let old_arg = args
|
||||
.get(fixed_args + repair.num, &pos.func.dfg.value_lists)
|
||||
.get(num_fixed_args + repair.num, &pos.func.dfg.value_lists)
|
||||
.expect("Too few branch arguments");
|
||||
|
||||
// It's possible that the CFG's predecessor list has duplicates. Detect them here.
|
||||
@@ -155,21 +155,23 @@ fn split_any(
|
||||
|
||||
// The `lo` part replaces the original argument.
|
||||
*args
|
||||
.get_mut(fixed_args + repair.num, &mut pos.func.dfg.value_lists)
|
||||
.get_mut(num_fixed_args + repair.num, &mut pos.func.dfg.value_lists)
|
||||
.unwrap() = lo;
|
||||
|
||||
// The `hi` part goes at the end. Since multiple repairs may have been scheduled to the
|
||||
// same EBB, there could be multiple arguments missing.
|
||||
if num_args > fixed_args + repair.hi_num {
|
||||
if num_args > num_fixed_args + repair.hi_num {
|
||||
*args
|
||||
.get_mut(fixed_args + repair.hi_num, &mut pos.func.dfg.value_lists)
|
||||
.unwrap() = hi;
|
||||
.get_mut(
|
||||
num_fixed_args + repair.hi_num,
|
||||
&mut pos.func.dfg.value_lists,
|
||||
).unwrap() = hi;
|
||||
} else {
|
||||
// We need to append one or more arguments. If we're adding more than one argument,
|
||||
// there must be pending repairs on the stack that will fill in the correct values
|
||||
// instead of `hi`.
|
||||
args.extend(
|
||||
iter::repeat(hi).take(1 + fixed_args + repair.hi_num - num_args),
|
||||
iter::repeat(hi).take(1 + num_fixed_args + repair.hi_num - num_args),
|
||||
&mut pos.func.dfg.value_lists,
|
||||
);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user