pub struct Selector {
pub table: &'static Table,
pub shapes: &'static MachineInsts,
pub address: fn(&str) -> Option<Address>,
pub frame: &'static FrameInsts,
pub branch: &'static BranchInsts,
pub gpr: RegClass,
pub fence: &'static str,
pub trap: &'static str,
pub abi: &'static Insts,
pub scratch: &'static [PhysReg],
pub symbols: &'static Symbols,
pub jumps: &'static Jumps,
}Expand description
What crate::lower has to know about the machine it selects instructions for.
The lowering is one walk over the IR whichever machine it is for, and everything in it that differs between two machines is a question this answers: which table the rules compiled into, what each opcode’s operands are, what an address constructor’s arguments mean, and the handful of instructions the walk writes itself rather than getting from a rule. A walk that reaches for a machine’s module by name is a walk for that machine only, which is what this is here to stop.
The frame and branch instructions are the same tables crate::pipeline::Machine hands the
passes after this one. They are in here as well so that the lowering is handed one thing,
rather than a machine and the convention and the rules separately.
Fields§
§table: &'static TableThe rules, compiled.
shapes: &'static MachineInstsThe shape of each opcode, and the prefix a rule file puts in front of one.
address: fn(&str) -> Option<Address>What an address constructor in a replacement stands for, or None for a name that is not
one of this machine’s.
frame: &'static FrameInstsThe instructions that take a frame and give it back, of which the walk writes the address of a local and the move between two registers itself.
branch: &'static BranchInstsThe instructions a branch becomes, of which the walk writes the indirect jump itself.
gpr: RegClassThe class an address is in.
fence: &'static strThe instruction a full fence is, without the prefix.
trap: &'static strThe instruction a program that must stop here stops with, without the prefix.
abi: &'static InstsThe instructions the calling convention is written with.
scratch: &'static [PhysReg]The address registers held back from the allocator for the rewriter’s reloads, which are the ones the walk must not keep anything in across more than one instruction.
symbols: &'static SymbolsHow the walk comes by the address of a symbol, which is its own business rather than a rule’s because whether it goes through the global offset table is a fact about the link and not about the instruction.
jumps: &'static JumpsThe instructions a jump through a table is built from, and the address of a label.