forked from OSchip/llvm-project
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. llvm-svn: 65821
This commit is contained in:
parent
57359cad17
commit
931d4521c3
|
@ -11,8 +11,8 @@
|
||||||
//
|
//
|
||||||
//===----------------------------------------------------------------------===//
|
//===----------------------------------------------------------------------===//
|
||||||
|
|
||||||
#include "Error.h"
|
|
||||||
#include "llvm/CompilerDriver/CompilationGraph.h"
|
#include "llvm/CompilerDriver/CompilationGraph.h"
|
||||||
|
#include "llvm/CompilerDriver/Error.h"
|
||||||
|
|
||||||
#include "llvm/ADT/STLExtras.h"
|
#include "llvm/ADT/STLExtras.h"
|
||||||
#include "llvm/Support/CommandLine.h"
|
#include "llvm/Support/CommandLine.h"
|
|
@ -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
|
|
@ -9,7 +9,7 @@
|
||||||
LEVEL = ..
|
LEVEL = ..
|
||||||
|
|
||||||
PARALLEL_DIRS = VMCore AsmParser Bitcode Archive Analysis Transforms CodeGen \
|
PARALLEL_DIRS = VMCore AsmParser Bitcode Archive Analysis Transforms CodeGen \
|
||||||
Target ExecutionEngine Debugger Linker
|
Target ExecutionEngine Debugger Linker CompilerDriver
|
||||||
|
|
||||||
include $(LEVEL)/Makefile.common
|
include $(LEVEL)/Makefile.common
|
||||||
|
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
add_subdirectory(driver)
|
# add_subdirectory(driver)
|
||||||
|
|
||||||
# TODO: support plugins and user-configured builds.
|
# TODO: support plugins and user-configured builds.
|
||||||
# See ./doc/LLVMC-Reference.rst "Customizing LLVMC: the compilation graph"
|
# See ./doc/LLVMC-Reference.rst "Customizing LLVMC: the compilation graph"
|
||||||
|
|
|
@ -9,11 +9,12 @@
|
||||||
|
|
||||||
LEVEL = ../..
|
LEVEL = ../..
|
||||||
|
|
||||||
BUILTIN_PLUGINS = Base Clang
|
# The current plan is to make the user copy the skeleton project and change only
|
||||||
DRIVER_NAME = llvmc
|
# this file (and plugins/UserPlugin, of course).
|
||||||
|
|
||||||
|
export LLVMC_BASED_DRIVER_NAME = llvmc
|
||||||
|
export LLVMC_BUILTIN_PLUGINS = Base Clang
|
||||||
|
|
||||||
DIRS = plugins driver
|
DIRS = plugins driver
|
||||||
|
|
||||||
export BUILTIN_PLUGINS
|
|
||||||
export DRIVER_NAME
|
|
||||||
|
|
||||||
include $(LEVEL)/Makefile.common
|
include $(LEVEL)/Makefile.common
|
||||||
|
|
|
@ -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
|
|
@ -1,4 +1,4 @@
|
||||||
//===--- llvmc.cpp - The LLVM Compiler Driver -------------------*- C++ -*-===//
|
//===--- Main.cpp - The LLVM Compiler Driver -------------------*- C++ -*-===//
|
||||||
//
|
//
|
||||||
// The LLVM Compiler Infrastructure
|
// The LLVM Compiler Infrastructure
|
||||||
//
|
//
|
||||||
|
@ -14,9 +14,8 @@
|
||||||
//
|
//
|
||||||
//===----------------------------------------------------------------------===//
|
//===----------------------------------------------------------------------===//
|
||||||
|
|
||||||
#include "Error.h"
|
|
||||||
|
|
||||||
#include "llvm/CompilerDriver/CompilationGraph.h"
|
#include "llvm/CompilerDriver/CompilationGraph.h"
|
||||||
|
#include "llvm/CompilerDriver/Error.h"
|
||||||
#include "llvm/CompilerDriver/Plugin.h"
|
#include "llvm/CompilerDriver/Plugin.h"
|
||||||
|
|
||||||
#include "llvm/System/Path.h"
|
#include "llvm/System/Path.h"
|
|
@ -8,12 +8,15 @@
|
||||||
##===----------------------------------------------------------------------===##
|
##===----------------------------------------------------------------------===##
|
||||||
|
|
||||||
LEVEL = ../../..
|
LEVEL = ../../..
|
||||||
TOOLNAME = $(DRIVER_NAME)
|
|
||||||
|
TOOLNAME = $(LLVMC_BASED_DRIVER_NAME)
|
||||||
|
USEDLIBS = CompilerDriver
|
||||||
|
|
||||||
|
ifneq ($(LLVMC_BUILTIN_PLUGINS),)
|
||||||
|
USEDLIBS += $(patsubst %,plugin_llvmc_%,$(LLVMC_BUILTIN_PLUGINS))
|
||||||
|
endif
|
||||||
|
|
||||||
LINK_COMPONENTS = support system
|
LINK_COMPONENTS = support system
|
||||||
REQUIRES_EH := 1
|
REQUIRES_EH := 1
|
||||||
|
|
||||||
ifneq ($(BUILTIN_PLUGINS),)
|
|
||||||
USEDLIBS = $(patsubst %,plugin_llvmc_%,$(BUILTIN_PLUGINS))
|
|
||||||
endif
|
|
||||||
|
|
||||||
include $(LEVEL)/Makefile.common
|
include $(LEVEL)/Makefile.common
|
||||||
|
|
|
@ -7,7 +7,9 @@
|
||||||
#
|
#
|
||||||
##===----------------------------------------------------------------------===##
|
##===----------------------------------------------------------------------===##
|
||||||
|
|
||||||
|
LEVEL = ../..
|
||||||
|
|
||||||
LLVMC_PLUGIN = Base
|
LLVMC_PLUGIN = Base
|
||||||
BUILT_SOURCES = AutoGenerated.inc
|
BUILT_SOURCES = AutoGenerated.inc
|
||||||
|
|
||||||
include ../Makefile
|
include $(LEVEL)/Makefile.llvmc
|
||||||
|
|
|
@ -7,7 +7,9 @@
|
||||||
#
|
#
|
||||||
##===----------------------------------------------------------------------===##
|
##===----------------------------------------------------------------------===##
|
||||||
|
|
||||||
|
LEVEL = ../..
|
||||||
|
|
||||||
LLVMC_PLUGIN = Clang
|
LLVMC_PLUGIN = Clang
|
||||||
BUILT_SOURCES = AutoGenerated.inc
|
BUILT_SOURCES = AutoGenerated.inc
|
||||||
|
|
||||||
include ../Makefile
|
include $(LEVEL)/Makefile.llvmc
|
||||||
|
|
|
@ -7,6 +7,8 @@
|
||||||
#
|
#
|
||||||
##===----------------------------------------------------------------------===##
|
##===----------------------------------------------------------------------===##
|
||||||
|
|
||||||
|
LEVEL = ../..
|
||||||
|
|
||||||
LLVMC_PLUGIN = Hello
|
LLVMC_PLUGIN = Hello
|
||||||
|
|
||||||
include ../Makefile
|
include $(LEVEL)/Makefile.llvmc
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
##===- tools/llvmc/plugins/Makefile.plugins ----------------*- Makefile -*-===##
|
##===- tools/llvmc/plugins/Makefile ------------------------*- Makefile -*-===##
|
||||||
#
|
#
|
||||||
# The LLVM Compiler Infrastructure
|
# The LLVM Compiler Infrastructure
|
||||||
#
|
#
|
||||||
|
@ -7,49 +7,12 @@
|
||||||
#
|
#
|
||||||
##===----------------------------------------------------------------------===##
|
##===----------------------------------------------------------------------===##
|
||||||
|
|
||||||
ifndef LLVMC_PLUGIN
|
|
||||||
|
|
||||||
LEVEL = ../../..
|
LEVEL = ../../..
|
||||||
DIRS = $(BUILTIN_PLUGINS)
|
|
||||||
|
|
||||||
# TOFIX: Should we also build DSO versions of plugins?
|
ifneq ($(LLVMC_BUILTIN_PLUGINS),)
|
||||||
export BUILTIN_LLVMC_PLUGIN=1
|
DIRS = $(LLVMC_BUILTIN_PLUGINS)
|
||||||
|
|
||||||
include $(LEVEL)/Makefile.common
|
|
||||||
|
|
||||||
else # LLVMC_PLUGIN
|
|
||||||
|
|
||||||
LEVEL = ../../../..
|
|
||||||
|
|
||||||
LIBRARYNAME := $(patsubst %,plugin_llvmc_%,$(LLVMC_PLUGIN))
|
|
||||||
REQUIRES_EH = 1
|
|
||||||
|
|
||||||
ifndef BUILTIN_LLVMC_PLUGIN
|
|
||||||
LOADABLE_MODULE = 1
|
|
||||||
endif
|
endif
|
||||||
|
|
||||||
ifneq ($(BUILT_SOURCES),)
|
export LLVMC_BUILTIN_PLUGIN=1
|
||||||
BUILD_AUTOGENERATED_INC=1
|
|
||||||
endif
|
|
||||||
|
|
||||||
include $(LEVEL)/Makefile.common
|
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
|
|
||||||
|
|
|
@ -7,7 +7,9 @@
|
||||||
#
|
#
|
||||||
##===----------------------------------------------------------------------===##
|
##===----------------------------------------------------------------------===##
|
||||||
|
|
||||||
|
LEVEL = ../..
|
||||||
|
|
||||||
LLVMC_PLUGIN = Simple
|
LLVMC_PLUGIN = Simple
|
||||||
BUILT_SOURCES = AutoGenerated.inc
|
BUILT_SOURCES = AutoGenerated.inc
|
||||||
|
|
||||||
include ../Makefile
|
include $(LEVEL)/Makefile.llvmc
|
||||||
|
|
Loading…
Reference in New Issue