MimIR
0.1
MimIR is my Intermediate Representation
Loading...
Searching...
No Matches
normalizers.cpp
Go to the documentation of this file.
1
#include "
mim/world.h
"
2
3
#include "
mim/plug/mem/mem.h
"
4
5
namespace
mim::plug::mem
{
6
7
Ref
normalize_lea
(
Ref
,
Ref
,
Ref
arg) {
8
auto
[ptr, index] = arg->
projs
<2>();
9
auto
[pointee, addr_space] =
force<Ptr>
(ptr->type())->args<2>();
10
11
if
(
auto
a =
Lit::isa
(pointee->arity()); a && *a == 1)
return
ptr;
12
// TODO
13
14
return
{};
15
}
16
17
Ref
normalize_load
(
Ref
type,
Ref
,
Ref
arg) {
18
auto
& world = type->
world
();
19
auto
[
mem
, ptr] = arg->
projs
<2>();
20
auto
[pointee, addr_space] =
force<Ptr>
(ptr->type())->args<2>();
21
22
if
(ptr->isa<
Bot
>())
return
world.tuple({
mem
, world.bot(type->as<
Sigma
>()->
op
(1))});
23
24
// loading an empty tuple can only result in an empty tuple
25
if
(
auto
sigma = pointee->isa<
Sigma
>(); sigma && sigma->
num_ops
() == 0)
26
return
world.tuple({
mem
, world.tuple(sigma->type(), {})});
27
28
return
{};
29
}
30
31
Ref
normalize_remem
(
Ref
,
Ref
,
Ref
) {
return
{}; }
32
33
Ref
normalize_store
(
Ref
,
Ref
,
Ref
arg) {
34
auto
[
mem
, ptr, val] = arg->
projs
<3>();
35
36
if
(ptr->isa<
Bot
>() || val->isa<
Bot
>())
return
mem
;
37
if
(
auto
pack = val->isa<
Pack
>(); pack && pack->
body
()->isa<
Bot
>())
return
mem
;
38
if
(
auto
tuple = val->isa<
Tuple
>()) {
39
if
(std::ranges::all_of(tuple->ops(), [](
Ref
op) { return op->isa<Bot>(); }))
return
mem
;
40
}
41
42
return
{};
43
}
44
45
MIM_mem_NORMALIZER_IMPL
46
47
}
// namespace mim::plug::mem
mim::Def::num_ops
size_t num_ops() const
Definition
def.h:273
mim::Def::world
World & world() const
Definition
def.cpp:411
mim::Def::op
Ref op(size_t i) const
Definition
def.h:272
mim::Def::projs
auto projs(F f) const
Splits this Def via Def::projections into an Array (if A == std::dynamic_extent) or std::array (other...
Definition
def.h:361
mim::Lit::isa
static std::optional< T > isa(Ref def)
Definition
def.h:762
mim::Pack
A (possibly paramterized) Tuple.
Definition
tuple.h:114
mim::Pack::body
Ref body() const
Definition
tuple.h:124
mim::Ref
Helper class to retrieve Infer::arg if present.
Definition
def.h:86
mim::Sigma
A dependent tuple type.
Definition
tuple.h:9
mim::TExt
Extremum. Either Top (Up) or Bottom.
Definition
lattice.h:156
mim::Tuple
Data constructor for a Sigma.
Definition
tuple.h:50
MIM_mem_NORMALIZER_IMPL
#define MIM_mem_NORMALIZER_IMPL
Definition
autogen.h:186
mem.h
mim::plug::mem
The mem Plugin
Definition
mem.h:11
mim::plug::mem::normalize_lea
Ref normalize_lea(Ref, Ref, Ref arg)
Definition
normalizers.cpp:7
mim::plug::mem::normalize_remem
Ref normalize_remem(Ref, Ref, Ref)
Definition
normalizers.cpp:31
mim::plug::mem::normalize_store
Ref normalize_store(Ref, Ref, Ref arg)
Definition
normalizers.cpp:33
mim::plug::mem::normalize_load
Ref normalize_load(Ref type, Ref, Ref arg)
Definition
normalizers.cpp:17
mim::force
auto force(Ref def)
Definition
axiom.h:133
world.h
src
mim
plug
mem
normalizers.cpp
Generated by
1.12.0