Make tail merging the default, except on powerPC. There was no prior art
[oota-llvm.git] / lib / Target / PowerPC / PPCTargetMachine.cpp
index 8cf85d186fb2072625d0c613c4984603b16eb84b..6d5e05077379e0980f923dc22b79d3ed2a6415f7 100644 (file)
@@ -28,18 +28,21 @@ namespace {
 }
 
 const TargetAsmInfo *PPCTargetMachine::createTargetAsmInfo() const {
-  return new DarwinTargetAsmInfo(*this);
+  if (Subtarget.isDarwin())
+    return new DarwinTargetAsmInfo(*this);
+  else
+    return new LinuxTargetAsmInfo(*this);
 }
 
 unsigned PPC32TargetMachine::getJITMatchQuality() {
-#if defined(__POWERPC__) || defined (__ppc__) || defined(_POWER)
+#if defined(__POWERPC__) || defined (__ppc__) || defined(_POWER) || defined(__PPC__)
   if (sizeof(void*) == 4)
     return 10;
 #endif
   return 0;
 }
 unsigned PPC64TargetMachine::getJITMatchQuality() {
-#if defined(__POWERPC__) || defined (__ppc__) || defined(_POWER)
+#if defined(__POWERPC__) || defined (__ppc__) || defined(_POWER) || defined(__PPC__)
   if (sizeof(void*) == 8)
     return 10;
 #endif
@@ -84,15 +87,19 @@ PPCTargetMachine::PPCTargetMachine(const Module &M, const std::string &FS,
   : Subtarget(*this, M, FS, is64Bit),
     DataLayout(Subtarget.getTargetDataString()), InstrInfo(*this),
     FrameInfo(*this, is64Bit), JITInfo(*this, is64Bit), TLInfo(*this),
-    InstrItins(Subtarget.getInstrItineraryData()) {
+    InstrItins(Subtarget.getInstrItineraryData()), MachOWriterInfo(*this) {
 
   if (getRelocationModel() == Reloc::Default)
     if (Subtarget.isDarwin())
       setRelocationModel(Reloc::DynamicNoPIC);
     else
-      setRelocationModel(Reloc::PIC_);
+      setRelocationModel(Reloc::Static);
 }
 
+/// Override this for PowerPC.  Tail merging happily breaks up instruction issue
+/// groups, which typically degrades performance.
+const bool PPCTargetMachine::DoTailMergeDefault() const { return false; }
+
 PPC32TargetMachine::PPC32TargetMachine(const Module &M, const std::string &FS) 
   : PPCTargetMachine(M, FS, false) {
 }
@@ -126,13 +133,6 @@ bool PPCTargetMachine::addAssemblyEmitter(FunctionPassManager &PM, bool Fast,
   return false;
 }
 
-bool PPCTargetMachine::addObjectWriter(FunctionPassManager &PM, bool Fast,
-                                       std::ostream &Out) {
-  // FIXME: support PPC ELF files at some point
-  addPPCMachOObjectWriterPass(PM, Out, *this);
-  return false;
-}
-
 bool PPCTargetMachine::addCodeEmitter(FunctionPassManager &PM, bool Fast,
                                       MachineCodeEmitter &MCE) {
   // The JIT should use the static relocation model in ppc32 mode, PIC in ppc64.
@@ -155,3 +155,9 @@ bool PPCTargetMachine::addCodeEmitter(FunctionPassManager &PM, bool Fast,
   return false;
 }
 
+bool PPCTargetMachine::addSimpleCodeEmitter(FunctionPassManager &PM, bool Fast,
+                                            MachineCodeEmitter &MCE) {
+  // Machine code emitter pass for PowerPC.
+  PM.add(createPPCCodeEmitterPass(*this, MCE));
+  return false;
+}