ba22450697b31a33696348e1b6a3d89dd50d8b20
[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 llvmc2.
11 //
12 //===----------------------------------------------------------------------===//
13
14 #ifndef LLVM_TOOLS_LLVMC2_PLUGIN_H
15 #define LLVM_TOOLS_LLVMC2_PLUGIN_H
16
17 namespace llvmc {
18
19   class LanguageMap;
20   class CompilationGraph;
21
22   /// BasePlugin - An abstract base class for all LLVMC plugins.
23   struct BasePlugin {
24
25     /// PopulateLanguageMap - The auto-generated function that fills in
26     /// the language map (map from file extensions to language names).
27     virtual void PopulateLanguageMap(LanguageMap&) const = 0;
28
29     /// PopulateCompilationGraph - The auto-generated function that
30     /// populates the compilation graph with nodes and edges.
31     virtual void PopulateCompilationGraph(CompilationGraph&) const = 0;
32   };
33
34   // Helper class for RegisterPlugin.
35   class RegisterPluginImpl {
36   protected:
37     RegisterPluginImpl(BasePlugin*);
38   };
39
40   /// RegisterPlugin<T> template - Used to register LLVMC plugins.
41   template <class T>
42   struct RegisterPlugin : RegisterPluginImpl {
43     RegisterPlugin() : RegisterPluginImpl (new T()) {}
44   };
45
46   /// PopulateLanguageMap - Fills in the language map by calling
47   /// PopulateLanguageMap methods of all plugins.
48   void PopulateLanguageMap(LanguageMap& langMap);
49
50   /// PopulateCompilationGraph - Populates the compilation graph by
51   /// calling PopulateCompilationGraph methods of all plugins.
52   void PopulateCompilationGraph(CompilationGraph& tools);
53
54 }
55
56 #endif // LLVM_TOOLS_LLVMC2_PLUGIN_H