summaryrefslogtreecommitdiffstats
path: root/llvm/lib
diff options
context:
space:
mode:
authorChris Lattner <sabre@nondot.org>2009-08-01 23:46:12 +0000
committerChris Lattner <sabre@nondot.org>2009-08-01 23:46:12 +0000
commit0c40266b5a7a58774a2f33128b68d45ee1801920 (patch)
treec41d72b1ac2817e6b48458630d1468a03482cd9b /llvm/lib
parentcc71620c866ad7b5bc7c451704e04374c68ef963 (diff)
downloadbcm5719-llvm-0c40266b5a7a58774a2f33128b68d45ee1801920.tar.gz
bcm5719-llvm-0c40266b5a7a58774a2f33128b68d45ee1801920.zip
Remove "JumpTableDataSection" from TAI, instead, have AsmPrinter
compute it based on what it knows. As part of this, rename getSectionForMergeableConstant to getSectionForConstant because it works for non-mergable constants also. The only functionality change from this is that Xcore will start dropping its jump tables into readonly section instead of data section in -static mode. This should be fine as the linker resolves the relocations. If this is a problem, let me know and we'll come up with another solution. llvm-svn: 77833
Diffstat (limited to 'llvm/lib')
-rw-r--r--llvm/lib/CodeGen/AsmPrinter/AsmPrinter.cpp20
-rw-r--r--llvm/lib/CodeGen/ELFWriter.cpp10
-rw-r--r--llvm/lib/Target/DarwinTargetAsmInfo.cpp2
-rw-r--r--llvm/lib/Target/TargetAsmInfo.cpp1
-rw-r--r--llvm/lib/Target/TargetLoweringObjectFile.cpp12
-rw-r--r--llvm/lib/Target/X86/X86TargetAsmInfo.cpp1
-rw-r--r--llvm/lib/Target/XCore/XCoreTargetAsmInfo.cpp2
7 files changed, 23 insertions, 25 deletions
diff --git a/llvm/lib/CodeGen/AsmPrinter/AsmPrinter.cpp b/llvm/lib/CodeGen/AsmPrinter/AsmPrinter.cpp
index 7c9fcf5fd60..f9839ddc68c 100644
--- a/llvm/lib/CodeGen/AsmPrinter/AsmPrinter.cpp
+++ b/llvm/lib/CodeGen/AsmPrinter/AsmPrinter.cpp
@@ -349,8 +349,7 @@ void AsmPrinter::EmitConstantPool(MachineConstantPool *MCP) {
}
}
- const MCSection *S =
- getObjFileLowering().getSectionForMergeableConstant(Kind);
+ const MCSection *S = getObjFileLowering().getSectionForConstant(Kind);
// The number of sections are small, just do a linear search from the
// last section to the first.
@@ -419,22 +418,21 @@ void AsmPrinter::EmitJumpTableInfo(MachineJumpTableInfo *MJTI,
// the appropriate section.
TargetLowering *LoweringInfo = TM.getTargetLowering();
- const char *JumpTableDataSection = TAI->getJumpTableDataSection();
const Function *F = MF.getFunction();
-
- const MCSection *FuncSection =
- getObjFileLowering().SectionForGlobal(F, Mang, TM);
-
bool JTInDiffSection = false;
- if ((IsPic && !LoweringInfo->usesGlobalOffsetTable()) ||
- !JumpTableDataSection || F->isWeakForLinker()) {
+ if (F->isWeakForLinker() ||
+ (IsPic && !LoweringInfo->usesGlobalOffsetTable())) {
// In PIC mode, we need to emit the jump table to the same section as the
// function body itself, otherwise the label differences won't make sense.
// We should also do if the section name is NULL or function is declared in
// discardable section.
- SwitchToSection(FuncSection);
+ SwitchToSection(getObjFileLowering().SectionForGlobal(F, Mang, TM));
} else {
- SwitchToDataSection(JumpTableDataSection);
+ // Otherwise, drop it in the readonly section.
+ const MCSection *ReadOnlySection =
+ getObjFileLowering().getSectionForConstant(
+ SectionKind::get(SectionKind::ReadOnly));
+ SwitchToSection(ReadOnlySection);
JTInDiffSection = true;
}
diff --git a/llvm/lib/CodeGen/ELFWriter.cpp b/llvm/lib/CodeGen/ELFWriter.cpp
index 1d33c7e1fef..be1e6bfe751 100644
--- a/llvm/lib/CodeGen/ELFWriter.cpp
+++ b/llvm/lib/CodeGen/ELFWriter.cpp
@@ -178,7 +178,13 @@ void ELFWriter::addExternalSymbol(const char *External) {
// Get jump table section on the section name returned by TAI
ELFSection &ELFWriter::getJumpTableSection() {
unsigned Align = TM.getTargetData()->getPointerABIAlignment();
- return getSection(TAI->getJumpTableDataSection(),
+
+ const TargetLoweringObjectFile &TLOF =
+ TM.getTargetLowering()->getObjFileLowering();
+
+ return getSection(TLOF.getSectionForConstant(
+ SectionKind::get(SectionKind::ReadOnly))
+ ->getName(),
ELFSection::SHT_PROGBITS,
ELFSection::SHF_ALLOC, Align);
}
@@ -204,7 +210,7 @@ ELFSection &ELFWriter::getConstantPoolSection(MachineConstantPoolEntry &CPE) {
const TargetLoweringObjectFile &TLOF =
TM.getTargetLowering()->getObjFileLowering();
- return getSection(TLOF.getSectionForMergeableConstant(Kind)->getName(),
+ return getSection(TLOF.getSectionForConstant(Kind)->getName(),
ELFSection::SHT_PROGBITS,
ELFSection::SHF_MERGE | ELFSection::SHF_ALLOC,
CPE.getAlignment());
diff --git a/llvm/lib/Target/DarwinTargetAsmInfo.cpp b/llvm/lib/Target/DarwinTargetAsmInfo.cpp
index 7000b4f023c..cca12c01cb0 100644
--- a/llvm/lib/Target/DarwinTargetAsmInfo.cpp
+++ b/llvm/lib/Target/DarwinTargetAsmInfo.cpp
@@ -49,8 +49,6 @@ DarwinTargetAsmInfo::DarwinTargetAsmInfo(const TargetMachine &TM)
HiddenDirective = "\t.private_extern ";
// Sections:
- JumpTableDataSection = "\t.const";
-
if (TM.getRelocationModel() == Reloc::Static) {
StaticCtorsSection = ".constructor";
StaticDtorsSection = ".destructor";
diff --git a/llvm/lib/Target/TargetAsmInfo.cpp b/llvm/lib/Target/TargetAsmInfo.cpp
index 1fb65632959..add1dbf5c37 100644
--- a/llvm/lib/Target/TargetAsmInfo.cpp
+++ b/llvm/lib/Target/TargetAsmInfo.cpp
@@ -69,7 +69,6 @@ TargetAsmInfo::TargetAsmInfo(const TargetMachine &tm) : TM(tm) {
TextSectionStartSuffix = "";
DataSectionStartSuffix = "";
SectionEndDirectiveSuffix = 0;
- JumpTableDataSection = "\t.section .rodata";
JumpTableDirective = 0;
// FIXME: Flags are ELFish - replace with normal section stuff.
StaticCtorsSection = "\t.section .ctors,\"aw\",@progbits";
diff --git a/llvm/lib/Target/TargetLoweringObjectFile.cpp b/llvm/lib/Target/TargetLoweringObjectFile.cpp
index 84247790f45..7eb9a4a4ebf 100644
--- a/llvm/lib/Target/TargetLoweringObjectFile.cpp
+++ b/llvm/lib/Target/TargetLoweringObjectFile.cpp
@@ -228,12 +228,11 @@ TargetLoweringObjectFile::SelectSectionForGlobal(const GlobalValue *GV,
return getDataSection();
}
-/// getSectionForMergableConstant - Given a mergable constant with the
+/// getSectionForConstant - Given a mergable constant with the
/// specified size and relocation information, return a section that it
/// should be placed in.
const MCSection *
-TargetLoweringObjectFile::
-getSectionForMergeableConstant(SectionKind Kind) const {
+TargetLoweringObjectFile::getSectionForConstant(SectionKind Kind) const {
if (Kind.isReadOnly() && ReadOnlySection != 0)
return ReadOnlySection;
@@ -459,11 +458,11 @@ SelectSectionForGlobal(const GlobalValue *GV, SectionKind Kind,
return DataRelROSection;
}
-/// getSectionForMergeableConstant - Given a mergeable constant with the
+/// getSectionForConstant - Given a mergeable constant with the
/// specified size and relocation information, return a section that it
/// should be placed in.
const MCSection *TargetLoweringObjectFileELF::
-getSectionForMergeableConstant(SectionKind Kind) const {
+getSectionForConstant(SectionKind Kind) const {
if (Kind.isMergeableConst4())
return MergeableConst4Section;
if (Kind.isMergeableConst8())
@@ -582,8 +581,7 @@ SelectSectionForGlobal(const GlobalValue *GV, SectionKind Kind,
}
const MCSection *
-TargetLoweringObjectFileMachO::
-getSectionForMergeableConstant(SectionKind Kind) const {
+TargetLoweringObjectFileMachO::getSectionForConstant(SectionKind Kind) const {
// If this constant requires a relocation, we have to put it in the data
// segment, not in the text segment.
if (Kind.isDataRel())
diff --git a/llvm/lib/Target/X86/X86TargetAsmInfo.cpp b/llvm/lib/Target/X86/X86TargetAsmInfo.cpp
index c13d9ac3cee..c30f3378b7b 100644
--- a/llvm/lib/Target/X86/X86TargetAsmInfo.cpp
+++ b/llvm/lib/Target/X86/X86TargetAsmInfo.cpp
@@ -228,7 +228,6 @@ X86WinTargetAsmInfo::X86WinTargetAsmInfo(const X86TargetMachine &TM):
AlignmentIsInBytes = true;
- JumpTableDataSection = NULL;
SwitchToSectionDirective = "";
TextSectionStartSuffix = "\tSEGMENT PARA 'CODE'";
DataSectionStartSuffix = "\tSEGMENT PARA 'DATA'";
diff --git a/llvm/lib/Target/XCore/XCoreTargetAsmInfo.cpp b/llvm/lib/Target/XCore/XCoreTargetAsmInfo.cpp
index 33a7eedc743..48502d07f63 100644
--- a/llvm/lib/Target/XCore/XCoreTargetAsmInfo.cpp
+++ b/llvm/lib/Target/XCore/XCoreTargetAsmInfo.cpp
@@ -18,7 +18,7 @@ XCoreTargetAsmInfo::XCoreTargetAsmInfo(const TargetMachine &TM)
Data64bitsDirective = 0;
ZeroDirective = "\t.space\t";
CommentString = "#";
- JumpTableDataSection = "\t.section\t.dp.data,\"awd\",@progbits";
+
PrivateGlobalPrefix = ".L";
AscizDirective = ".asciiz";
WeakDefDirective = "\t.weak\t";
OpenPOWER on IntegriCloud