Update to rustfmt-preview (#348)
* Update to rustfmt-preview. * Run "cargo fmt --all" with rustfmt 0.4.1. rustfmt 0.4.1 is the latest release of rustfmt-preview available on the stable channel. * Fix a long line that rustfmt 0.4.1 can't handle. * Remove unneeded commas left behind by rustfmt.
This commit is contained in:
@@ -133,8 +133,7 @@ fn legalize_entry_params(func: &mut Function, entry: Ebb) {
|
||||
}
|
||||
// The callee-save parameters should not appear until after register allocation is
|
||||
// done.
|
||||
ArgumentPurpose::FramePointer |
|
||||
ArgumentPurpose::CalleeSaved => {
|
||||
ArgumentPurpose::FramePointer | ArgumentPurpose::CalleeSaved => {
|
||||
panic!("Premature callee-saved arg {}", arg);
|
||||
}
|
||||
// These can be meaningfully added by `legalize_signature()`.
|
||||
@@ -174,9 +173,8 @@ fn legalize_inst_results<ResType>(pos: &mut FuncCursor, mut get_abi_type: ResTyp
|
||||
where
|
||||
ResType: FnMut(&Function, usize) -> AbiParam,
|
||||
{
|
||||
let call = pos.current_inst().expect(
|
||||
"Cursor must point to a call instruction",
|
||||
);
|
||||
let call = pos.current_inst()
|
||||
.expect("Cursor must point to a call instruction");
|
||||
|
||||
// We theoretically allow for call instructions that return a number of fixed results before
|
||||
// the call return values. In practice, it doesn't happen.
|
||||
@@ -377,8 +375,8 @@ fn check_call_signature(dfg: &DataFlowGraph, inst: Inst) -> Result<(), SigRef> {
|
||||
};
|
||||
let sig = &dfg.signatures[sig_ref];
|
||||
|
||||
if check_arg_types(dfg, args, &sig.params[..]) &&
|
||||
check_arg_types(dfg, dfg.inst_results(inst), &sig.returns[..])
|
||||
if check_arg_types(dfg, args, &sig.params[..])
|
||||
&& check_arg_types(dfg, dfg.inst_results(inst), &sig.returns[..])
|
||||
{
|
||||
// All types check out.
|
||||
Ok(())
|
||||
@@ -407,14 +405,13 @@ fn legalize_inst_arguments<ArgType>(
|
||||
) where
|
||||
ArgType: FnMut(&Function, usize) -> AbiParam,
|
||||
{
|
||||
let inst = pos.current_inst().expect(
|
||||
"Cursor must point to a call instruction",
|
||||
);
|
||||
let inst = pos.current_inst()
|
||||
.expect("Cursor must point to a call instruction");
|
||||
|
||||
// Lift the value list out of the call instruction so we modify it.
|
||||
let mut vlist = pos.func.dfg[inst].take_value_list().expect(
|
||||
"Call must have a value list",
|
||||
);
|
||||
let mut vlist = pos.func.dfg[inst]
|
||||
.take_value_list()
|
||||
.expect("Call must have a value list");
|
||||
|
||||
// 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.
|
||||
@@ -544,8 +541,8 @@ pub fn handle_return_abi(inst: Inst, func: &mut Function, cfg: &ControlFlowGraph
|
||||
.iter()
|
||||
.rev()
|
||||
.take_while(|&rt| {
|
||||
rt.purpose == ArgumentPurpose::Link || rt.purpose == ArgumentPurpose::StructReturn ||
|
||||
rt.purpose == ArgumentPurpose::VMContext
|
||||
rt.purpose == ArgumentPurpose::Link || rt.purpose == ArgumentPurpose::StructReturn
|
||||
|| rt.purpose == ArgumentPurpose::VMContext
|
||||
})
|
||||
.count();
|
||||
let abi_args = func.signature.returns.len() - special_args;
|
||||
@@ -570,9 +567,9 @@ pub fn handle_return_abi(inst: Inst, func: &mut Function, cfg: &ControlFlowGraph
|
||||
let mut vlist = pos.func.dfg[inst].take_value_list().unwrap();
|
||||
for arg in &pos.func.signature.returns[abi_args..] {
|
||||
match arg.purpose {
|
||||
ArgumentPurpose::Link |
|
||||
ArgumentPurpose::StructReturn |
|
||||
ArgumentPurpose::VMContext => {}
|
||||
ArgumentPurpose::Link
|
||||
| ArgumentPurpose::StructReturn
|
||||
| ArgumentPurpose::VMContext => {}
|
||||
ArgumentPurpose::Normal => panic!("unexpected return value {}", arg),
|
||||
_ => panic!("Unsupported special purpose return value {}", arg),
|
||||
}
|
||||
@@ -587,10 +584,9 @@ 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_params(
|
||||
pos.func.layout.entry_block().unwrap(),
|
||||
)
|
||||
[idx];
|
||||
let val = pos.func
|
||||
.dfg
|
||||
.ebb_params(pos.func.layout.entry_block().unwrap())[idx];
|
||||
debug_assert_eq!(pos.func.dfg.value_type(val), arg.value_type);
|
||||
vlist.push(val, &mut pos.func.dfg.value_lists);
|
||||
}
|
||||
@@ -630,12 +626,12 @@ fn spill_entry_params(func: &mut Function, entry: Ebb) {
|
||||
/// or calls between writing the stack slots and the call instruction. Writing the slots earlier
|
||||
/// could help reduce register pressure before the call.
|
||||
fn spill_call_arguments(pos: &mut FuncCursor) -> bool {
|
||||
let inst = pos.current_inst().expect(
|
||||
"Cursor must point to a call instruction",
|
||||
);
|
||||
let sig_ref = pos.func.dfg.call_signature(inst).expect(
|
||||
"Call instruction expected.",
|
||||
);
|
||||
let inst = pos.current_inst()
|
||||
.expect("Cursor must point to a call instruction");
|
||||
let sig_ref = pos.func
|
||||
.dfg
|
||||
.call_signature(inst)
|
||||
.expect("Call instruction expected.");
|
||||
|
||||
// Start by building a list of stack slots and arguments to be replaced.
|
||||
// This requires borrowing `pos.func.dfg`, so we can't change anything.
|
||||
|
||||
@@ -51,10 +51,7 @@ pub fn expand_call(
|
||||
);
|
||||
}
|
||||
|
||||
func.dfg.replace(inst).CallIndirect(
|
||||
ir::Opcode::CallIndirect,
|
||||
ptr_ty,
|
||||
sig,
|
||||
new_args,
|
||||
);
|
||||
func.dfg
|
||||
.replace(inst)
|
||||
.CallIndirect(ir::Opcode::CallIndirect, ptr_ty, sig, new_args);
|
||||
}
|
||||
|
||||
@@ -34,9 +34,8 @@ pub fn expand_global_addr(
|
||||
/// Expand a `global_addr` instruction for a vmctx global.
|
||||
fn vmctx_addr(inst: ir::Inst, func: &mut ir::Function, offset: i64) {
|
||||
// Get the value representing the `vmctx` argument.
|
||||
let vmctx = func.special_param(ir::ArgumentPurpose::VMContext).expect(
|
||||
"Missing vmctx parameter",
|
||||
);
|
||||
let vmctx = func.special_param(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);
|
||||
|
||||
@@ -67,30 +67,21 @@ fn dynamic_addr(
|
||||
let oob;
|
||||
if size == 1 {
|
||||
// `offset > bound - 1` is the same as `offset >= bound`.
|
||||
oob = pos.ins().icmp(
|
||||
IntCC::UnsignedGreaterThanOrEqual,
|
||||
offset,
|
||||
bound,
|
||||
);
|
||||
oob = pos.ins()
|
||||
.icmp(IntCC::UnsignedGreaterThanOrEqual, offset, bound);
|
||||
} else if size <= min_size {
|
||||
// We know that bound >= min_size, so here we can compare `offset > bound - size` without
|
||||
// wrapping.
|
||||
let adj_bound = pos.ins().iadd_imm(bound, -size);
|
||||
oob = pos.ins().icmp(
|
||||
IntCC::UnsignedGreaterThan,
|
||||
offset,
|
||||
adj_bound,
|
||||
);
|
||||
oob = pos.ins()
|
||||
.icmp(IntCC::UnsignedGreaterThan, offset, adj_bound);
|
||||
} else {
|
||||
// We need an overflow check for the adjusted offset.
|
||||
let size_val = pos.ins().iconst(offset_ty, size);
|
||||
let (adj_offset, overflow) = pos.ins().iadd_cout(offset, size_val);
|
||||
pos.ins().trapnz(overflow, ir::TrapCode::HeapOutOfBounds);
|
||||
oob = pos.ins().icmp(
|
||||
IntCC::UnsignedGreaterThan,
|
||||
adj_offset,
|
||||
bound,
|
||||
);
|
||||
oob = pos.ins()
|
||||
.icmp(IntCC::UnsignedGreaterThan, adj_offset, bound);
|
||||
}
|
||||
pos.ins().trapnz(oob, ir::TrapCode::HeapOutOfBounds);
|
||||
|
||||
@@ -137,17 +128,11 @@ fn static_addr(
|
||||
let oob = if limit & 1 == 1 {
|
||||
// Prefer testing `offset >= limit - 1` when limit is odd because an even number is
|
||||
// likely to be a convenient constant on ARM and other RISC architectures.
|
||||
pos.ins().icmp_imm(
|
||||
IntCC::UnsignedGreaterThanOrEqual,
|
||||
offset,
|
||||
limit - 1,
|
||||
)
|
||||
pos.ins()
|
||||
.icmp_imm(IntCC::UnsignedGreaterThanOrEqual, offset, limit - 1)
|
||||
} else {
|
||||
pos.ins().icmp_imm(
|
||||
IntCC::UnsignedGreaterThan,
|
||||
offset,
|
||||
limit,
|
||||
)
|
||||
pos.ins()
|
||||
.icmp_imm(IntCC::UnsignedGreaterThan, offset, limit)
|
||||
};
|
||||
pos.ins().trapnz(oob, ir::TrapCode::HeapOutOfBounds);
|
||||
}
|
||||
|
||||
@@ -1,18 +1,18 @@
|
||||
//! Expanding instructions as runtime library calls.
|
||||
|
||||
use ir;
|
||||
use ir::{InstBuilder, get_libcall_funcref};
|
||||
use std::vec::Vec;
|
||||
use ir::{get_libcall_funcref, InstBuilder};
|
||||
use isa::TargetIsa;
|
||||
use std::vec::Vec;
|
||||
|
||||
/// Try to expand `inst` as a library call, returning true is successful.
|
||||
pub fn expand_as_libcall(inst: ir::Inst, func: &mut ir::Function, isa: &TargetIsa) -> bool {
|
||||
// Does the opcode/ctrl_type combo even have a well-known runtime library name.
|
||||
let libcall =
|
||||
match ir::LibCall::for_inst(func.dfg[inst].opcode(), func.dfg.ctrl_typevar(inst)) {
|
||||
Some(lc) => lc,
|
||||
None => return false,
|
||||
};
|
||||
let libcall = match ir::LibCall::for_inst(func.dfg[inst].opcode(), func.dfg.ctrl_typevar(inst))
|
||||
{
|
||||
Some(lc) => lc,
|
||||
None => return false,
|
||||
};
|
||||
|
||||
// Now we convert `inst` to a call. First save the arguments.
|
||||
let mut args = Vec::new();
|
||||
|
||||
@@ -27,9 +27,9 @@ mod heap;
|
||||
mod libcall;
|
||||
mod split;
|
||||
|
||||
use self::call::expand_call;
|
||||
use self::globalvar::expand_global_addr;
|
||||
use self::heap::expand_heap_addr;
|
||||
use self::call::expand_call;
|
||||
use self::libcall::expand_as_libcall;
|
||||
|
||||
/// Legalize `inst` for `isa`. Return true if any changes to the code were
|
||||
|
||||
@@ -134,9 +134,9 @@ fn split_any(
|
||||
pos.func.dfg.display_inst(inst, None)
|
||||
);
|
||||
let fixed_args = branch_opc.constraints().fixed_value_arguments();
|
||||
let mut args = pos.func.dfg[inst].take_value_list().expect(
|
||||
"Branches must have value lists.",
|
||||
);
|
||||
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)
|
||||
@@ -236,12 +236,9 @@ fn split_value(
|
||||
// Note that it is safe to move `pos` here since `reuse` was set above, so we don't
|
||||
// need to insert a split instruction before returning.
|
||||
pos.goto_first_inst(ebb);
|
||||
pos.ins().with_result(value).Binary(
|
||||
concat,
|
||||
split_type,
|
||||
lo,
|
||||
hi,
|
||||
);
|
||||
pos.ins()
|
||||
.with_result(value)
|
||||
.Binary(concat, split_type, lo, hi);
|
||||
|
||||
// Finally, splitting the EBB parameter is not enough. We also have to repair all
|
||||
// of the predecessor instructions that branch here.
|
||||
|
||||
Reference in New Issue
Block a user