Thorin 1.9.0
The Higher ORder INtermediate representation
Loading...
Searching...
No Matches
core.cpp
Go to the documentation of this file.
2
3#include <thorin/config.h>
4
5#include <thorin/pass/pass.h>
6
8
9using namespace thorin;
10using namespace thorin::plug;
11
13 return {"core", [](Normalizers& normalizers) { core::register_normalizers(normalizers); }, nullptr,
14 [](Backends& backends) { backends["ll"] = &ll::emit; }};
15}
16
17namespace thorin::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 thorin::plug::core
auto ops() const
Definition def.h:268
size_t num_ops() const
Definition def.h:270
World & world() const
Definition def.cpp:421
static std::optional< T > isa(Ref def)
Definition def.h:726
A dependent tuple type.
Definition tuple.h:9
Specific Bound depending on Up.
Definition lattice.h:31
#define THORIN_EXPORT
Definition config.h:16
void emit(World &, std::ostream &)
Definition ll.cpp:1065
The core Plugin
Definition core.h:8
void register_normalizers(Normalizers &normalizers)
Ref op(trait o, Ref type)
Definition core.h:35
const Sigma * convert(const TBound< up > *b)
Definition core.cpp:19
Definition cfg.h:11
THORIN_EXPORT thorin::Plugin thorin_get_plugin()
To be implemented and exported by a plugin.
u64 nat_t
Definition types.h:44
absl::flat_hash_map< flags_t, NormalizeFn > Normalizers
Definition plugin.h:19
absl::btree_map< std::string, void(*)(World &, std::ostream &)> Backends
Definition plugin.h:23
Basic info and registration function pointer to be returned from a specific plugin.
Definition plugin.h:29