Remove special cases for more opcodes.
[oota-llvm.git] / include / llvm / CompilerDriver / Plugin.h
1 //===--- Plugin.h - The LLVM Compiler Driver --------------------*- C++ -*-===//
2 //
3 //                     The LLVM Compiler Infrastructure
4 //
5 // This file is distributed under the University of Illinois Open
6 // Source License. See LICENSE.TXT for details.
7 //
8 //===----------------------------------------------------------------------===//
9 //
10 //  Plugin support for llvmc.
11 //
12 //===----------------------------------------------------------------------===//
13
14 #ifndef LLVM_INCLUDE_COMPILER_DRIVER_PLUGIN_H
15 #define LLVM_INCLUDE_COMPILER_DRIVER_PLUGIN_H
16
17 #include "llvm/Support/Registry.h"
18
19 namespace llvmc {
20
21   class LanguageMap;
22   class CompilationGraph;
23
24   /// BasePlugin - An abstract base class for all LLVMC plugins.
25   struct BasePlugin {
26
27     /// Priority - Plugin priority, useful for handling dependencies
28     /// between plugins. Plugins with lower priorities are loaded
29     /// first.
30     virtual int Priority() const { return 0; }
31
32     /// PopulateLanguageMap - The auto-generated function that fills in
33     /// the language map (map from file extensions to language names).
34     virtual void PopulateLanguageMap(LanguageMap&) const = 0;
35
36     /// PopulateCompilationGraph - The auto-generated function that
37     /// populates the compilation graph with nodes and edges.
38     virtual void PopulateCompilationGraph(CompilationGraph&) const = 0;
39
40     /// Needed to avoid a compiler warning.
41     virtual ~BasePlugin() {}
42   };
43
44   typedef llvm::Registry<BasePlugin> PluginRegistry;
45
46   template <class P>
47   struct RegisterPlugin
48     : public PluginRegistry::Add<P> {
49     typedef PluginRegistry::Add<P> Base;
50
51     RegisterPlugin(const char* Name = "Nameless",
52                    const char* Desc = "Auto-generated plugin")
53       : Base(Name, Desc) {}
54   };
55
56
57   /// PluginLoader - Helper class used by the main program for
58   /// lifetime management.
59   struct PluginLoader {
60     PluginLoader();
61     ~PluginLoader();
62
63     /// PopulateLanguageMap - Fills in the language map by calling
64     /// PopulateLanguageMap methods of all plugins.
65     void PopulateLanguageMap(LanguageMap& langMap);
66
67     /// PopulateCompilationGraph - Populates the compilation graph by
68     /// calling PopulateCompilationGraph methods of all plugins.
69     void PopulateCompilationGraph(CompilationGraph& tools);
70
71   private:
72     // noncopyable
73     PluginLoader(const PluginLoader& other);
74     const PluginLoader& operator=(const PluginLoader& other);
75   };
76
77 }
78
79 #endif // LLVM_INCLUDE_COMPILER_DRIVER_PLUGIN_H