llvm.org GIT mirror llvm / d092e0e
Add abbreviations to the TYPE_BLOCK for pointers, functions, structs and arrays. This shrinks the type_block of kc++ from 139901 bits to 99389 bits (0.55% to 0.39% of the file), a 40% reduction. This shrink the record from: Block ID #10 (TYPE_BLOCK): Num Instances: 1 Total Size: 139901b/17487.6B/4371.91W % of file: 0.549306 Num Abbrevs: 0 Num Records: 3203 % Abbrev Recs: 0 to: Block ID #10 (TYPE_BLOCK): Num Instances: 1 Total Size: 99389b/12423.6B/3105.91W % of file: 0.390862 Num Abbrevs: 4 Num Records: 3203 % Abbrev Recs: 99.6566 With a common histogram of: Code Histogram: 1613 POINTER 1100 FUNCTION 255 STRUCT 224 ARRAY 5 INTEGER 2 OPAQUE 1 LABEL 1 DOUBLE 1 VOID 1 NUMENTRY git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@36776 91177308-0d34-0410-b5e6-96231b3b80d8 Chris Lattner 12 years ago
1 changed file(s) with 40 addition(s) and 3 deletion(s). Raw diff Collapse all Expand all
120120 Stream.EnterSubblock(bitc::TYPE_BLOCK_ID, 4 /*count from # abbrevs */);
121121 SmallVector TypeVals;
122122
123 // FIXME: Set up abbrevs now that we know the width of the type fields, etc.
123 // Abbrev for TYPE_CODE_POINTER.
124 BitCodeAbbrev *Abbv = new BitCodeAbbrev();
125 Abbv->Add(BitCodeAbbrevOp(bitc::TYPE_CODE_POINTER));
126 Abbv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed,
127 Log2_32_Ceil(VE.getTypes().size()+1)));
128 unsigned PtrAbbrev = Stream.EmitAbbrev(Abbv);
129
130 // Abbrev for TYPE_CODE_FUNCTION.
131 Abbv = new BitCodeAbbrev();
132 Abbv->Add(BitCodeAbbrevOp(bitc::TYPE_CODE_FUNCTION));
133 Abbv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 1)); // isvararg
134 Abbv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed,
135 Log2_32_Ceil(VE.getParamAttrs().size()+1)));
136 Abbv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Array));
137 Abbv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed,
138 Log2_32_Ceil(VE.getTypes().size()+1)));
139 unsigned FunctionAbbrev = Stream.EmitAbbrev(Abbv);
140
141 // Abbrev for TYPE_CODE_STRUCT.
142 Abbv = new BitCodeAbbrev();
143 Abbv->Add(BitCodeAbbrevOp(bitc::TYPE_CODE_STRUCT));
144 Abbv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 1)); // ispacked
145 Abbv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Array));
146 Abbv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed,
147 Log2_32_Ceil(VE.getTypes().size()+1)));
148 unsigned StructAbbrev = Stream.EmitAbbrev(Abbv);
149
150 // Abbrev for TYPE_CODE_ARRAY.
151 Abbv = new BitCodeAbbrev();
152 Abbv->Add(BitCodeAbbrevOp(bitc::TYPE_CODE_ARRAY));
153 Abbv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 8)); // size
154 Abbv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed,
155 Log2_32_Ceil(VE.getTypes().size()+1)));
156 unsigned ArrayAbbrev = Stream.EmitAbbrev(Abbv);
124157
125158 // Emit an entry count so the reader can reserve space.
126159 TypeVals.push_back(TypeList.size());
150183 // POINTER: [pointee type]
151184 Code = bitc::TYPE_CODE_POINTER;
152185 TypeVals.push_back(VE.getTypeID(cast(T)->getElementType()));
186 AbbrevToUse = PtrAbbrev;
153187 break;
154188
155189 case Type::FunctionTyID: {
156190 const FunctionType *FT = cast(T);
157 // FUNCTION: [isvararg, attrid, #pararms, paramty x N]
191 // FUNCTION: [isvararg, attrid, retty, paramty x N]
158192 Code = bitc::TYPE_CODE_FUNCTION;
159193 TypeVals.push_back(FT->isVarArg());
160194 TypeVals.push_back(VE.getParamAttrID(FT->getParamAttrs()));
161195 TypeVals.push_back(VE.getTypeID(FT->getReturnType()));
162196 for (unsigned i = 0, e = FT->getNumParams(); i != e; ++i)
163197 TypeVals.push_back(VE.getTypeID(FT->getParamType(i)));
198 AbbrevToUse = FunctionAbbrev;
164199 break;
165200 }
166201 case Type::StructTyID: {
167202 const StructType *ST = cast(T);
168 // STRUCT: [ispacked, #elts, eltty x N]
203 // STRUCT: [ispacked, eltty x N]
169204 Code = bitc::TYPE_CODE_STRUCT;
170205 TypeVals.push_back(ST->isPacked());
171206 // Output all of the element types.
172207 for (StructType::element_iterator I = ST->element_begin(),
173208 E = ST->element_end(); I != E; ++I)
174209 TypeVals.push_back(VE.getTypeID(*I));
210 AbbrevToUse = StructAbbrev;
175211 break;
176212 }
177213 case Type::ArrayTyID: {
180216 Code = bitc::TYPE_CODE_ARRAY;
181217 TypeVals.push_back(AT->getNumElements());
182218 TypeVals.push_back(VE.getTypeID(AT->getElementType()));
219 AbbrevToUse = ArrayAbbrev;
183220 break;
184221 }
185222 case Type::VectorTyID: {