Fix clippy warnings.
This commit fixes the current set of (stable) clippy warnings in the repo.
This commit is contained in:
committed by
Andrew Brown
parent
1176e4f178
commit
9f506692c2
@@ -70,7 +70,7 @@ impl PerCpuModeEncodings {
|
||||
{
|
||||
let (recipe, bits) = template.build();
|
||||
let recipe_number = self.add_recipe(recipe);
|
||||
let builder = EncodingBuilder::new(inst.into(), recipe_number, bits);
|
||||
let builder = EncodingBuilder::new(inst, recipe_number, bits);
|
||||
builder_closure(builder).build(&self.recipes, &mut self.inst_pred_reg)
|
||||
}
|
||||
|
||||
@@ -367,6 +367,7 @@ impl PerCpuModeEncodings {
|
||||
|
||||
// Definitions.
|
||||
|
||||
#[allow(clippy::cognitive_complexity)]
|
||||
pub(crate) fn define(
|
||||
shared_defs: &SharedDefinitions,
|
||||
settings: &SettingGroup,
|
||||
@@ -1916,7 +1917,7 @@ pub(crate) fn define(
|
||||
|
||||
// SIMD integer addition
|
||||
for (ty, opcodes) in &[(I8, &PADDB), (I16, &PADDW), (I32, &PADDD), (I64, &PADDQ)] {
|
||||
let iadd = iadd.bind(vector(ty.clone(), sse_vector_size));
|
||||
let iadd = iadd.bind(vector(*ty, sse_vector_size));
|
||||
e.enc_32_64(iadd, rec_fa.opcodes(*opcodes));
|
||||
}
|
||||
|
||||
@@ -1940,7 +1941,7 @@ pub(crate) fn define(
|
||||
|
||||
// SIMD integer subtraction
|
||||
for (ty, opcodes) in &[(I8, &PSUBB), (I16, &PSUBW), (I32, &PSUBD), (I64, &PSUBQ)] {
|
||||
let isub = isub.bind(vector(ty.clone(), sse_vector_size));
|
||||
let isub = isub.bind(vector(*ty, sse_vector_size));
|
||||
e.enc_32_64(isub, rec_fa.opcodes(*opcodes));
|
||||
}
|
||||
|
||||
@@ -1968,7 +1969,7 @@ pub(crate) fn define(
|
||||
(I16, &PMULLW[..], None),
|
||||
(I32, &PMULLD[..], Some(use_sse41_simd)),
|
||||
] {
|
||||
let imul = imul.bind(vector(ty.clone(), sse_vector_size));
|
||||
let imul = imul.bind(vector(*ty, sse_vector_size));
|
||||
e.enc_32_64_maybe_isap(imul, rec_fa.opcodes(opcodes), *isap);
|
||||
}
|
||||
|
||||
|
||||
@@ -11,6 +11,7 @@ use crate::shared::formats::Formats;
|
||||
use crate::shared::immediates::Immediates;
|
||||
use crate::shared::types;
|
||||
|
||||
#[allow(clippy::many_single_char_names)]
|
||||
pub(crate) fn define(
|
||||
mut all_instructions: &mut AllInstructions,
|
||||
formats: &Formats,
|
||||
|
||||
@@ -6,6 +6,7 @@ use crate::shared::types::Float::F64;
|
||||
use crate::shared::types::Int::{I16, I32, I64};
|
||||
use crate::shared::Definitions as SharedDefinitions;
|
||||
|
||||
#[allow(clippy::many_single_char_names)]
|
||||
pub(crate) fn define(shared: &mut SharedDefinitions, x86_instructions: &InstructionGroup) {
|
||||
let mut group = TransformGroupBuilder::new(
|
||||
"x86_expand",
|
||||
@@ -253,7 +254,7 @@ pub(crate) fn define(shared: &mut SharedDefinitions, x86_instructions: &Instruct
|
||||
def!(r = popcnt.I64(x)),
|
||||
vec![
|
||||
def!(qv3 = ushr_imm(x, imm64_1)),
|
||||
def!(qc77 = iconst(Literal::constant(&imm.imm64, 0x7777777777777777))),
|
||||
def!(qc77 = iconst(Literal::constant(&imm.imm64, 0x7777_7777_7777_7777))),
|
||||
def!(qv4 = band(qv3, qc77)),
|
||||
def!(qv5 = isub(x, qv4)),
|
||||
def!(qv6 = ushr_imm(qv4, imm64_1)),
|
||||
@@ -264,9 +265,9 @@ pub(crate) fn define(shared: &mut SharedDefinitions, x86_instructions: &Instruct
|
||||
def!(qv11 = isub(qv8, qv10)),
|
||||
def!(qv12 = ushr_imm(qv11, imm64_4)),
|
||||
def!(qv13 = iadd(qv11, qv12)),
|
||||
def!(qc0F = iconst(Literal::constant(&imm.imm64, 0x0F0F0F0F0F0F0F0F))),
|
||||
def!(qc0F = iconst(Literal::constant(&imm.imm64, 0x0F0F_0F0F_0F0F_0F0F))),
|
||||
def!(qv14 = band(qv13, qc0F)),
|
||||
def!(qc01 = iconst(Literal::constant(&imm.imm64, 0x0101010101010101))),
|
||||
def!(qc01 = iconst(Literal::constant(&imm.imm64, 0x0101_0101_0101_0101))),
|
||||
def!(qv15 = imul(qv14, qc01)),
|
||||
def!(r = ushr_imm(qv15, Literal::constant(&imm.imm64, 56))),
|
||||
],
|
||||
@@ -294,7 +295,7 @@ pub(crate) fn define(shared: &mut SharedDefinitions, x86_instructions: &Instruct
|
||||
def!(r = popcnt.I32(x)),
|
||||
vec![
|
||||
def!(lv3 = ushr_imm(x, imm64_1)),
|
||||
def!(lc77 = iconst(Literal::constant(&imm.imm64, 0x77777777))),
|
||||
def!(lc77 = iconst(Literal::constant(&imm.imm64, 0x7777_7777))),
|
||||
def!(lv4 = band(lv3, lc77)),
|
||||
def!(lv5 = isub(x, lv4)),
|
||||
def!(lv6 = ushr_imm(lv4, imm64_1)),
|
||||
@@ -305,9 +306,9 @@ pub(crate) fn define(shared: &mut SharedDefinitions, x86_instructions: &Instruct
|
||||
def!(lv11 = isub(lv8, lv10)),
|
||||
def!(lv12 = ushr_imm(lv11, imm64_4)),
|
||||
def!(lv13 = iadd(lv11, lv12)),
|
||||
def!(lc0F = iconst(Literal::constant(&imm.imm64, 0x0F0F0F0F))),
|
||||
def!(lc0F = iconst(Literal::constant(&imm.imm64, 0x0F0F_0F0F))),
|
||||
def!(lv14 = band(lv13, lc0F)),
|
||||
def!(lc01 = iconst(Literal::constant(&imm.imm64, 0x01010101))),
|
||||
def!(lc01 = iconst(Literal::constant(&imm.imm64, 0x0101_0101))),
|
||||
def!(lv15 = imul(lv14, lc01)),
|
||||
def!(r = ushr_imm(lv15, Literal::constant(&imm.imm64, 24))),
|
||||
],
|
||||
|
||||
@@ -51,14 +51,14 @@ impl<'builder> RecipeGroup<'builder> {
|
||||
pub fn recipe(&self, name: &str) -> &EncodingRecipe {
|
||||
self.recipes
|
||||
.iter()
|
||||
.find(|recipe| &recipe.name == name)
|
||||
.expect(&format!("unknown recipe name: {}. Try template?", name))
|
||||
.find(|recipe| recipe.name == name)
|
||||
.unwrap_or_else(|| panic!("unknown recipe name: {}. Try template?", name))
|
||||
}
|
||||
pub fn template(&self, name: &str) -> &Template {
|
||||
self.templates
|
||||
.iter()
|
||||
.find(|recipe| recipe.name() == name)
|
||||
.expect(&format!("unknown tail recipe name: {}. Try recipe?", name))
|
||||
.unwrap_or_else(|| panic!("unknown tail recipe name: {}. Try recipe?", name))
|
||||
}
|
||||
}
|
||||
|
||||
@@ -96,7 +96,7 @@ impl<'builder> RecipeGroup<'builder> {
|
||||
|
||||
/// Given a sequence of opcode bytes, compute the recipe name prefix and encoding bits.
|
||||
fn decode_opcodes(op_bytes: &[u8], rrr: u16, w: u16) -> (&'static str, u16) {
|
||||
assert!(op_bytes.len() >= 1, "at least one opcode byte");
|
||||
assert!(!op_bytes.is_empty(), "at least one opcode byte");
|
||||
|
||||
let prefix_bytes = &op_bytes[..op_bytes.len() - 1];
|
||||
let (name, mmpp) = match prefix_bytes {
|
||||
@@ -121,7 +121,7 @@ fn decode_opcodes(op_bytes: &[u8], rrr: u16, w: u16) -> (&'static str, u16) {
|
||||
}
|
||||
};
|
||||
|
||||
let opcode_byte = op_bytes[op_bytes.len() - 1] as u16;
|
||||
let opcode_byte = u16::from(op_bytes[op_bytes.len() - 1]);
|
||||
(name, opcode_byte | (mmpp << 8) | (rrr << 12) | w << 15)
|
||||
}
|
||||
|
||||
@@ -243,7 +243,7 @@ impl<'builder> Template<'builder> {
|
||||
if let Some(prefixed) = &self.when_prefixed {
|
||||
let mut ret = prefixed.rex();
|
||||
// Forward specialized parameters.
|
||||
ret.op_bytes = self.op_bytes.clone();
|
||||
ret.op_bytes = self.op_bytes;
|
||||
ret.w_bit = self.w_bit;
|
||||
ret.rrr_bits = self.rrr_bits;
|
||||
return ret;
|
||||
@@ -266,18 +266,17 @@ impl<'builder> Template<'builder> {
|
||||
self.recipe.base_size += size_addendum;
|
||||
|
||||
// Branch ranges are relative to the end of the instruction.
|
||||
self.recipe
|
||||
.branch_range
|
||||
.as_mut()
|
||||
.map(|range| range.inst_size += size_addendum);
|
||||
if let Some(range) = self.recipe.branch_range.as_mut() {
|
||||
range.inst_size += size_addendum;
|
||||
}
|
||||
|
||||
self.recipe.emit = replace_put_op(self.recipe.emit, &name);
|
||||
self.recipe.name = name + &self.recipe.name;
|
||||
|
||||
if !self.rex {
|
||||
let operands_in = self.recipe.operands_in.unwrap_or(Vec::new());
|
||||
let operands_in = self.recipe.operands_in.unwrap_or_default();
|
||||
self.recipe.operands_in = Some(replace_nonrex_constraints(self.regs, operands_in));
|
||||
let operands_out = self.recipe.operands_out.unwrap_or(Vec::new());
|
||||
let operands_out = self.recipe.operands_out.unwrap_or_default();
|
||||
self.recipe.operands_out = Some(replace_nonrex_constraints(self.regs, operands_out));
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user