pub enum AddrMode {
Base,
BaseDisp,
BaseIndex,
BaseIndexScale,
BaseIndexScaleDisp,
}Expand description
The shape of a memory address, which is what an addressing mode table is indexed by.
Section 40.9 wants these costed per target and wants the complexity counted per structural
feature, and AddrMode::complexity is that count. A mode the target does not have is
Cycles::INFINITE in the table rather than absent from it, so that a pass asking about a mode
gets an answer it can compare instead of an Option it has to unwrap into a policy.
Variants§
Base
[base].
BaseDisp
[base + disp].
BaseIndex
[base + index].
BaseIndexScale
[base + index * scale].
BaseIndexScaleDisp
[base + index * scale + disp].
Implementations§
Source§impl AddrMode
impl AddrMode
Sourcepub const fn complexity(self) -> u32
pub const fn complexity(self) -> u32
How many structural features this mode has, per section 40.9.
One each for a displacement, an index, and a scale on the index. The base is not counted because every mode has one, and a feature every mode has cannot discriminate between them.
This is the absolute count. Section 40.9’s refinement, that a feature the target has no
alternative to should not count against a mode, is applied by CostTable::addr_cost,
which is where the target is known.