aboutsummaryrefslogtreecommitdiffstats
path: root/lib/Target/XCore
diff options
context:
space:
mode:
Diffstat (limited to 'lib/Target/XCore')
-rw-r--r--lib/Target/XCore/CMakeLists.txt1
-rw-r--r--lib/Target/XCore/XCoreAsmPrinter.cpp5
-rw-r--r--lib/Target/XCore/XCoreISelLowering.cpp4
-rw-r--r--lib/Target/XCore/XCoreTargetAsmInfo.cpp32
-rw-r--r--lib/Target/XCore/XCoreTargetAsmInfo.h6
-rw-r--r--lib/Target/XCore/XCoreTargetObjectFile.cpp32
-rw-r--r--lib/Target/XCore/XCoreTargetObjectFile.h25
7 files changed, 67 insertions, 38 deletions
diff --git a/lib/Target/XCore/CMakeLists.txt b/lib/Target/XCore/CMakeLists.txt
index a7aba14..f4e4c22 100644
--- a/lib/Target/XCore/CMakeLists.txt
+++ b/lib/Target/XCore/CMakeLists.txt
@@ -20,4 +20,5 @@ add_llvm_target(XCore
XCoreSubtarget.cpp
XCoreTargetAsmInfo.cpp
XCoreTargetMachine.cpp
+ XCoreTargetObjectFile.cpp
)
diff --git a/lib/Target/XCore/XCoreAsmPrinter.cpp b/lib/Target/XCore/XCoreAsmPrinter.cpp
index 5f24842..d57151c 100644
--- a/lib/Target/XCore/XCoreAsmPrinter.cpp
+++ b/lib/Target/XCore/XCoreAsmPrinter.cpp
@@ -28,6 +28,7 @@
#include "llvm/CodeGen/MachineInstr.h"
#include "llvm/Target/TargetAsmInfo.h"
#include "llvm/Target/TargetData.h"
+#include "llvm/Target/TargetLoweringObjectFile.h"
#include "llvm/Target/TargetRegistry.h"
#include "llvm/Support/Mangler.h"
#include "llvm/ADT/Statistic.h"
@@ -133,7 +134,7 @@ void XCoreAsmPrinter::PrintGlobalVariable(const GlobalVariable *GV) {
const TargetData *TD = TM.getTargetData();
- SwitchToSection(TAI->SectionForGlobal(GV));
+ SwitchToSection(getObjFileLowering().SectionForGlobal(GV, TM));
std::string name = Mang->getMangledName(GV);
Constant *C = GV->getInitializer();
@@ -204,7 +205,7 @@ void XCoreAsmPrinter::emitFunctionStart(MachineFunction &MF) {
// Print out the label for the function.
const Function *F = MF.getFunction();
- SwitchToSection(TAI->SectionForGlobal(F));
+ SwitchToSection(getObjFileLowering().SectionForGlobal(F, TM));
// Mark the start of the function
O << "\t.cc_top " << CurrentFnName << ".function," << CurrentFnName << "\n";
diff --git a/lib/Target/XCore/XCoreISelLowering.cpp b/lib/Target/XCore/XCoreISelLowering.cpp
index e4e7f27..eaab849 100644
--- a/lib/Target/XCore/XCoreISelLowering.cpp
+++ b/lib/Target/XCore/XCoreISelLowering.cpp
@@ -16,6 +16,7 @@
#include "XCoreISelLowering.h"
#include "XCoreMachineFunctionInfo.h"
#include "XCore.h"
+#include "XCoreTargetObjectFile.h"
#include "XCoreTargetMachine.h"
#include "XCoreSubtarget.h"
#include "llvm/DerivedTypes.h"
@@ -55,7 +56,8 @@ getTargetNodeName(unsigned Opcode) const
}
XCoreTargetLowering::XCoreTargetLowering(XCoreTargetMachine &XTM)
- : TargetLowering(XTM),
+ : TargetLowering(XTM,
+ new XCoreTargetObjectFile(XTM.getSubtargetImpl()->isXS1A())),
TM(XTM),
Subtarget(*XTM.getSubtargetImpl()) {
diff --git a/lib/Target/XCore/XCoreTargetAsmInfo.cpp b/lib/Target/XCore/XCoreTargetAsmInfo.cpp
index fee0a22..fd8c9d7 100644
--- a/lib/Target/XCore/XCoreTargetAsmInfo.cpp
+++ b/lib/Target/XCore/XCoreTargetAsmInfo.cpp
@@ -1,4 +1,4 @@
-//===-- XCoreTargetAsmInfo.cpp - XCore asm properties -----------*- C++ -*-===//
+//===-- XCoreTargetAsmInfo.cpp - XCore asm properties ---------------------===//
//
// The LLVM Compiler Infrastructure
//
@@ -6,41 +6,13 @@
// License. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
-//
-// This file contains the declarations of the XCoreTargetAsmInfo properties.
-// We use the small section flag for the CP relative and DP relative
-// flags. If a section is small and writable then it is DP relative. If a
-// section is small and not writable then it is CP relative.
-//
-//===----------------------------------------------------------------------===//
#include "XCoreTargetAsmInfo.h"
-#include "XCoreTargetMachine.h"
-#include "llvm/GlobalVariable.h"
-#include "llvm/ADT/StringExtras.h"
-
using namespace llvm;
-XCoreTargetAsmInfo::XCoreTargetAsmInfo(const XCoreTargetMachine &TM)
+XCoreTargetAsmInfo::XCoreTargetAsmInfo(const TargetMachine &TM)
: ELFTargetAsmInfo(TM) {
SupportsDebugInformation = true;
- TextSection = getOrCreateSection("\t.text", true, SectionKind::Text);
- DataSection = getOrCreateSection("\t.dp.data", false, SectionKind::DataRel);
- BSSSection_ = getOrCreateSection("\t.dp.bss", false, SectionKind::BSS);
-
- // TLS globals are lowered in the backend to arrays indexed by the current
- // thread id. After lowering they require no special handling by the linker
- // and can be placed in the standard data / bss sections.
- TLSDataSection = DataSection;
- TLSBSSSection = BSSSection_;
-
- if (TM.getSubtargetImpl()->isXS1A())
- // FIXME: Why is this writable???
- ReadOnlySection = getOrCreateSection("\t.dp.rodata", false,
- SectionKind::DataRel);
- else
- ReadOnlySection = getOrCreateSection("\t.cp.rodata", false,
- SectionKind::ReadOnly);
Data16bitsDirective = "\t.short\t";
Data32bitsDirective = "\t.long\t";
Data64bitsDirective = 0;
diff --git a/lib/Target/XCore/XCoreTargetAsmInfo.h b/lib/Target/XCore/XCoreTargetAsmInfo.h
index 6d38340..f220815 100644
--- a/lib/Target/XCore/XCoreTargetAsmInfo.h
+++ b/lib/Target/XCore/XCoreTargetAsmInfo.h
@@ -18,13 +18,9 @@
namespace llvm {
- // Forward declarations.
- class XCoreTargetMachine;
- class XCoreSubtarget;
-
class XCoreTargetAsmInfo : public ELFTargetAsmInfo {
public:
- explicit XCoreTargetAsmInfo(const XCoreTargetMachine &TM);
+ explicit XCoreTargetAsmInfo(const TargetMachine &TM);
};
} // namespace llvm
diff --git a/lib/Target/XCore/XCoreTargetObjectFile.cpp b/lib/Target/XCore/XCoreTargetObjectFile.cpp
new file mode 100644
index 0000000..89880c2
--- /dev/null
+++ b/lib/Target/XCore/XCoreTargetObjectFile.cpp
@@ -0,0 +1,32 @@
+//===-- XCoreTargetObjectFile.cpp - XCore object files --------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+#include "XCoreTargetObjectFile.h"
+using namespace llvm;
+
+
+XCoreTargetObjectFile::XCoreTargetObjectFile(bool isXS1A) {
+ TextSection = getOrCreateSection("\t.text", true, SectionKind::Text);
+ DataSection = getOrCreateSection("\t.dp.data", false, SectionKind::DataRel);
+ BSSSection_ = getOrCreateSection("\t.dp.bss", false, SectionKind::BSS);
+
+ // TLS globals are lowered in the backend to arrays indexed by the current
+ // thread id. After lowering they require no special handling by the linker
+ // and can be placed in the standard data / bss sections.
+ TLSDataSection = DataSection;
+ TLSBSSSection = BSSSection_;
+
+ if (isXS1A)
+ // FIXME: Why is this writable ("datarel")???
+ ReadOnlySection = getOrCreateSection("\t.dp.rodata", false,
+ SectionKind::DataRel);
+ else
+ ReadOnlySection = getOrCreateSection("\t.cp.rodata", false,
+ SectionKind::ReadOnly);
+} \ No newline at end of file
diff --git a/lib/Target/XCore/XCoreTargetObjectFile.h b/lib/Target/XCore/XCoreTargetObjectFile.h
new file mode 100644
index 0000000..af40e11
--- /dev/null
+++ b/lib/Target/XCore/XCoreTargetObjectFile.h
@@ -0,0 +1,25 @@
+//===-- llvm/Target/XCoreTargetObjectFile.h - XCore Object Info -*- C++ -*-===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+#ifndef LLVM_TARGET_XCORE_TARGETOBJECTFILE_H
+#define LLVM_TARGET_XCORE_TARGETOBJECTFILE_H
+
+#include "llvm/Target/TargetLoweringObjectFile.h"
+
+namespace llvm {
+
+ class XCoreTargetObjectFile : public TargetLoweringObjectFileELF {
+ public:
+ XCoreTargetObjectFile(bool isXS1A);
+
+ // TODO: Classify globals as xcore wishes.
+ };
+} // end namespace llvm
+
+#endif