LLVM: include/llvm/TargetParser/SubtargetFeature.h Source File (original) (raw)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17#ifndef LLVM_TARGETPARSER_SUBTARGETFEATURE_H
18#define LLVM_TARGETPARSER_SUBTARGETFEATURE_H
19
24#include
25#include <initializer_list>
26#include
27#include
28
29namespace llvm {
30
31class raw_ostream;
32class Triple;
33
36
37
38
39
40
43 "Should be a multiple of 64!");
44 std::array<uint64_t, MAX_SUBTARGET_WORDS> Bits{};
45
46protected:
47 constexpr FeatureBitset(const std::array<uint64_t, MAX_SUBTARGET_WORDS> &B)
48 : Bits{B} {}
49
50public:
55 }
56
58 std::fill(std::begin(Bits), std::end(Bits), -1ULL);
59 return *this;
60 }
61
63 Bits[I / 64] |= uint64_t(1) << (I % 64);
64 return *this;
65 }
66
68 Bits[I / 64] &= ~(uint64_t(1) << (I % 64));
69 return *this;
70 }
71
73 Bits[I / 64] ^= uint64_t(1) << (I % 64);
74 return *this;
75 }
76
79 return (Bits[I / 64] & Mask) != 0;
80 }
81
82 constexpr bool test(unsigned I) const { return (*this)[I]; }
83
85
88 }
89 bool none() const { return (); }
91 size_t Count = 0;
92 for (auto B : Bits)
94 return Count;
95 }
96
98 for (unsigned I = 0, E = Bits.size(); I != E; ++I) {
100 }
101 return *this;
102 }
105 Result ^= RHS;
106 return Result;
107 }
108
110 for (unsigned I = 0, E = Bits.size(); I != E; ++I)
112 return *this;
113 }
116 Result &= RHS;
117 return Result;
118 }
119
121 for (unsigned I = 0, E = Bits.size(); I != E; ++I) {
123 }
124 return *this;
125 }
128 Result |= RHS;
129 return Result;
130 }
131
134 for (auto &B : Result.Bits)
135 B = ~B;
136 return Result;
137 }
138
140 return std::equal(std::begin(Bits), std::end(Bits), std::begin(RHS.Bits));
141 }
142
144
146 for (unsigned I = 0, E = size(); I != E; ++I) {
150 }
151 return false;
152 }
153};
154
155
157public:
158 constexpr FeatureBitArray(const std::array<uint64_t, MAX_SUBTARGET_WORDS> &B)
160
162};
163
164
165
166
167
168
169
170
171
172
173
175 std::vectorstd::string Features;
176
177public:
179
180
182
183
185
187
188
189 const std::vectorstd::string &getFeatures() const { return Features; }
190
191
193
194
195 void dump() const;
196
197
199
200
202 assert(!Feature.empty() && "Empty string");
203
204 char Ch = Feature[0];
205
206 return Ch == '+' || Ch =='-';
207 }
208
209
211 return hasFlag(Feature) ? Feature.substr(1) : Feature;
212 }
213
214
216 assert(!Feature.empty() && "Empty string");
217
218 char Ch = Feature[0];
219
220 return Ch == '+';
221 }
222
223
224 static void Split(std::vectorstd::string &V, StringRef S);
225};
226
227}
228
229#endif
static GCRegistry::Add< OcamlGC > B("ocaml", "ocaml 3.10-compatible GC")
static GCRegistry::Add< CoreCLRGC > E("coreclr", "CoreCLR-compatible GC")
assert(ImpDefSCC.getReg()==AMDGPU::SCC &&ImpDefSCC.isDef())
ArrayRef - Represent a constant reference to an array (0 or more elements consecutively in memory),...
Class used to store the subtarget bits in the tables created by tablegen.
const FeatureBitset & getAsBitset() const
constexpr FeatureBitArray(const std::array< uint64_t, MAX_SUBTARGET_WORDS > &B)
Container class for subtarget features.
constexpr FeatureBitset(const std::array< uint64_t, MAX_SUBTARGET_WORDS > &B)
constexpr FeatureBitset & operator&=(const FeatureBitset &RHS)
constexpr FeatureBitset & operator|=(const FeatureBitset &RHS)
constexpr FeatureBitset & reset(unsigned I)
constexpr bool operator[](unsigned I) const
constexpr FeatureBitset & operator^=(const FeatureBitset &RHS)
bool operator!=(const FeatureBitset &RHS) const
constexpr FeatureBitset & set(unsigned I)
constexpr bool test(unsigned I) const
constexpr FeatureBitset & flip(unsigned I)
constexpr FeatureBitset()=default
constexpr FeatureBitset operator|(const FeatureBitset &RHS) const
constexpr FeatureBitset(std::initializer_list< unsigned > Init)
constexpr FeatureBitset operator&(const FeatureBitset &RHS) const
bool operator<(const FeatureBitset &Other) const
bool operator==(const FeatureBitset &RHS) const
constexpr FeatureBitset operator~() const
constexpr size_t size() const
constexpr FeatureBitset operator^(const FeatureBitset &RHS) const
StringRef - Represent a constant reference to a string, i.e.
constexpr StringRef substr(size_t Start, size_t N=npos) const
Return a reference to the substring from [Start, Start + N).
constexpr bool empty() const
empty - Check if the string is empty.
Manages the enabling and disabling of subtarget specific features.
static void Split(std::vector< std::string > &V, StringRef S)
Splits a string of comma separated items in to a vector of strings.
const std::vector< std::string > & getFeatures() const
Returns the vector of individual subtarget features.
void getDefaultSubtargetFeatures(const Triple &Triple)
Adds the default features for the specified target triple.
static bool hasFlag(StringRef Feature)
Determine if a feature has a flag; '+' or '-'.
static StringRef StripFlag(StringRef Feature)
Return string stripped of flag.
void print(raw_ostream &OS) const
Prints feature string.
std::string getString() const
Returns features as a string.
static bool isEnabled(StringRef Feature)
Return true if enable flag; '+'.
void AddFeature(StringRef String, bool Enable=true)
Adds Features.
void addFeaturesVector(const ArrayRef< std::string > OtherFeatures)
Triple - Helper class for working with autoconf configuration names.
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.
const unsigned MAX_SUBTARGET_FEATURES
int popcount(T Value) noexcept
Count the number of set bits in a value.
bool any_of(R &&range, UnaryPredicate P)
Provide wrappers to std::any_of which take ranges instead of having to pass begin/end explicitly.
const unsigned MAX_SUBTARGET_WORDS