Enable and fix several more clippy lints.
This commit is contained in:
@@ -19,7 +19,7 @@ pub enum Affinity {
|
||||
///
|
||||
/// This indicates a value that is not defined or used by any real instructions. It is a ghost
|
||||
/// value that won't appear in the final program.
|
||||
None,
|
||||
Unassigned,
|
||||
|
||||
/// This value should be placed in a spill slot on the stack.
|
||||
Stack,
|
||||
@@ -30,16 +30,16 @@ pub enum Affinity {
|
||||
|
||||
impl Default for Affinity {
|
||||
fn default() -> Self {
|
||||
Affinity::None
|
||||
Affinity::Unassigned
|
||||
}
|
||||
}
|
||||
|
||||
impl Affinity {
|
||||
/// Create an affinity that satisfies a single constraint.
|
||||
///
|
||||
/// This will never create an `Affinity::None`.
|
||||
/// This will never create an `Affinity::Unassigned`.
|
||||
/// Use the `Default` implementation for that.
|
||||
pub fn new(constraint: &OperandConstraint) -> Affinity {
|
||||
pub fn new(constraint: &OperandConstraint) -> Self {
|
||||
if constraint.kind == ConstraintKind::Stack {
|
||||
Affinity::Stack
|
||||
} else {
|
||||
@@ -48,18 +48,18 @@ impl Affinity {
|
||||
}
|
||||
|
||||
/// Create an affinity that matches an ABI argument for `isa`.
|
||||
pub fn abi(arg: &AbiParam, isa: &TargetIsa) -> Affinity {
|
||||
pub fn abi(arg: &AbiParam, isa: &TargetIsa) -> Self {
|
||||
match arg.location {
|
||||
ArgumentLoc::Unassigned => Affinity::None,
|
||||
ArgumentLoc::Unassigned => Affinity::Unassigned,
|
||||
ArgumentLoc::Reg(_) => Affinity::Reg(isa.regclass_for_abi_type(arg.value_type).into()),
|
||||
ArgumentLoc::Stack(_) => Affinity::Stack,
|
||||
}
|
||||
}
|
||||
|
||||
/// Is this the `None` affinity?
|
||||
pub fn is_none(self) -> bool {
|
||||
/// Is this the `Unassigned` affinity?
|
||||
pub fn is_unassigned(self) -> bool {
|
||||
match self {
|
||||
Affinity::None => true,
|
||||
Affinity::Unassigned => true,
|
||||
_ => false,
|
||||
}
|
||||
}
|
||||
@@ -86,15 +86,15 @@ impl Affinity {
|
||||
/// satisfies the constraint.
|
||||
pub fn merge(&mut self, constraint: &OperandConstraint, reg_info: &RegInfo) {
|
||||
match *self {
|
||||
Affinity::None => *self = Affinity::new(constraint),
|
||||
Affinity::Unassigned => *self = Self::new(constraint),
|
||||
Affinity::Reg(rc) => {
|
||||
// If the preferred register class is a subclass of the constraint, there's no need
|
||||
// to change anything.
|
||||
if constraint.kind != ConstraintKind::Stack &&
|
||||
!constraint.regclass.has_subclass(rc)
|
||||
{
|
||||
// If the register classes don't overlap, `intersect` returns `None`, and we
|
||||
// just keep our previous affinity.
|
||||
// If the register classes don't overlap, `intersect` returns `Unassigned`, and
|
||||
// we just keep our previous affinity.
|
||||
if let Some(subclass) = constraint.regclass.intersect_index(reg_info.rc(rc)) {
|
||||
// This constraint shrinks our preferred register class.
|
||||
*self = Affinity::Reg(subclass);
|
||||
@@ -118,7 +118,7 @@ pub struct DisplayAffinity<'a>(Affinity, Option<&'a RegInfo>);
|
||||
impl<'a> fmt::Display for DisplayAffinity<'a> {
|
||||
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
|
||||
match self.0 {
|
||||
Affinity::None => write!(f, "none"),
|
||||
Affinity::Unassigned => write!(f, "unassigned"),
|
||||
Affinity::Stack => write!(f, "stack"),
|
||||
Affinity::Reg(rci) => {
|
||||
match self.1 {
|
||||
|
||||
@@ -704,10 +704,10 @@ struct Node {
|
||||
|
||||
impl Node {
|
||||
/// Create a node representing `value`.
|
||||
pub fn value(value: Value, set_id: u8, func: &Function) -> Node {
|
||||
pub fn value(value: Value, set_id: u8, func: &Function) -> Self {
|
||||
let def = func.dfg.value_def(value).pp();
|
||||
let ebb = func.layout.pp_ebb(def);
|
||||
Node {
|
||||
Self {
|
||||
def,
|
||||
ebb,
|
||||
is_vcopy: false,
|
||||
@@ -717,10 +717,10 @@ impl Node {
|
||||
}
|
||||
|
||||
/// Create a node representing a virtual copy.
|
||||
pub fn vcopy(branch: Inst, value: Value, set_id: u8, func: &Function) -> Node {
|
||||
pub fn vcopy(branch: Inst, value: Value, set_id: u8, func: &Function) -> Self {
|
||||
let def = branch.into();
|
||||
let ebb = func.layout.pp_ebb(def);
|
||||
Node {
|
||||
Self {
|
||||
def,
|
||||
ebb,
|
||||
is_vcopy: true,
|
||||
@@ -891,8 +891,8 @@ struct VirtualCopies {
|
||||
|
||||
impl VirtualCopies {
|
||||
/// Create an empty VirtualCopies struct.
|
||||
pub fn new() -> VirtualCopies {
|
||||
VirtualCopies {
|
||||
pub fn new() -> Self {
|
||||
Self {
|
||||
params: Vec::new(),
|
||||
branches: Vec::new(),
|
||||
filter: Vec::new(),
|
||||
|
||||
@@ -272,7 +272,7 @@ impl<'a> Context<'a> {
|
||||
Affinity::Stack => debug_assert!(abi.location.is_stack()),
|
||||
// This is a ghost value, unused in the function. Don't assign it to a location
|
||||
// either.
|
||||
Affinity::None => {}
|
||||
Affinity::Unassigned => {}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1126,8 +1126,8 @@ struct AvailableRegs {
|
||||
|
||||
impl AvailableRegs {
|
||||
/// Initialize both the input and global sets from `regs`.
|
||||
pub fn new(regs: &RegisterSet) -> AvailableRegs {
|
||||
AvailableRegs {
|
||||
pub fn new(regs: &RegisterSet) -> Self {
|
||||
Self {
|
||||
input: regs.clone(),
|
||||
global: regs.clone(),
|
||||
}
|
||||
|
||||
@@ -32,9 +32,9 @@ pub struct Diversion {
|
||||
|
||||
impl Diversion {
|
||||
/// Make a new diversion.
|
||||
pub fn new(value: Value, from: ValueLoc, to: ValueLoc) -> Diversion {
|
||||
pub fn new(value: Value, from: ValueLoc, to: ValueLoc) -> Self {
|
||||
debug_assert!(from.is_assigned() && to.is_assigned());
|
||||
Diversion { value, from, to }
|
||||
Self { value, from, to }
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -179,7 +179,7 @@ use entity::SparseMap;
|
||||
use flowgraph::ControlFlowGraph;
|
||||
use ir::dfg::ValueDef;
|
||||
use ir::{Ebb, Function, Inst, Layout, ProgramPoint, Value};
|
||||
use isa::{EncInfo, TargetIsa};
|
||||
use isa::{EncInfo, TargetIsa, OperandConstraint};
|
||||
use regalloc::affinity::Affinity;
|
||||
use regalloc::liverange::{LiveRange, LiveRangeContext, LiveRangeForest};
|
||||
use std::mem;
|
||||
@@ -413,11 +413,10 @@ impl Liveness {
|
||||
|
||||
// Iterator of constraints, one per value operand.
|
||||
let encoding = func.encodings[inst];
|
||||
let mut operand_constraints = enc_info
|
||||
let operand_constraint_slice: &[OperandConstraint] = enc_info
|
||||
.operand_constraints(encoding)
|
||||
.map(|c| c.ins)
|
||||
.unwrap_or(&[])
|
||||
.iter();
|
||||
.map_or(&[], |c| c.ins);
|
||||
let mut operand_constraints = operand_constraint_slice.iter();
|
||||
|
||||
for &arg in func.dfg.inst_args(inst) {
|
||||
// Get the live range, create it as a dead range if necessary.
|
||||
|
||||
@@ -217,8 +217,8 @@ impl<PO: ProgramOrder> GenLiveRange<PO> {
|
||||
/// Create a new live range for `value` defined at `def`.
|
||||
///
|
||||
/// The live range will be created as dead, but it can be extended with `extend_in_ebb()`.
|
||||
pub fn new(value: Value, def: ProgramPoint, affinity: Affinity) -> GenLiveRange<PO> {
|
||||
GenLiveRange {
|
||||
pub fn new(value: Value, def: ProgramPoint, affinity: Affinity) -> Self {
|
||||
Self {
|
||||
value,
|
||||
affinity,
|
||||
def_begin: def,
|
||||
|
||||
@@ -81,8 +81,8 @@ pub struct Pressure {
|
||||
|
||||
impl Pressure {
|
||||
/// Create a new register pressure tracker.
|
||||
pub fn new(reginfo: &RegInfo, usable: &RegisterSet) -> Pressure {
|
||||
let mut p = Pressure {
|
||||
pub fn new(reginfo: &RegInfo, usable: &RegisterSet) -> Self {
|
||||
let mut p = Self {
|
||||
aliased: 0,
|
||||
toprc: Default::default(),
|
||||
};
|
||||
|
||||
@@ -103,7 +103,7 @@ impl RegisterSet {
|
||||
/// of `other`.
|
||||
///
|
||||
/// This assumes that unused bits are 1.
|
||||
pub fn interferes_with(&self, other: &RegisterSet) -> bool {
|
||||
pub fn interferes_with(&self, other: &Self) -> bool {
|
||||
self.avail.iter().zip(&other.avail).any(
|
||||
|(&x, &y)| (x | y) != !0,
|
||||
)
|
||||
@@ -111,7 +111,7 @@ impl RegisterSet {
|
||||
|
||||
/// Intersect this set of registers with `other`. This has the effect of removing any register
|
||||
/// units from this set that are not in `other`.
|
||||
pub fn intersect(&mut self, other: &RegisterSet) {
|
||||
pub fn intersect(&mut self, other: &Self) {
|
||||
for (x, &y) in self.avail.iter_mut().zip(&other.avail) {
|
||||
*x &= y;
|
||||
}
|
||||
|
||||
@@ -219,7 +219,7 @@ impl<'a> Context<'a> {
|
||||
|
||||
self.reloads.insert(ReloadedValue {
|
||||
stack: cand.value,
|
||||
reg: reg,
|
||||
reg,
|
||||
});
|
||||
cand.value = reg;
|
||||
|
||||
|
||||
@@ -151,8 +151,8 @@ pub struct Variable {
|
||||
}
|
||||
|
||||
impl Variable {
|
||||
fn new_live(value: Value, constraint: RegClass, from: RegUnit, is_output: bool) -> Variable {
|
||||
Variable {
|
||||
fn new_live(value: Value, constraint: RegClass, from: RegUnit, is_output: bool) -> Self {
|
||||
Self {
|
||||
value,
|
||||
constraint,
|
||||
from: Some(from),
|
||||
@@ -164,8 +164,8 @@ impl Variable {
|
||||
}
|
||||
}
|
||||
|
||||
fn new_def(value: Value, constraint: RegClass, is_global: bool) -> Variable {
|
||||
Variable {
|
||||
fn new_def(value: Value, constraint: RegClass, is_global: bool) -> Self {
|
||||
Self {
|
||||
value,
|
||||
constraint,
|
||||
from: None,
|
||||
@@ -280,7 +280,7 @@ pub enum Move {
|
||||
|
||||
impl Move {
|
||||
/// Create a register move from an assignment, but not for identity assignments.
|
||||
fn with_assignment(a: &Assignment) -> Option<Move> {
|
||||
fn with_assignment(a: &Assignment) -> Option<Self> {
|
||||
if a.from != a.to {
|
||||
Some(Move::Reg {
|
||||
value: a.value,
|
||||
|
||||
@@ -363,7 +363,7 @@ impl<'a> Context<'a> {
|
||||
self.cur.isa.regclass_for_abi_type(abi.value_type).into(),
|
||||
true,
|
||||
),
|
||||
Affinity::None => panic!("Missing affinity for {}", arg),
|
||||
Affinity::Unassigned => panic!("Missing affinity for {}", arg),
|
||||
};
|
||||
let mut reguse = RegUse::new(arg, fixed_args + idx, rci);
|
||||
reguse.fixed = true;
|
||||
@@ -393,10 +393,9 @@ impl<'a> Context<'a> {
|
||||
} else if ru.fixed {
|
||||
// This is a fixed register use which doesn't necessarily require a copy.
|
||||
// Make a copy only if this is not the first use of the value.
|
||||
self.reg_uses
|
||||
.get(i.wrapping_sub(1))
|
||||
.map(|ru2| ru2.value == ru.value)
|
||||
.unwrap_or(false)
|
||||
self.reg_uses.get(i.wrapping_sub(1)).map_or(false, |ru2| {
|
||||
ru2.value == ru.value
|
||||
})
|
||||
} else {
|
||||
false
|
||||
};
|
||||
@@ -567,8 +566,8 @@ struct RegUse {
|
||||
}
|
||||
|
||||
impl RegUse {
|
||||
fn new(value: Value, idx: usize, rci: RegClassIndex) -> RegUse {
|
||||
RegUse {
|
||||
fn new(value: Value, idx: usize, rci: RegClassIndex) -> Self {
|
||||
Self {
|
||||
value,
|
||||
opidx: idx as u16,
|
||||
rci,
|
||||
|
||||
@@ -101,10 +101,9 @@ impl VirtRegs {
|
||||
where
|
||||
'a: 'b,
|
||||
{
|
||||
self.get(*value).map(|vr| self.values(vr)).unwrap_or_else(
|
||||
|| {
|
||||
ref_slice(value)
|
||||
},
|
||||
self.get(*value).map_or_else(
|
||||
|| ref_slice(value),
|
||||
|vr| self.values(vr),
|
||||
)
|
||||
}
|
||||
|
||||
@@ -257,7 +256,7 @@ enum UFEntry {
|
||||
/// A singleton set is the same as a set with rank 0. It contains only the leader value.
|
||||
impl UFEntry {
|
||||
/// Decode a table entry.
|
||||
fn decode(x: i32) -> UFEntry {
|
||||
fn decode(x: i32) -> Self {
|
||||
if x < 0 {
|
||||
UFEntry::Link(Value::new((!x) as usize))
|
||||
} else {
|
||||
|
||||
Reference in New Issue
Block a user