aboutsummaryrefslogtreecommitdiffstats
path: root/lib/Target/Sparc
diff options
context:
space:
mode:
authorChris Lattner <sabre@nondot.org>2009-07-28 03:13:23 +0000
committerChris Lattner <sabre@nondot.org>2009-07-28 03:13:23 +0000
commitc4c40a9f14d66de770ba7c0922be07dca7e3b827 (patch)
treecfcb5bc95b5b8060f71ee1b251f0f3e93fbfff2a /lib/Target/Sparc
parent03708c5e3d8aea09235ae14d6072510c938188f0 (diff)
downloadexternal_llvm-c4c40a9f14d66de770ba7c0922be07dca7e3b827.zip
external_llvm-c4c40a9f14d66de770ba7c0922be07dca7e3b827.tar.gz
external_llvm-c4c40a9f14d66de770ba7c0922be07dca7e3b827.tar.bz2
Rip all of the global variable lowering logic out of TargetAsmInfo. Since
it is highly specific to the object file that will be generated in the end, this introduces a new TargetLoweringObjectFile interface that is implemented for each of ELF/MachO/COFF/Alpha/PIC16 and XCore. Though still is still a brutal and ugly refactoring, this is a major step towards goodness. This patch also: 1. fixes a bunch of dangling pointer problems in the PIC16 backend. 2. disables the TargetLowering copy ctor which PIC16 was accidentally using. 3. gets us closer to xcore having its own crazy target section flags and pic16 not having to shadow sections with its own objects. 4. fixes wierdness where ELF targets would set CStringSection but not CStringSection_. Factor the code better. 5. fixes some bugs in string lowering on ELF targets. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@77294 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Target/Sparc')
-rw-r--r--lib/Target/Sparc/AsmPrinter/SparcAsmPrinter.cpp5
-rw-r--r--lib/Target/Sparc/SparcISelLowering.cpp25
-rw-r--r--lib/Target/Sparc/SparcTargetAsmInfo.cpp21
-rw-r--r--lib/Target/Sparc/SparcTargetAsmInfo.h4
4 files changed, 27 insertions, 28 deletions
diff --git a/lib/Target/Sparc/AsmPrinter/SparcAsmPrinter.cpp b/lib/Target/Sparc/AsmPrinter/SparcAsmPrinter.cpp
index ad99cca..7569eee 100644
--- a/lib/Target/Sparc/AsmPrinter/SparcAsmPrinter.cpp
+++ b/lib/Target/Sparc/AsmPrinter/SparcAsmPrinter.cpp
@@ -26,6 +26,7 @@
#include "llvm/CodeGen/MachineConstantPool.h"
#include "llvm/CodeGen/MachineInstr.h"
#include "llvm/Target/TargetAsmInfo.h"
+#include "llvm/Target/TargetLoweringObjectFile.h"
#include "llvm/Target/TargetRegistry.h"
#include "llvm/Support/ErrorHandling.h"
#include "llvm/Support/FormattedStream.h"
@@ -95,7 +96,7 @@ bool SparcAsmPrinter::runOnMachineFunction(MachineFunction &MF) {
// Print out the label for the function.
const Function *F = MF.getFunction();
- SwitchToSection(TAI->SectionForGlobal(F));
+ SwitchToSection(getObjFileLowering().SectionForGlobal(F, TM));
EmitAlignment(MF.getAlignment(), F);
O << "\t.globl\t" << CurrentFnName << '\n';
@@ -229,7 +230,7 @@ void SparcAsmPrinter::PrintGlobalVariable(const GlobalVariable* GVar) {
printVisibility(name, GVar->getVisibility());
- SwitchToSection(TAI->SectionForGlobal(GVar));
+ SwitchToSection(getObjFileLowering().SectionForGlobal(GVar, TM));
if (C->isNullValue() && !GVar->hasSection()) {
if (!GVar->isThreadLocal() &&
diff --git a/lib/Target/Sparc/SparcISelLowering.cpp b/lib/Target/Sparc/SparcISelLowering.cpp
index fe7bf93..16d9229 100644
--- a/lib/Target/Sparc/SparcISelLowering.cpp
+++ b/lib/Target/Sparc/SparcISelLowering.cpp
@@ -21,6 +21,7 @@
#include "llvm/CodeGen/MachineInstrBuilder.h"
#include "llvm/CodeGen/MachineRegisterInfo.h"
#include "llvm/CodeGen/SelectionDAG.h"
+#include "llvm/Target/TargetLoweringObjectFile.h"
#include "llvm/ADT/VectorExtras.h"
#include "llvm/Support/ErrorHandling.h"
using namespace llvm;
@@ -548,9 +549,31 @@ static SPCC::CondCodes FPCondCCodeToFCC(ISD::CondCode CC) {
}
}
+class TargetLoweringObjectFileSparc : public TargetLoweringObjectFileELF {
+public:
+ void getSectionFlagsAsString(SectionKind Kind,
+ SmallVectorImpl<char> &Str) const {
+ if (Kind.isMergeableConst() || Kind.isMergeableCString())
+ return TargetLoweringObjectFileELF::getSectionFlagsAsString(Kind, Str);
+
+ // FIXME: Inefficient.
+ std::string Res;
+ if (!Kind.isMetadata())
+ Res += ",#alloc";
+ if (Kind.isText())
+ Res += ",#execinstr";
+ if (Kind.isWriteable())
+ Res += ",#write";
+ if (Kind.isThreadLocal())
+ Res += ",#tls";
+
+ Str.append(Res.begin(), Res.end());
+ }
+};
+
SparcTargetLowering::SparcTargetLowering(TargetMachine &TM)
- : TargetLowering(TM) {
+ : TargetLowering(TM, new TargetLoweringObjectFileSparc()) {
// Set up the register classes.
addRegisterClass(MVT::i32, SP::IntRegsRegisterClass);
diff --git a/lib/Target/Sparc/SparcTargetAsmInfo.cpp b/lib/Target/Sparc/SparcTargetAsmInfo.cpp
index 59897e6..169eda7 100644
--- a/lib/Target/Sparc/SparcTargetAsmInfo.cpp
+++ b/lib/Target/Sparc/SparcTargetAsmInfo.cpp
@@ -25,27 +25,6 @@ SparcELFTargetAsmInfo::SparcELFTargetAsmInfo(const TargetMachine &TM)
ConstantPoolSection = "\t.section \".rodata\",#alloc\n";
COMMDirectiveTakesAlignment = true;
CStringSection=".rodata.str";
-
- // Sparc normally uses named section for BSS.
- BSSSection_ = getOrCreateSection("\t.bss", true, SectionKind::BSS);
}
-void SparcELFTargetAsmInfo::getSectionFlagsAsString(SectionKind Kind,
- SmallVectorImpl<char> &Str) const {
- if (Kind.isMergeableConst() || Kind.isMergeableCString())
- return ELFTargetAsmInfo::getSectionFlagsAsString(Kind, Str);
-
- // FIXME: Inefficient.
- std::string Res;
- if (!Kind.isMetadata())
- Res += ",#alloc";
- if (Kind.isText())
- Res += ",#execinstr";
- if (Kind.isWriteable())
- Res += ",#write";
- if (Kind.isThreadLocal())
- Res += ",#tls";
-
- Str.append(Res.begin(), Res.end());
-}
diff --git a/lib/Target/Sparc/SparcTargetAsmInfo.h b/lib/Target/Sparc/SparcTargetAsmInfo.h
index 943dcef..ae646c3 100644
--- a/lib/Target/Sparc/SparcTargetAsmInfo.h
+++ b/lib/Target/Sparc/SparcTargetAsmInfo.h
@@ -23,10 +23,6 @@ namespace llvm {
struct SparcELFTargetAsmInfo : public ELFTargetAsmInfo {
explicit SparcELFTargetAsmInfo(const TargetMachine &TM);
-
- virtual void getSectionFlagsAsString(SectionKind Kind,
- SmallVectorImpl<char> &Str) const;
-
};
} // namespace llvm