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"
20#include "llvm/IR/Instruction.h"
21#include "llvm/IR/Type.h"
22#include "llvm/IR/Value.h"
24#include <cstddef>
25#include <optional>
26
27namespace llvm {
28
29/// This is a utility class that provides an abstraction for the common
30/// functionality between Instructions and ConstantExprs.
31class Operator : public User {
32public:
33 // The Operator class is intended to be used as a utility, and is never itself
34 // instantiated.
35 Operator() = delete;
36 ~Operator() = delete;
37
38 void *operator new(size_t s) = delete;
39
40 /// Return the opcode for this Instruction or ConstantExpr.
41 unsigned getOpcode() const {
42 if (const Instruction *I = dyn_cast<Instruction>(this))
43 return I->getOpcode();
44 return cast<ConstantExpr>(this)->getOpcode();
45 }
46
47 /// If V is an Instruction or ConstantExpr, return its opcode.
48 /// Otherwise return UserOp1.
49 static unsigned getOpcode(const Value *V) {
50 if (const Instruction *I = dyn_cast<Instruction>(V))
51 return I->getOpcode();
52 if (const ConstantExpr *CE = dyn_cast<ConstantExpr>(V))
53 return CE->getOpcode();
54 return Instruction::UserOp1;
55 }
56
57 static bool classof(const Instruction *) { return true; }
58 static bool classof(const ConstantExpr *) { return true; }
59 static bool classof(const Value *V) {
60 return isa<Instruction>(V) || isa<ConstantExpr>(V);
61 }
62
63 /// Return true if this operator has flags which may cause this operator
64 /// to evaluate to poison despite having non-poison inputs.
65 bool hasPoisonGeneratingFlags() const;
66
67 /// Return true if this operator has poison-generating flags,
68 /// return attributes or metadata. The latter two is only possible for
69 /// instructions.
71};
72
73/// Utility class for integer operators which may exhibit overflow - Add, Sub,
74/// Mul, and Shl. It does not include SDiv, despite that operator having the
75/// potential for overflow.
77public:
78 enum {
80 NoUnsignedWrap = (1 << 0),
81 NoSignedWrap = (1 << 1)
82 };
83
84private:
85 friend class Instruction;
86 friend class ConstantExpr;
87
88 void setHasNoUnsignedWrap(bool B) {
90 (SubclassOptionalData & ~NoUnsignedWrap) | (B * NoUnsignedWrap);
91 }
92 void setHasNoSignedWrap(bool B) {
94 (SubclassOptionalData & ~NoSignedWrap) | (B * NoSignedWrap);
95 }
96
97public:
98 /// Transparently provide more efficient getOperand methods.
100
101 /// Test whether this operation is known to never
102 /// undergo unsigned overflow, aka the nuw property.
103 bool hasNoUnsignedWrap() const {
105 }
106
107 /// Test whether this operation is known to never
108 /// undergo signed overflow, aka the nsw property.
109 bool hasNoSignedWrap() const {
110 return (SubclassOptionalData & NoSignedWrap) != 0;
111 }
112
113 /// Returns the no-wrap kind of the operation.
114 unsigned getNoWrapKind() const {
115 unsigned NoWrapKind = 0;
116 if (hasNoUnsignedWrap())
117 NoWrapKind |= NoUnsignedWrap;
118
119 if (hasNoSignedWrap())
120 NoWrapKind |= NoSignedWrap;
121
122 return NoWrapKind;
123 }
124
125 static bool classof(const Instruction *I) {
126 return I->getOpcode() == Instruction::Add ||
127 I->getOpcode() == Instruction::Sub ||
128 I->getOpcode() == Instruction::Mul ||
129 I->getOpcode() == Instruction::Shl;
130 }
131 static bool classof(const ConstantExpr *CE) {
132 return CE->getOpcode() == Instruction::Add ||
133 CE->getOpcode() == Instruction::Sub ||
134 CE->getOpcode() == Instruction::Mul ||
135 CE->getOpcode() == Instruction::Shl;
136 }
137 static bool classof(const Value *V) {
138 return (isa<Instruction>(V) && classof(cast<Instruction>(V))) ||
139 (isa<ConstantExpr>(V) && classof(cast<ConstantExpr>(V)));
140 }
141};
142
143template <>
145 : public FixedNumOperandTraits<OverflowingBinaryOperator, 2> {};
146
148
149/// A udiv or sdiv instruction, which can be marked as "exact",
150/// indicating that no bits are destroyed.
152public:
153 enum {
154 IsExact = (1 << 0)
155 };
156
157private:
158 friend class Instruction;
159 friend class ConstantExpr;
160
161 void setIsExact(bool B) {
162 SubclassOptionalData = (SubclassOptionalData & ~IsExact) | (B * IsExact);
163 }
164
165public:
166 /// Transparently provide more efficient getOperand methods.
168
169 /// Test whether this division is known to be exact, with zero remainder.
170 bool isExact() const {
171 return SubclassOptionalData & IsExact;
172 }
173
174 static bool isPossiblyExactOpcode(unsigned OpC) {
175 return OpC == Instruction::SDiv ||
176 OpC == Instruction::UDiv ||
177 OpC == Instruction::AShr ||
178 OpC == Instruction::LShr;
179 }
180
181 static bool classof(const ConstantExpr *CE) {
182 return isPossiblyExactOpcode(CE->getOpcode());
183 }
184 static bool classof(const Instruction *I) {
185 return isPossiblyExactOpcode(I->getOpcode());
186 }
187 static bool classof(const Value *V) {
188 return (isa<Instruction>(V) && classof(cast<Instruction>(V))) ||
189 (isa<ConstantExpr>(V) && classof(cast<ConstantExpr>(V)));
190 }
191};
192
193template <>
195 : public FixedNumOperandTraits<PossiblyExactOperator, 2> {};
196
198
199/// Utility class for floating point operations which can have
200/// information about relaxed accuracy requirements attached to them.
201class FPMathOperator : public Operator {
202private:
203 friend class Instruction;
204
205 /// 'Fast' means all bits are set.
206 void setFast(bool B) {
207 setHasAllowReassoc(B);
208 setHasNoNaNs(B);
209 setHasNoInfs(B);
210 setHasNoSignedZeros(B);
211 setHasAllowReciprocal(B);
212 setHasAllowContract(B);
213 setHasApproxFunc(B);
214 }
215
216 void setHasAllowReassoc(bool B) {
217 SubclassOptionalData =
218 (SubclassOptionalData & ~FastMathFlags::AllowReassoc) |
220 }
221
222 void setHasNoNaNs(bool B) {
223 SubclassOptionalData =
224 (SubclassOptionalData & ~FastMathFlags::NoNaNs) |
226 }
227
228 void setHasNoInfs(bool B) {
229 SubclassOptionalData =
230 (SubclassOptionalData & ~FastMathFlags::NoInfs) |
232 }
233
234 void setHasNoSignedZeros(bool B) {
235 SubclassOptionalData =
236 (SubclassOptionalData & ~FastMathFlags::NoSignedZeros) |
238 }
239
240 void setHasAllowReciprocal(bool B) {
241 SubclassOptionalData =
242 (SubclassOptionalData & ~FastMathFlags::AllowReciprocal) |
244 }
245
246 void setHasAllowContract(bool B) {
247 SubclassOptionalData =
248 (SubclassOptionalData & ~FastMathFlags::AllowContract) |
250 }
251
252 void setHasApproxFunc(bool B) {
253 SubclassOptionalData =
254 (SubclassOptionalData & ~FastMathFlags::ApproxFunc) |
256 }
257
258 /// Convenience function for setting multiple fast-math flags.
259 /// FMF is a mask of the bits to set.
260 void setFastMathFlags(FastMathFlags FMF) {
261 SubclassOptionalData |= FMF.Flags;
262 }
263
264 /// Convenience function for copying all fast-math flags.
265 /// All values in FMF are transferred to this operator.
266 void copyFastMathFlags(FastMathFlags FMF) {
267 SubclassOptionalData = FMF.Flags;
268 }
269
270public:
271 /// Test if this operation allows all non-strict floating-point transforms.
272 bool isFast() const {
273 return ((SubclassOptionalData & FastMathFlags::AllowReassoc) != 0 &&
274 (SubclassOptionalData & FastMathFlags::NoNaNs) != 0 &&
275 (SubclassOptionalData & FastMathFlags::NoInfs) != 0 &&
276 (SubclassOptionalData & FastMathFlags::NoSignedZeros) != 0 &&
277 (SubclassOptionalData & FastMathFlags::AllowReciprocal) != 0 &&
278 (SubclassOptionalData & FastMathFlags::AllowContract) != 0 &&
279 (SubclassOptionalData & FastMathFlags::ApproxFunc) != 0);
280 }
281
282 /// Test if this operation may be simplified with reassociative transforms.
283 bool hasAllowReassoc() const {
284 return (SubclassOptionalData & FastMathFlags::AllowReassoc) != 0;
285 }
286
287 /// Test if this operation's arguments and results are assumed not-NaN.
288 bool hasNoNaNs() const {
289 return (SubclassOptionalData & FastMathFlags::NoNaNs) != 0;
290 }
291
292 /// Test if this operation's arguments and results are assumed not-infinite.
293 bool hasNoInfs() const {
294 return (SubclassOptionalData & FastMathFlags::NoInfs) != 0;
295 }
296
297 /// Test if this operation can ignore the sign of zero.
298 bool hasNoSignedZeros() const {
299 return (SubclassOptionalData & FastMathFlags::NoSignedZeros) != 0;
300 }
301
302 /// Test if this operation can use reciprocal multiply instead of division.
303 bool hasAllowReciprocal() const {
304 return (SubclassOptionalData & FastMathFlags::AllowReciprocal) != 0;
305 }
306
307 /// Test if this operation can be floating-point contracted (FMA).
308 bool hasAllowContract() const {
309 return (SubclassOptionalData & FastMathFlags::AllowContract) != 0;
310 }
311
312 /// Test if this operation allows approximations of math library functions or
313 /// intrinsics.
314 bool hasApproxFunc() const {
315 return (SubclassOptionalData & FastMathFlags::ApproxFunc) != 0;
316 }
317
318 /// Convenience function for getting all the fast-math flags
320 return FastMathFlags(SubclassOptionalData);
321 }
322
323 /// Get the maximum error permitted by this operation in ULPs. An accuracy of
324 /// 0.0 means that the operation should be performed with the default
325 /// precision.
326 float getFPAccuracy() const;
327
328 static bool classof(const Value *V) {
329 unsigned Opcode;
330 if (auto *I = dyn_cast<Instruction>(V))
331 Opcode = I->getOpcode();
332 else if (auto *CE = dyn_cast<ConstantExpr>(V))
333 Opcode = CE->getOpcode();
334 else
335 return false;
336
337 switch (Opcode) {
338 case Instruction::FNeg:
339 case Instruction::FAdd:
340 case Instruction::FSub:
341 case Instruction::FMul:
342 case Instruction::FDiv:
343 case Instruction::FRem:
344 // FIXME: To clean up and correct the semantics of fast-math-flags, FCmp
345 // should not be treated as a math op, but the other opcodes should.
346 // This would make things consistent with Select/PHI (FP value type
347 // determines whether they are math ops and, therefore, capable of
348 // having fast-math-flags).
349 case Instruction::FCmp:
350 return true;
351 case Instruction::PHI:
352 case Instruction::Select:
353 case Instruction::Call: {
354 Type *Ty = V->getType();
355 while (ArrayType *ArrTy = dyn_cast<ArrayType>(Ty))
356 Ty = ArrTy->getElementType();
357 return Ty->isFPOrFPVectorTy();
358 }
359 default:
360 return false;
361 }
362 }
363};
364
365/// A helper template for defining operators for individual opcodes.
366template<typename SuperClass, unsigned Opc>
368public:
369 static bool classof(const Instruction *I) {
370 return I->getOpcode() == Opc;
371 }
372 static bool classof(const ConstantExpr *CE) {
373 return CE->getOpcode() == Opc;
374 }
375 static bool classof(const Value *V) {
376 return (isa<Instruction>(V) && classof(cast<Instruction>(V))) ||
377 (isa<ConstantExpr>(V) && classof(cast<ConstantExpr>(V)));
378 }
379};
380
382 : public ConcreteOperator<OverflowingBinaryOperator, Instruction::Add> {
383};
385 : public ConcreteOperator<OverflowingBinaryOperator, Instruction::Sub> {
386};
388 : public ConcreteOperator<OverflowingBinaryOperator, Instruction::Mul> {
389};
391 : public ConcreteOperator<OverflowingBinaryOperator, Instruction::Shl> {
392};
393
395 : public ConcreteOperator<PossiblyExactOperator, Instruction::AShr> {
396};
398 : public ConcreteOperator<PossiblyExactOperator, Instruction::LShr> {
399};
400
402 : public ConcreteOperator<Operator, Instruction::GetElementPtr> {
403 friend class GetElementPtrInst;
404 friend class ConstantExpr;
405
406 enum {
407 IsInBounds = (1 << 0),
408 };
409
410 void setIsInBounds(bool B) {
412 (SubclassOptionalData & ~IsInBounds) | (B * IsInBounds);
413 }
414
415public:
416 /// Transparently provide more efficient getOperand methods.
418
419 /// Test whether this is an inbounds GEP, as defined by LangRef.html.
420 bool isInBounds() const {
421 return SubclassOptionalData & IsInBounds;
422 }
423
424 /// Returns the offset of the index with an inrange attachment, or
425 /// std::nullopt if none.
426 std::optional<ConstantRange> getInRange() const;
427
428 inline op_iterator idx_begin() { return op_begin()+1; }
429 inline const_op_iterator idx_begin() const { return op_begin()+1; }
430 inline op_iterator idx_end() { return op_end(); }
431 inline const_op_iterator idx_end() const { return op_end(); }
432
434 return make_range(idx_begin(), idx_end());
435 }
436
438 return make_range(idx_begin(), idx_end());
439 }
440
442 return getOperand(0);
443 }
444 const Value *getPointerOperand() const {
445 return getOperand(0);
446 }
447 static unsigned getPointerOperandIndex() {
448 return 0U; // get index for modifying correct operand
449 }
450
451 /// Method to return the pointer operand as a PointerType.
453 return getPointerOperand()->getType();
454 }
455
456 Type *getSourceElementType() const;
457 Type *getResultElementType() const;
458
459 /// Method to return the address space of the pointer operand.
460 unsigned getPointerAddressSpace() const {
462 }
463
464 unsigned getNumIndices() const { // Note: always non-negative
465 return getNumOperands() - 1;
466 }
467
468 bool hasIndices() const {
469 return getNumOperands() > 1;
470 }
471
472 /// Return true if all of the indices of this GEP are zeros.
473 /// If so, the result pointer and the first operand have the same
474 /// value, just potentially different types.
475 bool hasAllZeroIndices() const {
476 for (const_op_iterator I = idx_begin(), E = idx_end(); I != E; ++I) {
477 if (ConstantInt *C = dyn_cast<ConstantInt>(I))
478 if (C->isZero())
479 continue;
480 return false;
481 }
482 return true;
483 }
484
485 /// Return true if all of the indices of this GEP are constant integers.
486 /// If so, the result pointer and the first operand have
487 /// a constant offset between them.
489 for (const_op_iterator I = idx_begin(), E = idx_end(); I != E; ++I) {
490 if (!isa<ConstantInt>(I))
491 return false;
492 }
493 return true;
494 }
495
496 unsigned countNonConstantIndices() const {
497 return count_if(indices(), [](const Use& use) {
498 return !isa<ConstantInt>(*use);
499 });
500 }
501
502 /// Compute the maximum alignment that this GEP is garranteed to preserve.
504
505 /// Accumulate the constant address offset of this GEP if possible.
506 ///
507 /// This routine accepts an APInt into which it will try to accumulate the
508 /// constant offset of this GEP.
509 ///
510 /// If \p ExternalAnalysis is provided it will be used to calculate a offset
511 /// when a operand of GEP is not constant.
512 /// For example, for a value \p ExternalAnalysis might try to calculate a
513 /// lower bound. If \p ExternalAnalysis is successful, it should return true.
514 ///
515 /// If the \p ExternalAnalysis returns false or the value returned by \p
516 /// ExternalAnalysis results in a overflow/underflow, this routine returns
517 /// false and the value of the offset APInt is undefined (it is *not*
518 /// preserved!).
519 ///
520 /// The APInt passed into this routine must be at exactly as wide as the
521 /// IntPtr type for the address space of the base GEP pointer.
523 const DataLayout &DL, APInt &Offset,
524 function_ref<bool(Value &, APInt &)> ExternalAnalysis = nullptr) const;
525
526 static bool accumulateConstantOffset(
527 Type *SourceType, ArrayRef<const Value *> Index, const DataLayout &DL,
528 APInt &Offset,
529 function_ref<bool(Value &, APInt &)> ExternalAnalysis = nullptr);
530
531 /// Collect the offset of this GEP as a map of Values to their associated
532 /// APInt multipliers, as well as a total Constant Offset.
533 bool collectOffset(const DataLayout &DL, unsigned BitWidth,
534 MapVector<Value *, APInt> &VariableOffsets,
535 APInt &ConstantOffset) const;
536};
537
538template <>
540 : public VariadicOperandTraits<GEPOperator, 1> {};
541
543
545 : public ConcreteOperator<Operator, Instruction::PtrToInt> {
546 friend class PtrToInt;
547 friend class ConstantExpr;
548
549public:
550 /// Transparently provide more efficient getOperand methods.
552
554 return getOperand(0);
555 }
556 const Value *getPointerOperand() const {
557 return getOperand(0);
558 }
559
560 static unsigned getPointerOperandIndex() {
561 return 0U; // get index for modifying correct operand
562 }
563
564 /// Method to return the pointer operand as a PointerType.
566 return getPointerOperand()->getType();
567 }
568
569 /// Method to return the address space of the pointer operand.
570 unsigned getPointerAddressSpace() const {
571 return cast<PointerType>(getPointerOperandType())->getAddressSpace();
572 }
573};
574
575template <>
577 : public FixedNumOperandTraits<PtrToIntOperator, 1> {};
578
580
582 : public ConcreteOperator<Operator, Instruction::BitCast> {
583 friend class BitCastInst;
584 friend class ConstantExpr;
585
586public:
587 /// Transparently provide more efficient getOperand methods.
589
590 Type *getSrcTy() const {
591 return getOperand(0)->getType();
592 }
593
594 Type *getDestTy() const {
595 return getType();
596 }
597};
598
599template <>
601 : public FixedNumOperandTraits<BitCastOperator, 1> {};
602
604
606 : public ConcreteOperator<Operator, Instruction::AddrSpaceCast> {
607 friend class AddrSpaceCastInst;
608 friend class ConstantExpr;
609
610public:
611 /// Transparently provide more efficient getOperand methods.
613
614 Value *getPointerOperand() { return getOperand(0); }
615
616 const Value *getPointerOperand() const { return getOperand(0); }
617
618 unsigned getSrcAddressSpace() const {
620 }
621
622 unsigned getDestAddressSpace() const {
623 return getType()->getPointerAddressSpace();
624 }
625};
626
627template <>
629 : public FixedNumOperandTraits<AddrSpaceCastOperator, 1> {};
630
632
633} // end namespace llvm
634
635#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:76
This class represents a conversion between pointers from one address space to another.
const Value * getPointerOperand() const
Definition: Operator.h:616
unsigned getDestAddressSpace() const
Definition: Operator.h:622
DECLARE_TRANSPARENT_OPERAND_ACCESSORS(Value)
Transparently provide more efficient getOperand methods.
unsigned getSrcAddressSpace() const
Definition: Operator.h:618
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:594
DECLARE_TRANSPARENT_OPERAND_ACCESSORS(Value)
Transparently provide more efficient getOperand methods.
Type * getSrcTy() const
Definition: Operator.h:590
A helper template for defining operators for individual opcodes.
Definition: Operator.h:367
static bool classof(const Value *V)
Definition: Operator.h:375
static bool classof(const ConstantExpr *CE)
Definition: Operator.h:372
static bool classof(const Instruction *I)
Definition: Operator.h:369
A constant value that is initialized with an expression using other constant values.
Definition: Constants.h:1017
This is the shared class of boolean and integer constants.
Definition: Constants.h:80
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:201
bool hasAllowReassoc() const
Test if this operation may be simplified with reassociative transforms.
Definition: Operator.h:283
bool isFast() const
Test if this operation allows all non-strict floating-point transforms.
Definition: Operator.h:272
static bool classof(const Value *V)
Definition: Operator.h:328
bool hasNoNaNs() const
Test if this operation's arguments and results are assumed not-NaN.
Definition: Operator.h:288
FastMathFlags getFastMathFlags() const
Convenience function for getting all the fast-math flags.
Definition: Operator.h:319
bool hasAllowReciprocal() const
Test if this operation can use reciprocal multiply instead of division.
Definition: Operator.h:303
bool hasNoSignedZeros() const
Test if this operation can ignore the sign of zero.
Definition: Operator.h:298
bool hasAllowContract() const
Test if this operation can be floating-point contracted (FMA).
Definition: Operator.h:308
bool hasNoInfs() const
Test if this operation's arguments and results are assumed not-infinite.
Definition: Operator.h:293
bool hasApproxFunc() const
Test if this operation allows approximations of math library functions or intrinsics.
Definition: Operator.h:314
Convenience struct for specifying and reasoning about fast-math flags.
Definition: FMF.h:20
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:201
const_op_iterator idx_end() const
Definition: Operator.h:431
const Value * getPointerOperand() const
Definition: Operator.h:444
const_op_iterator idx_begin() const
Definition: Operator.h:429
bool isInBounds() const
Test whether this is an inbounds GEP, as defined by LangRef.html.
Definition: Operator.h:420
Type * getPointerOperandType() const
Method to return the pointer operand as a PointerType.
Definition: Operator.h:452
unsigned getNumIndices() const
Definition: Operator.h:464
std::optional< ConstantRange > getInRange() const
Returns the offset of the index with an inrange attachment, or std::nullopt if none.
Definition: Operator.cpp:79
unsigned countNonConstantIndices() const
Definition: Operator.h:496
Type * getSourceElementType() const
Definition: Operator.cpp:67
Type * getResultElementType() const
Definition: Operator.cpp:73
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:110
bool hasAllZeroIndices() const
Return true if all of the indices of this GEP are zeros.
Definition: Operator.h:475
op_iterator idx_end()
Definition: Operator.h:430
DECLARE_TRANSPARENT_OPERAND_ACCESSORS(Value)
Transparently provide more efficient getOperand methods.
op_iterator idx_begin()
Definition: Operator.h:428
Value * getPointerOperand()
Definition: Operator.h:441
bool hasAllConstantIndices() const
Return true if all of the indices of this GEP are constant integers.
Definition: Operator.h:488
iterator_range< op_iterator > indices()
Definition: Operator.h:433
bool hasIndices() const
Definition: Operator.h:468
iterator_range< const_op_iterator > indices() const
Definition: Operator.h:437
Align getMaxPreservedAlignment(const DataLayout &DL) const
Compute the maximum alignment that this GEP is garranteed to preserve.
Definition: Operator.cpp:85
unsigned getPointerAddressSpace() const
Method to return the address space of the pointer operand.
Definition: Operator.h:460
static unsigned getPointerOperandIndex()
Definition: Operator.h:447
an instruction for type-safe pointer arithmetic to access elements of arrays and structs
Definition: Instructions.h:973
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:31
static bool classof(const ConstantExpr *)
Definition: Operator.h:58
bool hasPoisonGeneratingAnnotations() const
Return true if this operator has poison-generating flags, return attributes or metadata.
Definition: Operator.cpp:59
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:57
Operator()=delete
unsigned getOpcode() const
Return the opcode for this Instruction or ConstantExpr.
Definition: Operator.h:41
~Operator()=delete
static bool classof(const Value *V)
Definition: Operator.h:59
static unsigned getOpcode(const Value *V)
If V is an Instruction or ConstantExpr, return its opcode.
Definition: Operator.h:49
Utility class for integer operators which may exhibit overflow - Add, Sub, Mul, and Shl.
Definition: Operator.h:76
static bool classof(const Value *V)
Definition: Operator.h:137
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:109
unsigned getNoWrapKind() const
Returns the no-wrap kind of the operation.
Definition: Operator.h:114
bool hasNoUnsignedWrap() const
Test whether this operation is known to never undergo unsigned overflow, aka the nuw property.
Definition: Operator.h:103
static bool classof(const ConstantExpr *CE)
Definition: Operator.h:131
static bool classof(const Instruction *I)
Definition: Operator.h:125
A udiv or sdiv instruction, which can be marked as "exact", indicating that no bits are destroyed.
Definition: Operator.h:151
static bool classof(const ConstantExpr *CE)
Definition: Operator.h:181
bool isExact() const
Test whether this division is known to be exact, with zero remainder.
Definition: Operator.h:170
DECLARE_TRANSPARENT_OPERAND_ACCESSORS(Value)
Transparently provide more efficient getOperand methods.
static bool isPossiblyExactOpcode(unsigned OpC)
Definition: Operator.h:174
static bool classof(const Value *V)
Definition: Operator.h:187
static bool classof(const Instruction *I)
Definition: Operator.h:184
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:565
static unsigned getPointerOperandIndex()
Definition: Operator.h:560
unsigned getPointerAddressSpace() const
Method to return the address space of the pointer operand.
Definition: Operator.h:570
const Value * getPointerOperand() const
Definition: Operator.h:556
Value * getPointerOperand()
Definition: Operator.h:553
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