diff options
author | Anders Carlsson <andersca@mac.com> | 2009-07-23 17:01:21 +0000 |
---|---|---|
committer | Anders Carlsson <andersca@mac.com> | 2009-07-23 17:01:21 +0000 |
commit | 8330ceeebb3bfac31116b387b90ff2ce3cef85e4 (patch) | |
tree | 35042c9a783cc668d2dab4fa0e9166736d50acf5 /lib/CodeGen/CGExprConstant.cpp | |
parent | bd1099efde211cbb63fce3feee4ebcc6bac58781 (diff) |
Move the LLVM field number for bit fields into the BitFieldInfo structure, since it's meaning is completely different than for non-bit fields.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@76882 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/CodeGen/CGExprConstant.cpp')
-rw-r--r-- | lib/CodeGen/CGExprConstant.cpp | 20 |
1 files changed, 10 insertions, 10 deletions
diff --git a/lib/CodeGen/CGExprConstant.cpp b/lib/CodeGen/CGExprConstant.cpp index 43284b5173..61b217bc66 100644 --- a/lib/CodeGen/CGExprConstant.cpp +++ b/lib/CodeGen/CGExprConstant.cpp @@ -139,16 +139,16 @@ public: const llvm::Type* Ty = CI->getType(); const llvm::TargetData &TD = CGM.getTypes().getTargetData(); unsigned size = TD.getTypeAllocSizeInBits(Ty); - unsigned fieldOffset = CGM.getTypes().getLLVMFieldNo(Field) * size; - CodeGenTypes::BitFieldInfo bitFieldInfo = - CGM.getTypes().getBitFieldInfo(Field); - fieldOffset += bitFieldInfo.Begin; + CodeGenTypes::BitFieldInfo Info = CGM.getTypes().getBitFieldInfo(Field); + unsigned FieldOffset = Info.FieldNo * size; + + FieldOffset += Info.Start; // Find where to start the insertion // FIXME: This is O(n^2) in the number of bit-fields! // FIXME: This won't work if the struct isn't completely packed! unsigned offset = 0, i = 0; - while (offset < (fieldOffset & -8)) + while (offset < (FieldOffset & -8)) offset += TD.getTypeAllocSizeInBits(Elts[i++]->getType()); // Advance over 0 sized elements (must terminate in bounds since @@ -160,15 +160,15 @@ public: // FIXME: This should never occur, but currently it can because initializer // constants are cast to bool, and because clang is not enforcing bitfield // width limits. - if (bitFieldInfo.Size > V.getBitWidth()) - V.zext(bitFieldInfo.Size); + if (Info.Size > V.getBitWidth()) + V.zext(Info.Size); // Insert the bits into the struct // FIXME: This algorthm is only correct on X86! // FIXME: THis algorthm assumes bit-fields only have byte-size elements! - unsigned bitsToInsert = bitFieldInfo.Size; - unsigned curBits = std::min(8 - (fieldOffset & 7), bitsToInsert); - unsigned byte = V.getLoBits(curBits).getZExtValue() << (fieldOffset & 7); + unsigned bitsToInsert = Info.Size; + unsigned curBits = std::min(8 - (FieldOffset & 7), bitsToInsert); + unsigned byte = V.getLoBits(curBits).getZExtValue() << (FieldOffset & 7); do { llvm::Constant* byteC = VMContext.getConstantInt(llvm::Type::Int8Ty, byte); |