LLVM 19.0.0git
Operator.h
Go to the documentation of this file.
1//===-- llvm/Operator.h - Operator utility subclass -------------*- C++ -*-===//
2//
3// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4// See https://llvm.org/LICENSE.txt for license information.
5// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6//
7//===----------------------------------------------------------------------===//
8//
9// This file defines various classes for working with Instructions and
10// ConstantExprs.
11//
12//===----------------------------------------------------------------------===//
13
14#ifndef LLVM_IR_OPERATOR_H
15#define LLVM_IR_OPERATOR_H
16
17#include "llvm/ADT/MapVector.h"
18#include "llvm/IR/Constants.h"
19#include "llvm/IR/FMF.h"
21#include "llvm/IR/Instruction.h"
22#include "llvm/IR/Type.h"
23#include "llvm/IR/Value.h"
25#include <cstddef>
26#include <optional>
27
28namespace llvm {
29
30/// This is a utility class that provides an abstraction for the common
31/// functionality between Instructions and ConstantExprs.
32class Operator : public User {
33public:
34 // The Operator class is intended to be used as a utility, and is never itself
35 // instantiated.
36 Operator() = delete;
37 ~Operator() = delete;
38
39 void *operator new(size_t s) = delete;
40
41 /// Return the opcode for this Instruction or ConstantExpr.
42 unsigned getOpcode() const {
43 if (const Instruction *I = dyn_cast<Instruction>(this))
44 return I->getOpcode();
45 return cast<ConstantExpr>(this)->getOpcode();
46 }
47
48 /// If V is an Instruction or ConstantExpr, return its opcode.
49 /// Otherwise return UserOp1.
50 static unsigned getOpcode(const Value *V) {
51 if (const Instruction *I = dyn_cast<Instruction>(V))
52 return I->getOpcode();
53 if (const ConstantExpr *CE = dyn_cast<ConstantExpr>(V))
54 return CE->getOpcode();
55 return Instruction::UserOp1;
56 }
57
58 static bool classof(const Instruction *) { return true; }
59 static bool classof(const ConstantExpr *) { return true; }
60 static bool classof(const Value *V) {
61 return isa<Instruction>(V) || isa<ConstantExpr>(V);
62 }
63
64 /// Return true if this operator has flags which may cause this operator
65 /// to evaluate to poison despite having non-poison inputs.
66 bool hasPoisonGeneratingFlags() const;
67
68 /// Return true if this operator has poison-generating flags,
69 /// return attributes or metadata. The latter two is only possible for
70 /// instructions.
72};
73
74/// Utility class for integer operators which may exhibit overflow - Add, Sub,
75/// Mul, and Shl. It does not include SDiv, despite that operator having the
76/// potential for overflow.
78public:
79 enum {
81 NoUnsignedWrap = (1 << 0),
82 NoSignedWrap = (1 << 1)
83 };
84
85private:
86 friend class Instruction;
87 friend class ConstantExpr;
88
89 void setHasNoUnsignedWrap(bool B) {
91 (SubclassOptionalData & ~NoUnsignedWrap) | (B * NoUnsignedWrap);
92 }
93 void setHasNoSignedWrap(bool B) {
95 (SubclassOptionalData & ~NoSignedWrap) | (B * NoSignedWrap);
96 }
97
98public:
99 /// Transparently provide more efficient getOperand methods.
101
102 /// Test whether this operation is known to never
103 /// undergo unsigned overflow, aka the nuw property.
104 bool hasNoUnsignedWrap() const {
106 }
107
108 /// Test whether this operation is known to never
109 /// undergo signed overflow, aka the nsw property.
110 bool hasNoSignedWrap() const {
111 return (SubclassOptionalData & NoSignedWrap) != 0;
112 }
113
114 /// Returns the no-wrap kind of the operation.
115 unsigned getNoWrapKind() const {
116 unsigned NoWrapKind = 0;
117 if (hasNoUnsignedWrap())
118 NoWrapKind |= NoUnsignedWrap;
119
120 if (hasNoSignedWrap())
121 NoWrapKind |= NoSignedWrap;
122
123 return NoWrapKind;
124 }
125
126 static bool classof(const Instruction *I) {
127 return I->getOpcode() == Instruction::Add ||
128 I->getOpcode() == Instruction::Sub ||
129 I->getOpcode() == Instruction::Mul ||
130 I->getOpcode() == Instruction::Shl;
131 }
132 static bool classof(const ConstantExpr *CE) {
133 return CE->getOpcode() == Instruction::Add ||
134 CE->getOpcode() == Instruction::Sub ||
135 CE->getOpcode() == Instruction::Mul ||
136 CE->getOpcode() == Instruction::Shl;
137 }
138 static bool classof(const Value *V) {
139 return (isa<Instruction>(V) && classof(cast<Instruction>(V))) ||
140 (isa<ConstantExpr>(V) && classof(cast<ConstantExpr>(V)));
141 }
142};
143
144template <>
146 : public FixedNumOperandTraits<OverflowingBinaryOperator, 2> {};
147
149
150/// A udiv or sdiv instruction, which can be marked as "exact",
151/// indicating that no bits are destroyed.
153public:
154 enum {
155 IsExact = (1 << 0)
156 };
157
158private:
159 friend class Instruction;
160 friend class ConstantExpr;
161
162 void setIsExact(bool B) {
163 SubclassOptionalData = (SubclassOptionalData & ~IsExact) | (B * IsExact);
164 }
165
166public:
167 /// Transparently provide more efficient getOperand methods.
169
170 /// Test whether this division is known to be exact, with zero remainder.
171 bool isExact() const {
172 return SubclassOptionalData & IsExact;
173 }
174
175 static bool isPossiblyExactOpcode(unsigned OpC) {
176 return OpC == Instruction::SDiv ||
177 OpC == Instruction::UDiv ||
178 OpC == Instruction::AShr ||
179 OpC == Instruction::LShr;
180 }
181
182 static bool classof(const ConstantExpr *CE) {
183 return isPossiblyExactOpcode(CE->getOpcode());
184 }
185 static bool classof(const Instruction *I) {
186 return isPossiblyExactOpcode(I->getOpcode());
187 }
188 static bool classof(const Value *V) {
189 return (isa<Instruction>(V) && classof(cast<Instruction>(V))) ||
190 (isa<ConstantExpr>(V) && classof(cast<ConstantExpr>(V)));
191 }
192};
193
194template <>
196 : public FixedNumOperandTraits<PossiblyExactOperator, 2> {};
197
199
200/// Utility class for floating point operations which can have
201/// information about relaxed accuracy requirements attached to them.
202class FPMathOperator : public Operator {
203private:
204 friend class Instruction;
205
206 /// 'Fast' means all bits are set.
207 void setFast(bool B) {
208 setHasAllowReassoc(B);
209 setHasNoNaNs(B);
210 setHasNoInfs(B);
211 setHasNoSignedZeros(B);
212 setHasAllowReciprocal(B);
213 setHasAllowContract(B);
214 setHasApproxFunc(B);
215 }
216
217 void setHasAllowReassoc(bool B) {
218 SubclassOptionalData =
219 (SubclassOptionalData & ~FastMathFlags::AllowReassoc) |
221 }
222
223 void setHasNoNaNs(bool B) {
224 SubclassOptionalData =
225 (SubclassOptionalData & ~FastMathFlags::NoNaNs) |
227 }
228
229 void setHasNoInfs(bool B) {
230 SubclassOptionalData =
231 (SubclassOptionalData & ~FastMathFlags::NoInfs) |
233 }
234
235 void setHasNoSignedZeros(bool B) {
236 SubclassOptionalData =
237 (SubclassOptionalData & ~FastMathFlags::NoSignedZeros) |
239 }
240
241 void setHasAllowReciprocal(bool B) {
242 SubclassOptionalData =
243 (SubclassOptionalData & ~FastMathFlags::AllowReciprocal) |
245 }
246
247 void setHasAllowContract(bool B) {
248 SubclassOptionalData =
249 (SubclassOptionalData & ~FastMathFlags::AllowContract) |
251 }
252
253 void setHasApproxFunc(bool B) {
254 SubclassOptionalData =
255 (SubclassOptionalData & ~FastMathFlags::ApproxFunc) |
257 }
258
259 /// Convenience function for setting multiple fast-math flags.
260 /// FMF is a mask of the bits to set.
261 void setFastMathFlags(FastMathFlags FMF) {
262 SubclassOptionalData |= FMF.Flags;
263 }
264
265 /// Convenience function for copying all fast-math flags.
266 /// All values in FMF are transferred to this operator.
267 void copyFastMathFlags(FastMathFlags FMF) {
268 SubclassOptionalData = FMF.Flags;
269 }
270
271public:
272 /// Test if this operation allows all non-strict floating-point transforms.
273 bool isFast() const {
274 return ((SubclassOptionalData & FastMathFlags::AllowReassoc) != 0 &&
275 (SubclassOptionalData & FastMathFlags::NoNaNs) != 0 &&
276 (SubclassOptionalData & FastMathFlags::NoInfs) != 0 &&
277 (SubclassOptionalData & FastMathFlags::NoSignedZeros) != 0 &&
278 (SubclassOptionalData & FastMathFlags::AllowReciprocal) != 0 &&
279 (SubclassOptionalData & FastMathFlags::AllowContract) != 0 &&
280 (SubclassOptionalData & FastMathFlags::ApproxFunc) != 0);
281 }
282
283 /// Test if this operation may be simplified with reassociative transforms.
284 bool hasAllowReassoc() const {
285 return (SubclassOptionalData & FastMathFlags::AllowReassoc) != 0;
286 }
287
288 /// Test if this operation's arguments and results are assumed not-NaN.
289 bool hasNoNaNs() const {
290 return (SubclassOptionalData & FastMathFlags::NoNaNs) != 0;
291 }
292
293 /// Test if this operation's arguments and results are assumed not-infinite.
294 bool hasNoInfs() const {
295 return (SubclassOptionalData & FastMathFlags::NoInfs) != 0;
296 }
297
298 /// Test if this operation can ignore the sign of zero.
299 bool hasNoSignedZeros() const {
300 return (SubclassOptionalData & FastMathFlags::NoSignedZeros) != 0;
301 }
302
303 /// Test if this operation can use reciprocal multiply instead of division.
304 bool hasAllowReciprocal() const {
305 return (SubclassOptionalData & FastMathFlags::AllowReciprocal) != 0;
306 }
307
308 /// Test if this operation can be floating-point contracted (FMA).
309 bool hasAllowContract() const {
310 return (SubclassOptionalData & FastMathFlags::AllowContract) != 0;
311 }
312
313 /// Test if this operation allows approximations of math library functions or
314 /// intrinsics.
315 bool hasApproxFunc() const {
316 return (SubclassOptionalData & FastMathFlags::ApproxFunc) != 0;
317 }
318
319 /// Convenience function for getting all the fast-math flags
321 return FastMathFlags(SubclassOptionalData);
322 }
323
324 /// Get the maximum error permitted by this operation in ULPs. An accuracy of
325 /// 0.0 means that the operation should be performed with the default
326 /// precision.
327 float getFPAccuracy() const;
328
329 static bool classof(const Value *V) {
330 unsigned Opcode;
331 if (auto *I = dyn_cast<Instruction>(V))
332 Opcode = I->getOpcode();
333 else
334 return false;
335
336 switch (Opcode) {
337 case Instruction::FNeg:
338 case Instruction::FAdd:
339 case Instruction::FSub:
340 case Instruction::FMul:
341 case Instruction::FDiv:
342 case Instruction::FRem:
343 // FIXME: To clean up and correct the semantics of fast-math-flags, FCmp
344 // should not be treated as a math op, but the other opcodes should.
345 // This would make things consistent with Select/PHI (FP value type
346 // determines whether they are math ops and, therefore, capable of
347 // having fast-math-flags).
348 case Instruction::FCmp:
349 return true;
350 case Instruction::PHI:
351 case Instruction::Select:
352 case Instruction::Call: {
353 Type *Ty = V->getType();
354 while (ArrayType *ArrTy = dyn_cast<ArrayType>(Ty))
355 Ty = ArrTy->getElementType();
356 return Ty->isFPOrFPVectorTy();
357 }
358 default:
359 return false;
360 }
361 }
362};
363
364/// A helper template for defining operators for individual opcodes.
365template<typename SuperClass, unsigned Opc>
367public:
368 static bool classof(const Instruction *I) {
369 return I->getOpcode() == Opc;
370 }
371 static bool classof(const ConstantExpr *CE) {
372 return CE->getOpcode() == Opc;
373 }
374 static bool classof(const Value *V) {
375 return (isa<Instruction>(V) && classof(cast<Instruction>(V))) ||
376 (isa<ConstantExpr>(V) && classof(cast<ConstantExpr>(V)));
377 }
378};
379
381 : public ConcreteOperator<OverflowingBinaryOperator, Instruction::Add> {
382};
384 : public ConcreteOperator<OverflowingBinaryOperator, Instruction::Sub> {
385};
387 : public ConcreteOperator<OverflowingBinaryOperator, Instruction::Mul> {
388};
390 : public ConcreteOperator<OverflowingBinaryOperator, Instruction::Shl> {
391};
392
394 : public ConcreteOperator<PossiblyExactOperator, Instruction::AShr> {
395};
397 : public ConcreteOperator<PossiblyExactOperator, Instruction::LShr> {
398};
399
401 : public ConcreteOperator<Operator, Instruction::GetElementPtr> {
402public:
403 /// Transparently provide more efficient getOperand methods.
405
408 }
409
410 /// Test whether this is an inbounds GEP, as defined by LangRef.html.
411 bool isInBounds() const { return getNoWrapFlags().isInBounds(); }
412
415 }
416
417 bool hasNoUnsignedWrap() const {
419 }
420
421 /// Returns the offset of the index with an inrange attachment, or
422 /// std::nullopt if none.
423 std::optional<ConstantRange> getInRange() const;
424
425 inline op_iterator idx_begin() { return op_begin()+1; }
426 inline const_op_iterator idx_begin() const { return op_begin()+1; }
427 inline op_iterator idx_end() { return op_end(); }
428 inline const_op_iterator idx_end() const { return op_end(); }
429
431 return make_range(idx_begin(), idx_end());
432 }
433
435 return make_range(idx_begin(), idx_end());
436 }
437
439 return getOperand(0);
440 }
441 const Value *getPointerOperand() const {
442 return getOperand(0);
443 }
444 static unsigned getPointerOperandIndex() {
445 return 0U; // get index for modifying correct operand
446 }
447
448 /// Method to return the pointer operand as a PointerType.
450 return getPointerOperand()->getType();
451 }
452
453 Type *getSourceElementType() const;
454 Type *getResultElementType() const;
455
456 /// Method to return the address space of the pointer operand.
457 unsigned getPointerAddressSpace() const {
459 }
460
461 unsigned getNumIndices() const { // Note: always non-negative
462 return getNumOperands() - 1;
463 }
464
465 bool hasIndices() const {
466 return getNumOperands() > 1;
467 }
468
469 /// Return true if all of the indices of this GEP are zeros.
470 /// If so, the result pointer and the first operand have the same
471 /// value, just potentially different types.
472 bool hasAllZeroIndices() const {
473 for (const_op_iterator I = idx_begin(), E = idx_end(); I != E; ++I) {
474 if (ConstantInt *C = dyn_cast<ConstantInt>(I))
475 if (C->isZero())
476 continue;
477 return false;
478 }
479 return true;
480 }
481
482 /// Return true if all of the indices of this GEP are constant integers.
483 /// If so, the result pointer and the first operand have
484 /// a constant offset between them.
486 for (const_op_iterator I = idx_begin(), E = idx_end(); I != E; ++I) {
487 if (!isa<ConstantInt>(I))
488 return false;
489 }
490 return true;
491 }
492
493 unsigned countNonConstantIndices() const {
494 return count_if(indices(), [](const Use& use) {
495 return !isa<ConstantInt>(*use);
496 });
497 }
498
499 /// Compute the maximum alignment that this GEP is garranteed to preserve.
501
502 /// Accumulate the constant address offset of this GEP if possible.
503 ///
504 /// This routine accepts an APInt into which it will try to accumulate the
505 /// constant offset of this GEP.
506 ///
507 /// If \p ExternalAnalysis is provided it will be used to calculate a offset
508 /// when a operand of GEP is not constant.
509 /// For example, for a value \p ExternalAnalysis might try to calculate a
510 /// lower bound. If \p ExternalAnalysis is successful, it should return true.
511 ///
512 /// If the \p ExternalAnalysis returns false or the value returned by \p
513 /// ExternalAnalysis results in a overflow/underflow, this routine returns
514 /// false and the value of the offset APInt is undefined (it is *not*
515 /// preserved!).
516 ///
517 /// The APInt passed into this routine must be at exactly as wide as the
518 /// IntPtr type for the address space of the base GEP pointer.
520 const DataLayout &DL, APInt &Offset,
521 function_ref<bool(Value &, APInt &)> ExternalAnalysis = nullptr) const;
522
523 static bool accumulateConstantOffset(
524 Type *SourceType, ArrayRef<const Value *> Index, const DataLayout &DL,
525 APInt &Offset,
526 function_ref<bool(Value &, APInt &)> ExternalAnalysis = nullptr);
527
528 /// Collect the offset of this GEP as a map of Values to their associated
529 /// APInt multipliers, as well as a total Constant Offset.
530 bool collectOffset(const DataLayout &DL, unsigned BitWidth,
531 MapVector<Value *, APInt> &VariableOffsets,
532 APInt &ConstantOffset) const;
533};
534
535template <>
537 : public VariadicOperandTraits<GEPOperator, 1> {};
538
540
542 : public ConcreteOperator<Operator, Instruction::PtrToInt> {
543 friend class PtrToInt;
544 friend class ConstantExpr;
545
546public:
547 /// Transparently provide more efficient getOperand methods.
549
551 return getOperand(0);
552 }
553 const Value *getPointerOperand() const {
554 return getOperand(0);
555 }
556
557 static unsigned getPointerOperandIndex() {
558 return 0U; // get index for modifying correct operand
559 }
560
561 /// Method to return the pointer operand as a PointerType.
563 return getPointerOperand()->getType();
564 }
565
566 /// Method to return the address space of the pointer operand.
567 unsigned getPointerAddressSpace() const {
568 return cast<PointerType>(getPointerOperandType())->getAddressSpace();
569 }
570};
571
572template <>
574 : public FixedNumOperandTraits<PtrToIntOperator, 1> {};
575
577
579 : public ConcreteOperator<Operator, Instruction::BitCast> {
580 friend class BitCastInst;
581 friend class ConstantExpr;
582
583public:
584 /// Transparently provide more efficient getOperand methods.
586
587 Type *getSrcTy() const {
588 return getOperand(0)->getType();
589 }
590
591 Type *getDestTy() const {
592 return getType();
593 }
594};
595
596template <>
598 : public FixedNumOperandTraits<BitCastOperator, 1> {};
599
601
603 : public ConcreteOperator<Operator, Instruction::AddrSpaceCast> {
604 friend class AddrSpaceCastInst;
605 friend class ConstantExpr;
606
607public:
608 /// Transparently provide more efficient getOperand methods.
610
611 Value *getPointerOperand() { return getOperand(0); }
612
613 const Value *getPointerOperand() const { return getOperand(0); }
614
615 unsigned getSrcAddressSpace() const {
617 }
618
619 unsigned getDestAddressSpace() const {
620 return getType()->getPointerAddressSpace();
621 }
622};
623
624template <>
626 : public FixedNumOperandTraits<AddrSpaceCastOperator, 1> {};
627
629
630} // end namespace llvm
631
632#endif // LLVM_IR_OPERATOR_H
MachineBasicBlock MachineBasicBlock::iterator DebugLoc DL
static GCRegistry::Add< OcamlGC > B("ocaml", "ocaml 3.10-compatible GC")
static GCRegistry::Add< CoreCLRGC > E("coreclr", "CoreCLR-compatible GC")
This file contains the declarations for the subclasses of Constant, which represent the different fla...
Move duplicate certain instructions close to their use
Definition: Localizer.cpp:33
#define I(x, y, z)
Definition: MD5.cpp:58
This file implements a map that provides insertion order iteration.
#define DEFINE_TRANSPARENT_OPERAND_ACCESSORS(CLASS, VALUECLASS)
Macro for generating out-of-class operand accessor definitions.
static SymbolRef::Type getType(const Symbol *Sym)
Definition: TapiFile.cpp:40
Class for arbitrary precision integers.
Definition: APInt.h:77
This class represents a conversion between pointers from one address space to another.
const Value * getPointerOperand() const
Definition: Operator.h:613
unsigned getDestAddressSpace() const
Definition: Operator.h:619
DECLARE_TRANSPARENT_OPERAND_ACCESSORS(Value)
Transparently provide more efficient getOperand methods.
unsigned getSrcAddressSpace() const
Definition: Operator.h:615
ArrayRef - Represent a constant reference to an array (0 or more elements consecutively in memory),...
Definition: ArrayRef.h:41
Class to represent array types.
Definition: DerivedTypes.h:371
This class represents a no-op cast from one type to another.
Type * getDestTy() const
Definition: Operator.h:591
DECLARE_TRANSPARENT_OPERAND_ACCESSORS(Value)
Transparently provide more efficient getOperand methods.
Type * getSrcTy() const
Definition: Operator.h:587
A helper template for defining operators for individual opcodes.
Definition: Operator.h:366
static bool classof(const Value *V)
Definition: Operator.h:374
static bool classof(const ConstantExpr *CE)
Definition: Operator.h:371
static bool classof(const Instruction *I)
Definition: Operator.h:368
A constant value that is initialized with an expression using other constant values.
Definition: Constants.h:1084
This is the shared class of boolean and integer constants.
Definition: Constants.h:81
A parsed version of the target data layout string in and methods for querying it.
Definition: DataLayout.h:110
Utility class for floating point operations which can have information about relaxed accuracy require...
Definition: Operator.h:202
bool hasAllowReassoc() const
Test if this operation may be simplified with reassociative transforms.
Definition: Operator.h:284
bool isFast() const
Test if this operation allows all non-strict floating-point transforms.
Definition: Operator.h:273
static bool classof(const Value *V)
Definition: Operator.h:329
bool hasNoNaNs() const
Test if this operation's arguments and results are assumed not-NaN.
Definition: Operator.h:289
FastMathFlags getFastMathFlags() const
Convenience function for getting all the fast-math flags.
Definition: Operator.h:320
bool hasAllowReciprocal() const
Test if this operation can use reciprocal multiply instead of division.
Definition: Operator.h:304
bool hasNoSignedZeros() const
Test if this operation can ignore the sign of zero.
Definition: Operator.h:299
bool hasAllowContract() const
Test if this operation can be floating-point contracted (FMA).
Definition: Operator.h:309
bool hasNoInfs() const
Test if this operation's arguments and results are assumed not-infinite.
Definition: Operator.h:294
bool hasApproxFunc() const
Test if this operation allows approximations of math library functions or intrinsics.
Definition: Operator.h:315
Convenience struct for specifying and reasoning about fast-math flags.
Definition: FMF.h:20
Represents flags for the getelementptr instruction/expression.
static GEPNoWrapFlags fromRaw(unsigned Flags)
bool hasNoUnsignedSignedWrap() const
bool hasNoUnsignedWrap() const
bool isInBounds() const
bool hasNoUnsignedSignedWrap() const
Definition: Operator.h:413
bool collectOffset(const DataLayout &DL, unsigned BitWidth, MapVector< Value *, APInt > &VariableOffsets, APInt &ConstantOffset) const
Collect the offset of this GEP as a map of Values to their associated APInt multipliers,...
Definition: Operator.cpp:202
const_op_iterator idx_end() const
Definition: Operator.h:428
const Value * getPointerOperand() const
Definition: Operator.h:441
const_op_iterator idx_begin() const
Definition: Operator.h:426
bool isInBounds() const
Test whether this is an inbounds GEP, as defined by LangRef.html.
Definition: Operator.h:411
Type * getPointerOperandType() const
Method to return the pointer operand as a PointerType.
Definition: Operator.h:449
unsigned getNumIndices() const
Definition: Operator.h:461
std::optional< ConstantRange > getInRange() const
Returns the offset of the index with an inrange attachment, or std::nullopt if none.
Definition: Operator.cpp:80
unsigned countNonConstantIndices() const
Definition: Operator.h:493
Type * getSourceElementType() const
Definition: Operator.cpp:68
Type * getResultElementType() const
Definition: Operator.cpp:74
bool accumulateConstantOffset(const DataLayout &DL, APInt &Offset, function_ref< bool(Value &, APInt &)> ExternalAnalysis=nullptr) const
Accumulate the constant address offset of this GEP if possible.
Definition: Operator.cpp:111
bool hasNoUnsignedWrap() const
Definition: Operator.h:417
bool hasAllZeroIndices() const
Return true if all of the indices of this GEP are zeros.
Definition: Operator.h:472
op_iterator idx_end()
Definition: Operator.h:427
DECLARE_TRANSPARENT_OPERAND_ACCESSORS(Value)
Transparently provide more efficient getOperand methods.
op_iterator idx_begin()
Definition: Operator.h:425
Value * getPointerOperand()
Definition: Operator.h:438
GEPNoWrapFlags getNoWrapFlags() const
Definition: Operator.h:406
bool hasAllConstantIndices() const
Return true if all of the indices of this GEP are constant integers.
Definition: Operator.h:485
iterator_range< op_iterator > indices()
Definition: Operator.h:430
bool hasIndices() const
Definition: Operator.h:465
iterator_range< const_op_iterator > indices() const
Definition: Operator.h:434
Align getMaxPreservedAlignment(const DataLayout &DL) const
Compute the maximum alignment that this GEP is garranteed to preserve.
Definition: Operator.cpp:86
unsigned getPointerAddressSpace() const
Method to return the address space of the pointer operand.
Definition: Operator.h:457
static unsigned getPointerOperandIndex()
Definition: Operator.h:444
This class implements a map that also provides access to all stored values in a deterministic order.
Definition: MapVector.h:36
This is a utility class that provides an abstraction for the common functionality between Instruction...
Definition: Operator.h:32
static bool classof(const ConstantExpr *)
Definition: Operator.h:59
bool hasPoisonGeneratingAnnotations() const
Return true if this operator has poison-generating flags, return attributes or metadata.
Definition: Operator.cpp:60
bool hasPoisonGeneratingFlags() const
Return true if this operator has flags which may cause this operator to evaluate to poison despite ha...
Definition: Operator.cpp:21
static bool classof(const Instruction *)
Definition: Operator.h:58
Operator()=delete
unsigned getOpcode() const
Return the opcode for this Instruction or ConstantExpr.
Definition: Operator.h:42
~Operator()=delete
static bool classof(const Value *V)
Definition: Operator.h:60
static unsigned getOpcode(const Value *V)
If V is an Instruction or ConstantExpr, return its opcode.
Definition: Operator.h:50
Utility class for integer operators which may exhibit overflow - Add, Sub, Mul, and Shl.
Definition: Operator.h:77
static bool classof(const Value *V)
Definition: Operator.h:138
DECLARE_TRANSPARENT_OPERAND_ACCESSORS(Value)
Transparently provide more efficient getOperand methods.
bool hasNoSignedWrap() const
Test whether this operation is known to never undergo signed overflow, aka the nsw property.
Definition: Operator.h:110
unsigned getNoWrapKind() const
Returns the no-wrap kind of the operation.
Definition: Operator.h:115
bool hasNoUnsignedWrap() const
Test whether this operation is known to never undergo unsigned overflow, aka the nuw property.
Definition: Operator.h:104
static bool classof(const ConstantExpr *CE)
Definition: Operator.h:132
static bool classof(const Instruction *I)
Definition: Operator.h:126
A udiv or sdiv instruction, which can be marked as "exact", indicating that no bits are destroyed.
Definition: Operator.h:152
static bool classof(const ConstantExpr *CE)
Definition: Operator.h:182
bool isExact() const
Test whether this division is known to be exact, with zero remainder.
Definition: Operator.h:171
DECLARE_TRANSPARENT_OPERAND_ACCESSORS(Value)
Transparently provide more efficient getOperand methods.
static bool isPossiblyExactOpcode(unsigned OpC)
Definition: Operator.h:175
static bool classof(const Value *V)
Definition: Operator.h:188
static bool classof(const Instruction *I)
Definition: Operator.h:185
DECLARE_TRANSPARENT_OPERAND_ACCESSORS(Value)
Transparently provide more efficient getOperand methods.
Type * getPointerOperandType() const
Method to return the pointer operand as a PointerType.
Definition: Operator.h:562
static unsigned getPointerOperandIndex()
Definition: Operator.h:557
unsigned getPointerAddressSpace() const
Method to return the address space of the pointer operand.
Definition: Operator.h:567
const Value * getPointerOperand() const
Definition: Operator.h:553
Value * getPointerOperand()
Definition: Operator.h:550
The instances of the Type class are immutable: once they are created, they are never changed.
Definition: Type.h:45
unsigned getPointerAddressSpace() const
Get the address space of this pointer or pointer vector type.
bool isFPOrFPVectorTy() const
Return true if this is a FP type or a vector of FP.
Definition: Type.h:216
A Use represents the edge between a Value definition and its users.
Definition: Use.h:43
op_iterator op_begin()
Definition: User.h:234
Value * getOperand(unsigned i) const
Definition: User.h:169
unsigned getNumOperands() const
Definition: User.h:191
op_iterator op_end()
Definition: User.h:236
LLVM Value Representation.
Definition: Value.h:74
Type * getType() const
All values are typed, get the type of this value.
Definition: Value.h:255
unsigned char SubclassOptionalData
Hold subclass data that can be dropped.
Definition: Value.h:84
An efficient, type-erasing, non-owning reference to a callable.
A range adaptor for a pair of iterators.
@ C
The default llvm calling convention, compatible with C.
Definition: CallingConv.h:34
This is an optimization pass for GlobalISel generic memory operations.
Definition: AddressRanges.h:18
@ Offset
Definition: DWP.cpp:456
iterator_range< T > make_range(T x, T y)
Convenience function for iterating over sub-ranges.
const Value * getPointerOperand(const Value *V)
A helper function that returns the pointer operand of a load, store or GEP instruction.
constexpr unsigned BitWidth
Definition: BitmaskEnum.h:191
auto count_if(R &&Range, UnaryPredicate P)
Wrapper function around std::count_if to count the number of times an element satisfying a given pred...
Definition: STLExtras.h:1921
This struct is a compact representation of a valid (non-zero power of two) alignment.
Definition: Alignment.h:39
FixedNumOperandTraits - determine the allocation regime of the Use array when it is a prefix to the U...
Definition: OperandTraits.h:30
Compile-time customization of User operands.
Definition: User.h:42
VariadicOperandTraits - determine the allocation regime of the Use array when it is a prefix to the U...
Definition: OperandTraits.h:68