|
11 | 11 | #ifndef ROLLRAT_REGISTER_LEVEL_DOM_H |
12 | 12 | #define ROLLRAT_REGISTER_LEVEL_DOM_H |
13 | 13 |
|
| 14 | +#include <vector> |
| 15 | +#include <map> |
14 | 16 | #include "llvm/CodeGen/MachineFunction.h" |
15 | 17 |
|
16 | 18 | namespace llvm { |
17 | 19 |
|
| 20 | +typedef enum class _sign_ { |
| 21 | + None, |
| 22 | + Gen, |
| 23 | + Kill, |
| 24 | + Dead, |
| 25 | +} RegisterLevelSign; |
| 26 | + |
| 27 | +class InstructionRegisterInfo { |
| 28 | +public: |
| 29 | + using child_type = std::vector<std::pair<unsigned, RegisterLevelSign>>; |
| 30 | + using return_type = std::vector<unsigned>; |
| 31 | +private: |
| 32 | + child_type ChildInfo; |
| 33 | +public: |
| 34 | + return_type getRegisters(RegisterLevelSign sign) const { |
| 35 | + return_type result; |
| 36 | + for (auto e : ChildInfo) { |
| 37 | + if (e.second == sign) |
| 38 | + result.push_back(e.first); |
| 39 | + } |
| 40 | + return result; |
| 41 | + } |
| 42 | + |
| 43 | + return_type getGenRegisters() const { |
| 44 | + return getRegisters(RegisterLevelSign::Gen); |
| 45 | + } |
| 46 | + |
| 47 | + return_type getKillRegisters() const { |
| 48 | + return getRegisters(RegisterLevelSign::Kill); |
| 49 | + } |
| 50 | + |
| 51 | + return_type getDeadRegisters() const { |
| 52 | + return getRegisters(RegisterLevelSign::Dead); |
| 53 | + } |
| 54 | +}; |
| 55 | + |
| 56 | +class BasicBlockRegisterInfo { |
| 57 | +public: |
| 58 | + using child_type = std::map<MachineInstr *, InstructionRegisterInfo *>; |
| 59 | +private: |
| 60 | + child_type ChildInfo; |
| 61 | +public: |
| 62 | + child_type& childs() { return ChildInfo; } |
| 63 | +}; |
| 64 | + |
| 65 | +class FunctionRegisterInfo { |
| 66 | +public: |
| 67 | + using child_type = std::map<MachineBasicBlock *, BasicBlockRegisterInfo *>; |
| 68 | +private: |
| 69 | + child_type ChildInfo; |
| 70 | +public: |
| 71 | + child_type& childs() { return ChildInfo; } |
| 72 | +}; |
| 73 | + |
18 | 74 | class RegisterLevelDom { |
| 75 | +public: |
| 76 | + RegisterLevelDom(MachineFunction& MF); |
19 | 77 |
|
| 78 | +private: |
| 79 | + std::vector<MachineInstr *> FindFInstrs(MachineFunction& MF); |
| 80 | + FunctionRegisterInfo *BuildRegisterInfo(MachineFunction& MF); |
20 | 81 | }; |
21 | 82 |
|
22 | 83 | } |
|
0 commit comments