20 #include "llvm/Config/llvm-config.h" 41 return Ch ==
'+' || Ch ==
'-';
61 S.
split(Tmp,
',', -1,
false );
70 : (Enable ?
"+" :
"-") + String.
lower());
88 MaxLen =
std::max(MaxLen, std::strlen(
I.Key));
100 errs() <<
"Available CPUs for this target:\n\n";
101 for (
auto &CPU : CPUTable)
102 errs() <<
format(
" %-*s - %s.\n", MaxCPULen, CPU.Key, CPU.Desc);
106 errs() <<
"Available features for this target:\n\n";
107 for (
auto &Feature : FeatTable)
108 errs() <<
format(
" %-*s - %s.\n", MaxFeatLen, Feature.Key, Feature.Desc);
111 errs() <<
"Use +feature to enable a feature, or -feature to disable it.\n" 112 "For example, llc -mcpu=mycpu -mattr=+feature1,-feature2\n";
117 Split(Features, Initial);
121 return join(Features.begin(), Features.end(),
",");
129 if (FeatureEntry.
Value == FE.Value)
continue;
131 if ((FeatureEntry.
Implies & FE.Value).any()) {
144 if (FeatureEntry.
Value == FE.Value)
continue;
146 if ((FE.Implies & FeatureEntry.
Value).any()) {
161 if ((Bits & FeatureEntry->
Value) == FeatureEntry->
Value) {
162 Bits &= ~FeatureEntry->
Value;
166 Bits |= FeatureEntry->
Value;
172 errs() <<
"'" << Feature <<
"' is not a recognized feature for this target" 173 <<
" (ignoring feature)\n";
188 Bits |= FeatureEntry->
Value;
193 Bits &= ~FeatureEntry->
Value;
199 errs() <<
"'" << Feature <<
"' is not a recognized feature for this target" 200 <<
" (ignoring feature)\n";
212 "CPU table is not sorted");
214 "CPU features table is not sorted");
220 Help(CPUTable, FeatureTable);
223 else if (!CPU.
empty()) {
229 Bits = CPUEntry->
Value;
232 for (
auto &FE : FeatureTable) {
233 if ((CPUEntry->
Value & FE.Value).any())
237 errs() <<
"'" << CPU <<
"' is not a recognized processor for this target" 238 <<
" (ignoring processor)\n";
243 for (
const std::string &Feature : Features) {
245 if (Feature ==
"+help")
246 Help(CPUTable, FeatureTable);
255 for (
auto &
F : Features)
260 #if !defined(NDEBUG) || defined(LLVM_ENABLE_DUMP) const_iterator end(StringRef path)
Get end iterator over path.
raw_ostream & errs()
This returns a reference to a raw_ostream for standard error.
GCNRegPressure max(const GCNRegPressure &P1, const GCNRegPressure &P2)
const_iterator begin(StringRef path, Style style=Style::native)
Get begin iterator over path.
static void Help(ArrayRef< SubtargetFeatureKV > CPUTable, ArrayRef< SubtargetFeatureKV > FeatTable)
Display help for feature choices.
void print(raw_ostream &OS) const
Prints feature string.
This class represents lattice values for constants.
void getDefaultSubtargetFeatures(const Triple &Triple)
Adds the default features for the specified target triple.
static size_t getLongestEntryLength(ArrayRef< SubtargetFeatureKV > Table)
Return the length of the longest entry in the table.
format_object< Ts... > format(const char *Fmt, const Ts &... Vals)
These are helper functions used to produce formatted output.
std::string getString() const
Returns features as a string.
static std::string StripFlag(StringRef Feature)
Return string stripped of flag.
std::string join(IteratorT Begin, IteratorT End, StringRef Separator)
Joins the strings in the range [Begin, End), adding Separator between the elements.
void AddFeature(StringRef String, bool Enable=true)
Adds Features.
ArchType getArch() const
getArch - Get the parsed architecture type of this triple.
FeatureBitset Value
K-V integer value.
LLVM_NODISCARD LLVM_ATTRIBUTE_ALWAYS_INLINE bool empty() const
empty - Check if the string is empty.
Used to provide key value pairs for feature and CPU bit flags.
ArrayRef - Represent a constant reference to an array (0 or more elements consecutively in memory)...
auto lower_bound(R &&Range, ForwardIt I) -> decltype(adl_begin(Range))
Provide wrappers to std::lower_bound which take ranges instead of having to pass begin/end explicitly...
LLVM_NODISCARD LLVM_ATTRIBUTE_ALWAYS_INLINE StringRef substr(size_t Start, size_t N=npos) const
Return a reference to the substring from [Start, Start + N).
static void SetImpliedBits(FeatureBitset &Bits, const SubtargetFeatureKV &FeatureEntry, ArrayRef< SubtargetFeatureKV > FeatureTable)
For each feature that is (transitively) implied by this feature, set it.
static bool hasFlag(StringRef Feature)
Determine if a feature has a flag; '+' or '-'.
Container class for subtarget features.
VendorType getVendor() const
getVendor - Get the parsed vendor type of this triple.
static const SubtargetFeatureKV * Find(StringRef S, ArrayRef< SubtargetFeatureKV > A)
Find KV in array using binary search.
LLVM_ATTRIBUTE_ALWAYS_INLINE iterator begin()
static void ToggleFeature(FeatureBitset &Bits, StringRef String, ArrayRef< SubtargetFeatureKV > FeatureTable)
Toggles a feature and update the feature bits.
Triple - Helper class for working with autoconf configuration names.
This is a 'vector' (really, a variable-sized array), optimized for the case when the array is small...
LLVM_NODISCARD std::pair< StringRef, StringRef > split(char Separator) const
Split into two substrings around the first occurrence of a separator character.
SubtargetFeatures(StringRef Initial="")
raw_ostream & dbgs()
dbgs() - This returns a reference to a raw_ostream for debugging messages.
static void ClearImpliedBits(FeatureBitset &Bits, const SubtargetFeatureKV &FeatureEntry, ArrayRef< SubtargetFeatureKV > FeatureTable)
For each feature that (transitively) implies this feature, clear it.
LLVM_ATTRIBUTE_ALWAYS_INLINE iterator end()
static bool isEnabled(StringRef Feature)
Return true if enable flag; '+'.
LLVM_NODISCARD std::string lower() const
assert(ImpDefSCC.getReg()==AMDGPU::SCC &&ImpDefSCC.isDef())
static void ApplyFeatureFlag(FeatureBitset &Bits, StringRef Feature, ArrayRef< SubtargetFeatureKV > FeatureTable)
Applies the feature flag and update the feature bits.
This class implements an extremely fast bulk output stream that can only output to a stream...
StringRef - Represent a constant reference to a string, i.e.
FeatureBitset Implies
K-V bit mask.
FeatureBitset getFeatureBits(StringRef CPU, ArrayRef< SubtargetFeatureKV > CPUTable, ArrayRef< SubtargetFeatureKV > FeatureTable)
Returns feature bits of a CPU.
static void Split(std::vector< std::string > &V, StringRef S)
Splits a string of comma separated items in to a vector of strings.
bool empty() const
empty - Check if the array is empty.