9#ifndef LLVM_TRANSFORMS_VECTORIZE_SANDBOXVEC_PASSES_INSTRMAPS_H
10#define LLVM_TRANSFORMS_VECTORIZE_SANDBOXVEC_PASSES_INSTRMAPS_H
37 std::optional<Context::CallbackID> EraseInstrCB;
40 void notifyEraseInstr(
Value *V) {
42 auto It = OrigToVectorMap.
find(V);
43 if (It != OrigToVectorMap.
end()) {
46 Value *Vec = It->second;
47 VectorToOrigLaneMap[Vec].
erase(V);
49 OrigToVectorMap.
erase(It);
54 for (
auto [Orig, Lane] : VectorToOrigLaneMap[V])
55 OrigToVectorMap.
erase(Orig);
57 VectorToOrigLaneMap.
erase(V);
70 auto It = OrigToVectorMap.
find(Orig);
71 return It != OrigToVectorMap.
end() ? It->second :
nullptr;
76 auto It1 = VectorToOrigLaneMap.
find(Vec);
77 if (It1 == VectorToOrigLaneMap.
end())
79 const auto &OrigToLaneMap = It1->second;
80 auto It2 = OrigToLaneMap.find(Orig);
81 if (It2 == OrigToLaneMap.end())
87 auto &OrigToLaneMap = VectorToOrigLaneMap[Vec];
88 for (
auto [Lane, Orig] :
enumerate(Origs)) {
90 assert(Pair.second &&
"Orig already exists in the map!");
92 OrigToLaneMap[Orig] = Lane;
96 OrigToVectorMap.
clear();
97 VectorToOrigLaneMap.
clear();
101 OS <<
"OrigToVectorMap:\n";
102 for (
auto [Orig, Vec] : OrigToVectorMap)
103 OS << *Orig <<
" : " << *Vec <<
"\n";
#define LLVM_DUMP_METHOD
Mark debug helper function definitions like dump() that should not be stripped from debug builds.
This file defines the DenseMap class.
assert(ImpDefSCC.getReg()==AMDGPU::SCC &&ImpDefSCC.isDef())
This file defines the SmallSet class.
This file defines the SmallVector class.
ArrayRef - Represent a constant reference to an array (0 or more elements consecutively in memory),...
iterator find(const_arg_type_t< KeyT > Val)
std::pair< iterator, bool > try_emplace(KeyT &&Key, Ts &&...Args)
bool erase(const KeyT &Val)
This class implements an extremely fast bulk output stream that can only output to a stream.
void unregisterEraseInstrCallback(CallbackID ID)
CallbackID registerEraseInstrCallback(EraseInstrCallback CB)
Register a callback that gets called when a SandboxIR instruction is about to be removed from its par...
Maps the original instructions to the vectorized instrs and the reverse.
Value * getVectorForOrig(Value *Orig) const
\Returns the vector value that we got from vectorizing Orig, or nullptr if not found.
void print(raw_ostream &OS) const
void registerVector(ArrayRef< Value * > Origs, Value *Vec)
Update the map to reflect that Origs got vectorized into Vec.
LLVM_DUMP_METHOD void dump() const
std::optional< unsigned > getOrigLane(Value *Vec, Value *Orig) const
\Returns the lane of Orig before it got vectorized into Vec, or nullopt if not found.
A sandboxir::User with operands, opcode and linked with previous/next instructions in an instruction ...
A SandboxIR Value has users. This is the base class.
auto enumerate(FirstRange &&First, RestRanges &&...Rest)
Given two or more input ranges, returns a new range whose values are tuples (A, B,...