| 55 | phys_regs: HashMap::new(), |
| 56 | reg_types: HashMap::new(), |
| 57 | stack_address_regs: HashSet::new(), |
| 58 | label_map: HashMap::new(), |
| 59 | asm_scratch_slots: None, |
| 60 | omit_frame_pointer: false, |
| 61 | } |
| 62 | } |
| 63 | |
| 64 | /// Allocate a stack slot for a virtual register. |
| 65 | pub fn alloc_slot_for_reg(&mut self, reg: &IrRegister, ty: &IrType) -> usize { |
| 66 | let size = self.frame.type_size(ty, &self.type_aliases); |
| 67 | let alignment = self.frame.type_alignment(ty, &self.type_aliases); |
| 68 | let slot = self.frame.alloc_slot(size, alignment); |
| 69 | self.reg_slots.insert(reg.clone(), slot); |
| 70 | self.reg_types.insert(reg.clone(), ty.clone()); |
| 71 | slot |
| 72 | } |
| 73 | |