MimIR
0.6-dev
MimIR is my Intermediate Representation
Toggle main menu visibility
Loading...
Searching...
No Matches
live.cpp
Go to the documentation of this file.
1
#include <print>
2
3
#include "
mim/plug/mach/liveness.h
"
4
#include "
mim/plug/mach/regalloc.h
"
5
6
namespace
mim::plug::mach
{
7
8
namespace
{
9
10
std::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
16
std::string str(
const
DefVec
& values) {
return
std::format(
"{}"
, fe::Join(values,
", "
)); }
17
18
}
// namespace
19
20
void
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
mim::Def::gid
constexpr u32 gid() const noexcept
Global id - unique number for this Def.
Definition
def.h:308
mim::Lam
A function.
Definition
lam.h:91
mim::Out::Out
Out()=default
mim::plug::mach::FunPhase::target_args
const fe::Vector< std::string > & target_args()
The arguments -X <backend>:<arg> of the Target's backend plugin.
Definition
phase.h:63
mim::plug::mach::Live::visit
void visit(Lam *) final
Definition
live.cpp:20
mim::plug::mach::Liveness::Liveness
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
liveness.h
mim::plug::mach
The mach Plugin
Definition
asm.h:15
mim::plug::mach::live
live
Definition
autogen.h:165
mim::plug::mach::sorted
fe::Vector< const Nest::Node * > sorted(const Nest::Node::SCC &scc)
The Nodes of scc in a deterministic order.
Definition
phase.h:24
mim::DefVec
fe::Vector< const Def * > DefVec
Definition
def.h:96
mim::DefSet
GIDSet< const Def * > DefSet
Definition
def.h:92
mim::arg_value
std::optional< std::string_view > arg_value(fe::View< std::string > args, Keys... keys)
Definition
plugin.h:65
regalloc.h
src
mim
plug
mach
live.cpp
Generated by
1.18.0