44 #ifndef LLVM_SUPPORT_DEBUGCOUNTER_H
45 #define LLVM_SUPPORT_DEBUGCOUNTER_H
70 return instance().addCounter(Name, Desc);
78 auto Result = Us.Counters.find(CounterName);
79 if (Result != Us.Counters.end()) {
80 auto &CounterPair = Result->second;
84 if (CounterPair.first < 0)
86 if (CounterPair.first != 0) {
90 if (CounterPair.second < 0)
92 if (CounterPair.second != 0) {
113 auto Result = Us.Counters.find(ID);
114 assert(Result != Us.Counters.end() &&
"Asking about a non-set counter");
115 return Result->second;
121 Us.Counters[
ID] = Val;
131 return RegisteredCounters.
idFor(Name);
139 return std::make_pair(RegisteredCounters[ID], CounterDesc.
lookup(ID));
145 return RegisteredCounters.
begin();
150 unsigned addCounter(
const std::string &
Name,
const std::string &
Desc) {
151 unsigned Result = RegisteredCounters.
insert(Name);
152 CounterDesc[Result] =
Desc;
155 DenseMap<unsigned, std::pair<long, long>> Counters;
156 DenseMap<unsigned, std::string> CounterDesc;
160 #define DEBUG_COUNTER(VARNAME, COUNTERNAME, DESC) \
161 static const unsigned VARNAME = \
162 DebugCounter::registerCounter(COUNTERNAME, DESC);
ValueT lookup(const_arg_type_t< KeyT > Val) const
lookup - Return the entry for the specified key, or a default constructed value if no such entry exis...
#define LLVM_DUMP_METHOD
Mark debug helper function definitions like dump() that should not be stripped from debug builds...
UniqueVector< std::string > CounterVector
MachineInstrBuilder MachineInstrBuilder &DefMI const MCInstrDesc & Desc
static DebugCounter & instance()
Returns a reference to the singleton instance.
static unsigned registerCounter(StringRef Name, StringRef Desc)
LLVM_DUMP_METHOD void dump() const
void print(raw_ostream &OS) const
unsigned idFor(const T &Entry) const
idFor - return the ID for an existing entry.
std::pair< std::string, std::string > getCounterInfo(unsigned ID) const
unsigned getCounterId(const std::string &Name) const
static bool isCounterSet(unsigned ID)
typename VectorType::const_iterator const_iterator
CounterVector::const_iterator begin() const
static void setCounterValue(unsigned ID, const std::pair< int, int > &Val)
CounterVector::const_iterator end() const
iterator begin()
Return an iterator to the start of the vector.
static bool shouldExecute(unsigned CounterName)
static std::pair< int, int > getCounterValue(unsigned ID)
iterator end()
Return an iterator to the end of the vector.
size_type count(const_arg_type_t< KeyT > Val) const
Return 1 if the specified key is in the map, 0 otherwise.
void push_back(const std::string &)
unsigned insert(const T &Entry)
insert - Append entry to the vector if it doesn't already exist.
size_t size() const
size - Returns the number of entries in the vector.
assert(ImpDefSCC.getReg()==AMDGPU::SCC &&ImpDefSCC.isDef())
unsigned int getNumCounters() const
This class implements an extremely fast bulk output stream that can only output to a stream...
StringRef - Represent a constant reference to a string, i.e.