OLD | NEW |
(Empty) | |
| 1 //===-- NaClBitcodeBlockDist.h -----------------------------------------===// |
| 2 // Defines distribution maps for blocks within PNaCl bitcode. |
| 3 // |
| 4 // The LLVM Compiler Infrastructure |
| 5 // |
| 6 // This file is distributed under the University of Illinois Open Source |
| 7 // License. See LICENSE.TXT for details. |
| 8 // |
| 9 //===----------------------------------------------------------------------===// |
| 10 // |
| 11 // Defines a distribution map for blocks which tracks the number of bits |
| 12 // in each block, as well as the percentage of the file each bitcode block |
| 13 // ID holds. |
| 14 |
| 15 |
| 16 #ifndef LLVM_BITCODE_NACL_NACLBITCODEBLOCKDIST_H |
| 17 #define LLVM_BITCODE_NACL_NACLBITCODEBLOCKDIST_H |
| 18 |
| 19 #include "llvm/Bitcode/NaCl/NaClBitcodeBitsDist.h" |
| 20 |
| 21 namespace llvm { |
| 22 |
| 23 class NaClBitcodeBlockDistElement : public NaClBitcodeBitsDistElement { |
| 24 NaClBitcodeBlockDistElement(const NaClBitcodeBlockDistElement&) |
| 25 LLVM_DELETED_FUNCTION; |
| 26 void operator=(const NaClBitcodeBlockDistElement&); |
| 27 |
| 28 public: |
| 29 static bool classof(const NaClBitcodeDistElement *Element) { |
| 30 return Element->getKind() >= RDE_BlockDist && |
| 31 Element->getKind() < RDE_BlockDistLast; |
| 32 } |
| 33 |
| 34 // Top-level constructor to create instances of this class. |
| 35 explicit NaClBitcodeBlockDistElement( |
| 36 NaClBitcodeDistElementKind Kind=RDE_BlockDist) |
| 37 : NaClBitcodeBitsDistElement(Kind) {} |
| 38 |
| 39 virtual ~NaClBitcodeBlockDistElement(); |
| 40 |
| 41 virtual NaClBitcodeDistElement *CreateElement( |
| 42 NaClBitcodeDistValue Value) const; |
| 43 |
| 44 // Sorts by %file, rather than number of instances. |
| 45 virtual double GetImportance(NaClBitcodeDistValue value) const; |
| 46 |
| 47 virtual const char *GetTitle() const; |
| 48 |
| 49 virtual const char *GetValueHeader() const; |
| 50 |
| 51 /// Prints out header for row of statistics associated with instances |
| 52 /// of this distribution element. |
| 53 virtual void PrintStatsHeader(raw_ostream &Stream) const; |
| 54 |
| 55 /// Prints out statistics for the row with the given value. |
| 56 virtual void PrintRowStats(raw_ostream &Stream, |
| 57 const NaClBitcodeDist *Distribution) const; |
| 58 |
| 59 virtual void PrintRowValue(raw_ostream &Stream, |
| 60 NaClBitcodeDistValue Value, |
| 61 const NaClBitcodeDist *Distribution) const; |
| 62 }; |
| 63 |
| 64 class NaClBitcodeBlockDist : public NaClBitcodeDist { |
| 65 NaClBitcodeBlockDist(const NaClBitcodeBlockDist&) LLVM_DELETED_FUNCTION; |
| 66 void operator=(const NaClBitcodeBlockDist&) LLVM_DELETED_FUNCTION; |
| 67 |
| 68 public: |
| 69 static bool classof(const NaClBitcodeDist *Dist) { |
| 70 return Dist->getKind() >= RD_BlockDist && |
| 71 Dist->getKind() < RD_BlockDistLast; |
| 72 } |
| 73 |
| 74 static NaClBitcodeBlockDistElement DefaultSentinal; |
| 75 |
| 76 explicit NaClBitcodeBlockDist( |
| 77 const NaClBitcodeBlockDistElement *Sentinal=&DefaultSentinal) |
| 78 : NaClBitcodeDist(BlockStorage, Sentinal, RD_BlockDist) |
| 79 {} |
| 80 |
| 81 virtual ~NaClBitcodeBlockDist(); |
| 82 |
| 83 // Returns the total number of bits in all blocks in the distribution. |
| 84 uint64_t GetTotalBits() const; |
| 85 |
| 86 // Returns the printable name associated with the given BlockID. |
| 87 // |
| 88 // Note: If the name is not known, an "UnknownBlock" name is |
| 89 // generated and returned. |
| 90 static std::string GetName(unsigned BlockID); |
| 91 |
| 92 }; |
| 93 |
| 94 } |
| 95 |
| 96 #endif |
OLD | NEW |