MimIR 0.1
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
5#include <mim/pass/pass.h>
6
8
9using namespace mim;
10using namespace mim::plug;
11
13 return {"core", [](Normalizers& normalizers) { core::register_normalizers(normalizers); }, nullptr,
14 [](Backends& backends) { backends["ll"] = &ll::emit; }};
15}
16
17namespace mim::plug::core {
18
19template<bool up> const Sigma* convert(const TBound<up>* b) {
20 auto& w = b->world();
21
22 if constexpr (up) {
23 nat_t align = 0;
24 nat_t size = 0;
25
26 for (auto op : b->ops()) {
27 auto a = Lit::isa(w.call(trait::align, op));
28 auto s = Lit::isa(w.call(trait::size, op));
29 if (!a || !s) return nullptr;
30
31 align = std::max(align, *a);
32 size = std::max(size, *s);
33 }
34
35 assert(size % align == 0);
36 auto arr = w.arr(size / align, w.type_int(align * 8_u64));
37
38 return w.sigma({w.type_idx(b->num_ops()), arr})->template as<Sigma>();
39 } else {
40 return w.sigma(b->ops())->template as<Sigma>();
41 }
42}
43
44#ifndef DOXYGEN
45template const Sigma* convert(const TBound<false>*);
46template const Sigma* convert(const TBound<true>*);
47#endif
48
49} // namespace mim::plug::core
size_t num_ops() const
Definition def.h:270
World & world() const
Definition def.cpp:415
auto ops() const
Definition def.h:268
static std::optional< T > isa(Ref def)
Definition def.h:763
A dependent tuple type.
Definition tuple.h:9
Specific Bound depending on Up.
Definition lattice.h:31
#define MIM_EXPORT
Definition config.h:16
void emit(World &, std::ostream &)
Definition ll.cpp:1065
The core Plugin
Definition core.h:8
const Sigma * convert(const TBound< up > *b)
Definition core.cpp:19
Ref op(trait o, Ref type)
Definition core.h:33
void register_normalizers(Normalizers &normalizers)
Definition cfg.h:11
u64 nat_t
Definition types.h:43
absl::btree_map< std::string, void(*)(World &, std::ostream &)> Backends
Definition plugin.h:23
MIM_EXPORT mim::Plugin mim_get_plugin()
absl::flat_hash_map< flags_t, NormalizeFn > Normalizers
Definition plugin.h:19
Basic info and registration function pointer to be returned from a specific plugin.
Definition plugin.h:29