7 #include "core/adt/bitset.h"
11 #include "core/inst_visitor.h"
12 #include "passes/global_forward/nodes.h"
41 std::unordered_map<unsigned, std::unique_ptr<NodeState>> States;
45 , Active(dag.rbegin()->
Index)
52 auto it = States.emplace(index,
nullptr);
56 return *it.first->second;
65 void VisitInst(
Inst &inst)
override { }
67 void VisitMovInst(
MovInst &mov)
override;
68 void VisitMemoryStoreInst(MemoryStoreInst &store)
override;
69 void VisitMemoryLoadInst(MemoryLoadInst &load)
override;
70 void VisitCallSite(CallSite &site)
override;
71 void VisitTrapInst(TrapInst &)
override { }
72 void VisitRaiseInst(RaiseInst &
raise)
override { Raises =
true; }
78 bool Indirect =
false;
106 bool VisitInst(
Inst &inst)
override {
return false; }
108 bool VisitAddInst(AddInst &add)
override;
109 bool VisitMovInst(
MovInst &mov)
override;
110 bool VisitMemoryStoreInst(MemoryStoreInst &store)
override;
111 bool VisitMemoryLoadInst(MemoryLoadInst &load)
override;
112 bool VisitMemoryExchangeInst(MemoryExchangeInst &xchg)
override;
114 bool VisitTerminatorInst(TerminatorInst &)
override
116 llvm_unreachable(
"cannot evaluate terminator");
146 auto it = funcToID_.find(&func);
147 assert(it != funcToID_.end() &&
"missing function");
154 auto it = objectToID_.find(
object);
155 assert(it != objectToID_.end() &&
"missing object");
162 auto &dag = funcs_[GetFuncID(func)]->DAG;
172 std::pair<Func *, unsigned> key(&func, index);
173 auto it = reverse_.emplace(key,
nullptr);
177 return *it.first->second;
187 std::unordered_map<Object *, ID<Object>> objectToID_;
189 std::vector<std::unique_ptr<ObjectClosure>> objects_;
191 std::vector<Object *> idToObject_;
194 std::unordered_map<Func *, ID<Func>> funcToID_;
196 std::vector<std::unique_ptr<FuncClosure>> funcs_;
200 < std::pair<Func *, unsigned>
201 , std::unique_ptr<ReverseNodeState>
205 std::vector<FuncState> stack_;