13#ifndef LLVM_DEBUGINFO_LOGICALVIEW_CORE_LVSUPPORT_H
14#define LLVM_DEBUGINFO_LOGICALVIEW_CORE_LVSUPPORT_H
29namespace logicalview {
37 std::tuple<LVStringRefs::size_type, LVStringRefs::size_type>;
46 void set(
T Idx) { Bits[
static_cast<unsigned>(
Idx)] = 1; }
48 bool get(
T Idx)
const {
return Bits[
static_cast<unsigned>(
Idx)]; }
56#define BOOL_BIT(FAMILY, ENUM, FIELD) \
57 bool get##FIELD() const { return FAMILY.get(ENUM::FIELD); } \
58 void set##FIELD() { FAMILY.set(ENUM::FIELD); } \
59 void reset##FIELD() { FAMILY.reset(ENUM::FIELD); }
61#define BOOL_BIT_1(FAMILY, ENUM, FIELD, F1) \
62 bool get##FIELD() const { return FAMILY.get(ENUM::FIELD); } \
64 FAMILY.set(ENUM::FIELD); \
67 void reset##FIELD() { FAMILY.reset(ENUM::FIELD); }
69#define BOOL_BIT_2(FAMILY, ENUM, FIELD, F1, F2) \
70 bool get##FIELD() const { return FAMILY.get(ENUM::FIELD); } \
72 FAMILY.set(ENUM::FIELD); \
76 void reset##FIELD() { FAMILY.reset(ENUM::FIELD); }
78#define BOOL_BIT_3(FAMILY, ENUM, FIELD, F1, F2, F3) \
79 bool get##FIELD() const { return FAMILY.get(ENUM::FIELD); } \
81 FAMILY.set(ENUM::FIELD); \
86 void reset##FIELD() { FAMILY.reset(ENUM::FIELD); }
89#define PROPERTY(ENUM, FIELD) BOOL_BIT(Properties, ENUM, FIELD)
90#define PROPERTY_1(ENUM, FIELD, F1) BOOL_BIT_1(Properties, ENUM, FIELD, F1)
91#define PROPERTY_2(ENUM, FIELD, F1, F2) \
92 BOOL_BIT_2(Properties, ENUM, FIELD, F1, F2)
93#define PROPERTY_3(ENUM, FIELD, F1, F2, F3) \
94 BOOL_BIT_3(Properties, ENUM, FIELD, F1, F2, F3)
97#define KIND(ENUM, FIELD) BOOL_BIT(Kinds, ENUM, FIELD)
98#define KIND_1(ENUM, FIELD, F1) BOOL_BIT_1(Kinds, ENUM, FIELD, F1)
99#define KIND_2(ENUM, FIELD, F1, F2) BOOL_BIT_2(Kinds, ENUM, FIELD, F1, F2)
100#define KIND_3(ENUM, FIELD, F1, F2, F3) \
101 BOOL_BIT_3(Kinds, ENUM, FIELD, F1, F2, F3)
105 bool Upper =
false) {
123template <
typename... Args>
125 const auto List = {First, Others...};
126 std::stringstream Stream;
129 Stream << (
Size ?
" " :
"") << Item.str();
132 Stream << (
Size ?
" " :
"");
137template <
typename MapType,
typename KeyType,
typename ValueType>
139 (*Map)[Key].push_back(
Value);
143template <
typename FirstKeyType,
typename SecondKeyType,
typename ValueType>
145 static_assert(std::is_pointer<ValueType>::value,
146 "ValueType must be a pointer.");
147 using LVSecondMapType = std::map<SecondKeyType, ValueType>;
148 using LVFirstMapType =
149 std::map<FirstKeyType, std::unique_ptr<LVSecondMapType>>;
150 using LVAuxMapType = std::map<SecondKeyType, FirstKeyType>;
151 using LVValueTypes = std::vector<ValueType>;
152 LVFirstMapType FirstMap;
157 typename LVFirstMapType::iterator FirstIter = FirstMap.find(FirstKey);
158 if (FirstIter == FirstMap.end()) {
159 auto SecondMapSP = std::make_unique<LVSecondMapType>();
160 SecondMapSP->emplace(SecondKey,
Value);
161 FirstMap.emplace(FirstKey, std::move(SecondMapSP));
163 LVSecondMapType *SecondMap = FirstIter->second.get();
164 if (SecondMap->find(SecondKey) == SecondMap->end())
165 SecondMap->emplace(SecondKey,
Value);
168 typename LVAuxMapType::iterator AuxIter = AuxMap.find(SecondKey);
169 if (AuxIter == AuxMap.end()) {
170 AuxMap.emplace(SecondKey, FirstKey);
174 LVSecondMapType *
findMap(FirstKeyType FirstKey)
const {
175 typename LVFirstMapType::const_iterator FirstIter = FirstMap.find(FirstKey);
176 if (FirstIter == FirstMap.end())
179 return FirstIter->second.get();
183 LVSecondMapType *SecondMap =
findMap(FirstKey);
187 typename LVSecondMapType::const_iterator SecondIter =
188 SecondMap->find(SecondKey);
189 return (SecondIter != SecondMap->end()) ? SecondIter->second :
nullptr;
193 typename LVAuxMapType::const_iterator AuxIter = AuxMap.find(SecondKey);
194 if (AuxIter == AuxMap.end())
196 return find(AuxIter->second, SecondKey);
202 if (FirstMap.empty())
204 for (
typename LVFirstMapType::const_reference FirstEntry : FirstMap) {
205 LVSecondMapType &SecondMap = *FirstEntry.second;
206 for (
typename LVSecondMapType::const_reference SecondEntry : SecondMap)
207 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 file defines the SmallString 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.
std::string & str()
Returns the string's reference.
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.