aboutsummaryrefslogtreecommitdiffstats
path: root/tools
diff options
context:
space:
mode:
Diffstat (limited to 'tools')
-rw-r--r--tools/Makefile27
-rw-r--r--tools/bugpoint/CrashDebugger.cpp2
-rw-r--r--tools/bugpoint/ExtractFunction.cpp2
-rw-r--r--tools/llc/llc.cpp14
-rw-r--r--tools/llvm-config/CMakeLists.txt2
-rw-r--r--tools/llvm-config/Makefile4
-rw-r--r--tools/llvm-extract/llvm-extract.cpp52
-rw-r--r--tools/llvm-mc/llvm-mc.cpp4
-rw-r--r--tools/llvm-shlib/Makefile60
-rw-r--r--tools/llvmc/doc/LLVMC-Reference.rst26
-rw-r--r--tools/llvmc/example/mcc16/plugins/PIC16Base/PIC16Base.td42
-rw-r--r--tools/llvmc/plugins/Base/Base.td.in146
-rw-r--r--tools/llvmc/plugins/Clang/Clang.td37
-rw-r--r--tools/opt/opt.cpp3
14 files changed, 274 insertions, 147 deletions
diff --git a/tools/Makefile b/tools/Makefile
index c9b9ff2..86ba72d 100644
--- a/tools/Makefile
+++ b/tools/Makefile
@@ -21,8 +21,8 @@ PARALLEL_DIRS := opt llvm-as llvm-dis \
llvm-ld llvm-prof llvm-link \
lli llvm-extract \
bugpoint llvm-bcanalyzer llvm-stub \
- llvm-mc llvmc \
- edis
+ llvm-mc llvmc
+
# Let users override the set of tools to build from the command line.
ifdef ONLY_TOOLS
@@ -32,16 +32,27 @@ endif
include $(LEVEL)/Makefile.config
+# These libraries build as dynamic libraries (.dylib /.so), they can only be
+# built if ENABLE_PIC is set.
ifeq ($(ENABLE_PIC),1)
- DIRS += lto
- ifdef BINUTILS_INCDIR
- DIRS += gold
+ # No support for dynamic libraries on windows targets.
+ ifneq ($(TARGET_OS), $(filter $(TARGET_OS), Cygwin MingW))
+ PARALLEL_DIRS += edis
+
+ # gold only builds if binutils is around. It requires "lto" to build before
+ # it so it is added to DIRS.
+ ifdef BINUTILS_INCDIR
+ PARALLEL_DIRS += gold
+ DIRS += lto
+ else
+ PARALLEL_DIRS += lto
+ endif
endif
endif
-# No support for lto / gold on windows targets
-ifeq ($(TARGET_OS), $(filter $(TARGET_OS), Cygwin MingW))
- DIRS := $(filter-out lto gold, $(DIRS))
+# Only build edis if X86 target support is enabled.
+ifeq ($(filter $(TARGETS_TO_BUILD), X86),)
+ PARALLEL_DIRS := $(filter-out edis, $(PARALLEL_DIRS))
endif
include $(LEVEL)/Makefile.common
diff --git a/tools/bugpoint/CrashDebugger.cpp b/tools/bugpoint/CrashDebugger.cpp
index b348a08..b51bdb4 100644
--- a/tools/bugpoint/CrashDebugger.cpp
+++ b/tools/bugpoint/CrashDebugger.cpp
@@ -295,7 +295,7 @@ bool ReduceCrashingBlocks::TestBlocks(std::vector<const BasicBlock*> &BBs) {
TerminatorInst *BBTerm = BB->getTerminator();
- if (isa<StructType>(BBTerm->getType()))
+ if (BBTerm->getType()->isStructTy())
BBTerm->replaceAllUsesWith(UndefValue::get(BBTerm->getType()));
else if (BB->getTerminator()->getType() !=
Type::getVoidTy(BB->getContext()))
diff --git a/tools/bugpoint/ExtractFunction.cpp b/tools/bugpoint/ExtractFunction.cpp
index 70011a7..eaa2c53 100644
--- a/tools/bugpoint/ExtractFunction.cpp
+++ b/tools/bugpoint/ExtractFunction.cpp
@@ -73,7 +73,7 @@ Module *BugDriver::deleteInstructionFromProgram(const Instruction *I,
Instruction *TheInst = RI; // Got the corresponding instruction!
// If this instruction produces a value, replace any users with null values
- if (isa<StructType>(TheInst->getType()))
+ if (TheInst->getType()->isStructTy())
TheInst->replaceAllUsesWith(UndefValue::get(TheInst->getType()));
else if (TheInst->getType() != Type::getVoidTy(I->getContext()))
TheInst->replaceAllUsesWith(Constant::getNullValue(TheInst->getType()));
diff --git a/tools/llc/llc.cpp b/tools/llc/llc.cpp
index fe34bd1..810ba42 100644
--- a/tools/llc/llc.cpp
+++ b/tools/llc/llc.cpp
@@ -305,6 +305,14 @@ int main(int argc, char **argv) {
case '3': OLvl = CodeGenOpt::Aggressive; break;
}
+ // Request that addPassesToEmitFile run the Verifier after running
+ // passes which modify the IR.
+#ifndef NDEBUG
+ bool DisableVerify = false;
+#else
+ bool DisableVerify = true;
+#endif
+
// If this target requires addPassesToEmitWholeFile, do it now. This is
// used by strange things like the C backend.
if (Target.WantsWholeFile()) {
@@ -320,7 +328,8 @@ int main(int argc, char **argv) {
PM.add(createVerifierPass());
// Ask the target to add backend passes as necessary.
- if (Target.addPassesToEmitWholeFile(PM, *Out, FileType, OLvl)) {
+ if (Target.addPassesToEmitWholeFile(PM, *Out, FileType, OLvl,
+ DisableVerify)) {
errs() << argv[0] << ": target does not support generation of this"
<< " file type!\n";
if (Out != &fouts()) delete Out;
@@ -347,7 +356,8 @@ int main(int argc, char **argv) {
// Override default to generate verbose assembly.
Target.setAsmVerbosityDefault(true);
- if (Target.addPassesToEmitFile(Passes, *Out, FileType, OLvl)) {
+ if (Target.addPassesToEmitFile(Passes, *Out, FileType, OLvl,
+ DisableVerify)) {
errs() << argv[0] << ": target does not support generation of this"
<< " file type!\n";
if (Out != &fouts()) delete Out;
diff --git a/tools/llvm-config/CMakeLists.txt b/tools/llvm-config/CMakeLists.txt
index 8a710ea..7a43dba 100644
--- a/tools/llvm-config/CMakeLists.txt
+++ b/tools/llvm-config/CMakeLists.txt
@@ -18,8 +18,6 @@ execute_process(COMMAND date
#set(LLVMGCCDIR "")
#set(LLVMGCC "")
#set(LLVMGXX "")
-#set(LLVMGCC_VERSION "")
-#set(LLVMGCC_MAJVERS "")
test_big_endian(IS_BIG_ENDIAN)
if( IS_BIG_ENDIAN )
set(ENDIAN "big")
diff --git a/tools/llvm-config/Makefile b/tools/llvm-config/Makefile
index cc5cf43..c7f7b32 100644
--- a/tools/llvm-config/Makefile
+++ b/tools/llvm-config/Makefile
@@ -126,6 +126,6 @@ clean-local::
$(LibDeps) GenLibDeps.out
install-local:: all-local
$(Echo) Installing llvm-config
- $(Verb) $(MKDIR) $(PROJ_bindir)
- $(Verb) $(ScriptInstall) $(ToolDir)/llvm-config $(PROJ_bindir)
+ $(Verb) $(MKDIR) $(DESTDIR)$(PROJ_bindir)
+ $(Verb) $(ScriptInstall) $(ToolDir)/llvm-config $(DESTDIR)$(PROJ_bindir)
diff --git a/tools/llvm-extract/llvm-extract.cpp b/tools/llvm-extract/llvm-extract.cpp
index 517244f..231634c 100644
--- a/tools/llvm-extract/llvm-extract.cpp
+++ b/tools/llvm-extract/llvm-extract.cpp
@@ -49,15 +49,15 @@ static cl::opt<bool>
Relink("relink",
cl::desc("Turn external linkage for callees of function to delete"));
-// ExtractFunc - The function to extract from the module...
-static cl::opt<std::string>
-ExtractFunc("func", cl::desc("Specify function to extract"), cl::init(""),
- cl::value_desc("function"));
+// ExtractFuncs - The functions to extract from the module...
+static cl::list<std::string>
+ExtractFuncs("func", cl::desc("Specify function to extract"),
+ cl::ZeroOrMore, cl::value_desc("function"));
-// ExtractGlobal - The global to extract from the module...
-static cl::opt<std::string>
-ExtractGlobal("glob", cl::desc("Specify global to extract"), cl::init(""),
- cl::value_desc("global"));
+// ExtractGlobals - The globals to extract from the module...
+static cl::list<std::string>
+ExtractGlobals("glob", cl::desc("Specify global to extract"),
+ cl::ZeroOrMore, cl::value_desc("global"));
static cl::opt<bool>
OutputAssembly("S",
@@ -81,28 +81,34 @@ int main(int argc, char **argv) {
return 1;
}
- // Figure out which function we should extract
- GlobalVariable *G = !ExtractGlobal.empty() ?
- M.get()->getNamedGlobal(ExtractGlobal) : 0;
-
- // Figure out which function we should extract
- if (ExtractFunc.empty() && ExtractGlobal.empty()) ExtractFunc = "main";
- Function *F = M.get()->getFunction(ExtractFunc);
+ std::vector<GlobalValue *> GVs;
+
+ // Figure out which globals we should extract.
+ for (size_t i = 0, e = ExtractGlobals.size(); i != e; ++i) {
+ GlobalValue *GV = M.get()->getNamedGlobal(ExtractGlobals[i]);
+ if (!GV) {
+ errs() << argv[0] << ": program doesn't contain global named '"
+ << ExtractGlobals[i] << "'!\n";
+ return 1;
+ }
+ GVs.push_back(GV);
+ }
- if (F == 0 && G == 0) {
- errs() << argv[0] << ": program doesn't contain function named '"
- << ExtractFunc << "' or a global named '" << ExtractGlobal << "'!\n";
- return 1;
+ // Figure out which functions we should extract.
+ for (size_t i = 0, e = ExtractFuncs.size(); i != e; ++i) {
+ GlobalValue *GV = M.get()->getFunction(ExtractFuncs[i]);
+ if (!GV) {
+ errs() << argv[0] << ": program doesn't contain function named '"
+ << ExtractFuncs[i] << "'!\n";
+ return 1;
+ }
+ GVs.push_back(GV);
}
// In addition to deleting all other functions, we also want to spiff it
// up a little bit. Do this now.
PassManager Passes;
Passes.add(new TargetData(M.get())); // Use correct TargetData
- // Either isolate the function or delete it from the Module
- std::vector<GlobalValue*> GVs;
- if (F) GVs.push_back(F);
- if (G) GVs.push_back(G);
Passes.add(createGVExtractionPass(GVs, DeleteFn, Relink));
if (!DeleteFn)
diff --git a/tools/llvm-mc/llvm-mc.cpp b/tools/llvm-mc/llvm-mc.cpp
index c05bd52..76ce080 100644
--- a/tools/llvm-mc/llvm-mc.cpp
+++ b/tools/llvm-mc/llvm-mc.cpp
@@ -266,14 +266,14 @@ static int AssembleInput(const char *ProgName) {
if (FileType == OFT_AssemblyFile) {
IP.reset(TheTarget->createMCInstPrinter(OutputAsmVariant, *MAI, *Out));
if (ShowEncoding)
- CE.reset(TheTarget->createCodeEmitter(*TM));
+ CE.reset(TheTarget->createCodeEmitter(*TM, Ctx));
Str.reset(createAsmStreamer(Ctx, *Out, *MAI,
TM->getTargetData()->isLittleEndian(),
/*asmverbose*/true, IP.get(), CE.get(),
ShowInst));
} else {
assert(FileType == OFT_ObjectFile && "Invalid file type!");
- CE.reset(TheTarget->createCodeEmitter(*TM));
+ CE.reset(TheTarget->createCodeEmitter(*TM, Ctx));
Str.reset(createMachOStreamer(Ctx, *Out, CE.get()));
}
diff --git a/tools/llvm-shlib/Makefile b/tools/llvm-shlib/Makefile
new file mode 100644
index 0000000..ce29bf8
--- /dev/null
+++ b/tools/llvm-shlib/Makefile
@@ -0,0 +1,60 @@
+##===- tools/shlib/Makefile --------------------------------*- Makefile -*-===##
+#
+# The LLVM Compiler Infrastructure
+#
+# This file is distributed under the University of Illinois Open Source
+# License. See LICENSE.TXT for details.
+#
+##===----------------------------------------------------------------------===##
+
+LEVEL = ../..
+
+LIBRARYNAME = LLVM-$(LLVMVersion)
+
+NO_BUILD_ARCHIVE = 1
+LINK_LIBS_IN_SHARED = 1
+SHARED_LIBRARY = 1
+
+include $(LEVEL)/Makefile.common
+
+# Include all archives in libLLVM.(so|dylib) except the ones that have
+# their own dynamic libraries.
+Archives := $(wildcard $(LibDir)/libLLVM*.a)
+SharedLibraries := $(wildcard $(LibDir)/libLLVM*$(SHLIBEXT))
+IncludeInLibLlvm := $(filter-out $(basename $(SharedLibraries)).a, $(Archives))
+LLVMLibsOptions := $(IncludeInLibLlvm:$(LibDir)/lib%.a=-l%)
+LLVMLibsPaths := $(IncludeInLibLlvm)
+
+$(LibName.SO): $(LLVMLibsPaths)
+
+ifeq ($(HOST_OS),Darwin)
+ # set dylib internal version number to llvmCore submission number
+ ifdef LLVM_SUBMIT_VERSION
+ LLVMLibsOptions := $(LLVMLibsOptions) -Wl,-current_version \
+ -Wl,$(LLVM_SUBMIT_VERSION).$(LLVM_SUBMIT_SUBVERSION) \
+ -Wl,-compatibility_version -Wl,1
+ endif
+ # Include everything from the .a's into the shared library.
+ LLVMLibsOptions := $(LLVMLibsOptions) -all_load
+ # extra options to override libtool defaults
+ LLVMLibsOptions := $(LLVMLibsOptions) \
+ -avoid-version \
+ -Wl,-dead_strip \
+ -Wl,-seg1addr -Wl,0xE0000000
+
+ # Mac OS X 10.4 and earlier tools do not allow a second -install_name on command line
+ DARWIN_VERS := $(shell echo $(TARGET_TRIPLE) | sed 's/.*darwin\([0-9]*\).*/\1/')
+ ifneq ($(DARWIN_VERS),8)
+ LLVMLibsOptions := $(LLVMLibsOptions) \
+ -Wl,-install_name \
+ -Wl,"@executable_path/../lib/lib$(LIBRARYNAME)$(SHLIBEXT)"
+ endif
+endif
+
+ifeq ($(HOST_OS), Linux)
+ # Include everything from the .a's into the shared library.
+ LLVMLibsOptions := -Wl,--whole-archive $(LLVMLibsOptions) \
+ -Wl,--no-whole-archive
+ # Don't allow unresolved symbols.
+ LLVMLibsOptions += -Wl,--no-undefined
+endif
diff --git a/tools/llvmc/doc/LLVMC-Reference.rst b/tools/llvmc/doc/LLVMC-Reference.rst
index dfe3898..ca8500d 100644
--- a/tools/llvmc/doc/LLVMC-Reference.rst
+++ b/tools/llvmc/doc/LLVMC-Reference.rst
@@ -329,16 +329,22 @@ separate option groups syntactically.
- ``required`` - this option must be specified exactly once (or, in case of
the list options without the ``multi_val`` property, at least
- once). Incompatible with ``zero_or_one`` and ``one_or_more``.
-
- - ``one_or_more`` - the option must be specified at least one time. Useful
- only for list options in conjunction with ``multi_val``; for ordinary lists
- it is synonymous with ``required``. Incompatible with ``required`` and
- ``zero_or_one``.
-
- - ``optional`` - the option can be specified zero or one times. Useful only
- for list options in conjunction with ``multi_val``. Incompatible with
- ``required`` and ``one_or_more``.
+ once). Incompatible with ``optional`` and ``one_or_more``.
+
+ - ``optional`` - the option can be specified either zero times or exactly
+ once. The default for switch options. Useful only for list options in
+ conjunction with ``multi_val``. Incompatible with ``required``,
+ ``zero_or_more`` and ``one_or_more``.
+
+ - ``one_or_more`` - the option must be specified at least once. Can be useful
+ to allow switch options be both obligatory and be specified multiple
+ times. For list options is useful only in conjunction with ``multi_val``;
+ for ordinary it is synonymous with ``required``. Incompatible with
+ ``required``, ``optional`` and ``zero_or_more``.
+
+ - ``zero_or_more`` - the option can be specified zero or more times. Useful
+ to allow a single switch option to be specified more than
+ once. Incompatible with ``required``, ``optional`` and ``one_or_more``.
- ``hidden`` - the description of this option will not appear in
the ``--help`` output (but will appear in the ``--help-hidden``
diff --git a/tools/llvmc/example/mcc16/plugins/PIC16Base/PIC16Base.td b/tools/llvmc/example/mcc16/plugins/PIC16Base/PIC16Base.td
index f13b9f8..25149ad 100644
--- a/tools/llvmc/example/mcc16/plugins/PIC16Base/PIC16Base.td
+++ b/tools/llvmc/example/mcc16/plugins/PIC16Base/PIC16Base.td
@@ -56,7 +56,7 @@ def OptionList : OptionList<[
// (parameter_option "pre-RA-sched",
// (help "Example of an option that is passed to llc")),
(parameter_option "regalloc",
- (help "Register allocator to use.(possible values: simple, linearscan, pbqp, local. default = linearscan)")),
+ (help "Register allocator to use (possible values: simple, linearscan, pbqp, local; default=linearscan)")),
(prefix_list_option "Wa,", (comma_separated),
(help "Pass options to assembler (Run 'gpasm -help' for assembler options)")),
(prefix_list_option "Wl,", (comma_separated),
@@ -72,16 +72,14 @@ class clang_based<string language, string cmd, string ext_E> : Tool<
[(in_language language),
(out_language "llvm-bitcode"),
(output_suffix "bc"),
- (cmd_line (case
- (switch_on "E"),
- (case
- (not_empty "o"), !strconcat(cmd, " -E $INFILE -o $OUTFILE"),
- (default), !strconcat(cmd, " -E $INFILE")),
- (default), !strconcat(cmd, " $INFILE -o $OUTFILE"))),
- (actions (case
- (and (multiple_input_files), (or (switch_on "S"), (switch_on "c"))),
- (error "cannot specify -o with -c or -S with multiple files"),
- (switch_on "E"), [(stop_compilation), (output_suffix ext_E)],
+ (command cmd),
+ (actions (case
+ (and (multiple_input_files),
+ (or (switch_on "S"), (switch_on "c"))),
+ (error "cannot specify -o with -c or -S with multiple files"),
+ (switch_on "E"), [(forward "E"),
+ (stop_compilation), (output_suffix ext_E)],
+ (and (switch_on "E"), (empty "o")), (no_out_file),
(switch_on "bc"),[(stop_compilation), (output_suffix "bc")],
(switch_on "g"), (append_cmd "-g"),
(switch_on "w"), (append_cmd "-w"),
@@ -116,12 +114,13 @@ def llvm_ld : Tool<[
(in_language "llvm-bitcode"),
(out_language "llvm-bitcode"),
(output_suffix "bc"),
- (cmd_line "$CALL(GetBinDir)llvm-ld -L $CALL(GetStdLibsDir) -disable-gvn -disable-licm-promotion -disable-mem2reg $INFILE -b $OUTFILE -l std"),
+ (command "$CALL(GetBinDir)llvm-ld -L $CALL(GetStdLibsDir) -disable-licm-promotion -l std"),
+ (out_file_option "-b"),
(actions (case
(switch_on "O0"), (append_cmd "-disable-opt"),
(switch_on "O1"), (append_cmd "-disable-opt"),
// Whenever O3 is not specified on the command line, default i.e. disable-inlining will always be added.
- (switch_on "O2"), (append_cmd ""),
+ (switch_on "O2"), (append_cmd ""),
(switch_on "O3"), (append_cmd ""),
(default), (append_cmd "-disable-inlining"))),
(join)
@@ -134,12 +133,13 @@ def llvm_ld_optimizer : Tool<[
(output_suffix "bc"),
// FIXME: we are still not disabling licm-promotion.
// -disable-licm-promotion and building stdn library causes c16-71 to fail.
- (cmd_line "$CALL(GetBinDir)llvm-ld -disable-gvn -disable-mem2reg $INFILE -b $OUTFILE"),
+ (command "$CALL(GetBinDir)llvm-ld "),
+ (out_file_option "-b"),
(actions (case
(switch_on "O0"), (append_cmd "-disable-opt"),
(switch_on "O1"), (append_cmd "-disable-opt"),
// Whenever O3 is not specified on the command line, default i.e. disable-inlining will always be added.
- (switch_on "O2"), (append_cmd ""),
+ (switch_on "O2"), (append_cmd ""),
(switch_on "O3"), (append_cmd ""),
(default), (append_cmd "-disable-inlining")))
]>;
@@ -149,7 +149,7 @@ def pic16passes : Tool<[
(in_language "llvm-bitcode"),
(out_language "llvm-bitcode"),
(output_suffix "obc"),
- (cmd_line "$CALL(GetBinDir)opt -pic16cg -pic16overlay $INFILE -f -o $OUTFILE"),
+ (command "$CALL(GetBinDir)opt -pic16cloner -pic16overlay -f"),
(actions (case
(switch_on "O0"), (append_cmd "-disable-opt")))
]>;
@@ -158,7 +158,7 @@ def llc : Tool<[
(in_language "llvm-bitcode"),
(out_language "assembler"),
(output_suffix "s"),
- (cmd_line "$CALL(GetBinDir)llc -march=pic16 -disable-jump-tables -pre-RA-sched=list-burr -f $INFILE -o $OUTFILE"),
+ (command "$CALL(GetBinDir)llc -march=pic16 -disable-jump-tables -pre-RA-sched=list-burr -f"),
(actions (case
(switch_on "S"), (stop_compilation),
// (not_empty "Wllc,"), (unpack_values "Wllc,"),
@@ -171,7 +171,7 @@ def gpasm : Tool<[
(in_language "assembler"),
(out_language "object-code"),
(output_suffix "o"),
- (cmd_line "$CALL(GetBinDir)gpasm -z -r decimal -I $CALL(GetStdAsmHeadersDir) -C -c -w 2 $INFILE -o $OUTFILE"),
+ (command "$CALL(GetBinDir)gpasm -z -r decimal -I $CALL(GetStdAsmHeadersDir) -C -c -w 2"),
(actions (case
(switch_on "c"), (stop_compilation),
(switch_on "g"), (append_cmd "-g"),
@@ -184,7 +184,7 @@ def mplink : Tool<[
(in_language "object-code"),
(out_language "executable"),
(output_suffix "cof"),
- (cmd_line "$CALL(GetBinDir)mplink -e -k $CALL(GetStdLinkerScriptsDir) -l $CALL(GetStdLibsDir) intrinsics.lib stdn.lib $INFILE -o $OUTFILE"),
+ (command "$CALL(GetBinDir)mplink -e -k $CALL(GetStdLinkerScriptsDir) -l $CALL(GetStdLibsDir) intrinsics.lib stdn.lib"),
(actions (case
(not_empty "Wl,"), (forward_value "Wl,"),
(switch_on "X"), (append_cmd "-x"),
@@ -217,13 +217,13 @@ def LanguageMap : LanguageMap<[
def CompilationGraph : CompilationGraph<[
Edge<"root", "clang_cc">,
Edge<"root", "llvm_ld">,
- OptionalEdge<"root", "llvm_ld_optimizer", (case
+ 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
+ OptionalEdge<"clang_cc", "llvm_ld_optimizer", (case
(switch_on "S"), (inc_weight),
(switch_on "c"), (inc_weight))>,
Edge<"llvm_ld", "pic16passes">,
diff --git a/tools/llvmc/plugins/Base/Base.td.in b/tools/llvmc/plugins/Base/Base.td.in
index c94c3df..ac0f665 100644
--- a/tools/llvmc/plugins/Base/Base.td.in
+++ b/tools/llvmc/plugins/Base/Base.td.in
@@ -25,13 +25,13 @@ def OptList : OptionList<[
(switch_option "opt",
(help "Enable opt")),
(switch_option "O0",
- (help "Turn off optimization")),
+ (help "Turn off optimization"), (zero_or_more)),
(switch_option "O1",
- (help "Optimization level 1")),
+ (help "Optimization level 1"), (zero_or_more)),
(switch_option "O2",
- (help "Optimization level 2")),
+ (help "Optimization level 2"), (zero_or_more)),
(switch_option "O3",
- (help "Optimization level 3")),
+ (help "Optimization level 3"), (zero_or_more)),
(switch_option "S",
(help "Stop after compilation, do not assemble")),
(switch_option "c",
@@ -49,12 +49,7 @@ def OptList : OptionList<[
(parameter_option "linker",
(help "Choose linker (possible values: gcc, g++)")),
(parameter_option "mtune",
- (help "Target a specific CPU type"), (hidden)),
- (parameter_option "fmessage-length",
- (help "Format error messages to fit on lines of about n characters "),
- (hidden)),
- (parameter_option "std",
- (help "Determine the language standard"), (hidden)),
+ (help "Target a specific CPU type"), (hidden), (forward_not_split)),
// TODO: Add a conditional compilation mechanism to make Darwin-only options
// like '-arch' really Darwin-only.
@@ -62,9 +57,11 @@ def OptList : OptionList<[
(parameter_option "arch",
(help "Compile for the specified target architecture"), (hidden)),
(parameter_option "march",
- (help "A synonym for -mtune"), (hidden)),
+ (help "A synonym for -mtune"), (hidden), (forward_not_split)),
(parameter_option "mcpu",
- (help "A deprecated synonym for -mtune"), (hidden)),
+ (help "A deprecated synonym for -mtune"), (hidden), (forward_not_split)),
+ (switch_option "mfix-and-continue",
+ (help "Needed by gdb to load .o files dynamically"), (hidden)),
(parameter_option "MF",
(help "Specify a file to write dependencies to"), (hidden)),
(parameter_list_option "MT",
@@ -79,14 +76,20 @@ def OptList : OptionList<[
(help "Specifies a framework to link against")),
(parameter_list_option "weak_framework",
(help "Specifies a framework to weakly link against"), (hidden)),
+ (parameter_option "filelist", (hidden),
+ (help "Link the files listed in file")),
(prefix_list_option "F",
(help "Add a directory to framework search path")),
(prefix_list_option "I",
(help "Add a directory to include path")),
(prefix_list_option "D",
(help "Define a macro")),
+ (parameter_list_option "Xpreprocessor", (hidden),
+ (help "Pass options to preprocessor")),
(prefix_list_option "Wa,", (comma_separated),
(help "Pass options to assembler")),
+ (parameter_list_option "Xassembler", (hidden),
+ (help "Pass options to assembler")),
(prefix_list_option "Wllc,", (comma_separated),
(help "Pass options to llc")),
(prefix_list_option "L",
@@ -95,11 +98,27 @@ def OptList : OptionList<[
(help "Search a library when linking")),
(prefix_list_option "Wl,",
(help "Pass options to linker")),
+ (parameter_list_option "Xlinker", (hidden),
+ (help "Pass options to linker")),
(prefix_list_option "Wo,", (comma_separated),
(help "Pass options to opt")),
(prefix_list_option "m",
(help "Enable or disable various extensions (-mmmx, -msse, etc.)"),
- (hidden))
+ (hidden)),
+ (switch_option "dynamiclib", (hidden),
+ (help "Produce a dynamic library")),
+ (switch_option "prebind", (hidden),
+ (help "Prebind all undefined symbols")),
+ (switch_option "dead_strip", (hidden),
+ (help "Remove unreachable blocks of code")),
+ (switch_option "single_module", (hidden),
+ (help "Build the library so it contains only one module")),
+ (parameter_option "install_name", (hidden),
+ (help "File name the library will be installed in")),
+ (parameter_option "compatibility_version", (hidden),
+ (help "Compatibility version number")),
+ (parameter_option "current_version", (hidden),
+ (help "Current version number"))
]>;
// Option preprocessor.
@@ -117,31 +136,31 @@ def Preprocess : OptionPreprocessor<
// Tools
-class llvm_gcc_based <string cmd_prefix, string in_lang, string E_ext> : Tool<
+class llvm_gcc_based <string cmd_prefix, string in_lang,
+ string E_ext, string out_lang> : Tool<
[(in_language in_lang),
(out_language "llvm-bitcode"),
- (output_suffix "bc"),
- (cmd_line (case
- (switch_on "E"),
- (case (not_empty "o"),
- !strconcat(cmd_prefix, " -E $INFILE -o $OUTFILE"),
- (default),
- !strconcat(cmd_prefix, " -E $INFILE")),
- (switch_on "fsyntax-only"),
- !strconcat(cmd_prefix, " -fsyntax-only $INFILE"),
- (and (switch_on "S"), (switch_on "emit-llvm")),
- !strconcat(cmd_prefix, " -S $INFILE -o $OUTFILE -emit-llvm"),
- (default),
- !strconcat(cmd_prefix, " -c $INFILE -o $OUTFILE -emit-llvm"))),
+ (output_suffix out_lang),
+ (command cmd_prefix),
(actions
(case
- (and (multiple_input_files), (or (switch_on "S"), (switch_on "c"))),
+ (and (not_empty "o"),
+ (multiple_input_files), (or (switch_on "S"), (switch_on "c"))),
(error "cannot specify -o with -c or -S with multiple files"),
- (switch_on "E"), [(stop_compilation), (output_suffix E_ext)],
+ (switch_on "E"),
+ [(forward "E"), (stop_compilation), (output_suffix E_ext)],
+ (and (switch_on "E"), (empty "o")), (no_out_file),
(switch_on ["emit-llvm", "S"]),
[(output_suffix "ll"), (stop_compilation)],
(switch_on ["emit-llvm", "c"]), (stop_compilation),
- (switch_on "fsyntax-only"), (stop_compilation),
+ (switch_on "fsyntax-only"), [(forward "fsyntax-only"),
+ (no_out_file), (stop_compilation)],
+ (switch_on ["S", "emit-llvm"]), [(forward "S"), (forward "emit-llvm")],
+ (not (or (switch_on ["S", "emit-llvm"]), (switch_on "fsyntax-only"))),
+ [(append_cmd "-c"), (append_cmd "-emit-llvm")],
+
+ // Forwards
+ (not_empty "Xpreprocessor"), (forward "Xpreprocessor"),
(not_empty "include"), (forward "include"),
(not_empty "iquote"), (forward "iquote"),
(not_empty "save-temps"), (append_cmd "-save-temps"),
@@ -153,8 +172,7 @@ class llvm_gcc_based <string cmd_prefix, string in_lang, string E_ext> : Tool<
(not_empty "mtune"), (forward "mtune"),
(not_empty "mcpu"), (forward "mcpu"),
(not_empty "m"), (forward "m"),
- (not_empty "std"), (forward "std"),
- (not_empty "fmessage-length"), (forward "fmessage-length"),
+ (switch_on "mfix-and-continue"), (forward "mfix-and-continue"),
(switch_on "m32"), (forward "m32"),
(switch_on "m64"), (forward "m64"),
(switch_on "O0"), (forward "O0"),
@@ -168,12 +186,24 @@ class llvm_gcc_based <string cmd_prefix, string in_lang, string E_ext> : Tool<
(sink)
]>;
-def llvm_gcc_c : llvm_gcc_based<"@LLVMGCCCOMMAND@ -x c", "c", "i">;
-def llvm_gcc_cpp : llvm_gcc_based<"@LLVMGXXCOMMAND@ -x c++", "c++", "i">;
+def llvm_gcc_c : llvm_gcc_based<"@LLVMGCCCOMMAND@ -x c", "c", "i", "bc">;
+def llvm_gcc_cpp : llvm_gcc_based<"@LLVMGXXCOMMAND@ -x c++", "c++", "i", "bc">;
def llvm_gcc_m : llvm_gcc_based<"@LLVMGCCCOMMAND@ -x objective-c",
- "objective-c", "mi">;
+ "objective-c", "mi", "bc">;
def llvm_gcc_mxx : llvm_gcc_based<"@LLVMGCCCOMMAND@ -x objective-c++",
- "objective-c++", "mi">;
+ "objective-c++", "mi", "bc">;
+
+def llvm_gcc_c_pch : llvm_gcc_based<"@LLVMGCCCOMMAND@ -x c-header",
+ "c-header", "i", "gch">;
+def llvm_gcc_cpp_pch : llvm_gcc_based<"@LLVMGXXCOMMAND@ -x c++-header",
+ "c++-header",
+ "i", "gch">;
+def llvm_gcc_m_pch : llvm_gcc_based<"@LLVMGCCCOMMAND@ -x objective-c-header",
+ "objective-c-header",
+ "mi", "gch">;
+def llvm_gcc_mxx_pch
+ : llvm_gcc_based<"@LLVMGCCCOMMAND@ -x objective-c++-header",
+ "objective-c++-header", "mi", "gch">;
def opt : Tool<
[(in_language "llvm-bitcode"),
@@ -183,14 +213,14 @@ def opt : Tool<
(switch_on "O1"), (forward "O1"),
(switch_on "O2"), (forward "O2"),
(switch_on "O3"), (forward "O3"))),
- (cmd_line "opt -f $INFILE -o $OUTFILE")
+ (command "opt -f")
]>;
def llvm_as : Tool<
[(in_language "llvm-assembler"),
(out_language "llvm-bitcode"),
(output_suffix "bc"),
- (cmd_line "llvm-as $INFILE -o $OUTFILE"),
+ (command "llvm-as"),
(actions (case (switch_on "emit-llvm"), (stop_compilation)))
]>;
@@ -198,19 +228,19 @@ def llvm_gcc_assembler : Tool<
[(in_language "assembler"),
(out_language "object-code"),
(output_suffix "o"),
- (cmd_line "@LLVMGCCCOMMAND@ -c -x assembler $INFILE -o $OUTFILE"),
+ (command "@LLVMGCCCOMMAND@ -c -x assembler"),
(actions (case
(switch_on "c"), (stop_compilation),
(not_empty "arch"), (forward "arch"),
- (not_empty "fmessage-length"), (forward "fmessage-length"),
- (not_empty "Wa,"), (forward_value "Wa,")))
+ (not_empty "Xassembler"), (forward "Xassembler"),
+ (not_empty "Wa,"), (forward "Wa,")))
]>;
def llc : Tool<
[(in_language ["llvm-bitcode", "llvm-assembler"]),
(out_language "assembler"),
(output_suffix "s"),
- (cmd_line "llc -f $INFILE -o $OUTFILE"),
+ (command "llc -f"),
(actions (case
(switch_on "S"), (stop_compilation),
(switch_on "O0"), (forward "O0"),
@@ -220,8 +250,8 @@ def llc : Tool<
(switch_on "fPIC"), (append_cmd "-relocation-model=pic"),
(switch_on "mdynamic-no-pic"),
(append_cmd "-relocation-model=dynamic-no-pic"),
- (not_empty "march"), (forward "mcpu"),
- (not_empty "mtune"), (forward "mcpu"),
+ (not_empty "march"), (forward_as "mtune", "-mcpu"),
+ (not_empty "mtune"), (forward_as "mtune", "-mcpu"),
(not_empty "mcpu"), (forward "mcpu"),
(not_empty "m"), (forward_transformed_value "m", "ConvertToMAttr"),
(not_empty "Wllc,"), (forward_value "Wllc,")))
@@ -232,7 +262,9 @@ class llvm_gcc_based_linker <string cmd_prefix> : Tool<
[(in_language "object-code"),
(out_language "executable"),
(output_suffix "out"),
- (cmd_line !strconcat(cmd_prefix, " $INFILE -o $OUTFILE")),
+ (command cmd_prefix),
+ (works_on_empty (case (not_empty "filelist"), true,
+ (default), false)),
(join),
(actions (case
(switch_on "pthread"), (append_cmd "-lpthread"),
@@ -241,11 +273,20 @@ class llvm_gcc_based_linker <string cmd_prefix> : Tool<
(not_empty "arch"), (forward "arch"),
(not_empty "framework"), (forward "framework"),
(not_empty "weak_framework"), (forward "weak_framework"),
+ (not_empty "filelist"), (forward "filelist"),
(switch_on "m32"), (forward "m32"),
(switch_on "m64"), (forward "m64"),
- (not_empty "fmessage-length"), (forward "fmessage-length"),
(not_empty "l"), (forward "l"),
- (not_empty "Wl,"), (forward "Wl,")))
+ (not_empty "Xlinker"), (forward "Xlinker"),
+ (not_empty "Wl,"), (forward "Wl,"),
+ (switch_on "dynamiclib"), (forward "dynamiclib"),
+ (switch_on "prebind"), (forward "prebind"),
+ (switch_on "dead_strip"), (forward "dead_strip"),
+ (switch_on "single_module"), (forward "single_module"),
+ (not_empty "compatibility_version"),
+ (forward "compatibility_version"),
+ (not_empty "current_version"), (forward "current_version"),
+ (not_empty "install_name"), (forward "install_name")))
]>;
// Default linker
@@ -257,16 +298,20 @@ def llvm_gcc_cpp_linker : llvm_gcc_based_linker<"@LLVMGXXCOMMAND@">;
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"]>,
+ LangToSuffixes<"object-code", ["o", "*empty*"]>,
LangToSuffixes<"executable", ["out"]>
]>;
@@ -280,6 +325,11 @@ def CompilationGraph : CompilationGraph<[
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<"llvm_gcc_c", "llc">,
Edge<"llvm_gcc_cpp", "llc">,
Edge<"llvm_gcc_m", "llc">,
diff --git a/tools/llvmc/plugins/Clang/Clang.td b/tools/llvmc/plugins/Clang/Clang.td
index ac8ac15..988d9b1 100644
--- a/tools/llvmc/plugins/Clang/Clang.td
+++ b/tools/llvmc/plugins/Clang/Clang.td
@@ -1,12 +1,3 @@
-// A replacement for the Clang's ccc script.
-// Depends on the Base plugin.
-// To compile, use this command:
-//
-// cd $LLVMC2_DIR
-// make DRIVER_NAME=ccc2 BUILTIN_PLUGINS=Clang
-//
-// Or just use the default llvmc, which now has this plugin enabled.
-
include "llvm/CompilerDriver/Common.td"
def Priority : PluginPriority<1>;
@@ -33,23 +24,17 @@ class clang_based<string language, string cmd, string ext_E> : Tool<
[(in_language language),
(out_language "llvm-bitcode"),
(output_suffix "bc"),
- (cmd_line (case
- (switch_on "E"),
- (case
- (not_empty "o"),
- !strconcat(cmd, " -E $INFILE -o $OUTFILE"),
- (default),
- !strconcat(cmd, " -E $INFILE")),
- (and (switch_on "S"), (switch_on "emit-llvm")),
- !strconcat(cmd, " -emit-llvm $INFILE -o $OUTFILE"),
- (default),
- !strconcat(cmd, " -emit-llvm-bc $INFILE -o $OUTFILE"))),
+ (command cmd),
(actions (case (switch_on "E"),
- [(stop_compilation), (output_suffix ext_E)],
+ [(forward "E"), (stop_compilation), (output_suffix ext_E)],
+ (and (switch_on "E"), (empty "o")), (no_out_file),
(switch_on "fsyntax-only"), (stop_compilation),
- (and (switch_on "S"), (switch_on "emit-llvm")),
- [(stop_compilation), (output_suffix "ll")],
- (and (switch_on "c"), (switch_on "emit-llvm")),
+ (switch_on ["S", "emit-llvm"]),
+ [(append_cmd "-emit-llvm"),
+ (stop_compilation), (output_suffix "ll")],
+ (not (switch_on ["S", "emit-llvm"])),
+ (append_cmd "-emit-llvm-bc"),
+ (switch_on ["c", "emit-llvm"]),
(stop_compilation),
(not_empty "include"), (forward "include"),
(not_empty "I"), (forward "I"))),
@@ -67,7 +52,7 @@ def as : Tool<
[(in_language "assembler"),
(out_language "object-code"),
(output_suffix "o"),
- (cmd_line "as $INFILE -o $OUTFILE"),
+ (command "as"),
(actions (case (not_empty "Wa,"), (forward_value "Wa,"),
(switch_on "c"), (stop_compilation)))
]>;
@@ -77,7 +62,7 @@ def llvm_ld : Tool<
[(in_language "object-code"),
(out_language "executable"),
(output_suffix "out"),
- (cmd_line "llvm-ld -native -disable-internalize $INFILE -o $OUTFILE"),
+ (command "llvm-ld -native -disable-internalize"),
(actions (case
(switch_on "pthread"), (append_cmd "-lpthread"),
(not_empty "L"), (forward "L"),
diff --git a/tools/opt/opt.cpp b/tools/opt/opt.cpp
index 5200180..b123d54 100644
--- a/tools/opt/opt.cpp
+++ b/tools/opt/opt.cpp
@@ -475,10 +475,11 @@ int main(int argc, char **argv) {
errs() << argv[0] << ": cannot create pass: "
<< PassInf->getPassName() << "\n";
if (P) {
+ PassKind Kind = P->getPassKind();
addPass(Passes, P);
if (AnalyzeOnly) {
- switch (P->getPassKind()) {
+ switch (Kind) {
case PT_BasicBlock:
Passes.add(new BasicBlockPassPrinter(PassInf));
break;