Skip to content

Commit de98c5c

Browse files
committed
trace-register: Add register-info classes.
1 parent 667545f commit de98c5c

File tree

2 files changed

+83
-1
lines changed

2 files changed

+83
-1
lines changed

lib/Target/X86/RegisterLevelDom.cpp

Lines changed: 22 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,4 +8,25 @@
88
//
99
//===----------------------------------------------------------------------===//
1010

11-
#include "RegisterLevelDom.h"
11+
#include "RegisterLevelDom.h"
12+
#include "llvm/Transforms/Utils/InjectFault.h"
13+
14+
using namespace llvm;
15+
16+
RegisterLevelDom::RegisterLevelDom(MachineFunction& MF) {
17+
auto target = FindFInstrs(MF);
18+
19+
20+
}
21+
22+
std::vector<MachineInstr *> RegisterLevelDom::FindFInstrs(MachineFunction& MF) {
23+
std::vector<MachineInstr *> result;
24+
for (auto bb = MF.begin(); bb != MF.end(); bb++) {
25+
for (auto inst = bb->begin(); inst != bb->end(); inst++) {
26+
if (inst->getDebugLoc()) {
27+
result.push_back(&*inst);
28+
}
29+
}
30+
}
31+
return result;
32+
}

lib/Target/X86/RegisterLevelDom.h

Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,12 +11,73 @@
1111
#ifndef ROLLRAT_REGISTER_LEVEL_DOM_H
1212
#define ROLLRAT_REGISTER_LEVEL_DOM_H
1313

14+
#include <vector>
15+
#include <map>
1416
#include "llvm/CodeGen/MachineFunction.h"
1517

1618
namespace llvm {
1719

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+
1874
class RegisterLevelDom {
75+
public:
76+
RegisterLevelDom(MachineFunction& MF);
1977

78+
private:
79+
std::vector<MachineInstr *> FindFInstrs(MachineFunction& MF);
80+
FunctionRegisterInfo *BuildRegisterInfo(MachineFunction& MF);
2081
};
2182

2283
}

0 commit comments

Comments
 (0)