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

Side by Side Diff: lib/Bitcode/NaCl/Writer/NaClValueEnumerator.h

Issue 14495008: Create type IDs based on reference counts. (Closed) Base URL: http://git.chromium.org/native_client/pnacl-llvm.git@master
Patch Set: Created 7 years, 7 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
1 //===-- Bitcode/NaCl/Writer/NaClValueEnumerator.h - ----------*- C++ -*-===// 1 //===-- Bitcode/NaCl/Writer/NaClValueEnumerator.h - ----------*- C++ -*-===//
2 // Number values. 2 // Number values.
3 // 3 //
4 // The LLVM Compiler Infrastructure 4 // The LLVM Compiler Infrastructure
5 // 5 //
6 // This file is distributed under the University of Illinois Open Source 6 // This file is distributed under the University of Illinois Open Source
7 // License. See LICENSE.TXT for details. 7 // License. See LICENSE.TXT for details.
8 // 8 //
9 //===----------------------------------------------------------------------===// 9 //===----------------------------------------------------------------------===//
10 // 10 //
(...skipping 24 matching lines...) Expand all
35 class MDSymbolTable; 35 class MDSymbolTable;
36 class raw_ostream; 36 class raw_ostream;
37 37
38 class NaClValueEnumerator { 38 class NaClValueEnumerator {
39 public: 39 public:
40 typedef std::vector<Type*> TypeList; 40 typedef std::vector<Type*> TypeList;
41 41
42 // For each value, we remember its Value* and occurrence frequency. 42 // For each value, we remember its Value* and occurrence frequency.
43 typedef std::vector<std::pair<const Value*, unsigned> > ValueList; 43 typedef std::vector<std::pair<const Value*, unsigned> > ValueList;
44 private: 44 private:
45 // Defines unique ID's for each type.
45 typedef DenseMap<Type*, unsigned> TypeMapType; 46 typedef DenseMap<Type*, unsigned> TypeMapType;
46 TypeMapType TypeMap; 47 TypeMapType TypeMap;
48 // Defines the number of references to each type. If defined,
49 // we are in the first pass of collecting types, and reference counts
50 // should be added to the map. If undefined, we are in the second pass
51 // that actually assigns type IDs, based on frequency counts found in
52 // the first pass.
53 typedef TypeMapType TypeCountMapType;
54 TypeCountMapType* TypeCountMap;
jvoung (off chromium) 2013/04/29 18:35:42 Does this need to be a pointer, or could it be all
Karl 2013/04/29 22:19:16 I did it this way because it is only needed during
55
47 TypeList Types; 56 TypeList Types;
48 57
49 typedef DenseMap<const Value*, unsigned> ValueMapType; 58 typedef DenseMap<const Value*, unsigned> ValueMapType;
50 ValueMapType ValueMap; 59 ValueMapType ValueMap;
51 ValueList Values; 60 ValueList Values;
52 ValueList MDValues; 61 ValueList MDValues;
53 SmallVector<const MDNode *, 8> FunctionLocalMDs; 62 SmallVector<const MDNode *, 8> FunctionLocalMDs;
54 ValueMapType MDValueMap; 63 ValueMapType MDValueMap;
55 64
56 typedef DenseMap<AttributeSet, unsigned> AttributeGroupMapType; 65 typedef DenseMap<AttributeSet, unsigned> AttributeGroupMapType;
(...skipping 19 matching lines...) Expand all
76 /// When a function is incorporated, this is the size of the Values list 85 /// When a function is incorporated, this is the size of the Values list
77 /// before incorporation. 86 /// before incorporation.
78 unsigned NumModuleValues; 87 unsigned NumModuleValues;
79 88
80 /// When a function is incorporated, this is the size of the MDValues list 89 /// When a function is incorporated, this is the size of the MDValues list
81 /// before incorporation. 90 /// before incorporation.
82 unsigned NumModuleMDValues; 91 unsigned NumModuleMDValues;
83 92
84 unsigned FirstFuncConstantID; 93 unsigned FirstFuncConstantID;
85 unsigned FirstInstID; 94 unsigned FirstInstID;
95 unsigned FirstFloatTypeID;
jvoung (off chromium) 2013/04/29 18:35:42 why are float types singled out?
Karl 2013/04/29 22:19:16 I was looking ahead to "float" operations, which c
86 96
87 NaClValueEnumerator(const NaClValueEnumerator &) LLVM_DELETED_FUNCTION; 97 NaClValueEnumerator(const NaClValueEnumerator &) LLVM_DELETED_FUNCTION;
88 void operator=(const NaClValueEnumerator &) LLVM_DELETED_FUNCTION; 98 void operator=(const NaClValueEnumerator &) LLVM_DELETED_FUNCTION;
89 public: 99 public:
90 NaClValueEnumerator(const Module *M); 100 NaClValueEnumerator(const Module *M);
91 101
92 void dump() const; 102 void dump() const;
93 void print(raw_ostream &OS, const ValueMapType &Map, const char *Name) const; 103 void print(raw_ostream &OS, const ValueMapType &Map, const char *Name) const;
94 104
95 unsigned getValueID(const Value *V) const; 105 unsigned getValueID(const Value *V) const;
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after
145 /// should only be used by rare constructs such as address-of-label. 155 /// should only be used by rare constructs such as address-of-label.
146 unsigned getGlobalBasicBlockID(const BasicBlock *BB) const; 156 unsigned getGlobalBasicBlockID(const BasicBlock *BB) const;
147 157
148 /// incorporateFunction/purgeFunction - If you'd like to deal with a function, 158 /// incorporateFunction/purgeFunction - If you'd like to deal with a function,
149 /// use these two methods to get its data into the NaClValueEnumerator! 159 /// use these two methods to get its data into the NaClValueEnumerator!
150 /// 160 ///
151 void incorporateFunction(const Function &F); 161 void incorporateFunction(const Function &F);
152 void purgeFunction(); 162 void purgeFunction();
153 163
154 private: 164 private:
165 void OptimizeTypes(const Module *M);
jvoung (off chromium) 2013/04/29 18:35:42 This seems like a change that could be upstreamed.
Karl 2013/04/29 22:19:16 I agree that it is worth considering upstreaming t
155 void OptimizeConstants(unsigned CstStart, unsigned CstEnd); 166 void OptimizeConstants(unsigned CstStart, unsigned CstEnd);
156 167
157 void EnumerateMDNodeOperands(const MDNode *N); 168 void EnumerateMDNodeOperands(const MDNode *N);
158 void EnumerateMetadata(const Value *MD); 169 void EnumerateMetadata(const Value *MD);
159 void EnumerateFunctionLocalMetadata(const MDNode *N); 170 void EnumerateFunctionLocalMetadata(const MDNode *N);
160 void EnumerateNamedMDNode(const NamedMDNode *NMD); 171 void EnumerateNamedMDNode(const NamedMDNode *NMD);
161 void EnumerateValue(const Value *V); 172 void EnumerateValue(const Value *V);
162 void EnumerateType(Type *T); 173 void EnumerateType(Type *T);
163 void EnumerateOperandType(const Value *V); 174 void EnumerateOperandType(const Value *V);
164 void EnumerateAttributes(AttributeSet PAL); 175 void EnumerateAttributes(AttributeSet PAL);
165 176
166 void EnumerateValueSymbolTable(const ValueSymbolTable &ST); 177 void EnumerateValueSymbolTable(const ValueSymbolTable &ST);
167 void EnumerateNamedMetadata(const Module *M); 178 void EnumerateNamedMetadata(const Module *M);
168 }; 179 };
169 180
170 } // End llvm namespace 181 } // End llvm namespace
171 182
172 #endif 183 #endif
OLDNEW
« no previous file with comments | « no previous file | lib/Bitcode/NaCl/Writer/NaClValueEnumerator.cpp » ('j') | lib/Bitcode/NaCl/Writer/NaClValueEnumerator.cpp » ('J')

Powered by Google App Engine
This is Rietveld 408576698