31 assert(!Feature.
empty() &&
"Empty string");
35 return Ch ==
'+' || Ch ==
'-';
47 assert(!Feature.
empty() &&
"Empty string");
58 assert(!Feature.
empty() &&
"Empty string");
61 std::string
Prefix = IsEnabled ?
"+" :
"-";
76 size_t Comma = S.
find(
',', Pos);
78 if (Comma == std::string::npos) {
80 V.push_back(S.
substr(Pos));
84 V.push_back(S.
substr(Pos, Comma - Pos));
92 static std::string
Join(
const std::vector<std::string> &V) {
100 for (
size_t i = 1; i < V.size(); i++) {
115 if (!String.
empty()) {
139 for (
size_t i = 0; i < Size; i++)
140 MaxLen = std::max(MaxLen,
std::strlen(Table[i].Key));
153 errs() <<
"Available CPUs for this target:\n\n";
154 for (
size_t i = 0; i != CPUTableSize; i++)
156 MaxCPULen, CPUTable[i].Key, CPUTable[i].Desc);
160 errs() <<
"Available features for this target:\n\n";
161 for (
size_t i = 0; i != FeatTableSize; i++)
163 MaxFeatLen, FeatTable[i].Key, FeatTable[i].Desc);
166 errs() <<
"Use +feature to enable a feature, or -feature to disable it.\n"
167 "For example, llc -mcpu=mycpu -mattr=+feature1,-feature2\n";
177 Split(Features, Initial);
182 return Join(Features);
191 size_t FeatureTableSize) {
192 for (
size_t i = 0; i < FeatureTableSize; ++i) {
195 if (FeatureEntry->
Value == FE.
Value)
continue;
210 size_t FeatureTableSize) {
211 for (
size_t i = 0; i < FeatureTableSize; ++i) {
214 if (FeatureEntry->
Value == FE.
Value)
continue;
228 size_t FeatureTableSize) {
234 if ((Bits & FeatureEntry->
Value) == FeatureEntry->
Value) {
235 Bits &= ~FeatureEntry->
Value;
240 Bits |= FeatureEntry->
Value;
243 SetImpliedBits(Bits, FeatureEntry, FeatureTable, FeatureTableSize);
246 errs() <<
"'" << Feature
247 <<
"' is not a recognized feature for this target"
248 <<
" (ignoring feature)\n";
261 size_t FeatureTableSize) {
262 if (!FeatureTableSize || !CPUTableSize)
266 for (
size_t i = 1; i < CPUTableSize; i++) {
267 assert(
strcmp(CPUTable[i - 1].Key, CPUTable[i].Key) < 0 &&
268 "CPU table is not sorted");
270 for (
size_t i = 1; i < FeatureTableSize; i++) {
271 assert(
strcmp(FeatureTable[i - 1].Key, FeatureTable[i].Key) < 0 &&
272 "CPU features table is not sorted");
279 Help(CPUTable, CPUTableSize, FeatureTable, FeatureTableSize);
287 Bits = CPUEntry->
Value;
290 for (
size_t i = 0; i < FeatureTableSize; ++i) {
297 <<
"' is not a recognized processor for this target"
298 <<
" (ignoring processor)\n";
303 for (
size_t i = 0, E = Features.size(); i < E; i++) {
307 if (Feature ==
"+help")
308 Help(CPUTable, CPUTableSize, FeatureTable, FeatureTableSize);
317 Bits |= FeatureEntry->
Value;
320 SetImpliedBits(Bits, FeatureEntry, FeatureTable, FeatureTableSize);
322 Bits &= ~FeatureEntry->
Value;
328 errs() <<
"'" << Feature
329 <<
"' is not a recognized feature for this target"
330 <<
" (ignoring feature)\n";
340 for (
size_t i = 0, e = Features.size(); i != e; ++i)
341 OS << Features[i] <<
" ";
345 #if !defined(NDEBUG) || defined(LLVM_ENABLE_DUMP)
static void Help(const SubtargetFeatureKV *CPUTable, size_t CPUTableSize, const SubtargetFeatureKV *FeatTable, size_t FeatTableSize)
int strcmp(const char *s1, const char *s2);
void getDefaultSubtargetFeatures(const Triple &Triple)
Adds the default features for the specified target triple.
static const SubtargetFeatureKV * Find(StringRef S, const SubtargetFeatureKV *A, size_t L)
Find KV in array using binary search.
size_t find(char C, size_t From=0) const
StringRef substr(size_t Start, size_t N=npos) const
static void ClearImpliedBits(uint64_t &Bits, const SubtargetFeatureKV *FeatureEntry, const SubtargetFeatureKV *FeatureTable, size_t FeatureTableSize)
SubtargetFeatures(const StringRef Initial="")
format_object1< T > format(const char *Fmt, const T &Val)
static bool isEnabled(const StringRef Feature)
ArchType getArch() const
getArch - Get the parsed architecture type of this triple.
static std::string Join(const std::vector< std::string > &V)
static size_t getLongestEntryLength(const SubtargetFeatureKV *Table, size_t Size)
static void SetImpliedBits(uint64_t &Bits, const SubtargetFeatureKV *FeatureEntry, const SubtargetFeatureKV *FeatureTable, size_t FeatureTableSize)
std::string getString() const
Features string accessors.
uint64_t getFeatureBits(const StringRef CPU, const SubtargetFeatureKV *CPUTable, size_t CPUTableSize, const SubtargetFeatureKV *FeatureTable, size_t FeatureTableSize)
Get feature bits of a CPU.
void AddFeature(const StringRef String, bool IsEnabled=true)
Adding Features.
static void Split(std::vector< std::string > &V, const StringRef S)
static std::string StripFlag(const StringRef Feature)
size_t strlen(const char *s);
raw_ostream & dbgs()
dbgs - Return a circular-buffered debug stream.
uint64_t ToggleFeature(uint64_t Bits, const StringRef String, const SubtargetFeatureKV *FeatureTable, size_t FeatureTableSize)
static std::string PrependFlag(const StringRef Feature, bool IsEnabled)
void print(raw_ostream &OS) const
Print feature string.
VendorType getVendor() const
getVendor - Get the parsed vendor type of this triple.
std::string lower() const
static bool hasFlag(const StringRef Feature)
bool empty() const
empty - Check if the string is empty.