diff options
author | Mikhail Glushenkov <foldr@codedgers.com> | 2008-11-25 21:38:12 +0000 |
---|---|---|
committer | Mikhail Glushenkov <foldr@codedgers.com> | 2008-11-25 21:38:12 +0000 |
commit | c7e56fe6f41501ec3a56e4be70506d2033b45bd4 (patch) | |
tree | 3b134d1c1e4f3a77e35efe15051cb40295f4e801 /tools/llvmc/plugins | |
parent | 17cc062a8b2dc21bc35b5a692fe365c0b31a30f1 (diff) | |
download | external_llvm-c7e56fe6f41501ec3a56e4be70506d2033b45bd4.tar.gz external_llvm-c7e56fe6f41501ec3a56e4be70506d2033b45bd4.tar.bz2 external_llvm-c7e56fe6f41501ec3a56e4be70506d2033b45bd4.zip |
Since the old llvmc was removed, rename llvmc2 to llvmc.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@60048 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'tools/llvmc/plugins')
-rw-r--r-- | tools/llvmc/plugins/Base/Base.td | 59 | ||||
-rw-r--r-- | tools/llvmc/plugins/Base/Makefile | 13 | ||||
-rw-r--r-- | tools/llvmc/plugins/Base/PluginMain.cpp | 1 | ||||
-rw-r--r-- | tools/llvmc/plugins/Clang/Clang.td | 85 | ||||
-rw-r--r-- | tools/llvmc/plugins/Clang/Makefile | 13 | ||||
-rw-r--r-- | tools/llvmc/plugins/Clang/PluginMain.cpp | 1 | ||||
-rw-r--r-- | tools/llvmc/plugins/Hello/Hello.cpp | 30 | ||||
-rw-r--r-- | tools/llvmc/plugins/Hello/Makefile | 12 | ||||
-rw-r--r-- | tools/llvmc/plugins/Makefile | 55 | ||||
-rw-r--r-- | tools/llvmc/plugins/Simple/Makefile | 13 | ||||
-rw-r--r-- | tools/llvmc/plugins/Simple/PluginMain.cpp | 1 | ||||
-rw-r--r-- | tools/llvmc/plugins/Simple/Simple.td | 30 |
12 files changed, 313 insertions, 0 deletions
diff --git a/tools/llvmc/plugins/Base/Base.td b/tools/llvmc/plugins/Base/Base.td new file mode 100644 index 0000000000..85a37cb41a --- /dev/null +++ b/tools/llvmc/plugins/Base/Base.td @@ -0,0 +1,59 @@ +//===- Base.td - LLVMC2 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 llvmc2. +// +//===----------------------------------------------------------------------===// + +include "llvm/CompilerDriver/Common.td" +include "llvm/CompilerDriver/Tools.td" + +// Toolchains + +def CompilationGraph : CompilationGraph<[ + Edge<"root", "llvm_gcc_c">, + Edge<"root", "llvm_gcc_assembler">, + Edge<"root", "llvm_gcc_cpp">, + Edge<"root", "llvm_gcc_m">, + Edge<"root", "llvm_gcc_mxx">, + Edge<"root", "llvm_as">, + + Edge<"llvm_gcc_c", "llc">, + Edge<"llvm_gcc_cpp", "llc">, + Edge<"llvm_gcc_m", "llc">, + Edge<"llvm_gcc_mxx", "llc">, + Edge<"llvm_as", "llc">, + + OptionalEdge<"llvm_gcc_c", "opt", (case (switch_on "opt"), (inc_weight))>, + OptionalEdge<"llvm_gcc_cpp", "opt", (case (switch_on "opt"), (inc_weight))>, + OptionalEdge<"llvm_gcc_m", "opt", (case (switch_on "opt"), (inc_weight))>, + OptionalEdge<"llvm_gcc_mxx", "opt", (case (switch_on "opt"), (inc_weight))>, + OptionalEdge<"llvm_as", "opt", (case (switch_on "opt"), (inc_weight))>, + Edge<"opt", "llc">, + + Edge<"llc", "llvm_gcc_assembler">, + Edge<"llvm_gcc_assembler", "llvm_gcc_linker">, + OptionalEdge<"llvm_gcc_assembler", "llvm_gcc_cpp_linker", + (case + (or (input_languages_contain "c++"), + (input_languages_contain "objective-c++")), + (inc_weight), + (or (parameter_equals "linker", "g++"), + (parameter_equals "linker", "c++")), (inc_weight))>, + + + Edge<"root", "llvm_gcc_linker">, + OptionalEdge<"root", "llvm_gcc_cpp_linker", + (case + (or (input_languages_contain "c++"), + (input_languages_contain "objective-c++")), + (inc_weight), + (or (parameter_equals "linker", "g++"), + (parameter_equals "linker", "c++")), (inc_weight))> + ]>; diff --git a/tools/llvmc/plugins/Base/Makefile b/tools/llvmc/plugins/Base/Makefile new file mode 100644 index 0000000000..5ca6048508 --- /dev/null +++ b/tools/llvmc/plugins/Base/Makefile @@ -0,0 +1,13 @@ +##===- 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. +# +##===----------------------------------------------------------------------===## + +LLVMC_PLUGIN = Base +BUILT_SOURCES = AutoGenerated.inc + +include ../Makefile diff --git a/tools/llvmc/plugins/Base/PluginMain.cpp b/tools/llvmc/plugins/Base/PluginMain.cpp new file mode 100644 index 0000000000..add8acb4a5 --- /dev/null +++ b/tools/llvmc/plugins/Base/PluginMain.cpp @@ -0,0 +1 @@ +#include "AutoGenerated.inc" diff --git a/tools/llvmc/plugins/Clang/Clang.td b/tools/llvmc/plugins/Clang/Clang.td new file mode 100644 index 0000000000..0f5d8cd918 --- /dev/null +++ b/tools/llvmc/plugins/Clang/Clang.td @@ -0,0 +1,85 @@ +// A (first stab at a) replacement for the Clang's ccc script. +// To compile, use this command: +// cd $LLVMC2_DIR +// make DRIVER_NAME=ccc2 BUILTIN_PLUGINS=Clang + +include "llvm/CompilerDriver/Common.td" + + +def Options : OptionList<[ +(switch_option "E", + (help "Stop after the preprocessing stage, do not run the compiler")) +]>; + +class clang_base<string language, dag cmdline> : Tool< +[(in_language language), + (out_language "llvm-bitcode"), + (output_suffix "bc"), + (cmd_line cmdline), + (switch_option "E", (stop_compilation), (output_suffix "i")), + (sink) +]>; + +def clang_c : clang_base<"c", +(case +(switch_on "E"), + (case + (not_empty "o"), + "clang -E -x c $INFILE -o $OUTFILE", + (default), + "clang -E -x c $INFILE"), +(default), + "clang -emit-llvm-bc -x c $INFILE -o $OUTFILE")>; + +def clang_cpp : clang_base<"c++", +(case +(switch_on "E"), + (case + (not_empty "o"), + "clang -E -x c++ $INFILE -o $OUTFILE", + (default), + "clang -E -x c++ $INFILE"), +(default), + "clang -emit-llvm-bc -x c++ $INFILE -o $OUTFILE")>; + +def clang_objective_c : clang_base<"objective-c", +(case +(switch_on "E"), + (case + (not_empty "o"), + "clang -E -x objective-c $INFILE -o $OUTFILE", + (default), + "clang -E -x objective-c $INFILE"), +(default), + "clang -emit-llvm-bc -x objective-c $INFILE -o $OUTFILE")>; + +// Default linker +def llvm_ld : Tool< +[(in_language "llvm-bitcode"), + (out_language "executable"), + (output_suffix "out"), + (cmd_line "llvm-ld -native -disable-internalize $INFILE -o $OUTFILE"), + (prefix_list_option "L", (forward), (help "Specify a library search path")), + (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<[ + Edge<"root", "clang_c">, + Edge<"root", "clang_cpp">, + Edge<"root", "clang_objective_c">, + Edge<"clang_c", "llvm_ld">, + Edge<"clang_cpp", "llvm_ld">, + Edge<"clang_objective_c", "llvm_ld"> + ]>; diff --git a/tools/llvmc/plugins/Clang/Makefile b/tools/llvmc/plugins/Clang/Makefile new file mode 100644 index 0000000000..32060138c2 --- /dev/null +++ b/tools/llvmc/plugins/Clang/Makefile @@ -0,0 +1,13 @@ +##===- 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. +# +##===----------------------------------------------------------------------===## + +LLVMC_PLUGIN = Clang +BUILT_SOURCES = AutoGenerated.inc + +include ../Makefile diff --git a/tools/llvmc/plugins/Clang/PluginMain.cpp b/tools/llvmc/plugins/Clang/PluginMain.cpp new file mode 100644 index 0000000000..add8acb4a5 --- /dev/null +++ b/tools/llvmc/plugins/Clang/PluginMain.cpp @@ -0,0 +1 @@ +#include "AutoGenerated.inc" diff --git a/tools/llvmc/plugins/Hello/Hello.cpp b/tools/llvmc/plugins/Hello/Hello.cpp new file mode 100644 index 0000000000..2ecd2f1c5b --- /dev/null +++ b/tools/llvmc/plugins/Hello/Hello.cpp @@ -0,0 +1,30 @@ +//===- Hello.cpp - Example code from "Writing an LLVM Pass" ---------------===// +// +// The LLVM Compiler Infrastructure +// +// This file is distributed under the University of Illinois Open Source +// License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// +// +// Test plugin for LLVMC. +// +//===----------------------------------------------------------------------===// + +#include "llvm/CompilerDriver/CompilationGraph.h" +#include "llvm/CompilerDriver/Plugin.h" + +#include <iostream> + +namespace { +struct MyPlugin : public llvmc::BasePlugin { + void PopulateLanguageMap(llvmc::LanguageMap&) const + { std::cout << "Hello!\n"; } + + void PopulateCompilationGraph(llvmc::CompilationGraph&) const + {} +}; + +static llvmc::RegisterPlugin<MyPlugin> RP("Hello", "Hello World plugin"); + +} diff --git a/tools/llvmc/plugins/Hello/Makefile b/tools/llvmc/plugins/Hello/Makefile new file mode 100644 index 0000000000..181dd0c605 --- /dev/null +++ b/tools/llvmc/plugins/Hello/Makefile @@ -0,0 +1,12 @@ +##===- tools/llvmc/plugins/Hello/Makefile ------------------*- Makefile -*-===## +# +# The LLVM Compiler Infrastructure +# +# This file is distributed under the University of Illinois Open Source +# License. See LICENSE.TXT for details. +# +##===----------------------------------------------------------------------===## + +LLVMC_PLUGIN = Hello + +include ../Makefile diff --git a/tools/llvmc/plugins/Makefile b/tools/llvmc/plugins/Makefile new file mode 100644 index 0000000000..dab58e0758 --- /dev/null +++ b/tools/llvmc/plugins/Makefile @@ -0,0 +1,55 @@ +##===- tools/llvmc/plugins/Makefile.plugins ----------------*- Makefile -*-===## +# +# The LLVM Compiler Infrastructure +# +# This file is distributed under the University of Illinois Open +# Source License. See LICENSE.TXT for details. +# +##===----------------------------------------------------------------------===## + +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 %,LLVMC%,$(LLVMC_PLUGIN)) +REQUIRES_EH = 1 + +ifndef BUILTIN_LLVMC_PLUGIN +LOADABLE_MODULE = 1 +endif + +ifneq ($(BUILT_SOURCES),) +BUILD_AUTOGENERATED_INC=1 +endif + +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 new file mode 100644 index 0000000000..1cd5af7a15 --- /dev/null +++ b/tools/llvmc/plugins/Simple/Makefile @@ -0,0 +1,13 @@ +##===- tools/llvmc/plugins/Simple/Makefile -----------------*- Makefile -*-===## +# +# The LLVM Compiler Infrastructure +# +# This file is distributed under the University of Illinois Open Source +# License. See LICENSE.TXT for details. +# +##===----------------------------------------------------------------------===## + +LLVMC_PLUGIN = Simple +BUILT_SOURCES = AutoGenerated.inc + +include ../Makefile diff --git a/tools/llvmc/plugins/Simple/PluginMain.cpp b/tools/llvmc/plugins/Simple/PluginMain.cpp new file mode 100644 index 0000000000..add8acb4a5 --- /dev/null +++ b/tools/llvmc/plugins/Simple/PluginMain.cpp @@ -0,0 +1 @@ +#include "AutoGenerated.inc" diff --git a/tools/llvmc/plugins/Simple/Simple.td b/tools/llvmc/plugins/Simple/Simple.td new file mode 100644 index 0000000000..b974cbc95e --- /dev/null +++ b/tools/llvmc/plugins/Simple/Simple.td @@ -0,0 +1,30 @@ +// A simple wrapper for gcc. +// To compile, use this command: +// +// $ cd $LLVMC2_DIR +// $ make DRIVER_NAME=mygcc BUILTIN_PLUGINS=Simple +// +// To build this plugin as a dynamic library: +// +// $ cd $LLVMC2_DIR +// $ make BUILTIN_PLUGINS="" +// $ cd plugins/Simple +// $ make +// +// Run as: +// +// $ llvmc2 -load $LLVM_DIR/Release/lib/LLVMCSimple.so + +include "llvm/CompilerDriver/Common.td" + +def gcc : Tool< +[(in_language "c"), + (out_language "executable"), + (output_suffix "out"), + (cmd_line "gcc $INFILE -o $OUTFILE"), + (sink) +]>; + +def LanguageMap : LanguageMap<[LangToSuffixes<"c", ["c"]>]>; + +def CompilationGraph : CompilationGraph<[Edge<"root", "gcc">]>; |