Support for non-landing pad exception handling.
[oota-llvm.git] / include / llvm / Target / TargetMachineRegistry.h
index e122e9afd713a86c0c3732b62ce544c820d92718..dd3ed7da96621262b349594bb887a8e11b7169f9 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 exposes two classes: the TargetMachineRegistry class, which allows
 #ifndef LLVM_TARGET_TARGETMACHINEREGISTRY_H
 #define LLVM_TARGET_TARGETMACHINEREGISTRY_H
 
-#include "Support/CommandLine.h"
+#include "llvm/Support/CommandLine.h"
 
 namespace llvm {
   class Module;
   class TargetMachine;
-  class IntrinsicLowering;
 
   struct TargetMachineRegistry {
     struct Entry;
@@ -49,7 +48,7 @@ namespace llvm {
     struct Entry {
       const char *Name;
       const char *ShortDesc;
-      TargetMachine *(*CtorFn)(const Module &, IntrinsicLowering*);
+      TargetMachine *(*CtorFn)(const Module &, const std::string &);
       unsigned (*ModuleMatchQualityFn)(const Module &M);
       unsigned (*JITMatchQualityFn)();
 
@@ -57,12 +56,8 @@ namespace llvm {
 
     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;
-      }
+            TargetMachine *(*CF)(const Module &, const std::string &),
+            unsigned (*MMF)(const Module &M), unsigned (*JMF)());
     private:
       const Entry *Next;  // Next entry in the linked list.
     };
@@ -75,24 +70,44 @@ namespace llvm {
   /// 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..
+  /// TargetMachine comments.
+  /// 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) : 
+    RegisterTarget(const char *Name, const char *ShortDesc) :
       TargetMachineRegistry::Entry(Name, ShortDesc, &Allocator,
                                    &TargetMachineImpl::getModuleMatchQuality,
                                    &TargetMachineImpl::getJITMatchQuality) {
     }
   private:
-    static TargetMachine *Allocator(const Module &M, IntrinsicLowering *IL) {
-      return new TargetMachineImpl(M, IL);
+    static TargetMachine *Allocator(const Module &M, const std::string &FS) {
+      return new TargetMachineImpl(M, FS);
     }
   };
 
+  /// TargetRegistrationListener - This class allows code to listen for targets
+  /// that are dynamically registered, and be notified of it when they are.
+  class TargetRegistrationListener {
+    TargetRegistrationListener **Prev, *Next;
+  public:
+    TargetRegistrationListener();
+    virtual ~TargetRegistrationListener();
+
+    TargetRegistrationListener *getNext() const { return Next; }
+
+    virtual void targetRegistered(const TargetMachineRegistry::Entry *E) = 0;
+  };
+
+
   //===--------------------------------------------------------------------===//
   /// TargetNameParser - This option can be used to provide a command line
   /// option to choose among the various registered targets (commonly -march).
-  class TargetNameParser :
+  class TargetNameParser : public TargetRegistrationListener,
     public cl::parser<const TargetMachineRegistry::Entry*> {
   public:
     void initialize(cl::Option &O) {
@@ -102,6 +117,11 @@ namespace llvm {
                                         std::make_pair(E, E->ShortDesc)));
       cl::parser<const TargetMachineRegistry::Entry*>::initialize(O);
     }
+
+    virtual void targetRegistered(const TargetMachineRegistry::Entry *E) {
+      Values.push_back(std::make_pair(E->Name,
+                                      std::make_pair(E, E->ShortDesc)));
+    }
   };
 }