summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMikhail Glushenkov <foldr@codedgers.com>2009-03-02 09:01:14 +0000
committerMikhail Glushenkov <foldr@codedgers.com>2009-03-02 09:01:14 +0000
commitf188178a2f8e6452d3e161acdad9a79e1f36c43f (patch)
treede8d87fb2706a89f24bc57ce512955909645eecc
parent99dac47b0abfaf40c36822a11310b43e95654e50 (diff)
downloadllvm-f188178a2f8e6452d3e161acdad9a79e1f36c43f.tar.gz
llvm-f188178a2f8e6452d3e161acdad9a79e1f36c43f.tar.bz2
llvm-f188178a2f8e6452d3e161acdad9a79e1f36c43f.tar.xz
Reorganize llvmc code.
Move the code from 'llvmc/driver' into a new CompilerDriver library, and change the build system accordingly. Makes it easier for projects using LLVM to build their own llvmc-based drivers. Tested with objdir != srcdir. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@65821 91177308-0d34-0410-b5e6-96231b3b80d8
-rw-r--r--include/llvm/CompilerDriver/Error.h (renamed from tools/llvmc/driver/Error.h)0
-rw-r--r--lib/CompilerDriver/Action.cpp (renamed from tools/llvmc/driver/Action.cpp)0
-rw-r--r--lib/CompilerDriver/CMakeLists.txt (renamed from tools/llvmc/driver/CMakeLists.txt)0
-rw-r--r--lib/CompilerDriver/CompilationGraph.cpp (renamed from tools/llvmc/driver/CompilationGraph.cpp)2
-rw-r--r--lib/CompilerDriver/Makefile19
-rw-r--r--lib/CompilerDriver/Plugin.cpp (renamed from tools/llvmc/driver/Plugin.cpp)0
-rw-r--r--lib/CompilerDriver/Tool.cpp (renamed from tools/llvmc/driver/Tool.cpp)0
-rw-r--r--lib/Makefile2
-rw-r--r--tools/llvmc/CMakeLists.txt2
-rw-r--r--tools/llvmc/Makefile11
-rw-r--r--tools/llvmc/Makefile.llvmc49
-rw-r--r--tools/llvmc/driver/Main.cpp (renamed from tools/llvmc/driver/llvmc.cpp)5
-rw-r--r--tools/llvmc/driver/Makefile13
-rw-r--r--tools/llvmc/plugins/Base/Makefile4
-rw-r--r--tools/llvmc/plugins/Clang/Makefile4
-rw-r--r--tools/llvmc/plugins/Hello/Makefile4
-rw-r--r--tools/llvmc/plugins/Makefile45
-rw-r--r--tools/llvmc/plugins/Simple/Makefile4
18 files changed, 103 insertions, 61 deletions
diff --git a/tools/llvmc/driver/Error.h b/include/llvm/CompilerDriver/Error.h
index c0aaff1a72..c0aaff1a72 100644
--- a/tools/llvmc/driver/Error.h
+++ b/include/llvm/CompilerDriver/Error.h
diff --git a/tools/llvmc/driver/Action.cpp b/lib/CompilerDriver/Action.cpp
index c0a1b849bc..c0a1b849bc 100644
--- a/tools/llvmc/driver/Action.cpp
+++ b/lib/CompilerDriver/Action.cpp
diff --git a/tools/llvmc/driver/CMakeLists.txt b/lib/CompilerDriver/CMakeLists.txt
index 153dd443cb..153dd443cb 100644
--- a/tools/llvmc/driver/CMakeLists.txt
+++ b/lib/CompilerDriver/CMakeLists.txt
diff --git a/tools/llvmc/driver/CompilationGraph.cpp b/lib/CompilerDriver/CompilationGraph.cpp
index 238ef6f42a..b8a66e17f5 100644
--- a/tools/llvmc/driver/CompilationGraph.cpp
+++ b/lib/CompilerDriver/CompilationGraph.cpp
@@ -11,8 +11,8 @@
//
//===----------------------------------------------------------------------===//
-#include "Error.h"
#include "llvm/CompilerDriver/CompilationGraph.h"
+#include "llvm/CompilerDriver/Error.h"
#include "llvm/ADT/STLExtras.h"
#include "llvm/Support/CommandLine.h"
diff --git a/lib/CompilerDriver/Makefile b/lib/CompilerDriver/Makefile
new file mode 100644
index 0000000000..e5bf3e10a7
--- /dev/null
+++ b/lib/CompilerDriver/Makefile
@@ -0,0 +1,19 @@
+##===- lib/CompilerDriver/Makefile -------------------------*- Makefile -*-===##
+#
+# The LLVM Compiler Infrastructure
+#
+# This file is distributed under the University of Illinois Open
+# Source License. See LICENSE.TXT for details.
+#
+##===----------------------------------------------------------------------===##
+
+LEVEL = ../..
+
+# We don't want this library to appear in `llvm-config --libs` output, so its
+# name doesn't start with "LLVM".
+
+LIBRARYNAME = CompilerDriver
+LINK_COMPONENTS = support system
+REQUIRES_EH := 1
+
+include $(LEVEL)/Makefile.common
diff --git a/tools/llvmc/driver/Plugin.cpp b/lib/CompilerDriver/Plugin.cpp
index 75abbd041d..75abbd041d 100644
--- a/tools/llvmc/driver/Plugin.cpp
+++ b/lib/CompilerDriver/Plugin.cpp
diff --git a/tools/llvmc/driver/Tool.cpp b/lib/CompilerDriver/Tool.cpp
index 886b26b5d7..886b26b5d7 100644
--- a/tools/llvmc/driver/Tool.cpp
+++ b/lib/CompilerDriver/Tool.cpp
diff --git a/lib/Makefile b/lib/Makefile
index 4ad0763f97..8dd67d9957 100644
--- a/lib/Makefile
+++ b/lib/Makefile
@@ -9,7 +9,7 @@
LEVEL = ..
PARALLEL_DIRS = VMCore AsmParser Bitcode Archive Analysis Transforms CodeGen \
- Target ExecutionEngine Debugger Linker
+ Target ExecutionEngine Debugger Linker CompilerDriver
include $(LEVEL)/Makefile.common
diff --git a/tools/llvmc/CMakeLists.txt b/tools/llvmc/CMakeLists.txt
index f820419904..bebaaebca8 100644
--- a/tools/llvmc/CMakeLists.txt
+++ b/tools/llvmc/CMakeLists.txt
@@ -1,4 +1,4 @@
-add_subdirectory(driver)
+# add_subdirectory(driver)
# 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 4354c387d4..60961769d1 100644
--- a/tools/llvmc/Makefile
+++ b/tools/llvmc/Makefile
@@ -9,11 +9,12 @@
LEVEL = ../..
-BUILTIN_PLUGINS = Base Clang
-DRIVER_NAME = llvmc
-DIRS = plugins driver
+# The current plan is to make the user copy the skeleton project and change only
+# this file (and plugins/UserPlugin, of course).
+
+export LLVMC_BASED_DRIVER_NAME = llvmc
+export LLVMC_BUILTIN_PLUGINS = Base Clang
-export BUILTIN_PLUGINS
-export DRIVER_NAME
+DIRS = plugins driver
include $(LEVEL)/Makefile.common
diff --git a/tools/llvmc/Makefile.llvmc b/tools/llvmc/Makefile.llvmc
new file mode 100644
index 0000000000..79ec6426e8
--- /dev/null
+++ b/tools/llvmc/Makefile.llvmc
@@ -0,0 +1,49 @@
+##===- tools/llvmc/Makefile.llvmc --------------------------*- Makefile -*-===##
+#
+# The LLVM Compiler Infrastructure
+#
+# This file is distributed under the University of Illinois Open
+# Source License. See LICENSE.TXT for details.
+#
+##===----------------------------------------------------------------------===##
+
+# TODO: This must be eventually merged into Makefile.rules.
+
+ifdef LLVMC_PLUGIN
+
+# We are included from plugins/PluginName/Makefile...
+
+LEVEL = ../../../..
+
+LIBRARYNAME := $(patsubst %,plugin_llvmc_%,$(LLVMC_PLUGIN))
+REQUIRES_EH := 1
+
+# Build a dynamic library if the user runs `make` from plugins/PluginName
+ifndef LLVMC_BUILTIN_PLUGIN
+LOADABLE_MODULE = 1
+endif
+
+# TableGen stuff...
+ifneq ($(BUILT_SOURCES),)
+BUILD_AUTOGENERATED_INC=1
+endif
+
+include $(LEVEL)/Makefile.common
+
+ifdef BUILD_AUTOGENERATED_INC
+
+TOOLS_SOURCE := $(strip $(wildcard $(PROJ_SRC_DIR)/*.td))
+
+TD_COMMON :=$(strip $(wildcard \
+ $(LLVM_SRC_ROOT)/include/llvm/CompilerDriver/*.td))
+
+$(ObjDir)/AutoGenerated.inc.tmp: $(TOOLS_SOURCE) $(ObjDir)/.dir \
+ $(TBLGEN) $(TD_COMMON)
+ $(Echo) "Building LLVMC configuration library with tblgen"
+ $(Verb) $(TableGen) -gen-llvmc -o $(call SYSPATH, $@) $<
+
+AutoGenerated.inc : $(ObjDir)/AutoGenerated.inc.tmp
+ $(Verb) $(CMP) -s $@ $< || $(CP) $< $@
+endif # BUILD_AUTOGENERATED_INC
+
+endif # LLVMC_PLUGIN
diff --git a/tools/llvmc/driver/llvmc.cpp b/tools/llvmc/driver/Main.cpp
index 059e840eeb..16b91a87c9 100644
--- a/tools/llvmc/driver/llvmc.cpp
+++ b/tools/llvmc/driver/Main.cpp
@@ -1,4 +1,4 @@
-//===--- llvmc.cpp - The LLVM Compiler Driver -------------------*- C++ -*-===//
+//===--- Main.cpp - The LLVM Compiler Driver -------------------*- C++ -*-===//
//
// The LLVM Compiler Infrastructure
//
@@ -14,9 +14,8 @@
//
//===----------------------------------------------------------------------===//
-#include "Error.h"
-
#include "llvm/CompilerDriver/CompilationGraph.h"
+#include "llvm/CompilerDriver/Error.h"
#include "llvm/CompilerDriver/Plugin.h"
#include "llvm/System/Path.h"
diff --git a/tools/llvmc/driver/Makefile b/tools/llvmc/driver/Makefile
index 107f0dea38..0e32726fec 100644
--- a/tools/llvmc/driver/Makefile
+++ b/tools/llvmc/driver/Makefile
@@ -8,12 +8,15 @@
##===----------------------------------------------------------------------===##
LEVEL = ../../..
-TOOLNAME = $(DRIVER_NAME)
-LINK_COMPONENTS = support system
-REQUIRES_EH := 1
-ifneq ($(BUILTIN_PLUGINS),)
-USEDLIBS = $(patsubst %,plugin_llvmc_%,$(BUILTIN_PLUGINS))
+TOOLNAME = $(LLVMC_BASED_DRIVER_NAME)
+USEDLIBS = CompilerDriver
+
+ifneq ($(LLVMC_BUILTIN_PLUGINS),)
+USEDLIBS += $(patsubst %,plugin_llvmc_%,$(LLVMC_BUILTIN_PLUGINS))
endif
+LINK_COMPONENTS = support system
+REQUIRES_EH := 1
+
include $(LEVEL)/Makefile.common
diff --git a/tools/llvmc/plugins/Base/Makefile b/tools/llvmc/plugins/Base/Makefile
index 5ca6048508..eb6ed010c6 100644
--- a/tools/llvmc/plugins/Base/Makefile
+++ b/tools/llvmc/plugins/Base/Makefile
@@ -7,7 +7,9 @@
#
##===----------------------------------------------------------------------===##
+LEVEL = ../..
+
LLVMC_PLUGIN = Base
BUILT_SOURCES = AutoGenerated.inc
-include ../Makefile
+include $(LEVEL)/Makefile.llvmc
diff --git a/tools/llvmc/plugins/Clang/Makefile b/tools/llvmc/plugins/Clang/Makefile
index 32060138c2..a1b011e90d 100644
--- a/tools/llvmc/plugins/Clang/Makefile
+++ b/tools/llvmc/plugins/Clang/Makefile
@@ -7,7 +7,9 @@
#
##===----------------------------------------------------------------------===##
+LEVEL = ../..
+
LLVMC_PLUGIN = Clang
BUILT_SOURCES = AutoGenerated.inc
-include ../Makefile
+include $(LEVEL)/Makefile.llvmc
diff --git a/tools/llvmc/plugins/Hello/Makefile b/tools/llvmc/plugins/Hello/Makefile
index 181dd0c605..8e9fa6f313 100644
--- a/tools/llvmc/plugins/Hello/Makefile
+++ b/tools/llvmc/plugins/Hello/Makefile
@@ -7,6 +7,8 @@
#
##===----------------------------------------------------------------------===##
+LEVEL = ../..
+
LLVMC_PLUGIN = Hello
-include ../Makefile
+include $(LEVEL)/Makefile.llvmc
diff --git a/tools/llvmc/plugins/Makefile b/tools/llvmc/plugins/Makefile
index 734323f50d..37dac6f0ac 100644
--- a/tools/llvmc/plugins/Makefile
+++ b/tools/llvmc/plugins/Makefile
@@ -1,4 +1,4 @@
-##===- tools/llvmc/plugins/Makefile.plugins ----------------*- Makefile -*-===##
+##===- tools/llvmc/plugins/Makefile ------------------------*- Makefile -*-===##
#
# The LLVM Compiler Infrastructure
#
@@ -7,49 +7,12 @@
#
##===----------------------------------------------------------------------===##
-ifndef LLVMC_PLUGIN
-
LEVEL = ../../..
-DIRS = $(BUILTIN_PLUGINS)
-
-# TOFIX: Should we also build DSO versions of plugins?
-export BUILTIN_LLVMC_PLUGIN=1
-
-include $(LEVEL)/Makefile.common
-else # LLVMC_PLUGIN
-
-LEVEL = ../../../..
-
-LIBRARYNAME := $(patsubst %,plugin_llvmc_%,$(LLVMC_PLUGIN))
-REQUIRES_EH = 1
-
-ifndef BUILTIN_LLVMC_PLUGIN
-LOADABLE_MODULE = 1
+ifneq ($(LLVMC_BUILTIN_PLUGINS),)
+DIRS = $(LLVMC_BUILTIN_PLUGINS)
endif
-ifneq ($(BUILT_SOURCES),)
-BUILD_AUTOGENERATED_INC=1
-endif
+export LLVMC_BUILTIN_PLUGIN=1
include $(LEVEL)/Makefile.common
-
-# TOFIX: This probably should go into Makefile.rules
-
-ifdef BUILD_AUTOGENERATED_INC
-
-TOOLS_SOURCE := $(strip $(wildcard $(PROJ_SRC_DIR)/*.td))
-
-TD_COMMON :=$(strip $(wildcard \
- $(LLVM_SRC_ROOT)/include/llvm/CompilerDriver/*.td))
-
-$(ObjDir)/AutoGenerated.inc.tmp: $(TOOLS_SOURCE) $(ObjDir)/.dir \
- $(TBLGEN) $(TD_COMMON)
- $(Echo) "Building LLVMC configuration library with tblgen"
- $(Verb) $(TableGen) -gen-llvmc -o $(call SYSPATH, $@) $<
-
-AutoGenerated.inc : $(ObjDir)/AutoGenerated.inc.tmp
- $(Verb) $(CMP) -s $@ $< || $(CP) $< $@
-endif # BUILD_AUTOGENERATED_INC
-
-endif # LLVMC_PLUGIN
diff --git a/tools/llvmc/plugins/Simple/Makefile b/tools/llvmc/plugins/Simple/Makefile
index 1cd5af7a15..c38cda5171 100644
--- a/tools/llvmc/plugins/Simple/Makefile
+++ b/tools/llvmc/plugins/Simple/Makefile
@@ -7,7 +7,9 @@
#
##===----------------------------------------------------------------------===##
+LEVEL = ../..
+
LLVMC_PLUGIN = Simple
BUILT_SOURCES = AutoGenerated.inc
-include ../Makefile
+include $(LEVEL)/Makefile.llvmc