1#ifndef TDL_INCLUDE_IR_CODEGEN_LIVENESS_H
2#define TDL_INCLUDE_IR_CODEGEN_LIVENESS_H
3
4#include "triton/codegen/analysis/layout.h"
5#include "triton/tools/graph.h"
6
7#include "llvm/ADT/MapVector.h"
8
9#include <set>
10#include <vector>
11
12namespace triton{
13
14namespace ir{
15 class value;
16 class phi_node;
17 class function;
18 class module;
19 class instruction;
20}
21
22namespace codegen{
23namespace analysis{
24
25typedef unsigned slot_index;
26
27class tiles;
28class layouts;
29class data_layout;
30
31struct segment {
32 slot_index start;
33 slot_index end;
34
35 bool contains(slot_index idx) const {
36 return start <= idx && idx < end;
37 }
38
39 bool intersect(const segment &Other){
40 return contains(Other.start) || Other.contains(start);
41 }
42};
43
44
45class liveness {
46private:
47 typedef llvm::MapVector<shared_layout*, segment> intervals_map_t;
48
49public:
50 // constructor
51 liveness(layouts *l): layouts_(l){ }
52 // accessors
53 const intervals_map_t& get() const { return intervals_; }
54 segment get(shared_layout* v) const { return intervals_.lookup(v); }
55 // run
56 void run(ir::module &mod);
57
58private:
59 // analysis
60 layouts *layouts_;
61 intervals_map_t intervals_;
62};
63
64}
65}
66}
67
68
69#endif
70