Remove PRegData::reg and use PReg::from_index instead

Performance impact is negligible but this is a good cleanup.
This commit is contained in:
Amanieu d'Antras
2022-01-11 04:07:05 +00:00
parent 74928b83fa
commit 053375f049
4 changed files with 4 additions and 12 deletions

View File

@@ -264,7 +264,6 @@ pub struct VRegData {
#[derive(Clone, Debug)]
pub struct PRegData {
pub reg: PReg,
pub allocations: LiveRangeSet,
pub is_stack: bool,
}

View File

@@ -102,17 +102,10 @@ impl<'a, F: Function> Env<'a, F> {
self.pregs.resize(
PReg::NUM_INDEX,
PRegData {
reg: PReg::invalid(),
allocations: LiveRangeSet::new(),
is_stack: false,
},
);
for i in 0..=PReg::MAX {
let preg_int = PReg::new(i, RegClass::Int);
self.pregs[preg_int.index()].reg = preg_int;
let preg_float = PReg::new(i, RegClass::Float);
self.pregs[preg_float.index()].reg = preg_float;
}
for &preg in &self.env.fixed_stack_slots {
self.pregs[preg.index()].is_stack = true;
}

View File

@@ -20,7 +20,7 @@ use super::{
use crate::moves::ParallelMoves;
use crate::{
Allocation, Block, Edit, Function, Inst, InstPosition, OperandConstraint, OperandKind,
OperandPos, ProgPoint, RegClass, VReg,
OperandPos, PReg, ProgPoint, RegClass, VReg,
};
use smallvec::{smallvec, SmallVec};
use std::fmt::Debug;
@@ -697,7 +697,7 @@ impl<'a, F: Function> Env<'a, F> {
// Handle multi-fixed-reg constraints by copying.
for fixup in std::mem::replace(&mut self.multi_fixed_reg_fixups, vec![]) {
let from_alloc = self.get_alloc(fixup.pos.inst(), fixup.from_slot as usize);
let to_alloc = Allocation::reg(self.pregs[fixup.to_preg.index()].reg);
let to_alloc = Allocation::reg(PReg::from_index(fixup.to_preg.index()));
log::trace!(
"multi-fixed-move constraint at {:?} from {} to {} for v{}",
fixup.pos,
@@ -715,7 +715,7 @@ impl<'a, F: Function> Env<'a, F> {
self.set_alloc(
fixup.pos.inst(),
fixup.to_slot as usize,
Allocation::reg(self.pregs[fixup.to_preg.index()].reg),
Allocation::reg(PReg::from_index(fixup.to_preg.index())),
);
}

View File

@@ -197,7 +197,7 @@ impl<'a, F: Function> Env<'a, F> {
}
// We can allocate! Add our ranges to the preg's BTree.
let preg = self.pregs[reg.index()].reg;
let preg = PReg::from_index(reg.index());
log::trace!(" -> bundle {:?} assigned to preg {:?}", bundle, preg);
self.bundles[bundle.index()].allocation = Allocation::reg(preg);
for entry in &self.bundles[bundle.index()].ranges {