MimIR
MimIR is my Intermediate Representation
Loading...
Searching...
No Matches
core.cpp
Go to the documentation of this file.
2
3#include <mim/config.h>
4#include <mim/phase.h>
5
6using namespace mim;
7using namespace mim::plug;
8
10 return {"core", MIM_VERSION, core::register_normalizers, {}, {}, {}, {}, {}};
11}
12
13namespace mim::plug::core {
14
15template<bool up>
16const 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
42template const Sigma* convert(const TBound<false>*);
43template const Sigma* convert(const TBound<true>*);
44#endif
45
46} // namespace mim::plug::core
World & world() const noexcept
Definition def.h:1097
constexpr auto ops() const noexcept
Definition def.h:348
constexpr size_t num_ops() const noexcept
Definition def.h:352
static std::optional< T > isa(const Def *def)
Definition def.h:937
A dependent tuple type.
Definition tuple.h:23
Specific Bound depending on Up.
Definition lattice.h:35
#define MIM_EXPORT
Definition config.h:21
The core Plugin
Definition core.h:8
const Sigma * convert(const TBound< up > *b)
Definition core.cpp:16
const Def * op(trait o, const Def *type)
Definition core.h:35
void register_normalizers(Normalizers &normalizers)
Definition ast.h:16
u64 nat_t
Definition types.h:37
mim::Plugin mim_get_plugin()
#define MIM_VERSION
Definition plugin.h:149
Basic info and registration function pointer to be returned from a specific plugin.
Definition plugin.h:154