OLD | NEW |
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 Loading... |
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; |
| 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 88 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
145 /// should only be used by rare constructs such as address-of-label. | 154 /// should only be used by rare constructs such as address-of-label. |
146 unsigned getGlobalBasicBlockID(const BasicBlock *BB) const; | 155 unsigned getGlobalBasicBlockID(const BasicBlock *BB) const; |
147 | 156 |
148 /// incorporateFunction/purgeFunction - If you'd like to deal with a function, | 157 /// incorporateFunction/purgeFunction - If you'd like to deal with a function, |
149 /// use these two methods to get its data into the NaClValueEnumerator! | 158 /// use these two methods to get its data into the NaClValueEnumerator! |
150 /// | 159 /// |
151 void incorporateFunction(const Function &F); | 160 void incorporateFunction(const Function &F); |
152 void purgeFunction(); | 161 void purgeFunction(); |
153 | 162 |
154 private: | 163 private: |
| 164 void OptimizeTypes(const Module *M); |
155 void OptimizeConstants(unsigned CstStart, unsigned CstEnd); | 165 void OptimizeConstants(unsigned CstStart, unsigned CstEnd); |
156 | 166 |
157 void EnumerateMDNodeOperands(const MDNode *N); | 167 void EnumerateMDNodeOperands(const MDNode *N); |
158 void EnumerateMetadata(const Value *MD); | 168 void EnumerateMetadata(const Value *MD); |
159 void EnumerateFunctionLocalMetadata(const MDNode *N); | 169 void EnumerateFunctionLocalMetadata(const MDNode *N); |
160 void EnumerateNamedMDNode(const NamedMDNode *NMD); | 170 void EnumerateNamedMDNode(const NamedMDNode *NMD); |
161 void EnumerateValue(const Value *V); | 171 void EnumerateValue(const Value *V); |
162 void EnumerateType(Type *T); | 172 void EnumerateType(Type *T, bool InsideOptimizeTypes=false); |
163 void EnumerateOperandType(const Value *V); | 173 void EnumerateOperandType(const Value *V); |
164 void EnumerateAttributes(AttributeSet PAL); | 174 void EnumerateAttributes(AttributeSet PAL); |
165 | 175 |
166 void EnumerateValueSymbolTable(const ValueSymbolTable &ST); | 176 void EnumerateValueSymbolTable(const ValueSymbolTable &ST); |
167 void EnumerateNamedMetadata(const Module *M); | 177 void EnumerateNamedMetadata(const Module *M); |
168 }; | 178 }; |
169 | 179 |
170 } // End llvm namespace | 180 } // End llvm namespace |
171 | 181 |
172 #endif | 182 #endif |
OLD | NEW |