def really_hidden;
def required;
def zero_or_one;
+def comma_separated;
// The 'case' construct.
def case;
// (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")),
(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)],
(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<[
(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)
]>;
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">,
(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")),
(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.)"),
[(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"))),
(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<
(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
(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)))
]>;
(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)
]>;
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
bool isMultiVal() const;
+ bool isCommaSeparated() const;
+ void setCommaSeparated();
+
bool isExtern() const;
void setExtern();
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;
}
AddHandler("really_hidden", &CollectOptionProperties::onReallyHidden);
AddHandler("required", &CollectOptionProperties::onRequired);
AddHandler("zero_or_one", &CollectOptionProperties::onZeroOrOne);
+ AddHandler("comma_separated", &CollectOptionProperties::onCommaSeparated);
staticMembersInitialized_ = true;
}
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();
}
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;
}
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";
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";
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;
}
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);
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:
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 << ')';
<< "#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"