MimIR
MimIR is my Intermediate Representation
Loading...
Searching...
No Matches
ll.cpp
Go to the documentation of this file.
1#include "mim/plug/ll/ll.h"
2
3#include <fstream>
4#include <string>
5
6#include <mim/config.h>
7#include <mim/phase.h>
8#include <mim/plugin.h>
9
10#include "mim/plug/ll/autogen.h"
11
12namespace mim::plug::ll {
13
14using namespace std::string_literals;
15
16/// Pipeline phase for `%ll.emit`.
17/// Writes the LLVM IR of the fully lowered world to `<world>.ll` or `a.ll`.
18class Emit : public Phase {
19public:
22
23 void start() override {
24 auto name = world().name() ? std::string(world().name().view()) : "a"s;
25 auto ofs = std::ofstream(name + ".ll"s);
26 auto emitter = Emitter(world(), ofs);
27 emitter.run();
28 }
29};
30
31} // namespace mim::plug::ll
32
33using namespace mim;
34
36
37extern "C" MIM_EXPORT Plugin mim_get_plugin() { return {"ll", MIM_VERSION, nullptr, reg_stages}; }
void reg_stages(Flags2Stages &stages)
Definition affine.cpp:12
Phase(World &world, std::string name)
Definition phase.h:31
World & world()
Definition pass.h:77
std::string_view name() const
Definition pass.h:80
static void hook(Flags2Stages &stages)
Definition pass.h:70
flags_t annex() const
Definition pass.h:81
The World represents the whole program and manages creation of MimIR nodes (Defs).
Definition world.h:36
Sym name() const
Definition world.h:97
void start() override
Actual entry.
Definition ll.cpp:23
Emit(World &world, flags_t annex)
Definition ll.cpp:20
#define MIM_EXPORT
Definition config.h:19
static void reg_stages(Flags2Stages &stages)
Definition ll.cpp:35
The ll Plugin
Definition ll.h:38
Definition ast.h:14
u64 flags_t
Definition types.h:39
absl::flat_hash_map< flags_t, std::function< std::unique_ptr< Stage >(World &)> > Flags2Stages
Maps an an axiom of a Stage to a function that creates one.
Definition plugin.h:25
mim::Plugin mim_get_plugin()
#define MIM_VERSION
Definition plugin.h:54
Basic info and registration function pointer to be returned from a specific plugin.
Definition plugin.h:59