Kill off last uses of TargetMachineRegistry class.
[oota-llvm.git] / include / llvm / Target / TargetMachineRegistry.h
1 //===-- Target/TargetMachineRegistry.h - Target Registration ----*- C++ -*-===//
2 //
3 //                     The LLVM Compiler Infrastructure
4 //
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
7 //
8 //===----------------------------------------------------------------------===//
9 //
10 // This file exposes two classes: the TargetMachineRegistry class, which allows
11 // tools to inspect all of registered targets, and the RegisterTarget class,
12 // which TargetMachine implementations should use to register themselves with
13 // the system.
14 //
15 //===----------------------------------------------------------------------===//
16
17 #ifndef LLVM_TARGET_TARGETMACHINEREGISTRY_H
18 #define LLVM_TARGET_TARGETMACHINEREGISTRY_H
19
20 #include "llvm/Module.h"
21 #include "llvm/Target/TargetRegistry.h"
22
23 namespace llvm {
24   class Module;
25   class Target;
26   class TargetMachine;
27
28   //===--------------------------------------------------------------------===//
29   /// RegisterTarget - This class is used to make targets automatically register
30   /// themselves with the tools they are linked with.  Targets should define an
31   /// single global Target instance and register it using the TargetRegistry
32   /// interfaces. Targets must also include a static instance of this class.
33   ///
34   /// The type 'TargetMachineImpl' should provide a constructor with two
35   /// parameters:
36   /// - const Module& M: the module that is being compiled:
37   /// - const std::string& FS: target-specific string describing target
38   ///   flavour.
39
40   template<class TargetMachineImpl>
41   struct RegisterTarget {
42     RegisterTarget(Target &T, const char *Name, const char *ShortDesc) {
43       TargetRegistry::RegisterTargetMachine(T, &Allocator);
44     }
45
46   private:
47     static TargetMachine *Allocator(const Target &T, const Module &M, 
48                                     const std::string &FS) {
49       return new TargetMachineImpl(T, M, FS);
50     }
51   };
52
53 }
54
55 #endif