Changes in directory llvm/lib/CodeGen:
DwarfWriter.cpp updated: 1.44 -> 1.45 MachineDebugInfo.cpp updated: 1.27 -> 1.28 --- Log message: Move bit field endianness to backend. --- Diffs of the changes: (+29 -10) DwarfWriter.cpp | 36 ++++++++++++++++++++++++++---------- MachineDebugInfo.cpp | 3 +++ 2 files changed, 29 insertions(+), 10 deletions(-) Index: llvm/lib/CodeGen/DwarfWriter.cpp diff -u llvm/lib/CodeGen/DwarfWriter.cpp:1.44 llvm/lib/CodeGen/DwarfWriter.cpp:1.45 --- llvm/lib/CodeGen/DwarfWriter.cpp:1.44 Wed Mar 8 12:11:06 2006 +++ llvm/lib/CodeGen/DwarfWriter.cpp Thu Mar 9 07:28:47 2006 @@ -1323,6 +1323,7 @@ unsigned Line = MemberDesc->getLine(); TypeDesc *MemTy = MemberDesc->getFromType(); uint64_t Size = MemberDesc->getSize(); + uint64_t Align = MemberDesc->getAlign(); uint64_t Offset = MemberDesc->getOffset(); // Construct member die. @@ -1338,27 +1339,42 @@ Member->AddUInt(DW_AT_decl_line, 0, Line); } - // FIXME - Bitfields not quite right but getting there. - uint64_t ByteSize = Size; - uint64_t ByteOffset = Offset; + // Most of the time the field info is the same as the members. + uint64_t FieldSize = Size; + uint64_t FieldAlign = Align; + uint64_t FieldOffset = Offset; if (TypeDesc *FromTy = MemberDesc->getFromType()) { Member->AddDIEntry(DW_AT_type, DW_FORM_ref4, NewType(Context, FromTy)); - ByteSize = FromTy->getSize(); + FieldSize = FromTy->getSize(); + FieldAlign = FromTy->getSize(); } - if (ByteSize != Size) { - ByteOffset -= Offset % ByteSize; - Member->AddUInt(DW_AT_byte_size, 0, ByteSize >> 3); - Member->AddUInt(DW_AT_bit_size, 0, Size % ByteSize); - Member->AddUInt(DW_AT_bit_offset, 0, Offset - ByteOffset); + // Unless we have a bit field. + if (FieldSize != Size) { + // Construct the alignment mask. + uint64_t AlignMask = ~(FieldAlign - 1); + // Determine the high bit + 1 of the declared size. + uint64_t HiMark = (Offset + FieldSize) & AlignMask; + // Work backwards to determine the base offset of the field. + FieldOffset = HiMark - FieldSize; + // Now normalize offset to the field. + Offset -= FieldOffset; + + // Maybe we need to work from the other. + const TargetData &TD = Asm->TM.getTargetData(); + if (TD.isLittleEndian()) Offset = FieldSize - (Offset + Size); + + Member->AddUInt(DW_AT_byte_size, 0, FieldSize >> 3); + Member->AddUInt(DW_AT_bit_size, 0, Size); + Member->AddUInt(DW_AT_bit_offset, 0, Offset); } // Add computation for offset. DIEBlock *Block = new DIEBlock(); Block->AddUInt(DW_FORM_data1, DW_OP_plus_uconst); - Block->AddUInt(DW_FORM_udata, ByteOffset >> 3); + Block->AddUInt(DW_FORM_udata, FieldOffset >> 3); Block->ComputeSize(*this); Member->AddBlock(DW_AT_data_member_location, 0, Block); Index: llvm/lib/CodeGen/MachineDebugInfo.cpp diff -u llvm/lib/CodeGen/MachineDebugInfo.cpp:1.27 llvm/lib/CodeGen/MachineDebugInfo.cpp:1.28 --- llvm/lib/CodeGen/MachineDebugInfo.cpp:1.27 Wed Mar 8 12:11:06 2006 +++ llvm/lib/CodeGen/MachineDebugInfo.cpp Thu Mar 9 07:28:47 2006 @@ -653,6 +653,7 @@ , Name("") , File(NULL) , Size(0) +, Align(0) , Offset(0) {} @@ -666,6 +667,7 @@ Visitor->Apply((DebugInfoDesc *&)File); Visitor->Apply(Line); Visitor->Apply(Size); + Visitor->Apply(Align); Visitor->Apply(Offset); } @@ -690,6 +692,7 @@ << "File(" << File << "), " << "Line(" << Line << "), " << "Size(" << Size << "), " + << "Align(" << Align << "), " << "Offset(" << Offset << ")\n"; } #endif _______________________________________________ llvm-commits mailing list llvm-commits@cs.uiuc.edu http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits