MimIR
0.6-dev
MimIR is my Intermediate Representation
Toggle main menu visibility
Loading...
Searching...
No Matches
gen.cpp
Go to the documentation of this file.
1
#include "
mim/plug/x86_isel/gen.h
"
2
3
#include <
mim/plug/mach/mach.h
>
4
#include <
mim/plug/x86/autogen.h
>
5
#include <
mim/plug/x86/insn.h
>
6
7
#include "
mim/plug/x86_isel/x86_isel.h
"
8
9
namespace
mim::plug::x86_isel
{
10
11
using
mach::rules::Want
;
12
13
Gen::Gen
(
World
&
world
,
flags_t
annex
)
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>
(),
27
.lit =
Annex::base<mach::lit>
(),
28
.commutes =
Annex::base<commutes>
(),
29
.formats =
Annex::base<formats>
(),
30
.sizes =
Annex::base<sizes>
(),
31
}) {}
32
33
u32
Gen::cost
(
const
App
* insn)
const
{
return
x86::insn::cost
(insn); }
34
35
std::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.
38
std::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
mim::App
Definition
lam.h:215
mim::Axm::isa
static auto isa(const Def *def)
Definition
axm.h:112
mim::Def
Base class for all Defs.
Definition
def.h:285
mim::Lit::isa
static std::optional< T > isa(const Def *def)
Definition
def.h:974
mim::Phase::annex
flags_t annex() const
Definition
phase.h:64
mim::Phase::world
World & world()
Definition
phase.h:60
mim::World
The World represents the whole program and manages creation of MimIR nodes (Defs).
Definition
world.h:43
mim::plug::x86_isel::Gen::classify
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
mim::plug::x86_isel::Gen::Gen
Gen(World &world, flags_t annex)
Definition
gen.cpp:13
mim::plug::x86_isel::Gen::cost
u32 cost(const App *insn) const final
Definition
gen.cpp:33
mim::plug::x86_isel::Gen::tied
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
mach.h
mim::plug::mach::rules::Want
Want
What a rule wants of the term a meta variable matches; a Param is bound but no operand.
Definition
rule_table.h:28
mim::plug::mach
The mach Plugin
Definition
asm.h:15
mim::plug::x86::insn::tied
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
mim::plug::x86::insn::cost
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
mim::plug::x86_isel
The x86_isel Plugin
Definition
gen.h:5
mim::plug::x86_isel::addr
addr
Definition
autogen.h:22
mim::plug::x86
The x86 Plugin
Definition
emit.h:9
mim::flags_t
u64 flags_t
Definition
types.h:39
mim::u32
uint32_t u32
Definition
types.h:27
mim::Annex::base
static consteval flags_t base()
Definition
plugin.h:278
autogen.h
insn.h
gen.h
x86_isel.h
src
mim
plug
x86_isel
gen.cpp
Generated by
1.18.0