rustfmt 0.8.1

This commit is contained in:
Jakob Stoklund Olesen
2017-04-05 09:00:11 -07:00
parent e641c97670
commit 1984c96f7c
38 changed files with 497 additions and 334 deletions

View File

@@ -232,7 +232,9 @@ impl<'a> Context<'a> {
if let Affinity::Reg(rc_index) = lv.affinity {
let regclass = self.reginfo.rc(rc_index);
// TODO: Fall back to a top-level super-class. Sub-classes are only hints.
let regunit = regs.iter(regclass).next().expect("Out of registers for arguments");
let regunit = regs.iter(regclass)
.next()
.expect("Out of registers for arguments");
regs.take(regclass, regunit);
*locations.ensure(lv.value) = ValueLoc::Reg(regunit);
}

View File

@@ -52,6 +52,7 @@ impl Context {
// TODO: Second pass: Spilling.
// Third pass: Reload and coloring.
self.coloring.run(isa, func, domtree, &mut self.liveness, &mut self.tracker);
self.coloring
.run(isa, func, domtree, &mut self.liveness, &mut self.tracker);
}
}

View File

@@ -68,11 +68,12 @@ impl LiveValueVec {
/// Add a new live value to `values`.
fn push(&mut self, value: Value, endpoint: Inst, affinity: Affinity) {
self.values.push(LiveValue {
value: value,
endpoint: endpoint,
affinity: affinity,
});
self.values
.push(LiveValue {
value: value,
endpoint: endpoint,
affinity: affinity,
});
}
/// Remove all elements.
@@ -163,11 +164,14 @@ impl LiveValueTracker {
// If the immediate dominator exits, we must have a stored list for it. This is a
// requirement to the order EBBs are visited: All dominators must have been processed
// before the current EBB.
let idom_live_list =
self.idom_sets.get(&idom).expect("No stored live set for dominator");
let idom_live_list = self.idom_sets
.get(&idom)
.expect("No stored live set for dominator");
// Get just the values that are live-in to `ebb`.
for &value in idom_live_list.as_slice(&self.idom_pool) {
let lr = liveness.get(value).expect("Immediate dominator value has no live range");
let lr = liveness
.get(value)
.expect("Immediate dominator value has no live range");
// Check if this value is live-in here.
if let Some(endpoint) = lr.livein_local_end(ebb, program_order) {
@@ -179,7 +183,9 @@ impl LiveValueTracker {
// Now add all the live arguments to `ebb`.
let first_arg = self.live.values.len();
for value in dfg.ebb_args(ebb) {
let lr = liveness.get(value).expect("EBB argument value has no live range");
let lr = liveness
.get(value)
.expect("EBB argument value has no live range");
assert_eq!(lr.def(), ebb.into());
match lr.def_local_end().into() {
ExpandedProgramPoint::Inst(endpoint) => {
@@ -259,16 +265,15 @@ impl LiveValueTracker {
/// Save the current set of live values so it is associated with `idom`.
fn save_idom_live_set(&mut self, idom: Inst) {
let values = self.live
.values
.iter()
.map(|lv| lv.value);
let values = self.live.values.iter().map(|lv| lv.value);
let pool = &mut self.idom_pool;
// If there already is a set saved for `idom`, just keep it.
self.idom_sets.entry(idom).or_insert_with(|| {
let mut list = ValueList::default();
list.extend(values, pool);
list
});
self.idom_sets
.entry(idom)
.or_insert_with(|| {
let mut list = ValueList::default();
list.extend(values, pool);
list
});
}
}

View File

@@ -205,7 +205,8 @@ fn get_or_create<'a>(lrset: &'a mut LiveRangeSet,
def = inst.into();
// Initialize the affinity from the defining instruction's result constraints.
// Don't do this for call return values which are always tied to a single register.
affinity = recipe_constraints.get(func.encodings[inst].recipe())
affinity = recipe_constraints
.get(func.encodings[inst].recipe())
.and_then(|rc| rc.outs.get(rnum))
.map(Affinity::new)
.unwrap_or_default();
@@ -315,7 +316,8 @@ impl Liveness {
let recipe = func.encodings[inst].recipe();
// Iterator of constraints, one per value operand.
// TODO: Should we fail here if the instruction doesn't have a valid encoding?
let mut operand_constraints = recipe_constraints.get(recipe)
let mut operand_constraints = recipe_constraints
.get(recipe)
.map(|c| c.ins)
.unwrap_or(&[])
.iter();

View File

@@ -221,14 +221,16 @@ impl LiveRange {
/// Return `Ok(n)` if `liveins[n]` already contains `ebb`.
/// Otherwise, return `Err(n)` with the index where such an interval should be inserted.
fn find_ebb_interval<PO: ProgramOrder>(&self, ebb: Ebb, order: &PO) -> Result<usize, usize> {
self.liveins.binary_search_by(|intv| order.cmp(intv.begin, ebb)).or_else(|n| {
// The interval at `n-1` may cover `ebb`.
if n > 0 && order.cmp(self.liveins[n - 1].end, ebb) == Ordering::Greater {
Ok(n - 1)
} else {
Err(n)
}
})
self.liveins
.binary_search_by(|intv| order.cmp(intv.begin, ebb))
.or_else(|n| {
// The interval at `n-1` may cover `ebb`.
if n > 0 && order.cmp(self.liveins[n - 1].end, ebb) == Ordering::Greater {
Ok(n - 1)
} else {
Err(n)
}
})
}
/// Extend the local interval for `ebb` so it reaches `to` which must belong to `ebb`.
@@ -307,11 +309,12 @@ impl LiveRange {
}
// Cannot coalesce; insert new interval
(false, false) => {
self.liveins.insert(n,
Interval {
begin: ebb,
end: to,
});
self.liveins
.insert(n,
Interval {
begin: ebb,
end: to,
});
}
}
@@ -361,7 +364,9 @@ impl LiveRange {
/// answer, but it is also possible that an even later program point is returned. So don't
/// depend on the returned `Inst` to belong to `ebb`.
pub fn livein_local_end<PO: ProgramOrder>(&self, ebb: Ebb, order: &PO) -> Option<Inst> {
self.find_ebb_interval(ebb, order).ok().map(|n| self.liveins[n].end)
self.find_ebb_interval(ebb, order)
.ok()
.map(|n| self.liveins[n].end)
}
}