pub struct Machine {
pub conv: &'static CallRegs,
pub file: RegFile,
pub insts: &'static FrameInsts,
pub branch: &'static BranchInsts,
pub bits: &'static BitInsts,
pub flags: &'static FlagInsts,
pub shapes: &'static MachineInsts,
pub timing: &'static TimingInsts,
pub short: &'static ShortInsts,
pub selector: &'static Selector,
pub env: Env,
}Expand description
Everything about a machine that compiling a function for it needs.
The fields are different kinds of fact and they come from different places: where the
convention puts things, what registers the machine has, which instructions build a frame,
which instructions a branch becomes, and which registers the allocator may hand out. The last
one is not a target fact on its own, because holding a register back as scratch is a decision
about the allocator rather than about the machine, which is why it is built here rather than
in rucc_target.
Fields§
§conv: &'static CallRegsWhere the convention this function is compiled for puts things.
file: RegFileThe registers the machine has, which is what says how wide a spill slot of a class is.
insts: &'static FrameInstsThe instructions that take a frame and give it back.
branch: &'static BranchInstsThe instructions a branch becomes once the blocks are in an order.
bits: &'static BitInstsHow much of a register each of the machine’s instructions reads and writes.
flags: &'static FlagInstsWhat each of the machine’s instructions leaves in the condition state.
shapes: &'static MachineInstsWhat shape each of the machine’s instructions is, which is what a pass proposing a new one has its proposal held against.
timing: &'static TimingInstsHow long each of the machine’s instructions takes, and what it takes it on.
short: &'static ShortInstsWhich of the machine’s instructions have a shorter spelling of the same answer.
selector: &'static SelectorWhat the selector asks of the machine, which is the rules and the instructions it writes itself.
env: EnvWhat the allocator may hand out, and what it holds back.
Implementations§
Source§impl Machine
impl Machine
Sourcepub fn x86_64(conv: &'static CallRegs) -> Self
pub fn x86_64(conv: &'static CallRegs) -> Self
The x86-64 machine under that convention.
Both files are offered. A value the selector produces is in one or the other, which is
decided by its type: an integer and an address are general purpose and a float or a
double is in a vector register, and the allocator is given each file separately because
no move goes between them.
Sourcepub fn aarch64(conv: &'static CallRegs) -> Self
pub fn aarch64(conv: &'static CallRegs) -> Self
The AArch64 machine under that convention.
The scratch registers are x16 and x17, which the convention already keeps out of the
allocation order because a linker’s veneer may write them between a call and the function
it reaches. That is the property a scratch register wants: nothing lives in one across
anything the compiler did not write, so a move the rewriter puts in can have it. The vector
file’s two are picked the way the x86 ones are, which lands on v30 and v31.
Nothing selects AArch64 instructions yet, so Machine::for_target does not return this.
Sourcepub fn for_target(target: &TargetInfo) -> Option<Self>
pub fn for_target(target: &TargetInfo) -> Option<Self>
The machine a target describes, or None when no backend in this crate covers it.
TargetInfo already carries the convention, because the front end needs it to lay a
va_list out, so the only thing this decides is which architecture’s frame instructions
and register file go with it. RISC-V is None until it has a rule file, and a caller that
gets one reports a target it cannot compile for rather than compiling wrongly.