9#ifndef LLVM_OPTION_OPTTABLE_H
10#define LLVM_OPTION_OPTTABLE_H
129 Prefixes.
push_back(StrTable[PrefixOffset]);
134 unsigned PrefixIndex)
const {
144 unsigned PrefixLength =
165 "This helper is only for valid registered subcommands.");
167 SubCommands, [&](
const auto &
C) {
return SubCommand ==
C.Name; });
168 assert(SCIT != SubCommands.end() &&
169 "This helper is only for valid registered subcommands.");
170 auto SubCommandIDs = getSubCommandIDs(*CandidateInfo);
171 unsigned CurrentSubCommandID = SCIT - &SubCommands[0];
201 ValuesCodeFnTy ValuesCodeFn =
nullptr;
203 bool GroupedShortOptions =
false;
204 bool DashDashParsing =
false;
205 const char *EnvVar =
nullptr;
207 unsigned InputOptionID = 0;
208 unsigned UnknownOptionID = 0;
212 unsigned FirstSearchableIndex = 0;
222 unsigned id = Opt.
getID();
223 assert(
id > 0 &&
id - 1 < getNumOptions() &&
"Invalid Option ID.");
224 return OptionInfos[
id - 1];
228 Visibility VisibilityMask)
const {
229 for (
const HelpTextVariant *V =
230 &HelpTextVariantsTable[getExtra(
I).HelpTextVariantsOffset];
232 if (VisibilityMask & V->Visibility)
233 return V->HelpTextOffset;
234 return I.HelpTextOffset;
237 StringRef getOptionValues(
const Info &
I)
const {
238 StringRef Values = StrTable[getExtra(
I).ValuesOffset];
239 if (Values.empty() && ValuesCodeFn)
240 Values = ValuesCodeFn(getOptionID(
I));
244 ArrayRef<unsigned> getSubCommandIDs(
const Info &
I)
const {
246 unsigned Offset = getExtra(
I).SubCommandIDsOffset;
247 return SubCommandIDsTable.
slice(Offset + 1, SubCommandIDsTable[Offset]);
250 std::unique_ptr<Arg> parseOneArgGrouped(InputArgList &Args,
251 unsigned &Index)
const;
254 OptTable(
const Tables &Tables,
bool IgnoreCase =
false);
268 return PrefixesTable;
275 return &
I - OptionInfos.data() + 1;
286 return getInfo(
id).getName(StrTable, PrefixesTable);
291 const Info &
I = getInfo(
id);
293 :
I.getPrefix(StrTable, PrefixesTable, 0);
298 const Info &
I = getInfo(
id);
299 I.appendPrefixes(StrTable, PrefixesTable, Prefixes);
304 return getInfo(
id).getPrefixedName(StrTable);
308 return InfoExtrasTable[
I.ExtraOffset];
313 return getInfo(
id).Kind;
318 return getInfo(
id).GroupID;
331 return StrTable[getHelpTextOffset(getInfo(
id), VisibilityMask)];
337 return StrTable[
getExtra(getInfo(
id)).MetaVarOffset];
342 return StrTable.getCString(
getExtra(getInfo(
id)).AliasArgsOffset);
374 std::vector<std::string> findByPrefix(
StringRef Cur,
376 unsigned int DisableFlags)
const;
396 unsigned MinimumLength = 4,
397 unsigned MaximumDistance = UINT_MAX)
const;
400 unsigned FlagsToInclude,
unsigned FlagsToExclude = 0,
401 unsigned MinimumLength = 4,
402 unsigned MaximumDistance = UINT_MAX)
const;
407 unsigned MinimumLength,
unsigned MaximumDistance,
408 std::function<
bool(
const Info &)> ExcludeOption)
const;
417 unsigned FlagsToInclude,
unsigned FlagsToExclude = 0)
const {
435 ParseOneArg(
const ArgList &Args,
unsigned &Index,
438 std::unique_ptr<Arg> ParseOneArg(
const ArgList &Args,
unsigned &Index,
439 unsigned FlagsToInclude,
440 unsigned FlagsToExclude)
const;
444 internalParseOneArg(
const ArgList &Args,
unsigned &Index,
445 std::function<
bool(
const Option &)> ExcludeOption)
const;
465 unsigned &MissingArgCount,
469 unsigned &MissingArgCount,
unsigned FlagsToInclude,
470 unsigned FlagsToExclude = 0)
const;
475 unsigned &MissingArgCount,
476 std::function<
bool(
const Option &)> ExcludeOption)
const;
489 std::function<
void(
StringRef)> ErrorFn)
const;
503 void printHelp(
raw_ostream &OS,
const char *Usage,
const char *Title,
504 bool ShowHidden =
false,
bool ShowAllAliases =
false,
508 void printHelp(
raw_ostream &OS,
const char *Usage,
const char *Title,
509 unsigned FlagsToInclude,
unsigned FlagsToExclude,
510 bool ShowAllAliases)
const;
513 void internalPrintHelp(
raw_ostream &OS,
const char *Usage,
const char *Title,
516 std::function<
bool(
const Info &)> ExcludeOption,
517 Visibility VisibilityMask)
const;
524#define LLVM_MAKE_OPT_ID_WITH_ID_PREFIX( \
525 ID_PREFIX, PREFIXES_OFFSET, PREFIXED_NAME_OFFSET, ID, KIND, GROUP, ALIAS, \
526 ALIASARGS, FLAGS, VISIBILITY, PARAM, HELPTEXT, HELPTEXTSFORVARIANTS, \
527 METAVAR, VALUES, SUBCOMMANDIDS_OFFSET) \
530#define LLVM_MAKE_OPT_ID(PREFIXES_OFFSET, PREFIXED_NAME_OFFSET, ID, KIND, \
531 GROUP, ALIAS, ALIASARGS, FLAGS, VISIBILITY, PARAM, \
532 HELPTEXT, HELPTEXTSFORVARIANTS, METAVAR, VALUES, \
533 SUBCOMMANDIDS_OFFSET) \
534 LLVM_MAKE_OPT_ID_WITH_ID_PREFIX( \
535 OPT_, PREFIXES_OFFSET, PREFIXED_NAME_OFFSET, ID, KIND, GROUP, ALIAS, \
536 ALIASARGS, FLAGS, VISIBILITY, PARAM, HELPTEXT, HELPTEXTSFORVARIANTS, \
537 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),...
ArrayRef< T > slice(size_t N, size_t M) const
slice(n, m) - Chop off the first N elements of the array, and keep M elements in the array.
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.
OptSpecifier - Wrapper class for abstracting references to option IDs.
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 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.
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.
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,...
const char * getOptionAliasArgs(OptSpecifier id) const
Get the alias arguments as a \0 separated list, e.g. "foo\0bar\0".
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.
const InfoExtra & getExtra(const Info &I) const
OptTable(const Tables &Tables, bool IgnoreCase=false)
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.
void appendOptionPrefixes(OptSpecifier id, SmallVectorImpl< StringRef > &Prefixes) const
unsigned getOptionID(const Info &I) 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.
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.
@ 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.
Help text that replaces Info::HelpTextOffset when the visibility mask being printed intersects Visibi...
StringTable::Offset HelpTextOffset
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 PrefixedNameOffset
unsigned getNumPrefixes(ArrayRef< StringTable::Offset > PrefixesTable) const
StringRef getPrefixedName(const StringTable &StrTable) const
ArrayRef< StringTable::Offset > getPrefixOffsets(ArrayRef< StringTable::Offset > PrefixesTable) const
StringTable::Offset HelpTextOffset
Offset 0 means the .td supplied no HelpText.
StringRef getPrefix(const StringTable &StrTable, ArrayRef< StringTable::Offset > PrefixesTable, unsigned PrefixIndex) const
StringRef getName(const StringTable &StrTable, ArrayRef< StringTable::Offset > PrefixesTable) const
Represents a subcommand and its options in the option table.
The tables TableGen emits for an option set under OPTTABLE_CODE.
ArrayRef< unsigned > SubCommandIDs
ArrayRef< InfoExtra > InfoExtras
ArrayRef< SubCommand > SubCommands
ArrayRef< HelpTextVariant > HelpTextVariants
ArrayRef< StringTable::Offset > PrefixesTable