13#ifndef LLVM_DEBUGINFO_LOGICALVIEW_CORE_LVSUPPORT_H
14#define LLVM_DEBUGINFO_LOGICALVIEW_CORE_LVSUPPORT_H
28namespace logicalview {
31using TypeIsValid = std::bool_constant<std::is_pointer<T>::value>;
34template <
typename T,
unsigned N = 8>
44 for (
auto *Item : *
this)
56 void set(
T Idx) { Bits[
static_cast<unsigned>(
Idx)] = 1; }
58 bool get(
T Idx)
const {
return Bits[
static_cast<unsigned>(
Idx)]; }
66#define BOOL_BIT(FAMILY, ENUM, FIELD) \
67 bool get##FIELD() const { return FAMILY.get(ENUM::FIELD); } \
68 void set##FIELD() { FAMILY.set(ENUM::FIELD); } \
69 void reset##FIELD() { FAMILY.reset(ENUM::FIELD); }
71#define BOOL_BIT_1(FAMILY, ENUM, FIELD, F1) \
72 bool get##FIELD() const { return FAMILY.get(ENUM::FIELD); } \
74 FAMILY.set(ENUM::FIELD); \
77 void reset##FIELD() { FAMILY.reset(ENUM::FIELD); }
79#define BOOL_BIT_2(FAMILY, ENUM, FIELD, F1, F2) \
80 bool get##FIELD() const { return FAMILY.get(ENUM::FIELD); } \
82 FAMILY.set(ENUM::FIELD); \
86 void reset##FIELD() { FAMILY.reset(ENUM::FIELD); }
88#define BOOL_BIT_3(FAMILY, ENUM, FIELD, F1, F2, F3) \
89 bool get##FIELD() const { return FAMILY.get(ENUM::FIELD); } \
91 FAMILY.set(ENUM::FIELD); \
96 void reset##FIELD() { FAMILY.reset(ENUM::FIELD); }
99#define PROPERTY(ENUM, FIELD) BOOL_BIT(Properties, ENUM, FIELD)
100#define PROPERTY_1(ENUM, FIELD, F1) BOOL_BIT_1(Properties, ENUM, FIELD, F1)
101#define PROPERTY_2(ENUM, FIELD, F1, F2) \
102 BOOL_BIT_2(Properties, ENUM, FIELD, F1, F2)
103#define PROPERTY_3(ENUM, FIELD, F1, F2, F3) \
104 BOOL_BIT_3(Properties, ENUM, FIELD, F1, F2, F3)
107#define KIND(ENUM, FIELD) BOOL_BIT(Kinds, ENUM, FIELD)
108#define KIND_1(ENUM, FIELD, F1) BOOL_BIT_1(Kinds, ENUM, FIELD, F1)
109#define KIND_2(ENUM, FIELD, F1, F2) BOOL_BIT_2(Kinds, ENUM, FIELD, F1, F2)
110#define KIND_3(ENUM, FIELD, F1, F2, F3) \
111 BOOL_BIT_3(Kinds, ENUM, FIELD, F1, F2, F3)
115 bool Upper =
false) {
133template <
typename... Args>
135 const auto List = {First, Others...};
136 std::stringstream Stream;
139 Stream << (
Size ?
" " :
"") << Item.str();
142 Stream << (
Size ?
" " :
"");
147template <
typename MapType,
typename ListType,
typename KeyType,
150 ListType *
List =
nullptr;
151 typename MapType::const_iterator Iter = Map->find(Key);
152 if (Iter != Map->end())
155 List =
new ListType();
156 Map->emplace(Key,
List);
163 for (
typename MapType::const_reference Entry : Map)
168template <
typename FirstKeyType,
typename SecondKeyType,
typename ValueType>
170 static_assert(std::is_pointer<ValueType>::value,
171 "ValueType must be a pointer.");
172 using LVSecondMapType = std::map<SecondKeyType, ValueType>;
173 using LVFirstMapType = std::map<FirstKeyType, LVSecondMapType *>;
174 using LVAuxMapType = std::map<SecondKeyType, FirstKeyType>;
175 using LVValueTypes = std::vector<ValueType>;
176 LVFirstMapType FirstMap;
182 for (
auto &Entry : FirstMap)
187 LVSecondMapType *SecondMap =
nullptr;
188 typename LVFirstMapType::iterator FirstIter = FirstMap.find(FirstKey);
189 if (FirstIter == FirstMap.end()) {
190 SecondMap =
new LVSecondMapType();
191 FirstMap.emplace(FirstKey, SecondMap);
193 SecondMap = FirstIter->second;
196 assert(SecondMap &&
"SecondMap is null.");
197 if (SecondMap && SecondMap->find(SecondKey) == SecondMap->end())
198 SecondMap->emplace(SecondKey,
Value);
200 typename LVAuxMapType::iterator AuxIter = AuxMap.find(SecondKey);
201 if (AuxIter == AuxMap.end()) {
202 AuxMap.emplace(SecondKey, FirstKey);
206 LVSecondMapType *
findMap(FirstKeyType FirstKey)
const {
207 typename LVFirstMapType::const_iterator FirstIter = FirstMap.find(FirstKey);
208 if (FirstIter == FirstMap.end())
211 LVSecondMapType *SecondMap = FirstIter->second;
216 LVSecondMapType *SecondMap =
findMap(FirstKey);
220 typename LVSecondMapType::const_iterator SecondIter =
221 SecondMap->find(SecondKey);
222 return (SecondIter != SecondMap->end()) ? SecondIter->second :
nullptr;
226 typename LVAuxMapType::const_iterator AuxIter = AuxMap.find(SecondKey);
227 if (AuxIter == AuxMap.end())
229 return find(AuxIter->second, SecondKey);
235 if (FirstMap.empty())
237 for (
typename LVFirstMapType::const_reference FirstEntry : FirstMap) {
238 LVSecondMapType *SecondMap = FirstEntry.second;
239 for (
typename LVSecondMapType::const_reference SecondEntry : *SecondMap)
240 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
assert(ImpDefSCC.getReg()==AMDGPU::SCC &&ImpDefSCC.isDef())
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 ...
This is a 'vector' (really, a variable-sized array), optimized for the case when the array is small.
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.
typename SmallVector< T, N >::iterator iterator
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::bool_constant< std::is_pointer< T >::value > TypeIsValid
std::string formattedNames(StringRef Name1, StringRef Name2)
void addItem(MapType *Map, KeyType Key, ValueType Value)
std::string formattedKind(StringRef Kind)
uint16_t getCodeViewOperationCode(uint8_t Code)
void deleteList(MapType &Map)
std::string hexSquareString(uint64_t Value)
std::string transformPath(StringRef Path)
std::string formattedName(StringRef Name)
std::string flattenedFilePath(StringRef Path)
std::string formatAttributes(const StringRef First, Args... Others)
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.