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
25#include
26#include <initializer_list>
27#include
28#include
29
30namespace llvm {
31
34
37
38
39
40
41
44 "Should be a multiple of 64!");
45 std::array<uint64_t, MAX_SUBTARGET_WORDS> Bits{};
46
47protected:
48 constexpr FeatureBitset(const std::array<uint64_t, MAX_SUBTARGET_WORDS> &B)
49 : Bits{B} {}
50
51public:
56 }
57
62
64 Bits[I / 64] |= uint64_t(1) << (I % 64);
65 return *this;
66 }
67
69 Bits[I / 64] &= ~(uint64_t(1) << (I % 64));
70 return *this;
71 }
72
74 Bits[I / 64] ^= uint64_t(1) << (I % 64);
75 return *this;
76 }
77
80 return (Bits[I / 64] & Mask) != 0;
81 }
82
83 constexpr bool test(unsigned I) const { return (*this)[I]; }
84
86
89 }
90 bool none() const { return (); }
93 for (auto B : Bits)
96 }
97
99 for (unsigned I = 0, E = Bits.size(); I != E; ++I) {
101 }
102 return *this;
103 }
106 Result ^= RHS;
107 return Result;
108 }
109
111 for (unsigned I = 0, E = Bits.size(); I != E; ++I)
113 return *this;
114 }
117 Result &= RHS;
118 return Result;
119 }
120
122 for (unsigned I = 0, E = Bits.size(); I != E; ++I) {
124 }
125 return *this;
126 }
129 Result |= RHS;
130 return Result;
131 }
132
135 for (auto &B : Result.Bits)
137 return Result;
138 }
139
141 return std::equal(std::begin(Bits), std::end(Bits), std::begin(RHS.Bits));
142 }
143
145
147 for (unsigned I = 0, E = size(); I != E; ++I) {
151 }
152 return false;
153 }
154};
155
156
164
165
166
167
168
169
170
171
172
173
174
176 std::vectorstd::string Features;
177
178public:
180
181
183
184
186
188
189
190 const std::vectorstd::string &getFeatures() const { return Features; }
191
192
194
195
197
198
200
201
203 assert(!Feature.empty() && "Empty string");
204
205 char Ch = Feature[0];
206
207 return Ch == '+' || Ch =='-';
208 }
209
210
214
215
217 assert(!Feature.empty() && "Empty string");
218
219 char Ch = Feature[0];
220
221 return Ch == '+';
222 }
223
224
226};
227
228}
229
230#endif
assert(UImm &&(UImm !=~static_cast< T >(0)) &&"Invalid immediate!")
static GCRegistry::Add< CoreCLRGC > E("coreclr", "CoreCLR-compatible GC")
static GCRegistry::Add< OcamlGC > B("ocaml", "ocaml 3.10-compatible GC")
ArrayRef - Represent a constant reference to an array (0 or more elements consecutively in memory),...
const FeatureBitset & getAsBitset() const
Definition SubtargetFeature.h:162
constexpr FeatureBitArray(const std::array< uint64_t, MAX_SUBTARGET_WORDS > &B)
Definition SubtargetFeature.h:159
constexpr FeatureBitset(const std::array< uint64_t, MAX_SUBTARGET_WORDS > &B)
Definition SubtargetFeature.h:48
constexpr FeatureBitset & operator&=(const FeatureBitset &RHS)
Definition SubtargetFeature.h:110
bool any() const
Definition SubtargetFeature.h:87
constexpr FeatureBitset & operator|=(const FeatureBitset &RHS)
Definition SubtargetFeature.h:121
constexpr FeatureBitset & reset(unsigned I)
Definition SubtargetFeature.h:68
constexpr bool operator[](unsigned I) const
Definition SubtargetFeature.h:78
constexpr FeatureBitset & operator^=(const FeatureBitset &RHS)
Definition SubtargetFeature.h:98
bool operator!=(const FeatureBitset &RHS) const
Definition SubtargetFeature.h:144
constexpr FeatureBitset & set(unsigned I)
Definition SubtargetFeature.h:63
constexpr bool test(unsigned I) const
Definition SubtargetFeature.h:83
constexpr FeatureBitset & flip(unsigned I)
Definition SubtargetFeature.h:73
FeatureBitset & set()
Definition SubtargetFeature.h:58
constexpr FeatureBitset()=default
size_t count() const
Definition SubtargetFeature.h:91
constexpr FeatureBitset operator|(const FeatureBitset &RHS) const
Definition SubtargetFeature.h:127
constexpr FeatureBitset(std::initializer_list< unsigned > Init)
Definition SubtargetFeature.h:53
constexpr FeatureBitset operator&(const FeatureBitset &RHS) const
Definition SubtargetFeature.h:115
bool operator<(const FeatureBitset &Other) const
Definition SubtargetFeature.h:146
bool none() const
Definition SubtargetFeature.h:90
bool operator==(const FeatureBitset &RHS) const
Definition SubtargetFeature.h:140
constexpr FeatureBitset operator~() const
Definition SubtargetFeature.h:133
constexpr size_t size() const
Definition SubtargetFeature.h:85
constexpr FeatureBitset operator^(const FeatureBitset &RHS) const
Definition SubtargetFeature.h:104
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.
static LLVM_ABI 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.
Definition SubtargetFeature.h:190
LLVM_ABI 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 '-'.
Definition SubtargetFeature.h:202
static StringRef StripFlag(StringRef Feature)
Return string stripped of flag.
Definition SubtargetFeature.h:211
LLVM_ABI void print(raw_ostream &OS) const
Prints feature string.
LLVM_ABI std::string getString() const
Returns features as a string.
LLVM_ABI void dump() const
LLVM_ABI SubtargetFeatures(StringRef Initial="")
static bool isEnabled(StringRef Feature)
Return true if enable flag; '+'.
Definition SubtargetFeature.h:216
LLVM_ABI void AddFeature(StringRef String, bool Enable=true)
Adds Features.
LLVM_ABI 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
Definition SubtargetFeature.h:36
void fill(R &&Range, T &&Value)
Provide wrappers to std::fill which take ranges instead of having to pass begin/end explicitly.
constexpr 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.
FunctionAddr VTableAddr Count
const unsigned MAX_SUBTARGET_WORDS
Definition SubtargetFeature.h:35