14#ifndef LLVM_DEBUGINFO_LOGICALVIEW_CORE_LVOPTIONS_H
15#define LLVM_DEBUGINFO_LOGICALVIEW_CORE_LVOPTIONS_H
28namespace logicalview {
31#define BOOL_FUNCTION(FAMILY, FIELD) \
32 bool get##FAMILY##FIELD() const { return FAMILY.FIELD; } \
33 void set##FAMILY##FIELD() { FAMILY.FIELD = true; } \
34 void reset##FAMILY##FIELD() { FAMILY.FIELD = false; }
37#define UNSIGNED_FUNCTION(FAMILY, FIELD) \
38 unsigned get##FAMILY##FIELD() const { return FAMILY.FIELD; } \
39 void set##FAMILY##FIELD(unsigned Value) { FAMILY.FIELD = Value; } \
40 void reset##FAMILY##FIELD() { FAMILY.FIELD = -1U; }
43#define STD_STRING_FUNCTION(FAMILY, FIELD) \
44 std::string get##FAMILY##FIELD() const { return FAMILY.FIELD; } \
45 void set##FAMILY##FIELD(std::string FIELD) { \
46 FAMILY.FIELD = std::move(FIELD); \
48 void reset##FAMILY##FIELD() { FAMILY.FIELD = ""; }
51#define STDSET_FUNCTION_4(FAMILY, FIELD, TYPE, SET) \
52 bool get##FAMILY##FIELD() const { \
53 return FAMILY.SET.find(TYPE::FIELD) != FAMILY.SET.end(); \
55 void set##FAMILY##FIELD() { FAMILY.SET.insert(TYPE::FIELD); } \
56 void reset##FAMILY##FIELD() { FAMILY.SET.erase(TYPE::FIELD); }
58#define STDSET_FUNCTION_5(FAMILY, FIELD, ENTRY, TYPE, SET) \
59 bool get##FAMILY##FIELD##ENTRY() const { \
60 return FAMILY.SET.find(TYPE::ENTRY) != FAMILY.SET.end(); \
62 void set##FAMILY##FIELD##ENTRY() { FAMILY.SET.insert(TYPE::ENTRY); }
65#define ATTRIBUTE_OPTION(FIELD) \
66 STDSET_FUNCTION_4(Attribute, FIELD, LVAttributeKind, Kinds)
69#define OUTPUT_OPTION(FIELD) \
70 STDSET_FUNCTION_4(Output, FIELD, LVOutputKind, Kinds)
73#define PRINT_OPTION(FIELD) STDSET_FUNCTION_4(Print, FIELD, LVPrintKind, Kinds)
76#define WARNING_OPTION(FIELD) \
77 STDSET_FUNCTION_4(Warning, FIELD, LVWarningKind, Kinds)
80#define COMPARE_OPTION(FIELD) \
81 STDSET_FUNCTION_4(Compare, FIELD, LVCompareKind, Elements)
84#define REPORT_OPTION(FIELD) \
85 STDSET_FUNCTION_4(Report, FIELD, LVReportKind, Kinds)
88#define INTERNAL_OPTION(FIELD) \
89 STDSET_FUNCTION_4(Internal, FIELD, LVInternalKind, Kinds)
203 bool AnyLocation =
false;
204 bool AnySource =
false;
212 bool Execute =
false;
219 bool AnyElement =
false;
220 bool AnyLine =
false;
221 bool Execute =
false;
222 bool Formatting =
true;
224 bool SizesSummary =
false;
230 bool AnyView =
false;
231 bool Execute =
false;
236 bool IgnoreCase =
false;
237 bool UseRegex =
false;
238 bool Execute =
false;
239 bool GenericKind =
false;
240 bool GenericPattern =
false;
241 bool OffsetPattern =
false;
256 unsigned Level = -1U;
271 bool CollectRanges =
false;
278 size_t LastFilenameIndex = 0;
282 size_t IndentationSize = 0;
286 void calculateIndentationSize();
291 bool IndexChanged = (
Index != LastFilenameIndex);
293 LastFilenameIndex =
Index;
443#if !defined(NDEBUG) || defined(LLVM_ENABLE_DUMP)
453 enum class LVMatchMode {
463 std::shared_ptr<Regex> RE;
464 LVMatchMode Mode = LVMatchMode::None;
467 using LVMatchInfo = std::vector<LVMatch>;
468 LVMatchInfo GenericMatchInfo;
469 using LVMatchOffsets = std::vector<uint64_t>;
470 LVMatchOffsets OffsetMatchInfo;
487 template <
typename T,
typename U>
488 bool checkElementRequest(
const T *Element,
const U &Requests)
const {
489 assert(Element &&
"Element must not be nullptr");
490 for (
const auto &Request : Requests)
491 if ((Element->*Request)())
495 if ((Element->*Request)())
501 template <
typename T,
typename U,
typename V>
502 void addRequest(
const T &
Selection,
const U &Dispatch, V &Request)
const {
505 typename U::const_iterator Iter = Dispatch.find(Entry);
506 if (Iter != Dispatch.end())
507 Request.push_back(Iter->second);
513 template <
typename T,
typename U>
514 void resolveGenericPatternMatch(
T *Element,
const U &Requests) {
515 assert(Element &&
"Element must not be nullptr");
516 auto CheckPattern = [
this, Element]() ->
bool {
517 return (Element->isNamed() &&
520 (Element->isTyped() &&
523 auto CheckOffset = [
this, Element]() ->
bool {
526 if ((
options().getSelectGenericPattern() && CheckPattern()) ||
527 (
options().getSelectOffsetPattern() && CheckOffset()) ||
528 ((Requests.size() || ElementRequest.size()) &&
529 checkElementRequest(Element, Requests)))
533 template <
typename U>
534 void resolveGenericPatternMatch(
LVLine *
Line,
const U &Requests) {
536 auto CheckPattern = [
this,
Line]() ->
bool {
541 auto CheckOffset = [
this,
Line]() ->
bool {
544 if ((
options().getSelectGenericPattern() && CheckPattern()) ||
545 (
options().getSelectOffsetPattern() && CheckOffset()) ||
546 (Requests.size() && checkElementRequest(
Line, Requests)))
551 bool IgnoreCase,
bool UseRegex);
569 GenericMatchInfo.clear();
570 OffsetMatchInfo.clear();
571 ElementRequest.clear();
573 ScopeRequest.clear();
574 SymbolRequest.clear();
577 options().resetSelectGenericKind();
578 options().resetSelectGenericPattern();
579 options().resetSelectOffsetPattern();
583 addRequest(
Selection, ElementDispatch, ElementRequest);
586 addRequest(
Selection, LineDispatch, LineRequest);
589 addRequest(
Selection, ScopeDispatch, ScopeRequest);
592 addRequest(
Selection, SymbolDispatch, SymbolRequest);
595 addRequest(
Selection, TypeDispatch, TypeRequest);
610 resolveGenericPatternMatch(
Line, LineRequest);
614 resolveGenericPatternMatch(Scope, ScopeRequest);
618 resolveGenericPatternMatch(Symbol, SymbolRequest);
622 resolveGenericPatternMatch(
Type, TypeRequest);
640#if !defined(NDEBUG) || defined(LLVM_ENABLE_DUMP)
assert(UImm &&(UImm !=~static_cast< T >(0)) &&"Invalid immediate!")
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)
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 LLVM_ABI void setOptions(LVOptions *Options)
ATTRIBUTE_OPTION(Publics)
ATTRIBUTE_OPTION(Producer)
void resetFilenameIndex()
BOOL_FUNCTION(Select, GenericKind)
LLVM_ABI 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 LLVM_ABI LVOptions * getOptions()
BOOL_FUNCTION(Print, AnyLine)
INTERNAL_OPTION(Integrity)
BOOL_FUNCTION(Print, SizesSummary)
ATTRIBUTE_OPTION(Pathname)
ATTRIBUTE_OPTION(Extended)
ATTRIBUTE_OPTION(Qualified)
LLVM_ABI void print(raw_ostream &OS) const
BOOL_FUNCTION(Report, Execute)
bool changeFilenameIndex(size_t Index)
BOOL_FUNCTION(Compare, Context)
BOOL_FUNCTION(Attribute, AnyLocation)
ATTRIBUTE_OPTION(Language)
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)
LLVM_ABI void addGenericPatterns(StringSet<> &Patterns)
void resolvePatternMatch(LVType *Type)
void resolvePatternMatch(LVLine *Line)
void addRequest(LVTypeKindSelection &Selection)
bool matchOffsetPattern(LVOffset Offset)
void resolvePatternMatch(LVScope *Scope)
LLVM_ABI bool matchPattern(StringRef Input, const LVMatchInfo &MatchInfo)
void addRequest(LVElementKindSet &Selection)
void addRequest(LVLineKindSet &Selection)
LLVM_ABI bool printObject(const LVLocation *Location) const
LLVM_ABI void print(raw_ostream &OS) const
LLVM_ABI bool printElement(const LVLine *Line) const
LVPatterns(const LVPatterns &)=delete
LLVM_ABI void addPatterns(StringSet<> &Patterns, LVMatchInfo &Filters)
LLVM_ABI void updateReportOptions()
bool matchGenericPattern(StringRef Input)
LLVM_ABI void addOffsetPatterns(const LVOffsetSet &Patterns)
void resolvePatternMatch(LVSymbol *Symbol)
void addRequest(LVSymbolKindSet &Selection)
LVPatterns & operator=(const LVPatterns &)=delete
void addRequest(LVScopeKindSet &Selection)
static LLVM_ABI 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.
LLVM_ABI 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.