1//===--- CGRecordLayoutBuilder.cpp - CGRecordLayout builder ----*- C++ -*-===// 2// 3// The LLVM Compiler Infrastructure 4// 5// This file is distributed under the University of Illinois Open Source 6// License. See LICENSE.TXT for details. 7// 8//===----------------------------------------------------------------------===// --- 23 unchanged lines hidden (view full) --- 32 /// FieldTypes - Holds the LLVM types that the struct is created from. 33 std::vector<const llvm::Type *> FieldTypes; 34 35 /// LLVMFieldInfo - Holds a field and its corresponding LLVM field number. 36 typedef std::pair<const FieldDecl *, unsigned> LLVMFieldInfo; 37 llvm::SmallVector<LLVMFieldInfo, 16> LLVMFields; 38 39 /// LLVMBitFieldInfo - Holds location and size information about a bit field. |
40 typedef std::pair<const FieldDecl *, CGBitFieldInfo> LLVMBitFieldInfo; |
41 llvm::SmallVector<LLVMBitFieldInfo, 16> LLVMBitFields; 42 43 /// ContainsPointerToDataMember - Whether one of the fields in this record 44 /// layout is a pointer to data member, or a struct that contains pointer to 45 /// data member. 46 bool ContainsPointerToDataMember; 47 48 /// Packed - Whether the resulting LLVM struct will be packed or not. --- 124 unchanged lines hidden (view full) --- 173 llvm::RoundUpToAlignment(FieldSize, 8) / 8; 174 175 assert(NumBytesToAppend && "No bytes to append!"); 176 } 177 178 const llvm::Type *Ty = Types.ConvertTypeForMemRecursive(D->getType()); 179 uint64_t TypeSizeInBits = getTypeSizeInBytes(Ty) * 8; 180 |
181 bool IsSigned = D->getType()->isSignedIntegerType(); 182 LLVMBitFields.push_back(LLVMBitFieldInfo( 183 D, CGBitFieldInfo(FieldOffset / TypeSizeInBits, 184 FieldOffset % TypeSizeInBits, 185 FieldSize, IsSigned))); |
186 187 AppendBytes(NumBytesToAppend); 188 189 BitsAvailableInLastField = 190 NextFieldOffsetInBytes * 8 - (FieldOffset + FieldSize); 191} 192 193bool CGRecordLayoutBuilder::LayoutField(const FieldDecl *D, --- 81 unchanged lines hidden (view full) --- 275 uint64_t FieldSize = 276 Field->getBitWidth()->EvaluateAsInt(Types.getContext()).getZExtValue(); 277 278 // Ignore zero sized bit fields. 279 if (FieldSize == 0) 280 continue; 281 282 // Add the bit field info. |
283 bool IsSigned = Field->getType()->isSignedIntegerType(); 284 LLVMBitFields.push_back(LLVMBitFieldInfo( 285 *Field, CGBitFieldInfo(0, 0, FieldSize, 286 IsSigned))); |
287 } else { 288 LLVMFields.push_back(LLVMFieldInfo(*Field, 0)); 289 } 290 291 HasOnlyZeroSizedBitFields = false; 292 293 const llvm::Type *FieldTy = 294 Types.ConvertTypeForMemRecursive(Field->getType()); --- 189 unchanged lines hidden (view full) --- 484 assert(getContext().getASTRecordLayout(D).getSize() / 8 == 485 getTargetData().getTypeAllocSize(Ty) && 486 "Type size mismatch!"); 487 488 CGRecordLayout *RL = 489 new CGRecordLayout(Ty, Builder.ContainsPointerToDataMember); 490 491 // Add all the field numbers. |
492 for (unsigned i = 0, e = Builder.LLVMFields.size(); i != e; ++i) 493 RL->FieldInfo.insert(Builder.LLVMFields[i]); |
494 |
495 // Add bitfield info. |
496 for (unsigned i = 0, e = Builder.LLVMBitFields.size(); i != e; ++i) 497 RL->BitFields.insert(Builder.LLVMBitFields[i]); |
498 |
499 return RL; 500} |