Update rustfmt to 0.8.4; (#81)

This commit is contained in:
Benjamin Bouvier
2017-05-16 00:10:47 +02:00
committed by Jakob Stoklund Olesen
parent 232fb36d8f
commit 29dc723e25
20 changed files with 120 additions and 176 deletions

View File

@@ -97,9 +97,7 @@ pub fn relax_branches(func: &mut Function, isa: &TargetIsa) {
/// existing `fallthrough` instructions are correct.
fn fallthroughs(func: &mut Function) {
for (ebb, succ) in func.layout.ebbs().adjacent_pairs() {
let term = func.layout
.last_inst(ebb)
.expect("EBB has no terminator.");
let term = func.layout.last_inst(ebb).expect("EBB has no terminator.");
if let InstructionData::Jump {
ref mut opcode,
destination,

View File

@@ -88,8 +88,7 @@ impl DominatorTree {
// Run a finger up the dominator tree from b until we see a.
// Do nothing if b is unreachable.
while rpo_a < self.nodes[ebb_b].rpo_number {
b = self.idom(ebb_b)
.expect("Shouldn't meet unreachable here.");
b = self.idom(ebb_b).expect("Shouldn't meet unreachable here.");
ebb_b = layout.inst_ebb(b).expect("Dominator got removed.");
}

View File

@@ -135,9 +135,7 @@ impl<T: EntityRef> ListPool<T> {
// The `wrapping_sub` handles the special case 0, which is the empty list. This way, the
// cost of the bounds check that we have to pay anyway is co-opted to handle the special
// case of the empty list.
self.data
.get(idx.wrapping_sub(1))
.map(|len| len.index())
self.data.get(idx.wrapping_sub(1)).map(|len| len.index())
}
/// Allocate a storage block with a size given by `sclass`.

View File

@@ -132,8 +132,7 @@ impl<'c, 'fc, 'fd, Array> InstBuilderBase<'fd> for InsertReuseBuilder<'c, 'fc, '
let inst = self.dfg.make_inst(data);
// Make an `Interator<Item = Option<Value>>`.
let ru = self.reuse.as_ref().iter().cloned();
self.dfg
.make_inst_results_reusing(inst, ctrl_typevar, ru);
self.dfg.make_inst_results_reusing(inst, ctrl_typevar, ru);
self.pos.insert_inst(inst);
(inst, self.dfg)
}

View File

@@ -316,37 +316,25 @@ impl DataFlowGraph {
/// Get the fixed value arguments on `inst` as a slice.
pub fn inst_fixed_args(&self, inst: Inst) -> &[Value] {
let fixed_args = self[inst]
.opcode()
.constraints()
.fixed_value_arguments();
let fixed_args = self[inst].opcode().constraints().fixed_value_arguments();
&self.inst_args(inst)[..fixed_args]
}
/// Get the fixed value arguments on `inst` as a mutable slice.
pub fn inst_fixed_args_mut(&mut self, inst: Inst) -> &mut [Value] {
let fixed_args = self[inst]
.opcode()
.constraints()
.fixed_value_arguments();
let fixed_args = self[inst].opcode().constraints().fixed_value_arguments();
&mut self.inst_args_mut(inst)[..fixed_args]
}
/// Get the variable value arguments on `inst` as a slice.
pub fn inst_variable_args(&self, inst: Inst) -> &[Value] {
let fixed_args = self[inst]
.opcode()
.constraints()
.fixed_value_arguments();
let fixed_args = self[inst].opcode().constraints().fixed_value_arguments();
&self.inst_args(inst)[fixed_args..]
}
/// Get the variable value arguments on `inst` as a mutable slice.
pub fn inst_variable_args_mut(&mut self, inst: Inst) -> &mut [Value] {
let fixed_args = self[inst]
.opcode()
.constraints()
.fixed_value_arguments();
let fixed_args = self[inst].opcode().constraints().fixed_value_arguments();
&mut self.inst_args_mut(inst)[fixed_args..]
}

View File

@@ -288,20 +288,20 @@ impl InstructionData {
pub fn analyze_branch<'a>(&'a self, pool: &'a ValueListPool) -> BranchInfo<'a> {
match self {
&InstructionData::Jump {
destination,
ref args,
..
} => BranchInfo::SingleDest(destination, &args.as_slice(pool)),
destination,
ref args,
..
} => BranchInfo::SingleDest(destination, &args.as_slice(pool)),
&InstructionData::Branch {
destination,
ref args,
..
} => BranchInfo::SingleDest(destination, &args.as_slice(pool)[1..]),
destination,
ref args,
..
} => BranchInfo::SingleDest(destination, &args.as_slice(pool)[1..]),
&InstructionData::BranchIcmp {
destination,
ref args,
..
} => BranchInfo::SingleDest(destination, &args.as_slice(pool)[2..]),
destination,
ref args,
..
} => BranchInfo::SingleDest(destination, &args.as_slice(pool)[2..]),
&InstructionData::BranchTable { table, .. } => BranchInfo::Table(table),
_ => BranchInfo::NotABranch,
}
@@ -595,11 +595,7 @@ impl OperandConstraint {
Same => Bound(ctrl_type),
LaneOf => Bound(ctrl_type.lane_type()),
AsBool => Bound(ctrl_type.as_bool()),
HalfWidth => {
Bound(ctrl_type
.half_width()
.expect("invalid type for half_width"))
}
HalfWidth => Bound(ctrl_type.half_width().expect("invalid type for half_width")),
DoubleWidth => {
Bound(ctrl_type
.double_width()

View File

@@ -467,8 +467,7 @@ impl Layout {
/// Remove `inst` from the layout.
pub fn remove_inst(&mut self, inst: Inst) {
let ebb = self.inst_ebb(inst)
.expect("Instruction already removed.");
let ebb = self.inst_ebb(inst).expect("Instruction already removed.");
// Clear the `inst` node and extract links.
let prev;
let next;

View File

@@ -130,8 +130,6 @@ impl EncInfo {
///
/// This will never return `None` for a legal branch encoding.
pub fn branch_range(&self, enc: Encoding) -> Option<BranchRange> {
self.sizing
.get(enc.recipe())
.and_then(|s| s.branch_range)
self.sizing.get(enc.recipe()).and_then(|s| s.branch_range)
}
}

View File

@@ -65,17 +65,9 @@ mod tests {
.adjacent_pairs()
.collect::<Vec<_>>(),
vec![(2, 3), (3, 4)]);
assert_eq!([3, 4]
.iter()
.cloned()
.adjacent_pairs()
.collect::<Vec<_>>(),
assert_eq!([3, 4].iter().cloned().adjacent_pairs().collect::<Vec<_>>(),
vec![(3, 4)]);
assert_eq!([4]
.iter()
.cloned()
.adjacent_pairs()
.collect::<Vec<_>>(),
assert_eq!([4].iter().cloned().adjacent_pairs().collect::<Vec<_>>(),
vec![]);
assert_eq!([]
.iter()

View File

@@ -251,9 +251,7 @@ fn convert_from_abi<GetArg>(dfg: &mut DataFlowGraph,
assert!(!ty.is_int());
let abi_ty = Type::int(ty.bits()).expect("Invalid type for conversion");
let arg = convert_from_abi(dfg, pos, abi_ty, None, get_arg);
dfg.ins(pos)
.with_results([into_result])
.bitcast(ty, arg)
dfg.ins(pos).with_results([into_result]).bitcast(ty, arg)
}
// ABI argument is a sign-extended version of the value we want.
ValueConversion::Sext(abi_ty) => {
@@ -261,18 +259,14 @@ fn convert_from_abi<GetArg>(dfg: &mut DataFlowGraph,
// TODO: Currently, we don't take advantage of the ABI argument being sign-extended.
// We could insert an `assert_sreduce` which would fold with a following `sextend` of
// this value.
dfg.ins(pos)
.with_results([into_result])
.ireduce(ty, arg)
dfg.ins(pos).with_results([into_result]).ireduce(ty, arg)
}
ValueConversion::Uext(abi_ty) => {
let arg = convert_from_abi(dfg, pos, abi_ty, None, get_arg);
// TODO: Currently, we don't take advantage of the ABI argument being sign-extended.
// We could insert an `assert_ureduce` which would fold with a following `uextend` of
// this value.
dfg.ins(pos)
.with_results([into_result])
.ireduce(ty, arg)
dfg.ins(pos).with_results([into_result]).ireduce(ty, arg)
}
}
}

View File

@@ -137,21 +137,21 @@ mod tests {
// Register classes for testing.
const GPR: RegClass = &RegClassData {
name: "GPR",
index: 0,
width: 1,
first: 28,
subclasses: 0,
mask: [0xf0000000, 0x0000000f, 0],
};
name: "GPR",
index: 0,
width: 1,
first: 28,
subclasses: 0,
mask: [0xf0000000, 0x0000000f, 0],
};
const DPR: RegClass = &RegClassData {
name: "DPR",
index: 0,
width: 2,
first: 28,
subclasses: 0,
mask: [0x50000000, 0x0000000a, 0],
};
name: "DPR",
index: 0,
width: 2,
first: 28,
subclasses: 0,
mask: [0x50000000, 0x0000000a, 0],
};
#[test]
fn put_and_take() {

View File

@@ -100,10 +100,10 @@ mod tests {
divs.regmove(v1, 10, 12);
assert_eq!(divs.diversion(v1),
Some(&Diversion {
value: v1,
from: 10,
to: 12,
}));
value: v1,
from: 10,
to: 12,
}));
assert_eq!(divs.diversion(v2), None);
divs.regmove(v1, 12, 11);

View File

@@ -414,8 +414,7 @@ impl Solver {
if self.inputs_done {
self.regs_out.free(constraint, from);
}
self.vars
.push(Variable::new_live(value, constraint, from));
self.vars.push(Variable::new_live(value, constraint, from));
}
/// Check for conflicts between fixed input assignments and existing live values.

View File

@@ -234,20 +234,20 @@ impl<'a> Verifier<'a> {
self.verify_value_list(inst, args)?;
}
&Jump {
destination,
ref args,
..
} |
destination,
ref args,
..
} |
&Branch {
destination,
ref args,
..
} |
destination,
ref args,
..
} |
&BranchIcmp {
destination,
ref args,
..
} => {
destination,
ref args,
..
} => {
self.verify_ebb(inst, destination)?;
self.verify_value_list(inst, args)?;
}
@@ -381,8 +381,7 @@ impl<'a> Verifier<'a> {
ebb);
}
// The defining EBB dominates the instruction using this value.
if !self.domtree
.ebb_dominates(ebb, loc_inst, &self.func.layout) {
if !self.domtree.ebb_dominates(ebb, loc_inst, &self.func.layout) {
return err!(loc_inst, "uses value arg from non-dominating {}", ebb);
}
}
@@ -639,10 +638,7 @@ impl<'a> Verifier<'a> {
return err!(ebb, "cfg had unexpected successor(s) {:?}", excess_succs);
}
expected_preds.extend(self.cfg
.get_predecessors(ebb)
.iter()
.map(|&(_, inst)| inst));
expected_preds.extend(self.cfg.get_predecessors(ebb).iter().map(|&(_, inst)| inst));
got_preds.extend(cfg.get_predecessors(ebb).iter().map(|&(_, inst)| inst));
let missing_preds: Vec<Inst> = expected_preds.difference(&got_preds).cloned().collect();