1 //===--- Plugin.h - The LLVM Compiler Driver --------------------*- C++ -*-===//
3 // The LLVM Compiler Infrastructure
5 // This file is distributed under the University of Illinois Open
6 // Source License. See LICENSE.TXT for details.
8 //===----------------------------------------------------------------------===//
10 // Plugin support for llvmc.
12 //===----------------------------------------------------------------------===//
14 #ifndef LLVM_INCLUDE_COMPILER_DRIVER_PLUGIN_H
15 #define LLVM_INCLUDE_COMPILER_DRIVER_PLUGIN_H
17 #include "llvm/Support/Registry.h"
22 class CompilationGraph;
24 /// BasePlugin - An abstract base class for all LLVMC plugins.
27 /// Priority - Plugin priority, useful for handling dependencies
28 /// between plugins. Plugins with lower priorities are loaded
30 virtual int Priority() const { return 0; }
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;
36 /// PopulateCompilationGraph - The auto-generated function that
37 /// populates the compilation graph with nodes and edges.
38 virtual void PopulateCompilationGraph(CompilationGraph&) const = 0;
40 /// Needed to avoid a compiler warning.
41 virtual ~BasePlugin() {}
44 typedef llvm::Registry<BasePlugin> PluginRegistry;
48 : public PluginRegistry::Add<P> {
49 typedef PluginRegistry::Add<P> Base;
51 RegisterPlugin(const char* Name = "Nameless",
52 const char* Desc = "Auto-generated plugin")
57 /// PluginLoader - Helper class used by the main program for
58 /// lifetime management.
63 /// PopulateLanguageMap - Fills in the language map by calling
64 /// PopulateLanguageMap methods of all plugins.
65 void PopulateLanguageMap(LanguageMap& langMap);
67 /// PopulateCompilationGraph - Populates the compilation graph by
68 /// calling PopulateCompilationGraph methods of all plugins.
69 void PopulateCompilationGraph(CompilationGraph& tools);
73 PluginLoader(const PluginLoader& other);
74 const PluginLoader& operator=(const PluginLoader& other);
79 #endif // LLVM_INCLUDE_COMPILER_DRIVER_PLUGIN_H