forked from OSchip/llvm-project
Deprecate 'unpack_values'.
Use 'forward_values' + 'comma_separated' instead. llvm-svn: 90774
This commit is contained in:
parent
1b31c37922
commit
67c106664b
|
@ -45,6 +45,7 @@ def one_or_more;
|
|||
def really_hidden;
|
||||
def required;
|
||||
def zero_or_one;
|
||||
def comma_separated;
|
||||
|
||||
// The 'case' construct.
|
||||
def case;
|
||||
|
|
|
@ -41,9 +41,9 @@ def OptionList : OptionList<[
|
|||
// (help "Optimization level 2. (Default)")),
|
||||
// (parameter_option "pre-RA-sched",
|
||||
// (help "Example of an option that is passed to llc")),
|
||||
(prefix_list_option "Wa,",
|
||||
(prefix_list_option "Wa,", (comma_separated),
|
||||
(help "Pass options to native assembler")),
|
||||
(prefix_list_option "Wl,",
|
||||
(prefix_list_option "Wl,", (comma_separated),
|
||||
(help "Pass options to native linker"))
|
||||
// (prefix_list_option "Wllc,",
|
||||
// (help "Pass options to llc")),
|
||||
|
@ -58,11 +58,11 @@ class clang_based<string language, string cmd, string ext_E> : Tool<
|
|||
(output_suffix "bc"),
|
||||
(cmd_line (case
|
||||
(switch_on "E"),
|
||||
(case
|
||||
(case
|
||||
(not_empty "o"), !strconcat(cmd, " -E $INFILE -o $OUTFILE"),
|
||||
(default), !strconcat(cmd, " -E $INFILE")),
|
||||
(default), !strconcat(cmd, " $INFILE -o $OUTFILE"))),
|
||||
(actions (case
|
||||
(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)],
|
||||
|
@ -138,7 +138,7 @@ def gpasm : Tool<[
|
|||
(actions (case
|
||||
(switch_on "c"), (stop_compilation),
|
||||
(switch_on "g"), (append_cmd "-g"),
|
||||
(not_empty "Wa,"), (unpack_values "Wa,")))
|
||||
(not_empty "Wa,"), (forward_value "Wa,")))
|
||||
]>;
|
||||
|
||||
def mplink : Tool<[
|
||||
|
@ -147,13 +147,13 @@ def mplink : Tool<[
|
|||
(output_suffix "cof"),
|
||||
(cmd_line "$CALL(GetBinDir)mplink.exe -k $CALL(GetStdLinkerScriptsDir) -l $CALL(GetStdLibsDir) -p 16f1937 intrinsics.lib devices.lib $INFILE -o $OUTFILE"),
|
||||
(actions (case
|
||||
(not_empty "Wl,"), (unpack_values "Wl,"),
|
||||
(not_empty "Wl,"), (forward_value "Wl,"),
|
||||
(not_empty "L"), (forward_as "L", "-l"),
|
||||
(not_empty "K"), (forward_as "K", "-k"),
|
||||
(not_empty "m"), (forward "m"),
|
||||
// (not_empty "l"), [(unpack_values "l"),(append_cmd ".lib")])),
|
||||
(not_empty "k"), (unpack_values "k"),
|
||||
(not_empty "l"), (unpack_values "l"))),
|
||||
(not_empty "k"), (forward_value "k"),
|
||||
(not_empty "l"), (forward_value "l"))),
|
||||
(join)
|
||||
]>;
|
||||
|
||||
|
@ -175,13 +175,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">,
|
||||
|
|
|
@ -71,9 +71,9 @@ def OptList : OptionList<[
|
|||
(help "Add a directory to include path")),
|
||||
(prefix_list_option "D",
|
||||
(help "Define a macro")),
|
||||
(prefix_list_option "Wa,",
|
||||
(prefix_list_option "Wa,", (comma_separated),
|
||||
(help "Pass options to assembler")),
|
||||
(prefix_list_option "Wllc,",
|
||||
(prefix_list_option "Wllc,", (comma_separated),
|
||||
(help "Pass options to llc")),
|
||||
(prefix_list_option "L",
|
||||
(help "Add a directory to link path")),
|
||||
|
@ -81,7 +81,7 @@ def OptList : OptionList<[
|
|||
(help "Search a library when linking")),
|
||||
(prefix_list_option "Wl,",
|
||||
(help "Pass options to linker")),
|
||||
(prefix_list_option "Wo,",
|
||||
(prefix_list_option "Wo,", (comma_separated),
|
||||
(help "Pass options to opt")),
|
||||
(prefix_list_option "m",
|
||||
(help "Enable or disable various extensions (-mmmx, -msse, etc.)"),
|
||||
|
@ -159,7 +159,7 @@ def opt : Tool<
|
|||
[(in_language "llvm-bitcode"),
|
||||
(out_language "llvm-bitcode"),
|
||||
(output_suffix "bc"),
|
||||
(actions (case (not_empty "Wo,"), (unpack_values "Wo,"),
|
||||
(actions (case (not_empty "Wo,"), (forward_value "Wo,"),
|
||||
(switch_on "O1"), (forward "O1"),
|
||||
(switch_on "O2"), (forward "O2"),
|
||||
(switch_on "O3"), (forward "O3"))),
|
||||
|
@ -181,7 +181,7 @@ def llvm_gcc_assembler : Tool<
|
|||
(cmd_line "@LLVMGCCCOMMAND@ -c -x assembler $INFILE -o $OUTFILE"),
|
||||
(actions (case
|
||||
(switch_on "c"), (stop_compilation),
|
||||
(not_empty "Wa,"), (unpack_values "Wa,")))
|
||||
(not_empty "Wa,"), (forward_value "Wa,")))
|
||||
]>;
|
||||
|
||||
def llc : Tool<
|
||||
|
@ -202,7 +202,7 @@ def llc : Tool<
|
|||
(not_empty "mtune"), (forward "mcpu"),
|
||||
(not_empty "mcpu"), (forward "mcpu"),
|
||||
(not_empty "m"), (forward_transformed_value "m", "ConvertToMAttr"),
|
||||
(not_empty "Wllc,"), (unpack_values "Wllc,")))
|
||||
(not_empty "Wllc,"), (forward_value "Wllc,")))
|
||||
]>;
|
||||
|
||||
// Base class for linkers
|
||||
|
|
|
@ -68,7 +68,7 @@ def as : Tool<
|
|||
(out_language "object-code"),
|
||||
(output_suffix "o"),
|
||||
(cmd_line "as $INFILE -o $OUTFILE"),
|
||||
(actions (case (not_empty "Wa,"), (unpack_values "Wa,"),
|
||||
(actions (case (not_empty "Wa,"), (forward_value "Wa,"),
|
||||
(switch_on "c"), (stop_compilation)))
|
||||
]>;
|
||||
|
||||
|
@ -82,7 +82,7 @@ def llvm_ld : Tool<
|
|||
(switch_on "pthread"), (append_cmd "-lpthread"),
|
||||
(not_empty "L"), (forward "L"),
|
||||
(not_empty "l"), (forward "l"),
|
||||
(not_empty "Wl,"), (unpack_values "Wl,"))),
|
||||
(not_empty "Wl,"), (forward_value "Wl,"))),
|
||||
(join)
|
||||
]>;
|
||||
|
||||
|
|
|
@ -211,7 +211,8 @@ OptionType::OptionType stringToOptionType(const std::string& T) {
|
|||
namespace OptionDescriptionFlags {
|
||||
enum OptionDescriptionFlags { Required = 0x1, Hidden = 0x2,
|
||||
ReallyHidden = 0x4, Extern = 0x8,
|
||||
OneOrMore = 0x10, ZeroOrOne = 0x20 };
|
||||
OneOrMore = 0x10, ZeroOrOne = 0x20,
|
||||
CommaSeparated = 0x40 };
|
||||
}
|
||||
|
||||
/// OptionDescription - Represents data contained in a single
|
||||
|
@ -247,6 +248,9 @@ struct OptionDescription {
|
|||
|
||||
bool isMultiVal() const;
|
||||
|
||||
bool isCommaSeparated() const;
|
||||
void setCommaSeparated();
|
||||
|
||||
bool isExtern() const;
|
||||
void setExtern();
|
||||
|
||||
|
@ -299,6 +303,13 @@ bool OptionDescription::isMultiVal() const {
|
|||
return MultiVal > 1;
|
||||
}
|
||||
|
||||
bool OptionDescription::isCommaSeparated() const {
|
||||
return Flags & OptionDescriptionFlags::CommaSeparated;
|
||||
}
|
||||
void OptionDescription::setCommaSeparated() {
|
||||
Flags |= OptionDescriptionFlags::CommaSeparated;
|
||||
}
|
||||
|
||||
bool OptionDescription::isExtern() const {
|
||||
return Flags & OptionDescriptionFlags::Extern;
|
||||
}
|
||||
|
@ -538,6 +549,7 @@ public:
|
|||
AddHandler("really_hidden", &CollectOptionProperties::onReallyHidden);
|
||||
AddHandler("required", &CollectOptionProperties::onRequired);
|
||||
AddHandler("zero_or_one", &CollectOptionProperties::onZeroOrOne);
|
||||
AddHandler("comma_separated", &CollectOptionProperties::onCommaSeparated);
|
||||
|
||||
staticMembersInitialized_ = true;
|
||||
}
|
||||
|
@ -574,11 +586,18 @@ private:
|
|||
optDesc_.setReallyHidden();
|
||||
}
|
||||
|
||||
void onCommaSeparated (const DagInit* d) {
|
||||
checkNumberOfArguments(d, 0);
|
||||
if (!optDesc_.isList())
|
||||
throw "'comma_separated' is valid only on list options!";
|
||||
optDesc_.setCommaSeparated();
|
||||
}
|
||||
|
||||
void onRequired (const DagInit* d) {
|
||||
checkNumberOfArguments(d, 0);
|
||||
if (optDesc_.isOneOrMore())
|
||||
throw std::string("An option can't have both (required) "
|
||||
"and (one_or_more) properties!");
|
||||
if (optDesc_.isOneOrMore() || optDesc_.isZeroOrOne())
|
||||
throw "Only one of (required), (zero_or_one) or "
|
||||
"(one_or_more) properties is allowed!";
|
||||
optDesc_.setRequired();
|
||||
}
|
||||
|
||||
|
@ -591,7 +610,7 @@ private:
|
|||
correct |= (optDesc_.isSwitch() && (str == "true" || str == "false"));
|
||||
|
||||
if (!correct)
|
||||
throw std::string("Incorrect usage of the 'init' option property!");
|
||||
throw "Incorrect usage of the 'init' option property!";
|
||||
|
||||
optDesc_.InitVal = i;
|
||||
}
|
||||
|
@ -599,8 +618,8 @@ private:
|
|||
void onOneOrMore (const DagInit* d) {
|
||||
checkNumberOfArguments(d, 0);
|
||||
if (optDesc_.isRequired() || optDesc_.isZeroOrOne())
|
||||
throw std::string("Only one of (required), (zero_or_one) or "
|
||||
"(one_or_more) properties is allowed!");
|
||||
throw "Only one of (required), (zero_or_one) or "
|
||||
"(one_or_more) properties is allowed!";
|
||||
if (!OptionType::IsList(optDesc_.Type))
|
||||
llvm::errs() << "Warning: specifying the 'one_or_more' property "
|
||||
"on a non-list option will have no effect.\n";
|
||||
|
@ -610,8 +629,8 @@ private:
|
|||
void onZeroOrOne (const DagInit* d) {
|
||||
checkNumberOfArguments(d, 0);
|
||||
if (optDesc_.isRequired() || optDesc_.isOneOrMore())
|
||||
throw std::string("Only one of (required), (zero_or_one) or "
|
||||
"(one_or_more) properties is allowed!");
|
||||
throw "Only one of (required), (zero_or_one) or "
|
||||
"(one_or_more) properties is allowed!";
|
||||
if (!OptionType::IsList(optDesc_.Type))
|
||||
llvm::errs() << "Warning: specifying the 'zero_or_one' property"
|
||||
"on a non-list option will have no effect.\n";
|
||||
|
@ -622,11 +641,10 @@ private:
|
|||
checkNumberOfArguments(d, 1);
|
||||
int val = InitPtrToInt(d->getArg(0));
|
||||
if (val < 2)
|
||||
throw std::string("Error in the 'multi_val' property: "
|
||||
"the value must be greater than 1!");
|
||||
throw "Error in the 'multi_val' property: "
|
||||
"the value must be greater than 1!";
|
||||
if (!OptionType::IsList(optDesc_.Type))
|
||||
throw std::string("The multi_val property is valid only "
|
||||
"on list options!");
|
||||
throw "The multi_val property is valid only on list options!";
|
||||
optDesc_.MultiVal = val;
|
||||
}
|
||||
|
||||
|
@ -1048,9 +1066,9 @@ class ExtractOptionNames {
|
|||
if (ActionName == "forward" || ActionName == "forward_as" ||
|
||||
ActionName == "forward_value" ||
|
||||
ActionName == "forward_transformed_value" ||
|
||||
ActionName == "unpack_values" || ActionName == "switch_on" ||
|
||||
ActionName == "parameter_equals" || ActionName == "element_in_list" ||
|
||||
ActionName == "not_empty" || ActionName == "empty") {
|
||||
ActionName == "switch_on" || ActionName == "parameter_equals" ||
|
||||
ActionName == "element_in_list" || ActionName == "not_empty" ||
|
||||
ActionName == "empty") {
|
||||
checkNumberOfArguments(&Stmt, 1);
|
||||
const std::string& Name = InitPtrToString(Stmt.getArg(0));
|
||||
OptionNames_.insert(Name);
|
||||
|
@ -1858,30 +1876,8 @@ class EmitActionHandlersCallback
|
|||
void onUnpackValues (const DagInit& Dag,
|
||||
unsigned IndentLevel, raw_ostream& O) const
|
||||
{
|
||||
checkNumberOfArguments(&Dag, 1);
|
||||
const std::string& Name = InitPtrToString(Dag.getArg(0));
|
||||
const OptionDescription& D = OptDescs.FindOption(Name);
|
||||
|
||||
if (D.isMultiVal())
|
||||
throw "Can't use unpack_values with multi-valued options!";
|
||||
|
||||
if (D.isList()) {
|
||||
O.indent(IndentLevel)
|
||||
<< "for (" << D.GenTypeDeclaration()
|
||||
<< "::iterator B = " << D.GenVariableName() << ".begin(),\n";
|
||||
O.indent(IndentLevel)
|
||||
<< "E = " << D.GenVariableName() << ".end(); B != E; ++B)\n";
|
||||
O.indent(IndentLevel + Indent1)
|
||||
<< "llvm::SplitString(*B, vec, \",\");\n";
|
||||
}
|
||||
else if (D.isParameter()){
|
||||
O.indent(IndentLevel) << "llvm::SplitString("
|
||||
<< D.GenVariableName() << ", vec, \",\");\n";
|
||||
}
|
||||
else {
|
||||
throw "Option '" + D.Name +
|
||||
"': switches can't have the 'unpack_values' property!";
|
||||
}
|
||||
throw "'unpack_values' is deprecated. "
|
||||
"Use 'comma_separated' + 'forward_value' instead!";
|
||||
}
|
||||
|
||||
public:
|
||||
|
@ -2191,12 +2187,13 @@ void EmitOptionDefinitions (const OptionDescriptions& descs,
|
|||
O << ", cl::ZeroOrOne";
|
||||
}
|
||||
|
||||
if (val.isReallyHidden()) {
|
||||
if (val.isReallyHidden())
|
||||
O << ", cl::ReallyHidden";
|
||||
}
|
||||
else if (val.isHidden()) {
|
||||
else if (val.isHidden())
|
||||
O << ", cl::Hidden";
|
||||
}
|
||||
|
||||
if (val.isCommaSeparated())
|
||||
O << ", cl::CommaSeparated";
|
||||
|
||||
if (val.MultiVal > 1)
|
||||
O << ", cl::multi_val(" << val.MultiVal << ')';
|
||||
|
@ -2650,7 +2647,6 @@ void EmitIncludes(raw_ostream& O) {
|
|||
<< "#include \"llvm/CompilerDriver/Plugin.h\"\n"
|
||||
<< "#include \"llvm/CompilerDriver/Tool.h\"\n\n"
|
||||
|
||||
<< "#include \"llvm/ADT/StringExtras.h\"\n"
|
||||
<< "#include \"llvm/Support/CommandLine.h\"\n"
|
||||
<< "#include \"llvm/Support/raw_ostream.h\"\n\n"
|
||||
|
||||
|
|
Loading…
Reference in New Issue