LLVM: include/llvm/CodeGen/GlobalISel/GISelWorkList.h Source File (original) (raw)
1
2
3
4
5
6
7
8
9#ifndef LLVM_CODEGEN_GLOBALISEL_GISELWORKLIST_H
10#define LLVM_CODEGEN_GLOBALISEL_GISELWORKLIST_H
11
14
15namespace llvm {
16
18
19
20
21
22
23
24
25
26template
30
31#if LLVM_ENABLE_ABI_BREAKING_CHECKS
32 bool Finalized = true;
33#endif
34
35public:
37
38 bool empty() const { return WorklistMap.empty(); }
39
40 unsigned size() const { return WorklistMap.size(); }
41
42
43
44
45
46
47
48
49
51 Worklist.push_back(I);
52#if LLVM_ENABLE_ABI_BREAKING_CHECKS
53 Finalized = false;
54#endif
55 }
56
57
58
59
60
62 assert(WorklistMap.empty() && "Expecting empty worklistmap");
63 if (Worklist.size() > N)
64 WorklistMap.reserve(Worklist.size());
65 for (unsigned i = 0; i < Worklist.size(); ++i)
66 if (!WorklistMap.try_emplace(Worklist[i], i).second)
68#if LLVM_ENABLE_ABI_BREAKING_CHECKS
69 Finalized = true;
70#endif
71 }
72
73
75#if LLVM_ENABLE_ABI_BREAKING_CHECKS
76 assert(Finalized && "GISelWorkList used without finalizing");
77#endif
78 if (WorklistMap.try_emplace(I, Worklist.size()).second)
79 Worklist.push_back(I);
80 }
81
82
84#if LLVM_ENABLE_ABI_BREAKING_CHECKS
85 assert(Finalized && "GISelWorkList used without finalizing");
86#endif
87 auto It = WorklistMap.find(I);
88 if (It == WorklistMap.end())
89 return;
90
91
92 Worklist[It->second] = nullptr;
93
94 WorklistMap.erase(It);
95 }
96
98 Worklist.clear();
99 WorklistMap.clear();
100 }
101
103#if LLVM_ENABLE_ABI_BREAKING_CHECKS
104 assert(Finalized && "GISelWorkList used without finalizing");
105#endif
107 do {
108 I = Worklist.pop_back_val();
109 } while();
110 assert(I && "Pop back on empty worklist");
111 WorklistMap.erase(I);
112 return I;
113 }
114};
115
116}
117
118#endif
assert(UImm &&(UImm !=~static_cast< T >(0)) &&"Invalid immediate!")
This file defines the DenseMap class.
This file defines the SmallVector class.
void insert(MachineInstr *I)
Add the specified instruction to the worklist if it isn't already in it.
Definition GISelWorkList.h:74
MachineInstr * pop_back_val()
Definition GISelWorkList.h:102
GISelWorkList()
Definition GISelWorkList.h:36
unsigned size() const
Definition GISelWorkList.h:40
void deferred_insert(MachineInstr *I)
Definition GISelWorkList.h:50
void finalize()
Definition GISelWorkList.h:61
bool empty() const
Definition GISelWorkList.h:38
void remove(const MachineInstr *I)
Remove I from the worklist if it exists.
Definition GISelWorkList.h:83
void clear()
Definition GISelWorkList.h:97
Representation of each machine instruction.
This is a 'vector' (really, a variable-sized array), optimized for the case when the array is small.
#define llvm_unreachable(msg)
Marks that the current location is not supposed to be reachable.
This is an optimization pass for GlobalISel generic memory operations.