2008-09-22 20:49:34 +00:00
|
|
|
//===--- Plugin.h - The LLVM Compiler Driver --------------------*- C++ -*-===//
|
|
|
|
//
|
|
|
|
// The LLVM Compiler Infrastructure
|
|
|
|
//
|
|
|
|
// This file is distributed under the University of Illinois Open
|
|
|
|
// Source License. See LICENSE.TXT for details.
|
|
|
|
//
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
//
|
2009-03-02 09:02:28 +00:00
|
|
|
// Plugin support for llvmc.
|
2008-09-22 20:49:34 +00:00
|
|
|
//
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
|
2009-03-02 09:02:28 +00:00
|
|
|
#ifndef LLVM_INCLUDE_COMPILER_DRIVER_PLUGIN_H
|
|
|
|
#define LLVM_INCLUDE_COMPILER_DRIVER_PLUGIN_H
|
2008-09-22 20:49:34 +00:00
|
|
|
|
2008-09-22 20:51:19 +00:00
|
|
|
#include "llvm/Support/Registry.h"
|
|
|
|
|
2008-09-22 20:49:34 +00:00
|
|
|
namespace llvmc {
|
|
|
|
|
|
|
|
class LanguageMap;
|
|
|
|
class CompilationGraph;
|
|
|
|
|
|
|
|
/// BasePlugin - An abstract base class for all LLVMC plugins.
|
|
|
|
struct BasePlugin {
|
|
|
|
|
2008-11-17 17:30:25 +00:00
|
|
|
/// Priority - Plugin priority, useful for handling dependencies
|
|
|
|
/// between plugins. Plugins with lower priorities are loaded
|
|
|
|
/// first.
|
2009-03-02 09:02:01 +00:00
|
|
|
virtual int Priority() const { return 0; }
|
2008-11-17 17:30:25 +00:00
|
|
|
|
2009-10-17 20:09:29 +00:00
|
|
|
/// PreprocessOptions - The auto-generated function that performs various
|
|
|
|
/// consistency checks on options (like ensuring that -O2 and -O3 are not
|
|
|
|
/// used together).
|
|
|
|
virtual void PreprocessOptions() const = 0;
|
|
|
|
|
2008-09-22 20:49:34 +00:00
|
|
|
/// PopulateLanguageMap - The auto-generated function that fills in
|
|
|
|
/// the language map (map from file extensions to language names).
|
|
|
|
virtual void PopulateLanguageMap(LanguageMap&) const = 0;
|
|
|
|
|
|
|
|
/// PopulateCompilationGraph - The auto-generated function that
|
|
|
|
/// populates the compilation graph with nodes and edges.
|
|
|
|
virtual void PopulateCompilationGraph(CompilationGraph&) const = 0;
|
2008-09-22 22:33:34 +00:00
|
|
|
|
|
|
|
/// Needed to avoid a compiler warning.
|
2008-09-22 23:28:18 +00:00
|
|
|
virtual ~BasePlugin() {}
|
2008-09-22 20:49:34 +00:00
|
|
|
};
|
|
|
|
|
2008-09-22 20:51:19 +00:00
|
|
|
typedef llvm::Registry<BasePlugin> PluginRegistry;
|
2008-09-22 20:49:34 +00:00
|
|
|
|
2008-09-22 20:51:19 +00:00
|
|
|
template <class P>
|
|
|
|
struct RegisterPlugin
|
|
|
|
: public PluginRegistry::Add<P> {
|
|
|
|
typedef PluginRegistry::Add<P> Base;
|
|
|
|
|
|
|
|
RegisterPlugin(const char* Name = "Nameless",
|
|
|
|
const char* Desc = "Auto-generated plugin")
|
|
|
|
: Base(Name, Desc) {}
|
2008-09-22 20:49:34 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
|
2008-09-22 20:51:19 +00:00
|
|
|
/// PluginLoader - Helper class used by the main program for
|
|
|
|
/// lifetime management.
|
|
|
|
struct PluginLoader {
|
|
|
|
PluginLoader();
|
|
|
|
~PluginLoader();
|
|
|
|
|
2009-10-17 20:09:29 +00:00
|
|
|
/// RunInitialization - Calls PreprocessOptions, PopulateLanguageMap and
|
|
|
|
/// PopulateCompilationGraph methods of all plugins. This populates the
|
|
|
|
/// global language map and the compilation graph.
|
|
|
|
void RunInitialization(LanguageMap& langMap, CompilationGraph& graph) const;
|
2008-09-22 20:51:19 +00:00
|
|
|
|
|
|
|
private:
|
|
|
|
// noncopyable
|
|
|
|
PluginLoader(const PluginLoader& other);
|
|
|
|
const PluginLoader& operator=(const PluginLoader& other);
|
|
|
|
};
|
2008-09-22 20:49:34 +00:00
|
|
|
|
|
|
|
}
|
|
|
|
|
2009-03-02 09:02:28 +00:00
|
|
|
#endif // LLVM_INCLUDE_COMPILER_DRIVER_PLUGIN_H
|