13#ifndef LLVM_DEBUGINFO_LOGICALVIEW_CORE_LVSUPPORT_H
14#define LLVM_DEBUGINFO_LOGICALVIEW_CORE_LVSUPPORT_H
28namespace logicalview {
36 std::tuple<LVStringRefs::size_type, LVStringRefs::size_type>;
45 void set(
T Idx) { Bits[
static_cast<unsigned>(
Idx)] = 1; }
47 bool get(
T Idx)
const {
return Bits[
static_cast<unsigned>(
Idx)]; }
55#define BOOL_BIT(FAMILY, ENUM, FIELD) \
56 bool get##FIELD() const { return FAMILY.get(ENUM::FIELD); } \
57 void set##FIELD() { FAMILY.set(ENUM::FIELD); } \
58 void reset##FIELD() { FAMILY.reset(ENUM::FIELD); }
60#define BOOL_BIT_1(FAMILY, ENUM, FIELD, F1) \
61 bool get##FIELD() const { return FAMILY.get(ENUM::FIELD); } \
63 FAMILY.set(ENUM::FIELD); \
66 void reset##FIELD() { FAMILY.reset(ENUM::FIELD); }
68#define BOOL_BIT_2(FAMILY, ENUM, FIELD, F1, F2) \
69 bool get##FIELD() const { return FAMILY.get(ENUM::FIELD); } \
71 FAMILY.set(ENUM::FIELD); \
75 void reset##FIELD() { FAMILY.reset(ENUM::FIELD); }
77#define BOOL_BIT_3(FAMILY, ENUM, FIELD, F1, F2, F3) \
78 bool get##FIELD() const { return FAMILY.get(ENUM::FIELD); } \
80 FAMILY.set(ENUM::FIELD); \
85 void reset##FIELD() { FAMILY.reset(ENUM::FIELD); }
88#define PROPERTY(ENUM, FIELD) BOOL_BIT(Properties, ENUM, FIELD)
89#define PROPERTY_1(ENUM, FIELD, F1) BOOL_BIT_1(Properties, ENUM, FIELD, F1)
90#define PROPERTY_2(ENUM, FIELD, F1, F2) \
91 BOOL_BIT_2(Properties, ENUM, FIELD, F1, F2)
92#define PROPERTY_3(ENUM, FIELD, F1, F2, F3) \
93 BOOL_BIT_3(Properties, ENUM, FIELD, F1, F2, F3)
96#define KIND(ENUM, FIELD) BOOL_BIT(Kinds, ENUM, FIELD)
97#define KIND_1(ENUM, FIELD, F1) BOOL_BIT_1(Kinds, ENUM, FIELD, F1)
98#define KIND_2(ENUM, FIELD, F1, F2) BOOL_BIT_2(Kinds, ENUM, FIELD, F1, F2)
99#define KIND_3(ENUM, FIELD, F1, F2, F3) \
100 BOOL_BIT_3(Kinds, ENUM, FIELD, F1, F2, F3)
104 bool Upper =
false) {
122template <
typename... Args>
125 std::stringstream Stream;
128 Stream << (
Size ?
" " :
"") << Item.str();
131 Stream << (
Size ?
" " :
"");
136template <
typename MapType,
typename KeyType,
typename ValueType>
138 (*Map)[Key].push_back(
Value);
142template <
typename FirstKeyType,
typename SecondKeyType,
typename ValueType>
144 static_assert(std::is_pointer<ValueType>::value,
145 "ValueType must be a pointer.");
146 using LVSecondMapType = std::map<SecondKeyType, ValueType>;
147 using LVFirstMapType =
148 std::map<FirstKeyType, std::unique_ptr<LVSecondMapType>>;
149 using LVAuxMapType = std::map<SecondKeyType, FirstKeyType>;
150 using LVValueTypes = std::vector<ValueType>;
151 LVFirstMapType FirstMap;
156 typename LVFirstMapType::iterator FirstIter = FirstMap.find(FirstKey);
157 if (FirstIter == FirstMap.end()) {
158 auto SecondMapSP = std::make_unique<LVSecondMapType>();
159 SecondMapSP->emplace(SecondKey,
Value);
160 FirstMap.emplace(FirstKey, std::move(SecondMapSP));
162 LVSecondMapType *SecondMap = FirstIter->second.get();
163 if (SecondMap->find(SecondKey) == SecondMap->end())
164 SecondMap->emplace(SecondKey,
Value);
167 typename LVAuxMapType::iterator AuxIter = AuxMap.find(SecondKey);
168 if (AuxIter == AuxMap.end()) {
169 AuxMap.emplace(SecondKey, FirstKey);
173 LVSecondMapType *
findMap(FirstKeyType FirstKey)
const {
174 typename LVFirstMapType::const_iterator FirstIter = FirstMap.find(FirstKey);
175 if (FirstIter == FirstMap.end())
178 return FirstIter->second.get();
182 LVSecondMapType *SecondMap =
findMap(FirstKey);
186 typename LVSecondMapType::const_iterator SecondIter =
187 SecondMap->find(SecondKey);
188 return (SecondIter != SecondMap->end()) ? SecondIter->second :
nullptr;
192 typename LVAuxMapType::const_iterator AuxIter = AuxMap.find(SecondKey);
193 if (AuxIter == AuxMap.end())
195 return find(AuxIter->second, SecondKey);
201 if (FirstMap.empty())
203 for (
typename LVFirstMapType::const_reference FirstEntry : FirstMap) {
204 LVSecondMapType &SecondMap = *FirstEntry.second;
205 for (
typename LVSecondMapType::const_reference SecondEntry : SecondMap)
206 Values.push_back(SecondEntry.second);
Returns the sub type a function will return at a given Idx Should correspond to the result type of an ExtractValue instruction executed with just that one unsigned Idx
This file implements the SmallBitVector class.
This is a 'bitvector' (really, a variable-sized bit array), optimized for the case when the array is ...
StringRef - Represent a constant reference to a string, i.e.
Twine - A lightweight data structure for efficiently representing the concatenation of temporary valu...
LLVM Value Representation.
void add(FirstKeyType FirstKey, SecondKeyType SecondKey, ValueType Value)
LVValueTypes find() const
LVSecondMapType * findMap(FirstKeyType FirstKey) const
ValueType find(FirstKeyType FirstKey, SecondKeyType SecondKey) const
ValueType find(SecondKeyType SecondKey) const
A raw_ostream that writes to an std::string.
FormattedNumber hexValue(uint64_t N, unsigned Width=HEX_WIDTH, bool Upper=false)
std::string hexString(uint64_t Value, size_t Width=HEX_WIDTH)
std::string formattedNames(StringRef Name1, StringRef Name2)
std::vector< StringRef > LVStringRefs
LVStringPool & getStringPool()
std::tuple< StringRef, StringRef > LVLexicalComponent
std::string formattedKind(StringRef Kind)
uint16_t getCodeViewOperationCode(uint8_t Code)
void addItem(MapType *Map, KeyType Key, ValueType Value)
std::string hexSquareString(uint64_t Value)
LVStringRefs getAllLexicalComponents(StringRef Name)
std::string transformPath(StringRef Path)
LVLexicalComponent getInnerComponent(StringRef Name)
std::string formattedName(StringRef Name)
std::string flattenedFilePath(StringRef Path)
std::string formatAttributes(const StringRef First, Args... Others)
std::string getScopedName(const LVStringRefs &Components, StringRef BaseName={})
std::tuple< LVStringRefs::size_type, LVStringRefs::size_type > LVLexicalIndex
This is an optimization pass for GlobalISel generic memory operations.
FormattedNumber format_hex(uint64_t N, unsigned Width, bool Upper=false)
format_hex - Output N as a fixed width hexadecimal.
@ First
Helpers to iterate all locations in the MemoryEffectsBase class.