Fix clippy warnings.

This commit fixes the current set of (stable) clippy warnings in the repo.
This commit is contained in:
Peter Huene
2019-10-23 23:15:42 -07:00
committed by Andrew Brown
parent 1176e4f178
commit 9f506692c2
93 changed files with 667 additions and 662 deletions

View File

@@ -29,7 +29,7 @@ pub struct ConstantData(Vec<u8>);
impl FromIterator<u8> for ConstantData {
fn from_iter<T: IntoIterator<Item = u8>>(iter: T) -> Self {
let v = iter.into_iter().collect();
ConstantData(v)
Self(v)
}
}
@@ -58,7 +58,7 @@ impl ConstantData {
}
/// Convert the data to a vector.
pub fn to_vec(self) -> Vec<u8> {
pub fn into_vec(self) -> Vec<u8> {
self.0
}
@@ -122,7 +122,7 @@ impl FromStr for ConstantData {
/// ```
/// use cranelift_codegen::ir::ConstantData;
/// let c: ConstantData = "0x000102".parse().unwrap();
/// assert_eq!(c.to_vec(), [2, 1, 0]);
/// assert_eq!(c.into_vec(), [2, 1, 0]);
/// ```
fn from_str(s: &str) -> Result<Self, &'static str> {
if s.len() <= 2 || &s[0..2] != "0x" {
@@ -137,7 +137,7 @@ impl FromStr for ConstantData {
.cloned()
.collect(); // remove 0x prefix and any intervening _ characters
if cleaned.len() == 0 {
if cleaned.is_empty() {
Err("Hexadecimal string must have some digits")
} else if cleaned.len() % 2 != 0 {
Err("Hexadecimal string must have an even number of digits")
@@ -152,7 +152,7 @@ impl FromStr for ConstantData {
.or_else(|_| Err("Unable to parse as hexadecimal"))?;
buffer.insert(0, byte);
}
Ok(ConstantData(buffer))
Ok(Self(buffer))
}
}
}
@@ -221,15 +221,13 @@ impl ConstantPool {
/// returned.
pub fn insert(&mut self, constant_value: ConstantData) -> Constant {
if self.values_to_handles.contains_key(&constant_value) {
self.values_to_handles.get(&constant_value).unwrap().clone()
*self.values_to_handles.get(&constant_value).unwrap()
} else {
let constant_handle = Constant::new(self.len());
self.values_to_handles
.insert(constant_value.clone(), constant_handle.clone());
self.handles_to_values.insert(
constant_handle.clone(),
ConstantPoolEntry::new(constant_value),
);
.insert(constant_value.clone(), constant_handle);
self.handles_to_values
.insert(constant_handle, ConstantPoolEntry::new(constant_value));
constant_handle
}
}
@@ -402,13 +400,13 @@ mod tests {
fn add_to_constant_data() {
let d = ConstantData::from([1, 2].as_ref());
let e = d.append(i16::from(3u8));
assert_eq!(e.to_vec(), vec![1, 2, 3, 0])
assert_eq!(e.into_vec(), vec![1, 2, 3, 0])
}
#[test]
fn extend_constant_data() {
let d = ConstantData::from([1, 2].as_ref());
assert_eq!(d.expand_to(4).to_vec(), vec![1, 2, 0, 0])
assert_eq!(d.expand_to(4).into_vec(), vec![1, 2, 0, 0])
}
#[test]
@@ -460,7 +458,7 @@ mod tests {
#[test]
fn verify_stored_bytes_in_constant_data() {
assert_eq!("0x01".parse::<ConstantData>().unwrap().to_vec(), [1]);
assert_eq!("0x01".parse::<ConstantData>().unwrap().into_vec(), [1]);
assert_eq!(ConstantData::from([1, 0].as_ref()).0, [1, 0]);
assert_eq!(ConstantData::from(vec![1, 0, 0, 0]).0, [1, 0, 0, 0]);
}
@@ -468,7 +466,10 @@ mod tests {
#[test]
fn check_constant_data_endianness_as_uimm128() {
fn parse_to_uimm128(from: &str) -> Vec<u8> {
from.parse::<ConstantData>().unwrap().expand_to(16).to_vec()
from.parse::<ConstantData>()
.unwrap()
.expand_to(16)
.into_vec()
}
assert_eq!(

View File

@@ -378,7 +378,7 @@ impl ValueDef {
/// Unwrap the instruction where the value was defined, or panic.
pub fn unwrap_inst(&self) -> Inst {
match *self {
ValueDef::Result(inst, _) => inst,
Self::Result(inst, _) => inst,
_ => panic!("Value is not an instruction result"),
}
}
@@ -386,7 +386,7 @@ impl ValueDef {
/// Unwrap the EBB there the parameter is defined, or panic.
pub fn unwrap_ebb(&self) -> Ebb {
match *self {
ValueDef::Param(ebb, _) => ebb,
Self::Param(ebb, _) => ebb,
_ => panic!("Value is not an EBB parameter"),
}
}
@@ -402,7 +402,7 @@ impl ValueDef {
/// this value.
pub fn num(self) -> usize {
match self {
ValueDef::Result(_, n) | ValueDef::Param(_, n) => n,
Self::Result(_, n) | Self::Param(_, n) => n,
}
}
}

View File

@@ -41,7 +41,7 @@ impl Ebb {
/// This method is for use by the parser.
pub fn with_number(n: u32) -> Option<Self> {
if n < u32::MAX {
Some(Ebb(n))
Some(Self(n))
} else {
None
}
@@ -72,7 +72,7 @@ impl Value {
/// This method is for use by the parser.
pub fn with_number(n: u32) -> Option<Self> {
if n < u32::MAX / 2 {
Some(Value(n))
Some(Self(n))
} else {
None
}
@@ -118,7 +118,7 @@ impl StackSlot {
/// This method is for use by the parser.
pub fn with_number(n: u32) -> Option<Self> {
if n < u32::MAX {
Some(StackSlot(n))
Some(Self(n))
} else {
None
}
@@ -152,7 +152,7 @@ impl GlobalValue {
/// This method is for use by the parser.
pub fn with_number(n: u32) -> Option<Self> {
if n < u32::MAX {
Some(GlobalValue(n))
Some(Self(n))
} else {
None
}
@@ -174,7 +174,7 @@ impl Constant {
/// This method is for use by the parser.
pub fn with_number(n: u32) -> Option<Self> {
if n < u32::MAX {
Some(Constant(n))
Some(Self(n))
} else {
None
}
@@ -197,7 +197,7 @@ impl Immediate {
/// This method is for use by the parser.
pub fn with_number(n: u32) -> Option<Self> {
if n < u32::MAX {
Some(Immediate(n))
Some(Self(n))
} else {
None
}
@@ -225,7 +225,7 @@ impl JumpTable {
/// This method is for use by the parser.
pub fn with_number(n: u32) -> Option<Self> {
if n < u32::MAX {
Some(JumpTable(n))
Some(Self(n))
} else {
None
}
@@ -258,7 +258,7 @@ impl FuncRef {
/// This method is for use by the parser.
pub fn with_number(n: u32) -> Option<Self> {
if n < u32::MAX {
Some(FuncRef(n))
Some(Self(n))
} else {
None
}
@@ -287,7 +287,7 @@ impl SigRef {
/// This method is for use by the parser.
pub fn with_number(n: u32) -> Option<Self> {
if n < u32::MAX {
Some(SigRef(n))
Some(Self(n))
} else {
None
}
@@ -310,7 +310,7 @@ impl Heap {
/// This method is for use by the parser.
pub fn with_number(n: u32) -> Option<Self> {
if n < u32::MAX {
Some(Heap(n))
Some(Self(n))
} else {
None
}
@@ -334,7 +334,7 @@ impl Table {
/// This method is for use by the parser.
pub fn with_number(n: u32) -> Option<Self> {
if n < u32::MAX {
Some(Table(n))
Some(Self(n))
} else {
None
}
@@ -371,17 +371,17 @@ pub enum AnyEntity {
impl fmt::Display for AnyEntity {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
match *self {
AnyEntity::Function => write!(f, "function"),
AnyEntity::Ebb(r) => r.fmt(f),
AnyEntity::Inst(r) => r.fmt(f),
AnyEntity::Value(r) => r.fmt(f),
AnyEntity::StackSlot(r) => r.fmt(f),
AnyEntity::GlobalValue(r) => r.fmt(f),
AnyEntity::JumpTable(r) => r.fmt(f),
AnyEntity::FuncRef(r) => r.fmt(f),
AnyEntity::SigRef(r) => r.fmt(f),
AnyEntity::Heap(r) => r.fmt(f),
AnyEntity::Table(r) => r.fmt(f),
Self::Function => write!(f, "function"),
Self::Ebb(r) => r.fmt(f),
Self::Inst(r) => r.fmt(f),
Self::Value(r) => r.fmt(f),
Self::StackSlot(r) => r.fmt(f),
Self::GlobalValue(r) => r.fmt(f),
Self::JumpTable(r) => r.fmt(f),
Self::FuncRef(r) => r.fmt(f),
Self::SigRef(r) => r.fmt(f),
Self::Heap(r) => r.fmt(f),
Self::Table(r) => r.fmt(f),
}
}
}
@@ -394,61 +394,61 @@ impl fmt::Debug for AnyEntity {
impl From<Ebb> for AnyEntity {
fn from(r: Ebb) -> Self {
AnyEntity::Ebb(r)
Self::Ebb(r)
}
}
impl From<Inst> for AnyEntity {
fn from(r: Inst) -> Self {
AnyEntity::Inst(r)
Self::Inst(r)
}
}
impl From<Value> for AnyEntity {
fn from(r: Value) -> Self {
AnyEntity::Value(r)
Self::Value(r)
}
}
impl From<StackSlot> for AnyEntity {
fn from(r: StackSlot) -> Self {
AnyEntity::StackSlot(r)
Self::StackSlot(r)
}
}
impl From<GlobalValue> for AnyEntity {
fn from(r: GlobalValue) -> Self {
AnyEntity::GlobalValue(r)
Self::GlobalValue(r)
}
}
impl From<JumpTable> for AnyEntity {
fn from(r: JumpTable) -> Self {
AnyEntity::JumpTable(r)
Self::JumpTable(r)
}
}
impl From<FuncRef> for AnyEntity {
fn from(r: FuncRef) -> Self {
AnyEntity::FuncRef(r)
Self::FuncRef(r)
}
}
impl From<SigRef> for AnyEntity {
fn from(r: SigRef) -> Self {
AnyEntity::SigRef(r)
Self::SigRef(r)
}
}
impl From<Heap> for AnyEntity {
fn from(r: Heap) -> Self {
AnyEntity::Heap(r)
Self::Heap(r)
}
}
impl From<Table> for AnyEntity {
fn from(r: Table) -> Self {
AnyEntity::Table(r)
Self::Table(r)
}
}

View File

@@ -294,14 +294,14 @@ impl FromStr for ArgumentPurpose {
type Err = ();
fn from_str(s: &str) -> Result<Self, ()> {
match s {
"normal" => Ok(ArgumentPurpose::Normal),
"sret" => Ok(ArgumentPurpose::StructReturn),
"link" => Ok(ArgumentPurpose::Link),
"fp" => Ok(ArgumentPurpose::FramePointer),
"csr" => Ok(ArgumentPurpose::CalleeSaved),
"vmctx" => Ok(ArgumentPurpose::VMContext),
"sigid" => Ok(ArgumentPurpose::SignatureId),
"stack_limit" => Ok(ArgumentPurpose::StackLimit),
"normal" => Ok(Self::Normal),
"sret" => Ok(Self::StructReturn),
"link" => Ok(Self::Link),
"fp" => Ok(Self::FramePointer),
"csr" => Ok(Self::CalleeSaved),
"vmctx" => Ok(Self::VMContext),
"sigid" => Ok(Self::SignatureId),
"stack_limit" => Ok(Self::StackLimit),
_ => Err(()),
}
}

View File

@@ -62,7 +62,7 @@ impl ExternalName {
let mut bytes = [0u8; TESTCASE_NAME_LENGTH];
bytes[0..len].copy_from_slice(&vec[0..len]);
ExternalName::TestCase {
Self::TestCase {
length: len as u8,
ascii: bytes,
}
@@ -78,7 +78,7 @@ impl ExternalName {
/// assert_eq!(name.to_string(), "u123:456");
/// ```
pub fn user(namespace: u32, index: u32) -> Self {
ExternalName::User { namespace, index }
Self::User { namespace, index }
}
}
@@ -91,15 +91,15 @@ impl Default for ExternalName {
impl fmt::Display for ExternalName {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
match *self {
ExternalName::User { namespace, index } => write!(f, "u{}:{}", namespace, index),
ExternalName::TestCase { length, ascii } => {
Self::User { namespace, index } => write!(f, "u{}:{}", namespace, index),
Self::TestCase { length, ascii } => {
f.write_char('%')?;
for byte in ascii.iter().take(length as usize) {
f.write_char(*byte as char)?;
}
Ok(())
}
ExternalName::LibCall(lc) => write!(f, "%{}", lc),
Self::LibCall(lc) => write!(f, "%{}", lc),
}
}
}
@@ -110,7 +110,7 @@ impl FromStr for ExternalName {
fn from_str(s: &str) -> Result<Self, Self::Err> {
// Try to parse as a libcall name, otherwise it's a test case.
match s.parse() {
Ok(lc) => Ok(ExternalName::LibCall(lc)),
Ok(lc) => Ok(Self::LibCall(lc)),
Err(_) => Ok(Self::testcase(s.as_bytes())),
}
}

View File

@@ -70,7 +70,7 @@ impl GlobalValueData {
/// Assume that `self` is an `GlobalValueData::Symbol` and return its name.
pub fn symbol_name(&self) -> &ExternalName {
match *self {
GlobalValueData::Symbol { ref name, .. } => name,
Self::Symbol { ref name, .. } => name,
_ => panic!("only symbols have names"),
}
}
@@ -78,11 +78,8 @@ impl GlobalValueData {
/// Return the type of this global.
pub fn global_type(&self, isa: &dyn TargetIsa) -> Type {
match *self {
GlobalValueData::VMContext { .. } | GlobalValueData::Symbol { .. } => {
isa.pointer_type()
}
GlobalValueData::IAddImm { global_type, .. }
| GlobalValueData::Load { global_type, .. } => global_type,
Self::VMContext { .. } | Self::Symbol { .. } => isa.pointer_type(),
Self::IAddImm { global_type, .. } | Self::Load { global_type, .. } => global_type,
}
}
}
@@ -90,8 +87,8 @@ impl GlobalValueData {
impl fmt::Display for GlobalValueData {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
match *self {
GlobalValueData::VMContext => write!(f, "vmctx"),
GlobalValueData::Load {
Self::VMContext => write!(f, "vmctx"),
Self::Load {
base,
offset,
global_type,
@@ -104,12 +101,12 @@ impl fmt::Display for GlobalValueData {
base,
offset
),
GlobalValueData::IAddImm {
Self::IAddImm {
global_type,
base,
offset,
} => write!(f, "iadd_imm.{} {}, {}", global_type, base, offset),
GlobalValueData::Symbol {
Self::Symbol {
ref name,
offset,
colocated,

View File

@@ -50,12 +50,12 @@ pub struct Imm64(i64);
impl Imm64 {
/// Create a new `Imm64` representing the signed number `x`.
pub fn new(x: i64) -> Self {
Imm64(x)
Self(x)
}
/// Return self negated.
pub fn wrapping_neg(self) -> Self {
Imm64(self.0.wrapping_neg())
Self(self.0.wrapping_neg())
}
}
@@ -73,7 +73,7 @@ impl IntoBytes for Imm64 {
impl From<i64> for Imm64 {
fn from(x: i64) -> Self {
Imm64(x)
Self(x)
}
}
@@ -130,12 +130,12 @@ pub struct Uimm64(u64);
impl Uimm64 {
/// Create a new `Uimm64` representing the unsigned number `x`.
pub fn new(x: u64) -> Self {
Uimm64(x)
Self(x)
}
/// Return self negated.
pub fn wrapping_neg(self) -> Self {
Uimm64(self.0.wrapping_neg())
Self(self.0.wrapping_neg())
}
}
@@ -147,7 +147,7 @@ impl Into<u64> for Uimm64 {
impl From<u64> for Uimm64 {
fn from(x: u64) -> Self {
Uimm64(x)
Self(x)
}
}
@@ -272,7 +272,7 @@ impl Into<i64> for Uimm32 {
impl From<u32> for Uimm32 {
fn from(x: u32) -> Self {
Uimm32(x)
Self(x)
}
}
@@ -293,7 +293,7 @@ impl FromStr for Uimm32 {
fn from_str(s: &str) -> Result<Self, &'static str> {
parse_i64(s).and_then(|x| {
if 0 <= x && x <= i64::from(u32::MAX) {
Ok(Uimm32(x as u32))
Ok(Self(x as u32))
} else {
Err("Uimm32 out of range")
}
@@ -329,7 +329,7 @@ impl From<&[u8]> for V128Imm {
assert_eq!(slice.len(), 16);
let mut buffer = [0; 16];
buffer.copy_from_slice(slice);
V128Imm(buffer)
Self(buffer)
}
}
@@ -343,7 +343,7 @@ pub struct Offset32(i32);
impl Offset32 {
/// Create a new `Offset32` representing the signed number `x`.
pub fn new(x: i32) -> Self {
Offset32(x)
Self(x)
}
/// Create a new `Offset32` representing the signed number `x` if possible.
@@ -381,7 +381,7 @@ impl Into<i64> for Offset32 {
impl From<i32> for Offset32 {
fn from(x: i32) -> Self {
Offset32(x)
Self(x)
}
}
@@ -676,7 +676,7 @@ fn parse_float(s: &str, w: u8, t: u8) -> Result<u64, &'static str> {
impl Ieee32 {
/// Create a new `Ieee32` containing the bits of `x`.
pub fn with_bits(x: u32) -> Self {
Ieee32(x)
Self(x)
}
/// Create an `Ieee32` number representing `2.0^n`.
@@ -688,7 +688,7 @@ impl Ieee32 {
let exponent = (n + bias) as u32;
assert!(exponent > 0, "Underflow n={}", n);
assert!(exponent < (1 << w) + 1, "Overflow n={}", n);
Ieee32(exponent << t)
Self(exponent << t)
}
/// Create an `Ieee32` number representing the greatest negative value
@@ -702,12 +702,12 @@ impl Ieee32 {
/// Return self negated.
pub fn neg(self) -> Self {
Ieee32(self.0 ^ (1 << 31))
Self(self.0 ^ (1 << 31))
}
/// Create a new `Ieee32` representing the number `x`.
pub fn with_float(x: f32) -> Self {
Ieee32(x.to_bits())
Self(x.to_bits())
}
/// Get the bitwise representation.
@@ -728,7 +728,7 @@ impl FromStr for Ieee32 {
fn from_str(s: &str) -> Result<Self, &'static str> {
match parse_float(s, 8, 23) {
Ok(b) => Ok(Ieee32(b as u32)),
Ok(b) => Ok(Self(b as u32)),
Err(s) => Err(s),
}
}
@@ -736,7 +736,7 @@ impl FromStr for Ieee32 {
impl From<f32> for Ieee32 {
fn from(x: f32) -> Self {
Ieee32::with_float(x)
Self::with_float(x)
}
}
@@ -749,7 +749,7 @@ impl IntoBytes for Ieee32 {
impl Ieee64 {
/// Create a new `Ieee64` containing the bits of `x`.
pub fn with_bits(x: u64) -> Self {
Ieee64(x)
Self(x)
}
/// Create an `Ieee64` number representing `2.0^n`.
@@ -761,7 +761,7 @@ impl Ieee64 {
let exponent = (n + bias) as u64;
assert!(exponent > 0, "Underflow n={}", n);
assert!(exponent < (1 << w) + 1, "Overflow n={}", n);
Ieee64(exponent << t)
Self(exponent << t)
}
/// Create an `Ieee64` number representing the greatest negative value
@@ -775,12 +775,12 @@ impl Ieee64 {
/// Return self negated.
pub fn neg(self) -> Self {
Ieee64(self.0 ^ (1 << 63))
Self(self.0 ^ (1 << 63))
}
/// Create a new `Ieee64` representing the number `x`.
pub fn with_float(x: f64) -> Self {
Ieee64(x.to_bits())
Self(x.to_bits())
}
/// Get the bitwise representation.
@@ -801,7 +801,7 @@ impl FromStr for Ieee64 {
fn from_str(s: &str) -> Result<Self, &'static str> {
match parse_float(s, 11, 52) {
Ok(b) => Ok(Ieee64(b)),
Ok(b) => Ok(Self(b)),
Err(s) => Err(s),
}
}
@@ -809,13 +809,13 @@ impl FromStr for Ieee64 {
impl From<f64> for Ieee64 {
fn from(x: f64) -> Self {
Ieee64::with_float(x)
Self::with_float(x)
}
}
impl From<u64> for Ieee64 {
fn from(x: u64) -> Self {
Ieee64::with_float(f64::from_bits(x))
Self::with_float(f64::from_bits(x))
}
}

View File

@@ -101,7 +101,7 @@ pub struct VariableArgs(Vec<Value>);
impl VariableArgs {
/// Create an empty argument list.
pub fn new() -> Self {
VariableArgs(Vec::new())
Self(Vec::new())
}
/// Add an argument to the end.
@@ -168,35 +168,35 @@ impl InstructionData {
/// here.
pub fn analyze_branch<'a>(&'a self, pool: &'a ValueListPool) -> BranchInfo<'a> {
match *self {
InstructionData::Jump {
Self::Jump {
destination,
ref args,
..
} => BranchInfo::SingleDest(destination, args.as_slice(pool)),
InstructionData::BranchInt {
Self::BranchInt {
destination,
ref args,
..
}
| InstructionData::BranchFloat {
| Self::BranchFloat {
destination,
ref args,
..
}
| InstructionData::Branch {
| Self::Branch {
destination,
ref args,
..
} => BranchInfo::SingleDest(destination, &args.as_slice(pool)[1..]),
InstructionData::BranchIcmp {
Self::BranchIcmp {
destination,
ref args,
..
} => BranchInfo::SingleDest(destination, &args.as_slice(pool)[2..]),
InstructionData::BranchTable {
Self::BranchTable {
table, destination, ..
} => BranchInfo::Table(table, Some(destination)),
InstructionData::IndirectJump { table, .. } => BranchInfo::Table(table, None),
Self::IndirectJump { table, .. } => BranchInfo::Table(table, None),
_ => {
debug_assert!(!self.opcode().is_branch());
BranchInfo::NotABranch
@@ -210,12 +210,12 @@ impl InstructionData {
/// Multi-destination branches like `br_table` return `None`.
pub fn branch_destination(&self) -> Option<Ebb> {
match *self {
InstructionData::Jump { destination, .. }
| InstructionData::Branch { destination, .. }
| InstructionData::BranchInt { destination, .. }
| InstructionData::BranchFloat { destination, .. }
| InstructionData::BranchIcmp { destination, .. } => Some(destination),
InstructionData::BranchTable { .. } | InstructionData::IndirectJump { .. } => None,
Self::Jump { destination, .. }
| Self::Branch { destination, .. }
| Self::BranchInt { destination, .. }
| Self::BranchFloat { destination, .. }
| Self::BranchIcmp { destination, .. } => Some(destination),
Self::BranchTable { .. } | Self::IndirectJump { .. } => None,
_ => {
debug_assert!(!self.opcode().is_branch());
None
@@ -229,27 +229,27 @@ impl InstructionData {
/// Multi-destination branches like `br_table` return `None`.
pub fn branch_destination_mut(&mut self) -> Option<&mut Ebb> {
match *self {
InstructionData::Jump {
Self::Jump {
ref mut destination,
..
}
| InstructionData::Branch {
| Self::Branch {
ref mut destination,
..
}
| InstructionData::BranchInt {
| Self::BranchInt {
ref mut destination,
..
}
| InstructionData::BranchFloat {
| Self::BranchFloat {
ref mut destination,
..
}
| InstructionData::BranchIcmp {
| Self::BranchIcmp {
ref mut destination,
..
} => Some(destination),
InstructionData::BranchTable { .. } => None,
Self::BranchTable { .. } => None,
_ => {
debug_assert!(!self.opcode().is_branch());
None
@@ -262,10 +262,10 @@ impl InstructionData {
/// Any instruction that can call another function reveals its call signature here.
pub fn analyze_call<'a>(&'a self, pool: &'a ValueListPool) -> CallInfo<'a> {
match *self {
InstructionData::Call {
Self::Call {
func_ref, ref args, ..
} => CallInfo::Direct(func_ref, args.as_slice(pool)),
InstructionData::CallIndirect {
Self::CallIndirect {
sig_ref, ref args, ..
} => CallInfo::Indirect(sig_ref, &args.as_slice(pool)[1..]),
_ => {

View File

@@ -59,18 +59,18 @@ impl FromStr for LibCall {
fn from_str(s: &str) -> Result<Self, Self::Err> {
match s {
"Probestack" => Ok(LibCall::Probestack),
"CeilF32" => Ok(LibCall::CeilF32),
"CeilF64" => Ok(LibCall::CeilF64),
"FloorF32" => Ok(LibCall::FloorF32),
"FloorF64" => Ok(LibCall::FloorF64),
"TruncF32" => Ok(LibCall::TruncF32),
"TruncF64" => Ok(LibCall::TruncF64),
"NearestF32" => Ok(LibCall::NearestF32),
"NearestF64" => Ok(LibCall::NearestF64),
"Memcpy" => Ok(LibCall::Memcpy),
"Memset" => Ok(LibCall::Memset),
"Memmove" => Ok(LibCall::Memmove),
"Probestack" => Ok(Self::Probestack),
"CeilF32" => Ok(Self::CeilF32),
"CeilF64" => Ok(Self::CeilF64),
"FloorF32" => Ok(Self::FloorF32),
"FloorF64" => Ok(Self::FloorF64),
"TruncF32" => Ok(Self::TruncF32),
"TruncF64" => Ok(Self::TruncF64),
"NearestF32" => Ok(Self::NearestF32),
"NearestF64" => Ok(Self::NearestF64),
"Memcpy" => Ok(Self::Memcpy),
"Memset" => Ok(Self::Memset),
"Memmove" => Ok(Self::Memmove),
_ => Err(()),
}
}
@@ -84,17 +84,17 @@ impl LibCall {
pub fn for_inst(opcode: Opcode, ctrl_type: Type) -> Option<Self> {
Some(match ctrl_type {
types::F32 => match opcode {
Opcode::Ceil => LibCall::CeilF32,
Opcode::Floor => LibCall::FloorF32,
Opcode::Trunc => LibCall::TruncF32,
Opcode::Nearest => LibCall::NearestF32,
Opcode::Ceil => Self::CeilF32,
Opcode::Floor => Self::FloorF32,
Opcode::Trunc => Self::TruncF32,
Opcode::Nearest => Self::NearestF32,
_ => return None,
},
types::F64 => match opcode {
Opcode::Ceil => LibCall::CeilF64,
Opcode::Floor => LibCall::FloorF64,
Opcode::Trunc => LibCall::TruncF64,
Opcode::Nearest => LibCall::NearestF64,
Opcode::Ceil => Self::CeilF64,
Opcode::Floor => Self::FloorF64,
Opcode::Trunc => Self::TruncF64,
Opcode::Nearest => Self::NearestF64,
_ => return None,
},
_ => return None,

View File

@@ -20,7 +20,7 @@ impl From<Inst> for ProgramPoint {
fn from(inst: Inst) -> Self {
let idx = inst.index();
debug_assert!(idx < (u32::MAX / 2) as usize);
ProgramPoint((idx * 2) as u32)
Self((idx * 2) as u32)
}
}
@@ -28,7 +28,7 @@ impl From<Ebb> for ProgramPoint {
fn from(ebb: Ebb) -> Self {
let idx = ebb.index();
debug_assert!(idx < (u32::MAX / 2) as usize);
ProgramPoint((idx * 2 + 1) as u32)
Self((idx * 2 + 1) as u32)
}
}
@@ -55,21 +55,21 @@ impl ExpandedProgramPoint {
/// Get the instruction we know is inside.
pub fn unwrap_inst(self) -> Inst {
match self {
ExpandedProgramPoint::Inst(x) => x,
ExpandedProgramPoint::Ebb(x) => panic!("expected inst: {}", x),
Self::Inst(x) => x,
Self::Ebb(x) => panic!("expected inst: {}", x),
}
}
}
impl From<Inst> for ExpandedProgramPoint {
fn from(inst: Inst) -> Self {
ExpandedProgramPoint::Inst(inst)
Self::Inst(inst)
}
}
impl From<Ebb> for ExpandedProgramPoint {
fn from(ebb: Ebb) -> Self {
ExpandedProgramPoint::Ebb(ebb)
Self::Ebb(ebb)
}
}
@@ -85,9 +85,9 @@ impl From<ValueDef> for ExpandedProgramPoint {
impl From<ProgramPoint> for ExpandedProgramPoint {
fn from(pp: ProgramPoint) -> Self {
if pp.0 & 1 == 0 {
ExpandedProgramPoint::Inst(Inst::from_u32(pp.0 / 2))
Self::Inst(Inst::from_u32(pp.0 / 2))
} else {
ExpandedProgramPoint::Ebb(Ebb::from_u32(pp.0 / 2))
Self::Ebb(Ebb::from_u32(pp.0 / 2))
}
}
}
@@ -95,8 +95,8 @@ impl From<ProgramPoint> for ExpandedProgramPoint {
impl fmt::Display for ExpandedProgramPoint {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
match *self {
ExpandedProgramPoint::Inst(x) => write!(f, "{}", x),
ExpandedProgramPoint::Ebb(x) => write!(f, "{}", x),
Self::Inst(x) => write!(f, "{}", x),
Self::Ebb(x) => write!(f, "{}", x),
}
}
}

View File

@@ -21,7 +21,7 @@ pub struct SourceLoc(u32);
impl SourceLoc {
/// Create a new source location with the given bits.
pub fn new(bits: u32) -> Self {
SourceLoc(bits)
Self(bits)
}
/// Is this the default source location?
@@ -37,7 +37,7 @@ impl SourceLoc {
impl Default for SourceLoc {
fn default() -> Self {
SourceLoc(!0)
Self(!0)
}
}

View File

@@ -91,7 +91,7 @@ impl Type {
/// Get a type with the same number of lanes as `self`, but using `lane` as the lane type.
fn replace_lanes(self, lane: Self) -> Self {
debug_assert!(lane.is_lane() && !self.is_special());
Type((lane.0 & 0x0f) | (self.0 & 0xf0))
Self((lane.0 & 0x0f) | (self.0 & 0xf0))
}
/// Get a type with the same number of lanes as this type, but with the lanes replaced by
@@ -262,7 +262,7 @@ impl Type {
let log2_lanes: u32 = n.trailing_zeros();
let new_type = u32::from(self.0) + (log2_lanes << 4);
if new_type < 0x100 {
Some(Type(new_type as u8))
Some(Self(new_type as u8))
} else {
None
}
@@ -273,7 +273,7 @@ impl Type {
/// There is no `double_vector()` method. Use `t.by(2)` instead.
pub fn half_vector(self) -> Option<Self> {
if self.is_vector() {
Some(Type(self.0 - 0x10))
Some(Self(self.0 - 0x10))
} else {
None
}

View File

@@ -24,7 +24,7 @@ pub enum ValueLoc {
impl Default for ValueLoc {
fn default() -> Self {
ValueLoc::Unassigned
Self::Unassigned
}
}
@@ -32,7 +32,7 @@ impl ValueLoc {
/// Is this an assigned location? (That is, not `Unassigned`).
pub fn is_assigned(self) -> bool {
match self {
ValueLoc::Unassigned => false,
Self::Unassigned => false,
_ => true,
}
}
@@ -40,7 +40,7 @@ impl ValueLoc {
/// Get the register unit of this location, or panic.
pub fn unwrap_reg(self) -> RegUnit {
match self {
ValueLoc::Reg(ru) => ru,
Self::Reg(ru) => ru,
_ => panic!("Expected register: {:?}", self),
}
}
@@ -48,7 +48,7 @@ impl ValueLoc {
/// Get the stack slot of this location, or panic.
pub fn unwrap_stack(self) -> StackSlot {
match self {
ValueLoc::Stack(ss) => ss,
Self::Stack(ss) => ss,
_ => panic!("Expected stack slot: {:?}", self),
}
}
@@ -109,7 +109,7 @@ pub enum ArgumentLoc {
impl Default for ArgumentLoc {
fn default() -> Self {
ArgumentLoc::Unassigned
Self::Unassigned
}
}
@@ -117,7 +117,7 @@ impl ArgumentLoc {
/// Is this an assigned location? (That is, not `Unassigned`).
pub fn is_assigned(self) -> bool {
match self {
ArgumentLoc::Unassigned => false,
Self::Unassigned => false,
_ => true,
}
}
@@ -125,7 +125,7 @@ impl ArgumentLoc {
/// Is this a register location?
pub fn is_reg(self) -> bool {
match self {
ArgumentLoc::Reg(_) => true,
Self::Reg(_) => true,
_ => false,
}
}
@@ -133,7 +133,7 @@ impl ArgumentLoc {
/// Is this a stack location?
pub fn is_stack(self) -> bool {
match self {
ArgumentLoc::Stack(_) => true,
Self::Stack(_) => true,
_ => false,
}
}