Upgrade to rustfmt 0.8.0.

Lots of changes this time.

Worked around what looks like a rustfmt bug in parse_inst_operands where
a large match was nested inside Ok().
This commit is contained in:
Jakob Stoklund Olesen
2017-03-14 10:48:05 -07:00
parent 849f3f3e9b
commit 32709a56ca
37 changed files with 462 additions and 377 deletions

View File

@@ -89,17 +89,17 @@ impl Display for IntCC {
fn fmt(&self, f: &mut Formatter) -> fmt::Result {
use self::IntCC::*;
f.write_str(match self {
&Equal => "eq",
&NotEqual => "ne",
&SignedGreaterThan => "sgt",
&SignedGreaterThanOrEqual => "sge",
&SignedLessThan => "slt",
&SignedLessThanOrEqual => "sle",
&UnsignedGreaterThan => "ugt",
&UnsignedGreaterThanOrEqual => "uge",
&UnsignedLessThan => "ult",
&UnsignedLessThanOrEqual => "ule",
})
&Equal => "eq",
&NotEqual => "ne",
&SignedGreaterThan => "sgt",
&SignedGreaterThanOrEqual => "sge",
&SignedLessThan => "slt",
&SignedLessThanOrEqual => "sle",
&UnsignedGreaterThan => "ugt",
&UnsignedGreaterThanOrEqual => "uge",
&UnsignedLessThan => "ult",
&UnsignedLessThanOrEqual => "ule",
})
}
}
@@ -220,21 +220,21 @@ impl Display for FloatCC {
fn fmt(&self, f: &mut Formatter) -> fmt::Result {
use self::FloatCC::*;
f.write_str(match self {
&Ordered => "ord",
&Unordered => "uno",
&Equal => "eq",
&NotEqual => "ne",
&OrderedNotEqual => "one",
&UnorderedOrEqual => "ueq",
&LessThan => "lt",
&LessThanOrEqual => "le",
&GreaterThan => "gt",
&GreaterThanOrEqual => "ge",
&UnorderedOrLessThan => "ult",
&UnorderedOrLessThanOrEqual => "ule",
&UnorderedOrGreaterThan => "ugt",
&UnorderedOrGreaterThanOrEqual => "uge",
})
&Ordered => "ord",
&Unordered => "uno",
&Equal => "eq",
&NotEqual => "ne",
&OrderedNotEqual => "one",
&UnorderedOrEqual => "ueq",
&LessThan => "lt",
&LessThanOrEqual => "le",
&GreaterThan => "gt",
&GreaterThanOrEqual => "ge",
&UnorderedOrLessThan => "ult",
&UnorderedOrLessThanOrEqual => "ule",
&UnorderedOrGreaterThan => "ugt",
&UnorderedOrGreaterThanOrEqual => "uge",
})
}
}

View File

@@ -180,19 +180,20 @@ impl DataFlowGraph {
for _ in 0..self.insts.len() {
v = self.resolve_aliases(match v.expand() {
Direct(inst) => {
match self[inst] {
InstructionData::Unary { opcode, arg, .. } => {
match opcode {
Opcode::Copy | Opcode::Spill | Opcode::Fill => arg,
_ => return v,
}
}
_ => return v,
}
}
_ => return v,
});
Direct(inst) => {
match self[inst] {
InstructionData::Unary { opcode, arg, .. } => {
match opcode {
Opcode::Copy | Opcode::Spill |
Opcode::Fill => arg,
_ => return v,
}
}
_ => return v,
}
}
_ => return v,
});
}
panic!("Copy loop detected for {}", value);
}
@@ -361,11 +362,11 @@ impl DataFlowGraph {
for res_idx in (0..var_results).rev() {
if let Some(ty) = first_type {
head = Some(self.make_value(ValueData::Inst {
ty: ty,
num: (total_results - rev_num) as u16,
inst: inst,
next: head.into(),
}));
ty: ty,
num: (total_results - rev_num) as u16,
inst: inst,
next: head.into(),
}));
rev_num += 1;
}
first_type = Some(self.signatures[sig].return_types[res_idx].value_type);
@@ -376,11 +377,11 @@ impl DataFlowGraph {
for res_idx in (0..fixed_results).rev() {
if let Some(ty) = first_type {
head = Some(self.make_value(ValueData::Inst {
ty: ty,
num: (total_results - rev_num) as u16,
inst: inst,
next: head.into(),
}));
ty: ty,
num: (total_results - rev_num) as u16,
inst: inst,
next: head.into(),
}));
rev_num += 1;
}
first_type = Some(constraints.result_type(res_idx, ctrl_typevar));
@@ -474,11 +475,11 @@ impl DataFlowGraph {
// Not a fixed result, try to extract a return type from the call signature.
self.call_signature(inst).and_then(|sigref| {
self.signatures[sigref]
.return_types
.get(result_idx - fixed_results)
.map(|&arg| arg.value_type)
})
self.signatures[sigref]
.return_types
.get(result_idx - fixed_results)
.map(|&arg| arg.value_type)
})
}
}
@@ -523,11 +524,11 @@ impl DataFlowGraph {
/// Append an argument with type `ty` to `ebb`.
pub fn append_ebb_arg(&mut self, ebb: Ebb, ty: Type) -> Value {
let val = self.make_value(ValueData::Arg {
ty: ty,
ebb: ebb,
num: 0,
next: None.into(),
});
ty: ty,
ebb: ebb,
num: 0,
next: None.into(),
});
self.put_ebb_arg(ebb, val);
val
}

View File

@@ -50,9 +50,11 @@ impl Signature {
let bytes = self.argument_types
.iter()
.filter_map(|arg| match arg.location {
ArgumentLoc::Stack(offset) => Some(offset + arg.value_type.bits() as u32 / 8),
_ => None,
})
ArgumentLoc::Stack(offset) => {
Some(offset + arg.value_type.bits() as u32 / 8)
}
_ => None,
})
.fold(0, cmp::max);
self.argument_bytes = Some(bytes);
}

View File

@@ -252,20 +252,20 @@ fn parse_float(s: &str, w: u8, t: u8) -> Result<u64, &'static str> {
if s2.starts_with("NaN:0x") {
// Quiet NaN with payload.
return match u64::from_str_radix(&s2[6..], 16) {
Ok(payload) if payload < quiet_bit => {
Ok(sign_bit | max_e_bits | quiet_bit | payload)
}
_ => Err("Invalid NaN payload"),
};
Ok(payload) if payload < quiet_bit => {
Ok(sign_bit | max_e_bits | quiet_bit | payload)
}
_ => Err("Invalid NaN payload"),
};
}
if s2.starts_with("sNaN:0x") {
// Signaling NaN with payload.
return match u64::from_str_radix(&s2[7..], 16) {
Ok(payload) if 0 < payload && payload < quiet_bit => {
Ok(sign_bit | max_e_bits | payload)
}
_ => Err("Invalid sNaN payload"),
};
Ok(payload) if 0 < payload && payload < quiet_bit => {
Ok(sign_bit | max_e_bits | payload)
}
_ => Err("Invalid sNaN payload"),
};
}
return Err("Float must be hexadecimal");

View File

@@ -66,7 +66,10 @@ impl JumpTableData {
///
/// This returns an iterator that skips any empty slots in the table.
pub fn entries<'a>(&'a self) -> Entries {
Entries(self.table.iter().cloned().enumerate())
Entries(self.table
.iter()
.cloned()
.enumerate())
}
/// Access the whole table as a mutable slice.
@@ -101,7 +104,10 @@ impl Display for JumpTableData {
Some(first) => write!(fmt, "jump_table {}", first)?,
}
for dest in self.table.iter().skip(1).map(|e| e.expand()) {
for dest in self.table
.iter()
.skip(1)
.map(|e| e.expand()) {
match dest {
None => write!(fmt, ", 0")?,
Some(ebb) => write!(fmt, ", {}", ebb)?,

View File

@@ -125,10 +125,7 @@ impl Layout {
/// Get the last sequence number in `ebb`.
fn last_ebb_seq(&self, ebb: Ebb) -> SequenceNumber {
// Get the seq of the last instruction if it exists, otherwise use the EBB header seq.
self.ebbs[ebb]
.last_inst
.map(|inst| self.insts[inst].seq)
.unwrap_or(self.ebbs[ebb].seq)
self.ebbs[ebb].last_inst.map(|inst| self.insts[inst].seq).unwrap_or(self.ebbs[ebb].seq)
}
/// Assign a valid sequence number to `ebb` such that the numbers are still monotonic. This may
@@ -439,8 +436,8 @@ impl Layout {
/// Insert `inst` before the instruction `before` in the same EBB.
pub fn insert_inst(&mut self, inst: Inst, before: Inst) {
assert_eq!(self.inst_ebb(inst), None);
let ebb = self.inst_ebb(before)
.expect("Instruction before insertion point not in the layout");
let ebb =
self.inst_ebb(before).expect("Instruction before insertion point not in the layout");
let after = self.insts[before].prev;
{
let inst_node = self.insts.ensure(inst);
@@ -488,8 +485,8 @@ impl Layout {
/// i4
/// ```
pub fn split_ebb(&mut self, new_ebb: Ebb, before: Inst) {
let old_ebb = self.inst_ebb(before)
.expect("The `before` instruction must be in the layout");
let old_ebb =
self.inst_ebb(before).expect("The `before` instruction must be in the layout");
assert!(!self.is_ebb_inserted(new_ebb));
// Insert new_ebb after old_ebb.

View File

@@ -348,7 +348,12 @@ mod tests {
assert_eq!(big.bits(), 64 * 256);
assert_eq!(big.half_vector().unwrap().to_string(), "f64x128");
assert_eq!(B1.by(2).unwrap().half_vector().unwrap().to_string(), "b1");
assert_eq!(B1.by(2)
.unwrap()
.half_vector()
.unwrap()
.to_string(),
"b1");
assert_eq!(I32.half_vector(), None);
assert_eq!(VOID.half_vector(), None);
@@ -378,7 +383,12 @@ mod tests {
assert_eq!(B1.by(8).unwrap().to_string(), "b1x8");
assert_eq!(B8.by(1).unwrap().to_string(), "b8");
assert_eq!(B16.by(256).unwrap().to_string(), "b16x256");
assert_eq!(B32.by(4).unwrap().by(2).unwrap().to_string(), "b32x8");
assert_eq!(B32.by(4)
.unwrap()
.by(2)
.unwrap()
.to_string(),
"b32x8");
assert_eq!(B64.by(8).unwrap().to_string(), "b64x8");
assert_eq!(I8.by(64).unwrap().to_string(), "i8x64");
assert_eq!(F64.by(2).unwrap().to_string(), "f64x2");