summaryrefslogtreecommitdiffstats
path: root/llvm/lib/CodeGen/AsmPrinter.cpp
diff options
context:
space:
mode:
authorDuncan Sands <baldrick@free.fr>2008-06-04 08:21:45 +0000
committerDuncan Sands <baldrick@free.fr>2008-06-04 08:21:45 +0000
commitfc3c489b526087a413da674d73ddea3bffb65e7c (patch)
tree443f58f1e511d8aa3d0a7ded9e5ac885163bfd5b /llvm/lib/CodeGen/AsmPrinter.cpp
parent6449690da46eec29daa54848bc4a003c241f640a (diff)
downloadbcm5719-llvm-fc3c489b526087a413da674d73ddea3bffb65e7c.tar.gz
bcm5719-llvm-fc3c489b526087a413da674d73ddea3bffb65e7c.zip
Change packed struct layout so that field sizes
are the same as in unpacked structs, only field positions differ. This only matters for structs containing x86 long double or an apint; it may cause backwards compatibility problems if someone has bitcode containing a packed struct with a field of one of those types. The issue is that only 10 bytes are needed to hold an x86 long double: the store size is 10 bytes, but the ABI size is 12 or 16 bytes (linux/ darwin) which comes from rounding the store size up by the alignment. Because it seemed silly not to pack an x86 long double into 10 bytes in a packed struct, this is what was done. I now think this was a mistake. Reserving the ABI size for an x86 long double field even in a packed struct makes things more uniform: the ABI size is now always used when reserving space for a type. This means that developers are less likely to make mistakes. It also makes life easier for the CBE which otherwise could not represent all LLVM packed structs (PR2402). Front-end people might need to adjust the way they create LLVM structs - see following change to llvm-gcc. llvm-svn: 51928
Diffstat (limited to 'llvm/lib/CodeGen/AsmPrinter.cpp')
-rw-r--r--llvm/lib/CodeGen/AsmPrinter.cpp16
1 files changed, 7 insertions, 9 deletions
diff --git a/llvm/lib/CodeGen/AsmPrinter.cpp b/llvm/lib/CodeGen/AsmPrinter.cpp
index 3265a99c05d..4ac8026a1b2 100644
--- a/llvm/lib/CodeGen/AsmPrinter.cpp
+++ b/llvm/lib/CodeGen/AsmPrinter.cpp
@@ -889,11 +889,9 @@ void AsmPrinter::EmitString(const ConstantArray *CVA) const {
}
/// EmitGlobalConstant - Print a general LLVM constant to the .s file.
-/// If Packed is false, pad to the ABI size.
-void AsmPrinter::EmitGlobalConstant(const Constant *CV, bool Packed) {
+void AsmPrinter::EmitGlobalConstant(const Constant *CV) {
const TargetData *TD = TM.getTargetData();
- unsigned Size = Packed ?
- TD->getTypeStoreSize(CV->getType()) : TD->getABITypeSize(CV->getType());
+ unsigned Size = TD->getABITypeSize(CV->getType());
if (CV->isNullValue() || isa<UndefValue>(CV)) {
EmitZeros(Size);
@@ -903,7 +901,7 @@ void AsmPrinter::EmitGlobalConstant(const Constant *CV, bool Packed) {
EmitString(CVA);
} else { // Not a string. Print the values in successive locations
for (unsigned i = 0, e = CVA->getNumOperands(); i != e; ++i)
- EmitGlobalConstant(CVA->getOperand(i), false);
+ EmitGlobalConstant(CVA->getOperand(i));
}
return;
} else if (const ConstantStruct *CVS = dyn_cast<ConstantStruct>(CV)) {
@@ -914,13 +912,13 @@ void AsmPrinter::EmitGlobalConstant(const Constant *CV, bool Packed) {
const Constant* field = CVS->getOperand(i);
// Check if padding is needed and insert one or more 0s.
- uint64_t fieldSize = TD->getTypeStoreSize(field->getType());
+ uint64_t fieldSize = TD->getABITypeSize(field->getType());
uint64_t padSize = ((i == e-1 ? Size : cvsLayout->getElementOffset(i+1))
- cvsLayout->getElementOffset(i)) - fieldSize;
sizeSoFar += fieldSize + padSize;
- // Now print the actual field value without ABI size padding.
- EmitGlobalConstant(field, true);
+ // Now print the actual field value.
+ EmitGlobalConstant(field);
// Insert padding - this may include padding to increase the size of the
// current field up to the ABI size (if the struct is not packed) as well
@@ -1066,7 +1064,7 @@ void AsmPrinter::EmitGlobalConstant(const Constant *CV, bool Packed) {
const VectorType *PTy = CP->getType();
for (unsigned I = 0, E = PTy->getNumElements(); I < E; ++I)
- EmitGlobalConstant(CP->getOperand(I), false);
+ EmitGlobalConstant(CP->getOperand(I));
return;
}
OpenPOWER on IntegriCloud