OLD | NEW |
(Empty) | |
| 1 //===-- NaClAnalyzerBlockDist.cpp -----------------------------------------===// |
| 2 // implements 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 #include "llvm/Bitcode/NaCl/NaClAnalyzerBlockDist.h" |
| 13 |
| 14 using namespace llvm; |
| 15 |
| 16 NaClAnalyzerBlockDistElement::~NaClAnalyzerBlockDistElement() {} |
| 17 |
| 18 NaClBitcodeDistElement* NaClAnalyzerBlockDistElement:: |
| 19 CreateElement(NaClBitcodeDistValue Value) const { |
| 20 return new NaClAnalyzerBlockDistElement(Value, OrderBlocksByID); |
| 21 } |
| 22 |
| 23 double NaClAnalyzerBlockDistElement:: |
| 24 GetImportance(NaClBitcodeDistValue Value) const { |
| 25 if (OrderBlocksByID) |
| 26 // Negate importance to "undo" reverse ordering of sort. |
| 27 return -static_cast<double>(BlockID); |
| 28 else |
| 29 return NaClBitcodeBlockDistElement::GetImportance(Value); |
| 30 } |
| 31 |
| 32 const SmallVectorImpl<NaClBitcodeDist*> *NaClAnalyzerBlockDistElement:: |
| 33 GetNestedDistributions() const { |
| 34 return &NestedDists; |
| 35 } |
| 36 |
| 37 void NaClAnalyzerBlockDist::AddRecord(const NaClBitcodeRecord &Record) { |
| 38 cast<NaClAnalyzerBlockDistElement>(GetElement(Record.GetBlockID())) |
| 39 ->GetRecordDist().AddRecord(Record); |
| 40 } |
| 41 |
| 42 void NaClAnalyzerBlockDist::AddBlock(const NaClBitcodeBlock &Block) { |
| 43 NaClBitcodeBlockDist::AddBlock(Block); |
| 44 if (const NaClBitcodeBlock *EncBlock = Block.GetEnclosingBlock()) { |
| 45 cast<NaClAnalyzerBlockDistElement>(GetElement(EncBlock->GetBlockID())) |
| 46 ->GetSubblockDist().AddBlock(Block); |
| 47 } |
| 48 } |
OLD | NEW |