The machine facts of a native backend that the phases of mach need. More...
#include <mim/plug/mach/target.h>
Public Types | |
| enum | Class : size_t { Gpr , Fpr , Flags , Stack , Num_Classes } |
| The register classes; Stack values live in a spill slot and are unbounded. More... | |
Public Member Functions | |
| Target (std::string_view name, plugin_t plugin) | |
plugin is the backend's plugin id. | |
| nat_t | ptr_size () const override |
| The size and alignment of a pointer in bytes; see core.trait. | |
Register File and ABI | |
Registers are hardware encodings within their Class. | |
| virtual size_t | num_regs (Class cls) const =0 |
| virtual bool | reserved (Class cls, size_t r) const =0 |
Is r never available to register allocation? | |
| virtual bool | caller_saved (Class cls, size_t r) const =0 |
| virtual size_t | num_arg_regs (Class cls) const =0 |
| virtual size_t | arg_reg (Class cls, size_t i) const =0 |
The register of the i-th argument of class cls. | |
| virtual size_t | ret_reg (Class cls) const =0 |
| size_t | num_allocatable (Class cls) const |
The number of registers of cls that register allocation may assign. | |
| size_t | num_caller_saved (Class cls) const |
| The number of those that a call may clobber. | |
Flags | |
| virtual bool | is_flags (const Def *def) const =0 |
| virtual bool | is_sched_cc (const App *app) const =0 |
Is app the sched of the backend's cc? | |
| virtual size_t | negate_cc (size_t cc) const =0 |
The subtag of the backend's cc that holds iff the one with subtag cc does not. | |
| const App * | isa_sched_cc (const Def *cond) const |
The sched of a cc that yields cond, if any. | |
| Public Member Functions inherited from mim::Target | |
| Target (std::string_view name) | |
| virtual | ~Target ()=default |
| std::string_view | name () const |
| The plugin name, used as the prefix of diagnostics. | |
Static Public Member Functions | |
| static const Target & | of (Driver &driver) |
| The Target of the one loaded backend; every backend's Target is a mach::Target. | |
Object Format | |
| static constexpr bool | is_elf () |
| static constexpr std::string_view | global_prefix () |
| The prefix that the object format adds to a C symbol. | |
| static constexpr std::string_view | local_prefix () |
| The prefix of an assembler-local label. | |
Spilling | |
| static const Def * | spill (const Def *type) |
| static const Def * | reload (const Def *type) |
The instruction that reloads a value of type from its spill slot. | |
| static const Def * | spill_type (const Def *type) |
The type of the spill slot of a value of type. | |
Instructions | |
| Class | cls (const Def *def) const |
| virtual bool | is_machine_insn (const App *app) const |
Is app an instruction of this backend, other than mach.sched, that belongs on a mem.M 0 chain? | |
| bool | is_insn (const App *app) const |
Is app an instruction that belongs on a mem.M 0 chain? | |
| virtual bool | is_mem_insn (const App *app) const |
Is app an instruction that takes the mem.M 0 it continues as its first argument? | |
| virtual bool | is_removable (const App *insn) const |
May insn go if nothing uses its results, e.g. | |
| virtual Constraint | constraint (const App *insn) const |
The register constraint of insn; by default, it has none. | |
| virtual const App * | untie (const App *, const DefSet &, const Def *) const |
An equivalent of insn that needs no copy of its tied operand if the values after the instruction hold it, or that ties the parameter phi which its result replaces at the block's jump; none if there is no better one. | |
| virtual bool | fits_imm (const Def *) const |
Does the literal lit fit a hole of type Want::Imm? | |
| static bool | is_lowered (const Axm *axm) |
Is axm an operation that instruction selection must have replaced? | |
| static DefVec | operands (const App *insn) |
The operands of insn: the argument of a sched's instruction, otherwise the arguments including the memory. | |
| static const Def * | result (const App *insn, size_t j) |
The j-th projection of the non-memory result of insn. | |
| static const App * | rebuild (const App *insn, const Def *m, const DefVec &ops) |
insn continuing m with ops instead of its operands. | |
Registers | |
| const Def * | in (Class cls, size_t r, const Def *v) const |
The value v of class cls in register r. | |
| static bool | is_in (const Def *def) |
| static size_t | in_reg (const Def *inin) |
| The register r of in r v. | |
| static bool | is_view (const Def *def) |
Is def a zext d v, which reads v's register? | |
| static const Def * | unview (const Def *def) |
The v of zext d v, otherwise def. | |
| static const Def * | strip (const Def *def) |
The v of in r v, zext d v, or zext d (in r v), otherwise def. | |
Chain | |
| const Def * | prev_mem (const App *app) const |
The memory app continues, if app is an instruction on a mem.M 0 chain. | |
| static const Def * | sched_insn (const App *app) |
| static bool | is_mem (const Def *def) |
The machine facts of a native backend that the phases of mach need.
A value's class is Flags for mach.Flags, Stack for mach.Spill T, Fpr for math.F pe, and Gpr otherwise. A backend derives from it and adds its instructions, register file, ABI, and constraints.
| enum mim::plug::mach::Target::Class : size_t |
|
inline |
|
pure virtual |
The register of the i-th argument of class cls.
Implemented in mim::plug::arm::Target, and mim::plug::x86::Target.
References cls().
Referenced by mim::plug::mach::arg_locs().
|
pure virtual |
Implemented in mim::plug::arm::Target, and mim::plug::x86::Target.
References cls().
Referenced by mim::plug::mach::clobbered(), num_caller_saved(), and mim::plug::mach::param_regs().
The register class of the value def, from its type.
Definition at line 105 of file target.h.
References Flags, Fpr, Gpr, mim::Axm::isa(), mim::plug::math::isa_f(), Stack, and mim::Def::type().
Referenced by mim::plug::mach::arg_locs(), mim::plug::arm::Target::arg_reg(), arg_reg(), mim::plug::x86::Target::arg_reg(), mim::plug::arm::Target::caller_saved(), caller_saved(), mim::plug::x86::Target::caller_saved(), in(), mim::plug::mach::is_value(), num_allocatable(), mim::plug::arm::Target::num_arg_regs(), num_arg_regs(), mim::plug::x86::Target::num_arg_regs(), num_caller_saved(), mim::plug::arm::Target::num_regs(), num_regs(), mim::plug::x86::Target::num_regs(), mim::plug::mach::param_regs(), mim::plug::arm::Target::reserved(), reserved(), mim::plug::x86::Target::reserved(), mim::plug::arm::Target::ret_reg(), ret_reg(), and mim::plug::x86::Target::ret_reg().
|
inlinevirtual |
The register constraint of insn; by default, it has none.
Its operands are values, so an operand zext d v is v.
Reimplemented in mim::plug::x86::Target.
Definition at line 128 of file target.h.
References operands(), and unview().
Referenced by mim::plug::x86::Target::constraint().
|
inlinevirtual |
Does the literal lit fit a hole of type Want::Imm?
Reimplemented in mim::plug::x86::Target.
|
inlinestaticconstexpr |
The prefix that the object format adds to a C symbol.
Definition at line 70 of file target.h.
References is_elf().
Referenced by mim::plug::mach::AsmEmit::symbol().
The value v of class cls in register r.
Definition at line 182 of file target.h.
References cls(), num_regs(), and mim::Def::world().
Referenced by in_reg().
|
inlinestatic |
The register r of in r v.
Definition at line 187 of file target.h.
References mim::App::arg(), mim::App::callee(), in(), and mim::Lit::isa().
Referenced by mim::plug::mach::Emitter::use_reg().
|
inlinestaticconstexpr |
Is the host that the emitted assembly is assembled and linked on ELF, not Mach-O?
Definition at line 62 of file target.h.
Referenced by mim::plug::x86::Emit::finish(), global_prefix(), local_prefix(), and mim::plug::mach::AsmEmit::start().
|
pure virtual |
Is def a Flags value or a condition tested on one, neither of which is a register value?
Implemented in mim::plug::arm::Target, and mim::plug::x86::Target.
|
inlinestatic |
Is def a register operand in r v?
Definition at line 180 of file target.h.
References mim::Axm::isa().
Referenced by strip(), and mim::plug::mach::Emitter::use_reg().
|
inline |
Is app an instruction that belongs on a mem.M 0 chain?
Definition at line 119 of file target.h.
References is_machine_insn(), and mim::Axm::isa().
|
inlinestatic |
Is axm an operation that instruction selection must have replaced?
An axiom of core, mem, or math, or mach.load/mach.store.
Definition at line 142 of file target.h.
References mim::Annex::Base, mim::Def::flags(), and mim::Axm::plugin().
Referenced by mim::plug::mach::ISel::rewrite_imm_App().
|
inlinevirtual |
Is app an instruction of this backend, other than mach.sched, that belongs on a mem.M 0 chain?
By default, an application of an axiom of the backend or of mach that is no Pi and no mach.in.
Reimplemented in mim::plug::x86::Target.
Definition at line 113 of file target.h.
References mim::App::axm(), is_view(), mim::Axm::isa(), and mim::Def::type().
Referenced by is_insn(), and mim::plug::x86::Target::is_machine_insn().
|
inlinestatic |
Definition at line 205 of file target.h.
References mim::Axm::isa(), and mim::Def::type().
Referenced by mim::plug::mach::arg_locs(), mim::plug::mach::is_value(), and mim::plug::mach::param_regs().
|
inlinevirtual |
Is app an instruction that takes the mem.M 0 it continues as its first argument?
mach.slot; a backend adds its loads and stores.
Reimplemented in mim::plug::arm::Target, and mim::plug::x86::Target.
Definition at line 122 of file target.h.
References mim::Axm::isa().
Referenced by mim::plug::arm::Target::is_mem_insn(), mim::plug::x86::Target::is_mem_insn(), and prev_mem().
|
inlinevirtual |
May insn go if nothing uses its results, e.g.
a load? A mach.sched and mach.slot; a backend adds its loads.
Reimplemented in mim::plug::arm::Target, and mim::plug::x86::Target.
Definition at line 125 of file target.h.
References mim::Axm::isa().
Referenced by mim::plug::arm::Target::is_removable(), and mim::plug::x86::Target::is_removable().
|
pure virtual |
Is app the sched of the backend's cc?
Implemented in mim::plug::arm::Target, and mim::plug::x86::Target.
Referenced by isa_sched_cc().
|
inlinestatic |
Is def a zext d v, which reads v's register?
Definition at line 191 of file target.h.
References mim::Axm::isa().
Referenced by is_machine_insn(), and unview().
The sched of a cc that yields cond, if any.
Definition at line 225 of file target.h.
References is_sched_cc().
|
inlinestaticconstexpr |
The prefix of an assembler-local label.
Definition at line 72 of file target.h.
References is_elf().
Referenced by mim::plug::x86::Emit::finish(), and mim::plug::mach::Emitter::label().
|
pure virtual |
The subtag of the backend's cc that holds iff the one with subtag cc does not.
Implemented in mim::plug::arm::Target, and mim::plug::x86::Target.
|
inline |
The number of registers of cls that register allocation may assign.
Definition at line 87 of file target.h.
References cls(), num_regs(), and reserved().
|
pure virtual |
Implemented in mim::plug::arm::Target, and mim::plug::x86::Target.
References cls().
Referenced by mim::plug::mach::arg_locs().
|
inline |
The number of those that a call may clobber.
Definition at line 94 of file target.h.
References caller_saved(), cls(), num_regs(), and reserved().
|
pure virtual |
Implemented in mim::plug::arm::Target, and mim::plug::x86::Target.
References cls().
Referenced by in(), num_allocatable(), num_caller_saved(), and mim::plug::mach::param_regs().
The Target of the one loaded backend; every backend's Target is a mach::Target.
Definition at line 55 of file target.h.
References Target(), and mim::Driver::target().
Referenced by mim::plug::mach::hook(), and mim::plug::mach::mim_mach_isel().
The operands of insn: the argument of a sched's instruction, otherwise the arguments including the memory.
Definition at line 148 of file target.h.
References mim::App::arg(), mim::App::args(), mim::Axm::isa(), and mim::Def::projs().
Referenced by constraint().
The memory app continues, if app is an instruction on a mem.M 0 chain.
Definition at line 210 of file target.h.
References mim::App::arg(), mim::App::callee(), is_mem_insn(), mim::Axm::isa(), and mim::App::num_args().
|
inlineoverridevirtual |
The size and alignment of a pointer in bytes; see core.trait.
Implements mim::Target.
|
inlinestatic |
insn continuing m with ops instead of its operands.
Definition at line 158 of file target.h.
References mim::App::callee(), mim::Axm::isa(), and mim::Def::world().
|
pure virtual |
Is r never available to register allocation?
Implemented in mim::plug::arm::Target, and mim::plug::x86::Target.
References cls().
Referenced by num_allocatable(), num_caller_saved(), and mim::plug::mach::param_regs().
The j-th projection of the non-memory result of insn.
Definition at line 153 of file target.h.
References mim::Def::proj().
Referenced by mim::plug::mach::constrain_fun().
|
pure virtual |
Implemented in mim::plug::arm::Target, and mim::plug::x86::Target.
References cls().
The f of sched f m x.
Definition at line 204 of file target.h.
References mim::App::callee().
Referenced by mim::plug::x86::Target::constraint(), mim::plug::arm::Target::is_sched_cc(), mim::plug::x86::Target::is_sched_cc(), and mim::plug::x86::Target::untie().
The v of in r v, zext d v, or zext d (in r v), otherwise def.
Definition at line 195 of file target.h.
References is_in(), and unview().
Referenced by mim::plug::mach::arg_locs(), and mim::plug::mach::Emitter::source().
|
inlinevirtual |
An equivalent of insn that needs no copy of its tied operand if the values after the instruction hold it, or that ties the parameter phi which its result replaces at the block's jump; none if there is no better one.
Reimplemented in mim::plug::x86::Target.
The v of zext d v, otherwise def.
Definition at line 193 of file target.h.
References is_view().
Referenced by constraint(), strip(), mim::plug::x86::Target::untie(), and mim::plug::mach::Emitter::use_reg().