MimIR
MimIR is my Intermediate Representation
Loading...
Searching...
No Matches
live.cpp
Go to the documentation of this file.
1#include <print>
2
5
6namespace mim::plug::mach {
7
8namespace {
9
10std::string str(const DefSet& values) {
11 auto sorted = DefVec(values.begin(), values.end());
12 std::ranges::sort(sorted, {}, &Def::gid);
13 return std::format("{}", fe::Join(sorted, ", "));
14}
15
16std::string str(const DefVec& values) { return std::format("{}", fe::Join(values, ", ")); }
17
18} // namespace
19
20void Live::visit(Lam* fun) {
21 auto out = Out(std::string(arg_value(target_args(), "live").value_or("-")));
22 auto& os = *out.os();
23 auto live = Liveness(*this, fun);
24 std::println(os, "fun {}", fun);
25 for (const auto& block : live.blocks())
26 std::println(os, " {}: params {{{}}} in {{{}}} out {{{}}} max {} fpr {} flags {}", block.lam,
27 str(block.params), str(block.live_in), str(block.live_out), block.max_live[Liveness::Gpr],
28 block.max_live[Liveness::Fpr], block.max_live[Liveness::Flags]);
29}
30
31} // namespace mim::plug::mach
constexpr u32 gid() const noexcept
Global id - unique number for this Def.
Definition def.h:308
A function.
Definition lam.h:91
Out()=default
const fe::Vector< std::string > & target_args()
The arguments -X <backend>:<arg> of the Target's backend plugin.
Definition phase.h:63
void visit(Lam *) final
Definition live.cpp:20
Liveness(const FunPhase &phase, Lam *fun, bool solve=false)
Bails unless the blocks of the function fun are closed; with solve, it iterates to the fixed point in...
Definition liveness.cpp:11
The mach Plugin
Definition asm.h:15
fe::Vector< const Nest::Node * > sorted(const Nest::Node::SCC &scc)
The Nodes of scc in a deterministic order.
Definition phase.h:24
fe::Vector< const Def * > DefVec
Definition def.h:96
GIDSet< const Def * > DefSet
Definition def.h:92
std::optional< std::string_view > arg_value(fe::View< std::string > args, Keys... keys)
Definition plugin.h:65