MimIR
MimIR is my Intermediate Representation
Loading...
Searching...
No Matches
fuse.h
Go to the documentation of this file.
1#pragma once
2
3#include <mim/phase.h>
4
6
7class Fuse : public RWPhase {
8public:
11
12private:
13 void start() override;
14 const Def* rewrite_imm_App(const App*) final;
15
16 const Def* fuse_map_reduce(const App*);
17 const Def* fuse_epilogue(const App* callee, const Def* arg);
18 const Def* fuse_read_through(const App* callee, const Def* arg);
19 bool sole_consumer(const Def*) const;
20
21 /// Old-world consumer count per `map_reduce_post` app (attributed through tuple wrappers), for
22 /// the epilogue direction's single-consumer guard.
23 DefMap<u64> mr_consumers_;
24 /// New-world defs whose consumers were multiplied by bypassing a shared (or uncounted) read;
25 /// the old-world count cannot see this, so `sole_consumer` rejects them.
26 DefSet shared_;
27 /// Rewritten/fused `map_reduce_post` app → the old-world app it replaces, to look up the
28 /// consumer count of new-world fusion candidates.
29 DefMap<const Def*> new2old_;
30};
31
32} // namespace mim::plug::tensor::phase
Base class for all Defs.
Definition def.h:273
flags_t annex() const
Definition phase.h:81
RWPhase(World &world, std::string name, Analysis *analysis=nullptr)
Definition phase.h:431
World & world()=delete
Hides both and forbids direct access.
The World represents the whole program and manages creation of MimIR nodes (Defs).
Definition world.h:40
void start() override
Actual entry.
Definition fuse.cpp:637
Fuse(World &world, flags_t annex)
Definition fuse.h:9
const Def * rewrite_imm_App(const App *) final
Definition fuse.cpp:643
u64 flags_t
Definition types.h:39
GIDMap< const Def *, To > DefMap
Definition def.h:88
GIDSet< const Def * > DefSet
Definition def.h:89