OLD | NEW |
(Empty) | |
| 1 //===- NaClBitcodeBitsDist.h ------------------------------------*- C++ -*-===// |
| 2 // Maps distributions of values and corresponding number of |
| 3 // bits in PNaCl bitcode records. |
| 4 // |
| 5 // The LLVM Compiler Infrastructure |
| 6 // |
| 7 // This file is distributed under the University of Illinois Open Source |
| 8 // License. See LICENSE.TXT for details. |
| 9 // |
| 10 //===----------------------------------------------------------------------===// |
| 11 // |
| 12 // Creates a (nestable) distribution map of values, and the correspdonding |
| 13 // bits, in PNaCl bitcode records. These distributions are built directly |
| 14 // on top of the NaClBitcodeDistElement class. |
| 15 |
| 16 #ifndef LLVM_BITCODE_NACL_NACLBITCODEBITSDIST_H |
| 17 #define LLVM_BITCODE_NACL_NACLBITCODEBITSDIST_H |
| 18 |
| 19 #include "llvm/Bitcode/NaCl/NaClBitcodeDist.h" |
| 20 |
| 21 namespace llvm { |
| 22 |
| 23 /// Defines the element type of a PNaCl bitcode distribution map when |
| 24 /// we want to count both the number of instances, and the number of |
| 25 /// bits used by each record. Also tracks the number to times an |
| 26 /// abbreviation was used to parse the corresponding record. |
| 27 class NaClBitcodeBitsDistElement : public NaClBitcodeDistElement { |
| 28 NaClBitcodeBitsDistElement(const NaClBitcodeBitsDistElement&) |
| 29 LLVM_DELETED_FUNCTION; |
| 30 void operator=(const NaClBitcodeBitsDistElement&) |
| 31 LLVM_DELETED_FUNCTION; |
| 32 |
| 33 public: |
| 34 static bool classof(const NaClBitcodeDistElement *Dist) { |
| 35 return Dist->getKind() >= RDE_BitsDist |
| 36 && Dist->getKind() < RDE_BitsDistLast; |
| 37 } |
| 38 |
| 39 // Create an element with no instances. |
| 40 explicit NaClBitcodeBitsDistElement( |
| 41 NaClBitcodeDistElementKind Kind=RDE_BitsDist) |
| 42 : NaClBitcodeDistElement(Kind), |
| 43 TotalBits(0) |
| 44 {} |
| 45 |
| 46 virtual ~NaClBitcodeBitsDistElement(); |
| 47 |
| 48 virtual void AddRecord(const NaClBitcodeRecord &Record); |
| 49 |
| 50 virtual void AddBlock(const NaClBitcodeBlock &Block); |
| 51 |
| 52 // Returns the total number of bits used to represent all instances |
| 53 // of this value. |
| 54 uint64_t GetTotalBits() const { |
| 55 return TotalBits; |
| 56 } |
| 57 |
| 58 virtual void PrintStatsHeader(raw_ostream &Stream) const; |
| 59 |
| 60 virtual void PrintRowStats(raw_ostream &Stream, |
| 61 const NaClBitcodeDist *Distribution) const; |
| 62 |
| 63 private: |
| 64 // Number of bits used to represent all instances of the value. |
| 65 uint64_t TotalBits; |
| 66 }; |
| 67 |
| 68 } |
| 69 |
| 70 #endif |
OLD | NEW |