[llvm-commits] [llvm] r56459 - in /llvm/trunk: tools/llvmc2/Common.td tools/llvmc2/doc/LLVMC-Reference.rst utils/TableGen/LLVMCConfigurationEmitter.cpp
Mikhail Glushenkov
foldr at codedgers.com
Mon Sep 22 13:46:20 PDT 2008
Author: foldr
Date: Mon Sep 22 15:46:19 2008
New Revision: 56459
URL: http://llvm.org/viewvc/llvm-project?rev=56459&view=rev
Log:
Add a (forward_as) option property
Modified:
llvm/trunk/tools/llvmc2/Common.td
llvm/trunk/tools/llvmc2/doc/LLVMC-Reference.rst
llvm/trunk/utils/TableGen/LLVMCConfigurationEmitter.cpp
Modified: llvm/trunk/tools/llvmc2/Common.td
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/tools/llvmc2/Common.td?rev=56459&r1=56458&r2=56459&view=diff
==============================================================================
--- llvm/trunk/tools/llvmc2/Common.td (original)
+++ llvm/trunk/tools/llvmc2/Common.td Mon Sep 22 15:46:19 2008
@@ -1,4 +1,4 @@
-//===- Common.td - Common definitions for LLVMCC ----------*- tablegen -*-===//
+//===- Common.td - Common definitions for LLVMC2 ----------*- tablegen -*-===//
//
// The LLVM Compiler Infrastructure
//
@@ -7,7 +7,7 @@
//
//===----------------------------------------------------------------------===//
//
-// This file contains common definitions used in llvmcc tool description files.
+// This file contains common definitions used in llvmc2 tool description files.
//
//===----------------------------------------------------------------------===//
@@ -41,6 +41,7 @@
def append_cmd;
def forward;
+def forward_as;
def stop_compilation;
def unpack_values;
def help;
@@ -58,7 +59,6 @@
def element_in_list;
def input_languages_contain;
def not_empty;
-// TOTHINK: remove?
def default;
// Boolean operators.
Modified: llvm/trunk/tools/llvmc2/doc/LLVMC-Reference.rst
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/tools/llvmc2/doc/LLVMC-Reference.rst?rev=56459&r1=56458&r2=56459&view=diff
==============================================================================
--- llvm/trunk/tools/llvmc2/doc/LLVMC-Reference.rst (original)
+++ llvm/trunk/tools/llvmc2/doc/LLVMC-Reference.rst Mon Sep 22 15:46:19 2008
@@ -250,8 +250,11 @@
- ``forward`` - forward this option unchanged.
+ - ``forward_as`` - Change the name of this option, but forward the
+ argument unchanged. Example: ``(forward_as "--disable-optimize")``.
+
- ``output_suffix`` - modify the output suffix of this
- tool. Example : ``(switch "E", (output_suffix "i")``.
+ tool. Example: ``(switch "E", (output_suffix "i")``.
- ``stop_compilation`` - stop compilation after this phase.
Modified: llvm/trunk/utils/TableGen/LLVMCConfigurationEmitter.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/utils/TableGen/LLVMCConfigurationEmitter.cpp?rev=56459&r1=56458&r2=56459&view=diff
==============================================================================
--- llvm/trunk/utils/TableGen/LLVMCConfigurationEmitter.cpp (original)
+++ llvm/trunk/utils/TableGen/LLVMCConfigurationEmitter.cpp Mon Sep 22 15:46:19 2008
@@ -155,11 +155,18 @@
std::string EscapeVariableName(const std::string& Var) const {
std::string ret;
for (unsigned i = 0; i != Var.size(); ++i) {
- if (Var[i] == ',') {
+ char cur_char = Var[i];
+ if (cur_char == ',') {
+ ret += "_comma_";
+ }
+ else if (cur_char == '+') {
+ ret += "_plus_";
+ }
+ else if (cur_char == ',') {
ret += "_comma_";
}
else {
- ret.push_back(Var[i]);
+ ret.push_back(cur_char);
}
}
return ret;
@@ -279,7 +286,7 @@
Forward = 0x2, UnpackValues = 0x4};
}
namespace OptionPropertyType {
- enum OptionPropertyType { AppendCmd, OutputSuffix };
+ enum OptionPropertyType { AppendCmd, ForwardAs, OutputSuffix };
}
typedef std::pair<OptionPropertyType::OptionPropertyType, std::string>
@@ -399,6 +406,8 @@
&CollectOptionProperties::onAppendCmd;
optionPropertyHandlers_["forward"] =
&CollectOptionProperties::onForward;
+ optionPropertyHandlers_["forward_as"] =
+ &CollectOptionProperties::onForwardAs;
optionPropertyHandlers_["help"] =
&CollectOptionProperties::onHelp;
optionPropertyHandlers_["output_suffix"] =
@@ -466,6 +475,15 @@
toolProps_->OptDescs[optDesc_.Name].setForward();
}
+ void onForwardAs (const DagInit* d) {
+ checkNumberOfArguments(d, 1);
+ checkToolProps(d);
+ const std::string& cmd = InitPtrToString(d->getArg(0));
+
+ toolProps_->OptDescs[optDesc_.Name].
+ AddProperty(OptionPropertyType::ForwardAs, cmd);
+ }
+
void onHelp (const DagInit* d) {
checkNumberOfArguments(d, 1);
const std::string& help_message = InitPtrToString(d->getArg(0));
@@ -956,26 +974,31 @@
/// EmitForwardOptionPropertyHandlingCode - Helper function used to
/// implement EmitOptionPropertyHandlingCode(). Emits code for
-/// handling the (forward) option property.
+/// handling the (forward) and (forward_as) option properties.
void EmitForwardOptionPropertyHandlingCode (const ToolOptionDescription& D,
+ const std::string& NewName,
std::ostream& O) {
+ const std::string& Name = NewName.empty()
+ ? ("-" + D.Name)
+ : NewName;
+
switch (D.Type) {
case OptionType::Switch:
- O << Indent3 << "vec.push_back(\"-" << D.Name << "\");\n";
+ O << Indent3 << "vec.push_back(\"" << Name << "\");\n";
break;
case OptionType::Parameter:
- O << Indent3 << "vec.push_back(\"-" << D.Name << "\");\n";
+ O << Indent3 << "vec.push_back(\"" << Name << "\");\n";
O << Indent3 << "vec.push_back(" << D.GenVariableName() << ");\n";
break;
case OptionType::Prefix:
- O << Indent3 << "vec.push_back(\"-" << D.Name << "\" + "
+ O << Indent3 << "vec.push_back(\"" << Name << "\" + "
<< D.GenVariableName() << ");\n";
break;
case OptionType::PrefixList:
O << Indent3 << "for (" << D.GenTypeDeclaration()
<< "::iterator B = " << D.GenVariableName() << ".begin(),\n"
<< Indent3 << "E = " << D.GenVariableName() << ".end(); B != E; ++B)\n"
- << Indent4 << "vec.push_back(\"-" << D.Name << "\" + "
+ << Indent4 << "vec.push_back(\"" << Name << "\" + "
<< "*B);\n";
break;
case OptionType::ParameterList:
@@ -983,7 +1006,7 @@
<< "::iterator B = " << D.GenVariableName() << ".begin(),\n"
<< Indent3 << "E = " << D.GenVariableName()
<< ".end() ; B != E; ++B) {\n"
- << Indent4 << "vec.push_back(\"-" << D.Name << "\");\n"
+ << Indent4 << "vec.push_back(\"" << Name << "\");\n"
<< Indent4 << "vec.push_back(*B);\n"
<< Indent3 << "}\n";
break;
@@ -1001,7 +1024,8 @@
for (OptionPropertyList::const_iterator B = D.Props.begin(),
E = D.Props.end(); B != E; ++B) {
const OptionProperty& OptProp = *B;
- if (OptProp.first == OptionPropertyType::AppendCmd)
+ if (OptProp.first == OptionPropertyType::AppendCmd
+ || OptProp.first == OptionPropertyType::ForwardAs)
ret = true;
}
if (D.isForward() || D.isUnpackValues())
@@ -1036,6 +1060,10 @@
case OptionPropertyType::AppendCmd:
O << Indent3 << "vec.push_back(\"" << val.second << "\");\n";
break;
+ // (forward_as) property
+ case OptionPropertyType::ForwardAs:
+ EmitForwardOptionPropertyHandlingCode(D, val.second, O);
+ break;
// Other properties with argument
default:
break;
@@ -1046,7 +1074,7 @@
// (forward) property
if (D.isForward())
- EmitForwardOptionPropertyHandlingCode(D, O);
+ EmitForwardOptionPropertyHandlingCode(D, "", O);
// (unpack_values) property
if (D.isUnpackValues()) {
More information about the llvm-commits
mailing list