MimIR
MimIR is my Intermediate Representation
Loading...
Searching...
No Matches
rule_table.h File Reference
#include <array>
#include <span>
#include <string_view>
#include <utility>
#include <mim/util/types.h>
Include dependency graph for rule_table.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Classes

struct  mim::plug::mach::rules::RefInfo
 A ref of a matcher: its cover and how the lhs refers to it. More...
struct  mim::plug::mach::rules::Use
 An operand position of a matcher in preorder: meta variable or Value ref index of the node owner. More...
struct  mim::plug::mach::rules::Matcher
 A matcher and the shape of its lhs; a cover's operands follow it in preorder. More...
struct  mim::plug::mach::rules::Rewrite
 A closed rule lhs ↦ rhs, whose metas want num_metas consecutive entries of wants. More...
struct  mim::plug::mach::rules::Root
 The rewrites rewrites[first, first + num) with the root axiom flags; roots is sorted by it. More...
struct  mim::plug::mach::rules::Conversion
 A conversion rule x ↦ rhs, whose lhs is all of its meta variables: a value of non-terminal from as one of to. More...
struct  mim::plug::mach::rules::Chains
 The cheapest chains of conversions between two non-terminals: their costs and each one's first conversion. More...
struct  mim::plug::mach::rules::Table
 The generated tables of one backend, as its isel_rules.h defines them. More...

Namespaces

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

Macros

#define MIM_MACH_RULE_WANTS(X)
#define MIM_MACH_RULE_TYS(X)

Typedefs

using mim::plug::mach::rules::MatchFn = bool (*)(const Def* def, u32 swap, const Def** metas, const Def** refs)
 Matches the root def with the commuting nodes in swap swapped and binds metas and refs.
using mim::plug::mach::rules::BuildFn = const Def* (*)(World&, const Def* const* holes)
 Builds the rhs from holes, one per meta variable, already in the new world.

Enumerations

enum class  mim::plug::mach::rules::Want : u8
 What a rule wants of the term a meta variable matches; a Param is bound but no operand. More...
enum class  mim::plug::mach::rules::Ty : u8
 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  mim::plug::mach::rules::Ref : u8 {
  mim::plug::mach::rules::Value ,
  mim::plug::mach::rules::Mem
}
 How the lhs refers to one of its inner nodes. More...

Costs

Shared by an isel plugin's gen, which checks the rule set with them, and isel.

#define X(w)
#define X(t)
#define X(_)
constexpr u32 mim::plug::mach::rules::Inf = u32(-1)
constexpr size_t mim::plug::mach::rules::Num_Tys = 0 MIM_MACH_RULE_TYS(X)
constexpr u32 mim::plug::mach::rules::Copy = 1
 A register-to-register copy, which move elimination makes free of latency.
constexpr u32 mim::plug::mach::rules::add (u32 a, u32 b)
constexpr bool mim::plug::mach::rules::is_param (Want w)
 Is a meta variable that w wants bound to its rewrite rather than an operand?
constexpr bool mim::plug::mach::rules::is_literal (Want want)
 Does a hole of type want take a literal rather than a replacement?
constexpr Want mim::plug::mach::rules::literal_of (Want want)
 The literal form of a hole of type want, or want itself.
constexpr bool mim::plug::mach::rules::fills (Ty ty, Want want)
 Does a value of non-terminal ty fill a hole of type want as it is?
constexpr Want mim::plug::mach::rules::reg_want (Ty ty)
 The register hole that a value of non-terminal ty fills.
constexpr bool mim::plug::mach::rules::same_class (Ty ty, Want want)
 Is a value of non-terminal ty in the same register class as a hole of type want?

Class Documentation

◆ mim::plug::mach::rules::RefInfo

struct mim::plug::mach::rules::RefInfo

A ref of a matcher: its cover and how the lhs refers to it.

Definition at line 56 of file rule_table.h.

Class Members
u8 cover
Ref kind

◆ mim::plug::mach::rules::Use

struct mim::plug::mach::rules::Use

An operand position of a matcher in preorder: meta variable or Value ref index of the node owner.

Definition at line 62 of file rule_table.h.

Class Members
u8 index
u8 owner
bool ref

◆ mim::plug::mach::rules::Matcher

struct mim::plug::mach::rules::Matcher

A matcher and the shape of its lhs; a cover's operands follow it in preorder.

Definition at line 69 of file rule_table.h.

Class Members
MatchFn fn
u8 num_covers
u8 num_refs
u8 num_uses
u32 refs
u32 uses

◆ mim::plug::mach::rules::Rewrite

struct mim::plug::mach::rules::Rewrite

A closed rule lhs ↦ rhs, whose metas want num_metas consecutive entries of wants.

Definition at line 79 of file rule_table.h.

Class Members
BuildFn build
u32 copy_swaps Those of swaps whose operands differ only as a RegImm or RegSh, which a literal never fills.
u32 cost The summed instruction costs of its rhs.
u8 maps k + 1 if the rhs replaces cover k as a whole, or 0.
const Matcher * match
string_view name
u8 num_metas
flags_t root The axiom at the head of its lhs, or 0 for an Extract.
u32 swaps The swaps of match that may yield another match.
u32 tied The meta variables that a two-address instruction of the rhs overwrites.
Ty type The non-terminal its rhs yields.
u32 wants

◆ mim::plug::mach::rules::Root

struct mim::plug::mach::rules::Root

The rewrites rewrites[first, first + num) with the root axiom flags; roots is sorted by it.

Definition at line 95 of file rule_table.h.

Class Members
u32 first
flags_t flags
u32 num

◆ mim::plug::mach::rules::Conversion

struct mim::plug::mach::rules::Conversion

A conversion rule x ↦ rhs, whose lhs is all of its meta variables: a value of non-terminal from as one of to.

Its builder takes the arity projections of the value.

Definition at line 103 of file rule_table.h.

Class Members
u8 arity
BuildFn build
u32 cost
Ty from
string_view name
Ty to

◆ mim::plug::mach::rules::Table

struct mim::plug::mach::rules::Table

The generated tables of one backend, as its isel_rules.h defines them.

Definition at line 220 of file rule_table.h.

Class Members
const Chains & chains
span< const Conversion > conversions
span< const Matcher > matchers
size_t max_covers
size_t max_metas
size_t max_refs
span< const RefInfo > refs
span< const Rewrite > rewrites
span< const Root > roots
span< const Use > uses
span< const Want > wants

Macro Definition Documentation

◆ MIM_MACH_RULE_TYS

#define MIM_MACH_RULE_TYS ( X)
Value:
X(Reg) X(FReg) X(Base) X(Index) X(Scaled) X(Zx) X(Lit)
#define X(w)
Definition rule_table.h:29

Definition at line 34 of file rule_table.h.

◆ MIM_MACH_RULE_WANTS

#define MIM_MACH_RULE_WANTS ( X)
Value:
X(Param) X(Lit) X(Reg) X(FReg) X(Imm) X(Sh) X(RegImm) X(RegSh) X(Base) X(Index) X(Addr) X(Scaled) X(Zx)

Definition at line 18 of file rule_table.h.

◆ X [1/3]

#define X ( _)
Value:
+1

Definition at line 29 of file rule_table.h.

◆ X [2/3]

#define X ( t)
Value:
t,

Definition at line 29 of file rule_table.h.

◆ X [3/3]

#define X ( w)
Value:
w,

Definition at line 29 of file rule_table.h.

Referenced by automaton::minimize_dfa().