LLVM 23.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"
26#include <cstddef>
27#include <optional>
28
29namespace llvm {
30
31/// This is a utility class that provides an abstraction for the common
32/// functionality between Instructions and ConstantExprs.
33class Operator : public User {
34public:
35 // The Operator class is intended to be used as a utility, and is never itself
36 // instantiated.
37 Operator() = delete;
38 ~Operator() = delete;
39
40 void *operator new(size_t s) = delete;
41
42 /// Return the opcode for this Instruction or ConstantExpr.
43 unsigned getOpcode() const {
44 if (const Instruction *I = dyn_cast<Instruction>(this))
45 return I->getOpcode();
46 return cast<ConstantExpr>(this)->getOpcode();
47 }
48
49 /// If V is an Instruction or ConstantExpr, return its opcode.
50 /// Otherwise return UserOp1.
51 static unsigned getOpcode(const Value *V) {
52 if (const Instruction *I = dyn_cast<Instruction>(V))
53 return I->getOpcode();
54 if (const ConstantExpr *CE = dyn_cast<ConstantExpr>(V))
55 return CE->getOpcode();
56 return Instruction::UserOp1;
57 }
58
59 static bool classof(const Instruction *) { return true; }
60 static bool classof(const ConstantExpr *) { return true; }
61 static bool classof(const Value *V) {
62 return isa<Instruction>(V) || isa<ConstantExpr>(V);
63 }
64
65 /// Return true if this operator has flags which may cause this operator
66 /// to evaluate to poison despite having non-poison inputs.
68
69 /// Return true if this operator has poison-generating flags,
70 /// return attributes or metadata. The latter two is only possible for
71 /// instructions.
73};
74
75/// Utility class for integer operators which may exhibit overflow - Add, Sub,
76/// Mul, and Shl. It does not include SDiv, despite that operator having the
77/// potential for overflow.
79public:
80 enum {
82 NoUnsignedWrap = (1 << 0),
83 NoSignedWrap = (1 << 1)
84 };
85
86private:
87 friend class Instruction;
88 friend class ConstantExpr;
89
90 void setHasNoUnsignedWrap(bool B) {
91 assert(isa<Instruction>(this) && "cannot modify ConstantExpr");
94 }
95 void setHasNoSignedWrap(bool B) {
96 assert(isa<Instruction>(this) && "cannot modify ConstantExpr");
98 (SubclassOptionalData & ~NoSignedWrap) | (B * NoSignedWrap);
99 }
100
101public:
102 /// Transparently provide more efficient getOperand methods.
104
105 /// Test whether this operation is known to never
106 /// undergo unsigned overflow, aka the nuw property.
107 bool hasNoUnsignedWrap() const {
109 }
110
111 /// Test whether this operation is known to never
112 /// undergo signed overflow, aka the nsw property.
113 bool hasNoSignedWrap() const {
114 return (SubclassOptionalData & NoSignedWrap) != 0;
115 }
116
117 /// Returns the no-wrap kind of the operation.
118 unsigned getNoWrapKind() const {
119 unsigned NoWrapKind = 0;
120 if (hasNoUnsignedWrap())
121 NoWrapKind |= NoUnsignedWrap;
122
123 if (hasNoSignedWrap())
124 NoWrapKind |= NoSignedWrap;
125
126 return NoWrapKind;
127 }
128
129 /// Return true if the instruction is commutative
131
132 static bool classof(const Instruction *I) {
133 return I->getOpcode() == Instruction::Add ||
134 I->getOpcode() == Instruction::Sub ||
135 I->getOpcode() == Instruction::Mul ||
136 I->getOpcode() == Instruction::Shl;
137 }
138 static bool classof(const ConstantExpr *CE) {
139 return CE->getOpcode() == Instruction::Add ||
140 CE->getOpcode() == Instruction::Sub;
141 }
142 static bool classof(const Value *V) {
143 return (isa<Instruction>(V) && classof(cast<Instruction>(V))) ||
145 }
146};
147
148template <>
150 : public FixedNumOperandTraits<OverflowingBinaryOperator, 2> {};
151
153
154/// A udiv, sdiv, lshr, or ashr instruction, which can be marked as "exact",
155/// indicating that no bits are destroyed.
157public:
158 enum {
159 IsExact = (1 << 0)
160 };
161
162private:
163 friend class Instruction;
164 friend class ConstantExpr;
165
166 void setIsExact(bool B) {
168 }
169
170public:
171 /// Transparently provide more efficient getOperand methods.
173
174 /// Test whether this division is known to be exact, with zero remainder.
175 bool isExact() const {
177 }
178
179 static bool isPossiblyExactOpcode(unsigned OpC) {
180 return OpC == Instruction::SDiv ||
181 OpC == Instruction::UDiv ||
182 OpC == Instruction::AShr ||
183 OpC == Instruction::LShr;
184 }
185
186 static bool classof(const Instruction *I) {
187 return isPossiblyExactOpcode(I->getOpcode());
188 }
189 static bool classof(const Value *V) {
190 return (isa<Instruction>(V) && classof(cast<Instruction>(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 LLVM_ABI LLVM_READONLY FastMathFlags &getFastMathFlagsImpl();
207
208 /// 'Fast' means all bits are set.
209 void setFast(bool B) {
210 setHasAllowReassoc(B);
211 setHasNoNaNs(B);
212 setHasNoInfs(B);
213 setHasNoSignedZeros(B);
214 setHasAllowReciprocal(B);
215 setHasAllowContract(B);
216 setHasApproxFunc(B);
217 }
218
219 void setHasAllowReassoc(bool B) { getFastMathFlagsImpl().setAllowReassoc(B); }
220
221 void setHasNoNaNs(bool B) { getFastMathFlagsImpl().setNoNaNs(B); }
222
223 void setHasNoInfs(bool B) { getFastMathFlagsImpl().setNoInfs(B); }
224
225 void setHasNoSignedZeros(bool B) {
226 getFastMathFlagsImpl().setNoSignedZeros(B);
227 }
228
229 void setHasAllowReciprocal(bool B) {
230 getFastMathFlagsImpl().setAllowReciprocal(B);
231 }
232
233 void setHasAllowContract(bool B) {
234 getFastMathFlagsImpl().setAllowContract(B);
235 }
236
237 void setHasApproxFunc(bool B) { getFastMathFlagsImpl().setApproxFunc(B); }
238
239 /// Convenience function for setting multiple fast-math flags.
240 /// FMF is a mask of the bits to set.
241 void setFastMathFlags(FastMathFlags FMF) { getFastMathFlagsImpl() |= FMF; }
242
243 /// Convenience function for copying all fast-math flags.
244 /// All values in FMF are transferred to this operator.
245 void copyFastMathFlags(FastMathFlags FMF) { getFastMathFlagsImpl() = FMF; }
246
247 /// Returns true if `Ty` is composed of a single kind of float-poing type
248 /// (possibly repeated within an aggregate).
249 static bool isComposedOfHomogeneousFloatingPointTypes(Type *Ty) {
250 if (auto *StructTy = dyn_cast<StructType>(Ty)) {
251 if (!StructTy->isLiteral() || !StructTy->containsHomogeneousTypes())
252 return false;
253 Ty = StructTy->elements().front();
254 } else if (auto *ArrayTy = dyn_cast<ArrayType>(Ty)) {
255 do {
256 Ty = ArrayTy->getElementType();
257 } while ((ArrayTy = dyn_cast<ArrayType>(Ty)) != nullptr);
258 }
259 return Ty->isFPOrFPVectorTy();
260 };
261
262public:
263 /// Test if this operation allows all non-strict floating-point transforms.
264 bool isFast() const { return getFastMathFlags().isFast(); }
265
266 /// Test if this operation may be simplified with reassociative transforms.
267 bool hasAllowReassoc() const { return getFastMathFlags().allowReassoc(); }
268
269 /// Test if this operation's arguments and results are assumed not-NaN.
270 bool hasNoNaNs() const { return getFastMathFlags().noNaNs(); }
271
272 /// Test if this operation's arguments and results are assumed not-infinite.
273 bool hasNoInfs() const { return getFastMathFlags().noInfs(); }
274
275 /// Test if this operation can ignore the sign of zero.
276 bool hasNoSignedZeros() const { return getFastMathFlags().noSignedZeros(); }
277
278 /// Test if this operation can use reciprocal multiply instead of division.
279 bool hasAllowReciprocal() const {
280 return getFastMathFlags().allowReciprocal();
281 }
282
283 /// Test if this operation can be floating-point contracted (FMA).
284 bool hasAllowContract() const { return getFastMathFlags().allowContract(); }
285
286 /// Test if this operation allows approximations of math library functions or
287 /// intrinsics.
288 bool hasApproxFunc() const { return getFastMathFlags().approxFunc(); }
289
290 /// Convenience function for getting all the fast-math flags
292 return const_cast<FPMathOperator *>(this)->getFastMathFlagsImpl();
293 }
294
295 /// Get the maximum error permitted by this operation in ULPs. An accuracy of
296 /// 0.0 means that the operation should be performed with the default
297 /// precision.
298 LLVM_ABI float getFPAccuracy() const;
299
300 /// Returns true if `Ty` is a supported floating-point type for phi, select,
301 /// or call FPMathOperators.
303 return Ty->isFPOrFPVectorTy() ||
304 isComposedOfHomogeneousFloatingPointTypes(Ty);
305 }
306
307 static bool classof(const Value *V) {
308 unsigned Opcode;
309 if (auto *I = dyn_cast<Instruction>(V))
310 Opcode = I->getOpcode();
311 else
312 return false;
313
314 switch (Opcode) {
315 case Instruction::FNeg:
316 case Instruction::FAdd:
317 case Instruction::FSub:
318 case Instruction::FMul:
319 case Instruction::FDiv:
320 case Instruction::FRem:
321 case Instruction::FPTrunc:
322 case Instruction::FPExt:
323 case Instruction::UIToFP:
324 case Instruction::SIToFP:
325 // FIXME: To clean up and correct the semantics of fast-math-flags, FCmp
326 // should not be treated as a math op, but the other opcodes should.
327 // This would make things consistent with Select/PHI (FP value type
328 // determines whether they are math ops and, therefore, capable of
329 // having fast-math-flags).
330 case Instruction::FCmp:
331 return true;
332 case Instruction::PHI:
333 case Instruction::Select:
334 case Instruction::Call: {
335 return isSupportedFloatingPointType(V->getType());
336 }
337 default:
338 return false;
339 }
340 }
341};
342
343/// A helper template for defining operators for individual opcodes.
344template<typename SuperClass, unsigned Opc>
346public:
347 static bool classof(const Instruction *I) {
348 return I->getOpcode() == Opc;
349 }
350 static bool classof(const ConstantExpr *CE) {
351 return CE->getOpcode() == Opc;
352 }
353 static bool classof(const Value *V) {
354 return (isa<Instruction>(V) && classof(cast<Instruction>(V))) ||
356 }
357};
358
360 : public ConcreteOperator<OverflowingBinaryOperator, Instruction::Add> {
361};
363 : public ConcreteOperator<OverflowingBinaryOperator, Instruction::Sub> {
364};
366 : public ConcreteOperator<OverflowingBinaryOperator, Instruction::Mul> {
367};
369 : public ConcreteOperator<OverflowingBinaryOperator, Instruction::Shl> {
370};
371
373 : public ConcreteOperator<PossiblyExactOperator, Instruction::AShr> {
374};
376 : public ConcreteOperator<PossiblyExactOperator, Instruction::LShr> {
377};
378
380 : public ConcreteOperator<Operator, Instruction::GetElementPtr> {
381public:
382 /// Transparently provide more efficient getOperand methods.
384
388
389 /// Test whether this is an inbounds GEP, as defined by LangRef.html.
390 bool isInBounds() const { return getNoWrapFlags().isInBounds(); }
391
395
396 bool hasNoUnsignedWrap() const {
398 }
399
400 /// Returns the offset of the index with an inrange attachment, or
401 /// std::nullopt if none.
402 LLVM_ABI std::optional<ConstantRange> getInRange() const;
403
404 inline op_iterator idx_begin() { return op_begin()+1; }
405 inline const_op_iterator idx_begin() const { return op_begin()+1; }
406 inline op_iterator idx_end() { return op_end(); }
407 inline const_op_iterator idx_end() const { return op_end(); }
408
412
414 return make_range(idx_begin(), idx_end());
415 }
416
418 return getOperand(0);
419 }
420 const Value *getPointerOperand() const {
421 return getOperand(0);
422 }
423 static unsigned getPointerOperandIndex() {
424 return 0U; // get index for modifying correct operand
425 }
426
427 /// Method to return the pointer operand as a PointerType.
429 return getPointerOperand()->getType();
430 }
431
434
435 /// Method to return the address space of the pointer operand.
436 unsigned getPointerAddressSpace() const {
438 }
439
440 unsigned getNumIndices() const { // Note: always non-negative
441 return getNumOperands() - 1;
442 }
443
444 bool hasIndices() const {
445 return getNumOperands() > 1;
446 }
447
448 /// Return true if all of the indices of this GEP are zeros.
449 /// If so, the result pointer and the first operand have the same
450 /// value, just potentially different types.
451 bool hasAllZeroIndices() const {
452 for (const_op_iterator I = idx_begin(), E = idx_end(); I != E; ++I) {
454 if (C->isZero())
455 continue;
456 return false;
457 }
458 return true;
459 }
460
461 /// Return true if all of the indices of this GEP are constant integers.
462 /// If so, the result pointer and the first operand have
463 /// a constant offset between them.
465 for (const_op_iterator I = idx_begin(), E = idx_end(); I != E; ++I) {
466 if (!isa<ConstantInt>(I))
467 return false;
468 }
469 return true;
470 }
471
472 unsigned countNonConstantIndices() const {
473 return count_if(indices(), [](const Use& use) {
474 return !isa<ConstantInt>(*use);
475 });
476 }
477
478 /// Compute the maximum alignment that this GEP is garranteed to preserve.
480
481 /// Accumulate the constant address offset of this GEP if possible.
482 ///
483 /// This routine accepts an APInt into which it will try to accumulate the
484 /// constant offset of this GEP.
485 ///
486 /// If \p ExternalAnalysis is provided it will be used to calculate a offset
487 /// when a operand of GEP is not constant.
488 /// For example, for a value \p ExternalAnalysis might try to calculate a
489 /// lower bound. If \p ExternalAnalysis is successful, it should return true.
490 ///
491 /// If the \p ExternalAnalysis returns false or the value returned by \p
492 /// ExternalAnalysis results in a overflow/underflow, this routine returns
493 /// false and the value of the offset APInt is undefined (it is *not*
494 /// preserved!).
495 ///
496 /// The APInt passed into this routine must be at exactly as wide as the
497 /// IntPtr type for the address space of the base GEP pointer.
499 const DataLayout &DL, APInt &Offset,
500 function_ref<bool(Value &, APInt &)> ExternalAnalysis = nullptr) const;
501
503 Type *SourceType, ArrayRef<const Value *> Index, const DataLayout &DL,
504 APInt &Offset,
505 function_ref<bool(Value &, APInt &)> ExternalAnalysis = nullptr);
506
507 /// Collect the offset of this GEP as a map of Values to their associated
508 /// APInt multipliers, as well as a total Constant Offset.
509 LLVM_ABI bool
510 collectOffset(const DataLayout &DL, unsigned BitWidth,
511 SmallMapVector<Value *, APInt, 4> &VariableOffsets,
512 APInt &ConstantOffset) const;
513};
514
515template <>
516struct OperandTraits<GEPOperator> : public VariadicOperandTraits<GEPOperator> {
517};
518
520
523 friend class PtrToInt;
524 friend class ConstantExpr;
525
526public:
527 /// Transparently provide more efficient getOperand methods.
529
531 return getOperand(0);
532 }
533 const Value *getPointerOperand() const {
534 return getOperand(0);
535 }
536
537 static unsigned getPointerOperandIndex() {
538 return 0U; // get index for modifying correct operand
539 }
540
541 /// Method to return the pointer operand as a PointerType.
543 return getPointerOperand()->getType();
544 }
545
546 /// Method to return the address space of the pointer operand.
547 unsigned getPointerAddressSpace() const {
548 return cast<PointerType>(getPointerOperandType())->getAddressSpace();
549 }
550};
551
552template <>
554 : public FixedNumOperandTraits<PtrToIntOperator, 1> {};
555
557
560 friend class PtrToAddr;
561 friend class ConstantExpr;
562
563public:
564 /// Transparently provide more efficient getOperand methods.
566
568 const Value *getPointerOperand() const { return getOperand(0); }
569
570 static unsigned getPointerOperandIndex() {
571 return 0U; // get index for modifying correct operand
572 }
573
574 /// Method to return the pointer operand as a PointerType.
576
577 /// Method to return the address space of the pointer operand.
578 unsigned getPointerAddressSpace() const {
579 return cast<PointerType>(getPointerOperandType())->getAddressSpace();
580 }
581};
582
583template <>
585 : public FixedNumOperandTraits<PtrToAddrOperator, 1> {};
586
588
590 : public ConcreteOperator<Operator, Instruction::BitCast> {
591 friend class BitCastInst;
592 friend class ConstantExpr;
593
594public:
595 /// Transparently provide more efficient getOperand methods.
597
598 Type *getSrcTy() const {
599 return getOperand(0)->getType();
600 }
601
602 Type *getDestTy() const {
603 return getType();
604 }
605};
606
607template <>
609 : public FixedNumOperandTraits<BitCastOperator, 1> {};
610
612
614 : public ConcreteOperator<Operator, Instruction::AddrSpaceCast> {
615 friend class AddrSpaceCastInst;
616 friend class ConstantExpr;
617
618public:
619 /// Transparently provide more efficient getOperand methods.
621
623
624 const Value *getPointerOperand() const { return getOperand(0); }
625
626 unsigned getSrcAddressSpace() const {
628 }
629
630 unsigned getDestAddressSpace() const {
631 return getType()->getPointerAddressSpace();
632 }
633};
634
635template <>
637 : public FixedNumOperandTraits<AddrSpaceCastOperator, 1> {};
638
640
641} // end namespace llvm
642
643#endif // LLVM_IR_OPERATOR_H
assert(UImm &&(UImm !=~static_cast< T >(0)) &&"Invalid immediate!")
MachineBasicBlock MachineBasicBlock::iterator DebugLoc DL
static GCRegistry::Add< CoreCLRGC > E("coreclr", "CoreCLR-compatible GC")
static GCRegistry::Add< OcamlGC > B("ocaml", "ocaml 3.10-compatible GC")
#define LLVM_ABI
Definition Compiler.h:213
#define LLVM_READONLY
Definition Compiler.h:322
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:57
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:39
Class for arbitrary precision integers.
Definition APInt.h:78
const Value * getPointerOperand() const
Definition Operator.h:624
friend class AddrSpaceCastInst
Definition Operator.h:615
unsigned getDestAddressSpace() const
Definition Operator.h:630
DECLARE_TRANSPARENT_OPERAND_ACCESSORS(Value)
Transparently provide more efficient getOperand methods.
unsigned getSrcAddressSpace() const
Definition Operator.h:626
Represent a constant reference to an array (0 or more elements consecutively in memory),...
Definition ArrayRef.h:40
Type * getDestTy() const
Definition Operator.h:602
friend class ConstantExpr
Definition Operator.h:592
DECLARE_TRANSPARENT_OPERAND_ACCESSORS(Value)
Transparently provide more efficient getOperand methods.
Type * getSrcTy() const
Definition Operator.h:598
friend class BitCastInst
Definition Operator.h:591
A helper template for defining operators for individual opcodes.
Definition Operator.h:345
static bool classof(const Value *V)
Definition Operator.h:353
static bool classof(const ConstantExpr *CE)
Definition Operator.h:350
static bool classof(const Instruction *I)
Definition Operator.h:347
A constant value that is initialized with an expression using other constant values.
Definition Constants.h:1310
This is the shared class of boolean and integer constants.
Definition Constants.h:87
A parsed version of the target data layout string in and methods for querying it.
Definition DataLayout.h:64
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:267
bool isFast() const
Test if this operation allows all non-strict floating-point transforms.
Definition Operator.h:264
static bool classof(const Value *V)
Definition Operator.h:307
bool hasNoNaNs() const
Test if this operation's arguments and results are assumed not-NaN.
Definition Operator.h:270
friend class Instruction
Iterator for Instructions in a `BasicBlock.
Definition Operator.h:204
FastMathFlags getFastMathFlags() const
Convenience function for getting all the fast-math flags.
Definition Operator.h:291
bool hasAllowReciprocal() const
Test if this operation can use reciprocal multiply instead of division.
Definition Operator.h:279
bool hasNoSignedZeros() const
Test if this operation can ignore the sign of zero.
Definition Operator.h:276
static bool isSupportedFloatingPointType(Type *Ty)
Returns true if Ty is a supported floating-point type for phi, select, or call FPMathOperators.
Definition Operator.h:302
bool hasAllowContract() const
Test if this operation can be floating-point contracted (FMA).
Definition Operator.h:284
bool hasNoInfs() const
Test if this operation's arguments and results are assumed not-infinite.
Definition Operator.h:273
bool hasApproxFunc() const
Test if this operation allows approximations of math library functions or intrinsics.
Definition Operator.h:288
Convenience struct for specifying and reasoning about fast-math flags.
Definition FMF.h:23
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:392
const_op_iterator idx_end() const
Definition Operator.h:407
const Value * getPointerOperand() const
Definition Operator.h:420
LLVM_ABI std::optional< ConstantRange > getInRange() const
Returns the offset of the index with an inrange attachment, or std::nullopt if none.
Definition Operator.cpp:94
const_op_iterator idx_begin() const
Definition Operator.h:405
LLVM_ABI bool collectOffset(const DataLayout &DL, unsigned BitWidth, SmallMapVector< Value *, APInt, 4 > &VariableOffsets, APInt &ConstantOffset) const
Collect the offset of this GEP as a map of Values to their associated APInt multipliers,...
Definition Operator.cpp:220
bool isInBounds() const
Test whether this is an inbounds GEP, as defined by LangRef.html.
Definition Operator.h:390
Type * getPointerOperandType() const
Method to return the pointer operand as a PointerType.
Definition Operator.h:428
unsigned getNumIndices() const
Definition Operator.h:440
unsigned countNonConstantIndices() const
Definition Operator.h:472
bool hasNoUnsignedWrap() const
Definition Operator.h:396
bool hasAllZeroIndices() const
Return true if all of the indices of this GEP are zeros.
Definition Operator.h:451
op_iterator idx_end()
Definition Operator.h:406
DECLARE_TRANSPARENT_OPERAND_ACCESSORS(Value)
Transparently provide more efficient getOperand methods.
LLVM_ABI Type * getResultElementType() const
Definition Operator.cpp:88
LLVM_ABI Type * getSourceElementType() const
Definition Operator.cpp:82
op_iterator idx_begin()
Definition Operator.h:404
Value * getPointerOperand()
Definition Operator.h:417
GEPNoWrapFlags getNoWrapFlags() const
Definition Operator.h:385
bool hasAllConstantIndices() const
Return true if all of the indices of this GEP are constant integers.
Definition Operator.h:464
LLVM_ABI Align getMaxPreservedAlignment(const DataLayout &DL) const
Compute the maximum alignment that this GEP is garranteed to preserve.
Definition Operator.cpp:100
iterator_range< op_iterator > indices()
Definition Operator.h:409
bool hasIndices() const
Definition Operator.h:444
iterator_range< const_op_iterator > indices() const
Definition Operator.h:413
LLVM_ABI 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:125
unsigned getPointerAddressSpace() const
Method to return the address space of the pointer operand.
Definition Operator.h:436
static unsigned getPointerOperandIndex()
Definition Operator.h:423
LLVM_ABI bool isCommutative() const LLVM_READONLY
Return true if the instruction is commutative:
This is a utility class that provides an abstraction for the common functionality between Instruction...
Definition Operator.h:33
static bool classof(const ConstantExpr *)
Definition Operator.h:60
static bool classof(const Instruction *)
Definition Operator.h:59
Operator()=delete
LLVM_ABI bool hasPoisonGeneratingFlags() const
Return true if this operator has flags which may cause this operator to evaluate to poison despite ha...
Definition Operator.cpp:23
unsigned getOpcode() const
Return the opcode for this Instruction or ConstantExpr.
Definition Operator.h:43
~Operator()=delete
static bool classof(const Value *V)
Definition Operator.h:61
static unsigned getOpcode(const Value *V)
If V is an Instruction or ConstantExpr, return its opcode.
Definition Operator.h:51
LLVM_ABI bool hasPoisonGeneratingAnnotations() const
Return true if this operator has poison-generating flags, return attributes or metadata.
Definition Operator.cpp:74
Utility class for integer operators which may exhibit overflow - Add, Sub, Mul, and Shl.
Definition Operator.h:78
static bool classof(const Value *V)
Definition Operator.h:142
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:113
unsigned getNoWrapKind() const
Returns the no-wrap kind of the operation.
Definition Operator.h:118
friend class Instruction
Iterator for Instructions in a `BasicBlock.
Definition Operator.h:87
bool hasNoUnsignedWrap() const
Test whether this operation is known to never undergo unsigned overflow, aka the nuw property.
Definition Operator.h:107
bool isCommutative() const
Return true if the instruction is commutative.
Definition Operator.h:130
static bool classof(const ConstantExpr *CE)
Definition Operator.h:138
static bool classof(const Instruction *I)
Definition Operator.h:132
A udiv, sdiv, lshr, or ashr instruction, which can be marked as "exact", indicating that no bits are ...
Definition Operator.h:156
bool isExact() const
Test whether this division is known to be exact, with zero remainder.
Definition Operator.h:175
DECLARE_TRANSPARENT_OPERAND_ACCESSORS(Value)
Transparently provide more efficient getOperand methods.
static bool isPossiblyExactOpcode(unsigned OpC)
Definition Operator.h:179
friend class Instruction
Iterator for Instructions in a `BasicBlock.
Definition Operator.h:163
static bool classof(const Value *V)
Definition Operator.h:189
static bool classof(const Instruction *I)
Definition Operator.h:186
static unsigned getPointerOperandIndex()
Definition Operator.h:570
Value * getPointerOperand()
Definition Operator.h:567
friend class PtrToAddr
Definition Operator.h:560
DECLARE_TRANSPARENT_OPERAND_ACCESSORS(Value)
Transparently provide more efficient getOperand methods.
friend class ConstantExpr
Definition Operator.h:561
Type * getPointerOperandType() const
Method to return the pointer operand as a PointerType.
Definition Operator.h:575
const Value * getPointerOperand() const
Definition Operator.h:568
unsigned getPointerAddressSpace() const
Method to return the address space of the pointer operand.
Definition Operator.h:578
DECLARE_TRANSPARENT_OPERAND_ACCESSORS(Value)
Transparently provide more efficient getOperand methods.
friend class ConstantExpr
Definition Operator.h:524
friend class PtrToInt
Definition Operator.h:523
Type * getPointerOperandType() const
Method to return the pointer operand as a PointerType.
Definition Operator.h:542
static unsigned getPointerOperandIndex()
Definition Operator.h:537
unsigned getPointerAddressSpace() const
Method to return the address space of the pointer operand.
Definition Operator.h:547
const Value * getPointerOperand() const
Definition Operator.h:533
Value * getPointerOperand()
Definition Operator.h:530
The instances of the Type class are immutable: once they are created, they are never changed.
Definition Type.h:46
LLVM_ABI unsigned getPointerAddressSpace() const
Get the address space of this pointer or pointer vector type.
A Use represents the edge between a Value definition and its users.
Definition Use.h:35
Use * op_iterator
Definition User.h:254
User(Type *ty, unsigned vty, AllocInfo AllocInfo)
Definition User.h:119
op_iterator op_begin()
Definition User.h:259
const Use * const_op_iterator
Definition User.h:255
Value * getOperand(unsigned i) const
Definition User.h:207
unsigned getNumOperands() const
Definition User.h:229
op_iterator op_end()
Definition User.h:261
LLVM Value Representation.
Definition Value.h:75
Type * getType() const
All values are typed, get the type of this value.
Definition Value.h:255
unsigned char SubclassOptionalData
Hold arbitary subclass data.
Definition Value.h:85
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.
@ Offset
Definition DWP.cpp:558
decltype(auto) dyn_cast(const From &Val)
dyn_cast<X> - Return the argument parameter cast to the specified type.
Definition Casting.h:643
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.
bool isa(const From &Val)
isa<X> - Return true if the parameter to the template is an instance of one of the template type argu...
Definition Casting.h:547
constexpr unsigned BitWidth
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:2018
decltype(auto) cast(const From &Val)
cast<X> - Return the argument parameter cast to the specified type.
Definition Casting.h:559
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...
Compile-time customization of User operands.
Definition User.h:42
A MapVector that performs no allocations if smaller than a certain size.
Definition MapVector.h:334
VariadicOperandTraits - determine the allocation regime of the Use array when it is a prefix to the U...