Browse Source

Update rustfmt to 0.8.4; (#81)

pull/3/head
Benjamin Bouvier 8 years ago
committed by Jakob Stoklund Olesen
parent
commit
a2fd9cf0cc
  1. 2
      check-rustfmt.sh
  2. 4
      lib/cretonne/src/binemit/relaxation.rs
  3. 3
      lib/cretonne/src/dominator_tree.rs
  4. 4
      lib/cretonne/src/entity_list.rs
  5. 3
      lib/cretonne/src/ir/builder.rs
  6. 20
      lib/cretonne/src/ir/dfg.rs
  7. 6
      lib/cretonne/src/ir/instructions.rs
  8. 3
      lib/cretonne/src/ir/layout.rs
  9. 4
      lib/cretonne/src/isa/encoding.rs
  10. 12
      lib/cretonne/src/iterators.rs
  11. 12
      lib/cretonne/src/legalizer/boundary.rs
  12. 3
      lib/cretonne/src/regalloc/solver.rs
  13. 8
      lib/cretonne/src/verifier/mod.rs
  14. 6
      lib/filecheck/src/checker.rs
  15. 26
      lib/reader/src/parser.rs
  16. 4
      src/filetest/concurrent.rs
  17. 4
      src/filetest/runner.rs

2
check-rustfmt.sh

@ -15,7 +15,7 @@
# With the --install option, also tries to install the right version. # With the --install option, also tries to install the right version.
# This version should always be bumped to the newest version available. # This version should always be bumped to the newest version available.
VERS="0.8.3" VERS="0.8.4"
if cargo install --list | grep -q "^rustfmt v$VERS"; then if cargo install --list | grep -q "^rustfmt v$VERS"; then
exit 0 exit 0

4
lib/cretonne/src/binemit/relaxation.rs

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

3
lib/cretonne/src/dominator_tree.rs

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

4
lib/cretonne/src/entity_list.rs

@ -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 // 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 // cost of the bounds check that we have to pay anyway is co-opted to handle the special
// case of the empty list. // case of the empty list.
self.data self.data.get(idx.wrapping_sub(1)).map(|len| len.index())
.get(idx.wrapping_sub(1))
.map(|len| len.index())
} }
/// Allocate a storage block with a size given by `sclass`. /// Allocate a storage block with a size given by `sclass`.

3
lib/cretonne/src/ir/builder.rs

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

20
lib/cretonne/src/ir/dfg.rs

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

6
lib/cretonne/src/ir/instructions.rs

@ -595,11 +595,7 @@ impl OperandConstraint {
Same => Bound(ctrl_type), Same => Bound(ctrl_type),
LaneOf => Bound(ctrl_type.lane_type()), LaneOf => Bound(ctrl_type.lane_type()),
AsBool => Bound(ctrl_type.as_bool()), AsBool => Bound(ctrl_type.as_bool()),
HalfWidth => { HalfWidth => Bound(ctrl_type.half_width().expect("invalid type for half_width")),
Bound(ctrl_type
.half_width()
.expect("invalid type for half_width"))
}
DoubleWidth => { DoubleWidth => {
Bound(ctrl_type Bound(ctrl_type
.double_width() .double_width()

3
lib/cretonne/src/ir/layout.rs

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

4
lib/cretonne/src/isa/encoding.rs

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

12
lib/cretonne/src/iterators.rs

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

12
lib/cretonne/src/legalizer/boundary.rs

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

3
lib/cretonne/src/regalloc/solver.rs

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

8
lib/cretonne/src/verifier/mod.rs

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

6
lib/filecheck/src/checker.rs

@ -416,11 +416,9 @@ mod tests {
Ok(true)); Ok(true));
assert_eq!(b.directive("regex: X = tommy").map_err(e2s), assert_eq!(b.directive("regex: X = tommy").map_err(e2s),
Err("expected '=' after variable 'X' in regex: X = tommy".to_string())); Err("expected '=' after variable 'X' in regex: X = tommy".to_string()));
assert_eq!(b.directive("[arm]not: patt $x $(y) here") assert_eq!(b.directive("[arm]not: patt $x $(y) here").map_err(e2s),
.map_err(e2s),
Ok(true)); Ok(true));
assert_eq!(b.directive("[x86]sameln: $x $(y=[^]]*) there") assert_eq!(b.directive("[x86]sameln: $x $(y=[^]]*) there").map_err(e2s),
.map_err(e2s),
Ok(true)); Ok(true));
// Windows line ending sneaking in. // Windows line ending sneaking in.
assert_eq!(b.directive("regex: Y=foo\r").map_err(e2s), Ok(true)); assert_eq!(b.directive("regex: Y=foo\r").map_err(e2s), Ok(true));

26
lib/reader/src/parser.rs

@ -29,12 +29,7 @@ use sourcemap::{SourceMap, MutableSourceMap};
/// ///
/// Any test commands or ISA declarations are ignored. /// Any test commands or ISA declarations are ignored.
pub fn parse_functions(text: &str) -> Result<Vec<Function>> { pub fn parse_functions(text: &str) -> Result<Vec<Function>> {
parse_test(text).map(|file| { parse_test(text).map(|file| file.functions.into_iter().map(|(func, _)| func).collect())
file.functions
.into_iter()
.map(|(func, _)| func)
.collect()
})
} }
/// Parse the entire `text` as a test case file. /// Parse the entire `text` as a test case file.
@ -753,9 +748,7 @@ impl<'a> Parser<'a> {
sig.return_types = self.parse_argument_list(unique_isa)?; sig.return_types = self.parse_argument_list(unique_isa)?;
} }
if sig.argument_types if sig.argument_types.iter().all(|a| a.location.is_assigned()) {
.iter()
.all(|a| a.location.is_assigned()) {
sig.compute_argument_bytes(); sig.compute_argument_bytes();
} }
@ -1319,8 +1312,7 @@ impl<'a> Parser<'a> {
inst_data: &InstructionData) inst_data: &InstructionData)
-> Result<Type> { -> Result<Type> {
let constraints = opcode.constraints(); let constraints = opcode.constraints();
let ctrl_type = let ctrl_type = match explicit_ctrl_type {
match explicit_ctrl_type {
Some(t) => t, Some(t) => t,
None => { None => {
if constraints.use_typevar_operand() { if constraints.use_typevar_operand() {
@ -1333,13 +1325,16 @@ impl<'a> Parser<'a> {
let ctrl_src_value = inst_data let ctrl_src_value = inst_data
.typevar_operand(&ctx.function.dfg.value_lists) .typevar_operand(&ctx.function.dfg.value_lists)
.expect("Constraints <-> Format inconsistency"); .expect("Constraints <-> Format inconsistency");
ctx.function.dfg.value_type(match ctx.map.get_value(ctrl_src_value) { ctx.function
.dfg
.value_type(match ctx.map.get_value(ctrl_src_value) {
Some(v) => v, Some(v) => v,
None => { None => {
if let Some(v) = ctx.aliases if let Some(v) = ctx.aliases
.get(&ctrl_src_value) .get(&ctrl_src_value)
.and_then(|&(aliased, _)| ctx.map.get_value(aliased)) .and_then(|&(aliased, _)| {
{ ctx.map.get_value(aliased)
}) {
v v
} else { } else {
return err!(self.loc, return err!(self.loc,
@ -1616,8 +1611,7 @@ impl<'a> Parser<'a> {
InstructionFormat::BranchTable => { InstructionFormat::BranchTable => {
let arg = self.match_value("expected SSA value operand")?; let arg = self.match_value("expected SSA value operand")?;
self.match_token(Token::Comma, "expected ',' between operands")?; self.match_token(Token::Comma, "expected ',' between operands")?;
let table = self.match_jt() let table = self.match_jt().and_then(|num| ctx.get_jt(num, &self.loc))?;
.and_then(|num| ctx.get_jt(num, &self.loc))?;
InstructionData::BranchTable { opcode, arg, table } InstructionData::BranchTable { opcode, arg, table }
} }
InstructionFormat::StackLoad => { InstructionFormat::StackLoad => {

4
src/filetest/concurrent.rs

@ -119,9 +119,7 @@ fn worker_thread(thread_num: usize,
// Tell them we're starting this job. // Tell them we're starting this job.
// The receiver should always be present for this as long as we have jobs. // The receiver should always be present for this as long as we have jobs.
replies replies.send(Reply::Starting { jobid, thread_num }).unwrap();
.send(Reply::Starting { jobid, thread_num })
.unwrap();
let result = catch_unwind(|| runone::run(path.as_path())).unwrap_or_else(|e| { let result = catch_unwind(|| runone::run(path.as_path())).unwrap_or_else(|e| {
// The test panicked, leaving us a `Box<Any>`. // The test panicked, leaving us a `Box<Any>`.

4
src/filetest/runner.rs

@ -207,9 +207,7 @@ impl TestRunner {
} }
// Check for any asynchronous replies without blocking. // Check for any asynchronous replies without blocking.
while let Some(reply) = self.threads while let Some(reply) = self.threads.as_mut().and_then(ConcurrentRunner::try_get) {
.as_mut()
.and_then(ConcurrentRunner::try_get) {
self.handle_reply(reply); self.handle_reply(reply);
} }
} }

Loading…
Cancel
Save