dont calc cfginfo
This commit is contained in:
@@ -4,12 +4,12 @@ use alloc::{string::String, vec};
|
||||
use smallvec::{smallvec, SmallVec};
|
||||
use std::{convert::TryFrom, println};
|
||||
|
||||
use crate::InstPosition;
|
||||
use crate::{
|
||||
cfg::CFGInfo, Allocation, Block, Edit, Function, Inst, MachineEnv, Operand, OperandConstraint,
|
||||
OperandKind, OperandPos, Output, PReg, PRegSet, ProgPoint, RegAllocError, RegClass, SpillSlot,
|
||||
VReg,
|
||||
};
|
||||
use crate::{postorder, InstPosition};
|
||||
|
||||
use super::Stats;
|
||||
|
||||
@@ -39,7 +39,7 @@ struct ReadOnlyData {
|
||||
}
|
||||
|
||||
impl ReadOnlyData {
|
||||
pub fn init<F: Function>(func: &F, mach_env: &MachineEnv, cfg: &CFGInfo) -> Self {
|
||||
pub fn init<F: Function>(func: &F, mach_env: &MachineEnv) -> Self {
|
||||
let reg_order_int = {
|
||||
let class = RegClass::Int as usize;
|
||||
let amount = mach_env.preferred_regs_by_class[class].len()
|
||||
@@ -63,7 +63,9 @@ impl ReadOnlyData {
|
||||
Self {
|
||||
reg_order_int,
|
||||
reg_order_float,
|
||||
postorder: cfg.postorder.clone(),
|
||||
postorder: postorder::calculate(func.num_blocks(), func.entry_block(), |b| {
|
||||
func.block_succs(b)
|
||||
}),
|
||||
}
|
||||
}
|
||||
|
||||
@@ -139,11 +141,10 @@ struct FastAllocState<'a, F: Function> {
|
||||
|
||||
pub func: &'a F,
|
||||
pub mach_env: &'a MachineEnv,
|
||||
pub cfg: &'a CFGInfo,
|
||||
}
|
||||
|
||||
impl<'a, F: Function> FastAllocState<'a, F> {
|
||||
pub fn init(func: &'a F, mach_env: &'a MachineEnv, cfg: &'a CFGInfo) -> Self {
|
||||
pub fn init(func: &'a F, mach_env: &'a MachineEnv) -> Self {
|
||||
let reftype_vregs = func.reftype_vregs();
|
||||
|
||||
let vregs = {
|
||||
@@ -162,6 +163,7 @@ impl<'a, F: Function> FastAllocState<'a, F> {
|
||||
pregs.resize(PReg::NUM_INDEX, PRegData::default());
|
||||
|
||||
for preg in &mach_env.fixed_stack_slots {
|
||||
trace!("{} is a stack pseudo", preg);
|
||||
pregs[preg.index()].stack_pseudo = true;
|
||||
}
|
||||
pregs
|
||||
@@ -214,7 +216,6 @@ impl<'a, F: Function> FastAllocState<'a, F> {
|
||||
|
||||
func,
|
||||
mach_env,
|
||||
cfg,
|
||||
}
|
||||
}
|
||||
|
||||
@@ -238,6 +239,7 @@ impl<'a, F: Function> FastAllocState<'a, F> {
|
||||
self.stack_slot_count_float
|
||||
};
|
||||
let idx = self.cur_stack_slot_idx;
|
||||
trace!("Allocated slot {} for {}", idx, vreg);
|
||||
self.cur_stack_slot_idx += size as u32;
|
||||
data.slot_idx = Some(idx);
|
||||
idx
|
||||
@@ -372,17 +374,13 @@ impl<'a, F: Function> FastAllocState<'a, F> {
|
||||
}
|
||||
}
|
||||
|
||||
pub fn run<F: Function>(
|
||||
func: &F,
|
||||
mach_env: &MachineEnv,
|
||||
cfg: CFGInfo,
|
||||
) -> Result<Output, RegAllocError> {
|
||||
pub fn run<F: Function>(func: &F, mach_env: &MachineEnv) -> Result<Output, RegAllocError> {
|
||||
if func.multi_spillslot_named_by_last_slot() {
|
||||
panic!("MultiSpillslotIndexPos not supported");
|
||||
}
|
||||
|
||||
let mut state = FastAllocState::init(func, mach_env, &cfg);
|
||||
let const_state = ReadOnlyData::init(func, mach_env, &cfg);
|
||||
let mut state = FastAllocState::init(func, mach_env);
|
||||
let const_state = ReadOnlyData::init(func, mach_env);
|
||||
|
||||
state.blocks[func.entry_block().index()].params_allocated = true;
|
||||
|
||||
|
||||
@@ -36,10 +36,10 @@ pub(crate) mod process;
|
||||
use process::*;
|
||||
use smallvec::smallvec;
|
||||
pub(crate) mod dump;
|
||||
mod fast_alloc;
|
||||
pub(crate) mod moves;
|
||||
pub(crate) mod spill;
|
||||
pub(crate) mod stackmap;
|
||||
mod fast_alloc;
|
||||
|
||||
impl<'a, F: Function> Env<'a, F> {
|
||||
pub(crate) fn new(
|
||||
@@ -123,17 +123,22 @@ pub fn run<F: Function>(
|
||||
enable_ssa_checker: bool,
|
||||
use_fast_alloc: bool,
|
||||
) -> Result<Output, RegAllocError> {
|
||||
let cfginfo = CFGInfo::new(func, !use_fast_alloc)?;
|
||||
let mut cfginfo = None;
|
||||
|
||||
if enable_ssa_checker {
|
||||
validate_ssa(func, &cfginfo)?;
|
||||
cfginfo = Some(CFGInfo::new(func, !use_fast_alloc)?);
|
||||
validate_ssa(func, cfginfo.as_ref().unwrap())?;
|
||||
}
|
||||
|
||||
if use_fast_alloc {
|
||||
return fast_alloc::run(func, mach_env, cfginfo);
|
||||
return fast_alloc::run(func, mach_env);
|
||||
}
|
||||
|
||||
let mut env = Env::new(func, mach_env, cfginfo, enable_annotations);
|
||||
if cfginfo.is_none() {
|
||||
cfginfo = Some(CFGInfo::new(func, !use_fast_alloc)?);
|
||||
}
|
||||
|
||||
let mut env = Env::new(func, mach_env, cfginfo.take().unwrap(), enable_annotations);
|
||||
env.init()?;
|
||||
|
||||
env.run()?;
|
||||
|
||||
Reference in New Issue
Block a user