use crate::ir::ir_variable::{IrVariable, IrVariableDescriptor, IrVrVariableDescriptor}; use crate::ir::register_allocation::{OffsetCounter, VrUser}; use std::cell::RefCell; use std::collections::{HashMap, HashSet}; use std::fmt::{Display, Formatter}; use std::rc::Rc; pub struct IrReadField { field_ref_variable: Rc>, } impl IrReadField { pub fn new(field_ref_variable: Rc>) -> Self { Self { field_ref_variable } } pub fn field_ref_variable(&self) -> &Rc> { &self.field_ref_variable } } impl Display for IrReadField { fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result { write!(f, "{}", self.field_ref_variable.borrow(),) } } impl VrUser for IrReadField { fn vr_definitions(&self) -> HashSet { HashSet::new() } fn vr_uses(&self) -> HashSet { let mut set = HashSet::new(); if let IrVariableDescriptor::VirtualRegister(vr_variable) = self.field_ref_variable.borrow().descriptor() { set.insert(vr_variable.clone()); } set } fn propagate_spills(&mut self, spills: &HashSet) {} fn propagate_register_assignments( &mut self, assignments: &HashMap, ) { } fn propagate_stack_offsets(&mut self, counter: &mut OffsetCounter) {} }