LLVM: lib/IR/AttributeImpl.h Source File (original) (raw)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15#ifndef LLVM_LIB_IR_ATTRIBUTEIMPL_H
16#define LLVM_LIB_IR_ATTRIBUTEIMPL_H
17
26#include
27#include
28#include
29#include
30#include
31#include
32
33namespace llvm {
34
35class LLVMContext;
37
38
39
40
41
43 unsigned char KindID;
44
45protected:
53 };
54
56
57public:
58
61
68 }
71 }
72
75
79
82
84
86
88
89
90
92
94
106 else
108 }
109
112 ID.AddInteger(Kind);
113 }
114
118 ID.AddInteger(Kind);
119 ID.AddInteger(Val);
120 }
121
123 ID.AddString(Kind);
124 if (!Values.empty()) ID.AddString(Values);
125 }
126
129 ID.AddInteger(Kind);
130 ID.AddPointer(Ty);
131 }
132
135 ID.AddInteger(Kind);
138 }
139
142 ID.AddInteger(Kind);
143 ID.AddInteger(Val.size());
144 for (auto &CR : Val) {
145 CR.getLower().Profile(ID);
146 CR.getUpper().Profile(ID);
147 }
148 }
149};
150
151static_assert(std::is_trivially_destructible::value,
152 "AttributeImpl should be trivially destructible");
153
154
155
156
157
158
159
160
163
164protected:
167
168public:
172 "Can't create a None attribute!");
173 }
174
176};
177
180
181public:
185 "Wrong kind for int attribute!");
186 }
187
189};
190
195
196 unsigned KindSize;
197 unsigned ValSize;
198 size_t numTrailingObjects(OverloadToken) const {
199 return KindSize + 1 + ValSize + 1;
200 }
201
202public:
205 ValSize(Val.size()) {
206 char *TrailingString = getTrailingObjects();
207
209 TrailingString[KindSize] = '\0';
210 llvm::copy(Val, &TrailingString[KindSize + 1]);
211 TrailingString[KindSize + 1 + ValSize] = '\0';
212 }
213
215 return StringRef(getTrailingObjects(), KindSize);
216 }
218 return StringRef(getTrailingObjects() + KindSize + 1, ValSize);
219 }
220
222 return TrailingObjects::totalSizeToAlloc(Kind.size() + 1 +
223 Val.size() + 1);
224 }
225};
226
229
230public:
233
235};
236
239
240public:
243
245};
246
249 private TrailingObjects<ConstantRangeListAttributeImpl, ConstantRange> {
251
252 unsigned Size;
253 size_t numTrailingObjects(OverloadToken) const { return Size; }
254
255public:
260 ConstantRange *TrailingCR = getTrailingObjects();
261 std::uninitialized_copy(Val.begin(), Val.end(), TrailingCR);
262 }
263
265 ConstantRange *TrailingCR = getTrailingObjects();
266 for (unsigned I = 0; I != Size; ++I)
268 }
269
271 return ArrayRef(getTrailingObjects(), Size);
272 }
273
275 return TrailingObjects::totalSizeToAlloc(Val.size());
276 }
277};
278
280
281 uint8_t AvailableAttrs[16] = {};
283 "Too many attributes");
284
285public:
287 return AvailableAttrs[Kind / 8] & (1 << (Kind % 8));
288 }
289
291 AvailableAttrs[Kind / 8] |= 1 << (Kind % 8);
292 }
293};
294
295
296
297
298
303
304 unsigned NumAttrs;
305 AttributeBitSet AvailableAttrs;
306
308
310
313 std::optional findEnumAttribute(Attribute::AttrKind Kind) const;
314
315public:
316
319
320 void operator delete(void *p) { ::operator delete(p); }
321
323
325
326
328
331 }
334
337
342 std::optional<std::pair<unsigned, std::optional>> getAllocSizeArgs()
343 const;
351 std::string getAsString(bool InAttrGrp) const;
353
355
356 iterator begin() const { return getTrailingObjects(); }
358
361 }
362
364 for (const auto &Attr : AttrList)
365 Attr.Profile(ID);
366 }
367};
368
369
370
371
372
375 private TrailingObjects<AttributeListImpl, AttributeSet> {
378
379private:
380 unsigned NumAttrSets;
381
383
385
386
387 size_t numTrailingObjects(OverloadToken) { return NumAttrSets; }
388
389public:
391
392
395
396
397
399 return AvailableFunctionAttrs.hasAttribute(Kind);
400 }
401
402
403
404
406 unsigned *Index = nullptr) const;
407
409
410 iterator begin() const { return getTrailingObjects(); }
412
415
416 void dump() const;
417};
418
419static_assert(std::is_trivially_destructible::value,
420 "AttributeListImpl should be trivially destructible");
421
422}
423
424#endif
This file contains the simple types necessary to represent the attributes associated with functions a...
static GCRegistry::Add< OcamlGC > B("ocaml", "ocaml 3.10-compatible GC")
static GCRegistry::Add< ErlangGC > A("erlang", "erlang-compatible garbage collector")
This file defines the DenseMap class.
This file defines a hash set that can be used to remove duplication of nodes in a graph.
assert(ImpDefSCC.getReg()==AMDGPU::SCC &&ImpDefSCC.isDef())
This header defines support for implementing classes that have some trailing object (or arrays of obj...
void Profile(FoldingSetNodeID &id) const
Used to insert APInt objects, or objects that contain APInt objects, into FoldingSets.
ArrayRef - Represent a constant reference to an array (0 or more elements consecutively in memory),...
size_t size() const
size - Get the array size.
void addAttribute(Attribute::AttrKind Kind)
bool hasAttribute(Attribute::AttrKind Kind) const
int cmp(const AttributeImpl &AI, bool KindOnly) const
Used to sort attributes.
bool isConstantRangeAttribute() const
bool hasAttribute(Attribute::AttrKind A) const
void Profile(FoldingSetNodeID &ID) const
Type * getValueAsType() const
Attribute::AttrKind getKindAsEnum() const
static void Profile(FoldingSetNodeID &ID, StringRef Kind, StringRef Values)
bool operator<(const AttributeImpl &AI) const
Used when sorting the attributes.
static void Profile(FoldingSetNodeID &ID, Attribute::AttrKind Kind, uint64_t Val)
AttributeImpl & operator=(const AttributeImpl &)=delete
static void Profile(FoldingSetNodeID &ID, Attribute::AttrKind Kind)
uint64_t getValueAsInt() const
bool isIntAttribute() const
bool isTypeAttribute() const
static void Profile(FoldingSetNodeID &ID, Attribute::AttrKind Kind, ArrayRef< ConstantRange > Val)
AttributeImpl(AttrEntryKind KindID)
AttributeImpl(const AttributeImpl &)=delete
static void Profile(FoldingSetNodeID &ID, Attribute::AttrKind Kind, Type *Ty)
bool getValueAsBool() const
StringRef getKindAsString() const
StringRef getValueAsString() const
bool isEnumAttribute() const
ArrayRef< ConstantRange > getValueAsConstantRangeList() const
bool isConstantRangeListAttribute() const
@ ConstantRangeListAttrEntry
bool isStringAttribute() const
static void Profile(FoldingSetNodeID &ID, Attribute::AttrKind Kind, const ConstantRange &CR)
const ConstantRange & getValueAsConstantRange() const
bool hasAttrSomewhere(Attribute::AttrKind Kind, unsigned *Index=nullptr) const
Return true if the specified attribute is set for at least one parameter or for the return value.
bool hasFnAttribute(Attribute::AttrKind Kind) const
Return true if the AttributeSet or the FunctionIndex has an enum attribute of the given kind.
AttributeListImpl & operator=(const AttributeListImpl &)=delete
AttributeListImpl(const AttributeListImpl &)=delete
MaybeAlign getStackAlignment() const
uint64_t getDereferenceableOrNullBytes() const
std::optional< unsigned > getVScaleRangeMax() const
bool hasAttribute(Attribute::AttrKind Kind) const
Type * getAttributeType(Attribute::AttrKind Kind) const
AllocFnKind getAllocKind() const
CaptureInfo getCaptureInfo() const
unsigned getVScaleRangeMin() const
MaybeAlign getAlignment() const
MemoryEffects getMemoryEffects() const
UWTableKind getUWTableKind() const
std::optional< std::pair< unsigned, std::optional< unsigned > > > getAllocSizeArgs() const
uint64_t getDereferenceableBytes() const
unsigned getNumAttributes() const
Return the number of attributes this AttributeList contains.
AttributeSetNode & operator=(const AttributeSetNode &)=delete
static void Profile(FoldingSetNodeID &ID, ArrayRef< Attribute > AttrList)
void Profile(FoldingSetNodeID &ID) const
AttributeSetNode(const AttributeSetNode &)=delete
std::string getAsString(bool InAttrGrp) const
static AttributeSetNode * get(LLVMContext &C, const AttrBuilder &B)
bool hasAttributes() const
FPClassTest getNoFPClass() const
Attribute getAttribute(Attribute::AttrKind Kind) const
AttrKind
This enumeration lists the attributes that can be associated with parameters, function results,...
@ None
No attributes have been set.
@ EndAttrKinds
Sentinel value useful for loops.
static bool isIntAttrKind(AttrKind Kind)
static bool isEnumAttrKind(AttrKind Kind)
Represents which components of the pointer may be captured in which location.
const ConstantRange & getConstantRangeValue() const
ConstantRangeAttributeImpl(Attribute::AttrKind Kind, const ConstantRange &CR)
ArrayRef< ConstantRange > getConstantRangeListValue() const
static size_t totalSizeToAlloc(ArrayRef< ConstantRange > Val)
~ConstantRangeListAttributeImpl()
ConstantRangeListAttributeImpl(Attribute::AttrKind Kind, ArrayRef< ConstantRange > Val)
This class represents a range of values.
const APInt & getLower() const
Return the lower value for this range.
const APInt & getUpper() const
Return the upper value for this range.
EnumAttributeImpl(AttrEntryKind ID, Attribute::AttrKind Kind)
Attribute::AttrKind getEnumKind() const
EnumAttributeImpl(Attribute::AttrKind Kind)
Node - This class is used to maintain the singly linked bucket list in a folding set.
FoldingSetNodeID - This class is used to gather all the unique data bits of a node.
IntAttributeImpl(Attribute::AttrKind Kind, uint64_t Val)
uint64_t getValue() const
This is an important class for using LLVM in a threaded context.
StringAttributeImpl(StringRef Kind, StringRef Val=StringRef())
StringRef getStringKind() const
StringRef getStringValue() const
static size_t totalSizeToAlloc(StringRef Kind, StringRef Val)
StringRef - Represent a constant reference to a string, i.e.
constexpr bool empty() const
empty - Check if the string is empty.
constexpr size_t size() const
size - Get the string size.
See the file comment for details on the usage of the TrailingObjects type.
Type * getTypeValue() const
TypeAttributeImpl(Attribute::AttrKind Kind, Type *Ty)
The instances of the Type class are immutable: once they are created, they are never changed.
@ C
The default llvm calling convention, compatible with C.
This is an optimization pass for GlobalISel generic memory operations.
auto size(R &&Range, std::enable_if_t< std::is_base_of< std::random_access_iterator_tag, typename std::iterator_traits< decltype(Range.begin())>::iterator_category >::value, void > *=nullptr)
Get the size of a range.
FPClassTest
Floating-point class tests, supported by 'is_fpclass' intrinsic.
OutputIt copy(R &&Range, OutputIt Out)
This struct is a compact representation of a valid (power of two) or undefined (0) alignment.