diff options
author | Chris Lattner <sabre@nondot.org> | 2006-12-06 17:46:33 +0000 |
---|---|---|
committer | Chris Lattner <sabre@nondot.org> | 2006-12-06 17:46:33 +0000 |
commit | ac0b6ae358944ae8b2b5a11dc08f52c3ed89f2da (patch) | |
tree | cba006a0f0e329a969ce29b7d10ba0dc244f4f90 /include/llvm/ADT/Statistic.h | |
parent | 2b4e98cb20c9391399b2601a793b6ea689da3cee (diff) | |
download | llvm-ac0b6ae358944ae8b2b5a11dc08f52c3ed89f2da.tar.gz llvm-ac0b6ae358944ae8b2b5a11dc08f52c3ed89f2da.tar.bz2 llvm-ac0b6ae358944ae8b2b5a11dc08f52c3ed89f2da.tar.xz |
Detemplatize the Statistic class. The only type it is instantiated with
is 'unsigned'.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@32279 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'include/llvm/ADT/Statistic.h')
-rw-r--r-- | include/llvm/ADT/Statistic.h | 39 |
1 files changed, 19 insertions, 20 deletions
diff --git a/include/llvm/ADT/Statistic.h b/include/llvm/ADT/Statistic.h index 99160da106..332a57d121 100644 --- a/include/llvm/ADT/Statistic.h +++ b/include/llvm/ADT/Statistic.h @@ -8,17 +8,19 @@ //===----------------------------------------------------------------------===// // // This file defines the 'Statistic' class, which is designed to be an easy way -// to expose various success metrics from passes. These statistics are printed -// at the end of a run, when the -stats command line option is enabled on the -// command line. +// to expose various metrics from passes. These statistics are printed at the +// end of a run (from llvm_shutdown), when the -stats command line option is +// passed on the command line. // // This is useful for reporting information like the number of instructions // simplified, optimized or removed by various transformations, like this: // -// static Statistic<> NumInstsKilled("gcse", "Number of instructions killed"); +// static Statistic NumInstsKilled("gcse", "Number of instructions killed"); // // Later, in the code: ++NumInstsKilled; // +// NOTE: Statistics *must* be declared as global variables. +// //===----------------------------------------------------------------------===// #ifndef LLVM_ADT_STATISTIC_H @@ -29,7 +31,7 @@ namespace llvm { -// StatisticBase - Nontemplated base class for Statistic<> class... +// StatisticBase - Nontemplated base class for Statistic class... class StatisticBase { const char *Name; const char *Desc; @@ -55,39 +57,36 @@ protected: }; // Statistic Class - templated on the data type we are monitoring... -template <typename DataType=unsigned> class Statistic : private StatisticBase { - DataType Value; + unsigned Value; virtual void printValue(std::ostream &o) const { o << Value; } - virtual bool hasSomeData() const { return Value != DataType(); } + virtual bool hasSomeData() const { return Value != 0; } public: // Normal constructor, default initialize data item... Statistic(const char *name, const char *desc) - : StatisticBase(name, desc), Value(DataType()) {} + : StatisticBase(name, desc), Value(0) {} // Constructor to provide an initial value... - Statistic(const DataType &Val, const char *name, const char *desc) + Statistic(const unsigned &Val, const char *name, const char *desc) : StatisticBase(name, desc), Value(Val) {} // Print information when destroyed, iff command line option is specified ~Statistic() { destroy(); } // Allow use of this class as the value itself... - operator DataType() const { return Value; } - const Statistic &operator=(DataType Val) { Value = Val; return *this; } + operator unsigned() const { return Value; } + const Statistic &operator=(unsigned Val) { Value = Val; return *this; } const Statistic &operator++() { ++Value; return *this; } - DataType operator++(int) { return Value++; } + unsigned operator++(int) { return Value++; } const Statistic &operator--() { --Value; return *this; } - DataType operator--(int) { return Value--; } - const Statistic &operator+=(const DataType &V) { Value += V; return *this; } - const Statistic &operator-=(const DataType &V) { Value -= V; return *this; } - const Statistic &operator*=(const DataType &V) { Value *= V; return *this; } - const Statistic &operator/=(const DataType &V) { Value /= V; return *this; } + unsigned operator--(int) { return Value--; } + const Statistic &operator+=(const unsigned &V) { Value += V; return *this; } + const Statistic &operator-=(const unsigned &V) { Value -= V; return *this; } + const Statistic &operator*=(const unsigned &V) { Value *= V; return *this; } + const Statistic &operator/=(const unsigned &V) { Value /= V; return *this; } }; -EXTERN_TEMPLATE_INSTANTIATION(class Statistic<unsigned>); - } // End llvm namespace #endif |