MimIR
MimIR is my Intermediate Representation
Loading...
Searching...
No Matches
gen.cpp
Go to the documentation of this file.
2
5#include <mim/plug/x86/insn.h>
6
8
9namespace mim::plug::x86_isel {
10
12
14 : mach::Gen(world,
15 annex,
16 "x86",
17 x86::Plugin_Id,
18 "x86_isel",
19 Plugin_Id,
20 {
21 .addr = Annex::base<addr>(),
22 .reg_imm = Annex::base<reg_imm>(),
23 .reg_sh = Annex::base<reg_sh>(),
24 .scaled = Annex::base<scaled>(),
25 .zx = Annex::base<zx>(),
26 .imm = Annex::base<imm>(),
28 .commutes = Annex::base<commutes>(),
29 .formats = Annex::base<formats>(),
30 .sizes = Annex::base<sizes>(),
31 }) {}
32
33u32 Gen::cost(const App* insn) const { return x86::insn::cost(insn); }
34
35std::optional<size_t> Gen::tied(const App* insn) const { return x86::insn::tied(insn); }
36
37/// An `x86.Addr i` is a Base, an Index, or, for a dynamic `i`, either.
38std::optional<Want> Gen::classify(const Def* type) const {
39 if (auto addr = Axm::isa<x86::Addr>(type)) {
40 auto i = Lit::isa(addr->arg());
41 return !i ? Want::Addr : *i ? Want::Index : Want::Base;
42 }
43 return {};
44}
45
46} // namespace mim::plug::x86_isel
static auto isa(const Def *def)
Definition axm.h:112
Base class for all Defs.
Definition def.h:285
static std::optional< T > isa(const Def *def)
Definition def.h:974
flags_t annex() const
Definition phase.h:64
World & world()
Definition phase.h:60
The World represents the whole program and manages creation of MimIR nodes (Defs).
Definition world.h:43
std::optional< mach::rules::Want > classify(const Def *type) const final
An x86.Addr i is a Base, an Index, or, for a dynamic i, either.
Definition gen.cpp:38
Gen(World &world, flags_t annex)
Definition gen.cpp:13
u32 cost(const App *insn) const final
Definition gen.cpp:33
std::optional< size_t > tied(const App *insn) const final
The operand whose register the result of the two-address instruction insn takes.
Definition gen.cpp:35
Want
What a rule wants of the term a meta variable matches; a Param is bound but no operand.
Definition rule_table.h:28
The mach Plugin
Definition asm.h:15
std::optional< size_t > tied(flags_t base)
The operand whose register the result of a two-address instruction base takes.
Definition insn.h:20
u32 cost(const App *app)
The cost of the instruction app: its latency plus one, so of two equally fast covers the shorter wins...
Definition insn.h:65
The x86_isel Plugin
Definition gen.h:5
The x86 Plugin
Definition emit.h:9
u64 flags_t
Definition types.h:39
uint32_t u32
Definition types.h:27
static consteval flags_t base()
Definition plugin.h:278