From 053375f049fbc52067972bc9d4e7d6e950de4517 Mon Sep 17 00:00:00 2001 From: Amanieu d'Antras Date: Tue, 11 Jan 2022 04:07:05 +0000 Subject: [PATCH] Remove PRegData::reg and use PReg::from_index instead Performance impact is negligible but this is a good cleanup. --- src/ion/data_structures.rs | 1 - src/ion/liveranges.rs | 7 ------- src/ion/moves.rs | 6 +++--- src/ion/process.rs | 2 +- 4 files changed, 4 insertions(+), 12 deletions(-) diff --git a/src/ion/data_structures.rs b/src/ion/data_structures.rs index 09f7834..b47c5c3 100644 --- a/src/ion/data_structures.rs +++ b/src/ion/data_structures.rs @@ -264,7 +264,6 @@ pub struct VRegData { #[derive(Clone, Debug)] pub struct PRegData { - pub reg: PReg, pub allocations: LiveRangeSet, pub is_stack: bool, } diff --git a/src/ion/liveranges.rs b/src/ion/liveranges.rs index 2f7e2e6..7dd9d56 100644 --- a/src/ion/liveranges.rs +++ b/src/ion/liveranges.rs @@ -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; } diff --git a/src/ion/moves.rs b/src/ion/moves.rs index c86fd1a..b01bf59 100644 --- a/src/ion/moves.rs +++ b/src/ion/moves.rs @@ -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())), ); } diff --git a/src/ion/process.rs b/src/ion/process.rs index 753990b..8b5a7a8 100644 --- a/src/ion/process.rs +++ b/src/ion/process.rs @@ -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 {