[llvm-commits] [llvm] r82957 - in /llvm/trunk: include/llvm/CompilerDriver/Common.td tools/llvmc/doc/LLVMC-Reference.rst tools/llvmc/plugins/Base/Base.td.in utils/TableGen/LLVMCConfigurationEmitter.cpp
Mikhail Glushenkov
foldr at codedgers.com
Sun Sep 27 18:16:42 PDT 2009
Author: foldr
Date: Sun Sep 27 20:16:42 2009
New Revision: 82957
URL: http://llvm.org/viewvc/llvm-project?rev=82957&view=rev
Log:
Add a way to query the number of input files.
Modified:
llvm/trunk/include/llvm/CompilerDriver/Common.td
llvm/trunk/tools/llvmc/doc/LLVMC-Reference.rst
llvm/trunk/tools/llvmc/plugins/Base/Base.td.in
llvm/trunk/utils/TableGen/LLVMCConfigurationEmitter.cpp
Modified: llvm/trunk/include/llvm/CompilerDriver/Common.td
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/CompilerDriver/Common.td?rev=82957&r1=82956&r2=82957&view=diff
==============================================================================
--- llvm/trunk/include/llvm/CompilerDriver/Common.td (original)
+++ llvm/trunk/include/llvm/CompilerDriver/Common.td Sun Sep 27 20:16:42 2009
@@ -66,6 +66,8 @@
def empty;
def not_empty;
def default;
+def single_input_file;
+def multiple_input_files;
// Possible actions.
Modified: llvm/trunk/tools/llvmc/doc/LLVMC-Reference.rst
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/tools/llvmc/doc/LLVMC-Reference.rst?rev=82957&r1=82956&r2=82957&view=diff
==============================================================================
--- llvm/trunk/tools/llvmc/doc/LLVMC-Reference.rst (original)
+++ llvm/trunk/tools/llvmc/doc/LLVMC-Reference.rst Sun Sep 27 20:16:42 2009
@@ -458,6 +458,13 @@
- ``empty`` - The opposite of ``not_empty``. Equivalent to ``(not (not_empty
X))``. Provided for convenience.
+ - ``single_input_file`` - Returns true if there was only one input file
+ provided on the command-line. Used without arguments:
+ ``(single_input_file)``.
+
+ - ``multiple_input_files`` - Equivalent to ``(not (single_input_file))`` (the
+ case of zero input files is considered an error).
+
- ``default`` - Always evaluates to true. Should always be the last
test in the ``case`` expression.
Modified: llvm/trunk/tools/llvmc/plugins/Base/Base.td.in
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/tools/llvmc/plugins/Base/Base.td.in?rev=82957&r1=82956&r2=82957&view=diff
==============================================================================
--- llvm/trunk/tools/llvmc/plugins/Base/Base.td.in (original)
+++ llvm/trunk/tools/llvmc/plugins/Base/Base.td.in Sun Sep 27 20:16:42 2009
@@ -70,6 +70,8 @@
!strconcat(cmd_prefix, " -c $INFILE -o $OUTFILE -emit-llvm"))),
(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 E_ext)],
(and (switch_on "emit-llvm"), (switch_on "S")),
[(output_suffix "ll"), (stop_compilation)],
Modified: llvm/trunk/utils/TableGen/LLVMCConfigurationEmitter.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/utils/TableGen/LLVMCConfigurationEmitter.cpp?rev=82957&r1=82956&r2=82957&view=diff
==============================================================================
--- llvm/trunk/utils/TableGen/LLVMCConfigurationEmitter.cpp (original)
+++ llvm/trunk/utils/TableGen/LLVMCConfigurationEmitter.cpp Sun Sep 27 20:16:42 2009
@@ -976,8 +976,22 @@
}
}
-/// EmitCaseTest1Arg - Helper function used by
-/// EmitCaseConstructHandler.
+/// EmitCaseTest0Args - Helper function used by EmitCaseConstructHandler().
+bool EmitCaseTest0Args(const std::string& TestName, raw_ostream& O) {
+ if (TestName == "single_input_file") {
+ O << "InputFilenames.size() == 1";
+ return true;
+ }
+ else if (TestName == "multiple_input_files") {
+ O << "InputFilenames.size() > 1";
+ return true;
+ }
+
+ return false;
+}
+
+
+/// EmitCaseTest1Arg - Helper function used by EmitCaseConstructHandler().
bool EmitCaseTest1Arg(const std::string& TestName,
const DagInit& d,
const OptionDescriptions& OptDescs,
@@ -1021,8 +1035,7 @@
return false;
}
-/// EmitCaseTest2Args - Helper function used by
-/// EmitCaseConstructHandler.
+/// EmitCaseTest2Args - Helper function used by EmitCaseConstructHandler().
bool EmitCaseTest2Args(const std::string& TestName,
const DagInit& d,
unsigned IndentLevel,
@@ -1101,6 +1114,8 @@
EmitLogicalOperationTest(d, "||", IndentLevel, OptDescs, O);
else if (TestName == "not")
EmitLogicalNot(d, IndentLevel, OptDescs, O);
+ else if (EmitCaseTest0Args(TestName, O))
+ return;
else if (EmitCaseTest1Arg(TestName, d, OptDescs, O))
return;
else if (EmitCaseTest2Args(TestName, d, IndentLevel, OptDescs, O))
@@ -2043,7 +2058,8 @@
/// EmitIncludes - Emit necessary #include directives and some
/// additional declarations.
void EmitIncludes(raw_ostream& O) {
- O << "#include \"llvm/CompilerDriver/CompilationGraph.h\"\n"
+ O << "#include \"llvm/CompilerDriver/BuiltinOptions.h\"\n"
+ << "#include \"llvm/CompilerDriver/CompilationGraph.h\"\n"
<< "#include \"llvm/CompilerDriver/ForceLinkageMacros.h\"\n"
<< "#include \"llvm/CompilerDriver/Plugin.h\"\n"
<< "#include \"llvm/CompilerDriver/Tool.h\"\n\n"
More information about the llvm-commits
mailing list