diff options
| author | Evan Cheng <evan.cheng@apple.com> | 2007-03-08 01:25:25 +0000 |
|---|---|---|
| committer | Evan Cheng <evan.cheng@apple.com> | 2007-03-08 01:25:25 +0000 |
| commit | d918477ac388430c9ca49c3d158092c886822cab (patch) | |
| tree | 1a9196f20c26d893bd851f5b18488b1f5f96862f /llvm/lib/Target | |
| parent | 13a1d969633776d7724d4ed98fbe9164dea72474 (diff) | |
| download | bcm5719-llvm-d918477ac388430c9ca49c3d158092c886822cab.tar.gz bcm5719-llvm-d918477ac388430c9ca49c3d158092c886822cab.zip | |
For Darwin, put constant data into .const, .const_data, .literal{4|8|16}
sections.
llvm-svn: 35017
Diffstat (limited to 'llvm/lib/Target')
| -rw-r--r-- | llvm/lib/Target/ARM/ARMAsmPrinter.cpp | 25 | ||||
| -rw-r--r-- | llvm/lib/Target/ARM/ARMTargetAsmInfo.cpp | 3 | ||||
| -rw-r--r-- | llvm/lib/Target/PowerPC/PPCAsmPrinter.cpp | 26 | ||||
| -rw-r--r-- | llvm/lib/Target/PowerPC/PPCTargetAsmInfo.cpp | 3 |
4 files changed, 53 insertions, 4 deletions
diff --git a/llvm/lib/Target/ARM/ARMAsmPrinter.cpp b/llvm/lib/Target/ARM/ARMAsmPrinter.cpp index 4654ef4d3e1..fc65144f57e 100644 --- a/llvm/lib/Target/ARM/ARMAsmPrinter.cpp +++ b/llvm/lib/Target/ARM/ARMAsmPrinter.cpp @@ -743,7 +743,8 @@ bool ARMAsmPrinter::doFinalization(Module &M) { std::string name = Mang->getValueName(I); 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 (I->hasHiddenVisibility()) @@ -829,8 +830,28 @@ bool ARMAsmPrinter::doFinalization(Module &M) { } else { if (C->isNullValue() && !NoZerosInBSS && TAI->getBSSSection()) SwitchToDataSection(TAI->getBSSSection(), I); - else + else if (!I->isConstant()) SwitchToDataSection(TAI->getDataSection(), I); + else { + // Read-only data. + bool isIntFPLiteral = Type->isInteger() || Type->isFloatingPoint(); + if (C->ContainsRelocations() && Subtarget->isTargetDarwin() && + 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; diff --git a/llvm/lib/Target/ARM/ARMTargetAsmInfo.cpp b/llvm/lib/Target/ARM/ARMTargetAsmInfo.cpp index ff6de2eee40..dfb78e8db9a 100644 --- a/llvm/lib/Target/ARM/ARMTargetAsmInfo.cpp +++ b/llvm/lib/Target/ARM/ARMTargetAsmInfo.cpp @@ -27,6 +27,9 @@ ARMTargetAsmInfo::ARMTargetAsmInfo(const ARMTargetMachine &TM) { HiddenDirective = "\t.private_extern\t"; JumpTableDataSection = ".const"; CStringSection = "\t.cstring"; + FourByteConstantSection = "\t.literal4\n"; + EightByteConstantSection = "\t.literal8\n"; + ReadOnlySection = "\t.const\n"; HasDotTypeDotSizeDirective = false; if (TM.getRelocationModel() == Reloc::Static) { StaticCtorsSection = ".constructor"; diff --git a/llvm/lib/Target/PowerPC/PPCAsmPrinter.cpp b/llvm/lib/Target/PowerPC/PPCAsmPrinter.cpp index f6b5d483e36..e16303e888d 100644 --- a/llvm/lib/Target/PowerPC/PPCAsmPrinter.cpp +++ b/llvm/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!"; diff --git a/llvm/lib/Target/PowerPC/PPCTargetAsmInfo.cpp b/llvm/lib/Target/PowerPC/PPCTargetAsmInfo.cpp index bdda9909f4a..01c78b71efa 100644 --- a/llvm/lib/Target/PowerPC/PPCTargetAsmInfo.cpp +++ b/llvm/lib/Target/PowerPC/PPCTargetAsmInfo.cpp @@ -57,6 +57,9 @@ DarwinTargetAsmInfo::DarwinTargetAsmInfo(const PPCTargetMachine &TM) JumpTableDataSection = ".const"; GlobalDirective = "\t.globl\t"; CStringSection = "\t.cstring"; + FourByteConstantSection = "\t.literal4\n"; + EightByteConstantSection = "\t.literal8\n"; + ReadOnlySection = "\t.const\n"; if (TM.getRelocationModel() == Reloc::Static) { StaticCtorsSection = ".constructor"; StaticDtorsSection = ".destructor"; |

