Move JITInfo from PPCTM to PPC32TM
[oota-llvm.git] / lib / Target / PowerPC / PPCTargetMachine.cpp
index 0fdc14c48f2a6e14982c5d07b5ce2a20e06e5138..6eef33d775010d0c06dbb8a5a11d2c1d37f974f1 100644 (file)
@@ -12,6 +12,7 @@
 
 #include "PowerPC.h"
 #include "PowerPCTargetMachine.h"
+#include "PowerPCFrameInfo.h"
 #include "PPC32TargetMachine.h"
 #include "PPC64TargetMachine.h"
 #include "PPC32JITInfo.h"
 #include "llvm/Target/TargetOptions.h"
 #include "llvm/Target/TargetMachineRegistry.h"
 #include "llvm/Transforms/Scalar.h"
-#include "Support/CommandLine.h"
+#include "llvm/Support/CommandLine.h"
 #include <iostream>
 using namespace llvm;
 
+namespace llvm {
+  cl::opt<bool> AIX("aix", 
+                    cl::desc("Generate AIX/xcoff instead of Darwin/MachO"), 
+                    cl::Hidden);
+}
+
 namespace {
-  cl::opt<bool> 
-    AIX("aix", 
-    cl::desc("Generate AIX/xcoff rather than Darwin/macho"), 
-    cl::Hidden);
-  const std::string PPC32 = "PowerPC/32bit";
-  const std::string PPC64 = "PowerPC/64bit";
+  const std::string PPC32ID = "PowerPC/32bit";
+  const std::string PPC64ID = "PowerPC/64bit";
   
   // Register the targets
   RegisterTarget<PPC32TargetMachine> 
-  X("ppc32", "  PowerPC 32-bit (experimental)");
+  X("ppc32", "  PowerPC 32-bit");
+
+#if 0
   RegisterTarget<PPC64TargetMachine> 
   Y("ppc64", "  PowerPC 64-bit (unimplemented)");
+#endif
 }
 
 PowerPCTargetMachine::PowerPCTargetMachine(const std::string &name,
                                            IntrinsicLowering *IL,
                                            const TargetData &TD,
-                                           const TargetFrameInfo &TFI,
-                                           const PowerPCJITInfo &TJI) 
-  : TargetMachine(name, IL, TD), FrameInfo(TFI), JITInfo(TJI) {}
+                                           const PowerPCFrameInfo &TFI)
+  : TargetMachine(name, IL, TD), FrameInfo(TFI)
+{}
 
-unsigned PowerPCTargetMachine::getJITMatchQuality() {
+unsigned PPC32TargetMachine::getJITMatchQuality() {
+  return 0;
 #if defined(__POWERPC__) || defined (__ppc__) || defined(_POWER)
   return 10;
 #else
@@ -80,7 +87,7 @@ bool PowerPCTargetMachine::addPassesToEmitAssembly(PassManager &PM,
   PM.add(createUnreachableBlockEliminationPass());
 
   if (LP64)
-    PM.add(createPPC32ISelSimple(*this));
+    PM.add(createPPC64ISelSimple(*this));
   else
     PM.add(createPPC32ISelSimple(*this));
 
@@ -92,17 +99,15 @@ bool PowerPCTargetMachine::addPassesToEmitAssembly(PassManager &PM,
   if (PrintMachineCode)
     PM.add(createMachineFunctionPrinterPass(&std::cerr));
 
-  // PowerPC-specific prolog/epilog code inserter to put the fills/spills in the
-  // right spots.
-  PM.add(createPowerPCPEI());
+  PM.add(createPrologEpilogCodeInserter());
   
-  // Must run branch selection immediately preceding the printer
+  // Must run branch selection immediately preceding the asm printer
   PM.add(createPPCBranchSelectionPass());
   
   if (AIX)
-    PM.add(createPPC32AsmPrinter(Out, *this));
+    PM.add(createAIXAsmPrinter(Out, *this));
   else
-    PM.add(createPPC32AsmPrinter(Out, *this));
+    PM.add(createDarwinAsmPrinter(Out, *this));
     
   PM.add(createMachineCodeDeleter());
   return false;
@@ -126,34 +131,31 @@ void PowerPCJITInfo::addPassesToJITCompile(FunctionPassManager &PM) {
   PM.add(createPPC32ISelSimple(TM));
   PM.add(createRegisterAllocator());
   PM.add(createPrologEpilogCodeInserter());
+
+  // Must run branch selection immediately preceding the asm printer
+  PM.add(createPPCBranchSelectionPass());
+
+  if (PrintMachineCode)
+    PM.add(createMachineFunctionPrinterPass(&std::cerr));
 }
 
 void PowerPCJITInfo::replaceMachineCodeForFunction(void *Old, void *New) {
   assert(0 && "Cannot execute PowerPCJITInfo::replaceMachineCodeForFunction()");
 }
 
-void *PowerPCJITInfo::getJITStubForFunction(Function *F, 
-                                            MachineCodeEmitter &MCE) {
-  assert(0 && "Cannot execute PowerPCJITInfo::getJITStubForFunction()");
-  return 0;
-}
-
 /// PowerPCTargetMachine ctor - Create an ILP32 architecture model
 ///
-PPC32TargetMachine::PPC32TargetMachine(const Module &M,
-                                               IntrinsicLowering *IL)
-  : PowerPCTargetMachine(PPC32, IL, 
-                         TargetData(PPC32,false,4,4,4,4,4,4,2,1,4),
-                         TargetFrameInfo(TargetFrameInfo::StackGrowsDown,16,0),
-                         PPC32JITInfo(*this)) {}
+PPC32TargetMachine::PPC32TargetMachine(const Module &M, IntrinsicLowering *IL)
+  : PowerPCTargetMachine(PPC32ID, IL, 
+                         TargetData(PPC32ID,false,4,4,4,4,4,4,2,1,4),
+                         PowerPCFrameInfo(*this, false)), JITInfo(*this) {}
 
 /// PPC64TargetMachine ctor - Create a LP64 architecture model
 ///
 PPC64TargetMachine::PPC64TargetMachine(const Module &M, IntrinsicLowering *IL)
-  : PowerPCTargetMachine(PPC64, IL,
-                         TargetData(PPC64,false,8,4,4,4,4,4,2,1,4),
-                         TargetFrameInfo(TargetFrameInfo::StackGrowsDown,16,0),
-                         PPC64JITInfo(*this)) {}
+  : PowerPCTargetMachine(PPC64ID, IL,
+                         TargetData(PPC64ID,false,8,4,4,4,4,4,2,1,4),
+                         PowerPCFrameInfo(*this, true)) {}
 
 unsigned PPC32TargetMachine::getModuleMatchQuality(const Module &M) {
   if (M.getEndianness()  == Module::BigEndian &&