9#ifndef LLVM_OPTION_OPTTABLE_H
10#define LLVM_OPTION_OPTTABLE_H
82 std::array<std::pair<std::array<
unsigned int, 2 >,
137 Prefixes.
push_back(StrTable[PrefixOffset]);
142 unsigned PrefixIndex)
const {
152 unsigned PrefixLength =
162 "This helper is only for valid registered subcommands.");
164 SubCommands, [&](
const auto &
C) {
return SubCommand ==
C.Name; });
165 assert(SCIT != SubCommands.end() &&
166 "This helper is only for valid registered subcommands.");
168 unsigned CurrentSubCommandID = SCIT - &SubCommands[0];
194 ValuesCodeFnTy ValuesCodeFn =
nullptr;
196 bool GroupedShortOptions =
false;
197 bool DashDashParsing =
false;
198 const char *EnvVar =
nullptr;
200 unsigned InputOptionID = 0;
201 unsigned UnknownOptionID = 0;
217 unsigned id = Opt.
getID();
219 return OptionInfos[
id - 1];
224 for (
const auto &[Visibilities, TextOffset] :
I.HelpTextsForVariants)
225 for (
auto Vis : Visibilities)
226 if (VisibilityMask & Vis)
228 return I.HelpTextOffset;
231 StringRef getOptionValues(
const Info &
I)
const {
233 if (
Values.empty() && ValuesCodeFn)
238 std::unique_ptr<Arg> parseOneArgGrouped(InputArgList &Args,
239 unsigned &Index)
const;
244 OptTable(
const StringTable &StrTable,
245 ArrayRef<StringTable::Offset> PrefixesTable,
246 ArrayRef<Info> OptionInfos,
bool IgnoreCase =
false,
247 ArrayRef<SubCommand> SubCommands = {},
248 ArrayRef<unsigned> SubCommandIDsTable = {});
253 void buildPrefixChars();
265 return PrefixesTable;
279 return getInfo(
id).getName(*StrTable, PrefixesTable);
284 const Info &
I = getInfo(
id);
286 :
I.getPrefix(*StrTable, PrefixesTable, 0);
291 const Info &
I = getInfo(
id);
292 I.appendPrefixes(*StrTable, PrefixesTable, Prefixes);
297 return getInfo(
id).getPrefixedName(*StrTable);
302 return getInfo(
id).Kind;
307 return getInfo(
id).GroupID;
320 return (*StrTable)[getHelpTextOffset(getInfo(
id), VisibilityMask)];
326 return (*StrTable)[getInfo(
id).MetaVarOffset];
358 std::vector<std::string> findByPrefix(
StringRef Cur,
360 unsigned int DisableFlags)
const;
380 unsigned MinimumLength = 4,
381 unsigned MaximumDistance = UINT_MAX)
const;
384 unsigned FlagsToInclude,
unsigned FlagsToExclude = 0,
385 unsigned MinimumLength = 4,
386 unsigned MaximumDistance = UINT_MAX)
const;
391 unsigned MinimumLength,
unsigned MaximumDistance,
392 std::function<
bool(
const Info &)> ExcludeOption)
const;
401 unsigned FlagsToInclude,
unsigned FlagsToExclude = 0)
const {
419 ParseOneArg(
const ArgList &Args,
unsigned &Index,
422 std::unique_ptr<Arg> ParseOneArg(
const ArgList &Args,
unsigned &Index,
423 unsigned FlagsToInclude,
424 unsigned FlagsToExclude)
const;
428 internalParseOneArg(
const ArgList &Args,
unsigned &Index,
429 std::function<
bool(
const Option &)> ExcludeOption)
const;
449 unsigned &MissingArgCount,
453 unsigned &MissingArgCount,
unsigned FlagsToInclude,
454 unsigned FlagsToExclude = 0)
const;
459 unsigned &MissingArgCount,
460 std::function<
bool(
const Option &)> ExcludeOption)
const;
473 std::function<
void(
StringRef)> ErrorFn)
const;
487 void printHelp(
raw_ostream &OS,
const char *Usage,
const char *Title,
488 bool ShowHidden =
false,
bool ShowAllAliases =
false,
492 void printHelp(
raw_ostream &OS,
const char *Usage,
const char *Title,
493 unsigned FlagsToInclude,
unsigned FlagsToExclude,
494 bool ShowAllAliases)
const;
497 void internalPrintHelp(
raw_ostream &OS,
const char *Usage,
const char *Title,
500 std::function<
bool(
const Info &)> ExcludeOption,
501 Visibility VisibilityMask)
const;
520 bool IgnoreCase =
false,
523 :
OptTable(StrTable, PrefixesTable, OptionInfos, IgnoreCase, SubCommands,
524 SubCommandIDsTable) {
525 for (
auto PrefixOffset : PrefixesUnionOffsets)
535#define LLVM_MAKE_OPT_ID_WITH_ID_PREFIX( \
536 ID_PREFIX, PREFIXES_OFFSET, PREFIXED_NAME_OFFSET, ID, KIND, GROUP, ALIAS, \
537 ALIASARGS, FLAGS, VISIBILITY, PARAM, HELPTEXT, HELPTEXTSFORVARIANTS, \
538 METAVAR, VALUES, SUBCOMMANDIDS_OFFSET) \
541#define LLVM_MAKE_OPT_ID(PREFIXES_OFFSET, PREFIXED_NAME_OFFSET, ID, KIND, \
542 GROUP, ALIAS, ALIASARGS, FLAGS, VISIBILITY, PARAM, \
543 HELPTEXT, HELPTEXTSFORVARIANTS, METAVAR, VALUES, \
544 SUBCOMMANDIDS_OFFSET) \
545 LLVM_MAKE_OPT_ID_WITH_ID_PREFIX( \
546 OPT_, PREFIXES_OFFSET, PREFIXED_NAME_OFFSET, ID, KIND, GROUP, ALIAS, \
547 ALIASARGS, FLAGS, VISIBILITY, PARAM, HELPTEXT, HELPTEXTSFORVARIANTS, \
548 METAVAR, VALUES, SUBCOMMANDIDS_OFFSET)
550#define LLVM_CONSTRUCT_OPT_INFO_WITH_ID_PREFIX( \
551 ID_PREFIX, PREFIXES_OFFSET, PREFIXED_NAME_OFFSET, ID, KIND, GROUP, ALIAS, \
552 ALIASARGS, FLAGS, VISIBILITY, PARAM, HELPTEXT, HELPTEXTSFORVARIANTS, \
553 METAVAR, VALUES, SUBCOMMANDIDS_OFFSET) \
554 llvm::opt::OptTable::Info { \
555 PREFIXES_OFFSET, PREFIXED_NAME_OFFSET, HELPTEXT, HELPTEXTSFORVARIANTS, \
556 METAVAR, ID_PREFIX##ID, llvm::opt::Option::KIND##Class, PARAM, FLAGS, \
557 VISIBILITY, ID_PREFIX##GROUP, ID_PREFIX##ALIAS, ALIASARGS, VALUES, \
558 SUBCOMMANDIDS_OFFSET \
561#define LLVM_CONSTRUCT_OPT_INFO( \
562 PREFIXES_OFFSET, PREFIXED_NAME_OFFSET, ID, KIND, GROUP, ALIAS, ALIASARGS, \
563 FLAGS, VISIBILITY, PARAM, HELPTEXT, HELPTEXTSFORVARIANTS, METAVAR, VALUES, \
564 SUBCOMMANDIDS_OFFSET) \
565 LLVM_CONSTRUCT_OPT_INFO_WITH_ID_PREFIX( \
566 OPT_, PREFIXES_OFFSET, PREFIXED_NAME_OFFSET, ID, KIND, GROUP, ALIAS, \
567 ALIASARGS, FLAGS, VISIBILITY, PARAM, HELPTEXT, HELPTEXTSFORVARIANTS, \
568 METAVAR, VALUES, SUBCOMMANDIDS_OFFSET)
assert(UImm &&(UImm !=~static_cast< T >(0)) &&"Invalid immediate!")
static GCRegistry::Add< ShadowStackGC > C("shadow-stack", "Very portable GC for uncooperative code generators")
static GCRegistry::Add< CoreCLRGC > E("coreclr", "CoreCLR-compatible GC")
static Expected< size_t > parseArgs(StringRef Section, mcdxbc::SourceInfo::ProgramArgs &Args)
This file defines the SmallString class.
Represent a constant reference to an array (0 or more elements consecutively in memory),...
SmallString - A SmallString is just a SmallVector with methods and accessors that make it work better...
This class consists of common code factored out of the SmallVector class to reduce code duplication b...
void push_back(const T &Elt)
This is a 'vector' (really, a variable-sized array), optimized for the case when the array is small.
Represent a constant reference to a string, i.e.
Saves strings in the provided stable storage and returns a StringRef with a stable character pointer.
A table of densely packed, null-terminated strings indexed by offset.
LLVM Value Representation.
An efficient, type-erasing, non-owning reference to a callable.
ArgList - Ordered collection of driver arguments.
A concrete instance of a particular driver option.
LLVM_ABI GenericOptTable(const StringTable &StrTable, ArrayRef< StringTable::Offset > PrefixesTable, ArrayRef< Info > OptionInfos, bool IgnoreCase=false, ArrayRef< SubCommand > SubCommands={}, ArrayRef< unsigned > SubCommandIDsTable={})
OptSpecifier - Wrapper class for abstracting references to option IDs.
void buildPrefixChars()
Build (or rebuild) the PrefixChars member.
bool isValidForSubCommand(const Info *CandidateInfo, StringRef SubCommand) const
StringRef getOptionName(OptSpecifier id) const
Lookup the name of the given option.
unsigned getOptionKind(OptSpecifier id) const
Get the kind of the given option.
unsigned FirstSearchableIndex
The index of the first option which can be parsed (i.e., is not a special option like 'input' or 'unk...
unsigned findNearest(StringRef Option, std::string &NearestString, Visibility VisibilityMask=Visibility(), unsigned MinimumLength=4, unsigned MaximumDistance=UINT_MAX) const
Find the OptTable option that most closely matches the given string.
SmallVector< StringRef > PrefixesUnion
The union of all option prefixes.
StringRef getOptionPrefix(OptSpecifier id) const
Lookup the prefix of the given option.
bool findExact(StringRef Option, std::string &ExactString, unsigned FlagsToInclude, unsigned FlagsToExclude=0) const
void setInitialOptionsFromEnvironment(const char *E)
Specify the environment variable where initial options should be read.
OptTable(const StringTable &StrTable, ArrayRef< StringTable::Offset > PrefixesTable, ArrayRef< Info > OptionInfos, bool IgnoreCase=false, ArrayRef< SubCommand > SubCommands={}, ArrayRef< unsigned > SubCommandIDsTable={})
Initialize OptTable using Tablegen'ed OptionInfos.
void setDashDashParsing(bool Value)
Set whether "--" stops option parsing and treats all subsequent arguments as positional.
StringRef getOptionHelpText(OptSpecifier id, Visibility VisibilityMask) const
StringRef(*)(unsigned) ValuesCodeFnTy
Values of options declared with TableGen ValuesCode: only the generated code knows them,...
void setValuesCodeFn(ValuesCodeFnTy Fn)
unsigned getOptionGroupID(OptSpecifier id) const
Get the group id for the given option.
StringRef getOptionMetaVar(OptSpecifier id) const
Get the meta-variable name to use when describing this options values in the help text.
StringRef getOptionPrefixedName(OptSpecifier id) const
Lookup the prefixed name of the given option.
ArrayRef< StringTable::Offset > getPrefixesTable() const
Return the prefixes table used for option names.
SmallString< 8 > PrefixChars
The union of the first element of all option prefixes.
void appendOptionPrefixes(OptSpecifier id, SmallVectorImpl< StringRef > &Prefixes) const
unsigned getNumOptions() const
Return the total number of option classes.
bool findExact(StringRef Option, std::string &ExactString, Visibility VisibilityMask=Visibility()) const
StringRef getOptionHelpText(OptSpecifier id) const
Get the help text to use to describe this option.
ArrayRef< SubCommand > getSubCommands() const
const StringTable & getStrTable() const
Return the string table used for option names.
void setGroupedShortOptions(bool Value)
Support grouped short options. e.g. -ab represents -a -b.
Option - Abstract representation for a single form of driver argument.
PrecomputedOptTable(const StringTable &StrTable, ArrayRef< StringTable::Offset > PrefixesTable, ArrayRef< Info > OptionInfos, ArrayRef< StringTable::Offset > PrefixesUnionOffsets, bool IgnoreCase=false, ArrayRef< SubCommand > SubCommands={}, ArrayRef< unsigned > SubCommandIDsTable={})
Helper for overload resolution while transitioning from FlagsToInclude/FlagsToExclude APIs to Visibil...
Visibility(unsigned Mask)
This class implements an extremely fast bulk output stream that can only output to a stream.
This is an optimization pass for GlobalISel generic memory operations.
RelativeUniformCounterPtr Values
@ Unknown
Not known to have no common set bits.
auto find_if(R &&Range, UnaryPredicate P)
Provide wrappers to std::find_if which take ranges instead of having to pass begin/end explicitly.
bool is_contained(R &&Range, const E &Element)
Returns true if Element is found in Range.
Entry for a single option instance in the option data table.
void appendPrefixes(const StringTable &StrTable, ArrayRef< StringTable::Offset > PrefixesTable, SmallVectorImpl< StringRef > &Prefixes) const
StringTable::Offset AliasArgsOffset
StringTable::Offset PrefixedNameOffset
unsigned getNumPrefixes(ArrayRef< StringTable::Offset > PrefixesTable) const
std::array< std::pair< std::array< unsigned int, 2 >, StringTable::Offset >, 1 > HelpTextsForVariants
bool hasSubCommands() const
StringRef getPrefixedName(const StringTable &StrTable) const
ArrayRef< StringTable::Offset > getPrefixOffsets(ArrayRef< StringTable::Offset > PrefixesTable) const
bool hasAliasArgs() const
StringTable::Offset HelpTextOffset
Offset 0 means the .td supplied no HelpText.
StringRef getPrefix(const StringTable &StrTable, ArrayRef< StringTable::Offset > PrefixesTable, unsigned PrefixIndex) const
StringTable::Offset ValuesOffset
The possible values as a comma separated list, empty for an option whose values only getOptionValuesC...
StringRef getName(const StringTable &StrTable, ArrayRef< StringTable::Offset > PrefixesTable) const
StringTable::Offset MetaVarOffset
unsigned SubCommandIDsOffset
ArrayRef< unsigned > getSubCommandIDs(ArrayRef< unsigned > SubCommandIDsTable) const
unsigned getNumSubCommandIDs(ArrayRef< unsigned > SubCommandIDsTable) const
Represents a subcommand and its options in the option table.