aboutsummaryrefslogtreecommitdiff
path: root/lib/Target/PowerPC/PPCTargetMachine.cpp
diff options
context:
space:
mode:
authorChris Lattner <sabre@nondot.org>2006-06-16 01:37:27 +0000
committerChris Lattner <sabre@nondot.org>2006-06-16 01:37:27 +0000
commit94de9a8951339536af1cc0ca947bc1005eb8f5f3 (patch)
tree0d4b5940346c745c5961385309bb2f9a6b589f30 /lib/Target/PowerPC/PPCTargetMachine.cpp
parent1127315562b221010040925980040fd4f65bdb1c (diff)
First baby step towards ppc64 support. This adds a new -march=ppc64 backend
that is currently just like ppc32 :) git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@28813 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Target/PowerPC/PPCTargetMachine.cpp')
-rw-r--r--lib/Target/PowerPC/PPCTargetMachine.cpp59
1 files changed, 49 insertions, 10 deletions
diff --git a/lib/Target/PowerPC/PPCTargetMachine.cpp b/lib/Target/PowerPC/PPCTargetMachine.cpp
index 82ea5c9742..a518f9d69c 100644
--- a/lib/Target/PowerPC/PPCTargetMachine.cpp
+++ b/lib/Target/PowerPC/PPCTargetMachine.cpp
@@ -29,19 +29,29 @@ using namespace llvm;
namespace {
// Register the targets
- RegisterTarget<PPCTargetMachine>
- X("ppc32", " PowerPC");
+ RegisterTarget<PPC32TargetMachine>
+ X("ppc32", " PowerPC 32");
+ RegisterTarget<PPC64TargetMachine>
+ Y("ppc64", " PowerPC 64");
}
-unsigned PPCTargetMachine::getJITMatchQuality() {
+unsigned PPC32TargetMachine::getJITMatchQuality() {
#if defined(__POWERPC__) || defined (__ppc__) || defined(_POWER)
- return 10;
+ if (sizeof(void*) == 4)
+ return 10;
#else
return 0;
#endif
}
+unsigned PPC64TargetMachine::getJITMatchQuality() {
+#if defined(__POWERPC__) || defined (__ppc__) || defined(_POWER)
+ if (sizeof(void*) == 8)
+ return 10 * 0/*FIXME: not PPC64-JIT support yet! */;
+#endif
+ return 0;
+}
-unsigned PPCTargetMachine::getModuleMatchQuality(const Module &M) {
+unsigned PPC32TargetMachine::getModuleMatchQuality(const Module &M) {
// We strongly match "powerpc-*".
std::string TT = M.getTargetTriple();
if (TT.size() >= 8 && std::string(TT.begin(), TT.begin()+8) == "powerpc-")
@@ -57,11 +67,31 @@ unsigned PPCTargetMachine::getModuleMatchQuality(const Module &M) {
return getJITMatchQuality()/2;
}
-PPCTargetMachine::PPCTargetMachine(const Module &M, const std::string &FS)
-: TargetMachine("PowerPC"),
- DataLayout(std::string("PowerPC"), std::string("E-p:32:32-d:32-l:32")),
- Subtarget(M, FS), FrameInfo(*this, false), JITInfo(*this),
- TLInfo(*this), InstrItins(Subtarget.getInstrItineraryData()) {
+unsigned PPC64TargetMachine::getModuleMatchQuality(const Module &M) {
+ // We strongly match "powerpc64-*".
+ std::string TT = M.getTargetTriple();
+ if (TT.size() >= 10 && std::string(TT.begin(), TT.begin()+10) == "powerpc64-")
+ return 20;
+
+ if (M.getEndianness() == Module::BigEndian &&
+ M.getPointerSize() == Module::Pointer64)
+ return 10; // Weak match
+ else if (M.getEndianness() != Module::AnyEndianness ||
+ M.getPointerSize() != Module::AnyPointerSize)
+ return 0; // Match for some other target
+
+ return getJITMatchQuality()/2;
+}
+
+
+PPCTargetMachine::PPCTargetMachine(const Module &M, const std::string &FS,
+ bool is64Bit)
+ : TargetMachine("PowerPC"), Subtarget(M, FS, is64Bit),
+ DataLayout(std::string("PowerPC"),
+ std::string(Subtarget.getTargetDataString())),
+ FrameInfo(*this, false), JITInfo(*this), TLInfo(*this),
+ InstrItins(Subtarget.getInstrItineraryData()) {
+
if (TargetDefault == PPCTarget) {
if (Subtarget.isAIX()) PPCTarget = TargetAIX;
if (Subtarget.isDarwin()) PPCTarget = TargetDarwin;
@@ -73,6 +103,15 @@ PPCTargetMachine::PPCTargetMachine(const Module &M, const std::string &FS)
setRelocationModel(Reloc::PIC);
}
+PPC32TargetMachine::PPC32TargetMachine(const Module &M, const std::string &FS)
+ : PPCTargetMachine(M, FS, false) {
+}
+
+
+PPC64TargetMachine::PPC64TargetMachine(const Module &M, const std::string &FS)
+ : PPCTargetMachine(M, FS, true) {
+}
+
/// addPassesToEmitFile - Add passes to the specified pass manager to implement
/// a static compiler for this target.
///