Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(637)

Side by Side Diff: include/llvm/Bitcode/NaCl/NaClBitcodeAbbrevDist.h

Issue 939073008: Rebased PNaCl localmods in LLVM to 223109 (Closed)
Patch Set: undo localmod Created 5 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
(Empty)
1 //===-- NaClBitcodeAbbrevDist.h ---------------------------------------------=== //
2 // Defines distribution maps for abbreviations associated with
3 // 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 // Defines distribution maps for tracking abbreviations associated
13 // with bitcode records.
14
15 #ifndef LLVM_BITCODE_NACL_NACLBITCODEABBREVDIST_H
16 #define LLVM_BITCODE_NACL_NACLBITCODEABBREVDIST_H
17
18 #include "llvm/Bitcode/NaCl/NaClBitcodeDist.h"
19 #include "llvm/Bitcode/NaCl/NaClCompressCodeDist.h"
20
21 namespace llvm {
22
23 /// Collects the number of instances associated with a given abbreviation
24 /// index of a bitcode record. Note: Uses naclbitc::UNABBREV_RECORD index
25 /// to denote bitcode records that did not use an abbreviation.
26 class NaClBitcodeAbbrevDistElement : public NaClBitcodeDistElement {
27 NaClBitcodeAbbrevDistElement(const NaClBitcodeAbbrevDistElement&)
28 LLVM_DELETED_FUNCTION;
29 void operator=(const NaClBitcodeAbbrevDistElement&) LLVM_DELETED_FUNCTION;
30
31 public:
32 static bool classof(const NaClBitcodeDistElement *Element) {
33 return Element->getKind() >= RDE_AbbrevDist &&
34 Element->getKind() < RDE_AbbrevDistLast;
35 }
36
37 explicit NaClBitcodeAbbrevDistElement(unsigned BlockID=0)
38 : NaClBitcodeDistElement(RDE_AbbrevDist),
39 CodeDist(BlockID, &NaClCompressCodeDistElement::Sentinel) {
40 NestedDists.push_back(&CodeDist);
41 }
42
43 // Sentinel to create instances of this.
44 static NaClBitcodeAbbrevDistElement Sentinel;
45
46 virtual ~NaClBitcodeAbbrevDistElement();
47
48 virtual NaClBitcodeDistElement *CreateElement(
49 NaClBitcodeDistValue Value) const;
50
51 virtual void GetValueList(const NaClBitcodeRecord &Record,
52 ValueListType &ValueList) const;
53
54 virtual void AddRecord(const NaClBitcodeRecord &Record);
55
56 virtual const char *GetTitle() const;
57
58 virtual const char *GetValueHeader() const;
59
60 virtual void PrintRowValue(raw_ostream &Stream,
61 NaClBitcodeDistValue Value,
62 const NaClBitcodeDist *Distribution) const;
63
64 virtual const SmallVectorImpl<NaClBitcodeDist*> *
65 GetNestedDistributions() const;
66
67 NaClBitcodeDist &GetCodeDist() {
68 return CodeDist;
69 }
70
71 private:
72 // Nested blocks used by GetNestedDistributions.
73 SmallVector<NaClBitcodeDist*, 1> NestedDists;
74
75 /// The records associated with the given abbreviation.
76 NaClBitcodeCodeDist CodeDist;
77 };
78
79 /// Separates record codes based on abbreviations. This is done so
80 /// that when we add abbreviations, they will be refinements of
81 /// existing abbreviations. This should guarantee that we don't lose
82 /// separation defined by previous iterations on calls to
83 /// pnacl-bccompress.
84 class NaClBitcodeAbbrevDist : public NaClBitcodeDist {
85 public:
86 static bool classof(const NaClBitcodeDist *Dist) {
87 return Dist->getKind() >= RD_AbbrevDist &&
88 Dist->getKind() < RD_AbbrevDistLast;
89 }
90
91 explicit NaClBitcodeAbbrevDist(
92 unsigned BlockID,
93 NaClBitcodeAbbrevDistElement *Sentinel
94 = &NaClBitcodeAbbrevDistElement::Sentinel,
95 NaClBitcodeDistKind Kind=RD_AbbrevDist)
96 : NaClBitcodeDist(RecordStorage, Sentinel, Kind),
97 BlockID(BlockID) {
98 }
99
100 virtual ~NaClBitcodeAbbrevDist();
101
102 // Returns the block id associated with the abbreviations in this
103 // distribution map.
104 unsigned GetBlockID() const {
105 return BlockID;
106 }
107
108 virtual NaClBitcodeDistElement*
109 CreateElement(NaClBitcodeDistValue Value) const;
110
111 private:
112 // The block id associated with the abbreviations in this
113 // distribution map.
114 unsigned BlockID;
115 };
116
117 }
118
119 #endif
OLDNEW
« no previous file with comments | « include/llvm/Bitcode/NaCl/NaClBitCodes.h ('k') | include/llvm/Bitcode/NaCl/NaClBitcodeAnalyzer.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698