Use a better name for the label relocations while emitting them for Jump Tables
[oota-llvm.git] / include / llvm / Target / TargetMachineRegistry.h
index e122e9afd713a86c0c3732b62ce544c820d92718..a1b13d360d0b05f696211ccf7d0d19a50200e38c 100644 (file)
@@ -1,10 +1,10 @@
 //===-- Target/TargetMachineRegistry.h - Target Registration ----*- C++ -*-===//
-// 
+//
 //                     The LLVM Compiler Infrastructure
 //
-// This file was developed by the LLVM research group 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.
+//
 //===----------------------------------------------------------------------===//
 //
 // This file exposes two classes: the TargetMachineRegistry class, which allows
 #ifndef LLVM_TARGET_TARGETMACHINEREGISTRY_H
 #define LLVM_TARGET_TARGETMACHINEREGISTRY_H
 
-#include "Support/CommandLine.h"
+#include "llvm/Module.h"
+#include "llvm/Target/TargetRegistry.h"
 
 namespace llvm {
   class Module;
+  class Target;
   class TargetMachine;
-  class IntrinsicLowering;
-
-  struct TargetMachineRegistry {
-    struct Entry;
-
-    /// TargetMachineRegistry::getList - This static method returns the list of
-    /// target machines that are registered with the system.
-    static const Entry *getList() { return List; }
-
-    /// getClosestStaticTargetForModule - Given an LLVM module, pick the best
-    /// target that is compatible with the module.  If no close target can be
-    /// found, this returns null and sets the Error string to a reason.
-    static const Entry *getClosestStaticTargetForModule(const Module &M,
-                                                        std::string &Error);
-
-    /// getClosestTargetForJIT - Given an LLVM module, pick the best target that
-    /// is compatible with the current host and the specified module.  If no
-    /// close target can be found, this returns null and sets the Error string
-    /// to a reason.
-    static const Entry *getClosestTargetForJIT(std::string &Error);
-
-
-    /// Entry - One instance of this struct is created for each target that is
-    /// registered.
-    struct Entry {
-      const char *Name;
-      const char *ShortDesc;
-      TargetMachine *(*CtorFn)(const Module &, IntrinsicLowering*);
-      unsigned (*ModuleMatchQualityFn)(const Module &M);
-      unsigned (*JITMatchQualityFn)();
-
-      const Entry *getNext() const { return Next; }
-
-    protected:
-      Entry(const char *N, const char *SD,
-            TargetMachine *(*CF)(const Module &, IntrinsicLowering*),
-            unsigned (*MMF)(const Module &M), unsigned (*JMF)())
-      : Name(N), ShortDesc(SD), CtorFn(CF), ModuleMatchQualityFn(MMF),
-      JITMatchQualityFn(JMF), Next(List) {
-        List = this;
-      }
-    private:
-      const Entry *Next;  // Next entry in the linked list.
-    };
-
-  private:
-    static const Entry *List;
-  };
 
   //===--------------------------------------------------------------------===//
   /// RegisterTarget - This class is used to make targets automatically register
-  /// themselves with the tool they are linked.  Targets should define an
-  /// instance of this and implement the static methods described in the
-  /// TargetMachine comments..
+  /// themselves with the tools they are linked with.  Targets should define an
+  /// single global Target instance and register it using the TargetRegistry
+  /// interfaces. Targets must also include a static instance of this class.
+  ///
+  /// The type 'TargetMachineImpl' should provide a constructor with two
+  /// parameters:
+  /// - const Module& M: the module that is being compiled:
+  /// - const std::string& FS: target-specific string describing target
+  ///   flavour.
+
   template<class TargetMachineImpl>
-  struct RegisterTarget : public TargetMachineRegistry::Entry {
-    RegisterTarget(const char *Name, const char *ShortDesc) : 
-      TargetMachineRegistry::Entry(Name, ShortDesc, &Allocator,
-                                   &TargetMachineImpl::getModuleMatchQuality,
-                                   &TargetMachineImpl::getJITMatchQuality) {
+  struct RegisterTarget {
+    RegisterTarget(Target &T, const char *Name, const char *ShortDesc) {
+      TargetRegistry::RegisterTargetMachine(T, &Allocator);
     }
+
   private:
-    static TargetMachine *Allocator(const Module &M, IntrinsicLowering *IL) {
-      return new TargetMachineImpl(M, IL);
+    static TargetMachine *Allocator(const Target &T, const Module &M, 
+                                    const std::string &FS) {
+      return new TargetMachineImpl(T, M, FS);
     }
   };
 
-  //===--------------------------------------------------------------------===//
-  /// TargetNameParser - This option can be used to provide a command line
-  /// option to choose among the various registered targets (commonly -march).
-  class TargetNameParser :
-    public cl::parser<const TargetMachineRegistry::Entry*> {
-  public:
-    void initialize(cl::Option &O) {
-      for (const TargetMachineRegistry::Entry *E =
-             TargetMachineRegistry::getList(); E; E = E->getNext())
-        Values.push_back(std::make_pair(E->Name,
-                                        std::make_pair(E, E->ShortDesc)));
-      cl::parser<const TargetMachineRegistry::Entry*>::initialize(O);
-    }
-  };
 }
 
 #endif