32 assert(!Feature.
empty() &&
"Empty string");
36 return Ch ==
'+' || Ch ==
'-';
48 assert(!Feature.
empty() &&
"Empty string");
59 S.
split(Tmp,
",", -1,
false );
69 : (Enable ?
"+" :
"-") + String.
lower());
76 auto F = std::lower_bound(A.
begin(), A.
end(), S);
88 MaxLen = std::max(MaxLen, std::strlen(
I.Key));
101 errs() <<
"Available CPUs for this target:\n\n";
102 for (
auto &CPU : CPUTable)
103 errs() <<
format(
" %-*s - %s.\n", MaxCPULen, CPU.Key, CPU.Desc);
107 errs() <<
"Available features for this target:\n\n";
108 for (
auto &Feature : FeatTable)
109 errs() <<
format(
" %-*s - %s.\n", MaxFeatLen, Feature.Key, Feature.Desc);
112 errs() <<
"Use +feature to enable a feature, or -feature to disable it.\n"
113 "For example, llc -mcpu=mycpu -mattr=+feature1,-feature2\n";
122 Split(Features, Initial);
127 return join(Features.begin(), Features.end(),
",");
136 for (
auto &FE : FeatureTable) {
137 if (FeatureEntry->
Value == FE.Value)
continue;
139 if ((FeatureEntry->
Implies & FE.Value).any()) {
153 for (
auto &FE : FeatureTable) {
154 if (FeatureEntry->
Value == FE.Value)
continue;
156 if ((FE.Implies & FeatureEntry->
Value).any()) {
174 if ((Bits & FeatureEntry->
Value) == FeatureEntry->
Value) {
175 Bits &= ~FeatureEntry->
Value;
179 Bits |= FeatureEntry->
Value;
185 errs() <<
"'" << Feature
186 <<
"' is not a recognized feature for this target"
187 <<
" (ignoring feature)\n";
206 Bits |= FeatureEntry->
Value;
211 Bits &= ~FeatureEntry->
Value;
217 errs() <<
"'" << Feature
218 <<
"' is not a recognized feature for this target"
219 <<
" (ignoring feature)\n";
237 for (
size_t i = 1, e = CPUTable.
size(); i != e; ++i) {
238 assert(strcmp(CPUTable[i - 1].Key, CPUTable[i].Key) < 0 &&
239 "CPU table is not sorted");
241 for (
size_t i = 1, e = FeatureTable.
size(); i != e; ++i) {
242 assert(strcmp(FeatureTable[i - 1].Key, FeatureTable[i].Key) < 0 &&
243 "CPU features table is not sorted");
251 Help(CPUTable, FeatureTable);
254 else if (!CPU.
empty()) {
260 Bits = CPUEntry->
Value;
263 for (
auto &FE : FeatureTable) {
264 if ((CPUEntry->
Value & FE.Value).any())
269 <<
"' is not a recognized processor for this target"
270 <<
" (ignoring processor)\n";
275 for (
auto &Feature : Features) {
277 if (Feature ==
"+help")
278 Help(CPUTable, FeatureTable);
289 for (
auto &
F : Features)
294 #if !defined(NDEBUG) || defined(LLVM_ENABLE_DUMP)
raw_ostream & errs()
This returns a reference to a raw_ostream for standard error.
static void Help(ArrayRef< SubtargetFeatureKV > CPUTable, ArrayRef< SubtargetFeatureKV > FeatTable)
Display help for feature choices.
void getDefaultSubtargetFeatures(const Triple &Triple)
Adds the default features for the specified target triple.
static size_t getLongestEntryLength(ArrayRef< SubtargetFeatureKV > Table)
getLongestEntryLength - Return the length of the longest entry in the table.
std::pair< StringRef, StringRef > split(char Separator) const
Split into two substrings around the first occurrence of a separator character.
static std::string StripFlag(StringRef Feature)
StripFlag - Return string stripped of flag.
StringRef substr(size_t Start, size_t N=npos) const
Return a reference to the substring from [Start, Start + N).
FeatureBitset ApplyFeatureFlag(FeatureBitset Bits, StringRef Feature, ArrayRef< SubtargetFeatureKV > FeatureTable)
Apply the feature flag and return the newly updated feature bits.
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)
Adding Features.
SubtargetFeatureKV - 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)...
ArchType getArch() const
getArch - Get the parsed architecture type of this triple.
size_t size() const
size - Get the array size.
static bool hasFlag(StringRef Feature)
hasFlag - Determine if a feature has a flag; '+' or '-'
format_object< Ts...> format(const char *Fmt, const Ts &...Vals)
These are helper functions used to produce formatted output.
static const SubtargetFeatureKV * Find(StringRef S, ArrayRef< SubtargetFeatureKV > A)
Find KV in array using binary search.
static void SetImpliedBits(FeatureBitset &Bits, const SubtargetFeatureKV *FeatureEntry, ArrayRef< SubtargetFeatureKV > FeatureTable)
SetImpliedBits - For each feature that is (transitively) implied by this feature, set it...
bool empty() const
empty - Check if the array is empty.
void dump() const
dump - Dump feature info.
std::string getString() const
Features string accessors.
Triple - Helper class for working with autoconf configuration names.
static void ClearImpliedBits(FeatureBitset &Bits, const SubtargetFeatureKV *FeatureEntry, ArrayRef< SubtargetFeatureKV > FeatureTable)
ClearImpliedBits - For each feature that (transitively) implies this feature, clear it...
This is a 'vector' (really, a variable-sized array), optimized for the case when the array is small...
SubtargetFeatures(StringRef Initial="")
raw_ostream & dbgs()
dbgs() - This returns a reference to a raw_ostream for debugging messages.
FeatureBitset ToggleFeature(FeatureBitset Bits, StringRef String, ArrayRef< SubtargetFeatureKV > FeatureTable)
ToggleFeature - Toggle a feature and returns the newly updated feature bits.
static bool isEnabled(StringRef Feature)
isEnabled - Return true if enable flag; '+'.
void print(raw_ostream &OS) const
Print feature string.
This class implements an extremely fast bulk output stream that can only output to a stream...
VendorType getVendor() const
getVendor - Get the parsed vendor type of this triple.
StringRef - Represent a constant reference to a string, i.e.
FeatureBitset getFeatureBits(StringRef CPU, ArrayRef< SubtargetFeatureKV > CPUTable, ArrayRef< SubtargetFeatureKV > FeatureTable)
Get feature bits of a CPU.
static void Split(std::vector< std::string > &V, StringRef S)
Split - Splits a string of comma separated items in to a vector of strings.
std::string lower() const
bool empty() const
empty - Check if the string is empty.