aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--Makefile2
-rw-r--r--Makefile.rules74
-rw-r--r--autoconf/configure.ac31
-rw-r--r--include/llvm/CompilerDriver/AutoGenerated.h40
-rw-r--r--include/llvm/CompilerDriver/Common.td6
-rw-r--r--include/llvm/CompilerDriver/ForceLinkage.h122
-rw-r--r--include/llvm/CompilerDriver/ForceLinkageMacros.h29
-rw-r--r--include/llvm/CompilerDriver/Main.h21
-rw-r--r--include/llvm/CompilerDriver/Main.inc14
-rw-r--r--include/llvm/CompilerDriver/Plugin.h81
-rw-r--r--lib/CompilerDriver/Main.cpp13
-rw-r--r--lib/CompilerDriver/Makefile31
-rw-r--r--lib/CompilerDriver/Plugin.cpp83
-rw-r--r--tools/llvmc/CMakeLists.txt2
-rw-r--r--tools/llvmc/Makefile5
-rw-r--r--tools/llvmc/plugins/Base/Makefile15
-rw-r--r--tools/llvmc/plugins/Base/PluginMain.cpp1
-rw-r--r--tools/llvmc/plugins/Clang/Makefile15
-rw-r--r--tools/llvmc/plugins/Clang/PluginMain.cpp1
-rw-r--r--tools/llvmc/plugins/Makefile18
-rw-r--r--tools/llvmc/src/AutoGenerated.td17
-rw-r--r--tools/llvmc/src/Base.td.in (renamed from tools/llvmc/plugins/Base/Base.td.in)1
-rw-r--r--tools/llvmc/src/Clang.td (renamed from tools/llvmc/plugins/Clang/Clang.td)40
-rw-r--r--tools/llvmc/src/Hooks.cpp (renamed from tools/llvmc/plugins/Base/Hooks.cpp)0
-rw-r--r--tools/llvmc/src/Main.cpp (renamed from tools/llvmc/driver/Main.cpp)4
-rw-r--r--tools/llvmc/src/Makefile (renamed from tools/llvmc/driver/Makefile)3
-rw-r--r--utils/TableGen/LLVMCConfigurationEmitter.cpp148
27 files changed, 163 insertions, 654 deletions
diff --git a/Makefile b/Makefile
index d810b5f681..ae650b7f2d 100644
--- a/Makefile
+++ b/Makefile
@@ -170,7 +170,7 @@ FilesToConfig := \
include/llvm/Config/AsmParsers.def \
include/llvm/Config/Disassemblers.def \
include/llvm/System/DataTypes.h \
- tools/llvmc/plugins/Base/Base.td
+ tools/llvmc/src/Base.td
FilesToConfigPATH := $(addprefix $(LLVM_OBJ_ROOT)/,$(FilesToConfig))
all-local:: $(FilesToConfigPATH)
diff --git a/Makefile.rules b/Makefile.rules
index 056a0ea3ef..2e14094b3a 100644
--- a/Makefile.rules
+++ b/Makefile.rules
@@ -196,57 +196,15 @@ install-local:: all-local
install-bytecode:: install-bytecode-local
###############################################################################
-# LLVMC: Provide rules for compiling llvmc plugins
+# LLVMC: Provide rules for compiling llvmc-based driver
###############################################################################
-ifdef LLVMC_PLUGIN
-
-LIBRARYNAME := $(patsubst %,plugin_llvmc_%,$(LLVMC_PLUGIN))
-CPP.Flags += -DLLVMC_PLUGIN_NAME=$(LLVMC_PLUGIN)
-
-ifeq ($(ENABLE_LLVMC_DYNAMIC),1)
- LD.Flags += -lCompilerDriver
-endif
-
-# Build a dynamic library if the user runs `make` directly from the plugin
-# directory.
-ifndef LLVMC_BUILTIN_PLUGIN
- LOADABLE_MODULE = 1
-endif
-
-# TableGen stuff...
-ifneq ($(BUILT_SOURCES),)
- LLVMC_BUILD_AUTOGENERATED_INC=1
-endif
-
-endif # LLVMC_PLUGIN
-
ifdef LLVMC_BASED_DRIVER
TOOLNAME = $(LLVMC_BASED_DRIVER)
-ifeq ($(ENABLE_LLVMC_DYNAMIC),1)
- LD.Flags += -lCompilerDriver
-else
- LLVMLIBS = CompilerDriver.a
- LINK_COMPONENTS = support system
-endif
-
-# Preprocessor magic that generates references to static variables in built-in
-# plugins.
-ifneq ($(LLVMC_BUILTIN_PLUGINS),)
-
-USEDLIBS += $(patsubst %,plugin_llvmc_%.a,$(LLVMC_BUILTIN_PLUGINS))
-
-LLVMC_BUILTIN_PLUGINS.pre := \
- $(patsubst %,-DLLVMC_BUILTIN_PLUGIN_%=, \
- 1 2 3 4 5 6 7 8 9 10)
-
-CPP.Flags += \
- $(filter-out $(LLVMC_BUILTIN_PLUGINS.pre) $(LLVMC_BUILTIN_PLUGINS), \
- $(join $(LLVMC_BUILTIN_PLUGINS.pre), $(LLVMC_BUILTIN_PLUGINS)))
-
-endif
+LLVMLIBS = CompilerDriver.a
+LINK_COMPONENTS = support system
endif # LLVMC_BASED_DRIVER
@@ -1601,7 +1559,7 @@ ifdef TARGET
TABLEGEN_INC_FILES_COMMON = 1
endif
-ifdef LLVMC_BUILD_AUTOGENERATED_INC
+ifdef LLVMC_BASED_DRIVER
TABLEGEN_INC_FILES_COMMON = 1
endif
@@ -1725,20 +1683,26 @@ clean-local::
endif # TARGET
-ifdef LLVMC_BUILD_AUTOGENERATED_INC
+ifdef LLVMC_BASED_DRIVER
+
+TDSrc := $(sort $(strip $(wildcard $(PROJ_SRC_DIR)/*.td)) \
+ $(strip $(wildcard $(PROJ_OBJ_DIR)/*.td)))
-LLVMCPluginSrc := $(sort $(strip $(wildcard $(PROJ_SRC_DIR)/*.td)) \
- $(strip $(wildcard $(PROJ_OBJ_DIR)/*.td)))
+TDCommon := $(strip $(wildcard \
+ $(LLVM_SRC_ROOT)/include/llvm/CompilerDriver/*.td))
-TDFiles := $(LLVMCPluginSrc) \
- $(strip $(wildcard $(LLVM_SRC_ROOT)/include/llvm/CompilerDriver/*.td))
+TDFiles := $(TDSrc) $(TDCommon)
-$(ObjDir)/AutoGenerated.inc.tmp: $(LLVMCPluginSrc) $(ObjDir)/.dir \
- $(TBLGEN) $(TD_COMMON)
- $(Echo) "Building LLVMC configuration library with tblgen"
+$(INCTMPFiles) : $(TBLGEN) $(TDFiles)
+
+$(ObjDir)/%.inc.tmp: %.td $(ObjDir)/.dir
+ $(Echo) "Building LLVMC compilation graph description with tblgen"
$(Verb) $(TableGen) -gen-llvmc -o $(call SYSPATH, $@) $<
-endif # LLVMC_BUILD_AUTOGENERATED_INC
+clean-local::
+ -$(Verb) $(RM) -f $(INCFiles)
+
+endif # LLVMC_BASED_DRIVER
###############################################################################
# OTHER RULES: Other rules needed
diff --git a/autoconf/configure.ac b/autoconf/configure.ac
index 7211fe1972..8a42d32666 100644
--- a/autoconf/configure.ac
+++ b/autoconf/configure.ac
@@ -858,35 +858,6 @@ AC_ARG_ENABLE(libffi,AS_HELP_STRING(
esac],
llvm_cv_enable_libffi=no)
-dnl Only Windows needs dynamic libCompilerDriver to support plugins.
-if test "$llvm_cv_os_type" = "Win32" ; then
- llvmc_dynamic="yes"
-else
- llvmc_dynamic="no"
-fi
-
-dnl --enable-llvmc-dynamic : should LLVMC link libCompilerDriver dynamically?
-AC_ARG_ENABLE(llvmc-dynamic,AS_HELP_STRING(
---enable-llvmc-dynamic,
-[Link LLVMC dynamically (default is NO, unless on Win32)]),,
-enableval=$llvmc_dynamic)
-if test ${enableval} = "yes" && test "$ENABLE_PIC" -eq 1 ; then
- AC_SUBST(ENABLE_LLVMC_DYNAMIC,[[ENABLE_LLVMC_DYNAMIC=1]])
-else
- AC_SUBST(ENABLE_LLVMC_DYNAMIC,[[]])
-fi
-
-dnl --enable-llvmc-dynamic-plugins : should LLVMC support dynamic plugins?
-AC_ARG_ENABLE(llvmc-dynamic-plugins,AS_HELP_STRING(
---enable-llvmc-dynamic-plugins,
-[Enable dynamic LLVMC plugins (default is YES)]),,
-enableval=yes)
-if test ${enableval} = "yes" ; then
- AC_SUBST(ENABLE_LLVMC_DYNAMIC_PLUGINS,[[ENABLE_LLVMC_DYNAMIC_PLUGINS=1]])
-else
- AC_SUBST(ENABLE_LLVMC_DYNAMIC_PLUGINS,[[]])
-fi
-
dnl===-----------------------------------------------------------------------===
dnl===
dnl=== SECTION 4: Check for programs we need and that they are the right version
@@ -1601,7 +1572,7 @@ dnl Configure the RPM spec file for LLVM
AC_CONFIG_FILES([llvm.spec])
dnl Configure llvmc's Base plugin
-AC_CONFIG_FILES([tools/llvmc/plugins/Base/Base.td])
+AC_CONFIG_FILES([tools/llvmc/src/Base.td])
dnl Do the first stage of configuration for llvm-config.in.
AC_CONFIG_FILES([tools/llvm-config/llvm-config.in])
diff --git a/include/llvm/CompilerDriver/AutoGenerated.h b/include/llvm/CompilerDriver/AutoGenerated.h
new file mode 100644
index 0000000000..7b926c622c
--- /dev/null
+++ b/include/llvm/CompilerDriver/AutoGenerated.h
@@ -0,0 +1,40 @@
+//===--- AutoGenerated.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.
+//
+//===----------------------------------------------------------------------===//
+//
+// Interface to the autogenerated driver code.
+//
+//===----------------------------------------------------------------------===//
+
+#ifndef LLVM_INCLUDE_COMPILER_DRIVER_AUTOGENERATED_H
+#define LLVM_INCLUDE_COMPILER_DRIVER_AUTOGENERATED_H
+
+namespace llvmc {
+ class LanguageMap;
+ class CompilationGraph;
+
+ namespace autogenerated {
+
+ int PreprocessOptions();
+ int PopulateLanguageMap(LanguageMap& langMap);
+ int PopulateCompilationGraph(CompilationGraph& graph);
+
+ inline int RunInitialization (LanguageMap& M, CompilationGraph& G) {
+ if (int ret = PreprocessOptions())
+ return ret;
+ if (int ret = PopulateLanguageMap(M))
+ return ret;
+ if (int ret = PopulateCompilationGraph(G))
+ return ret;
+
+ return 0;
+ }
+ }
+}
+
+#endif // LLVM_INCLUDE_COMPILER_DRIVER_AUTOGENERATED_H
diff --git a/include/llvm/CompilerDriver/Common.td b/include/llvm/CompilerDriver/Common.td
index 6527ab5d4f..d378bb74d2 100644
--- a/include/llvm/CompilerDriver/Common.td
+++ b/include/llvm/CompilerDriver/Common.td
@@ -40,7 +40,6 @@ def prefix_list_option;
// Possible option properties.
-def extern;
def help;
def hidden;
def init;
@@ -101,11 +100,6 @@ def dec_weight;
// Empty DAG marker.
def empty_dag_marker;
-// Used to specify plugin priority.
-class PluginPriority<int p> {
- int priority = p;
-}
-
// Option list - a single place to specify options.
class OptionList<list<dag> l> {
list<dag> options = l;
diff --git a/include/llvm/CompilerDriver/ForceLinkage.h b/include/llvm/CompilerDriver/ForceLinkage.h
deleted file mode 100644
index 830c04e2d3..0000000000
--- a/include/llvm/CompilerDriver/ForceLinkage.h
+++ /dev/null
@@ -1,122 +0,0 @@
-//===--- ForceLinkage.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.
-//
-//===----------------------------------------------------------------------===//
-//
-// A bit of preprocessor magic to force references to static libraries. Needed
-// because plugin initialization is done via static variables.
-//
-//===----------------------------------------------------------------------===//
-
-#ifndef LLVM_INCLUDE_COMPILER_DRIVER_FORCE_LINKAGE_H
-#define LLVM_INCLUDE_COMPILER_DRIVER_FORCE_LINKAGE_H
-
-#include "llvm/CompilerDriver/ForceLinkageMacros.h"
-
-namespace llvmc {
-
-// Declare all ForceLinkage$(PluginName) functions.
-
-#ifdef LLVMC_BUILTIN_PLUGIN_1
- LLVMC_FORCE_LINKAGE_DECL(LLVMC_BUILTIN_PLUGIN_1);
-#endif
-
-#ifdef LLVMC_BUILTIN_PLUGIN_2
- LLVMC_FORCE_LINKAGE_DECL(LLVMC_BUILTIN_PLUGIN_2);
-#endif
-
-#ifdef LLVMC_BUILTIN_PLUGIN_3
- LLVMC_FORCE_LINKAGE_DECL(LLVMC_BUILTIN_PLUGIN_3);
-#endif
-
-#ifdef LLVMC_BUILTIN_PLUGIN_4
- LLVMC_FORCE_LINKAGE_DECL(LLVMC_BUILTIN_PLUGIN_4);
-#endif
-
-#ifdef LLVMC_BUILTIN_PLUGIN_5
- LLVMC_FORCE_LINKAGE_DECL(LLVMC_BUILTIN_PLUGIN_5);
-#endif
-
-#ifdef LLVMC_BUILTIN_PLUGIN_6
- LLVMC_FORCE_LINKAGE_DECL(LLVMC_BUILTIN_PLUGIN_6);
-#endif
-
-#ifdef LLVMC_BUILTIN_PLUGIN_7
- LLVMC_FORCE_LINKAGE_DECL(LLVMC_BUILTIN_PLUGIN_7);
-#endif
-
-#ifdef LLVMC_BUILTIN_PLUGIN_8
- LLVMC_FORCE_LINKAGE_DECL(LLVMC_BUILTIN_PLUGIN_8);
-#endif
-
-#ifdef LLVMC_BUILTIN_PLUGIN_9
- LLVMC_FORCE_LINKAGE_DECL(LLVMC_BUILTIN_PLUGIN_9);
-#endif
-
-#ifdef LLVMC_BUILTIN_PLUGIN_10
- LLVMC_FORCE_LINKAGE_DECL(LLVMC_BUILTIN_PLUGIN_10);
-#endif
-
-namespace force_linkage {
-
- struct LinkageForcer {
-
- LinkageForcer() {
-
-// Call all ForceLinkage$(PluginName) functions.
-#ifdef LLVMC_BUILTIN_PLUGIN_1
- LLVMC_FORCE_LINKAGE_CALL(LLVMC_BUILTIN_PLUGIN_1);
-#endif
-
-#ifdef LLVMC_BUILTIN_PLUGIN_2
- LLVMC_FORCE_LINKAGE_CALL(LLVMC_BUILTIN_PLUGIN_2);
-#endif
-
-#ifdef LLVMC_BUILTIN_PLUGIN_3
- LLVMC_FORCE_LINKAGE_CALL(LLVMC_BUILTIN_PLUGIN_3);
-#endif
-
-#ifdef LLVMC_BUILTIN_PLUGIN_4
- LLVMC_FORCE_LINKAGE_CALL(LLVMC_BUILTIN_PLUGIN_4);
-#endif
-
-#ifdef LLVMC_BUILTIN_PLUGIN_5
- LLVMC_FORCE_LINKAGE_CALL(LLVMC_BUILTIN_PLUGIN_5);
-#endif
-
-#ifdef LLVMC_BUILTIN_PLUGIN_6
- LLVMC_FORCE_LINKAGE_CALL(LLVMC_BUILTIN_PLUGIN_6);
-#endif
-
-#ifdef LLVMC_BUILTIN_PLUGIN_7
- LLVMC_FORCE_LINKAGE_CALL(LLVMC_BUILTIN_PLUGIN_7);
-#endif
-
-#ifdef LLVMC_BUILTIN_PLUGIN_8
- LLVMC_FORCE_LINKAGE_CALL(LLVMC_BUILTIN_PLUGIN_8);
-#endif
-
-#ifdef LLVMC_BUILTIN_PLUGIN_9
- LLVMC_FORCE_LINKAGE_CALL(LLVMC_BUILTIN_PLUGIN_9);
-#endif
-
-#ifdef LLVMC_BUILTIN_PLUGIN_10
- LLVMC_FORCE_LINKAGE_CALL(LLVMC_BUILTIN_PLUGIN_10);
-#endif
-
- }
- };
-} // End namespace force_linkage.
-
-// The only externally used bit.
-void ForceLinkage() {
- force_linkage::LinkageForcer dummy;
-}
-
-} // End namespace llvmc.
-
-#endif // LLVM_INCLUDE_COMPILER_DRIVER_FORCE_LINKAGE_H
diff --git a/include/llvm/CompilerDriver/ForceLinkageMacros.h b/include/llvm/CompilerDriver/ForceLinkageMacros.h
deleted file mode 100644
index 8862b00823..0000000000
--- a/include/llvm/CompilerDriver/ForceLinkageMacros.h
+++ /dev/null
@@ -1,29 +0,0 @@
-//===--- ForceLinkageMacros.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.
-//
-//===----------------------------------------------------------------------===//
-//
-// Preprocessor magic that forces references to static libraries - common
-// macros used by both driver and plugins.
-//
-//===----------------------------------------------------------------------===//
-
-#ifndef LLVM_INCLUDE_COMPILER_DRIVER_FORCE_LINKAGE_MACROS_H
-#define LLVM_INCLUDE_COMPILER_DRIVER_FORCE_LINKAGE_MACROS_H
-
-#define LLVMC_FORCE_LINKAGE_PREFIX(PluginName) ForceLinkage ## PluginName
-
-#define LLVMC_FORCE_LINKAGE_FUN(PluginName) \
- LLVMC_FORCE_LINKAGE_PREFIX(PluginName)
-
-#define LLVMC_FORCE_LINKAGE_DECL(PluginName) \
- void LLVMC_FORCE_LINKAGE_FUN(PluginName) ()
-
-#define LLVMC_FORCE_LINKAGE_CALL(PluginName) \
- LLVMC_FORCE_LINKAGE_FUN(PluginName) ()
-
-#endif // LLVM_INCLUDE_COMPILER_DRIVER_FORCE_LINKAGE_MACROS_H
diff --git a/include/llvm/CompilerDriver/Main.h b/include/llvm/CompilerDriver/Main.h
new file mode 100644
index 0000000000..d136a5d2fa
--- /dev/null
+++ b/include/llvm/CompilerDriver/Main.h
@@ -0,0 +1,21 @@
+//===--- Main.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.
+//
+//===----------------------------------------------------------------------===//
+//
+// Entry point for the driver executable.
+//
+//===----------------------------------------------------------------------===//
+
+#ifndef LLVM_INCLUDE_COMPILER_DRIVER_MAIN_H
+#define LLVM_INCLUDE_COMPILER_DRIVER_MAIN_H
+
+namespace llvmc {
+ int Main(int argc, char** argv);
+}
+
+#endif // LLVM_INCLUDE_COMPILER_DRIVER_MAIN_H
diff --git a/include/llvm/CompilerDriver/Main.inc b/include/llvm/CompilerDriver/Main.inc
index 71bb8cb3bf..41640437de 100644
--- a/include/llvm/CompilerDriver/Main.inc
+++ b/include/llvm/CompilerDriver/Main.inc
@@ -7,26 +7,16 @@
//
//===----------------------------------------------------------------------===//
//
-// This tool provides a single point of access to the LLVM
-// compilation tools. It has many options. To discover the options
-// supported please refer to the tools' manual page or run the tool
-// with the -help option.
-//
-// This file provides the default entry point for the driver executable.
+// Default main() for the driver executable.
//
//===----------------------------------------------------------------------===//
#ifndef LLVM_INCLUDE_COMPILER_DRIVER_MAIN_INC
#define LLVM_INCLUDE_COMPILER_DRIVER_MAIN_INC
-#include "llvm/CompilerDriver/ForceLinkage.h"
-
-namespace llvmc {
- int Main(int argc, char** argv);
-}
+#include "llvm/CompilerDriver/Main.h"
int main(int argc, char** argv) {
- llvmc::ForceLinkage();
return llvmc::Main(argc, argv);
}
diff --git a/include/llvm/CompilerDriver/Plugin.h b/include/llvm/CompilerDriver/Plugin.h
deleted file mode 100644
index 75fd9162df..0000000000
--- a/include/llvm/CompilerDriver/Plugin.h
+++ /dev/null
@@ -1,81 +0,0 @@
-//===--- 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.
-//
-//===----------------------------------------------------------------------===//
-//
-// Plugin support for llvmc.
-//
-//===----------------------------------------------------------------------===//
-
-#ifndef LLVM_INCLUDE_COMPILER_DRIVER_PLUGIN_H
-#define LLVM_INCLUDE_COMPILER_DRIVER_PLUGIN_H
-
-#include "llvm/Support/Registry.h"
-
-namespace llvmc {
-
- class LanguageMap;
- class CompilationGraph;
-
- /// BasePlugin - An abstract base class for all LLVMC plugins.
- struct BasePlugin {
-
- /// Priority - Plugin priority, useful for handling dependencies
- /// between plugins. Plugins with lower priorities are loaded
- /// first.
- virtual int Priority() const { return 0; }
-
- /// PreprocessOptions - The auto-generated function that performs various
- /// consistency checks on options (like ensuring that -O2 and -O3 are not
- /// used together).
- virtual int PreprocessOptions() const = 0;
-
- /// PopulateLanguageMap - The auto-generated function that fills in
- /// the language map (map from file extensions to language names).
- virtual int PopulateLanguageMap(LanguageMap&) const = 0;
-
- /// PopulateCompilationGraph - The auto-generated function that
- /// populates the compilation graph with nodes and edges.
- virtual int PopulateCompilationGraph(CompilationGraph&) const = 0;
-
- /// Needed to avoid a compiler warning.
- virtual ~BasePlugin() {}
- };
-
- typedef llvm::Registry<BasePlugin> PluginRegistry;
-
- 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) {}
- };
-
-
- /// PluginLoader - Helper class used by the main program for
- /// lifetime management.
- struct PluginLoader {
- PluginLoader();
- ~PluginLoader();
-
- /// RunInitialization - Calls PreprocessOptions, PopulateLanguageMap and
- /// PopulateCompilationGraph methods of all plugins. This populates the
- /// global language map and the compilation graph.
- int RunInitialization(LanguageMap& langMap, CompilationGraph& graph) const;
-
- private:
- // noncopyable
- PluginLoader(const PluginLoader& other);
- const PluginLoader& operator=(const PluginLoader& other);
- };
-
-}
-
-#endif // LLVM_INCLUDE_COMPILER_DRIVER_PLUGIN_H
diff --git a/lib/CompilerDriver/Main.cpp b/lib/CompilerDriver/Main.cpp
index 898f16d515..0a6613aa77 100644
--- a/lib/CompilerDriver/Main.cpp
+++ b/lib/CompilerDriver/Main.cpp
@@ -11,10 +11,10 @@
//
//===----------------------------------------------------------------------===//
+#include "llvm/CompilerDriver/AutoGenerated.h"
#include "llvm/CompilerDriver/BuiltinOptions.h"
#include "llvm/CompilerDriver/CompilationGraph.h"
#include "llvm/CompilerDriver/Error.h"
-#include "llvm/CompilerDriver/Plugin.h"
#include "llvm/Support/raw_ostream.h"
#include "llvm/System/Path.h"
@@ -62,7 +62,8 @@ namespace {
return 0;
}
- /// BuildTargets - A small wrapper for CompilationGraph::Build. Returns non-zero value
+ /// BuildTargets - A small wrapper for CompilationGraph::Build. Returns
+ /// non-zero value in case of error.
int BuildTargets(CompilationGraph& graph, const LanguageMap& langMap) {
int ret;
sys::Path tempDir;
@@ -87,7 +88,7 @@ void AppendToGlobalTimeLog(const std::string& cmd, double time) {
*GlobalTimeLog << "# " << cmd << ' ' << time << '\n';
}
-// Sometimes plugins want to condition on the value in argv[0].
+// Sometimes user code wants to access the argv[0] value.
const char* ProgramName;
int Main(int argc, char** argv) {
@@ -98,11 +99,11 @@ int Main(int argc, char** argv) {
ProgramName = argv[0];
cl::ParseCommandLineOptions
- (argc, argv, "LLVM Compiler Driver (Work In Progress)",
+ (argc, argv,
+ /* Overview = */ "LLVM Compiler Driver (Work In Progress)",
/* ReadResponseFiles = */ false);
- PluginLoader Plugins;
- if (int ret = Plugins.RunInitialization(langMap, graph))
+ if (int ret = autogenerated::RunInitialization(langMap, graph))
return ret;
if (CheckGraph) {
diff --git a/lib/CompilerDriver/Makefile b/lib/CompilerDriver/Makefile
index b829f5261c..69c3707780 100644
--- a/lib/CompilerDriver/Makefile
+++ b/lib/CompilerDriver/Makefile
@@ -12,34 +12,7 @@ LEVEL = ../..
# We don't want this library to appear in `llvm-config --libs` output, so its
# name doesn't start with "LLVM".
-ifeq ($(ENABLE_LLVMC_DYNAMIC),1)
- LIBRARYNAME = libCompilerDriver
- LLVMLIBS = LLVMSupport.a LLVMSystem.a
- LOADABLE_MODULE := 1
-else
- LIBRARYNAME = CompilerDriver
- LINK_COMPONENTS = support system
-endif
+LIBRARYNAME = CompilerDriver
+LINK_COMPONENTS = support system
include $(LEVEL)/Makefile.common
-
-ifeq ($(ENABLE_LLVMC_DYNAMIC_PLUGINS), 1)
- CPP.Flags += -DENABLE_LLVMC_DYNAMIC_PLUGINS
-endif
-
-# Copy libCompilerDriver to the bin dir so that llvmc can find it.
-ifeq ($(ENABLE_LLVMC_DYNAMIC),1)
-
-FullLibName = $(LIBRARYNAME)$(SHLIBEXT)
-
-all-local:: $(ToolDir)/$(FullLibName)
-
-$(ToolDir)/$(FullLibName): $(LibDir)/$(FullLibName) $(ToolDir)/.dir
- $(Echo) Copying $(BuildMode) Shared Library $(FullLibName) to $@
- -$(Verb) $(CP) $< $@
-
-clean-local::
- $(Echo) Removing $(BuildMode) Shared Library $(FullLibName) \
- from $(ToolDir)
- -$(Verb) $(RM) -f $(ToolDir)/$(FullLibName)
-endif
diff --git a/lib/CompilerDriver/Plugin.cpp b/lib/CompilerDriver/Plugin.cpp
deleted file mode 100644
index d520d4f05c..0000000000
--- a/lib/CompilerDriver/Plugin.cpp
+++ /dev/null
@@ -1,83 +0,0 @@
-//===--- Plugin.cpp - 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.
-//
-//===----------------------------------------------------------------------===//
-//
-// Plugin support.
-//
-//===----------------------------------------------------------------------===//
-
-#include "llvm/CompilerDriver/Plugin.h"
-#include "llvm/Support/ManagedStatic.h"
-#include "llvm/System/Mutex.h"
-#include <algorithm>
-#include <vector>
-
-namespace {
-
- // Registry::Add<> does not do lifetime management (probably issues
- // with static constructor/destructor ordering), so we have to
- // implement it here.
- //
- // All this static registration/life-before-main model seems
- // unnecessary convoluted to me.
-
- static bool pluginListInitialized = false;
- typedef std::vector<const llvmc::BasePlugin*> PluginList;
- static PluginList Plugins;
- static llvm::ManagedStatic<llvm::sys::SmartMutex<true> > PluginMutex;
-
- struct ByPriority {
- bool operator()(const llvmc::BasePlugin* lhs,
- const llvmc::BasePlugin* rhs) {
- return lhs->Priority() < rhs->Priority();
- }
- };
-}
-
-namespace llvmc {
-
- PluginLoader::PluginLoader() {
- llvm::sys::SmartScopedLock<true> Lock(*PluginMutex);
- if (!pluginListInitialized) {
- for (PluginRegistry::iterator B = PluginRegistry::begin(),
- E = PluginRegistry::end(); B != E; ++B)
- Plugins.push_back(B->instantiate());
- std::sort(Plugins.begin(), Plugins.end(), ByPriority());
- }
- pluginListInitialized = true;
- }
-
- PluginLoader::~PluginLoader() {
- llvm::sys::SmartScopedLock<true> Lock(*PluginMutex);
- if (pluginListInitialized) {
- for (PluginList::iterator B = Plugins.begin(), E = Plugins.end();
- B != E; ++B)
- delete (*B);
- }
- pluginListInitialized = false;
- }
-
- int PluginLoader::RunInitialization(LanguageMap& langMap,
- CompilationGraph& graph) const
- {
- llvm::sys::SmartScopedLock<true> Lock(*PluginMutex);
- for (PluginList::iterator B = Plugins.begin(), E = Plugins.end();
- B != E; ++B) {
- const BasePlugin* BP = *B;
- if (int ret = BP->PreprocessOptions())
- return ret;
- if (int ret = BP->PopulateLanguageMap(langMap))
- return ret;
- if (int ret = BP->PopulateCompilationGraph(graph))
- return ret;
- }
-
- return 0;
- }
-
-}
diff --git a/tools/llvmc/CMakeLists.txt b/tools/llvmc/CMakeLists.txt
index bebaaebca8..10ad5d8200 100644
--- a/tools/llvmc/CMakeLists.txt
+++ b/tools/llvmc/CMakeLists.txt
@@ -1,4 +1,4 @@
-# add_subdirectory(driver)
+# add_subdirectory(src)
# TODO: support plugins and user-configured builds.
# See ./doc/LLVMC-Reference.rst "Customizing LLVMC: the compilation graph"
diff --git a/tools/llvmc/Makefile b/tools/llvmc/Makefile
index df91728ea3..9bcb96c954 100644
--- a/tools/llvmc/Makefile
+++ b/tools/llvmc/Makefile
@@ -9,9 +9,6 @@
LEVEL = ../..
-export LLVMC_BASED_DRIVER_NAME = llvmc
-export LLVMC_BUILTIN_PLUGINS = Base Clang
-
-DIRS = plugins driver
+DIRS = src
include $(LEVEL)/Makefile.common
diff --git a/tools/llvmc/plugins/Base/Makefile b/tools/llvmc/plugins/Base/Makefile
deleted file mode 100644
index ebc4335054..0000000000
--- a/tools/llvmc/plugins/Base/Makefile
+++ /dev/null
@@ -1,15 +0,0 @@
-##===- tools/llvmc/plugins/Base/Makefile -------------------*- Makefile -*-===##
-#
-# The LLVM Compiler Infrastructure
-#
-# This file is distributed under the University of Illinois Open Source
-# License. See LICENSE.TXT for details.
-#
-##===----------------------------------------------------------------------===##
-
-LEVEL = ../../../..
-
-LLVMC_PLUGIN = Base
-BUILT_SOURCES = AutoGenerated.inc
-
-include $(LEVEL)/Makefile.common
diff --git a/tools/llvmc/plugins/Base/PluginMain.cpp b/tools/llvmc/plugins/Base/PluginMain.cpp
deleted file mode 100644
index add8acb4a5..0000000000
--- a/tools/llvmc/plugins/Base/PluginMain.cpp
+++ /dev/null
@@ -1 +0,0 @@
-#include "AutoGenerated.inc"
diff --git a/tools/llvmc/plugins/Clang/Makefile b/tools/llvmc/plugins/Clang/Makefile
deleted file mode 100644
index 5e5b88a44b..0000000000
--- a/tools/llvmc/plugins/Clang/Makefile
+++ /dev/null
@@ -1,15 +0,0 @@
-##===- tools/llvmc/plugins/Clang/Makefile ------------------*- Makefile -*-===##
-#
-# The LLVM Compiler Infrastructure
-#
-# This file is distributed under the University of Illinois Open Source
-# License. See LICENSE.TXT for details.
-#
-##===----------------------------------------------------------------------===##
-
-LEVEL = ../../../..
-
-LLVMC_PLUGIN = Clang
-BUILT_SOURCES = AutoGenerated.inc
-
-include $(LEVEL)/Makefile.common
diff --git a/tools/llvmc/plugins/Clang/PluginMain.cpp b/tools/llvmc/plugins/Clang/PluginMain.cpp
deleted file mode 100644
index add8acb4a5..0000000000
--- a/tools/llvmc/plugins/Clang/PluginMain.cpp
+++ /dev/null
@@ -1 +0,0 @@
-#include "AutoGenerated.inc"
diff --git a/tools/llvmc/plugins/Makefile b/tools/llvmc/plugins/Makefile
deleted file mode 100644
index 37dac6f0ac..0000000000
--- a/tools/llvmc/plugins/Makefile
+++ /dev/null
@@ -1,18 +0,0 @@
-##===- tools/llvmc/plugins/Makefile ------------------------*- Makefile -*-===##
-#
-# The LLVM Compiler Infrastructure
-#
-# This file is distributed under the University of Illinois Open
-# Source License. See LICENSE.TXT for details.
-#
-##===----------------------------------------------------------------------===##
-
-LEVEL = ../../..
-
-ifneq ($(LLVMC_BUILTIN_PLUGINS),)
-DIRS = $(LLVMC_BUILTIN_PLUGINS)
-endif
-
-export LLVMC_BUILTIN_PLUGIN=1
-
-include $(LEVEL)/Makefile.common
diff --git a/tools/llvmc/src/AutoGenerated.td b/tools/llvmc/src/AutoGenerated.td
new file mode 100644
index 0000000000..8507b1ff22
--- /dev/null
+++ b/tools/llvmc/src/AutoGenerated.td
@@ -0,0 +1,17 @@
+//===- AutoGenerated.td - LLVMC toolchain descriptions -----*- tablegen -*-===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+//
+// This file contains compilation graph description used by llvmc.
+//
+//===----------------------------------------------------------------------===//
+
+include "llvm/CompilerDriver/Common.td"
+
+include "Base.td"
+include "Clang.td"
diff --git a/tools/llvmc/plugins/Base/Base.td.in b/tools/llvmc/src/Base.td.in
index a042997e10..45b60b735b 100644
--- a/tools/llvmc/plugins/Base/Base.td.in
+++ b/tools/llvmc/src/Base.td.in
@@ -11,7 +11,6 @@
//
//===----------------------------------------------------------------------===//
-include "llvm/CompilerDriver/Common.td"
// Options
diff --git a/tools/llvmc/plugins/Clang/Clang.td b/tools/llvmc/src/Clang.td
index 988d9b1c8a..c8c396e6ed 100644
--- a/tools/llvmc/plugins/Clang/Clang.td
+++ b/tools/llvmc/src/Clang.td
@@ -1,22 +1,18 @@
-include "llvm/CompilerDriver/Common.td"
+//===- Clang.td - LLVMC toolchain descriptions -------------*- tablegen -*-===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+//
+// This file contains compilation graph description used by llvmc.
+//
+//===----------------------------------------------------------------------===//
-def Priority : PluginPriority<1>;
def Options : OptionList<[
-// Extern options
-(switch_option "E", (extern)),
-(switch_option "S", (extern)),
-(switch_option "c", (extern)),
-(switch_option "fsyntax-only", (extern)),
-(switch_option "emit-llvm", (extern)),
-(switch_option "pthread", (extern)),
-(parameter_list_option "I", (extern)),
-(parameter_list_option "include", (extern)),
-(parameter_list_option "L", (extern)),
-(parameter_list_option "l", (extern)),
-(prefix_list_option "Wa,", (extern)),
-(prefix_list_option "Wl,", (extern)),
-
(switch_option "clang", (help "Use Clang instead of llvm-gcc"))
]>;
@@ -71,19 +67,9 @@ def llvm_ld : Tool<
(join)
]>;
-// Language map
-
-def LanguageMap : LanguageMap<[
- LangToSuffixes<"c++", ["cc", "cp", "cxx", "cpp", "CPP", "c++", "C"]>,
- LangToSuffixes<"c", ["c"]>,
- LangToSuffixes<"objective-c", ["m"]>,
- LangToSuffixes<"c-cpp-output", ["i"]>,
- LangToSuffixes<"objective-c-cpp-output", ["mi"]>
-]>;
-
// Compilation graph
-def CompilationGraph : CompilationGraph<[
+def ClangCompilationGraph : CompilationGraph<[
OptionalEdge<"root", "clang_c",
(case (switch_on "clang"), (inc_weight))>,
OptionalEdge<"root", "clang_cpp",
diff --git a/tools/llvmc/plugins/Base/Hooks.cpp b/tools/llvmc/src/Hooks.cpp
index 661a914489..661a914489 100644
--- a/tools/llvmc/plugins/Base/Hooks.cpp
+++ b/tools/llvmc/src/Hooks.cpp
diff --git a/tools/llvmc/driver/Main.cpp b/tools/llvmc/src/Main.cpp
index b1f5b6798a..9f9c71aa8c 100644
--- a/tools/llvmc/driver/Main.cpp
+++ b/tools/llvmc/src/Main.cpp
@@ -7,8 +7,10 @@
//
//===----------------------------------------------------------------------===//
//
-// Just include CompilerDriver/Main.inc.
+// Just include AutoGenerated.inc and CompilerDriver/Main.inc.
//
//===----------------------------------------------------------------------===//
+#include "AutoGenerated.inc"
+
#include "llvm/CompilerDriver/Main.inc"
diff --git a/tools/llvmc/driver/Makefile b/tools/llvmc/src/Makefile
index 2f3104b408..9cfb27f809 100644
--- a/tools/llvmc/driver/Makefile
+++ b/tools/llvmc/src/Makefile
@@ -8,6 +8,7 @@
##===----------------------------------------------------------------------===##
LEVEL = ../../..
-LLVMC_BASED_DRIVER = $(LLVMC_BASED_DRIVER_NAME)
+LLVMC_BASED_DRIVER = llvmc
+BUILT_SOURCES = AutoGenerated.inc
include $(LEVEL)/Makefile.common
diff --git a/utils/TableGen/LLVMCConfigurationEmitter.cpp b/utils/TableGen/LLVMCConfigurationEmitter.cpp
index 7a68d696f9..2d44550782 100644
--- a/utils/TableGen/LLVMCConfigurationEmitter.cpp
+++ b/utils/TableGen/LLVMCConfigurationEmitter.cpp
@@ -234,10 +234,9 @@ OptionType::OptionType stringToOptionType(const std::string& T) {
namespace OptionDescriptionFlags {
enum OptionDescriptionFlags { Required = 0x1, Hidden = 0x2,
- ReallyHidden = 0x4, Extern = 0x8,
- OneOrMore = 0x10, Optional = 0x20,
- CommaSeparated = 0x40, ForwardNotSplit = 0x80,
- ZeroOrMore = 0x100 };
+ ReallyHidden = 0x4, OneOrMore = 0x8,
+ Optional = 0x10, CommaSeparated = 0x20,
+ ForwardNotSplit = 0x40, ZeroOrMore = 0x80 };
}
/// OptionDescription - Represents data contained in a single
@@ -279,9 +278,6 @@ struct OptionDescription {
bool isCommaSeparated() const;
void setCommaSeparated();
- bool isExtern() const;
- void setExtern();
-
bool isForwardNotSplit() const;
void setForwardNotSplit();
@@ -372,13 +368,6 @@ void OptionDescription::setForwardNotSplit() {
Flags |= OptionDescriptionFlags::ForwardNotSplit;
}
-bool OptionDescription::isExtern() const {
- return Flags & OptionDescriptionFlags::Extern;
-}
-void OptionDescription::setExtern() {
- Flags |= OptionDescriptionFlags::Extern;
-}
-
bool OptionDescription::isRequired() const {
return Flags & OptionDescriptionFlags::Required;
}
@@ -653,7 +642,6 @@ public:
: optDesc_(OD)
{
if (!staticMembersInitialized_) {
- AddHandler("extern", &CollectOptionProperties::onExtern);
AddHandler("help", &CollectOptionProperties::onHelp);
AddHandler("hidden", &CollectOptionProperties::onHidden);
AddHandler("init", &CollectOptionProperties::onInit);
@@ -682,11 +670,6 @@ private:
/// Option property handlers --
/// Methods that handle option properties such as (help) or (hidden).
- void onExtern (const DagInit& d) {
- CheckNumberOfArguments(d, 0);
- optDesc_.setExtern();
- }
-
void onHelp (const DagInit& d) {
CheckNumberOfArguments(d, 1);
optDesc_.Help = EscapeQuotes(InitPtrToString(d.getArg(0)));
@@ -799,16 +782,17 @@ public:
OptionDescription OD(Type, Name);
- if (!OD.isExtern())
- CheckNumberOfArguments(d, 2);
+
+ CheckNumberOfArguments(d, 2);
if (OD.isAlias()) {
// Aliases store the aliased option name in the 'Help' field.
OD.Help = InitPtrToString(d.getArg(1));
}
- else if (!OD.isExtern()) {
+ else {
processOptionProperties(d, OD);
}
+
OptDescs_.InsertDescription(OD);
}
@@ -1043,22 +1027,6 @@ void FillInEdgeVector(RecordVector::const_iterator B,
}
}
-/// CalculatePriority - Calculate the priority of this plugin.
-int CalculatePriority(RecordVector::const_iterator B,
- RecordVector::const_iterator E) {
- int priority = 0;
-
- if (B != E) {
- priority = static_cast<int>((*B)->getValueAsInt("priority"));
-
- if (++B != E)
- throw "More than one 'PluginPriority' instance found: "
- "most probably an error!";
- }
-
- return priority;
-}
-
/// NotInGraph - Helper function object for FilterNotInGraph.
struct NotInGraph {
private:
@@ -2382,8 +2350,7 @@ void EmitToolClassDefinition (const ToolDescription& D,
/// EmitOptionDefinitions - Iterate over a list of option descriptions
/// and emit registration code.
void EmitOptionDefinitions (const OptionDescriptions& descs,
- bool HasSink, bool HasExterns,
- raw_ostream& O)
+ bool HasSink, raw_ostream& O)
{
std::vector<OptionDescription> Aliases;
@@ -2397,17 +2364,9 @@ void EmitOptionDefinitions (const OptionDescriptions& descs,
continue;
}
- if (val.isExtern())
- O << "extern ";
-
O << val.GenTypeDeclaration() << ' '
<< val.GenVariableName();
- if (val.isExtern()) {
- O << ";\n";
- continue;
- }
-
O << "(\"" << val.Name << "\"\n";
if (val.Type == OptionType::Prefix || val.Type == OptionType::PrefixList)
@@ -2468,9 +2427,7 @@ void EmitOptionDefinitions (const OptionDescriptions& descs,
// Emit the sink option.
if (HasSink)
- O << (HasExterns ? "extern cl" : "cl")
- << "::list<std::string> " << SinkOptionName
- << (HasExterns ? ";\n" : "(cl::Sink);\n");
+ O << "cl" << "::list<std::string> " << SinkOptionName << "(cl::Sink);\n";
O << '\n';
}
@@ -2629,11 +2586,11 @@ public:
};
-/// EmitPreprocessOptions - Emit the PreprocessOptionsLocal() function.
+/// EmitPreprocessOptions - Emit the PreprocessOptions() function.
void EmitPreprocessOptions (const RecordKeeper& Records,
const OptionDescriptions& OptDecs, raw_ostream& O)
{
- O << "int PreprocessOptionsLocal() {\n";
+ O << "int PreprocessOptions () {\n";
const RecordVector& OptionPreprocessors =
Records.getAllDerivedDefinitions("OptionPreprocessor");
@@ -2651,12 +2608,13 @@ void EmitPreprocessOptions (const RecordKeeper& Records,
O << "}\n\n";
}
-/// EmitPopulateLanguageMap - Emit the PopulateLanguageMapLocal() function.
+/// EmitPopulateLanguageMap - Emit the PopulateLanguageMap() function.
void EmitPopulateLanguageMap (const RecordKeeper& Records, raw_ostream& O)
{
- O << "int PopulateLanguageMapLocal(LanguageMap& langMap) {\n";
+ O << "int PopulateLanguageMap (LanguageMap& langMap) {\n";
// Get the relevant field out of RecordKeeper
+ // TODO: change this to getAllDerivedDefinitions.
const Record* LangMapRecord = Records.getDef("LanguageMap");
// It is allowed for a plugin to have no language map.
@@ -2758,13 +2716,12 @@ void EmitEdgeClasses (const RecordVector& EdgeVector,
}
}
-/// EmitPopulateCompilationGraph - Emit the PopulateCompilationGraphLocal()
-/// function.
+/// EmitPopulateCompilationGraph - Emit the PopulateCompilationGraph() function.
void EmitPopulateCompilationGraph (const RecordVector& EdgeVector,
const ToolDescriptions& ToolDescs,
raw_ostream& O)
{
- O << "int PopulateCompilationGraphLocal(CompilationGraph& G) {\n";
+ O << "int PopulateCompilationGraph (CompilationGraph& G) {\n";
for (ToolDescriptions::const_iterator B = ToolDescs.begin(),
E = ToolDescs.end(); B != E; ++B)
@@ -2974,30 +2931,12 @@ void EmitHookDeclarations(const ToolDescriptions& ToolDescs,
O << "}\n\n";
}
-/// EmitRegisterPlugin - Emit code to register this plugin.
-void EmitRegisterPlugin(int Priority, raw_ostream& O) {
- O << "struct Plugin : public llvmc::BasePlugin {\n\n";
- O.indent(Indent1) << "int Priority() const { return "
- << Priority << "; }\n\n";
- O.indent(Indent1) << "int PreprocessOptions() const\n";
- O.indent(Indent1) << "{ return PreprocessOptionsLocal(); }\n\n";
- O.indent(Indent1) << "int PopulateLanguageMap(LanguageMap& langMap) const\n";
- O.indent(Indent1) << "{ return PopulateLanguageMapLocal(langMap); }\n\n";
- O.indent(Indent1)
- << "int PopulateCompilationGraph(CompilationGraph& graph) const\n";
- O.indent(Indent1) << "{ return PopulateCompilationGraphLocal(graph); }\n"
- << "};\n\n"
- << "static llvmc::RegisterPlugin<Plugin> RP;\n\n";
-}
-
/// EmitIncludes - Emit necessary #include directives and some
/// additional declarations.
void EmitIncludes(raw_ostream& O) {
O << "#include \"llvm/CompilerDriver/BuiltinOptions.h\"\n"
<< "#include \"llvm/CompilerDriver/CompilationGraph.h\"\n"
<< "#include \"llvm/CompilerDriver/Error.h\"\n"
- << "#include \"llvm/CompilerDriver/ForceLinkageMacros.h\"\n"
- << "#include \"llvm/CompilerDriver/Plugin.h\"\n"
<< "#include \"llvm/CompilerDriver/Tool.h\"\n\n"
<< "#include \"llvm/Support/CommandLine.h\"\n"
@@ -3022,10 +2961,8 @@ void EmitIncludes(raw_ostream& O) {
struct PluginData {
OptionDescriptions OptDescs;
bool HasSink;
- bool HasExterns;
ToolDescriptions ToolDescs;
RecordVector Edges;
- int Priority;
};
/// HasSink - Go through the list of tool descriptions and check if
@@ -3039,19 +2976,8 @@ bool HasSink(const ToolDescriptions& ToolDescs) {
return false;
}
-/// HasExterns - Go through the list of option descriptions and check
-/// if there are any external options.
-bool HasExterns(const OptionDescriptions& OptDescs) {
- for (OptionDescriptions::const_iterator B = OptDescs.begin(),
- E = OptDescs.end(); B != E; ++B)
- if (B->second.isExtern())
- return true;
-
- return false;
-}
-
-/// CollectPluginData - Collect tool and option properties,
-/// compilation graph edges and plugin priority from the parse tree.
+/// CollectPluginData - Collect compilation graph edges, tool properties and
+/// option properties from the parse tree.
void CollectPluginData (const RecordKeeper& Records, PluginData& Data) {
// Collect option properties.
const RecordVector& OptionLists =
@@ -3063,18 +2989,12 @@ void CollectPluginData (const RecordKeeper& Records, PluginData& Data) {
const RecordVector& Tools = Records.getAllDerivedDefinitions("Tool");
CollectToolDescriptions(Tools.begin(), Tools.end(), Data.ToolDescs);
Data.HasSink = HasSink(Data.ToolDescs);
- Data.HasExterns = HasExterns(Data.OptDescs);
// Collect compilation graph edges.
const RecordVector& CompilationGraphs =
Records.getAllDerivedDefinitions("CompilationGraph");
FillInEdgeVector(CompilationGraphs.begin(), CompilationGraphs.end(),
Data.Edges);
-
- // Calculate the priority of this plugin.
- const RecordVector& Priorities =
- Records.getAllDerivedDefinitions("PluginPriority");
- Data.Priority = CalculatePriority(Priorities.begin(), Priorities.end());
}
/// CheckPluginData - Perform some sanity checks on the collected data.
@@ -3095,20 +3015,13 @@ void EmitPluginCode(const PluginData& Data, raw_ostream& O) {
EmitIncludes(O);
// Emit global option registration code.
- EmitOptionDefinitions(Data.OptDescs, Data.HasSink, Data.HasExterns, O);
+ EmitOptionDefinitions(Data.OptDescs, Data.HasSink, O);
// Emit hook declarations.
EmitHookDeclarations(Data.ToolDescs, Data.OptDescs, O);
O << "namespace {\n\n";
- // Emit PreprocessOptionsLocal() function.
- EmitPreprocessOptions(Records, Data.OptDescs, O);
-
- // Emit PopulateLanguageMapLocal() function
- // (language map maps from file extensions to language names).
- EmitPopulateLanguageMap(Records, O);
-
// Emit Tool classes.
for (ToolDescriptions::const_iterator B = Data.ToolDescs.begin(),
E = Data.ToolDescs.end(); B!=E; ++B)
@@ -3117,18 +3030,23 @@ void EmitPluginCode(const PluginData& Data, raw_ostream& O) {
// Emit Edge# classes.
EmitEdgeClasses(Data.Edges, Data.OptDescs, O);
- // Emit PopulateCompilationGraphLocal() function.
- EmitPopulateCompilationGraph(Data.Edges, Data.ToolDescs, O);
-
- // Emit code for plugin registration.
- EmitRegisterPlugin(Data.Priority, O);
-
O << "} // End anonymous namespace.\n\n";
- // Force linkage magic.
O << "namespace llvmc {\n";
- O << "LLVMC_FORCE_LINKAGE_DECL(LLVMC_PLUGIN_NAME) {}\n";
- O << "}\n";
+ O << "namespace autogenerated {\n\n";
+
+ // Emit PreprocessOptions() function.
+ EmitPreprocessOptions(Records, Data.OptDescs, O);
+
+ // Emit PopulateLanguageMap() function
+ // (language map maps from file extensions to language names).
+ EmitPopulateLanguageMap(Records, O);
+
+ // Emit PopulateCompilationGraph() function.
+ EmitPopulateCompilationGraph(Data.Edges, Data.ToolDescs, O);
+
+ O << "} // End namespace autogenerated.\n";
+ O << "} // End namespace llvmc.\n\n";
// EOF
}