aboutsummaryrefslogtreecommitdiff
path: root/lib/Target/PowerPC/PPCAsmPrinter.cpp
diff options
context:
space:
mode:
authorEvan Cheng <evan.cheng@apple.com>2007-03-08 01:25:25 +0000
committerEvan Cheng <evan.cheng@apple.com>2007-03-08 01:25:25 +0000
commit98ded765c2dc2f256e9f11502ca302f2b24f31e8 (patch)
treec66d73fc887d307117a58f5795f960fca4c0e2c2 /lib/Target/PowerPC/PPCAsmPrinter.cpp
parentf0b5d56efdb4f130c8abe7ac2732a3ff9a66e455 (diff)
For Darwin, put constant data into .const, .const_data, .literal{4|8|16}
sections. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@35017 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Target/PowerPC/PPCAsmPrinter.cpp')
-rw-r--r--lib/Target/PowerPC/PPCAsmPrinter.cpp26
1 files changed, 24 insertions, 2 deletions
diff --git a/lib/Target/PowerPC/PPCAsmPrinter.cpp b/lib/Target/PowerPC/PPCAsmPrinter.cpp
index f6b5d483e3..e16303e888 100644
--- a/lib/Target/PowerPC/PPCAsmPrinter.cpp
+++ b/lib/Target/PowerPC/PPCAsmPrinter.cpp
@@ -893,7 +893,8 @@ bool DarwinAsmPrinter::doFinalization(Module &M) {
O << Directive << name << "\n";
Constant *C = I->getInitializer();
- unsigned Size = TD->getTypeSize(C->getType());
+ const Type *Type = C->getType();
+ unsigned Size = TD->getTypeSize(Type);
unsigned Align = TD->getPreferredAlignmentLog(I);
if (C->isNullValue() && /* FIXME: Verify correct */
@@ -937,7 +938,28 @@ bool DarwinAsmPrinter::doFinalization(Module &M) {
}
}
- SwitchToDataSection("\t.data", I);
+ if (!I->isConstant())
+ SwitchToDataSection(TAI->getDataSection(), I);
+ else {
+ // Read-only data.
+ bool isIntFPLiteral = Type->isInteger() || Type->isFloatingPoint();
+ if (C->ContainsRelocations() &&
+ TM.getRelocationModel() != Reloc::Static)
+ SwitchToDataSection("\t.const_data\n");
+ else if (isIntFPLiteral && Size == 4 &&
+ TAI->getFourByteConstantSection())
+ SwitchToDataSection(TAI->getFourByteConstantSection(), I);
+ else if (isIntFPLiteral && Size == 8 &&
+ TAI->getEightByteConstantSection())
+ SwitchToDataSection(TAI->getEightByteConstantSection(), I);
+ else if (isIntFPLiteral && Size == 16 &&
+ TAI->getSixteenByteConstantSection())
+ SwitchToDataSection(TAI->getSixteenByteConstantSection(), I);
+ else if (TAI->getReadOnlySection())
+ SwitchToDataSection(TAI->getReadOnlySection(), I);
+ else
+ SwitchToDataSection(TAI->getDataSection(), I);
+ }
break;
default:
cerr << "Unknown linkage type!";