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
/// PreprocessOptions - The auto-generated function that performs various
33
/// consistency checks on options (like ensuring that -O2 and -O3 are not
35
virtual void PreprocessOptions() const = 0;
37
/// PopulateLanguageMap - The auto-generated function that fills in
38
/// the language map (map from file extensions to language names).
39
virtual void PopulateLanguageMap(LanguageMap&) const = 0;
41
/// PopulateCompilationGraph - The auto-generated function that
42
/// populates the compilation graph with nodes and edges.
43
virtual void PopulateCompilationGraph(CompilationGraph&) const = 0;
45
/// Needed to avoid a compiler warning.
46
virtual ~BasePlugin() {}
49
typedef llvm::Registry<BasePlugin> PluginRegistry;
53
: public PluginRegistry::Add<P> {
54
typedef PluginRegistry::Add<P> Base;
56
RegisterPlugin(const char* Name = "Nameless",
57
const char* Desc = "Auto-generated plugin")
62
/// PluginLoader - Helper class used by the main program for
63
/// lifetime management.
68
/// RunInitialization - Calls PreprocessOptions, PopulateLanguageMap and
69
/// PopulateCompilationGraph methods of all plugins. This populates the
70
/// global language map and the compilation graph.
71
void RunInitialization(LanguageMap& langMap, CompilationGraph& graph) const;
75
PluginLoader(const PluginLoader& other);
76
const PluginLoader& operator=(const PluginLoader& other);
81
#endif // LLVM_INCLUDE_COMPILER_DRIVER_PLUGIN_H