Index: include/llvm/Bitcode/NaCl/NaClBitcodeBitsAndAbbrevsDist.h |
diff --git a/include/llvm/Bitcode/NaCl/NaClBitcodeBitsAndAbbrevsDist.h b/include/llvm/Bitcode/NaCl/NaClBitcodeBitsAndAbbrevsDist.h |
new file mode 100644 |
index 0000000000000000000000000000000000000000..9e7a47be06af30f267ac34e3d7e1e1a5a6f039d8 |
--- /dev/null |
+++ b/include/llvm/Bitcode/NaCl/NaClBitcodeBitsAndAbbrevsDist.h |
@@ -0,0 +1,70 @@ |
+//===- NaClBitcodeBitsAndAbbrevsDist.h --------------------*- C++ -*-===// |
+// Maps distributions of values with corresponding number of bits, |
+// and percentage of abbreviations used in PNaCl bitcode records. |
+// |
+// The LLVM Compiler Infrastructure |
+// |
+// This file is distributed under the University of Illinois Open Source |
+// License. See LICENSE.TXT for details. |
+// |
+//===----------------------------------------------------------------------===// |
+// |
+// Creates a distribution map of values and the |
+// correspdonding bits and abbreviations in PNaCl bitcode records. |
+ |
+#ifndef LLVM_BITCODE_NACL_NACLBITCODEBITSANDABBREVSDIST_H |
+#define LLVM_BITCODE_NACL_NACLBITCODEBITSANDABBREVSDIST_H |
+ |
+#include "llvm/Bitcode/NaCl/NaClBitcodeBitsDist.h" |
+ |
+namespace llvm { |
+ |
+/// Defines the element type of a PNaCl bitcode distribution map when |
+/// we want to count both the number of instances, and the number of |
+/// bits used by each record. Also tracks the number to times an |
+/// abbreviation was used to parse the corresponding record. |
+class NaClBitcodeBitsAndAbbrevsDistElement : public NaClBitcodeBitsDistElement { |
+ NaClBitcodeBitsAndAbbrevsDistElement( |
+ const NaClBitcodeBitsAndAbbrevsDistElement&) LLVM_DELETED_FUNCTION; |
+ void operator=(const NaClBitcodeBitsAndAbbrevsDistElement&) |
+ LLVM_DELETED_FUNCTION; |
+ |
+public: |
+ static bool classof(const NaClBitcodeDistElement *Dist) { |
+ return Dist->getKind() >= RDE_BitsAndAbbrevsDist |
+ && Dist->getKind() < RDE_BitsAndAbbrevsDistLast; |
+ } |
+ |
+ // Create an element with no instances. |
+ explicit NaClBitcodeBitsAndAbbrevsDistElement( |
+ NaClBitcodeDistElementKind Kind=RDE_BitsAndAbbrevsDist) |
+ : NaClBitcodeBitsDistElement(Kind), |
+ NumAbbrevs(0) |
+ {} |
+ |
+ virtual ~NaClBitcodeBitsAndAbbrevsDistElement(); |
+ |
+ virtual void AddRecord(const NaClBitcodeRecord &Record); |
+ |
+ // Note: No AddBlock method override because abbrevations only |
+ // apply to records. |
+ |
+ // Returns the number of times an abbreviation was used to represent |
+ // the value. |
+ unsigned GetNumAbbrevs() const { |
+ return NumAbbrevs; |
+ } |
+ |
+ virtual void PrintStatsHeader(raw_ostream &Stream) const; |
+ |
+ virtual void PrintRowStats(raw_ostream &Stream, |
+ const NaClBitcodeDist *Distribution) const; |
+ |
+private: |
+ // Number of times an abbreviation is used for the value. |
+ unsigned NumAbbrevs; |
+}; |
+ |
+} |
+ |
+#endif |