Anders Carlsson | 45372a6 | 2009-07-23 03:17:50 +0000 | [diff] [blame] | 1 | //===--- CGRecordLayoutBuilder.cpp - Record builder helper ------*- 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 | //===----------------------------------------------------------------------===// |
| 9 | // |
| 10 | // This is a helper class used to build CGRecordLayout objects and LLVM types. |
| 11 | // |
| 12 | //===----------------------------------------------------------------------===// |
| 13 | |
| 14 | #include "CGRecordLayoutBuilder.h" |
| 15 | |
| 16 | #include "clang/AST/ASTContext.h" |
| 17 | #include "clang/AST/Attr.h" |
| 18 | #include "clang/AST/DeclCXX.h" |
| 19 | #include "clang/AST/Expr.h" |
| 20 | #include "clang/AST/RecordLayout.h" |
| 21 | #include "CodeGenTypes.h" |
| 22 | #include "llvm/DerivedTypes.h" |
| 23 | #include "llvm/Target/TargetData.h" |
| 24 | |
| 25 | |
| 26 | using namespace clang; |
| 27 | using namespace CodeGen; |
| 28 | |
| 29 | void CGRecordLayoutBuilder::Layout(const RecordDecl *D) { |
Anders Carlsson | a5dd722 | 2009-08-08 19:38:24 +0000 | [diff] [blame] | 30 | Alignment = Types.getContext().getASTRecordLayout(D).getAlignment() / 8; |
| 31 | |
Anders Carlsson | 5a6e398 | 2009-07-23 03:43:54 +0000 | [diff] [blame] | 32 | if (D->isUnion()) { |
| 33 | LayoutUnion(D); |
| 34 | return; |
| 35 | } |
Anders Carlsson | a860e75 | 2009-08-08 18:23:56 +0000 | [diff] [blame] | 36 | |
| 37 | Packed = D->hasAttr<PackedAttr>(); |
Anders Carlsson | a5dd722 | 2009-08-08 19:38:24 +0000 | [diff] [blame] | 38 | |
Anders Carlsson | 45372a6 | 2009-07-23 03:17:50 +0000 | [diff] [blame] | 39 | if (LayoutFields(D)) |
| 40 | return; |
| 41 | |
Anders Carlsson | 45372a6 | 2009-07-23 03:17:50 +0000 | [diff] [blame] | 42 | // We weren't able to layout the struct. Try again with a packed struct |
Anders Carlsson | 4b5584b | 2009-07-23 17:24:40 +0000 | [diff] [blame] | 43 | Packed = true; |
Anders Carlsson | 45372a6 | 2009-07-23 03:17:50 +0000 | [diff] [blame] | 44 | AlignmentAsLLVMStruct = 1; |
Anders Carlsson | c2cc1d5 | 2009-07-28 17:56:36 +0000 | [diff] [blame] | 45 | NextFieldOffsetInBytes = 0; |
Anders Carlsson | 45372a6 | 2009-07-23 03:17:50 +0000 | [diff] [blame] | 46 | FieldTypes.clear(); |
Anders Carlsson | 45372a6 | 2009-07-23 03:17:50 +0000 | [diff] [blame] | 47 | LLVMFields.clear(); |
| 48 | LLVMBitFields.clear(); |
| 49 | |
| 50 | LayoutFields(D); |
| 51 | } |
| 52 | |
| 53 | void CGRecordLayoutBuilder::LayoutBitField(const FieldDecl *D, |
| 54 | uint64_t FieldOffset) { |
| 55 | uint64_t FieldSize = |
| 56 | D->getBitWidth()->EvaluateAsInt(Types.getContext()).getZExtValue(); |
| 57 | |
| 58 | if (FieldSize == 0) |
| 59 | return; |
| 60 | |
Anders Carlsson | c2cc1d5 | 2009-07-28 17:56:36 +0000 | [diff] [blame] | 61 | uint64_t NextFieldOffset = NextFieldOffsetInBytes * 8; |
Anders Carlsson | 45372a6 | 2009-07-23 03:17:50 +0000 | [diff] [blame] | 62 | unsigned NumBytesToAppend; |
| 63 | |
| 64 | if (FieldOffset < NextFieldOffset) { |
| 65 | assert(BitsAvailableInLastField && "Bitfield size mismatch!"); |
Anders Carlsson | c2cc1d5 | 2009-07-28 17:56:36 +0000 | [diff] [blame] | 66 | assert(NextFieldOffsetInBytes && "Must have laid out at least one byte!"); |
Anders Carlsson | 45372a6 | 2009-07-23 03:17:50 +0000 | [diff] [blame] | 67 | |
| 68 | // The bitfield begins in the previous bit-field. |
| 69 | NumBytesToAppend = |
| 70 | llvm::RoundUpToAlignment(FieldSize - BitsAvailableInLastField, 8) / 8; |
| 71 | } else { |
| 72 | assert(FieldOffset % 8 == 0 && "Field offset not aligned correctly"); |
| 73 | |
| 74 | // Append padding if necessary. |
| 75 | AppendBytes((FieldOffset - NextFieldOffset) / 8); |
| 76 | |
| 77 | NumBytesToAppend = |
| 78 | llvm::RoundUpToAlignment(FieldSize, 8) / 8; |
| 79 | |
| 80 | assert(NumBytesToAppend && "No bytes to append!"); |
| 81 | } |
| 82 | |
| 83 | const llvm::Type *Ty = Types.ConvertTypeForMemRecursive(D->getType()); |
| 84 | uint64_t TypeSizeInBits = getTypeSizeInBytes(Ty) * 8; |
| 85 | |
Anders Carlsson | 8330cee | 2009-07-23 17:01:21 +0000 | [diff] [blame] | 86 | LLVMBitFields.push_back(LLVMBitFieldInfo(D, FieldOffset / TypeSizeInBits, |
| 87 | FieldOffset % TypeSizeInBits, |
Anders Carlsson | 45372a6 | 2009-07-23 03:17:50 +0000 | [diff] [blame] | 88 | FieldSize)); |
| 89 | |
| 90 | AppendBytes(NumBytesToAppend); |
| 91 | |
Anders Carlsson | c1efe36 | 2009-07-27 14:55:54 +0000 | [diff] [blame] | 92 | AlignmentAsLLVMStruct = std::max(AlignmentAsLLVMStruct, getTypeAlignment(Ty)); |
| 93 | |
Anders Carlsson | faaec22 | 2009-07-23 21:16:33 +0000 | [diff] [blame] | 94 | BitsAvailableInLastField = |
Anders Carlsson | c2cc1d5 | 2009-07-28 17:56:36 +0000 | [diff] [blame] | 95 | NextFieldOffsetInBytes * 8 - (FieldOffset + FieldSize); |
Anders Carlsson | 45372a6 | 2009-07-23 03:17:50 +0000 | [diff] [blame] | 96 | } |
| 97 | |
| 98 | bool CGRecordLayoutBuilder::LayoutField(const FieldDecl *D, |
| 99 | uint64_t FieldOffset) { |
Anders Carlsson | 45372a6 | 2009-07-23 03:17:50 +0000 | [diff] [blame] | 100 | // If the field is packed, then we need a packed struct. |
Anders Carlsson | a860e75 | 2009-08-08 18:23:56 +0000 | [diff] [blame] | 101 | if (!Packed && D->hasAttr<PackedAttr>()) |
Anders Carlsson | 45372a6 | 2009-07-23 03:17:50 +0000 | [diff] [blame] | 102 | return false; |
| 103 | |
| 104 | if (D->isBitField()) { |
| 105 | // We must use packed structs for unnamed bit fields since they |
| 106 | // don't affect the struct alignment. |
Anders Carlsson | 4b5584b | 2009-07-23 17:24:40 +0000 | [diff] [blame] | 107 | if (!Packed && !D->getDeclName()) |
Anders Carlsson | 45372a6 | 2009-07-23 03:17:50 +0000 | [diff] [blame] | 108 | return false; |
| 109 | |
| 110 | LayoutBitField(D, FieldOffset); |
| 111 | return true; |
| 112 | } |
| 113 | |
Anders Carlsson | 45372a6 | 2009-07-23 03:17:50 +0000 | [diff] [blame] | 114 | assert(FieldOffset % 8 == 0 && "FieldOffset is not on a byte boundary!"); |
Anders Carlsson | 45372a6 | 2009-07-23 03:17:50 +0000 | [diff] [blame] | 115 | uint64_t FieldOffsetInBytes = FieldOffset / 8; |
| 116 | |
Anders Carlsson | de9f2c9 | 2009-08-04 16:29:15 +0000 | [diff] [blame] | 117 | const llvm::Type *Ty = Types.ConvertTypeForMemRecursive(D->getType()); |
| 118 | unsigned TypeAlignment = getTypeAlignment(Ty); |
| 119 | |
Anders Carlsson | a5dd722 | 2009-08-08 19:38:24 +0000 | [diff] [blame] | 120 | // If the type alignment is larger then the struct alignment, we must use |
| 121 | // a packed struct. |
| 122 | if (TypeAlignment > Alignment) { |
| 123 | assert(!Packed && "Alignment is wrong even with packed struct!"); |
| 124 | return false; |
| 125 | } |
| 126 | |
| 127 | if (const RecordType *RT = D->getType()->getAs<RecordType>()) { |
| 128 | const RecordDecl *RD = cast<RecordDecl>(RT->getDecl()); |
| 129 | if (const PragmaPackAttr *PPA = RD->getAttr<PragmaPackAttr>()) { |
| 130 | if (PPA->getAlignment() != TypeAlignment * 8 && !Packed) |
| 131 | return false; |
| 132 | } |
| 133 | } |
| 134 | |
Anders Carlsson | de9f2c9 | 2009-08-04 16:29:15 +0000 | [diff] [blame] | 135 | // Round up the field offset to the alignment of the field type. |
| 136 | uint64_t AlignedNextFieldOffsetInBytes = |
| 137 | llvm::RoundUpToAlignment(NextFieldOffsetInBytes, TypeAlignment); |
| 138 | |
| 139 | if (FieldOffsetInBytes < AlignedNextFieldOffsetInBytes) { |
| 140 | assert(!Packed && "Could not place field even with packed struct!"); |
| 141 | return false; |
| 142 | } |
| 143 | |
| 144 | if (AlignedNextFieldOffsetInBytes < FieldOffsetInBytes) { |
| 145 | // Even with alignment, the field offset is not at the right place, |
| 146 | // insert padding. |
| 147 | uint64_t PaddingInBytes = FieldOffsetInBytes - NextFieldOffsetInBytes; |
| 148 | |
| 149 | AppendBytes(PaddingInBytes); |
| 150 | } |
Anders Carlsson | 45372a6 | 2009-07-23 03:17:50 +0000 | [diff] [blame] | 151 | |
Anders Carlsson | 45372a6 | 2009-07-23 03:17:50 +0000 | [diff] [blame] | 152 | // Now append the field. |
| 153 | LLVMFields.push_back(LLVMFieldInfo(D, FieldTypes.size())); |
Anders Carlsson | 728d7cd | 2009-07-24 02:45:50 +0000 | [diff] [blame] | 154 | AppendField(FieldOffsetInBytes, Ty); |
Anders Carlsson | 45372a6 | 2009-07-23 03:17:50 +0000 | [diff] [blame] | 155 | |
| 156 | return true; |
| 157 | } |
| 158 | |
Anders Carlsson | 5a6e398 | 2009-07-23 03:43:54 +0000 | [diff] [blame] | 159 | void CGRecordLayoutBuilder::LayoutUnion(const RecordDecl *D) { |
| 160 | assert(D->isUnion() && "Can't call LayoutUnion on a non-union record!"); |
| 161 | |
| 162 | const ASTRecordLayout &Layout = Types.getContext().getASTRecordLayout(D); |
| 163 | |
| 164 | const llvm::Type *Ty = 0; |
| 165 | uint64_t Size = 0; |
| 166 | unsigned Align = 0; |
| 167 | |
| 168 | unsigned FieldNo = 0; |
| 169 | for (RecordDecl::field_iterator Field = D->field_begin(), |
| 170 | FieldEnd = D->field_end(); Field != FieldEnd; ++Field, ++FieldNo) { |
| 171 | assert(Layout.getFieldOffset(FieldNo) == 0 && |
| 172 | "Union field offset did not start at the beginning of record!"); |
Anders Carlsson | 2cc8f17 | 2009-07-23 04:00:39 +0000 | [diff] [blame] | 173 | |
| 174 | if (Field->isBitField()) { |
| 175 | uint64_t FieldSize = |
| 176 | Field->getBitWidth()->EvaluateAsInt(Types.getContext()).getZExtValue(); |
| 177 | |
| 178 | // Ignore zero sized bit fields. |
| 179 | if (FieldSize == 0) |
| 180 | continue; |
Anders Carlsson | 94ae95f | 2009-07-23 22:52:34 +0000 | [diff] [blame] | 181 | |
| 182 | // Add the bit field info. |
| 183 | Types.addBitFieldInfo(*Field, 0, 0, FieldSize); |
| 184 | } else |
| 185 | Types.addFieldInfo(*Field, 0); |
Anders Carlsson | 5a6e398 | 2009-07-23 03:43:54 +0000 | [diff] [blame] | 186 | |
| 187 | const llvm::Type *FieldTy = |
| 188 | Types.ConvertTypeForMemRecursive(Field->getType()); |
Anders Carlsson | 177d4d8 | 2009-07-23 21:52:03 +0000 | [diff] [blame] | 189 | unsigned FieldAlign = Types.getTargetData().getABITypeAlignment(FieldTy); |
| 190 | uint64_t FieldSize = Types.getTargetData().getTypeAllocSize(FieldTy); |
Anders Carlsson | 5a6e398 | 2009-07-23 03:43:54 +0000 | [diff] [blame] | 191 | |
| 192 | if (FieldAlign < Align) |
| 193 | continue; |
| 194 | |
| 195 | if (FieldAlign > Align || FieldSize > Size) { |
| 196 | Ty = FieldTy; |
| 197 | Align = FieldAlign; |
| 198 | Size = FieldSize; |
| 199 | } |
| 200 | } |
| 201 | |
| 202 | // Now add our field. |
Anders Carlsson | 94ae95f | 2009-07-23 22:52:34 +0000 | [diff] [blame] | 203 | if (Ty) |
Anders Carlsson | 728d7cd | 2009-07-24 02:45:50 +0000 | [diff] [blame] | 204 | AppendField(0, Ty); |
Anders Carlsson | 5a6e398 | 2009-07-23 03:43:54 +0000 | [diff] [blame] | 205 | |
| 206 | // Append tail padding. |
| 207 | if (Layout.getSize() / 8 > Size) |
| 208 | AppendPadding(Layout.getSize() / 8, Align); |
| 209 | } |
| 210 | |
Anders Carlsson | 45372a6 | 2009-07-23 03:17:50 +0000 | [diff] [blame] | 211 | bool CGRecordLayoutBuilder::LayoutFields(const RecordDecl *D) { |
| 212 | assert(!D->isUnion() && "Can't call LayoutFields on a union!"); |
Anders Carlsson | a5dd722 | 2009-08-08 19:38:24 +0000 | [diff] [blame] | 213 | assert(Alignment && "Did not set alignment!"); |
Anders Carlsson | 45372a6 | 2009-07-23 03:17:50 +0000 | [diff] [blame] | 214 | |
Anders Carlsson | 5a6e398 | 2009-07-23 03:43:54 +0000 | [diff] [blame] | 215 | const ASTRecordLayout &Layout = Types.getContext().getASTRecordLayout(D); |
Anders Carlsson | 45372a6 | 2009-07-23 03:17:50 +0000 | [diff] [blame] | 216 | |
| 217 | unsigned FieldNo = 0; |
Fariborz Jahanian | cad8665 | 2009-07-27 20:57:45 +0000 | [diff] [blame] | 218 | |
Anders Carlsson | 45372a6 | 2009-07-23 03:17:50 +0000 | [diff] [blame] | 219 | for (RecordDecl::field_iterator Field = D->field_begin(), |
| 220 | FieldEnd = D->field_end(); Field != FieldEnd; ++Field, ++FieldNo) { |
| 221 | if (!LayoutField(*Field, Layout.getFieldOffset(FieldNo))) { |
Anders Carlsson | 4b5584b | 2009-07-23 17:24:40 +0000 | [diff] [blame] | 222 | assert(!Packed && |
Anders Carlsson | 45372a6 | 2009-07-23 03:17:50 +0000 | [diff] [blame] | 223 | "Could not layout fields even with a packed LLVM struct!"); |
| 224 | return false; |
| 225 | } |
| 226 | } |
| 227 | |
| 228 | // Append tail padding if necessary. |
Anders Carlsson | c1efe36 | 2009-07-27 14:55:54 +0000 | [diff] [blame] | 229 | AppendTailPadding(Layout.getSize()); |
Anders Carlsson | 45372a6 | 2009-07-23 03:17:50 +0000 | [diff] [blame] | 230 | |
| 231 | return true; |
| 232 | } |
| 233 | |
Anders Carlsson | c1efe36 | 2009-07-27 14:55:54 +0000 | [diff] [blame] | 234 | void CGRecordLayoutBuilder::AppendTailPadding(uint64_t RecordSize) { |
| 235 | assert(RecordSize % 8 == 0 && "Invalid record size!"); |
| 236 | |
| 237 | uint64_t RecordSizeInBytes = RecordSize / 8; |
Anders Carlsson | c2cc1d5 | 2009-07-28 17:56:36 +0000 | [diff] [blame] | 238 | assert(NextFieldOffsetInBytes <= RecordSizeInBytes && "Size mismatch!"); |
Anders Carlsson | c1efe36 | 2009-07-27 14:55:54 +0000 | [diff] [blame] | 239 | |
Anders Carlsson | c2cc1d5 | 2009-07-28 17:56:36 +0000 | [diff] [blame] | 240 | unsigned NumPadBytes = RecordSizeInBytes - NextFieldOffsetInBytes; |
Anders Carlsson | c1efe36 | 2009-07-27 14:55:54 +0000 | [diff] [blame] | 241 | AppendBytes(NumPadBytes); |
| 242 | } |
| 243 | |
Anders Carlsson | 45372a6 | 2009-07-23 03:17:50 +0000 | [diff] [blame] | 244 | void CGRecordLayoutBuilder::AppendField(uint64_t FieldOffsetInBytes, |
Anders Carlsson | 45372a6 | 2009-07-23 03:17:50 +0000 | [diff] [blame] | 245 | const llvm::Type *FieldTy) { |
| 246 | AlignmentAsLLVMStruct = std::max(AlignmentAsLLVMStruct, |
| 247 | getTypeAlignment(FieldTy)); |
Anders Carlsson | 728d7cd | 2009-07-24 02:45:50 +0000 | [diff] [blame] | 248 | |
| 249 | uint64_t FieldSizeInBytes = getTypeSizeInBytes(FieldTy); |
| 250 | |
Anders Carlsson | 45372a6 | 2009-07-23 03:17:50 +0000 | [diff] [blame] | 251 | FieldTypes.push_back(FieldTy); |
Anders Carlsson | 45372a6 | 2009-07-23 03:17:50 +0000 | [diff] [blame] | 252 | |
Anders Carlsson | c2cc1d5 | 2009-07-28 17:56:36 +0000 | [diff] [blame] | 253 | NextFieldOffsetInBytes = FieldOffsetInBytes + FieldSizeInBytes; |
Anders Carlsson | 45372a6 | 2009-07-23 03:17:50 +0000 | [diff] [blame] | 254 | BitsAvailableInLastField = 0; |
| 255 | } |
| 256 | |
| 257 | void |
| 258 | CGRecordLayoutBuilder::AppendPadding(uint64_t FieldOffsetInBytes, |
| 259 | const llvm::Type *FieldTy) { |
| 260 | AppendPadding(FieldOffsetInBytes, getTypeAlignment(FieldTy)); |
| 261 | } |
| 262 | |
| 263 | void CGRecordLayoutBuilder::AppendPadding(uint64_t FieldOffsetInBytes, |
| 264 | unsigned FieldAlignment) { |
Anders Carlsson | 45372a6 | 2009-07-23 03:17:50 +0000 | [diff] [blame] | 265 | assert(NextFieldOffsetInBytes <= FieldOffsetInBytes && |
| 266 | "Incorrect field layout!"); |
| 267 | |
| 268 | // Round up the field offset to the alignment of the field type. |
| 269 | uint64_t AlignedNextFieldOffsetInBytes = |
| 270 | llvm::RoundUpToAlignment(NextFieldOffsetInBytes, FieldAlignment); |
| 271 | |
| 272 | if (AlignedNextFieldOffsetInBytes < FieldOffsetInBytes) { |
| 273 | // Even with alignment, the field offset is not at the right place, |
| 274 | // insert padding. |
| 275 | uint64_t PaddingInBytes = FieldOffsetInBytes - NextFieldOffsetInBytes; |
| 276 | |
| 277 | AppendBytes(PaddingInBytes); |
| 278 | } |
| 279 | } |
| 280 | |
| 281 | void CGRecordLayoutBuilder::AppendBytes(uint64_t NumBytes) { |
| 282 | if (NumBytes == 0) |
| 283 | return; |
| 284 | |
| 285 | const llvm::Type *Ty = llvm::Type::Int8Ty; |
Anders Carlsson | c1efe36 | 2009-07-27 14:55:54 +0000 | [diff] [blame] | 286 | if (NumBytes > 1) |
Anders Carlsson | 45372a6 | 2009-07-23 03:17:50 +0000 | [diff] [blame] | 287 | Ty = llvm::ArrayType::get(Ty, NumBytes); |
Anders Carlsson | 45372a6 | 2009-07-23 03:17:50 +0000 | [diff] [blame] | 288 | |
| 289 | // Append the padding field |
Anders Carlsson | c2cc1d5 | 2009-07-28 17:56:36 +0000 | [diff] [blame] | 290 | AppendField(NextFieldOffsetInBytes, Ty); |
Anders Carlsson | 45372a6 | 2009-07-23 03:17:50 +0000 | [diff] [blame] | 291 | } |
| 292 | |
| 293 | unsigned CGRecordLayoutBuilder::getTypeAlignment(const llvm::Type *Ty) const { |
Anders Carlsson | 4b5584b | 2009-07-23 17:24:40 +0000 | [diff] [blame] | 294 | if (Packed) |
Anders Carlsson | 45372a6 | 2009-07-23 03:17:50 +0000 | [diff] [blame] | 295 | return 1; |
Anders Carlsson | 45372a6 | 2009-07-23 03:17:50 +0000 | [diff] [blame] | 296 | |
| 297 | return Types.getTargetData().getABITypeAlignment(Ty); |
| 298 | } |
| 299 | |
| 300 | uint64_t CGRecordLayoutBuilder::getTypeSizeInBytes(const llvm::Type *Ty) const { |
| 301 | return Types.getTargetData().getTypeAllocSize(Ty); |
| 302 | } |
| 303 | |
| 304 | CGRecordLayout * |
| 305 | CGRecordLayoutBuilder::ComputeLayout(CodeGenTypes &Types, |
| 306 | const RecordDecl *D) { |
| 307 | CGRecordLayoutBuilder Builder(Types); |
| 308 | |
Anders Carlsson | 45372a6 | 2009-07-23 03:17:50 +0000 | [diff] [blame] | 309 | Builder.Layout(D); |
Anders Carlsson | 4c98efd | 2009-07-24 15:20:52 +0000 | [diff] [blame] | 310 | |
Owen Anderson | 47a434f | 2009-08-05 23:18:46 +0000 | [diff] [blame] | 311 | const llvm::Type *Ty = llvm::StructType::get(Types.getLLVMContext(), |
| 312 | Builder.FieldTypes, |
Anders Carlsson | 4b5584b | 2009-07-23 17:24:40 +0000 | [diff] [blame] | 313 | Builder.Packed); |
Anders Carlsson | df31e09 | 2009-08-08 18:01:57 +0000 | [diff] [blame] | 314 | assert(Types.getContext().getASTRecordLayout(D).getSize() / 8 == |
| 315 | Types.getTargetData().getTypeAllocSize(Ty) && |
| 316 | "Type size mismatch!"); |
Anders Carlsson | 45372a6 | 2009-07-23 03:17:50 +0000 | [diff] [blame] | 317 | |
| 318 | // Add all the field numbers. |
| 319 | for (unsigned i = 0, e = Builder.LLVMFields.size(); i != e; ++i) { |
| 320 | const FieldDecl *FD = Builder.LLVMFields[i].first; |
| 321 | unsigned FieldNo = Builder.LLVMFields[i].second; |
| 322 | |
| 323 | Types.addFieldInfo(FD, FieldNo); |
| 324 | } |
| 325 | |
| 326 | // Add bitfield info. |
| 327 | for (unsigned i = 0, e = Builder.LLVMBitFields.size(); i != e; ++i) { |
| 328 | const LLVMBitFieldInfo &Info = Builder.LLVMBitFields[i]; |
| 329 | |
Anders Carlsson | 8330cee | 2009-07-23 17:01:21 +0000 | [diff] [blame] | 330 | Types.addBitFieldInfo(Info.FD, Info.FieldNo, Info.Start, Info.Size); |
Anders Carlsson | 45372a6 | 2009-07-23 03:17:50 +0000 | [diff] [blame] | 331 | } |
| 332 | |
| 333 | return new CGRecordLayout(Ty, llvm::SmallSet<unsigned, 8>()); |
| 334 | } |