MimIR
MimIR is my Intermediate Representation
Loading...
Searching...
No Matches
mim::plug::mach Namespace Reference

The mach Plugin More...

Namespaces

namespace  rules
 The closed rewrite rules of a backend's isel plugin as C++; its gen writes them to the backend's isel_rules.h.

Classes

struct  Alt
 An alternative of a PBQP node: a match rooted there, or the class of all matches covering it as the same inner node. More...
struct  ArgLoc
 Where an argument goes: a register of its class, an incoming stack slot, or neither (memory or a dead parameter). More...
class  AsmEmit
 The emit Phase of a native backend: writes GNU assembler code for each external function and each function it calls. More...
class  Assign
 Wraps every use of a value that regs assigns a register in in. More...
class  Close
 Closes every join of a scheduled function over its values, i.e., every block that a jump passes control to. More...
class  Constrain
 constrain_fun() alone; a testing aid. More...
struct  Constraint
 What an instruction on the chain prescribes about the registers of its operands; registers are hardware encodings. More...
struct  Conv
 The convention of a known() function: its param_regs() and the registers a call of it clobbers, all caller-saved. More...
struct  Cover
 An inner node a match covers, with what it needs of its own operands. More...
struct  Demand
 What a match needs of the operand def: a hole of type want or, if inner is set, that inner pattern node. More...
class  Emitter
 Writes the GNU assembler code of one function on the registers that Color assigned. More...
class  FunPhase
 Visits the closed Cns with a body of a scheduled World for one Target, each before the ones that call or jump to it. More...
class  Gen
 Writes the closed rules among the annexes of a backend's isel plugin as the C++ matchers and builders of a rules::Table in mim::plug::<backend>::rules, to -X <isel>:o=<file> or stdout. More...
class  ISel
 Rewrites the core, mach, and math operations of a world that mach.legalize lowered into the instructions of a backend by the rules of its generated rules::Table. More...
class  Legalize
 Turns every Nat value and every pointer into an I64, so that instruction selection only sees register types. More...
class  LibCall
 Turns each operation without a native instruction into a call of its C library function, e.g. More...
class  Live
 Prints the Liveness of every function to -X <backend>:live=<file> or stdout; a debugging and testing aid. More...
class  Liveness
 Liveness of the values of one scheduled function, as a side table. More...
struct  Reg
 A physical register of a register class. More...
class  RegAlloc
 spill_fun(), constrain_fun(), and color_fun() for one function after the other, bottom-up. More...
class  Schedule
 Makes each continuation's mem.M 0 chain total over the instructions of the Target, in a topological order. More...
class  Spilling
 spill_fun() alone, with the ABI at every call; a testing aid. More...
struct  Src
 The source of a copy: a register or a literal; reg.cls is the class of either. More...
class  Subst
 Rewrites a value of a block under reconstruction: memory becomes m; map and lams replace values and blocks. More...
class  Target
 The machine facts of a native backend that the phases of mach need. More...

Typedefs

using Moves = fe::Vector<std::pair<Reg, Src>>
using ParamRegs = fe::Vector<std::optional<size_t>>
 The register per parameter of a function with a convention of its own, or none if it is unused.

Enumerations

enum class  Ref
 How the lhs refers to one of its inner nodes. More...
enum class  Ty
 The non-terminal a rule yields by the type of its rhs: a register of either class, an address without/with an index, [I64, I2], or a register that holds its value zero-extended. More...
enum class  Want
 What a rule wants of the term a meta variable matches; a Param is bound but no operand. More...
<tt>mach.Flags</tt>
enum class  Flags : flags_t
<tt>mach.Spill</tt>
enum class  Spill : flags_t
enum class  spill : flags_t
<tt>mach.in</tt>
enum class  in : flags_t
<tt>mach.sched</tt>
enum class  sched : flags_t
<tt>mach.slot</tt>
enum class  slot : flags_t
<tt>mach.load</tt>
enum class  load : flags_t
<tt>mach.store</tt>
enum class  store : flags_t
<tt>mach.reload</tt>
enum class  reload : flags_t
<tt>mach.fpe</tt>
enum class  fpe : flags_t
<tt>mach.fok</tt>
enum class  fok : flags_t
<tt>mach.float</tt>
enum class  float_ : flags_t {
  arith = 0x3821090000000c00 ,
  unary = 0x3821090000000c01
}
<tt>mach.libcall</tt>
enum class  libcall : flags_t
<tt>mach.legalize</tt>
enum class  legalize : flags_t
<tt>mach.schedule</tt>
enum class  schedule : flags_t
<tt>mach.close</tt>
enum class  close : flags_t
<tt>mach.spilling</tt>
enum class  spilling : flags_t
<tt>mach.constrain</tt>
enum class  constrain : flags_t
<tt>mach.regalloc</tt>
enum class  regalloc : flags_t
<tt>mach.live</tt>
enum class  live : flags_t

Functions

void mim_mach_emit (Emitter &emitter, bool global)
 Emitter::emit, compiled once into libmim_mach; Emitter reaches it via GET_FUN_PTR.
void mim_mach_gen (Gen &)
 Gen::start, compiled once into libmim_mach; Gen reaches it via GET_FUN_PTR.
Phase * mim_mach_isel (World &, flags_t annex, const rules::Table &table)
 A new ISel for the annex annex of a backend, with the rules table; compiled once into libmim_mach.
template<class A>
void hook_isel (Flags2Phases &phases, const rules::Table &table)
 Registers ISel with the rules table as the Phase of the backend's annex A.
void for_each_succ (const App *term, auto f)
 Calls f for each block, possibly repeatedly, that the jump term passes control or a return continuation to.
bool is_value (const Def *value, Liveness::Class cls, const Target &target)
 Is value a value of class cls?
Lam * forwarded (const LamMap< Lam * > &forward, Lam *lam)
 Where a jump to lam goes once the blocks that forward skips are skipped.
fe::Vector< const Liveness::Block * > layout (const Liveness &livelive, const LamMap< Lam * > &forward={})
 The blocks of live in emission order: each block is followed by the one it falls through to, where possible.
void for_each_use (const Liveness &livelive, auto f)
 Calls f for each use of a value in live.
void rewrite_blocks (const Liveness &livelive, Rewriter &rw)
 Rewrites the filter and body of each block of live in place.
size_t num_params (Lam *lam)
 The parameters of lam without its return continuation.
ParamRegs param_regs (const Target &target, Lam *fun, const DefMap< size_t > &regs)
 Where the known() function fun receives its parameters, given the registers regs that Color assigned to them.
fe::Vector< ArgLoc > arg_locs (const Target &target, const Def *arg, size_t n, size_t num, const ParamRegs *conv)
 The ArgLocs of the first num of the n arguments in arg under conv, or the ABI if it is nullptr.
const Conv * callee_conv (const LamMap< Conv > &convs, const Liveness::Block &block)
 The Conv of the callee that the call at the end of block returns from, if it has one.
bool clobbered (const Target &target, const Conv *conv, Target::Class cls, size_t r)
 Does a call of a function with the convention conv, or of an ABI function if there is none, clobber r?
const Liveness::Block * call_cont (const Liveness &livelive, Lam *fun, const Liveness::Block &block)
 The block that a call at the end of block returns to, if any.
template<class Keep, class F>
void interferences (const Liveness &livelive, const Liveness::Block &block, Keep keep, F f)
 Calls f (d, v) for each value v that is live at the definition of d or defined along with it.
template<class Reg>
constexpr size_t encoding (Reg r)
 The hardware encoding of the register r of a backend's module reg, whose subtags are in encoding order.
const Def * fold_ext (const Def *type, const Def *x, bool sign)
 x of Idx s as a literal of type, sign-extended if sign.
void check_addr_space (const App *app, const Def *a)
 Bails unless the address space a of the mem operation app is 0.
template<class A, class P>
void hook (Flags2Phases &phases)
 Registers the Phase P for the annex A, constructed with the Target of the one loaded backend.
fe::Vector< const Nest::Node * > sorted (const Nest::Node::SCC &scc)
 The Nodes of scc in a deterministic order.
LamSet known (World &world)
 The closed Cns with a body that get a convention of their own instead of the ABI.
void spill_fun (const FunPhase &, Lam *fun, const LamMap< Conv > &convs, std::optional< size_t > k)
 Spills and reloads until at most k values of each register class are live at every point of a scheduled function.
bool constrain_fun (const Liveness &livelive)
 Copies fixed and live tied operands by a jump right before their instruction, keeping the graph chordal (Hack).
void color_fun (const FunPhase &, Lam *fun, Liveness livelive, LamMap< Conv > &convs, std::ostream *dot)
 Assigns a register to every value by one PBQP per function and register class (Buchwald, Zwinkau, Bersch, CC 2011).
std::optional< size_t > arg_k (Driver &, const Target &)
 The k of spill_fun(): -X <backend>:k=<n>, if given.
fe::Vector< std::pair< size_t, std::optional< size_t > > > copies (const Constraint &c, auto live_after)
 The fixed operands with their registers, and the tied one with no register if it is live_after.
void register_normalizers (Normalizers &normalizers)

Variables

static constexpr plugin_t Plugin_Id = 0x3821090000000000

<tt>mach.zext</tt>

enum class  zext : flags_t
const Def * normalize_zext (const Def *type, const Def *, const Def *x)

<tt>mach.lit</tt>

enum class  lit : flags_t
const Def * normalize_lit (const Def *type, const Def *, const Def *arg)

Rules

A rule rewrites a pattern over core/mach/math into a backend's term; the holes of the pattern are typed.

enum class  Ty
 The non-terminal a rule yields by the type of its rhs: a register of either class, an address without/with an index, [I64, I2], or a register that holds its value zero-extended. More...
enum class  Want
 What a rule wants of the term a meta variable matches; a Param is bound but no operand. More...
using Alts = fe::Vector<Alt>

Detailed Description


Class Documentation

◆ mim::plug::mach::Alt

struct mim::plug::mach::Alt

An alternative of a PBQP node: a match rooted there, or the class of all matches covering it as the same inner node.

Definition at line 43 of file isel.h.

Class Members
u32 copies = 0 The operands its two-address instructions overwrite although something else uses them.
Vector< Cover > covers
Vector< Demand > demands
DefVec metas What the meta variables of its rule match.
const Rewrite * rule = nullptr nullptr for an inner alternative, whose id is its index plus one.

◆ mim::plug::mach::ArgLoc

struct mim::plug::mach::ArgLoc

Where an argument goes: a register of its class, an incoming stack slot, or neither (memory or a dead parameter).

Definition at line 152 of file liveness.h.

Class Members
optional< size_t > reg
optional< size_t > stack

◆ mim::plug::mach::Constraint

struct mim::plug::mach::Constraint

What an instruction on the chain prescribes about the registers of its operands; registers are hardware encodings.

Definition at line 17 of file target.h.

Class Members
Vector< size_t > clobbers Registers written while the operands still occupy theirs.
Vector< pair< size_t, size_t > > fixed Non-literal operands that have to be in a given register.
DefVec ops See Target::operands.
Vector< pair< size_t, size_t > > results Results, see Target::result, that land in a given register.
optional< size_t > tied The operand whose register the (only) result takes.

◆ mim::plug::mach::Cover

struct mim::plug::mach::Cover

An inner node a match covers, with what it needs of its own operands.

Definition at line 35 of file isel.h.

Class Members
const Def * def
Vector< Demand > demands
size_t inner = 0
bool through = false The match only looks through it, since something else uses it.

◆ mim::plug::mach::Src

struct mim::plug::mach::Src

The source of a copy: a register or a literal; reg.cls is the class of either.

Definition at line 32 of file emit.h.

Class Members
const Def * imm = nullptr
Reg reg = {}

Typedef Documentation

◆ Alts

using mim::plug::mach::Alts = fe::Vector<Alt>

Definition at line 51 of file isel.h.

◆ Moves

using mim::plug::mach::Moves = fe::Vector<std::pair<Reg, Src>>

Definition at line 37 of file emit.h.

◆ ParamRegs

using mim::plug::mach::ParamRegs = fe::Vector<std::optional<size_t>>

The register per parameter of a function with a convention of its own, or none if it is unused.

Definition at line 40 of file target.h.

Enumeration Type Documentation

◆ close

enum class mim::plug::mach::close : flags_t
strong

Definition at line 137 of file autogen.h.

◆ constrain

enum class mim::plug::mach::constrain : flags_t
strong

Definition at line 151 of file autogen.h.

◆ Flags

enum class mim::plug::mach::Flags : flags_t
strong

Definition at line 14 of file autogen.h.

◆ float_

enum class mim::plug::mach::float_ : flags_t
strong
Enumerator
arith 
unary 

Definition at line 99 of file autogen.h.

◆ fok

enum class mim::plug::mach::fok : flags_t
strong

Definition at line 92 of file autogen.h.

◆ fpe

enum class mim::plug::mach::fpe : flags_t
strong

Definition at line 85 of file autogen.h.

◆ in

enum class mim::plug::mach::in : flags_t
strong

Definition at line 28 of file autogen.h.

◆ legalize

enum class mim::plug::mach::legalize : flags_t
strong

Definition at line 123 of file autogen.h.

◆ libcall

enum class mim::plug::mach::libcall : flags_t
strong

Definition at line 116 of file autogen.h.

◆ lit

enum class mim::plug::mach::lit : flags_t
strong

Definition at line 108 of file autogen.h.

◆ live

enum class mim::plug::mach::live : flags_t
strong

Definition at line 165 of file autogen.h.

◆ load

enum class mim::plug::mach::load : flags_t
strong

Definition at line 57 of file autogen.h.

◆ Ref

enum class mim::plug::mach::rules::Ref : u8
strong

How the lhs refers to one of its inner nodes.

Definition at line 50 of file rule_table.h.

◆ regalloc

enum class mim::plug::mach::regalloc : flags_t
strong

Definition at line 158 of file autogen.h.

◆ reload

enum class mim::plug::mach::reload : flags_t
strong

Definition at line 78 of file autogen.h.

◆ sched

enum class mim::plug::mach::sched : flags_t
strong

Definition at line 43 of file autogen.h.

◆ schedule

enum class mim::plug::mach::schedule : flags_t
strong

Definition at line 130 of file autogen.h.

◆ slot

enum class mim::plug::mach::slot : flags_t
strong

Definition at line 50 of file autogen.h.

◆ Spill

enum class mim::plug::mach::Spill : flags_t
strong

Definition at line 21 of file autogen.h.

◆ spill

enum class mim::plug::mach::spill : flags_t
strong

Definition at line 71 of file autogen.h.

◆ spilling

enum class mim::plug::mach::spilling : flags_t
strong

Definition at line 144 of file autogen.h.

◆ store

enum class mim::plug::mach::store : flags_t
strong

Definition at line 64 of file autogen.h.

◆ Ty [1/2]

enum class mim::plug::mach::rules::Ty : u8
strong

The non-terminal a rule yields by the type of its rhs: a register of either class, an address without/with an index, [I64, I2], or a register that holds its value zero-extended.

Lit is no rule's type but that of a literal operand.

Definition at line 38 of file rule_table.h.

◆ Ty [2/2]

enum class mim::plug::mach::rules::Ty : u8
strong

The non-terminal a rule yields by the type of its rhs: a register of either class, an address without/with an index, [I64, I2], or a register that holds its value zero-extended.

Lit is no rule's type but that of a literal operand.

Definition at line 38 of file rule_table.h.

◆ Want [1/2]

enum class mim::plug::mach::rules::Want : u8
strong

What a rule wants of the term a meta variable matches; a Param is bound but no operand.

A Lit is a Param that must be a literal. Reg is a general-purpose register, FReg a floating-point one, and Base/Index an address without/with an index. Addr is either address form, and Scaled an index with its scale. Zx is a general-purpose register that holds its value zero-extended, which mach.zext reads without an instruction. Imm is a literal that fits the backend's immediates, Sh a literal shift count, which the machine masks. RegImm and RegSh are a Reg, or an Imm and a Sh for a literal that is one.

Definition at line 28 of file rule_table.h.

◆ Want [2/2]

enum class mim::plug::mach::rules::Want : u8
strong

What a rule wants of the term a meta variable matches; a Param is bound but no operand.

A Lit is a Param that must be a literal. Reg is a general-purpose register, FReg a floating-point one, and Base/Index an address without/with an index. Addr is either address form, and Scaled an index with its scale. Zx is a general-purpose register that holds its value zero-extended, which mach.zext reads without an instruction. Imm is a literal that fits the backend's immediates, Sh a literal shift count, which the machine masks. RegImm and RegSh are a Reg, or an Imm and a Sh for a literal that is one.

Definition at line 28 of file rule_table.h.

◆ zext

enum class mim::plug::mach::zext : flags_t
strong

Definition at line 35 of file autogen.h.

Function Documentation

◆ arg_k()

std::optional< size_t > mim::plug::mach::arg_k ( Driver & driver,
const Target & target )

The k of spill_fun(): -X <backend>:k=<n>, if given.

Definition at line 499 of file spilling.cpp.

References arg_k(), mim::Driver::arg_nat(), mim::Driver::log(), and mim::Target::name().

Referenced by arg_k(), mim::plug::mach::RegAlloc::RegAlloc(), and mim::plug::mach::Spilling::Spilling().

◆ arg_locs()

fe::Vector< ArgLoc > mim::plug::mach::arg_locs ( const Target & target,
const Def * arg,
size_t n,
size_t num,
const ParamRegs * conv )

The ArgLocs of the first num of the n arguments in arg under conv, or the ABI if it is nullptr.

Definition at line 217 of file liveness.cpp.

References arg_locs(), mim::plug::mach::Target::arg_reg(), mim::plug::mach::Target::cls(), mim::plug::mach::Target::is_mem(), mim::plug::mach::Target::num_arg_regs(), mim::Def::proj(), and mim::plug::mach::Target::strip().

Referenced by arg_locs().

◆ call_cont()

const Liveness::Block * mim::plug::mach::call_cont ( const Liveness & live,
Lam * fun,
const Liveness::Block & block )
inline

The block that a call at the end of block returns to, if any.

Definition at line 178 of file liveness.h.

References call_cont(), mim::Lam::isa_mut_basicblock(), mim::Lam::isa_mut_returning(), and mim::Lam::ret_var().

Referenced by call_cont(), and mim::plug::mach::Close::visit().

◆ callee_conv()

const Conv * mim::plug::mach::callee_conv ( const LamMap< Conv > & convs,
const Liveness::Block & block )
inline

The Conv of the callee that the call at the end of block returns from, if it has one.

Definition at line 167 of file liveness.h.

References mim::App::callee(), callee_conv(), and mim::Lam::isa_mut_returning().

Referenced by callee_conv().

◆ check_addr_space()

void mim::plug::mach::check_addr_space ( const App * app,
const Def * a )
inline

Bails unless the address space a of the mem operation app is 0.

Definition at line 31 of file mach.h.

References mim::App::axm(), mim::Def::blame(), check_addr_space(), and mim::Lit::isa().

Referenced by check_addr_space(), mim::plug::mach::Legalize::rewrite_imm_App(), and mim::plug::mach::LibCall::rewrite_imm_App().

◆ clobbered()

bool mim::plug::mach::clobbered ( const Target & target,
const Conv * conv,
Target::Class cls,
size_t r )
inline

Does a call of a function with the convention conv, or of an ABI function if there is none, clobber r?

Definition at line 173 of file liveness.h.

References mim::plug::mach::Target::caller_saved(), and clobbered().

Referenced by clobbered().

◆ color_fun()

void mim::plug::mach::color_fun ( const FunPhase & phase,
Lam * fun,
Liveness live,
LamMap< Conv > & convs,
std::ostream * dot )

Assigns a register to every value by one PBQP per function and register class (Buchwald, Zwinkau, Bersch, CC 2011).

The result is in the graph: every use of a value v in register r becomes Target::in. Expects the output of spill_fun() and constrain_fun(), so the interference graph is chordal. Removes chain instructions whose results are all dead, so its instruction implies the register of any unused result. A checker verifies the assignment on a fresh Liveness. A known() function gets a Conv in convs, which its callers, colored after it, follow instead of the ABI.

Definition at line 425 of file color.cpp.

References mim::plug::mach::Assign::Assign(), color_fun(), mim::plug::mach::FunPhase::known(), known(), mim::plug::mach::Liveness::Liveness(), rewrite_blocks(), mim::plug::mach::FunPhase::target(), and mim::Def::world().

Referenced by color_fun(), and mim::plug::mach::RegAlloc::visit().

◆ constrain_fun()

bool mim::plug::mach::constrain_fun ( const Liveness & live)

Copies fixed and live tied operands by a jump right before their instruction, keeping the graph chordal (Hack).

Likewise, the live fixed results of an instruction go to a fresh continuation right after it. Returns whether it changed anything, which makes live stale.

Definition at line 51 of file constrain.cpp.

References constrain_fun(), mim::plug::mach::Target::Gpr, mim::plug::core::mem_var(), mim::plug::mach::Target::result(), mim::Def::set(), mim::plug::mach::Subst::Subst(), mim::Def::unset(), and mim::Def::var().

Referenced by constrain_fun(), mim::plug::mach::Constrain::visit(), and mim::plug::mach::RegAlloc::visit().

◆ copies()

fe::Vector< std::pair< size_t, std::optional< size_t > > > mim::plug::mach::copies ( const Constraint & c,
auto live_after )
inline

The fixed operands with their registers, and the tied one with no register if it is live_after.

With clobbers, also every other operand with no register, since it must not sit in a clobbered register.

Definition at line 27 of file target.h.

References copies(), and mim::Lit::isa().

Referenced by copies().

◆ encoding()

template<class Reg>
size_t mim::plug::mach::encoding ( Reg r)
constexpr

The hardware encoding of the register r of a backend's module reg, whose subtags are in encoding order.

Definition at line 15 of file mach.h.

References encoding(), and mim::Annex::flags2sub().

Referenced by encoding().

◆ fold_ext()

const Def * mim::plug::mach::fold_ext ( const Def * type,
const Def * x,
bool sign )
inline

◆ for_each_succ()

void mim::plug::mach::for_each_succ ( const App * term,
auto f )
inline

Calls f for each block, possibly repeatedly, that the jump term passes control or a return continuation to.

Definition at line 18 of file liveness.h.

References mim::App::args(), mim::App::callee(), for_each_succ(), and mim::Lam::isa_mut_basicblock().

Referenced by for_each_succ(), and mim::plug::mach::Liveness::Liveness().

◆ for_each_use()

void mim::plug::mach::for_each_use ( const Liveness & live,
auto f )

Calls f for each use of a value in live.

Definition at line 113 of file liveness.h.

References for_each_use().

Referenced by for_each_use().

◆ forwarded()

Lam * mim::plug::mach::forwarded ( const LamMap< Lam * > & forward,
Lam * lam )
inline

Where a jump to lam goes once the blocks that forward skips are skipped.

Definition at line 103 of file liveness.h.

References forwarded().

Referenced by forwarded(), and layout().

◆ hook()

template<class A, class P>
void mim::plug::mach::hook ( Flags2Phases & phases)

Registers the Phase P for the annex A, constructed with the Target of the one loaded backend.

Definition at line 17 of file phase.h.

References mim::Annex::base(), mim::World::driver(), hook(), and mim::plug::mach::Target::of().

Referenced by hook(), reg_phases(), reg_phases(), and reg_phases().

◆ hook_isel()

template<class A>
void mim::plug::mach::hook_isel ( Flags2Phases & phases,
const rules::Table & table )

Registers ISel with the rules table as the Phase of the backend's annex A.

Definition at line 60 of file isel.h.

References mim::Annex::base(), mim::World::driver(), hook_isel(), and mim_mach_isel().

Referenced by hook_isel(), reg_phases(), and reg_phases().

◆ interferences()

template<class Keep, class F>
void mim::plug::mach::interferences ( const Liveness & live,
const Liveness::Block & block,
Keep keep,
F f )

Calls f (d, v) for each value v that is live at the definition of d or defined along with it.

Only values that satisfy keep take part.

Definition at line 188 of file liveness.h.

References interferences().

Referenced by interferences().

◆ is_value()

bool mim::plug::mach::is_value ( const Def * value,
Liveness::Class cls,
const Target & target )
inline

Is value a value of class cls?

Definition at line 98 of file liveness.h.

References mim::plug::mach::Target::cls(), mim::plug::mach::Target::is_mem(), is_value(), and mim::Def::type().

Referenced by is_value().

◆ known()

LamSet mim::plug::mach::known ( World & world)
inline

The closed Cns with a body that get a convention of their own instead of the ABI.

Such a function is neither external nor recursive, and only ever called or jumped to. Recursion also counts through other closed functions, so it takes the Nest of all of them.

Definition at line 33 of file phase.h.

References mim::World::for_each(), mim::Lam::isa_mut_cn(), known(), mim::Nest::Late, and mim::Nest::Nest().

Referenced by color_fun(), known(), and mim::plug::mach::FunPhase::start().

◆ layout()

fe::Vector< const Liveness::Block * > mim::plug::mach::layout ( const Liveness & live,
const LamMap< Lam * > & forward = {} )

The blocks of live in emission order: each block is followed by the one it falls through to, where possible.

A block that forward skips is not placed, and jumps to it count as jumps to its target.

Definition at line 200 of file liveness.cpp.

References forwarded(), and layout().

Referenced by layout().

◆ mim_mach_emit()

void mim::plug::mach::mim_mach_emit ( Emitter & emitter,
bool global )

Emitter::emit, compiled once into libmim_mach; Emitter reaches it via GET_FUN_PTR.

Definition at line 371 of file emit.cpp.

◆ mim_mach_gen()

void mim::plug::mach::mim_mach_gen ( Gen & gen)

Gen::start, compiled once into libmim_mach; Gen reaches it via GET_FUN_PTR.

Definition at line 1006 of file gen.cpp.

References mim::arg_value(), mim::Annex::flags2plugin(), mim_mach_gen(), and mim::Out::Out().

Referenced by mim_mach_gen(), and mim::plug::mach::Gen::start().

◆ mim_mach_isel()

Phase * mim::plug::mach::mim_mach_isel ( World & world,
flags_t annex,
const rules::Table & table )

A new ISel for the annex annex of a backend, with the rules table; compiled once into libmim_mach.

Definition at line 421 of file isel.cpp.

References mim::World::driver(), mim_mach_isel(), and mim::plug::mach::Target::of().

Referenced by hook_isel(), and mim_mach_isel().

◆ normalize_lit()

const Def * mim::plug::mach::normalize_lit ( const Def * type,
const Def * ,
const Def * arg )

Definition at line 7 of file normalizers.cpp.

References mim::Lit::isa(), and normalize_lit().

Referenced by normalize_lit().

◆ normalize_zext()

const Def * mim::plug::mach::normalize_zext ( const Def * type,
const Def * ,
const Def * x )

Definition at line 11 of file normalizers.cpp.

References fold_ext(), and normalize_zext().

Referenced by normalize_zext().

◆ num_params()

size_t mim::plug::mach::num_params ( Lam * lam)
inline

The parameters of lam without its return continuation.

Definition at line 145 of file liveness.h.

References num_params(), mim::Def::num_vars(), and mim::Lam::ret_pi().

Referenced by num_params(), and param_regs().

◆ param_regs()

ParamRegs mim::plug::mach::param_regs ( const Target & target,
Lam * fun,
const DefMap< size_t > & regs )

Where the known() function fun receives its parameters, given the registers regs that Color assigned to them.

A parameter in a callee-saved register arrives in a free caller-saved one, so the callee clobbers only those.

Definition at line 234 of file liveness.cpp.

References mim::Def::blame(), mim::plug::mach::Target::caller_saved(), mim::plug::mach::Target::cls(), mim::plug::mach::Target::is_mem(), mim::Target::name(), mim::plug::mach::Target::Num_Classes, num_params(), mim::plug::mach::Target::num_regs(), mim::Def::num_vars(), param_regs(), mim::plug::mach::Target::reserved(), and mim::Def::var().

Referenced by param_regs().

◆ register_normalizers()

void mim::plug::mach::register_normalizers ( Normalizers & normalizers)

◆ rewrite_blocks()

void mim::plug::mach::rewrite_blocks ( const Liveness & live,
Rewriter & rw )

Rewrites the filter and body of each block of live in place.

Definition at line 263 of file liveness.cpp.

References mim::Rewriter::rewrite(), rewrite_blocks(), mim::Def::set(), and mim::Def::unset().

Referenced by color_fun(), and rewrite_blocks().

◆ sorted()

fe::Vector< const Nest::Node * > mim::plug::mach::sorted ( const Nest::Node::SCC & scc)
inline

The Nodes of scc in a deterministic order.

Definition at line 24 of file phase.h.

References mim::Nest::Node::gid(), and sorted().

Referenced by sorted().

◆ spill_fun()

void mim::plug::mach::spill_fun ( const FunPhase & phase,
Lam * fun,
const LamMap< Conv > & convs,
std::optional< size_t > k )

Spills and reloads until at most k values of each register class are live at every point of a scheduled function.

This is Belady's MIN per block with global next-use distances (Braun & Hack, CC 2009), summarized per block. A jump reads its target's distances and tells the target which arguments it passes in registers. A value is spilled right after its definition, and only if it is reloaded somewhere or flows into a memory φ. A parameter that is not in a register at the entry of its block becomes a memory φ of the type Target::spill_type. Expects the output of Close: a reload is a new version within its block, and a jump passes the current one. A block nested in the one block that jumps to it starts from the versions at the end of that block. Across a call of a function with a Conv in convs, only its clobber set is lost, else the caller-saved registers. k is -X <backend>:k=<n> or the number of allocatable registers of a class.

Definition at line 507 of file spilling.cpp.

References spill_fun(), and mim::plug::mach::FunPhase::target().

Referenced by spill_fun(), mim::plug::mach::RegAlloc::visit(), and mim::plug::mach::Spilling::visit().

Variable Documentation

◆ Plugin_Id

plugin_t mim::plug::mach::Plugin_Id = 0x3821090000000000
staticconstexpr

Definition at line 10 of file autogen.h.