14#ifndef LLVM_DEBUGINFO_LOGICALVIEW_CORE_LVOPTIONS_H
15#define LLVM_DEBUGINFO_LOGICALVIEW_CORE_LVOPTIONS_H
27namespace logicalview {
30#define BOOL_FUNCTION(FAMILY, FIELD) \
31 bool get##FAMILY##FIELD() const { return FAMILY.FIELD; } \
32 void set##FAMILY##FIELD() { FAMILY.FIELD = true; } \
33 void reset##FAMILY##FIELD() { FAMILY.FIELD = false; }
36#define UNSIGNED_FUNCTION(FAMILY, FIELD) \
37 unsigned get##FAMILY##FIELD() const { return FAMILY.FIELD; } \
38 void set##FAMILY##FIELD(unsigned Value) { FAMILY.FIELD = Value; } \
39 void reset##FAMILY##FIELD() { FAMILY.FIELD = -1U; }
42#define STD_STRING_FUNCTION(FAMILY, FIELD) \
43 std::string get##FAMILY##FIELD() const { return FAMILY.FIELD; } \
44 void set##FAMILY##FIELD(std::string FIELD) { FAMILY.FIELD = FIELD; } \
45 void reset##FAMILY##FIELD() { FAMILY.FIELD = ""; }
48#define STDSET_FUNCTION_4(FAMILY, FIELD, TYPE, SET) \
49 bool get##FAMILY##FIELD() const { \
50 return FAMILY.SET.find(TYPE::FIELD) != FAMILY.SET.end(); \
52 void set##FAMILY##FIELD() { FAMILY.SET.insert(TYPE::FIELD); } \
53 void reset##FAMILY##FIELD() { \
54 std::set<TYPE>::iterator Iter = FAMILY.SET.find(TYPE::FIELD); \
55 if (Iter != FAMILY.SET.end()) \
56 FAMILY.SET.erase(Iter); \
59#define STDSET_FUNCTION_5(FAMILY, FIELD, ENTRY, TYPE, SET) \
60 bool get##FAMILY##FIELD##ENTRY() const { \
61 return FAMILY.SET.find(TYPE::ENTRY) != FAMILY.SET.end(); \
63 void set##FAMILY##FIELD##ENTRY() { FAMILY.SET.insert(TYPE::ENTRY); }
66#define ATTRIBUTE_OPTION(FIELD) \
67 STDSET_FUNCTION_4(Attribute, FIELD, LVAttributeKind, Kinds)
70#define OUTPUT_OPTION(FIELD) \
71 STDSET_FUNCTION_4(Output, FIELD, LVOutputKind, Kinds)
74#define PRINT_OPTION(FIELD) STDSET_FUNCTION_4(Print, FIELD, LVPrintKind, Kinds)
77#define WARNING_OPTION(FIELD) \
78 STDSET_FUNCTION_4(Warning, FIELD, LVWarningKind, Kinds)
81#define COMPARE_OPTION(FIELD) \
82 STDSET_FUNCTION_4(Compare, FIELD, LVCompareKind, Elements)
85#define REPORT_OPTION(FIELD) \
86 STDSET_FUNCTION_4(Report, FIELD, LVReportKind, Kinds)
89#define INTERNAL_OPTION(FIELD) \
90 STDSET_FUNCTION_4(Internal, FIELD, LVInternalKind, Kinds)
202 bool AnyLocation =
false;
203 bool AnySource =
false;
210 bool Context =
false;
211 bool Execute =
false;
218 bool AnyElement =
false;
219 bool AnyLine =
false;
220 bool Execute =
false;
221 bool Formatting =
true;
223 bool SizesSummary =
false;
229 bool AnyView =
false;
230 bool Execute =
false;
235 bool IgnoreCase =
false;
236 bool UseRegex =
false;
237 bool Execute =
false;
238 bool GenericKind =
false;
239 bool GenericPattern =
false;
240 bool OffsetPattern =
false;
255 unsigned Level = -1U;
270 bool CollectRanges =
false;
277 size_t LastFilenameIndex = 0;
281 size_t IndentationSize = 0;
285 void calculateIndentationSize();
290 bool IndexChanged = (
Index != LastFilenameIndex);
292 LastFilenameIndex =
Index;
440#if !defined(NDEBUG) || defined(LLVM_ENABLE_DUMP)
450 enum class LVMatchMode {
460 std::shared_ptr<Regex> RE;
461 LVMatchMode Mode = LVMatchMode::None;
464 using LVMatchInfo = std::vector<LVMatch>;
465 LVMatchInfo GenericMatchInfo;
466 using LVMatchOffsets = std::vector<uint64_t>;
467 LVMatchOffsets OffsetMatchInfo;
484 template <
typename T,
typename U>
485 bool checkElementRequest(
const T *Element,
const U &Requests)
const {
486 assert(Element &&
"Element must not be nullptr");
487 for (
const auto &Request : Requests)
488 if ((Element->*Request)())
492 if ((Element->*Request)())
498 template <
typename T,
typename U,
typename V>
499 void addRequest(
const T &
Selection,
const U &Dispatch, V &Request)
const {
502 typename U::const_iterator Iter = Dispatch.find(Entry);
503 if (Iter != Dispatch.end())
504 Request.push_back(Iter->second);
510 template <
typename T,
typename U>
511 void resolveGenericPatternMatch(
T *Element,
const U &Requests) {
512 assert(Element &&
"Element must not be nullptr");
513 auto CheckPattern = [
this, Element]() ->
bool {
514 return (Element->isNamed() &&
517 (Element->isTyped() &&
520 auto CheckOffset = [
this, Element]() ->
bool {
523 if ((
options().getSelectGenericPattern() && CheckPattern()) ||
524 (
options().getSelectOffsetPattern() && CheckOffset()) ||
525 ((Requests.size() || ElementRequest.size()) &&
526 checkElementRequest(Element, Requests)))
530 template <
typename U>
531 void resolveGenericPatternMatch(
LVLine *
Line,
const U &Requests) {
533 auto CheckPattern = [
this,
Line]() ->
bool {
538 auto CheckOffset = [
this,
Line]() ->
bool {
541 if ((
options().getSelectGenericPattern() && CheckPattern()) ||
542 (
options().getSelectOffsetPattern() && CheckOffset()) ||
543 (Requests.size() && checkElementRequest(
Line, Requests)))
548 bool IgnoreCase,
bool UseRegex);
566 GenericMatchInfo.clear();
567 OffsetMatchInfo.clear();
568 ElementRequest.clear();
570 ScopeRequest.clear();
571 SymbolRequest.clear();
574 options().resetSelectGenericKind();
575 options().resetSelectGenericPattern();
576 options().resetSelectOffsetPattern();
580 addRequest(
Selection, ElementDispatch, ElementRequest);
583 addRequest(
Selection, LineDispatch, LineRequest);
586 addRequest(
Selection, ScopeDispatch, ScopeRequest);
589 addRequest(
Selection, SymbolDispatch, SymbolRequest);
592 addRequest(
Selection, TypeDispatch, TypeRequest);
607 resolveGenericPatternMatch(
Line, LineRequest);
611 resolveGenericPatternMatch(Scope, ScopeRequest);
615 resolveGenericPatternMatch(Symbol, SymbolRequest);
619 resolveGenericPatternMatch(
Type, TypeRequest);
637#if !defined(NDEBUG) || defined(LLVM_ENABLE_DUMP)
amdgpu AMDGPU DAG DAG Pattern Instruction Selection
static bool Execute(ProcessInfo &PI, StringRef Program, ArrayRef< StringRef > Args, std::optional< ArrayRef< StringRef > > Env, ArrayRef< std::optional< StringRef > > Redirects, unsigned MemoryLimit, std::string *ErrMsg, BitVector *AffinityMask, bool DetachProcess)
assert(ImpDefSCC.getReg()==AMDGPU::SCC &&ImpDefSCC.isDef())
StringSet - A set-like wrapper for the StringMap.
This class represents an incoming formal argument to a Function.
Lightweight error class with error context and mandatory checking.
Wrapper class representing virtual and physical registers.
StringRef - Represent a constant reference to a string, i.e.
StringSet - A wrapper for StringMap that provides set-like functionality.
The instances of the Type class are immutable: once they are created, they are never changed.
static LVElementDispatch & getDispatch()
static LVLineDispatch & getDispatch()
PRINT_OPTION(Instructions)
ATTRIBUTE_OPTION(Directories)
size_t indentationSize() const
LVOptions & operator=(const LVOptions &)=default
BOOL_FUNCTION(Attribute, Missing)
LVSortMode getSortMode() const
WARNING_OPTION(Locations)
ATTRIBUTE_OPTION(Discriminator)
BOOL_FUNCTION(Select, Execute)
BOOL_FUNCTION(Select, GenericPattern)
static void setOptions(LVOptions *Options)
ATTRIBUTE_OPTION(Publics)
ATTRIBUTE_OPTION(Producer)
void resetFilenameIndex()
BOOL_FUNCTION(Select, GenericKind)
void resolveDependencies()
ATTRIBUTE_OPTION(Linkage)
BOOL_FUNCTION(Print, Formatting)
STD_STRING_FUNCTION(Output, Folder)
ATTRIBUTE_OPTION(Underlying)
ATTRIBUTE_OPTION(Reference)
BOOL_FUNCTION(Compare, Execute)
ATTRIBUTE_OPTION(Qualifier)
UNSIGNED_FUNCTION(Output, Level)
BOOL_FUNCTION(Select, OffsetPattern)
BOOL_FUNCTION(Select, UseRegex)
static LVOptions * getOptions()
BOOL_FUNCTION(Print, AnyLine)
INTERNAL_OPTION(Integrity)
BOOL_FUNCTION(Print, SizesSummary)
ATTRIBUTE_OPTION(Pathname)
ATTRIBUTE_OPTION(Extended)
ATTRIBUTE_OPTION(Qualified)
void print(raw_ostream &OS) const
BOOL_FUNCTION(Report, Execute)
bool changeFilenameIndex(size_t Index)
BOOL_FUNCTION(Compare, Context)
BOOL_FUNCTION(Attribute, AnyLocation)
BOOL_FUNCTION(Print, Offset)
ATTRIBUTE_OPTION(Filename)
ATTRIBUTE_OPTION(Location)
BOOL_FUNCTION(Print, AnyElement)
ATTRIBUTE_OPTION(Generated)
ATTRIBUTE_OPTION(Discarded)
ATTRIBUTE_OPTION(Encoded)
ATTRIBUTE_OPTION(Inserted)
void setSortMode(LVSortMode SortMode)
ATTRIBUTE_OPTION(Standard)
WARNING_OPTION(Coverages)
ATTRIBUTE_OPTION(Coverage)
ATTRIBUTE_OPTION(Argument)
BOOL_FUNCTION(Report, AnyView)
LVOptions(const LVOptions &)=default
BOOL_FUNCTION(Select, IgnoreCase)
ATTRIBUTE_OPTION(Typename)
BOOL_FUNCTION(Attribute, Added)
ATTRIBUTE_OPTION(Subrange)
BOOL_FUNCTION(Attribute, AnySource)
ATTRIBUTE_OPTION(Register)
BOOL_FUNCTION(General, CollectRanges)
BOOL_FUNCTION(Compare, Print)
BOOL_FUNCTION(Print, Execute)
void addGenericPatterns(StringSet<> &Patterns)
void resolvePatternMatch(LVType *Type)
void resolvePatternMatch(LVLine *Line)
void addRequest(LVTypeKindSelection &Selection)
bool matchOffsetPattern(LVOffset Offset)
void resolvePatternMatch(LVScope *Scope)
bool matchPattern(StringRef Input, const LVMatchInfo &MatchInfo)
void addRequest(LVElementKindSet &Selection)
void addRequest(LVLineKindSet &Selection)
bool printObject(const LVLocation *Location) const
void print(raw_ostream &OS) const
bool printElement(const LVLine *Line) const
LVPatterns(const LVPatterns &)=delete
void addPatterns(StringSet<> &Patterns, LVMatchInfo &Filters)
void updateReportOptions()
bool matchGenericPattern(StringRef Input)
void addOffsetPatterns(const LVOffsetSet &Patterns)
void resolvePatternMatch(LVSymbol *Symbol)
void addRequest(LVSymbolKindSet &Selection)
LVPatterns & operator=(const LVPatterns &)=delete
void addRequest(LVScopeKindSet &Selection)
static LVPatterns * getPatterns()
static LVScopeDispatch & getDispatch()
static LVSymbolDispatch & getDispatch()
static LVTypeDispatch & getDispatch()
This class implements an extremely fast bulk output stream that can only output to a stream.
std::set< LVPrintKind > LVPrintKindSet
std::set< LVLineKind > LVLineKindSet
std::vector< LVSymbolGetFunction > LVSymbolRequest
bool(LVElement::*)() const LVElementGetFunction
std::set< LVScopeKind > LVScopeKindSet
void setOptions(LVOptions *Options)
std::set< LVTypeKind > LVTypeKindSelection
std::set< LVElementKind > LVElementKindSet
std::set< uint64_t > LVOffsetSet
std::set< LVOutputKind > LVOutputKindSet
std::map< LVScopeKind, LVScopeGetFunction > LVScopeDispatch
std::set< LVWarningKind > LVWarningKindSet
std::set< LVReportKind > LVReportKindSet
std::vector< LVLineGetFunction > LVLineRequest
std::set< LVSymbolKind > LVSymbolKindSet
std::vector< LVScopeGetFunction > LVScopeRequest
std::map< LVLineKind, LVLineGetFunction > LVLineDispatch
std::set< LVInternalKind > LVInternalKindSet
std::set< LVAttributeKind > LVAttributeKindSet
std::map< LVSymbolKind, LVSymbolGetFunction > LVSymbolDispatch
std::vector< LVElementGetFunction > LVElementRequest
std::map< LVElementKind, LVElementGetFunction > LVElementDispatch
std::set< LVCompareKind > LVCompareKindSet
std::map< LVTypeKind, LVTypeGetFunction > LVTypeDispatch
std::vector< LVTypeGetFunction > LVTypeRequest
This is an optimization pass for GlobalISel generic memory operations.
raw_ostream & dbgs()
dbgs() - This returns a reference to a raw_ostream for debugging messages.
bool is_contained(R &&Range, const E &Element)
Returns true if Element is found in Range.