the apple "ld_classic" linker doesn't support .literal16 in 32-bit

mode, and "ld64" (the default linker) falls back to it in -static
mode.

llvm-svn: 77334
This commit is contained in:
Chris Lattner 2009-07-28 17:50:28 +00:00
parent 5142fbd02e
commit a3242e93b7
5 changed files with 16 additions and 9 deletions

View File

@ -160,7 +160,7 @@ class TargetLoweringObjectFileMachO : public TargetLoweringObjectFile {
const Section *EightByteConstantSection; const Section *EightByteConstantSection;
const Section *SixteenByteConstantSection; const Section *SixteenByteConstantSection;
public: public:
TargetLoweringObjectFileMachO(); TargetLoweringObjectFileMachO(const TargetMachine &TM);
virtual const Section *SelectSectionForGlobal(const GlobalValue *GV, virtual const Section *SelectSectionForGlobal(const GlobalValue *GV,
SectionKind Kind, SectionKind Kind,
const TargetMachine &TM) const; const TargetMachine &TM) const;

View File

@ -106,7 +106,7 @@ void ARMTargetLowering::addQRTypeForNEON(MVT VT) {
static TargetLoweringObjectFile *createTLOF(TargetMachine &TM) { static TargetLoweringObjectFile *createTLOF(TargetMachine &TM) {
if (TM.getSubtarget<ARMSubtarget>().isTargetDarwin()) if (TM.getSubtarget<ARMSubtarget>().isTargetDarwin())
return new TargetLoweringObjectFileMachO(); return new TargetLoweringObjectFileMachO(TM);
return new TargetLoweringObjectFileELF(true); return new TargetLoweringObjectFileELF(true);
} }

View File

@ -59,7 +59,7 @@ cl::desc("enable preincrement load/store generation on PPC (experimental)"),
static TargetLoweringObjectFile *CreateTLOF(const PPCTargetMachine &TM) { static TargetLoweringObjectFile *CreateTLOF(const PPCTargetMachine &TM) {
if (TM.getSubtargetImpl()->isDarwin()) if (TM.getSubtargetImpl()->isDarwin())
return new TargetLoweringObjectFileMachO(); return new TargetLoweringObjectFileMachO(TM);
return new TargetLoweringObjectFileELF(false, true); return new TargetLoweringObjectFileELF(false, true);
} }

View File

@ -486,7 +486,7 @@ getSectionForMergeableConstant(SectionKind Kind) const {
//===----------------------------------------------------------------------===// //===----------------------------------------------------------------------===//
TargetLoweringObjectFileMachO:: TargetLoweringObjectFileMachO::
TargetLoweringObjectFileMachO() { TargetLoweringObjectFileMachO(const TargetMachine &TM) {
TextSection = getOrCreateSection("\t.text", true, SectionKind::Text); TextSection = getOrCreateSection("\t.text", true, SectionKind::Text);
DataSection = getOrCreateSection("\t.data", true, SectionKind::DataRel); DataSection = getOrCreateSection("\t.data", true, SectionKind::DataRel);
@ -496,8 +496,15 @@ TargetLoweringObjectFileMachO() {
SectionKind::MergeableConst4); SectionKind::MergeableConst4);
EightByteConstantSection = getOrCreateSection("\t.literal8\n", true, EightByteConstantSection = getOrCreateSection("\t.literal8\n", true,
SectionKind::MergeableConst8); SectionKind::MergeableConst8);
SixteenByteConstantSection =
getOrCreateSection("\t.literal16\n", true, SectionKind::MergeableConst16); // ld_classic doesn't support .literal16 in 32-bit mode, and ld64 falls back
// to using it in -static mode.
if (TM.getRelocationModel() != Reloc::Static &&
TM.getTargetData()->getPointerSize() == 32)
SixteenByteConstantSection =
getOrCreateSection("\t.literal16\n", true, SectionKind::MergeableConst16);
else
SixteenByteConstantSection = 0;
ReadOnlySection = getOrCreateSection("\t.const", true, SectionKind::ReadOnly); ReadOnlySection = getOrCreateSection("\t.const", true, SectionKind::ReadOnly);
@ -551,7 +558,7 @@ TargetLoweringObjectFileMachO::SelectSectionForGlobal(const GlobalValue *GV,
return FourByteConstantSection; return FourByteConstantSection;
if (Kind.isMergeableConst8()) if (Kind.isMergeableConst8())
return EightByteConstantSection; return EightByteConstantSection;
if (Kind.isMergeableConst16()) if (Kind.isMergeableConst16() && SixteenByteConstantSection)
return SixteenByteConstantSection; return SixteenByteConstantSection;
return ReadOnlySection; // .const return ReadOnlySection; // .const
} }
@ -582,7 +589,7 @@ getSectionForMergeableConstant(SectionKind Kind) const {
return FourByteConstantSection; return FourByteConstantSection;
if (Kind.isMergeableConst8()) if (Kind.isMergeableConst8())
return EightByteConstantSection; return EightByteConstantSection;
if (Kind.isMergeableConst16()) if (Kind.isMergeableConst16() && SixteenByteConstantSection)
return SixteenByteConstantSection; return SixteenByteConstantSection;
return ReadOnlySection; // .const return ReadOnlySection; // .const
} }

View File

@ -55,7 +55,7 @@ static TargetLoweringObjectFile *createTLOF(X86TargetMachine &TM) {
switch (TM.getSubtarget<X86Subtarget>().TargetType) { switch (TM.getSubtarget<X86Subtarget>().TargetType) {
default: llvm_unreachable("unknown subtarget type"); default: llvm_unreachable("unknown subtarget type");
case X86Subtarget::isDarwin: case X86Subtarget::isDarwin:
return new TargetLoweringObjectFileMachO(); return new TargetLoweringObjectFileMachO(TM);
case X86Subtarget::isELF: case X86Subtarget::isELF:
return new TargetLoweringObjectFileELF(); return new TargetLoweringObjectFileELF();
case X86Subtarget::isMingw: case X86Subtarget::isMingw: