OLD | NEW |
(Empty) | |
| 1 //===-- NaClAnalyzerBlockDist.h --------------------------------------------===/
/ |
| 2 // Defines distribution maps used to collect block and record |
| 3 // distributions for tools pnacl-bcanalyzer and pnacl-benchmark. |
| 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 // Defines a block distribution, with nested subblock and record code |
| 13 // distributions, to be collected during analysis. |
| 14 |
| 15 #ifndef LLVM_BITCODE_NACL_NACLANALYZERBLOCKDIST_H |
| 16 #define LLVM_BITCODE_NACL_NACLANALYZERBLOCKDIST_H |
| 17 |
| 18 #include "llvm/Bitcode/NaCl/NaClBitcodeBlockDist.h" |
| 19 #include "llvm/Bitcode/NaCl/NaClBitcodeCodeDist.h" |
| 20 #include "llvm/Bitcode/NaCl/NaClBitcodeSubblockDist.h" |
| 21 |
| 22 namespace llvm { |
| 23 |
| 24 /// Holds block distribution, and nested subblock and record code distributions, |
| 25 /// to be collected during analysis. |
| 26 class NaClAnalyzerBlockDistElement : public NaClBitcodeBlockDistElement { |
| 27 NaClAnalyzerBlockDistElement(const NaClAnalyzerBlockDistElement&) |
| 28 LLVM_DELETED_FUNCTION; |
| 29 void operator=(const NaClAnalyzerBlockDistElement&) LLVM_DELETED_FUNCTION; |
| 30 |
| 31 public: |
| 32 static bool classof(const NaClBitcodeDistElement *Element) { |
| 33 return Element->getKind() >= RDE_NaClAnalBlockDist && |
| 34 Element->getKind() < RDE_NaClAnalBlockDistLast; |
| 35 } |
| 36 |
| 37 explicit NaClAnalyzerBlockDistElement(unsigned BlockID=0, |
| 38 bool OrderBlocksByID=false) |
| 39 : NaClBitcodeBlockDistElement(RDE_NaClAnalBlockDist), |
| 40 BlockID(BlockID), |
| 41 RecordDist(BlockID), |
| 42 OrderBlocksByID(OrderBlocksByID) { |
| 43 NestedDists.push_back(&SubblockDist); |
| 44 NestedDists.push_back(&RecordDist); |
| 45 } |
| 46 |
| 47 virtual ~NaClAnalyzerBlockDistElement(); |
| 48 |
| 49 virtual NaClBitcodeDistElement* |
| 50 CreateElement(NaClBitcodeDistValue Value) const; |
| 51 |
| 52 virtual double GetImportance(NaClBitcodeDistValue Value) const; |
| 53 |
| 54 virtual const SmallVectorImpl<NaClBitcodeDist*> * |
| 55 GetNestedDistributions() const; |
| 56 |
| 57 NaClBitcodeDist &GetSubblockDist() { |
| 58 return SubblockDist; |
| 59 } |
| 60 |
| 61 NaClBitcodeCodeDist &GetRecordDist() { |
| 62 return RecordDist; |
| 63 } |
| 64 |
| 65 private: |
| 66 // The block ID of the distribution. |
| 67 unsigned BlockID; |
| 68 |
| 69 // Subblocks that appear in this block. |
| 70 NaClBitcodeSubblockDist SubblockDist; |
| 71 |
| 72 // Records that appear in this block. |
| 73 NaClBitcodeCodeDist RecordDist; |
| 74 |
| 75 // Nested blocks used by GetNestedDistributions. |
| 76 SmallVector<NaClBitcodeDist*, 2> NestedDists; |
| 77 |
| 78 // If true, order (top-level) blocks by block ID instead of file |
| 79 // size. |
| 80 bool OrderBlocksByID; |
| 81 }; |
| 82 |
| 83 /// Holds block distribution, and nested subblock and record code distributions, |
| 84 /// to be collected during analysis. |
| 85 class NaClAnalyzerBlockDist : public NaClBitcodeBlockDist { |
| 86 NaClAnalyzerBlockDist(const NaClAnalyzerBlockDist&) LLVM_DELETED_FUNCTION; |
| 87 void operator=(const NaClAnalyzerBlockDist&) LLVM_DELETED_FUNCTION; |
| 88 public: |
| 89 NaClAnalyzerBlockDist(NaClAnalyzerBlockDistElement &Sentinel) |
| 90 : NaClBitcodeBlockDist(&Sentinel) |
| 91 {} |
| 92 |
| 93 virtual ~NaClAnalyzerBlockDist() {} |
| 94 |
| 95 virtual void AddRecord(const NaClBitcodeRecord &Record); |
| 96 |
| 97 virtual void AddBlock(const NaClBitcodeBlock &Block); |
| 98 }; |
| 99 |
| 100 } |
| 101 #endif |
OLD | NEW |