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

37

38

39

40

41

43 unsigned char KindID;

44

45protected:

54

56

57public:

58

61

72

75

79

82

84

86

88

89

90

92

94

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

193 private TrailingObjects<StringAttributeImpl, char> {

194 friend TrailingObjects;

195

196 unsigned KindSize;

197 unsigned ValSize;

198

199public:

202 ValSize(Val.size()) {

204

206 TrailingString[KindSize] = '\0';

207 llvm::copy(Val, &TrailingString[KindSize + 1]);

208 TrailingString[KindSize + 1 + ValSize] = '\0';

209 }

210

217

220 Val.size() + 1);

221 }

222};

223

233

243

246 private TrailingObjects<ConstantRangeListAttributeImpl, ConstantRange> {

247 friend TrailingObjects;

248

249 unsigned Size;

250

251public:

258

261 CR.~ConstantRange();

262 }

263

267

271};

272

274

275 uint8_t AvailableAttrs[16] = {};

277 "Too many attributes");

278

279public:

281 return AvailableAttrs[Kind / 8] & (1 << (Kind % 8));

282 }

283

285 AvailableAttrs[Kind / 8] |= 1 << (Kind % 8);

286 }

287};

288

289

290

291

292

293class AttributeSetNode final

295 private TrailingObjects<AttributeSetNode, Attribute> {

296 friend TrailingObjects;

297

298 unsigned NumAttrs;

299 AttributeBitSet AvailableAttrs;

300

302

304

305 static AttributeSetNode *getSorted(LLVMContext &C,

307 std::optional findEnumAttribute(Attribute::AttrKind Kind) const;

308

309public:

310

312 AttributeSetNode &operator=(const AttributeSetNode &) = delete;

313

314 void operator delete(void *p) { ::operator delete(p); }

315

317

319

320

322

324 return AvailableAttrs.hasAttribute(Kind);

325 }

328

331

336 std::optional<std::pair<unsigned, std::optional>> getAllocSizeArgs()

337 const;

345 std::string getAsString(bool InAttrGrp) const;

347

349

352

356

358 for (const auto &Attr : AttrList)

359 Attr.Profile(ID);

360 }

361};

362

363

364

365

366

369 private TrailingObjects<AttributeListImpl, AttributeSet> {

371 friend TrailingObjects;

372

373private:

374 unsigned NumAttrSets;

375

377

379

380public:

382

383

386

387

388

390 return AvailableFunctionAttrs.hasAttribute(Kind);

391 }

392

393

394

395

397 unsigned *Index = nullptr) const;

398

400

403

406

407 void dump() const;

408};

409

410static_assert(std::is_trivially_destructible::value,

411 "AttributeListImpl should be trivially destructible");

412

413}

414

415#endif

assert(UImm &&(UImm !=~static_cast< T >(0)) &&"Invalid immediate!")

This file contains the simple types necessary to represent the attributes associated with functions a...

static GCRegistry::Add< ErlangGC > A("erlang", "erlang-compatible garbage collector")

static GCRegistry::Add< OcamlGC > B("ocaml", "ocaml 3.10-compatible GC")

This file defines the DenseMap class.

This file defines a hash set that can be used to remove duplication of nodes in a graph.

This header defines support for implementing classes that have some trailing object (or arrays of obj...

LLVM_ABI 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.

Definition AttributeImpl.h:273

void addAttribute(Attribute::AttrKind Kind)

Definition AttributeImpl.h:284

bool hasAttribute(Attribute::AttrKind Kind) const

Definition AttributeImpl.h:280

This class represents a single, uniqued attribute.

Definition AttributeImpl.h:42

int cmp(const AttributeImpl &AI, bool KindOnly) const

Used to sort attributes.

bool isConstantRangeAttribute() const

Definition AttributeImpl.h:66

bool hasAttribute(Attribute::AttrKind A) const

void Profile(FoldingSetNodeID &ID) const

Definition AttributeImpl.h:95

Type * getValueAsType() const

Attribute::AttrKind getKindAsEnum() const

static void Profile(FoldingSetNodeID &ID, StringRef Kind, StringRef Values)

Definition AttributeImpl.h:122

bool operator<(const AttributeImpl &AI) const

Used when sorting the attributes.

static void Profile(FoldingSetNodeID &ID, Attribute::AttrKind Kind, uint64_t Val)

Definition AttributeImpl.h:115

AttributeImpl & operator=(const AttributeImpl &)=delete

static void Profile(FoldingSetNodeID &ID, Attribute::AttrKind Kind)

Definition AttributeImpl.h:110

uint64_t getValueAsInt() const

bool isIntAttribute() const

Definition AttributeImpl.h:63

bool isTypeAttribute() const

Definition AttributeImpl.h:65

static void Profile(FoldingSetNodeID &ID, Attribute::AttrKind Kind, ArrayRef< ConstantRange > Val)

Definition AttributeImpl.h:140

AttributeImpl(AttrEntryKind KindID)

Definition AttributeImpl.h:55

AttributeImpl(const AttributeImpl &)=delete

static void Profile(FoldingSetNodeID &ID, Attribute::AttrKind Kind, Type *Ty)

Definition AttributeImpl.h:127

bool getValueAsBool() const

StringRef getKindAsString() const

StringRef getValueAsString() const

bool isEnumAttribute() const

Definition AttributeImpl.h:62

ArrayRef< ConstantRange > getValueAsConstantRangeList() const

bool isConstantRangeListAttribute() const

Definition AttributeImpl.h:69

AttrEntryKind

Definition AttributeImpl.h:46

@ TypeAttrEntry

Definition AttributeImpl.h:50

@ StringAttrEntry

Definition AttributeImpl.h:49

@ ConstantRangeAttrEntry

Definition AttributeImpl.h:51

@ IntAttrEntry

Definition AttributeImpl.h:48

@ ConstantRangeListAttrEntry

Definition AttributeImpl.h:52

@ EnumAttrEntry

Definition AttributeImpl.h:47

bool isStringAttribute() const

Definition AttributeImpl.h:64

static void Profile(FoldingSetNodeID &ID, Attribute::AttrKind Kind, const ConstantRange &CR)

Definition AttributeImpl.h:133

const ConstantRange & getValueAsConstantRange() const

const AttributeSet * iterator

Definition AttributeImpl.h:399

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.

Definition AttributeImpl.h:389

iterator begin() const

Definition AttributeImpl.h:401

AttributeListImpl(ArrayRef< AttributeSet > Sets)

iterator end() const

Definition AttributeImpl.h:402

AttributeListImpl & operator=(const AttributeListImpl &)=delete

friend class AttributeList

Definition AttributeImpl.h:370

AttributeListImpl(const AttributeListImpl &)=delete

This class represents a group of attributes that apply to one element: function, return type,...

Definition AttributeImpl.h:295

MaybeAlign getStackAlignment() const

uint64_t getDereferenceableOrNullBytes() const

std::optional< unsigned > getVScaleRangeMax() const

bool hasAttribute(Attribute::AttrKind Kind) const

Definition AttributeImpl.h:323

Type * getAttributeType(Attribute::AttrKind Kind) const

AllocFnKind getAllocKind() const

CaptureInfo getCaptureInfo() const

unsigned getVScaleRangeMin() const

MaybeAlign getAlignment() const

MemoryEffects getMemoryEffects() const

iterator begin() const

Definition AttributeImpl.h:350

UWTableKind getUWTableKind() const

std::optional< std::pair< unsigned, std::optional< unsigned > > > getAllocSizeArgs() const

iterator end() const

Definition AttributeImpl.h:351

const Attribute * iterator

Definition AttributeImpl.h:348

uint64_t getDereferenceableBytes() const

unsigned getNumAttributes() const

Return the number of attributes this AttributeList contains.

Definition AttributeImpl.h:321

AttributeSetNode & operator=(const AttributeSetNode &)=delete

static void Profile(FoldingSetNodeID &ID, ArrayRef< Attribute > AttrList)

Definition AttributeImpl.h:357

void Profile(FoldingSetNodeID &ID) const

Definition AttributeImpl.h:353

AttributeSetNode(const AttributeSetNode &)=delete

std::string getAsString(bool InAttrGrp) const

static AttributeSetNode * get(LLVMContext &C, const AttrBuilder &B)

bool hasAttributes() const

Definition AttributeImpl.h:327

FPClassTest getNoFPClass() const

Attribute getAttribute(Attribute::AttrKind Kind) const

This class holds the attributes for a particular argument, parameter, function, or return value.

Functions, function parameters, and return types can have attributes to indicate how they should be t...

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

Definition AttributeImpl.h:241

ConstantRangeAttributeImpl(Attribute::AttrKind Kind, const ConstantRange &CR)

Definition AttributeImpl.h:238

ArrayRef< ConstantRange > getConstantRangeListValue() const

Definition AttributeImpl.h:264

static size_t totalSizeToAlloc(ArrayRef< ConstantRange > Val)

Definition AttributeImpl.h:268

~ConstantRangeListAttributeImpl()

Definition AttributeImpl.h:259

ConstantRangeListAttributeImpl(Attribute::AttrKind Kind, ArrayRef< ConstantRange > Val)

Definition AttributeImpl.h:252

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)

Definition AttributeImpl.h:165

Attribute::AttrKind getEnumKind() const

Definition AttributeImpl.h:175

EnumAttributeImpl(Attribute::AttrKind Kind)

Definition AttributeImpl.h:169

FoldingSetNodeID - This class is used to gather all the unique data bits of a node.

IntAttributeImpl(Attribute::AttrKind Kind, uint64_t Val)

Definition AttributeImpl.h:182

uint64_t getValue() const

Definition AttributeImpl.h:188

This is an important class for using LLVM in a threaded context.

StringAttributeImpl(StringRef Kind, StringRef Val=StringRef())

Definition AttributeImpl.h:200

StringRef getStringKind() const

Definition AttributeImpl.h:211

StringRef getStringValue() const

Definition AttributeImpl.h:214

static size_t totalSizeToAlloc(StringRef Kind, StringRef Val)

Definition AttributeImpl.h:218

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.

static constexpr std::enable_if_t< std::is_same_v< Foo< TrailingTys... >, Foo< Tys... > >, size_t > totalSizeToAlloc(typename trailing_objects_internal::ExtractSecondType< TrailingTys, size_t >::type... Counts)

Returns the total size of an object if it were allocated with the given trailing object counts.

const T * getTrailingObjects() const

Type * getTypeValue() const

Definition AttributeImpl.h:231

TypeAttributeImpl(Attribute::AttrKind Kind, Type *Ty)

Definition AttributeImpl.h:228

The instances of the Type class are immutable: once they are created, they are never changed.

unsigned ID

LLVM IR allows to use arbitrary numbers as calling convention identifiers.

@ 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.

FoldingSetBase::Node FoldingSetNode

MemoryEffectsBase< IRMemLocation > MemoryEffects

Summary of how a function affects memory in the program.

auto uninitialized_copy(R &&Src, IterTy Dst)

FPClassTest

Floating-point class tests, supported by 'is_fpclass' intrinsic.

ArrayRef(const T &OneElt) -> ArrayRef< T >

OutputIt copy(R &&Range, OutputIt Out)

This struct is a compact representation of a valid (power of two) or undefined (0) alignment.