diff options
Diffstat (limited to 'contrib/llvm/tools/llvmc')
39 files changed, 268 insertions, 370 deletions
diff --git a/contrib/llvm/tools/llvmc/CMakeLists.txt b/contrib/llvm/tools/llvmc/CMakeLists.txt index bebaaeb..10ad5d8 100644 --- a/contrib/llvm/tools/llvmc/CMakeLists.txt +++ b/contrib/llvm/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/contrib/llvm/tools/llvmc/Makefile b/contrib/llvm/tools/llvmc/Makefile index 8f99526..7c03e2a 100644 --- a/contrib/llvm/tools/llvmc/Makefile +++ b/contrib/llvm/tools/llvmc/Makefile @@ -9,10 +9,10 @@ LEVEL = ../.. -export LLVMC_BASED_DRIVER_NAME = llvmc -export LLVMC_BUILTIN_PLUGINS = Base Clang -REQUIRES_RTTI = 1 +DIRS = src -DIRS = plugins driver +ifeq ($(BUILD_EXAMPLES),1) + OPTIONAL_DIRS += examples +endif include $(LEVEL)/Makefile.common diff --git a/contrib/llvm/tools/llvmc/doc/LLVMC-Reference.rst b/contrib/llvm/tools/llvmc/doc/LLVMC-Reference.rst index ca8500d..d160e75 100644 --- a/contrib/llvm/tools/llvmc/doc/LLVMC-Reference.rst +++ b/contrib/llvm/tools/llvmc/doc/LLVMC-Reference.rst @@ -299,7 +299,7 @@ separate option groups syntactically. * Possible option types: - ``switch_option`` - a simple boolean switch without arguments, for example - ``-O2`` or ``-time``. At most one occurrence is allowed. + ``-O2`` or ``-time``. At most one occurrence is allowed by default. - ``parameter_option`` - option that takes one argument, for example ``-std=c99``. It is also allowed to use spaces instead of the equality @@ -321,6 +321,13 @@ separate option groups syntactically. option types, aliases are not allowed to have any properties besides the aliased option name. Usage example: ``(alias_option "preprocess", "E")`` + - ``switch_list_option`` - like ``switch_option`` with the ``zero_or_more`` + property, but remembers how many times the switch was turned on. Useful + mostly for forwarding. Example: when ``-foo`` is a switch option (with the + ``zero_or_more`` property), the command ``driver -foo -foo`` is forwarded + as ``some-tool -foo``, but when ``-foo`` is a switch list, the same command + is forwarded as ``some-tool -foo -foo``. + * Possible option properties: diff --git a/contrib/llvm/tools/llvmc/example/Hello/Hello.cpp b/contrib/llvm/tools/llvmc/example/Hello/Hello.cpp deleted file mode 100644 index a7179ea..0000000 --- a/contrib/llvm/tools/llvmc/example/Hello/Hello.cpp +++ /dev/null @@ -1,33 +0,0 @@ -//===- Hello.cpp - Example code from "Writing an LLVMC Plugin" ------------===// -// -// 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. Shows how to write plugins without using TableGen. -// -//===----------------------------------------------------------------------===// - -#include "llvm/CompilerDriver/CompilationGraph.h" -#include "llvm/CompilerDriver/Plugin.h" -#include "llvm/Support/raw_ostream.h" - -namespace { -struct MyPlugin : public llvmc::BasePlugin { - - void PreprocessOptions() const - {} - - void PopulateLanguageMap(llvmc::LanguageMap&) const - { outs() << "Hello!\n"; } - - void PopulateCompilationGraph(llvmc::CompilationGraph&) const - {} -}; - -static llvmc::RegisterPlugin<MyPlugin> RP("Hello", "Hello World plugin"); - -} diff --git a/contrib/llvm/tools/llvmc/example/Simple/PluginMain.cpp b/contrib/llvm/tools/llvmc/example/Simple/PluginMain.cpp deleted file mode 100644 index add8acb..0000000 --- a/contrib/llvm/tools/llvmc/example/Simple/PluginMain.cpp +++ /dev/null @@ -1 +0,0 @@ -#include "AutoGenerated.inc" diff --git a/contrib/llvm/tools/llvmc/example/Skeleton/Makefile b/contrib/llvm/tools/llvmc/example/Skeleton/Makefile deleted file mode 100644 index f489abf..0000000 --- a/contrib/llvm/tools/llvmc/example/Skeleton/Makefile +++ /dev/null @@ -1,24 +0,0 @@ -##===- llvmc/example/Skeleton/Makefile ---------------------*- Makefile -*-===## -# -# The LLVM Compiler Infrastructure -# -# This file is distributed under the University of Illinois Open -# Source License. See LICENSE.TXT for details. -# -##===----------------------------------------------------------------------===## - -# Change this so that $(BASE_LEVEL)/Makefile.common refers to -# $LLVM_DIR/Makefile.common or $YOUR_LLVM_BASED_PROJECT/Makefile.common. -export LLVMC_BASE_LEVEL = ../../../.. - -# Change this to the name of your LLVMC-based driver. -export LLVMC_BASED_DRIVER_NAME = llvmc-skeleton - -# List your plugin names here -export LLVMC_BUILTIN_PLUGINS = # Plugin - -LEVEL = $(LLVMC_BASE_LEVEL) - -DIRS = plugins driver - -include $(LEVEL)/Makefile.common diff --git a/contrib/llvm/tools/llvmc/example/Skeleton/driver/Makefile b/contrib/llvm/tools/llvmc/example/Skeleton/driver/Makefile deleted file mode 100644 index 93e795b..0000000 --- a/contrib/llvm/tools/llvmc/example/Skeleton/driver/Makefile +++ /dev/null @@ -1,13 +0,0 @@ -##===- llvmc/example/Skeleton/driver/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_BASE_LEVEL)/.. -LLVMC_BASED_DRIVER = $(LLVMC_BASED_DRIVER_NAME) - -include $(LEVEL)/Makefile.common diff --git a/contrib/llvm/tools/llvmc/example/Skeleton/plugins/Makefile b/contrib/llvm/tools/llvmc/example/Skeleton/plugins/Makefile deleted file mode 100644 index fb07f23..0000000 --- a/contrib/llvm/tools/llvmc/example/Skeleton/plugins/Makefile +++ /dev/null @@ -1,18 +0,0 @@ -##===- llvmc/example/Skeleton/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 = $(LLVMC_BASE_LEVEL)/.. - -ifneq ($(LLVMC_BUILTIN_PLUGINS),) -DIRS = $(LLVMC_BUILTIN_PLUGINS) -endif - -export LLVMC_BUILTIN_PLUGIN=1 - -include $(LEVEL)/Makefile.common diff --git a/contrib/llvm/tools/llvmc/example/Skeleton/plugins/Plugin/Makefile b/contrib/llvm/tools/llvmc/example/Skeleton/plugins/Plugin/Makefile deleted file mode 100644 index 54f7221..0000000 --- a/contrib/llvm/tools/llvmc/example/Skeleton/plugins/Plugin/Makefile +++ /dev/null @@ -1,17 +0,0 @@ -##===- llvmc/example/Skeleton/plugins/Plugin/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_BASE_LEVEL)/../.. - -# Change this to the name of your plugin. -LLVMC_PLUGIN = Plugin - -BUILT_SOURCES = AutoGenerated.inc - -include $(LEVEL)/Makefile.common diff --git a/contrib/llvm/tools/llvmc/example/Skeleton/plugins/Plugin/PluginMain.cpp b/contrib/llvm/tools/llvmc/example/Skeleton/plugins/Plugin/PluginMain.cpp deleted file mode 100644 index add8acb..0000000 --- a/contrib/llvm/tools/llvmc/example/Skeleton/plugins/Plugin/PluginMain.cpp +++ /dev/null @@ -1 +0,0 @@ -#include "AutoGenerated.inc" diff --git a/contrib/llvm/tools/llvmc/example/mcc16/Makefile b/contrib/llvm/tools/llvmc/example/mcc16/Makefile deleted file mode 100644 index e94bca2..0000000 --- a/contrib/llvm/tools/llvmc/example/mcc16/Makefile +++ /dev/null @@ -1,18 +0,0 @@ -##===- llvmc/example/mcc16/Makefile ------------------------*- Makefile -*-===## -# -# The LLVM Compiler Infrastructure -# -# This file is distributed under the University of Illinois Open -# Source License. See LICENSE.TXT for details. -# -##===----------------------------------------------------------------------===## - -export LLVMC_BASE_LEVEL = ../../../.. -export LLVMC_BASED_DRIVER_NAME = mcc16 -export LLVMC_BUILTIN_PLUGINS = PIC16Base - -LEVEL = $(LLVMC_BASE_LEVEL) - -DIRS = plugins driver - -include $(LEVEL)/Makefile.common diff --git a/contrib/llvm/tools/llvmc/example/mcc16/driver/Makefile b/contrib/llvm/tools/llvmc/example/mcc16/driver/Makefile deleted file mode 100644 index 670d8bd..0000000 --- a/contrib/llvm/tools/llvmc/example/mcc16/driver/Makefile +++ /dev/null @@ -1,13 +0,0 @@ -##===- llvmc/example/mcc16/driver/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_BASE_LEVEL)/.. -LLVMC_BASED_DRIVER = $(LLVMC_BASED_DRIVER_NAME) - -include $(LEVEL)/Makefile.common diff --git a/contrib/llvm/tools/llvmc/example/mcc16/plugins/Makefile b/contrib/llvm/tools/llvmc/example/mcc16/plugins/Makefile deleted file mode 100644 index fb07f23..0000000 --- a/contrib/llvm/tools/llvmc/example/mcc16/plugins/Makefile +++ /dev/null @@ -1,18 +0,0 @@ -##===- llvmc/example/Skeleton/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 = $(LLVMC_BASE_LEVEL)/.. - -ifneq ($(LLVMC_BUILTIN_PLUGINS),) -DIRS = $(LLVMC_BUILTIN_PLUGINS) -endif - -export LLVMC_BUILTIN_PLUGIN=1 - -include $(LEVEL)/Makefile.common diff --git a/contrib/llvm/tools/llvmc/example/mcc16/plugins/PIC16Base/Makefile b/contrib/llvm/tools/llvmc/example/mcc16/plugins/PIC16Base/Makefile deleted file mode 100644 index 5d785fd..0000000 --- a/contrib/llvm/tools/llvmc/example/mcc16/plugins/PIC16Base/Makefile +++ /dev/null @@ -1,17 +0,0 @@ -##===- llvmc/example/Skeleton/plugins/Plugin/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_BASE_LEVEL)/../.. - -# Change this to the name of your plugin. -LLVMC_PLUGIN = PIC16Base - -BUILT_SOURCES = AutoGenerated.inc - -include $(LEVEL)/Makefile.common diff --git a/contrib/llvm/tools/llvmc/examples/Hello/Hello.cpp b/contrib/llvm/tools/llvmc/examples/Hello/Hello.cpp new file mode 100644 index 0000000..71f04fd --- /dev/null +++ b/contrib/llvm/tools/llvmc/examples/Hello/Hello.cpp @@ -0,0 +1,29 @@ +//===- Hello.cpp - Example code from "Writing an LLVMC Plugin" ------------===// +// +// The LLVM Compiler Infrastructure +// +// This file is distributed under the University of Illinois Open Source +// License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// +// +// Shows how to write llvmc-based drivers without using TableGen. +// +//===----------------------------------------------------------------------===// + +#include "llvm/CompilerDriver/AutoGenerated.h" +#include "llvm/CompilerDriver/Main.inc" + +#include "llvm/Support/raw_ostream.h" + +namespace llvmc { +namespace autogenerated { + +int PreprocessOptions () { return 0; } + +int PopulateLanguageMap (LanguageMap&) { llvm::outs() << "Hello!\n"; return 0; } + +int PopulateCompilationGraph (CompilationGraph&) { return 0; } + +} +} diff --git a/contrib/llvm/tools/llvmc/example/Hello/Makefile b/contrib/llvm/tools/llvmc/examples/Hello/Makefile index 10325e6..c281be6 100644 --- a/contrib/llvm/tools/llvmc/example/Hello/Makefile +++ b/contrib/llvm/tools/llvmc/examples/Hello/Makefile @@ -1,4 +1,4 @@ -##===- tools/llvmc/plugins/Hello/Makefile ------------------*- Makefile -*-===## +##===- tools/llvmc/examples/Hello/Makefile -----------------*- Makefile -*-===## # # The LLVM Compiler Infrastructure # @@ -9,6 +9,6 @@ LEVEL = ../../../.. -LLVMC_PLUGIN = Hello +LLVMC_BASED_DRIVER = Hello include $(LEVEL)/Makefile.common diff --git a/contrib/llvm/tools/llvmc/example/Simple/Makefile b/contrib/llvm/tools/llvmc/examples/Makefile index d7adb5d..8468e93 100644 --- a/contrib/llvm/tools/llvmc/example/Simple/Makefile +++ b/contrib/llvm/tools/llvmc/examples/Makefile @@ -1,4 +1,4 @@ -##===- tools/llvmc/plugins/Simple/Makefile -----------------*- Makefile -*-===## +##===- tools/llvmc/examples/Makefile -----------------------*- Makefile -*-===## # # The LLVM Compiler Infrastructure # @@ -7,9 +7,8 @@ # ##===----------------------------------------------------------------------===## -LEVEL = ../../../.. +LEVEL=../../.. -LLVMC_PLUGIN = Simple -BUILT_SOURCES = AutoGenerated.inc +PARALLEL_DIRS := Hello Simple mcc16 Skeleton include $(LEVEL)/Makefile.common diff --git a/contrib/llvm/tools/llvmc/plugins/Clang/Makefile b/contrib/llvm/tools/llvmc/examples/Simple/Makefile index 5e5b88a..c10387c 100644 --- a/contrib/llvm/tools/llvmc/plugins/Clang/Makefile +++ b/contrib/llvm/tools/llvmc/examples/Simple/Makefile @@ -1,4 +1,4 @@ -##===- tools/llvmc/plugins/Clang/Makefile ------------------*- Makefile -*-===## +##===- llvmc/examples/Simple/Makefile ----------------------*- Makefile -*-===## # # The LLVM Compiler Infrastructure # @@ -9,7 +9,7 @@ LEVEL = ../../../.. -LLVMC_PLUGIN = Clang -BUILT_SOURCES = AutoGenerated.inc +LLVMC_BASED_DRIVER = Simple +BUILT_SOURCES = Simple.inc include $(LEVEL)/Makefile.common diff --git a/contrib/llvm/tools/llvmc/examples/Simple/Simple.cpp b/contrib/llvm/tools/llvmc/examples/Simple/Simple.cpp new file mode 100644 index 0000000..8ac7313 --- /dev/null +++ b/contrib/llvm/tools/llvmc/examples/Simple/Simple.cpp @@ -0,0 +1,2 @@ +#include "llvm/CompilerDriver/Main.inc" +#include "Simple.inc" diff --git a/contrib/llvm/tools/llvmc/example/Simple/Simple.td b/contrib/llvm/tools/llvmc/examples/Simple/Simple.td index 87bc385..b47483b 100644 --- a/contrib/llvm/tools/llvmc/example/Simple/Simple.td +++ b/contrib/llvm/tools/llvmc/examples/Simple/Simple.td @@ -1,4 +1,4 @@ -//===- Simple.td - A simple plugin for LLVMC ------------------------------===// +//===- Simple.td - A simple LLVMC-based driver ----------------------------===// // // The LLVM Compiler Infrastructure // @@ -7,19 +7,19 @@ // //===----------------------------------------------------------------------===// // -// A simple LLVMC-based gcc wrapper that shows how to write LLVMC plugins. +// A simple LLVMC-based gcc wrapper. // // To compile, use this command: // -// $ cd $LLVMC_DIR/example/Simple -// $ make +// $ cd $LLVM_OBJ_DIR/tools/llvmc +// $ make BUILD_EXAMPLES=1 // // Run as: // -// $ llvmc -load $LLVM_DIR/Release/lib/plugin_llvmc_Simple.so +// $ $LLVM_OBJ_DIR/$(BuildMode)/bin/Simple // // For instructions on how to build your own LLVMC-based driver, see -// the 'example/Skeleton' directory. +// the 'examples/Skeleton' directory. //===----------------------------------------------------------------------===// include "llvm/CompilerDriver/Common.td" @@ -28,10 +28,14 @@ def gcc : Tool< [(in_language "c"), (out_language "executable"), (output_suffix "out"), - (cmd_line "gcc $INFILE -o $OUTFILE"), - (sink) + (command "gcc"), + (sink), + + // -o is what is used by default, out_file_option here is included for + // instructive purposes. + (out_file_option "-o") ]>; -def LanguageMap : LanguageMap<[LangToSuffixes<"c", ["c"]>]>; +def LanguageMap : LanguageMap<[(lang_to_suffixes "c", "c")]>; -def CompilationGraph : CompilationGraph<[Edge<"root", "gcc">]>; +def CompilationGraph : CompilationGraph<[(edge "root", "gcc")]>; diff --git a/contrib/llvm/tools/llvmc/example/Skeleton/plugins/Plugin/Plugin.td b/contrib/llvm/tools/llvmc/examples/Skeleton/AutoGenerated.td index febb9ad..97483ce 100644 --- a/contrib/llvm/tools/llvmc/example/Skeleton/plugins/Plugin/Plugin.td +++ b/contrib/llvm/tools/llvmc/examples/Skeleton/AutoGenerated.td @@ -1,6 +1,6 @@ -//===- Plugin.td - A skeleton plugin for LLVMC -------------*- tablegen -*-===// +//===- AutoGenerated.td ------------------------------------*- tablegen -*-===// // -// Write the code for your plugin here. +// Write the TableGen description of your llvmc-based driver here. // //===----------------------------------------------------------------------===// diff --git a/contrib/llvm/tools/llvmc/examples/Skeleton/Hooks.cpp b/contrib/llvm/tools/llvmc/examples/Skeleton/Hooks.cpp new file mode 100644 index 0000000..ddd38f6 --- /dev/null +++ b/contrib/llvm/tools/llvmc/examples/Skeleton/Hooks.cpp @@ -0,0 +1,12 @@ +//===--- Hooks.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. +// +//===----------------------------------------------------------------------===// +// +// Hook definitions should go here. +// +//===----------------------------------------------------------------------===// diff --git a/contrib/llvm/tools/llvmc/driver/Main.cpp b/contrib/llvm/tools/llvmc/examples/Skeleton/Main.cpp index b1f5b67..24c7768 100644 --- a/contrib/llvm/tools/llvmc/driver/Main.cpp +++ b/contrib/llvm/tools/llvmc/examples/Skeleton/Main.cpp @@ -7,8 +7,9 @@ // //===----------------------------------------------------------------------===// // -// Just include CompilerDriver/Main.inc. +// Just include CompilerDriver/Main.inc and AutoGenerated.inc. // //===----------------------------------------------------------------------===// #include "llvm/CompilerDriver/Main.inc" +#include "AutoGenerated.inc" diff --git a/contrib/llvm/tools/llvmc/examples/Skeleton/Makefile b/contrib/llvm/tools/llvmc/examples/Skeleton/Makefile new file mode 100644 index 0000000..41ca823 --- /dev/null +++ b/contrib/llvm/tools/llvmc/examples/Skeleton/Makefile @@ -0,0 +1,20 @@ +##===- llvmc/examples/Skeleton/Makefile --------------------*- Makefile -*-===## +# +# The LLVM Compiler Infrastructure +# +# This file is distributed under the University of Illinois Open +# Source License. See LICENSE.TXT for details. +# +##===----------------------------------------------------------------------===## + +# Change this so that $(LEVEL)/Makefile.common refers to +# $LLVM_OBJ_DIR/Makefile.common or $YOUR_LLVM_BASED_PROJECT/Makefile.common. +export LEVEL = ../../../.. + +# Change this to the name of your LLVMC-based driver. +LLVMC_BASED_DRIVER = llvmc-skeleton + +# Change this to the name of .inc file built from your .td file. +BUILT_SOURCES = AutoGenerated.inc + +include $(LEVEL)/Makefile.common diff --git a/contrib/llvm/tools/llvmc/example/Skeleton/README b/contrib/llvm/tools/llvmc/examples/Skeleton/README index 92216ae..61ff6fb 100644 --- a/contrib/llvm/tools/llvmc/example/Skeleton/README +++ b/contrib/llvm/tools/llvmc/examples/Skeleton/README @@ -1,6 +1,6 @@ This is a template that can be used to create your own LLVMC-based drivers. Just copy the `Skeleton` directory to the location of your preference and edit -`Skeleton/Makefile` and `Skeleton/plugins/Plugin`. +`Skeleton/Makefile` and `Skeleton/AutoGenerated.inc`. The build system assumes that your project is based on LLVM. diff --git a/contrib/llvm/tools/llvmc/example/mcc16/plugins/PIC16Base/PluginMain.cpp b/contrib/llvm/tools/llvmc/examples/mcc16/Hooks.cpp index 9b2f9fc5..edb91e1 100644 --- a/contrib/llvm/tools/llvmc/example/mcc16/plugins/PIC16Base/PluginMain.cpp +++ b/contrib/llvm/tools/llvmc/examples/mcc16/Hooks.cpp @@ -1,19 +1,23 @@ -#include "AutoGenerated.inc" - #include "llvm/System/Path.h" +#include "llvm/Support/CommandLine.h" #include "llvm/Support/raw_ostream.h" -using namespace llvm; +#include <string> namespace llvmc { extern char *ProgramName; + + namespace autogenerated { + extern llvm::cl::opt<std::string> Parameter_p; + } } - +using namespace llvm; +using namespace llvmc; // Returns the platform specific directory separator via #ifdefs. -// FIXME: This currently work on linux and windows only. It does not -// work on other unices. +// FIXME: This currently work on linux and windows only. It does not +// work on other unices. static std::string GetDirSeparator() { #if __linux__ || __APPLE__ return "/"; @@ -28,14 +32,14 @@ namespace hooks { std::string GetLowerCasePartDefine(void) { std::string Partname; - if (AutoGeneratedParameter_p.empty()) { + if (autogenerated::Parameter_p.empty()) { Partname = "16f1xxx"; } else { - Partname = AutoGeneratedParameter_p; + Partname = autogenerated::Parameter_p; } std::string LowerCase; - for (unsigned i = 0; i <= Partname.size(); i++) { + for (unsigned i = 0; i < Partname.size(); i++) { LowerCase.push_back(std::tolower(Partname[i])); } @@ -45,26 +49,25 @@ GetLowerCasePartDefine(void) { std::string GetUpperCasePartDefine(void) { std::string Partname; - if (AutoGeneratedParameter_p.empty()) { + if (autogenerated::Parameter_p.empty()) { Partname = "16f1xxx"; } else { - Partname = AutoGeneratedParameter_p; + Partname = autogenerated::Parameter_p; } std::string UpperCase; - for (unsigned i = 0; i <= Partname.size(); i++) { + for (unsigned i = 0; i < Partname.size(); i++) { UpperCase.push_back(std::toupper(Partname[i])); } return "__" + UpperCase; } - // Get the dir where c16 executables reside. std::string GetBinDir() { - // Construct a Path object from the program name. + // Construct a Path object from the program name. void *P = (void*) (intptr_t) GetBinDir; - sys::Path ProgramFullPath + sys::Path ProgramFullPath = sys::Path::GetMainExecutable(llvmc::ProgramName, P); // Get the dir name for the program. It's last component should be 'bin'. @@ -80,7 +83,7 @@ std::string GetInstallDir() { // Go one more level up to get the install dir. std::string InstallDir = BinDirPath.getDirname(); - + return InstallDir + GetDirSeparator(); } diff --git a/contrib/llvm/tools/llvmc/example/mcc16/driver/Main.cpp b/contrib/llvm/tools/llvmc/examples/mcc16/Main.cpp index e66e2f9..55ae912 100644 --- a/contrib/llvm/tools/llvmc/example/mcc16/driver/Main.cpp +++ b/contrib/llvm/tools/llvmc/examples/mcc16/Main.cpp @@ -13,21 +13,25 @@ // //===----------------------------------------------------------------------===// -#include "llvm/Config/config.h" #include "llvm/CompilerDriver/BuiltinOptions.h" -#include "llvm/CompilerDriver/ForceLinkage.h" +#include "llvm/CompilerDriver/Main.h" + #include "llvm/System/Path.h" +#include "llvm/Config/config.h" + #include <iostream> -namespace llvmc { - int Main(int argc, char** argv); -} +#include "PIC16.inc" + +namespace { // Modify the PACKAGE_VERSION to use build number in top level configure file. void PIC16VersionPrinter(void) { std::cout << "MPLAB C16 1.0 " << PACKAGE_VERSION << "\n"; } +} + int main(int argc, char** argv) { // HACK @@ -36,7 +40,7 @@ int main(int argc, char** argv) { Languages.setHiddenFlag(llvm::cl::Hidden); DryRun.setHiddenFlag(llvm::cl::Hidden); - llvm::cl::SetVersionPrinter(PIC16VersionPrinter); + llvm::cl::SetVersionPrinter(PIC16VersionPrinter); // Ask for a standard temp dir, but just cache its basename., and delete it. llvm::sys::Path tempDir; @@ -49,6 +53,5 @@ int main(int argc, char** argv) { tempDir = TempDirname; tempDir.eraseFromDisk(true); - llvmc::ForceLinkage(); return llvmc::Main(argc, argv); } diff --git a/contrib/llvm/tools/llvmc/plugins/Base/Makefile b/contrib/llvm/tools/llvmc/examples/mcc16/Makefile index ebc4335..4409cff 100644 --- a/contrib/llvm/tools/llvmc/plugins/Base/Makefile +++ b/contrib/llvm/tools/llvmc/examples/mcc16/Makefile @@ -1,4 +1,4 @@ -##===- tools/llvmc/plugins/Base/Makefile -------------------*- Makefile -*-===## +##===- llvmc/examples/mcc16/Makefile -----------------------*- Makefile -*-===## # # The LLVM Compiler Infrastructure # @@ -9,7 +9,7 @@ LEVEL = ../../../.. -LLVMC_PLUGIN = Base -BUILT_SOURCES = AutoGenerated.inc +LLVMC_BASED_DRIVER = mcc16 +BUILT_SOURCES = PIC16.inc include $(LEVEL)/Makefile.common diff --git a/contrib/llvm/tools/llvmc/example/mcc16/plugins/PIC16Base/PIC16Base.td b/contrib/llvm/tools/llvmc/examples/mcc16/PIC16.td index 25149ad..6f04196 100644 --- a/contrib/llvm/tools/llvmc/example/mcc16/plugins/PIC16Base/PIC16Base.td +++ b/contrib/llvm/tools/llvmc/examples/mcc16/PIC16.td @@ -1,4 +1,4 @@ -//===- PIC16Base.td - PIC16 toolchain driver ---------------*- tablegen -*-===// +//===- PIC16.td - PIC16 toolchain driver -------------------*- tablegen -*-===// // // A basic driver for the PIC16 toolchain. // @@ -202,33 +202,33 @@ def mplink : Tool<[ // Language map def LanguageMap : LanguageMap<[ - LangToSuffixes<"c", ["c"]>, - LangToSuffixes<"c-cpp-output", ["i"]>, - LangToSuffixes<"assembler", ["s"]>, - LangToSuffixes<"assembler-with-cpp", ["S"]>, - LangToSuffixes<"llvm-assembler", ["ll"]>, - LangToSuffixes<"llvm-bitcode", ["bc"]>, - LangToSuffixes<"object-code", ["o"]>, - LangToSuffixes<"executable", ["cof"]> + (lang_to_suffixes "c", "c"), + (lang_to_suffixes "c-cpp-output", "i"), + (lang_to_suffixes "assembler", "s"), + (lang_to_suffixes "assembler-with-cpp", "S"), + (lang_to_suffixes "llvm-assembler", "ll"), + (lang_to_suffixes "llvm-bitcode", "bc"), + (lang_to_suffixes "object-code", "o"), + (lang_to_suffixes "executable", "cof") ]>; // Compilation graph def CompilationGraph : CompilationGraph<[ - Edge<"root", "clang_cc">, - Edge<"root", "llvm_ld">, - OptionalEdge<"root", "llvm_ld_optimizer", (case - (switch_on "S"), (inc_weight), - (switch_on "c"), (inc_weight))>, - Edge<"root", "gpasm">, - Edge<"root", "mplink">, - Edge<"clang_cc", "llvm_ld">, - OptionalEdge<"clang_cc", "llvm_ld_optimizer", (case - (switch_on "S"), (inc_weight), - (switch_on "c"), (inc_weight))>, - Edge<"llvm_ld", "pic16passes">, - Edge<"llvm_ld_optimizer", "pic16passes">, - Edge<"pic16passes", "llc">, - Edge<"llc", "gpasm">, - Edge<"gpasm", "mplink"> + (edge "root", "clang_cc"), + (edge "root", "llvm_ld"), + (optional_edge "root", "llvm_ld_optimizer", + (case (switch_on "S"), (inc_weight), + (switch_on "c"), (inc_weight))), + (edge "root", "gpasm"), + (edge "root", "mplink"), + (edge "clang_cc", "llvm_ld"), + (optional_edge "clang_cc", "llvm_ld_optimizer", + (case (switch_on "S"), (inc_weight), + (switch_on "c"), (inc_weight))), + (edge "llvm_ld", "pic16passes"), + (edge "llvm_ld_optimizer", "pic16passes"), + (edge "pic16passes", "llc"), + (edge "llc", "gpasm"), + (edge "gpasm", "mplink") ]>; diff --git a/contrib/llvm/tools/llvmc/example/mcc16/README b/contrib/llvm/tools/llvmc/examples/mcc16/README index eeef6a4..6d2b73d 100644 --- a/contrib/llvm/tools/llvmc/example/mcc16/README +++ b/contrib/llvm/tools/llvmc/examples/mcc16/README @@ -1,5 +1,5 @@ This is a basic compiler driver for the PIC16 toolchain that shows how to create -your own llvmc-based drivers. It is based on the example/Skeleton template. +your own llvmc-based drivers. It is based on the examples/Skeleton template. The PIC16 toolchain looks like this: diff --git a/contrib/llvm/tools/llvmc/plugins/Base/PluginMain.cpp b/contrib/llvm/tools/llvmc/plugins/Base/PluginMain.cpp deleted file mode 100644 index add8acb..0000000 --- a/contrib/llvm/tools/llvmc/plugins/Base/PluginMain.cpp +++ /dev/null @@ -1 +0,0 @@ -#include "AutoGenerated.inc" diff --git a/contrib/llvm/tools/llvmc/plugins/Clang/PluginMain.cpp b/contrib/llvm/tools/llvmc/plugins/Clang/PluginMain.cpp deleted file mode 100644 index add8acb..0000000 --- a/contrib/llvm/tools/llvmc/plugins/Clang/PluginMain.cpp +++ /dev/null @@ -1 +0,0 @@ -#include "AutoGenerated.inc" diff --git a/contrib/llvm/tools/llvmc/plugins/Makefile b/contrib/llvm/tools/llvmc/plugins/Makefile deleted file mode 100644 index 37dac6f..0000000 --- a/contrib/llvm/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/contrib/llvm/tools/llvmc/src/AutoGenerated.td b/contrib/llvm/tools/llvmc/src/AutoGenerated.td new file mode 100644 index 0000000..8507b1f --- /dev/null +++ b/contrib/llvm/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/contrib/llvm/tools/llvmc/plugins/Base/Base.td.in b/contrib/llvm/tools/llvmc/src/Base.td.in index a042997..0c4de4c 100644 --- a/contrib/llvm/tools/llvmc/plugins/Base/Base.td.in +++ b/contrib/llvm/tools/llvmc/src/Base.td.in @@ -11,7 +11,6 @@ // //===----------------------------------------------------------------------===// -include "llvm/CompilerDriver/Common.td" // Options @@ -263,7 +262,7 @@ def llc : Tool< // Base class for linkers class llvm_gcc_based_linker <string cmd_prefix, dag on_empty> : Tool< -[(in_language ["object-code", "static-library"]), +[(in_language ["object-code", "static-library", "dynamic-library"]), (out_language "executable"), (output_suffix "out"), (command cmd_prefix), @@ -305,73 +304,79 @@ def llvm_gcc_cpp_linker : llvm_gcc_based_linker<"@LLVMGXXCOMMAND@", // Language map -def LanguageMap : LanguageMap< - [LangToSuffixes<"c++", ["cc", "cp", "cxx", "cpp", "CPP", "c++", "C"]>, - LangToSuffixes<"c++-header", ["hpp"]>, - LangToSuffixes<"c", ["c"]>, - LangToSuffixes<"c-header", ["h"]>, - LangToSuffixes<"c-cpp-output", ["i"]>, - LangToSuffixes<"objective-c-cpp-output", ["mi"]>, - LangToSuffixes<"objective-c++", ["mm"]>, - LangToSuffixes<"objective-c++-header", ["hmm"]>, - LangToSuffixes<"objective-c", ["m"]>, - LangToSuffixes<"objective-c-header", ["hm"]>, - LangToSuffixes<"assembler", ["s"]>, - LangToSuffixes<"assembler-with-cpp", ["S"]>, - LangToSuffixes<"llvm-assembler", ["ll"]>, - LangToSuffixes<"llvm-bitcode", ["bc"]>, - LangToSuffixes<"object-code", ["o", "*empty*"]>, - LangToSuffixes<"static-library", ["a", "lib"]>, - LangToSuffixes<"executable", ["out"]> - ]>; +def LanguageMap : LanguageMap<[ + (lang_to_suffixes "c++", ["cc", "cp", "cxx", "cpp", "CPP", "c++", "C"]), + (lang_to_suffixes "c++-header", "hpp"), + (lang_to_suffixes "c", "c"), + (lang_to_suffixes "c-header", "h"), + (lang_to_suffixes "c-cpp-output", "i"), + (lang_to_suffixes "objective-c-cpp-output", "mi"), + (lang_to_suffixes "objective-c++", "mm"), + (lang_to_suffixes "objective-c++-header", "hmm"), + (lang_to_suffixes "objective-c", "m"), + (lang_to_suffixes "objective-c-header", "hm"), + (lang_to_suffixes "assembler", "s"), + (lang_to_suffixes "assembler-with-cpp", "S"), + (lang_to_suffixes "llvm-assembler", "ll"), + (lang_to_suffixes "llvm-bitcode", "bc"), + (lang_to_suffixes "object-code", ["o", "*empty*"]), + (lang_to_suffixes "static-library", ["a", "lib"]), + (lang_to_suffixes "dynamic-library", ["so", "dylib", "dll"]), + (lang_to_suffixes "executable", ["out"]) +]>; // Compilation graph 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", "llc">, + (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", "llc"), - Edge<"root", "llvm_gcc_c_pch">, - Edge<"root", "llvm_gcc_cpp_pch">, - Edge<"root", "llvm_gcc_m_pch">, - Edge<"root", "llvm_gcc_mxx_pch">, + (edge "root", "llvm_gcc_c_pch"), + (edge "root", "llvm_gcc_cpp_pch"), + (edge "root", "llvm_gcc_m_pch"), + (edge "root", "llvm_gcc_mxx_pch"), - Edge<"llvm_gcc_c", "llc">, - Edge<"llvm_gcc_cpp", "llc">, - Edge<"llvm_gcc_m", "llc">, - Edge<"llvm_gcc_mxx", "llc">, - Edge<"llvm_as", "llc">, + (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<"root", "llvm_as", - (case (switch_on "emit-llvm"), (inc_weight))>, - 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">, + (optional_edge "root", "llvm_as", + (case (switch_on "emit-llvm"), (inc_weight))), + (optional_edge "llvm_gcc_c", "opt", + (case (switch_on "opt"), (inc_weight))), + (optional_edge "llvm_gcc_cpp", "opt", + (case (switch_on "opt"), (inc_weight))), + (optional_edge "llvm_gcc_m", "opt", + (case (switch_on "opt"), (inc_weight))), + (optional_edge "llvm_gcc_mxx", "opt", + (case (switch_on "opt"), (inc_weight))), + (optional_edge "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", + (edge "llc", "llvm_gcc_assembler"), + (edge "llvm_gcc_assembler", "llvm_gcc_linker"), + (optional_edge "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))>, + (parameter_equals "linker", "c++")), (inc_weight))), - Edge<"root", "llvm_gcc_linker">, - OptionalEdge<"root", "llvm_gcc_cpp_linker", + (edge "root", "llvm_gcc_linker"), + (optional_edge "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))> - ]>; + (parameter_equals "linker", "c++")), (inc_weight))) +]>; diff --git a/contrib/llvm/tools/llvmc/plugins/Clang/Clang.td b/contrib/llvm/tools/llvmc/src/Clang.td index 988d9b1..1d75743 100644 --- a/contrib/llvm/tools/llvmc/plugins/Clang/Clang.td +++ b/contrib/llvm/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,31 +67,21 @@ 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<[ - OptionalEdge<"root", "clang_c", - (case (switch_on "clang"), (inc_weight))>, - OptionalEdge<"root", "clang_cpp", - (case (switch_on "clang"), (inc_weight))>, - OptionalEdge<"root", "clang_objective_c", - (case (switch_on "clang"), (inc_weight))>, - OptionalEdge<"root", "clang_objective_cpp", - (case (switch_on "clang"), (inc_weight))>, - Edge<"clang_c", "llc">, - Edge<"clang_cpp", "llc">, - Edge<"clang_objective_c", "llc">, - Edge<"clang_objective_cpp", "llc">, - OptionalEdge<"llc", "as", (case (switch_on "clang"), (inc_weight))>, - Edge<"as", "llvm_ld"> +def ClangCompilationGraph : CompilationGraph<[ + (optional_edge "root", "clang_c", + (case (switch_on "clang"), (inc_weight))), + (optional_edge "root", "clang_cpp", + (case (switch_on "clang"), (inc_weight))), + (optional_edge "root", "clang_objective_c", + (case (switch_on "clang"), (inc_weight))), + (optional_edge "root", "clang_objective_cpp", + (case (switch_on "clang"), (inc_weight))), + (edge "clang_c", "llc"), + (edge "clang_cpp", "llc"), + (edge "clang_objective_c", "llc"), + (edge "clang_objective_cpp", "llc"), + (optional_edge "llc", "as", (case (switch_on "clang"), (inc_weight))), + (edge "as", "llvm_ld") ]>; diff --git a/contrib/llvm/tools/llvmc/plugins/Base/Hooks.cpp b/contrib/llvm/tools/llvmc/src/Hooks.cpp index 661a914..661a914 100644 --- a/contrib/llvm/tools/llvmc/plugins/Base/Hooks.cpp +++ b/contrib/llvm/tools/llvmc/src/Hooks.cpp diff --git a/contrib/llvm/tools/llvmc/example/Skeleton/driver/Main.cpp b/contrib/llvm/tools/llvmc/src/Main.cpp index b1f5b67..9f9c71a 100644 --- a/contrib/llvm/tools/llvmc/example/Skeleton/driver/Main.cpp +++ b/contrib/llvm/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/contrib/llvm/tools/llvmc/driver/Makefile b/contrib/llvm/tools/llvmc/src/Makefile index 2f3104b..f3f3091 100644 --- a/contrib/llvm/tools/llvmc/driver/Makefile +++ b/contrib/llvm/tools/llvmc/src/Makefile @@ -1,4 +1,4 @@ -##===- tools/llvmc/driver/Makefile -------------------------*- Makefile -*-===## +##===- tools/llvmc/src/Makefile ----------------------------*- Makefile -*-===## # # The LLVM Compiler Infrastructure # @@ -8,6 +8,7 @@ ##===----------------------------------------------------------------------===## LEVEL = ../../.. -LLVMC_BASED_DRIVER = $(LLVMC_BASED_DRIVER_NAME) +LLVMC_BASED_DRIVER = llvmc +BUILT_SOURCES = AutoGenerated.inc include $(LEVEL)/Makefile.common |