MimIR
MimIR is my Intermediate Representation
Loading...
Searching...
No Matches
mim::plug::mach::Target Class Referenceabstract

The machine facts of a native backend that the phases of mach need. More...

#include <mim/plug/mach/target.h>

Inheritance diagram for mim::plug::mach::Target:
[legend]

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)

Detailed Description

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.

Definition at line 45 of file target.h.

Member Enumeration Documentation

◆ Class

The register classes; Stack values live in a spill slot and are unbounded.

Enumerator
Gpr 
Fpr 
Flags 
Stack 
Num_Classes 

Definition at line 48 of file target.h.

Constructor & Destructor Documentation

◆ Target()

mim::plug::mach::Target::Target ( std::string_view name,
plugin_t plugin )
inline

plugin is the backend's plugin id.

Definition at line 50 of file target.h.

References mim::Target::name(), and Target().

Referenced by of(), and Target().

Member Function Documentation

◆ arg_reg()

virtual size_t mim::plug::mach::Target::arg_reg ( Class cls,
size_t i ) const
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().

◆ caller_saved()

virtual bool mim::plug::mach::Target::caller_saved ( Class cls,
size_t r ) const
pure virtual

◆ cls()

◆ constraint()

virtual Constraint mim::plug::mach::Target::constraint ( const App * insn) const
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().

◆ fits_imm()

virtual bool mim::plug::mach::Target::fits_imm ( const Def * ) const
inlinevirtual

Does the literal lit fit a hole of type Want::Imm?

Reimplemented in mim::plug::x86::Target.

Definition at line 139 of file target.h.

◆ global_prefix()

constexpr std::string_view mim::plug::mach::Target::global_prefix ( )
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().

◆ in()

const Def * mim::plug::mach::Target::in ( Class cls,
size_t r,
const Def * v ) const
inline

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().

◆ in_reg()

size_t mim::plug::mach::Target::in_reg ( const Def * in)
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().

◆ is_elf()

constexpr bool mim::plug::mach::Target::is_elf ( )
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().

◆ is_flags()

virtual bool mim::plug::mach::Target::is_flags ( const Def * def) const
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.

◆ is_in()

bool mim::plug::mach::Target::is_in ( const Def * def)
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().

◆ is_insn()

bool mim::plug::mach::Target::is_insn ( const App * app) const
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().

◆ is_lowered()

bool mim::plug::mach::Target::is_lowered ( const Axm * axm)
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().

◆ is_machine_insn()

virtual bool mim::plug::mach::Target::is_machine_insn ( const App * app) const
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().

◆ is_mem()

bool mim::plug::mach::Target::is_mem ( const Def * def)
inlinestatic

◆ is_mem_insn()

virtual bool mim::plug::mach::Target::is_mem_insn ( const App * app) const
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().

◆ is_removable()

virtual bool mim::plug::mach::Target::is_removable ( const App * insn) const
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().

◆ is_sched_cc()

virtual bool mim::plug::mach::Target::is_sched_cc ( const App * app) const
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().

◆ is_view()

bool mim::plug::mach::Target::is_view ( const Def * def)
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().

◆ isa_sched_cc()

const App * mim::plug::mach::Target::isa_sched_cc ( const Def * cond) const
inline

The sched of a cc that yields cond, if any.

Definition at line 225 of file target.h.

References is_sched_cc().

◆ local_prefix()

constexpr std::string_view mim::plug::mach::Target::local_prefix ( )
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().

◆ negate_cc()

virtual size_t mim::plug::mach::Target::negate_cc ( size_t cc) const
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.

◆ num_allocatable()

size_t mim::plug::mach::Target::num_allocatable ( Class cls) const
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().

◆ num_arg_regs()

virtual size_t mim::plug::mach::Target::num_arg_regs ( Class cls) const
pure virtual

Implemented in mim::plug::arm::Target, and mim::plug::x86::Target.

References cls().

Referenced by mim::plug::mach::arg_locs().

◆ num_caller_saved()

size_t mim::plug::mach::Target::num_caller_saved ( Class cls) const
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().

◆ num_regs()

virtual size_t mim::plug::mach::Target::num_regs ( Class cls) const
pure virtual

◆ of()

const Target & mim::plug::mach::Target::of ( Driver & driver)
inlinestatic

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().

◆ operands()

DefVec mim::plug::mach::Target::operands ( const App * insn)
inlinestatic

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().

◆ prev_mem()

const Def * mim::plug::mach::Target::prev_mem ( const App * app) const
inline

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().

◆ ptr_size()

nat_t mim::plug::mach::Target::ptr_size ( ) const
inlineoverridevirtual

The size and alignment of a pointer in bytes; see core.trait.

Implements mim::Target.

Definition at line 57 of file target.h.

◆ rebuild()

const App * mim::plug::mach::Target::rebuild ( const App * insn,
const Def * m,
const DefVec & ops )
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().

◆ reload()

const Def * mim::plug::mach::Target::reload ( const Def * type)
inlinestatic

The instruction that reloads a value of type from its spill slot.

Definition at line 172 of file target.h.

◆ reserved()

virtual bool mim::plug::mach::Target::reserved ( Class cls,
size_t r ) const
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().

◆ result()

const Def * mim::plug::mach::Target::result ( const App * insn,
size_t j )
inlinestatic

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().

◆ ret_reg()

virtual size_t mim::plug::mach::Target::ret_reg ( Class cls) const
pure virtual

Implemented in mim::plug::arm::Target, and mim::plug::x86::Target.

References cls().

◆ sched_insn()

const Def * mim::plug::mach::Target::sched_insn ( const App * app)
inlinestatic

◆ spill()

const Def * mim::plug::mach::Target::spill ( const Def * type)
inlinestatic

The instruction f of sched f m x that spills a value of type.

Definition at line 170 of file target.h.

◆ spill_type()

const Def * mim::plug::mach::Target::spill_type ( const Def * type)
inlinestatic

The type of the spill slot of a value of type.

Definition at line 174 of file target.h.

◆ strip()

const Def * mim::plug::mach::Target::strip ( const Def * def)
inlinestatic

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().

◆ untie()

virtual const App * mim::plug::mach::Target::untie ( const App * ,
const DefSet & ,
const Def *  ) const
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.

Definition at line 137 of file target.h.

◆ unview()

const Def * mim::plug::mach::Target::unview ( const Def * def)
inlinestatic

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().


The documentation for this class was generated from the following file: