Path: blob/main/winch/codegen/src/isa/x64/address.rs
1693 views
//! x64 addressing mode.12use crate::reg::Reg;3use cranelift_codegen::VCodeConstant;45/// Memory address representation.6#[derive(Debug, Copy, Clone)]7pub(crate) enum Address {8/// Base register with an immediate offset.9Offset { base: Reg, offset: u32 },10/// Address to identify a constant.11Const(VCodeConstant),12/// Address at `(base + index * 2^shift) + simm32`13ImmRegRegShift {14simm32: i32,15base: Reg,16index: Reg,17shift: u8,18},19}2021impl Address {22/// Create an offset.23pub fn offset(base: Reg, offset: u32) -> Self {24Self::Offset { base, offset }25}2627/// Create an address for a constant.28pub fn constant(data: VCodeConstant) -> Self {29Self::Const(data)30}3132/// Check if the address is a made of a base and offset.33pub fn is_offset(&self) -> bool {34match self {35Self::Offset { .. } => true,36_ => false,37}38}39}404142