Fix cmake build, add TargetMachineRegistry.cpp that got restored in r75807
[oota-llvm.git] / lib / Target / IA64 / IA64TargetMachine.cpp
index 0f7821f5af7053432791f97de75bd3e4b6ba601d..00fdd5e8a65e5341c1074a2035c8dd4421a6bcf8 100644 (file)
@@ -2,8 +2,8 @@
 //
 //                     The LLVM Compiler Infrastructure
 //
-// This file was developed by Duraid Madina and is distributed under the
-// University of Illinois Open Source License. See LICENSE.TXT for details.
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
 //
 //===----------------------------------------------------------------------===//
 //
@@ -11,6 +11,7 @@
 //
 //===----------------------------------------------------------------------===//
 
+#include "IA64TargetAsmInfo.h"
 #include "IA64TargetMachine.h"
 #include "IA64.h"
 #include "llvm/Module.h"
 #include "llvm/Target/TargetMachineRegistry.h"
 using namespace llvm;
 
-/// IA64TargetMachineModule - Note that this is used on hosts that cannot link
-/// in a library unless there are references into the library.  In particular,
-/// it seems that it is not possible to get things to work on Win32 without
-/// this.  Though it is unused, do not remove it.
-extern "C" int IA64TargetMachineModule;
-int IA64TargetMachineModule = 0;
+// Register the target
+static RegisterTarget<IA64TargetMachine> X("ia64",
+                                           "IA-64 (Itanium) [experimental]");
 
-namespace {
-  RegisterTarget<IA64TargetMachine> X("ia64", "  IA-64 (Itanium)");
+// No assembler printer by default
+IA64TargetMachine::AsmPrinterCtorFn IA64TargetMachine::AsmPrinterCtor = 0;
+
+// Force static initialization.
+extern "C" void LLVMInitializeIA64Target() { }
+
+const TargetAsmInfo *IA64TargetMachine::createTargetAsmInfo() const {
+  return new IA64TargetAsmInfo(*this);
 }
 
 unsigned IA64TargetMachine::getModuleMatchQuality(const Module &M) {
@@ -45,6 +49,8 @@ unsigned IA64TargetMachine::getModuleMatchQuality(const Module &M) {
     if (seenIA64)
       return 20; // strong match
   }
+  // If the target triple is something non-ia64, we don't match.
+  if (!TT.empty()) return 0;
 
 #if defined(__ia64__) || defined(__IA64__)
   return 5;
@@ -56,7 +62,7 @@ unsigned IA64TargetMachine::getModuleMatchQuality(const Module &M) {
 /// IA64TargetMachine ctor - Create an LP64 architecture model
 ///
 IA64TargetMachine::IA64TargetMachine(const Module &M, const std::string &FS)
-  : DataLayout("e"),
+  : DataLayout("e-f80:128:128"),
     FrameInfo(TargetFrameInfo::StackGrowsDown, 16, 0),
     TLInfo(*this) { // FIXME? check this stuff
 }
@@ -66,19 +72,26 @@ IA64TargetMachine::IA64TargetMachine(const Module &M, const std::string &FS)
 // Pass Pipeline Configuration
 //===----------------------------------------------------------------------===//
 
-bool IA64TargetMachine::addInstSelector(FunctionPassManager &PM, bool Fast) {
+bool IA64TargetMachine::addInstSelector(PassManagerBase &PM,
+                                        CodeGenOpt::Level OptLevel) {
   PM.add(createIA64DAGToDAGInstructionSelector(*this));
   return false;
 }
 
-bool IA64TargetMachine::addPreEmitPass(FunctionPassManager &PM, bool Fast) {
+bool IA64TargetMachine::addPreEmitPass(PassManagerBase &PM,
+                                       CodeGenOpt::Level OptLevel) {
   // Make sure everything is bundled happily
   PM.add(createIA64BundlingPass(*this));
   return true;
 }
-bool IA64TargetMachine::addAssemblyEmitter(FunctionPassManager &PM, bool Fast, 
-                                           std::ostream &Out) {
-  PM.add(createIA64CodePrinterPass(Out, *this));
+bool IA64TargetMachine::addAssemblyEmitter(PassManagerBase &PM,
+                                           CodeGenOpt::Level OptLevel,
+                                           bool Verbose,
+                                           formatted_raw_ostream &Out) {
+  // Output assembly language.
+  assert(AsmPrinterCtor && "AsmPrinter was not linked in");
+  if (AsmPrinterCtor)
+    PM.add(AsmPrinterCtor(Out, *this, Verbose));
   return false;
 }