MimIR
0.4-dev
MimIR is my Intermediate Representation
Toggle main menu visibility
Loading...
Searching...
No Matches
core.cpp
Go to the documentation of this file.
1
#include "
mim/plug/core/core.h
"
2
3
#include <
mim/config.h
>
4
#include <
mim/phase.h
>
5
6
using namespace
mim
;
7
using namespace
mim::plug
;
8
9
extern
"C"
MIM_EXPORT
Plugin
mim_get_plugin
() {
10
return
{
"core"
,
MIM_VERSION
,
core::register_normalizers
, {}, {}, {}, {}, {}};
11
}
12
13
namespace
mim::plug::core
{
14
15
template
<
bool
up>
16
const
Sigma
*
convert
(
const
TBound<up>
* b) {
17
auto
& w = b->
world
();
18
19
if
constexpr
(up) {
20
nat_t
align
= 0;
21
nat_t
size = 0;
22
23
for
(
auto
op
: b->
ops
()) {
24
auto
a
=
Lit::isa
(w.call(
trait::align
,
op
));
25
auto
s
=
Lit::isa
(w.call(
trait::size
,
op
));
26
if
(!
a
|| !
s
)
return
nullptr
;
27
28
align
= std::max(
align
, *
a
);
29
size = std::max(size, *
s
);
30
}
31
32
assert(size %
align
== 0);
33
auto
arr = w.arr(size /
align
, w.type_int(
align
* 8_u64));
34
35
return
w.sigma({w.type_idx(b->
num_ops
()), arr})->
template
as<Sigma>();
36
}
else
{
37
return
w.sigma(b->
ops
())->template as<Sigma>();
38
}
39
}
40
41
#ifndef DOXYGEN
42
template
const
Sigma
*
convert
(
const
TBound<false>
*);
43
template
const
Sigma
*
convert
(
const
TBound<true>
*);
44
#endif
45
46
}
// namespace mim::plug::core
mim::Def::world
World & world() const noexcept
Definition
def.h:1097
mim::Def::ops
constexpr auto ops() const noexcept
Definition
def.h:348
mim::Def::num_ops
constexpr size_t num_ops() const noexcept
Definition
def.h:352
mim::Lit::isa
static std::optional< T > isa(const Def *def)
Definition
def.h:937
mim::Sigma
A dependent tuple type.
Definition
tuple.h:23
mim::TBound
Specific Bound depending on Up.
Definition
lattice.h:35
config.h
MIM_EXPORT
#define MIM_EXPORT
Definition
config.h:21
core.h
mim::plug::core
The core Plugin
Definition
core.h:8
mim::plug::core::convert
const Sigma * convert(const TBound< up > *b)
Definition
core.cpp:16
mim::plug::core::conv::s
@ s
Definition
autogen.h:253
mim::plug::core::trait::align
@ align
Definition
autogen.h:274
mim::plug::core::trait::size
@ size
Definition
autogen.h:273
mim::plug::core::op
const Def * op(trait o, const Def *type)
Definition
core.h:35
mim::plug::core::register_normalizers
void register_normalizers(Normalizers &normalizers)
mim::plug::core::shr::a
@ a
Definition
autogen.h:126
mim::plug
Definition
lower_for.h:5
mim
Definition
ast.h:16
mim::nat_t
u64 nat_t
Definition
types.h:37
mim::mim_get_plugin
mim::Plugin mim_get_plugin()
phase.h
MIM_VERSION
#define MIM_VERSION
Definition
plugin.h:149
mim::Plugin
Basic info and registration function pointer to be returned from a specific plugin.
Definition
plugin.h:154
src
mim
plug
core
core.cpp
Generated by
1.18.0