mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2024-11-02 07:11:49 +00:00
Add a (forward_as) option property
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@56459 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
parent
5ccf28f168
commit
fdee954623
@ -1,4 +1,4 @@
|
|||||||
//===- Common.td - Common definitions for LLVMCC ----------*- tablegen -*-===//
|
//===- Common.td - Common definitions for LLVMC2 ----------*- tablegen -*-===//
|
||||||
//
|
//
|
||||||
// The LLVM Compiler Infrastructure
|
// 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 prefix_list_option;
|
|||||||
|
|
||||||
def append_cmd;
|
def append_cmd;
|
||||||
def forward;
|
def forward;
|
||||||
|
def forward_as;
|
||||||
def stop_compilation;
|
def stop_compilation;
|
||||||
def unpack_values;
|
def unpack_values;
|
||||||
def help;
|
def help;
|
||||||
@ -58,7 +59,6 @@ def parameter_equals;
|
|||||||
def element_in_list;
|
def element_in_list;
|
||||||
def input_languages_contain;
|
def input_languages_contain;
|
||||||
def not_empty;
|
def not_empty;
|
||||||
// TOTHINK: remove?
|
|
||||||
def default;
|
def default;
|
||||||
|
|
||||||
// Boolean operators.
|
// Boolean operators.
|
||||||
|
@ -250,8 +250,11 @@ currently implemented option types and properties are described below:
|
|||||||
|
|
||||||
- ``forward`` - forward this option unchanged.
|
- ``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
|
- ``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.
|
- ``stop_compilation`` - stop compilation after this phase.
|
||||||
|
|
||||||
|
@ -155,11 +155,18 @@ struct OptionDescription {
|
|||||||
std::string EscapeVariableName(const std::string& Var) const {
|
std::string EscapeVariableName(const std::string& Var) const {
|
||||||
std::string ret;
|
std::string ret;
|
||||||
for (unsigned i = 0; i != Var.size(); ++i) {
|
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_";
|
ret += "_comma_";
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
ret.push_back(Var[i]);
|
ret.push_back(cur_char);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return ret;
|
return ret;
|
||||||
@ -279,7 +286,7 @@ namespace ToolOptionDescriptionFlags {
|
|||||||
Forward = 0x2, UnpackValues = 0x4};
|
Forward = 0x2, UnpackValues = 0x4};
|
||||||
}
|
}
|
||||||
namespace OptionPropertyType {
|
namespace OptionPropertyType {
|
||||||
enum OptionPropertyType { AppendCmd, OutputSuffix };
|
enum OptionPropertyType { AppendCmd, ForwardAs, OutputSuffix };
|
||||||
}
|
}
|
||||||
|
|
||||||
typedef std::pair<OptionPropertyType::OptionPropertyType, std::string>
|
typedef std::pair<OptionPropertyType::OptionPropertyType, std::string>
|
||||||
@ -399,6 +406,8 @@ public:
|
|||||||
&CollectOptionProperties::onAppendCmd;
|
&CollectOptionProperties::onAppendCmd;
|
||||||
optionPropertyHandlers_["forward"] =
|
optionPropertyHandlers_["forward"] =
|
||||||
&CollectOptionProperties::onForward;
|
&CollectOptionProperties::onForward;
|
||||||
|
optionPropertyHandlers_["forward_as"] =
|
||||||
|
&CollectOptionProperties::onForwardAs;
|
||||||
optionPropertyHandlers_["help"] =
|
optionPropertyHandlers_["help"] =
|
||||||
&CollectOptionProperties::onHelp;
|
&CollectOptionProperties::onHelp;
|
||||||
optionPropertyHandlers_["output_suffix"] =
|
optionPropertyHandlers_["output_suffix"] =
|
||||||
@ -466,6 +475,15 @@ private:
|
|||||||
toolProps_->OptDescs[optDesc_.Name].setForward();
|
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) {
|
void onHelp (const DagInit* d) {
|
||||||
checkNumberOfArguments(d, 1);
|
checkNumberOfArguments(d, 1);
|
||||||
const std::string& help_message = InitPtrToString(d->getArg(0));
|
const std::string& help_message = InitPtrToString(d->getArg(0));
|
||||||
@ -956,26 +974,31 @@ void EmitCaseConstructHandler(const DagInit* d, const char* IndentLevel,
|
|||||||
|
|
||||||
/// EmitForwardOptionPropertyHandlingCode - Helper function used to
|
/// EmitForwardOptionPropertyHandlingCode - Helper function used to
|
||||||
/// implement EmitOptionPropertyHandlingCode(). Emits code for
|
/// implement EmitOptionPropertyHandlingCode(). Emits code for
|
||||||
/// handling the (forward) option property.
|
/// handling the (forward) and (forward_as) option properties.
|
||||||
void EmitForwardOptionPropertyHandlingCode (const ToolOptionDescription& D,
|
void EmitForwardOptionPropertyHandlingCode (const ToolOptionDescription& D,
|
||||||
|
const std::string& NewName,
|
||||||
std::ostream& O) {
|
std::ostream& O) {
|
||||||
|
const std::string& Name = NewName.empty()
|
||||||
|
? ("-" + D.Name)
|
||||||
|
: NewName;
|
||||||
|
|
||||||
switch (D.Type) {
|
switch (D.Type) {
|
||||||
case OptionType::Switch:
|
case OptionType::Switch:
|
||||||
O << Indent3 << "vec.push_back(\"-" << D.Name << "\");\n";
|
O << Indent3 << "vec.push_back(\"" << Name << "\");\n";
|
||||||
break;
|
break;
|
||||||
case OptionType::Parameter:
|
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";
|
O << Indent3 << "vec.push_back(" << D.GenVariableName() << ");\n";
|
||||||
break;
|
break;
|
||||||
case OptionType::Prefix:
|
case OptionType::Prefix:
|
||||||
O << Indent3 << "vec.push_back(\"-" << D.Name << "\" + "
|
O << Indent3 << "vec.push_back(\"" << Name << "\" + "
|
||||||
<< D.GenVariableName() << ");\n";
|
<< D.GenVariableName() << ");\n";
|
||||||
break;
|
break;
|
||||||
case OptionType::PrefixList:
|
case OptionType::PrefixList:
|
||||||
O << Indent3 << "for (" << D.GenTypeDeclaration()
|
O << Indent3 << "for (" << D.GenTypeDeclaration()
|
||||||
<< "::iterator B = " << D.GenVariableName() << ".begin(),\n"
|
<< "::iterator B = " << D.GenVariableName() << ".begin(),\n"
|
||||||
<< Indent3 << "E = " << D.GenVariableName() << ".end(); B != E; ++B)\n"
|
<< Indent3 << "E = " << D.GenVariableName() << ".end(); B != E; ++B)\n"
|
||||||
<< Indent4 << "vec.push_back(\"-" << D.Name << "\" + "
|
<< Indent4 << "vec.push_back(\"" << Name << "\" + "
|
||||||
<< "*B);\n";
|
<< "*B);\n";
|
||||||
break;
|
break;
|
||||||
case OptionType::ParameterList:
|
case OptionType::ParameterList:
|
||||||
@ -983,7 +1006,7 @@ void EmitForwardOptionPropertyHandlingCode (const ToolOptionDescription& D,
|
|||||||
<< "::iterator B = " << D.GenVariableName() << ".begin(),\n"
|
<< "::iterator B = " << D.GenVariableName() << ".begin(),\n"
|
||||||
<< Indent3 << "E = " << D.GenVariableName()
|
<< Indent3 << "E = " << D.GenVariableName()
|
||||||
<< ".end() ; B != E; ++B) {\n"
|
<< ".end() ; B != E; ++B) {\n"
|
||||||
<< Indent4 << "vec.push_back(\"-" << D.Name << "\");\n"
|
<< Indent4 << "vec.push_back(\"" << Name << "\");\n"
|
||||||
<< Indent4 << "vec.push_back(*B);\n"
|
<< Indent4 << "vec.push_back(*B);\n"
|
||||||
<< Indent3 << "}\n";
|
<< Indent3 << "}\n";
|
||||||
break;
|
break;
|
||||||
@ -1001,7 +1024,8 @@ bool ToolOptionHasInterestingProperties(const ToolOptionDescription& D) {
|
|||||||
for (OptionPropertyList::const_iterator B = D.Props.begin(),
|
for (OptionPropertyList::const_iterator B = D.Props.begin(),
|
||||||
E = D.Props.end(); B != E; ++B) {
|
E = D.Props.end(); B != E; ++B) {
|
||||||
const OptionProperty& OptProp = *B;
|
const OptionProperty& OptProp = *B;
|
||||||
if (OptProp.first == OptionPropertyType::AppendCmd)
|
if (OptProp.first == OptionPropertyType::AppendCmd
|
||||||
|
|| OptProp.first == OptionPropertyType::ForwardAs)
|
||||||
ret = true;
|
ret = true;
|
||||||
}
|
}
|
||||||
if (D.isForward() || D.isUnpackValues())
|
if (D.isForward() || D.isUnpackValues())
|
||||||
@ -1036,6 +1060,10 @@ void EmitOptionPropertyHandlingCode (const ToolOptionDescription& D,
|
|||||||
case OptionPropertyType::AppendCmd:
|
case OptionPropertyType::AppendCmd:
|
||||||
O << Indent3 << "vec.push_back(\"" << val.second << "\");\n";
|
O << Indent3 << "vec.push_back(\"" << val.second << "\");\n";
|
||||||
break;
|
break;
|
||||||
|
// (forward_as) property
|
||||||
|
case OptionPropertyType::ForwardAs:
|
||||||
|
EmitForwardOptionPropertyHandlingCode(D, val.second, O);
|
||||||
|
break;
|
||||||
// Other properties with argument
|
// Other properties with argument
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
@ -1046,7 +1074,7 @@ void EmitOptionPropertyHandlingCode (const ToolOptionDescription& D,
|
|||||||
|
|
||||||
// (forward) property
|
// (forward) property
|
||||||
if (D.isForward())
|
if (D.isForward())
|
||||||
EmitForwardOptionPropertyHandlingCode(D, O);
|
EmitForwardOptionPropertyHandlingCode(D, "", O);
|
||||||
|
|
||||||
// (unpack_values) property
|
// (unpack_values) property
|
||||||
if (D.isUnpackValues()) {
|
if (D.isUnpackValues()) {
|
||||||
|
Loading…
Reference in New Issue
Block a user