diff --git a/clang/docs/Multilib.rst b/clang/docs/Multilib.rst --- a/clang/docs/Multilib.rst +++ b/clang/docs/Multilib.rst @@ -59,31 +59,31 @@ Clang goes through the following steps to use multilib from a configuration file: -#. Convert command line arguments to flags. Clang can accept the same +#. Convert command line arguments to tags. Clang can accept the same information via different arguments - for example, ``--target=arm-none-eabi -march=armv7-m`` and ``--target=armv7m-none-eabi`` are equivalent. Clang can also accept many - independent pieces of information within a single flag - for example + independent pieces of information within a single option - for example ``-march=armv8.1m.main+fp+mve`` specifies the architecture and two extensions in a single command line argument. To make it easier for the multilib system, Clang converts the command line - arguments into a standard set of simpler "flags". In many cases these flags + arguments into a standard set of simpler "tags". In many cases these tags will look like a command line argument with the leading ``-`` stripped off, - but where a suitable form for the flag doesn't exist in command line + but where a suitable form for the tag doesn't exist in command line arguments then its form will be different. For example, an Arm architecture extension is represented like ``march=+mve`` since there's no way to specify it in isolation in a command line argument. - To see what flags are emitted for a given set of command line arguments, use - the ``-print-multi-selection-flags-experimental`` command line argument + To see what tags are emitted for a given set of command line arguments, use + the ``-print-multi-selection-tags-experimental`` command line argument along with the rest of the arguments you want to use. #. Load ``multilib.yaml`` from sysroot. -#. Generate additional flags. ``multilib.yaml`` contains a ``FlagMap`` section, - which specifies how to generate additional flags based on the flags derived - from command line arguments. Flags are matched using regular expressions. +#. Generate additional tags. ``multilib.yaml`` contains a ``TagMap`` section, + which specifies how to generate additional tags based on the tags derived + from command line arguments. Tags are matched using regular expressions. These regular expressions shall use the POSIX extended regular expression syntax. -#. Match flags against multilib variants. If the generated flags are a superset - of the flags specified for a multilib variant then the variant is considered +#. Match tags against multilib variants. If the generated tags are a superset + of the tags specified for a multilib variant then the variant is considered a match. If more than one variant matches then a toolchain may opt to either use only the *last* matching multilib variant, or may use all matching variants, @@ -131,13 +131,13 @@ ========= Multilib via configuration file shall be considered an experimental feature -until LLVM 18, at which point ``-print-multi-selection-flags-experimental`` -should be renamed to ``-print-multi-selection-flags``. +until LLVM 18, at which point ``-print-multi-selection-tags-experimental`` +should be renamed to ``-print-multi-selection-tags``. A toolchain can opt in to using this feature by including a ``multilib.yaml`` file in its distribution, once support for it is added in relevant ToolChain subclasses. -Once stability is reached, flags emitted by ``-print-multi-selection-flags`` -should not be removed or changed, although new flags may be added. +Once stability is reached, tags emitted by ``-print-multi-selection-tags`` +should not be removed or changed, although new tags may be added. Restrictions ============ @@ -172,15 +172,15 @@ # The rest of this file is in two parts: # 1. A list of multilib variants. - # 2. A list of regular expressions that may match flags generated from - # command line arguments, and further flags that shall be added if the + # 2. A list of regular expressions that may match tags generated from + # command line arguments, and further tags that shall be added if the # regex matches. # It is acceptable for the file to contain properties not documented here, # and these will be ignored by Clang. # List of multilib variants. Required. # The ordering of Variants is important if more than one variant can match - # the same set of flags. See the docs on multilib layering for more info. + # the same set of tags. See the docs on multilib layering for more info. Variants: # Example of a multilib variant targeting Arm v6-M. @@ -189,11 +189,11 @@ # Exactly how Dir is used is left up to the ToolChain subclass to define, but # typically it will be joined to the sysroot. - Dir: thumb/v6-m - # List of one or more "flags", as generated by Clang from the command line - # arguments or from FlagMap below. - # Here, if the flags are a superset of {target=thumbv6m-none-unknown-eabi} + # List of one or more "tags", as generated by Clang from the command line + # arguments or from TagMap below. + # Here, if the tags are a superset of {target=thumbv6m-none-unknown-eabi} # then this multilib variant will be considered a match. - Flags: [target=thumbv6m-none-unknown-eabi] + Tags: [target=thumbv6m-none-unknown-eabi] # If a user invokes Clang with -print-multi-lib then the options it # prints will be derived from PrintOptions. For example: # thumb/v6-m;@-target=thumbv6m-none-eabi @@ -203,31 +203,31 @@ # Similarly, a multilib variant targeting Arm v7-M with an FPU (floating # point unit). - Dir: thumb/v7-m - # Here, the flags generated by Clang must be a superset of + # Here, the tags generated by Clang must be a superset of # {V7MorLater, HasFPU} for this multilib variant to be a match. - Flags: [V7MorLater, HasFPU] + Tags: [V7MorLater, HasFPU] PrintOptions: [--target=thumbv7m-none-eabi, -mfpu=fpv4-sp-d16] # The second section of the file is a list of regular expressions that are - # used to map from auto-detected flags to custom flags. This is optional. - # Each regular expression must match a whole flag string. - # One or both of "MatchFlags" & "NoMatchFlags" must be specified. - # "MatchFlags" flags will be added if an argument matches, while - # "NoMatchFlags" flags will be added otherwise. - FlagMap: - - # Set a "V7MorLater" flag if the regular expression matches any of the flags + # used to map from auto-detected tags to custom tags. This is optional. + # Each regular expression must match a whole tag string. + # One or both of "MatchTags" & "NoMatchTags" must be specified. + # "MatchTags" tags will be added if an argument matches, while + # "NoMatchTags" tags will be added otherwise. + TagMap: + + # Set a "V7MorLater" tag if the regular expression matches any of the tags # generated from the command line arguments. # Regex is a POSIX extended regular expression strings. - Regex: target=thumbv[7-9].* - # MatchFlags is a list of one or more strings. - MatchFlags: [V7MorLater] + # MatchTags is a list of one or more strings. + MatchTags: [V7MorLater] # Set HasFPU if mfpu=none *doesn't* match. - Regex: mfpu=none - # NoMatchFlags is a list of one or more strings. - NoMatchFlags: [HasFPU] + # NoMatchTags is a list of one or more strings. + NoMatchTags: [HasFPU] Design principles ================= @@ -235,22 +235,22 @@ Stable interface ---------------- -multilib.yaml and -print-multi-selection-flags-experimental are new interfaces +multilib.yaml and -print-multi-selection-tags-experimental are new interfaces to Clang. In order for them to be usable over time and across LLVM versions their interfaces should be stable. The new multilib system will be considered experimental in LLVM 17, but in LLVM 18 it will be stable. In particular this is important to which multilib -selection flags Clang generates from command line arguments. Once a flag is +selection tags Clang generates from command line arguments. Once a tag is generated by a released version of Clang it may be used in multilib.yaml files that exist independently of the LLVM release cycle, and therefore -ceasing to generate the flag would be a breaking change and should be +ceasing to generate the tag would be a breaking change and should be avoided. Incomplete interface -------------------- The new multilib system does multilib selection based on only a limited set of -command line arguments, and limits which flags can be used for multilib +command line arguments, and limits which tags can be used for multilib selection. This is in order to avoid committing to too large an interface. Later LLVM versions can add support for multilib selection from more command line arguments as needed. @@ -312,9 +312,9 @@ The greater the API surface, the greater the difficulty of keeping it stable. Where possible the additional API surface should be kept small by defining it in relation to existing APIs. An example of this is keeping a simple -relationship between flag names and command line arguments where possible. +relationship between tag names and command line arguments where possible. Since the command line arguments are part of a stable API they are unlikely -to change, and therefore the flag names get the same stability. +to change, and therefore the tag names get the same stability. Low compile-time overhead ------------------------- diff --git a/clang/include/clang/Driver/Multilib.h b/clang/include/clang/Driver/Multilib.h --- a/clang/include/clang/Driver/Multilib.h +++ b/clang/include/clang/Driver/Multilib.h @@ -25,20 +25,19 @@ namespace clang { namespace driver { -/// This corresponds to a single GCC Multilib, or a segment of one controlled -/// by a command line flag. +/// This corresponds to a single GCC Multilib. /// See also MultilibBuilder for building a multilib by mutating it /// incrementally. class Multilib { public: - using flag_set = std::set; + using tag_set = std::set; using option_list = std::vector; private: std::string GCCSuffix; std::string OSSuffix; std::string IncludeSuffix; - flag_set Flags; + tag_set Tags; option_list PrintOptions; public: @@ -46,7 +45,7 @@ /// sysroot string so they must either be empty or begin with a '/' character. /// This is enforced with an assert in the constructor. Multilib(StringRef GCCSuffix = {}, StringRef OSSuffix = {}, - StringRef IncludeSuffix = {}, const flag_set &Flags = flag_set(), + StringRef IncludeSuffix = {}, const tag_set &Tags = tag_set(), const option_list &PrintOptions = option_list()); /// Get the detected GCC installation path suffix for the multi-arch @@ -61,11 +60,11 @@ /// empty const std::string &includeSuffix() const { return IncludeSuffix; } - /// Get the set of flags that indicate this multilib's use. - /// Flags are arbitrary strings although typically they will look similar to - /// command line options. A multilib is considered compatible if its flags are - /// a subset of the flags derived from the Clang command line options. - const flag_set &flags() const { return Flags; } + /// Get the set of tags that indicate this multilib's use. + /// Tags are arbitrary strings although typically they will look similar to + /// command line options. A multilib is considered compatible if its tags are + /// a subset of the tags derived from the Clang command line options. + const tag_set &tags() const { return Tags; } /// Returns the options that should be used for clang -print-multi-lib const option_list &getPrintOptions() const { return PrintOptions; } @@ -92,19 +91,19 @@ std::function(const Multilib &M)>; using FilterCallback = llvm::function_ref; - /// Uses regular expressions to simplify flags used for multilib selection. + /// Uses regular expressions to simplify tags used for multilib selection. /// For example, we may wish to simplify armv8, armv8.1, armv8.2 etc. to /// simply "v8". It's also possible to negate matches. For example, it may be /// appropriate to infer that if mfpu=none *doesn't* match then an FPU is - /// available. NoMatchFlags can be used for this purpose. - struct FlagMatcher { + /// available. NoMatchTags can be used for this purpose. + struct TagMatcher { std::string Regex; - std::vector MatchFlags, NoMatchFlags; + std::vector MatchTags, NoMatchTags; }; private: multilib_list Multilibs; - std::vector FlagMatchers; + std::vector TagMatchers; IncludeDirsFunc IncludeCallback; IncludeDirsFunc FilePathsCallback; @@ -124,16 +123,16 @@ const_iterator end() const { return Multilibs.end(); } /// Select compatible variants, \returns false if none are compatible - bool select(const Multilib::flag_set &Flags, + bool select(const Multilib::tag_set &Tags, llvm::SmallVector &) const; unsigned size() const { return Multilibs.size(); } - /// Get the given flags plus flags found by matching them against the - /// FlagMatchers and choosing the MatchFlags or NoMatchFlags of each + /// Get the given tags plus tags found by matching them against the + /// TagMatchers and choosing the MatchTags or NoMatchTags of each /// accordingly. The select method calls this method so in most cases it's not /// necessary to call it directly. - Multilib::flag_set expandFlags(const Multilib::flag_set &) const; + Multilib::tag_set expandTags(const Multilib::tag_set &) const; bool parse(llvm::MemoryBufferRef, llvm::SourceMgr::DiagHandlerTy = nullptr, void *DiagHandlerCtxt = nullptr); diff --git a/clang/include/clang/Driver/Options.td b/clang/include/clang/Driver/Options.td --- a/clang/include/clang/Driver/Options.td +++ b/clang/include/clang/Driver/Options.td @@ -4205,7 +4205,7 @@ "library (\"libgcc.a\" or \"libclang_rt.builtins.*.a\")">; def print_multi_directory : Flag<["-", "--"], "print-multi-directory">; def print_multi_lib : Flag<["-", "--"], "print-multi-lib">; -def print_multi_selection_flags : Flag<["-", "--"], "print-multi-selection-flags-experimental">, +def print_multi_selection_tags : Flag<["-", "--"], "print-multi-selection-tags-experimental">, HelpText<"Print the flags used for selecting multilibs (experimental)">; def print_multi_os_directory : Flag<["-", "--"], "print-multi-os-directory">, Flags<[Unsupported]>; diff --git a/clang/include/clang/Driver/ToolChain.h b/clang/include/clang/Driver/ToolChain.h --- a/clang/include/clang/Driver/ToolChain.h +++ b/clang/include/clang/Driver/ToolChain.h @@ -287,7 +287,7 @@ return SelectedMultilibs; } - /// Get flags suitable for multilib selection, based on the provided clang + /// Get tags suitable for multilib selection, based on the provided clang /// command line arguments. The command line arguments aren't suitable to be /// used directly for multilib selection because they are not normalized and /// normalization is a complex process. The result of this function is similar @@ -295,7 +295,7 @@ /// * It's incomplete. Only certain command line arguments are processed. If /// more command line arguments are needed for multilib selection then this /// function should be extended. - /// * The flags aren't prefixed with "-". + /// * The tags aren't prefixed with "-". /// * Where a single command line argument would contain a list, the elements /// are split out. For example, Arm extensions are appended to -march like /// -march=armv8m.main+crc+crypto+sha2+mve. Since this function is @@ -304,10 +304,10 @@ /// flag then that would be unstable. Instead, each extension will be /// returned separately. There may not be valid syntax to express this as a /// clang argument so a pseudo argument syntax must be used instead. - /// To allow users to find out what flags are returned, clang accepts a - /// -print-multi-selection-flags-experimental argument. + /// To allow users to find out what tags are returned, clang accepts a + /// -print-multi-selection-tags-experimental argument. std::vector - getMultiSelectionFlags(const llvm::opt::ArgList &) const; + getMultiSelectionTags(const llvm::opt::ArgList &) const; SanitizerArgs getSanitizerArgs(const llvm::opt::ArgList &JobArgs) const; diff --git a/clang/lib/Driver/Driver.cpp b/clang/lib/Driver/Driver.cpp --- a/clang/lib/Driver/Driver.cpp +++ b/clang/lib/Driver/Driver.cpp @@ -2207,12 +2207,12 @@ return false; } - if (C.getArgs().hasArg(options::OPT_print_multi_selection_flags)) { - auto ArgFlags = TC.getMultiSelectionFlags(C.getArgs()); - auto AllFlags = TC.getMultilibs().expandFlags( - Multilib::flag_set(ArgFlags.begin(), ArgFlags.end())); - for (StringRef Flag : AllFlags) - llvm::outs() << Flag << '\n'; + if (C.getArgs().hasArg(options::OPT_print_multi_selection_tags)) { + auto ArgTags = TC.getMultiSelectionTags(C.getArgs()); + auto AllTags = TC.getMultilibs().expandTags( + Multilib::tag_set(ArgTags.begin(), ArgTags.end())); + for (StringRef Tag : AllTags) + llvm::outs() << Tag << '\n'; return false; } diff --git a/clang/lib/Driver/Multilib.cpp b/clang/lib/Driver/Multilib.cpp --- a/clang/lib/Driver/Multilib.cpp +++ b/clang/lib/Driver/Multilib.cpp @@ -27,10 +27,10 @@ using namespace llvm::sys; Multilib::Multilib(StringRef GCCSuffix, StringRef OSSuffix, - StringRef IncludeSuffix, const flag_set &Flags, + StringRef IncludeSuffix, const tag_set &Tags, const option_list &PrintOptions) : GCCSuffix(GCCSuffix), OSSuffix(OSSuffix), IncludeSuffix(IncludeSuffix), - Flags(Flags), PrintOptions(PrintOptions) { + Tags(Tags), PrintOptions(PrintOptions) { assert(GCCSuffix.empty() || (StringRef(GCCSuffix).front() == '/' && GCCSuffix.size() > 1)); assert(OSSuffix.empty() || @@ -54,7 +54,7 @@ } bool Multilib::operator==(const Multilib &Other) const { - if (Flags != Other.Flags) + if (Tags != Other.Tags) return false; if (osSuffix() != Other.osSuffix()) @@ -81,22 +81,22 @@ void MultilibSet::push_back(const Multilib &M) { Multilibs.push_back(M); } -bool MultilibSet::select(const Multilib::flag_set &Flags, +bool MultilibSet::select(const Multilib::tag_set &Tags, llvm::SmallVector &Selected) const { - Multilib::flag_set AllFlags(expandFlags(Flags)); + Multilib::tag_set AllTags(expandTags(Tags)); Selected.clear(); llvm::copy_if(Multilibs, std::back_inserter(Selected), - [&AllFlags](const Multilib &M) { - return std::includes(AllFlags.begin(), AllFlags.end(), - M.flags().begin(), M.flags().end()); + [&AllTags](const Multilib &M) { + return std::includes(AllTags.begin(), AllTags.end(), + M.tags().begin(), M.tags().end()); }); return !Selected.empty(); } -Multilib::flag_set -MultilibSet::expandFlags(const Multilib::flag_set &InFlags) const { - Multilib::flag_set Result(InFlags); - for (const FlagMatcher &M : FlagMatchers) { +Multilib::tag_set +MultilibSet::expandTags(const Multilib::tag_set &InTags) const { + Multilib::tag_set Result(InTags); + for (const TagMatcher &M : TagMatchers) { std::string RegexString(M.Regex); // Make the regular expression match the whole string. @@ -107,12 +107,12 @@ const llvm::Regex Regex(RegexString); assert(Regex.isValid()); - if (llvm::find_if(InFlags, [&Regex](StringRef F) { + if (llvm::find_if(InTags, [&Regex](StringRef F) { return Regex.match(F); - }) != InFlags.end()) { - Result.insert(M.MatchFlags.begin(), M.MatchFlags.end()); + }) != InTags.end()) { + Result.insert(M.MatchTags.begin(), M.MatchTags.end()); } else { - Result.insert(M.NoMatchFlags.begin(), M.NoMatchFlags.end()); + Result.insert(M.NoMatchTags.begin(), M.NoMatchTags.end()); } } return Result; @@ -122,13 +122,13 @@ struct MultilibSerialization { std::string Dir; - std::vector Flags, PrintOptions; + std::vector Tags, PrintOptions; }; struct MultilibSetSerialization { std::string ClangMinimumVersion; std::vector Multilibs; - std::vector FlagMatchers; + std::vector TagMatchers; }; } // end anonymous namespace @@ -136,7 +136,7 @@ template <> struct llvm::yaml::MappingTraits { static void mapping(llvm::yaml::IO &io, MultilibSerialization &V) { io.mapRequired("Dir", V.Dir); - io.mapRequired("Flags", V.Flags); + io.mapRequired("Tags", V.Tags); io.mapRequired("PrintOptions", V.PrintOptions); } static std::string validate(IO &io, MultilibSerialization &V) { @@ -146,19 +146,19 @@ } }; -template <> struct llvm::yaml::MappingTraits { - static void mapping(llvm::yaml::IO &io, MultilibSet::FlagMatcher &M) { +template <> struct llvm::yaml::MappingTraits { + static void mapping(llvm::yaml::IO &io, MultilibSet::TagMatcher &M) { io.mapRequired("Regex", M.Regex); - io.mapOptional("MatchFlags", M.MatchFlags); - io.mapOptional("NoMatchFlags", M.NoMatchFlags); + io.mapOptional("MatchTags", M.MatchTags); + io.mapOptional("NoMatchTags", M.NoMatchTags); } - static std::string validate(IO &io, MultilibSet::FlagMatcher &M) { + static std::string validate(IO &io, MultilibSet::TagMatcher &M) { llvm::Regex Regex(M.Regex); std::string RegexError; if (!Regex.isValid(RegexError)) return RegexError; - if (M.MatchFlags.empty() && M.NoMatchFlags.empty()) - return "value required for 'MatchFlags' or 'NoMatchFlags'"; + if (M.MatchTags.empty() && M.NoMatchTags.empty()) + return "value required for 'MatchTags' or 'NoMatchTags'"; return std::string{}; } }; @@ -167,7 +167,7 @@ static void mapping(llvm::yaml::IO &io, MultilibSetSerialization &M) { io.mapRequired("ClangMinimumVersion", M.ClangMinimumVersion); io.mapRequired("Variants", M.Multilibs); - io.mapOptional("FlagMap", M.FlagMatchers); + io.mapOptional("TagMap", M.TagMatchers); } static std::string validate(IO &io, MultilibSetSerialization &M) { if (M.ClangMinimumVersion.empty()) @@ -205,7 +205,7 @@ }; LLVM_YAML_IS_SEQUENCE_VECTOR(MultilibSerialization) -LLVM_YAML_IS_SEQUENCE_VECTOR(MultilibSet::FlagMatcher) +LLVM_YAML_IS_SEQUENCE_VECTOR(MultilibSet::TagMatcher) bool MultilibSet::parse(llvm::MemoryBufferRef Input, llvm::SourceMgr::DiagHandlerTy DiagHandler, @@ -223,10 +223,10 @@ if (M.Dir != ".") Dir = "/" + M.Dir; Multilibs.emplace_back(Dir, Dir, Dir, - Multilib::flag_set(M.Flags.begin(), M.Flags.end()), + Multilib::tag_set(M.Tags.begin(), M.Tags.end()), M.PrintOptions); } - FlagMatchers = std::move(MS.FlagMatchers); + TagMatchers = std::move(MS.TagMatchers); return true; } diff --git a/clang/lib/Driver/MultilibBuilder.cpp b/clang/lib/Driver/MultilibBuilder.cpp --- a/clang/lib/Driver/MultilibBuilder.cpp +++ b/clang/lib/Driver/MultilibBuilder.cpp @@ -87,7 +87,7 @@ Multilib MultilibBuilder::makeMultilib() const { // Derive print options from flags. - // In general, flags in the Multilib class are not required to be valid + // In general, tags in the Multilib class are not required to be valid // command line options, but for the MultilibBuilder class flags are expected // to form valid command line options when their first character is replaced // with '-'. @@ -97,7 +97,7 @@ PrintOptions.push_back(("-" + Flag.substr(1)).str()); } return Multilib(GCCSuffix, OSSuffix, IncludeSuffix, - Multilib::flag_set(Flags.begin(), Flags.end()), PrintOptions); + Multilib::tag_set(Flags.begin(), Flags.end()), PrintOptions); } MultilibSetBuilder &MultilibSetBuilder::Maybe(const MultilibBuilder &M) { diff --git a/clang/lib/Driver/ToolChain.cpp b/clang/lib/Driver/ToolChain.cpp --- a/clang/lib/Driver/ToolChain.cpp +++ b/clang/lib/Driver/ToolChain.cpp @@ -228,7 +228,7 @@ } std::vector -ToolChain::getMultiSelectionFlags(const llvm::opt::ArgList &Args) const { +ToolChain::getMultiSelectionTags(const llvm::opt::ArgList &Args) const { using namespace clang::driver::options; std::vector Result; diff --git a/clang/lib/Driver/ToolChains/BareMetal.cpp b/clang/lib/Driver/ToolChains/BareMetal.cpp --- a/clang/lib/Driver/ToolChains/BareMetal.cpp +++ b/clang/lib/Driver/ToolChains/BareMetal.cpp @@ -32,7 +32,7 @@ static bool findRISCVMultilibs(const Driver &D, const llvm::Triple &TargetTriple, const ArgList &Args, DetectedMultilibs &Result) { - Multilib::flag_set Flags; + Multilib::tag_set Flags; StringRef Arch = riscv::getRISCVArch(Args, TargetTriple); StringRef Abi = tools::riscv::getRISCVABI(Args, TargetTriple); @@ -165,11 +165,11 @@ D.getVFS().getBufferForFile(MultilibPath); if (!MB) return false; - std::vector ArgsFlags = TC.getMultiSelectionFlags(Args); + std::vector ArgsTags = TC.getMultiSelectionTags(Args); if (!Result.Multilibs.parse(*MB.get())) return false; - Multilib::flag_set Flags(ArgsFlags.begin(), ArgsFlags.end()); - return Result.Multilibs.select(Flags, Result.SelectedMultilibs); + Multilib::tag_set Tags(ArgsTags.begin(), ArgsTags.end()); + return Result.Multilibs.select(Tags, Result.SelectedMultilibs); } #define MULTILIB_YAML_FILENAME "multilib.yaml" diff --git a/clang/lib/Driver/ToolChains/CommonArgs.h b/clang/lib/Driver/ToolChains/CommonArgs.h --- a/clang/lib/Driver/ToolChains/CommonArgs.h +++ b/clang/lib/Driver/ToolChains/CommonArgs.h @@ -201,7 +201,7 @@ /// \p Flag must be a flag accepted by the driver with its leading '-' removed, // otherwise '-print-multi-lib' will not emit them correctly. void addMultilibFlag(bool Enabled, const char *const Flag, - Multilib::flag_set &Flags); + Multilib::tag_set &Flags); void addX86AlignBranchArgs(const Driver &D, const llvm::opt::ArgList &Args, llvm::opt::ArgStringList &CmdArgs, bool IsLTO, diff --git a/clang/lib/Driver/ToolChains/CommonArgs.cpp b/clang/lib/Driver/ToolChains/CommonArgs.cpp --- a/clang/lib/Driver/ToolChains/CommonArgs.cpp +++ b/clang/lib/Driver/ToolChains/CommonArgs.cpp @@ -1805,7 +1805,7 @@ } void tools::addMultilibFlag(bool Enabled, const char *const Flag, - Multilib::flag_set &Flags) { + Multilib::tag_set &Flags) { Flags.insert(std::string(Enabled ? "+" : "-") + Flag); } diff --git a/clang/lib/Driver/ToolChains/Fuchsia.cpp b/clang/lib/Driver/ToolChains/Fuchsia.cpp --- a/clang/lib/Driver/ToolChains/Fuchsia.cpp +++ b/clang/lib/Driver/ToolChains/Fuchsia.cpp @@ -298,7 +298,7 @@ return llvm::all_of(RD, [&](std::string P) { return !getVFS().exists(P); }); }); - Multilib::flag_set Flags; + Multilib::tag_set Flags; bool Exceptions = Args.hasFlag(options::OPT_fexceptions, options::OPT_fno_exceptions, true); addMultilibFlag(Exceptions, "fexceptions", Flags); diff --git a/clang/lib/Driver/ToolChains/Gnu.cpp b/clang/lib/Driver/ToolChains/Gnu.cpp --- a/clang/lib/Driver/ToolChains/Gnu.cpp +++ b/clang/lib/Driver/ToolChains/Gnu.cpp @@ -1046,7 +1046,7 @@ return Arch == llvm::Triple::msp430; } -static bool findMipsCsMultilibs(const Multilib::flag_set &Flags, +static bool findMipsCsMultilibs(const Multilib::tag_set &Flags, FilterNonExistent &NonExistent, DetectedMultilibs &Result) { // Check for Code Sourcery toolchain multilibs @@ -1144,7 +1144,7 @@ } static bool findMipsAndroidMultilibs(llvm::vfs::FileSystem &VFS, StringRef Path, - const Multilib::flag_set &Flags, + const Multilib::tag_set &Flags, FilterNonExistent &NonExistent, DetectedMultilibs &Result) { @@ -1189,7 +1189,7 @@ return false; } -static bool findMipsMuslMultilibs(const Multilib::flag_set &Flags, +static bool findMipsMuslMultilibs(const Multilib::tag_set &Flags, FilterNonExistent &NonExistent, DetectedMultilibs &Result) { // Musl toolchain multilibs @@ -1223,7 +1223,7 @@ return false; } -static bool findMipsMtiMultilibs(const Multilib::flag_set &Flags, +static bool findMipsMtiMultilibs(const Multilib::tag_set &Flags, FilterNonExistent &NonExistent, DetectedMultilibs &Result) { // CodeScape MTI toolchain v1.2 and early. @@ -1404,7 +1404,7 @@ return false; } -static bool findMipsImgMultilibs(const Multilib::flag_set &Flags, +static bool findMipsImgMultilibs(const Multilib::tag_set &Flags, FilterNonExistent &NonExistent, DetectedMultilibs &Result) { // CodeScape IMG toolchain v1.2 and early. @@ -1517,7 +1517,7 @@ llvm::Triple::ArchType TargetArch = TargetTriple.getArch(); - Multilib::flag_set Flags; + Multilib::tag_set Flags; addMultilibFlag(TargetTriple.isMIPS32(), "m32", Flags); addMultilibFlag(TargetTriple.isMIPS64(), "m64", Flags); addMultilibFlag(isMips16(Args), "mips16", Flags); @@ -1599,7 +1599,7 @@ .makeMultilibSet() .FilterOut(NonExistent); - Multilib::flag_set Flags; + Multilib::tag_set Flags; llvm::StringRef Arch = Args.getLastArgValue(options::OPT_march_EQ); bool IsArmArch = TargetTriple.getArch() == llvm::Triple::arm; bool IsThumbArch = TargetTriple.getArch() == llvm::Triple::thumb; @@ -1635,7 +1635,7 @@ Result.Multilibs.push_back(WithExceptions.makeMultilib()); Result.Multilibs.FilterOut(NonExistent); - Multilib::flag_set Flags; + Multilib::tag_set Flags; addMultilibFlag(Args.hasFlag(options::OPT_fexceptions, options::OPT_fno_exceptions, false), "exceptions", Flags); @@ -1658,7 +1658,7 @@ return; auto ARCHName = *Res; - Multilib::flag_set Flags; + Multilib::tag_set Flags; addMultilibFlag(TheFloatABI == tools::csky::FloatABI::Hard, "hard-fp", Flags); addMultilibFlag(TheFloatABI == tools::csky::FloatABI::SoftFP, "soft-fp", Flags); @@ -1746,7 +1746,7 @@ "/../../../../riscv32-unknown-elf/lib" + M.gccSuffix()}); }); - Multilib::flag_set Flags; + Multilib::tag_set Flags; llvm::StringSet<> Added_ABIs; StringRef ABIName = tools::riscv::getRISCVABI(Args, TargetTriple); StringRef MArch = tools::riscv::getRISCVArch(Args, TargetTriple); @@ -1789,7 +1789,7 @@ .makeMultilibSet() .FilterOut(NonExistent); - Multilib::flag_set Flags; + Multilib::tag_set Flags; bool IsRV64 = TargetTriple.getArch() == llvm::Triple::riscv64; StringRef ABIName = tools::riscv::getRISCVABI(Args, TargetTriple); @@ -1900,7 +1900,7 @@ Result.Multilibs.FilterOut(NonExistent); - Multilib::flag_set Flags; + Multilib::tag_set Flags; addMultilibFlag(TargetTriple.isArch64Bit() && !IsX32, "m64", Flags); addMultilibFlag(TargetTriple.isArch32Bit(), "m32", Flags); addMultilibFlag(TargetTriple.isArch64Bit() && IsX32, "mx32", Flags); diff --git a/clang/test/Driver/baremetal-multilib.yaml b/clang/test/Driver/baremetal-multilib.yaml --- a/clang/test/Driver/baremetal-multilib.yaml +++ b/clang/test/Driver/baremetal-multilib.yaml @@ -65,19 +65,19 @@ --- # This file is in two parts: # 1. A list of library variants. -# 2. A mapping from flags generated from command line arguments to further -# flags. +# 2. A mapping from tags generated from command line arguments to further +# tags. # How does clang use this file? # 1. If the ToolChain class for the architecture supports this form of # multilib it then it loads the file if present in sysroot. -# 2. Generate flags from the user provided arguments. -# (Use `clang -print-multi-selection-flags` to see which flags are +# 2. Generate tags from the user provided arguments. +# (Use `clang -print-multi-selection-tags` to see which tags are # generated). # 3. Compare the arguments against each regular expression and store -# associated flags if there's a match. -# 4. Find the last library variant whose flags are a subset of the -# flags derived from the user provided arguments. +# associated tags if there's a match. +# 4. Find the last library variant whose tags are a subset of the +# tags derived from the user provided arguments. # 5. Use the directory for the library variant as the sysroot. # This defines the minimum version of Clang required to use this file. @@ -87,7 +87,7 @@ ClangMinimumVersion: 17.0.0 # The first section of the file is the list of library variants. -# A library is considered compatible if the are a subset of the flags derived +# A library is considered compatible if the are a subset of the tags derived # from the arguments provided by the user. # If multiple libraries are deemed compatible then the one that appears # last in the list wins. A ToolChain may instead opt to use more than one @@ -97,43 +97,43 @@ Variants: - Dir: arm-none-eabi/thumb/v6-m/nofp - Flags: [target=thumbv6m-none-unknown-eabi] + Tags: [target=thumbv6m-none-unknown-eabi] PrintOptions: [--target=thumbv6m-none-eabi, -mfloat-abi=soft] - Dir: arm-none-eabi/thumb/v7-m/nofp - Flags: [target=thumbv7m-none-unknown-eabi] + Tags: [target=thumbv7m-none-unknown-eabi] PrintOptions: [--target=thumbv7m-none-eabi, -mfloat-abi=soft] - Dir: arm-none-eabi/thumb/v7e-m/nofp - Flags: [target=thumbv7em-none-unknown-eabi] + Tags: [target=thumbv7em-none-unknown-eabi] PrintOptions: [--target=thumbv7em-none-eabi, -mfloat-abi=soft, -mfpu=none] - Dir: arm-none-eabi/thumb/v8-m.main/nofp - Flags: [target=thumbv8m.main-none-unknown-eabi] + Tags: [target=thumbv8m.main-none-unknown-eabi] PrintOptions: [--target=arm-none-eabi, -mfloat-abi=soft, -march=armv8m.main+nofp] - Dir: arm-none-eabi/thumb/v8.1-m.main/nofp/nomve - Flags: [target=thumbv8.1m.main-none-unknown-eabi] + Tags: [target=thumbv8.1m.main-none-unknown-eabi] PrintOptions: [--target=arm-none-eabi, -mfloat-abi=soft, -march=armv8.1m.main+nofp+nomve] - Dir: arm-none-eabi/thumb/v7e-m/fpv4_sp_d16 - Flags: [target=thumbv7em-none-unknown-eabihf, mfpu=fpv4-sp-d16] + Tags: [target=thumbv7em-none-unknown-eabihf, mfpu=fpv4-sp-d16] PrintOptions: [--target=thumbv7em-none-eabihf, -mfpu=fpv4-sp-d16] - Dir: arm-none-eabi/thumb/v7e-m/fpv5_d16 - Flags: [target=thumbv7em-none-unknown-eabihf, mfpu=fpv5-d16] + Tags: [target=thumbv7em-none-unknown-eabihf, mfpu=fpv5-d16] PrintOptions: [--target=thumbv7em-none-eabihf, -mfpu=fpv5-d16] - Dir: arm-none-eabi/thumb/v8-m.main/fp - Flags: [target=thumbv8m.main-none-unknown-eabihf, hasfpu] + Tags: [target=thumbv8m.main-none-unknown-eabihf, hasfpu] PrintOptions: [--target=thumbv8m.main-none-eabihf] - Dir: arm-none-eabi/thumb/v8.1-m.main/fp - Flags: [target=thumbv8.1m.main-none-unknown-eabihf, hasfpu] + Tags: [target=thumbv8.1m.main-none-unknown-eabihf, hasfpu] PrintOptions: [--target=thumbv8.1m.main-none-eabihf] - Dir: arm-none-eabi/thumb/v8.1-m.main/nofp/mve - Flags: [target=thumbv8.1m.main-none-unknown-eabihf, march=+mve] + Tags: [target=thumbv8.1m.main-none-unknown-eabihf, march=+mve] PrintOptions: [--target=arm-none-eabihf, -march=armv8.1m.main+nofp+mve] # A specialisation of v8.1-m.main/fp without exceptions. @@ -141,29 +141,29 @@ # need to have its own include directory or C library, thereby saving # disk space. - Dir: arm-none-eabi/thumb/v8.1-m.main/fp/noexcept - Flags: [target=thumbv8.1m.main-none-unknown-eabihf, hasfpu, fno-exceptions] + Tags: [target=thumbv8.1m.main-none-unknown-eabihf, hasfpu, fno-exceptions] PrintOptions: [--target=thumbv8.1m.main-none-eabihf, -fno-exceptions] -# The second section of the file is a map from auto-detected flags -# to custom flags. The auto-detected flags can be printed out -# by running clang with `-print-multi-selection-flags`. -# The regex must match a whole flag string. -# "MatchFlags" flags will be added if an argument matches, while -# "NoMatchFlags" flags will be added otherwise. -FlagMap: +# The second section of the file is a map from auto-detected tags +# to custom tags. The auto-detected tags can be printed out +# by running clang with `-print-multi-selection-tags`. +# The regex must match a whole tag string. +# "MatchTags" tags will be added if an argument matches, while +# "NoMatchTags" tags will be added otherwise. +TagMap: - Regex: mfpu=none - NoMatchFlags: [hasfpu] + NoMatchTags: [hasfpu] # For v8m.base (and potential later v8m baseline versions) use v6m - Regex: target=thumbv8(\.[0-9]+)?m\.base-none-unknown-eabi - MatchFlags: [target=thumbv6m-none-unknown-eabi] + MatchTags: [target=thumbv6m-none-unknown-eabi] # Match versions after v8.1m.main. We assume that v8.2m (if/when it exists) will # be backwards compatible with v8.1m. # The alternative is to not recognise later versions, and require that # this multilib spec is updated before it can be used with newer # architecture versions. - Regex: thumbv8\.[1-9]m\.main-none-unknown-eabi - MatchFlags: [target=thumbv8.1m.main-none-unknown-eabi] + MatchTags: [target=thumbv8.1m.main-none-unknown-eabi] - Regex: thumbv8\.[1-9]m\.main-none-unknown-eabihf - MatchFlags: [target=thumbv8.1m.main-none-unknown-eabihf] + MatchTags: [target=thumbv8.1m.main-none-unknown-eabihf] ... diff --git a/clang/test/Driver/print-multi-selection-flags.c b/clang/test/Driver/print-multi-selection-flags.c deleted file mode 100644 --- a/clang/test/Driver/print-multi-selection-flags.c +++ /dev/null @@ -1,54 +0,0 @@ -// RUN: %clang -print-multi-selection-flags-experimental --target=aarch64-linux -fc++-abi=itanium -fsanitize=address | FileCheck --check-prefix=CHECK-LINUX %s -// CHECK-LINUX: fc++-abi=itanium -// CHECK-LINUX: fexceptions -// CHECK-LINUX: frtti -// CHECK-LINUX: fsanitize=address -// CHECK-LINUX: target=aarch64-unknown-linux - -// RUN: %clang -print-multi-selection-flags-experimental --target=aarch64-fuchsia -fsanitize=hwaddress | FileCheck --check-prefix=CHECK-FUCHSIA %s -// CHECK-FUCHSIA: fsanitize=hwaddress -// CHECK-FUCHSIA: target=aarch64-unknown-fuchsia - -// RUN: %clang -print-multi-selection-flags-experimental --target=arm-none-eabi -mfloat-abi=soft -fno-exceptions -fno-rtti | FileCheck --check-prefix=CHECK-ARMV4T %s -// CHECK-ARMV4T: fno-exceptions -// CHECK-ARMV4T: fno-rtti -// CHECK-ARMV4T: mfloat-abi=soft -// CHECK-ARMV4T: mfpu=none -// CHECK-ARMV4T: target=armv4t-none-unknown-eabi - -// RUN: %clang -print-multi-selection-flags-experimental --target=armv7em-none-eabi -mfloat-abi=softfp | FileCheck --check-prefix=CHECK-SOFTFP %s -// CHECK-SOFTFP: mfloat-abi=softfp -// CHECK-SOFTFP: mfpu=fpv4-sp-d16 -// CHECK-SOFTFP: target=thumbv7em-none-unknown-eabi - -// RUN: %clang -print-multi-selection-flags-experimental --target=arm-none-eabihf -march=armv7em -mfpu=fpv5-d16 | FileCheck --check-prefix=CHECK-HARD %s -// CHECK-HARD: mfloat-abi=hard -// CHECK-HARD: mfpu=fpv5-d16 -// CHECK-HARD: target=thumbv7em-none-unknown-eabihf - -// RUN: %clang -print-multi-selection-flags-experimental --target=arm-none-eabi -mfloat-abi=soft -march=armv8-m.main+nofp | FileCheck --check-prefix=CHECK-V8MMAIN-NOFP %s -// CHECK-V8MMAIN-NOFP: mfloat-abi=soft -// CHECK-V8MMAIN-NOFP: mfpu=none -// CHECK-V8MMAIN-NOFP: target=thumbv8m.main-none-unknown-eabi - -// RUN: %clang -print-multi-selection-flags-experimental --target=arm-none-eabi -mfloat-abi=hard -march=armv8.1m.main+mve.fp | FileCheck --check-prefix=CHECK-MVE %s -// CHECK-MVE: march=+mve -// CHECK-MVE: march=+mve.fp -// CHECK-MVE: mfloat-abi=hard -// CHECK-MVE: mfpu=fp-armv8-fullfp16-sp-d16 -// CHECK-MVE: target=thumbv8.1m.main-none-unknown-eabihf - -// RUN: %clang -print-multi-selection-flags-experimental --target=arm-none-eabi -march=armv8.1m.main+mve+nofp | FileCheck --check-prefix=CHECK-MVENOFP %s -// CHECK-MVENOFP: march=+mve -// CHECK-MVENOFP-NOT: march=+mve.fp -// CHECK-MVENOFP: mfpu=none - -// RUN: %clang -print-multi-selection-flags-experimental --target=aarch64-none-elf -march=armv8-a+lse | FileCheck --check-prefix=CHECK-LSE %s -// CHECK-LSE: march=+lse - -// RUN: %clang -print-multi-selection-flags-experimental --target=aarch64-none-elf -march=armv8.5-a+sve+sve2 | FileCheck --check-prefix=CHECK-SVE2 %s -// RUN: %clang -print-multi-selection-flags-experimental --target=aarch64-none-elf -march=armv9-a | FileCheck --check-prefix=CHECK-SVE2 %s -// CHECK-SVE2: march=+simd -// CHECK-SVE2: march=+sve -// CHECK-SVE2: march=+sve2 -// CHECK-SVE2: target=aarch64-none-unknown-elf diff --git a/clang/test/Driver/print-multi-selection-tags.c b/clang/test/Driver/print-multi-selection-tags.c new file mode 100644 --- /dev/null +++ b/clang/test/Driver/print-multi-selection-tags.c @@ -0,0 +1,54 @@ +// RUN: %clang -print-multi-selection-tags-experimental --target=aarch64-linux -fc++-abi=itanium -fsanitize=address | FileCheck --check-prefix=CHECK-LINUX %s +// CHECK-LINUX: fc++-abi=itanium +// CHECK-LINUX: fexceptions +// CHECK-LINUX: frtti +// CHECK-LINUX: fsanitize=address +// CHECK-LINUX: target=aarch64-unknown-linux + +// RUN: %clang -print-multi-selection-tags-experimental --target=aarch64-fuchsia -fsanitize=hwaddress | FileCheck --check-prefix=CHECK-FUCHSIA %s +// CHECK-FUCHSIA: fsanitize=hwaddress +// CHECK-FUCHSIA: target=aarch64-unknown-fuchsia + +// RUN: %clang -print-multi-selection-tags-experimental --target=arm-none-eabi -mfloat-abi=soft -fno-exceptions -fno-rtti | FileCheck --check-prefix=CHECK-ARMV4T %s +// CHECK-ARMV4T: fno-exceptions +// CHECK-ARMV4T: fno-rtti +// CHECK-ARMV4T: mfloat-abi=soft +// CHECK-ARMV4T: mfpu=none +// CHECK-ARMV4T: target=armv4t-none-unknown-eabi + +// RUN: %clang -print-multi-selection-tags-experimental --target=armv7em-none-eabi -mfloat-abi=softfp | FileCheck --check-prefix=CHECK-SOFTFP %s +// CHECK-SOFTFP: mfloat-abi=softfp +// CHECK-SOFTFP: mfpu=fpv4-sp-d16 +// CHECK-SOFTFP: target=thumbv7em-none-unknown-eabi + +// RUN: %clang -print-multi-selection-tags-experimental --target=arm-none-eabihf -march=armv7em -mfpu=fpv5-d16 | FileCheck --check-prefix=CHECK-HARD %s +// CHECK-HARD: mfloat-abi=hard +// CHECK-HARD: mfpu=fpv5-d16 +// CHECK-HARD: target=thumbv7em-none-unknown-eabihf + +// RUN: %clang -print-multi-selection-tags-experimental --target=arm-none-eabi -mfloat-abi=soft -march=armv8-m.main+nofp | FileCheck --check-prefix=CHECK-V8MMAIN-NOFP %s +// CHECK-V8MMAIN-NOFP: mfloat-abi=soft +// CHECK-V8MMAIN-NOFP: mfpu=none +// CHECK-V8MMAIN-NOFP: target=thumbv8m.main-none-unknown-eabi + +// RUN: %clang -print-multi-selection-tags-experimental --target=arm-none-eabi -mfloat-abi=hard -march=armv8.1m.main+mve.fp | FileCheck --check-prefix=CHECK-MVE %s +// CHECK-MVE: march=+mve +// CHECK-MVE: march=+mve.fp +// CHECK-MVE: mfloat-abi=hard +// CHECK-MVE: mfpu=fp-armv8-fullfp16-sp-d16 +// CHECK-MVE: target=thumbv8.1m.main-none-unknown-eabihf + +// RUN: %clang -print-multi-selection-tags-experimental --target=arm-none-eabi -march=armv8.1m.main+mve+nofp | FileCheck --check-prefix=CHECK-MVENOFP %s +// CHECK-MVENOFP: march=+mve +// CHECK-MVENOFP-NOT: march=+mve.fp +// CHECK-MVENOFP: mfpu=none + +// RUN: %clang -print-multi-selection-tags-experimental --target=aarch64-none-elf -march=armv8-a+lse | FileCheck --check-prefix=CHECK-LSE %s +// CHECK-LSE: march=+lse + +// RUN: %clang -print-multi-selection-tags-experimental --target=aarch64-none-elf -march=armv8.5-a+sve+sve2 | FileCheck --check-prefix=CHECK-SVE2 %s +// RUN: %clang -print-multi-selection-tags-experimental --target=aarch64-none-elf -march=armv9-a | FileCheck --check-prefix=CHECK-SVE2 %s +// CHECK-SVE2: march=+simd +// CHECK-SVE2: march=+sve +// CHECK-SVE2: march=+sve2 +// CHECK-SVE2: target=aarch64-none-unknown-elf diff --git a/clang/unittests/Driver/MultilibBuilderTest.cpp b/clang/unittests/Driver/MultilibBuilderTest.cpp --- a/clang/unittests/Driver/MultilibBuilderTest.cpp +++ b/clang/unittests/Driver/MultilibBuilderTest.cpp @@ -34,7 +34,7 @@ << "Single contraindicative flag is not valid"; ASSERT_FALSE(MultilibBuilder().flag("+foo").flag("-foo").isValid()) - << "Conflicting flags should invalidate the Multilib"; + << "Conflicting tags should invalidate the Multilib"; ASSERT_TRUE(MultilibBuilder().flag("+foo").flag("+foo").isValid()) << "Multilib should be valid even if it has the same flag " @@ -68,9 +68,9 @@ ASSERT_TRUE(MS.size() == 2); for (MultilibSet::const_iterator I = MS.begin(), E = MS.end(); I != E; ++I) { if (I->gccSuffix() == "/64") - ASSERT_TRUE(*I->flags().begin() == "+m64"); + ASSERT_TRUE(*I->tags().begin() == "+m64"); else if (I->gccSuffix() == "") - ASSERT_TRUE(*I->flags().begin() == "-m64"); + ASSERT_TRUE(*I->tags().begin() == "-m64"); else FAIL() << "Unrecognized gccSufix: " << I->gccSuffix(); } @@ -89,17 +89,17 @@ .Default(false)) << "Multilib " << *I << " wasn't expected"; ASSERT_TRUE(llvm::StringSwitch(I->gccSuffix()) - .Case("", is_contained(I->flags(), "-sof")) - .Case("/sof", is_contained(I->flags(), "+sof")) - .Case("/el", is_contained(I->flags(), "-sof")) - .Case("/sof/el", is_contained(I->flags(), "+sof")) + .Case("", is_contained(I->tags(), "-sof")) + .Case("/sof", is_contained(I->tags(), "+sof")) + .Case("/el", is_contained(I->tags(), "-sof")) + .Case("/sof/el", is_contained(I->tags(), "+sof")) .Default(false)) << "Multilib " << *I << " didn't have the appropriate {+,-}sof flag"; ASSERT_TRUE(llvm::StringSwitch(I->gccSuffix()) - .Case("", is_contained(I->flags(), "-EL")) - .Case("/sof", is_contained(I->flags(), "-EL")) - .Case("/el", is_contained(I->flags(), "+EL")) - .Case("/sof/el", is_contained(I->flags(), "+EL")) + .Case("", is_contained(I->tags(), "-EL")) + .Case("/sof", is_contained(I->tags(), "-EL")) + .Case("/el", is_contained(I->tags(), "+EL")) + .Case("/sof/el", is_contained(I->tags(), "+EL")) .Default(false)) << "Multilib " << *I << " didn't have the appropriate {+,-}EL flag"; } @@ -157,7 +157,7 @@ .Maybe(MultilibBuilder("64").flag("+m64")) .makeMultilibSet(); - Multilib::flag_set FlagM64 = {"+m64"}; + Multilib::tag_set FlagM64 = {"+m64"}; llvm::SmallVector SelectionM64; ASSERT_TRUE(MS1.select(FlagM64, SelectionM64)) << "Flag set was {\"+m64\"}, but selection not found"; @@ -165,7 +165,7 @@ << "Selection picked " << SelectionM64.back() << " which was not expected"; - Multilib::flag_set FlagNoM64 = {"-m64"}; + Multilib::tag_set FlagNoM64 = {"-m64"}; llvm::SmallVector SelectionNoM64; ASSERT_TRUE(MS1.select(FlagNoM64, SelectionNoM64)) << "Flag set was {\"-m64\"}, but selection not found"; @@ -183,19 +183,19 @@ for (unsigned I = 0; I < 4; ++I) { bool IsEL = I & 0x1; bool IsSF = I & 0x2; - Multilib::flag_set Flags; + Multilib::tag_set Tags; if (IsEL) - Flags.insert("+EL"); + Tags.insert("+EL"); else - Flags.insert("-EL"); + Tags.insert("-EL"); if (IsSF) - Flags.insert("+SF"); + Tags.insert("+SF"); else - Flags.insert("-SF"); + Tags.insert("-SF"); llvm::SmallVector Selection; - ASSERT_TRUE(MS2.select(Flags, Selection)) + ASSERT_TRUE(MS2.select(Tags, Selection)) << "Selection failed for " << (IsEL ? "+EL" : "-EL") << " " << (IsSF ? "+SF" : "-SF"); diff --git a/clang/unittests/Driver/MultilibTest.cpp b/clang/unittests/Driver/MultilibTest.cpp --- a/clang/unittests/Driver/MultilibTest.cpp +++ b/clang/unittests/Driver/MultilibTest.cpp @@ -36,21 +36,21 @@ TEST(MultilibTest, OpEqReflexivity3) { Multilib M1({}, {}, {}, {"+foo"}); Multilib M2({}, {}, {}, {"+foo"}); - ASSERT_TRUE(M1 == M2) << "Multilibs with the same flag should be the same"; + ASSERT_TRUE(M1 == M2) << "Multilibs with the same tag should be the same"; } TEST(MultilibTest, OpEqInequivalence1) { Multilib M1({}, {}, {}, {"+foo"}); Multilib M2({}, {}, {}, {"-foo"}); - ASSERT_FALSE(M1 == M2) << "Multilibs with conflicting flags are not the same"; + ASSERT_FALSE(M1 == M2) << "Multilibs with conflicting tags are not the same"; ASSERT_FALSE(M2 == M1) - << "Multilibs with conflicting flags are not the same (commuted)"; + << "Multilibs with conflicting tags are not the same (commuted)"; } TEST(MultilibTest, OpEqInequivalence2) { Multilib M1; Multilib M2({}, {}, {}, {"+foo"}); - ASSERT_FALSE(M1 == M2) << "Flags make Multilibs different"; + ASSERT_FALSE(M1 == M2) << "Tags make Multilibs different"; } TEST(MultilibTest, OpEqEquivalence2) { @@ -126,8 +126,8 @@ TEST(MultilibTest, Construction3) { Multilib M({}, {}, {}, {"+f1", "+f2", "-f3"}); - for (Multilib::flag_set::const_iterator I = M.flags().begin(), - E = M.flags().end(); + for (Multilib::tag_set::const_iterator I = M.tags().begin(), + E = M.tags().end(); I != E; ++I) { ASSERT_TRUE(llvm::StringSwitch(*I) .Cases("+f1", "+f2", "-f3", true) @@ -153,17 +153,17 @@ Multilib("/foo", {}, {}, {"+foo"}), Multilib("/bar", {}, {}, {"+bar"}), }); - Multilib::flag_set Flags1 = {"+foo", "-bar"}; + Multilib::tag_set Tags1 = {"+foo", "-bar"}; llvm::SmallVector Selection1; - ASSERT_TRUE(MS.select(Flags1, Selection1)) - << "Flag set was {\"+foo\"}, but selection not found"; + ASSERT_TRUE(MS.select(Tags1, Selection1)) + << "Tag set was {\"+foo\"}, but selection not found"; ASSERT_TRUE(Selection1.back().gccSuffix() == "/foo") << "Selection picked " << Selection1.back() << " which was not expected"; - Multilib::flag_set Flags2 = {"+foo", "+bar"}; + Multilib::tag_set Tags2 = {"+foo", "+bar"}; llvm::SmallVector Selection2; - ASSERT_TRUE(MS.select(Flags2, Selection2)) - << "Flag set was {\"+bar\"}, but selection not found"; + ASSERT_TRUE(MS.select(Tags2, Selection2)) + << "Tag set was {\"+bar\"}, but selection not found"; ASSERT_TRUE(Selection2.back().gccSuffix() == "/bar") << "Selection picked " << Selection2.back() << " which was not expected"; } @@ -276,7 +276,7 @@ EXPECT_FALSE(parse(MS, Diagnostic, YAML_PREAMBLE R"( Variants: - Dir: /abc - Flags: [] + Tags: [] PrintOptions: [] )")); EXPECT_TRUE(StringRef(Diagnostic).contains("paths must be relative")) @@ -284,7 +284,7 @@ EXPECT_FALSE(parse(MS, Diagnostic, YAML_PREAMBLE R"( Variants: -- Flags: [] +- Tags: [] PrintOptions: [] )")); EXPECT_TRUE(StringRef(Diagnostic).contains("missing required key 'Dir'")) @@ -295,13 +295,13 @@ - Dir: . PrintOptions: [] )")); - EXPECT_TRUE(StringRef(Diagnostic).contains("missing required key 'Flags'")) + EXPECT_TRUE(StringRef(Diagnostic).contains("missing required key 'Tags'")) << Diagnostic; EXPECT_FALSE(parse(MS, Diagnostic, YAML_PREAMBLE R"( Variants: - Dir: . - Flags: [] + Tags: [] )")); EXPECT_TRUE( StringRef(Diagnostic).contains("missing required key 'PrintOptions'")) @@ -309,17 +309,17 @@ EXPECT_FALSE(parse(MS, Diagnostic, YAML_PREAMBLE R"( Variants: [] -FlagMap: +TagMap: - Regex: abc )")); EXPECT_TRUE( StringRef(Diagnostic) - .contains("value required for 'MatchFlags' or 'NoMatchFlags'")) + .contains("value required for 'MatchTags' or 'NoMatchTags'")) << Diagnostic; EXPECT_FALSE(parse(MS, Diagnostic, YAML_PREAMBLE R"( Variants: [] -FlagMap: +TagMap: - Dir: . Regex: '(' PrintOptions: [] @@ -333,7 +333,7 @@ EXPECT_TRUE(parse(MS, YAML_PREAMBLE R"( Variants: - Dir: . - Flags: [] + Tags: [] PrintOptions: [] )")); EXPECT_EQ(1U, MS.size()); @@ -342,7 +342,7 @@ EXPECT_TRUE(parse(MS, YAML_PREAMBLE R"( Variants: - Dir: abc - Flags: [] + Tags: [] PrintOptions: [] )")); EXPECT_EQ(1U, MS.size()); @@ -351,7 +351,7 @@ EXPECT_TRUE(parse(MS, YAML_PREAMBLE R"( Variants: - Dir: pqr - Flags: [] + Tags: [] PrintOptions: [-mfloat-abi=soft] )")); EXPECT_EQ(1U, MS.size()); @@ -362,7 +362,7 @@ EXPECT_TRUE(parse(MS, YAML_PREAMBLE R"( Variants: - Dir: pqr - Flags: [] + Tags: [] PrintOptions: [-mfloat-abi=soft, -fno-exceptions] )")); EXPECT_EQ(1U, MS.size()); @@ -372,10 +372,10 @@ EXPECT_TRUE(parse(MS, YAML_PREAMBLE R"( Variants: - Dir: a - Flags: [] + Tags: [] PrintOptions: [] - Dir: b - Flags: [] + Tags: [] PrintOptions: [] )")); EXPECT_EQ(2U, MS.size()); @@ -387,13 +387,13 @@ ASSERT_TRUE(parse(MS, YAML_PREAMBLE R"( Variants: - Dir: s - Flags: [softabi] + Tags: [softabi] PrintOptions: [] -FlagMap: +TagMap: - Regex: mfloat-abi=soft - MatchFlags: [softabi] + MatchTags: [softabi] - Regex: mfloat-abi=softfp - MatchFlags: [softabi] + MatchTags: [softabi] )")); EXPECT_TRUE(MS.select({"mfloat-abi=soft"}, Selected)); EXPECT_TRUE(MS.select({"mfloat-abi=softfp"}, Selected)); @@ -406,7 +406,7 @@ ASSERT_TRUE(parse(MS, YAML_PREAMBLE R"( Variants: - Dir: f - Flags: [mfloat-abi=softfp] + Tags: [mfloat-abi=softfp] PrintOptions: [] )")); EXPECT_FALSE(MS.select({"mfloat-abi=soft"}, Selected)); @@ -422,7 +422,7 @@ ASSERT_TRUE(parse(MS, YAML_PREAMBLE R"( Variants: - Dir: h - Flags: [mfloat-abi=hard] + Tags: [mfloat-abi=hard] PrintOptions: [] )")); EXPECT_FALSE(MS.select({"mfloat-abi=soft"}, Selected)); @@ -436,21 +436,21 @@ ASSERT_TRUE(parse(MS, YAML_PREAMBLE R"( Variants: - Dir: s - Flags: [softabi] + Tags: [softabi] PrintOptions: [] - Dir: f - Flags: [softabi, hasfp] + Tags: [softabi, hasfp] PrintOptions: [] - Dir: h - Flags: [hardabi, hasfp] + Tags: [hardabi, hasfp] PrintOptions: [] -FlagMap: +TagMap: - Regex: mfloat-abi=(soft|softfp) - MatchFlags: [softabi] + MatchTags: [softabi] - Regex: mfloat-abi=hard - MatchFlags: [hardabi] + MatchTags: [hardabi] - Regex: mfloat-abi=soft - NoMatchFlags: [hasfp] + NoMatchTags: [hasfp] )")); MS.select({"mfloat-abi=soft"}, Selected); EXPECT_EQ("/s", Selected.back().gccSuffix()); @@ -468,21 +468,21 @@ ASSERT_TRUE(parse(MS, YAML_PREAMBLE R"( Variants: - Dir: h - Flags: [hardabi, hasfp] + Tags: [hardabi, hasfp] PrintOptions: [] - Dir: f - Flags: [softabi, hasfp] + Tags: [softabi, hasfp] PrintOptions: [] - Dir: s - Flags: [softabi] + Tags: [softabi] PrintOptions: [] -FlagMap: +TagMap: - Regex: mfloat-abi=(soft|softfp) - MatchFlags: [softabi] + MatchTags: [softabi] - Regex: mfloat-abi=hard - MatchFlags: [hardabi] + MatchTags: [hardabi] - Regex: mfloat-abi=soft - NoMatchFlags: [hasfp] + NoMatchTags: [hasfp] )")); MS.select({"mfloat-abi=soft"}, Selected); EXPECT_EQ("/s", Selected.back().gccSuffix()); @@ -496,52 +496,52 @@ const char *MultilibSpec = YAML_PREAMBLE R"( Variants: - Dir: thumb/v6-m/nofp - Flags: [target=thumbv6m-none-eabi] + Tags: [target=thumbv6m-none-eabi] PrintOptions: [--target=thumbv6m-none-eabi, -mfloat-abi=soft] - Dir: thumb/v7-m/nofp - Flags: [target=thumbv7m-none-eabi] + Tags: [target=thumbv7m-none-eabi] PrintOptions: [--target=thumbv7m-none-eabi, -mfloat-abi=soft] - Dir: thumb/v7e-m/nofp - Flags: [target=thumbv7em-none-eabi] + Tags: [target=thumbv7em-none-eabi] PrintOptions: [--target=thumbv7em-none-eabi, -mfloat-abi=soft, -mfpu=none] - Dir: thumb/v8-m.main/nofp - Flags: [target=thumbv8m.main-none-eabi] + Tags: [target=thumbv8m.main-none-eabi] PrintOptions: [--target=arm-none-eabi, -mfloat-abi=soft, -march=armv8m.main+nofp] - Dir: thumb/v8.1-m.main/nofp/nomve - Flags: [target=thumbv8.1m.main-none-eabi] + Tags: [target=thumbv8.1m.main-none-eabi] PrintOptions: [--target=arm-none-eabi, -mfloat-abi=soft, -march=armv8.1m.main+nofp+nomve] - Dir: thumb/v7e-m/fpv4_sp_d16 - Flags: [target=thumbv7em-none-eabihf, mfpu=fpv4-sp-d16] + Tags: [target=thumbv7em-none-eabihf, mfpu=fpv4-sp-d16] PrintOptions: [--target=thumbv7em-none-eabihf, -mfpu=fpv4-sp-d16] - Dir: thumb/v7e-m/fpv5_d16 - Flags: [target=thumbv7em-none-eabihf, mfpu=fpv5-d16] + Tags: [target=thumbv7em-none-eabihf, mfpu=fpv5-d16] PrintOptions: [--target=thumbv7em-none-eabihf, -mfpu=fpv5-d16] - Dir: thumb/v8-m.main/fp - Flags: [target=thumbv8m.main-none-eabihf] + Tags: [target=thumbv8m.main-none-eabihf] PrintOptions: [--target=thumbv8m.main-none-eabihf] - Dir: thumb/v8.1-m.main/fp - Flags: [target=thumbv8.1m.main-none-eabihf] + Tags: [target=thumbv8.1m.main-none-eabihf] PrintOptions: [--target=thumbv8.1m.main-none-eabihf] - Dir: thumb/v8.1-m.main/nofp/mve - Flags: [target=thumbv8.1m.main-none-eabihf, march=+mve] + Tags: [target=thumbv8.1m.main-none-eabihf, march=+mve] PrintOptions: [--target=arm-none-eabihf, -march=armv8.1m.main+nofp+mve] -FlagMap: +TagMap: - Regex: target=thumbv8(\.[0-9]+)?m\.base-none-eabi - MatchFlags: [target=thumbv6m-none-eabi] + MatchTags: [target=thumbv6m-none-eabi] - Regex: thumbv8\.[1-9]m\.main-none-eabi - MatchFlags: [target=thumbv8.1m.main-none-eabi] + MatchTags: [target=thumbv8.1m.main-none-eabi] - Regex: thumbv8\.[1-9]m\.main-none-eabihf - MatchFlags: [target=thumbv8.1m.main-none-eabihf] + MatchTags: [target=thumbv8.1m.main-none-eabihf] )"; MultilibSet MS;