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 or metadata.
68 /// The latter is only possible for instructions.
70};
71
72/// Utility class for integer operators which may exhibit overflow - Add, Sub,
73/// Mul, and Shl. It does not include SDiv, despite that operator having the
74/// potential for overflow.
76public:
77 enum {
79 NoUnsignedWrap = (1 << 0),
80 NoSignedWrap = (1 << 1)
81 };
82
83private:
84 friend class Instruction;
85 friend class ConstantExpr;
86
87 void setHasNoUnsignedWrap(bool B) {
89 (SubclassOptionalData & ~NoUnsignedWrap) | (B * NoUnsignedWrap);
90 }
91 void setHasNoSignedWrap(bool B) {
93 (SubclassOptionalData & ~NoSignedWrap) | (B * NoSignedWrap);
94 }
95
96public:
97 /// Transparently provide more efficient getOperand methods.
99
100 /// Test whether this operation is known to never
101 /// undergo unsigned overflow, aka the nuw property.
102 bool hasNoUnsignedWrap() const {
104 }
105
106 /// Test whether this operation is known to never
107 /// undergo signed overflow, aka the nsw property.
108 bool hasNoSignedWrap() const {
109 return (SubclassOptionalData & NoSignedWrap) != 0;
110 }
111
112 /// Returns the no-wrap kind of the operation.
113 unsigned getNoWrapKind() const {
114 unsigned NoWrapKind = 0;
115 if (hasNoUnsignedWrap())
116 NoWrapKind |= NoUnsignedWrap;
117
118 if (hasNoSignedWrap())
119 NoWrapKind |= NoSignedWrap;
120
121 return NoWrapKind;
122 }
123
124 static bool classof(const Instruction *I) {
125 return I->getOpcode() == Instruction::Add ||
126 I->getOpcode() == Instruction::Sub ||
127 I->getOpcode() == Instruction::Mul ||
128 I->getOpcode() == Instruction::Shl;
129 }
130 static bool classof(const ConstantExpr *CE) {
131 return CE->getOpcode() == Instruction::Add ||
132 CE->getOpcode() == Instruction::Sub ||
133 CE->getOpcode() == Instruction::Mul ||
134 CE->getOpcode() == Instruction::Shl;
135 }
136 static bool classof(const Value *V) {
137 return (isa<Instruction>(V) && classof(cast<Instruction>(V))) ||
138 (isa<ConstantExpr>(V) && classof(cast<ConstantExpr>(V)));
139 }
140};
141
142template <>
144 : public FixedNumOperandTraits<OverflowingBinaryOperator, 2> {};
145
147
148/// A udiv or sdiv instruction, which can be marked as "exact",
149/// indicating that no bits are destroyed.
151public:
152 enum {
153 IsExact = (1 << 0)
154 };
155
156private:
157 friend class Instruction;
158 friend class ConstantExpr;
159
160 void setIsExact(bool B) {
161 SubclassOptionalData = (SubclassOptionalData & ~IsExact) | (B * IsExact);
162 }
163
164public:
165 /// Transparently provide more efficient getOperand methods.
167
168 /// Test whether this division is known to be exact, with zero remainder.
169 bool isExact() const {
170 return SubclassOptionalData & IsExact;
171 }
172
173 static bool isPossiblyExactOpcode(unsigned OpC) {
174 return OpC == Instruction::SDiv ||
175 OpC == Instruction::UDiv ||
176 OpC == Instruction::AShr ||
177 OpC == Instruction::LShr;
178 }
179
180 static bool classof(const ConstantExpr *CE) {
181 return isPossiblyExactOpcode(CE->getOpcode());
182 }
183 static bool classof(const Instruction *I) {
184 return isPossiblyExactOpcode(I->getOpcode());
185 }
186 static bool classof(const Value *V) {
187 return (isa<Instruction>(V) && classof(cast<Instruction>(V))) ||
188 (isa<ConstantExpr>(V) && classof(cast<ConstantExpr>(V)));
189 }
190};
191
192template <>
194 : public FixedNumOperandTraits<PossiblyExactOperator, 2> {};
195
197
198/// Utility class for floating point operations which can have
199/// information about relaxed accuracy requirements attached to them.
200class FPMathOperator : public Operator {
201private:
202 friend class Instruction;
203
204 /// 'Fast' means all bits are set.
205 void setFast(bool B) {
206 setHasAllowReassoc(B);
207 setHasNoNaNs(B);
208 setHasNoInfs(B);
209 setHasNoSignedZeros(B);
210 setHasAllowReciprocal(B);
211 setHasAllowContract(B);
212 setHasApproxFunc(B);
213 }
214
215 void setHasAllowReassoc(bool B) {
216 SubclassOptionalData =
217 (SubclassOptionalData & ~FastMathFlags::AllowReassoc) |
219 }
220
221 void setHasNoNaNs(bool B) {
222 SubclassOptionalData =
223 (SubclassOptionalData & ~FastMathFlags::NoNaNs) |
225 }
226
227 void setHasNoInfs(bool B) {
228 SubclassOptionalData =
229 (SubclassOptionalData & ~FastMathFlags::NoInfs) |
231 }
232
233 void setHasNoSignedZeros(bool B) {
234 SubclassOptionalData =
235 (SubclassOptionalData & ~FastMathFlags::NoSignedZeros) |
237 }
238
239 void setHasAllowReciprocal(bool B) {
240 SubclassOptionalData =
241 (SubclassOptionalData & ~FastMathFlags::AllowReciprocal) |
243 }
244
245 void setHasAllowContract(bool B) {
246 SubclassOptionalData =
247 (SubclassOptionalData & ~FastMathFlags::AllowContract) |
249 }
250
251 void setHasApproxFunc(bool B) {
252 SubclassOptionalData =
253 (SubclassOptionalData & ~FastMathFlags::ApproxFunc) |
255 }
256
257 /// Convenience function for setting multiple fast-math flags.
258 /// FMF is a mask of the bits to set.
259 void setFastMathFlags(FastMathFlags FMF) {
260 SubclassOptionalData |= FMF.Flags;
261 }
262
263 /// Convenience function for copying all fast-math flags.
264 /// All values in FMF are transferred to this operator.
265 void copyFastMathFlags(FastMathFlags FMF) {
266 SubclassOptionalData = FMF.Flags;
267 }
268
269public:
270 /// Test if this operation allows all non-strict floating-point transforms.
271 bool isFast() const {
272 return ((SubclassOptionalData & FastMathFlags::AllowReassoc) != 0 &&
273 (SubclassOptionalData & FastMathFlags::NoNaNs) != 0 &&
274 (SubclassOptionalData & FastMathFlags::NoInfs) != 0 &&
275 (SubclassOptionalData & FastMathFlags::NoSignedZeros) != 0 &&
276 (SubclassOptionalData & FastMathFlags::AllowReciprocal) != 0 &&
277 (SubclassOptionalData & FastMathFlags::AllowContract) != 0 &&
278 (SubclassOptionalData & FastMathFlags::ApproxFunc) != 0);
279 }
280
281 /// Test if this operation may be simplified with reassociative transforms.
282 bool hasAllowReassoc() const {
283 return (SubclassOptionalData & FastMathFlags::AllowReassoc) != 0;
284 }
285
286 /// Test if this operation's arguments and results are assumed not-NaN.
287 bool hasNoNaNs() const {
288 return (SubclassOptionalData & FastMathFlags::NoNaNs) != 0;
289 }
290
291 /// Test if this operation's arguments and results are assumed not-infinite.
292 bool hasNoInfs() const {
293 return (SubclassOptionalData & FastMathFlags::NoInfs) != 0;
294 }
295
296 /// Test if this operation can ignore the sign of zero.
297 bool hasNoSignedZeros() const {
298 return (SubclassOptionalData & FastMathFlags::NoSignedZeros) != 0;
299 }
300
301 /// Test if this operation can use reciprocal multiply instead of division.
302 bool hasAllowReciprocal() const {
303 return (SubclassOptionalData & FastMathFlags::AllowReciprocal) != 0;
304 }
305
306 /// Test if this operation can be floating-point contracted (FMA).
307 bool hasAllowContract() const {
308 return (SubclassOptionalData & FastMathFlags::AllowContract) != 0;
309 }
310
311 /// Test if this operation allows approximations of math library functions or
312 /// intrinsics.
313 bool hasApproxFunc() const {
314 return (SubclassOptionalData & FastMathFlags::ApproxFunc) != 0;
315 }
316
317 /// Convenience function for getting all the fast-math flags
319 return FastMathFlags(SubclassOptionalData);
320 }
321
322 /// Get the maximum error permitted by this operation in ULPs. An accuracy of
323 /// 0.0 means that the operation should be performed with the default
324 /// precision.
325 float getFPAccuracy() const;
326
327 static bool classof(const Value *V) {
328 unsigned Opcode;
329 if (auto *I = dyn_cast<Instruction>(V))
330 Opcode = I->getOpcode();
331 else if (auto *CE = dyn_cast<ConstantExpr>(V))
332 Opcode = CE->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> {
402 friend class GetElementPtrInst;
403 friend class ConstantExpr;
404
405 enum {
406 IsInBounds = (1 << 0),
407 // InRangeIndex: bits 1-6
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<unsigned> getInRangeIndex() const {
427 if (SubclassOptionalData >> 1 == 0)
428 return std::nullopt;
429 return (SubclassOptionalData >> 1) - 1;
430 }
431
432 inline op_iterator idx_begin() { return op_begin()+1; }
433 inline const_op_iterator idx_begin() const { return op_begin()+1; }
434 inline op_iterator idx_end() { return op_end(); }
435 inline const_op_iterator idx_end() const { return op_end(); }
436
438 return make_range(idx_begin(), idx_end());
439 }
440
442 return make_range(idx_begin(), idx_end());
443 }
444
446 return getOperand(0);
447 }
448 const Value *getPointerOperand() const {
449 return getOperand(0);
450 }
451 static unsigned getPointerOperandIndex() {
452 return 0U; // get index for modifying correct operand
453 }
454
455 /// Method to return the pointer operand as a PointerType.
457 return getPointerOperand()->getType();
458 }
459
460 Type *getSourceElementType() const;
461 Type *getResultElementType() const;
462
463 /// Method to return the address space of the pointer operand.
464 unsigned getPointerAddressSpace() const {
466 }
467
468 unsigned getNumIndices() const { // Note: always non-negative
469 return getNumOperands() - 1;
470 }
471
472 bool hasIndices() const {
473 return getNumOperands() > 1;
474 }
475
476 /// Return true if all of the indices of this GEP are zeros.
477 /// If so, the result pointer and the first operand have the same
478 /// value, just potentially different types.
479 bool hasAllZeroIndices() const {
480 for (const_op_iterator I = idx_begin(), E = idx_end(); I != E; ++I) {
481 if (ConstantInt *C = dyn_cast<ConstantInt>(I))
482 if (C->isZero())
483 continue;
484 return false;
485 }
486 return true;
487 }
488
489 /// Return true if all of the indices of this GEP are constant integers.
490 /// If so, the result pointer and the first operand have
491 /// a constant offset between them.
493 for (const_op_iterator I = idx_begin(), E = idx_end(); I != E; ++I) {
494 if (!isa<ConstantInt>(I))
495 return false;
496 }
497 return true;
498 }
499
500 unsigned countNonConstantIndices() const {
501 return count_if(indices(), [](const Use& use) {
502 return !isa<ConstantInt>(*use);
503 });
504 }
505
506 /// Compute the maximum alignment that this GEP is garranteed to preserve.
508
509 /// Accumulate the constant address offset of this GEP if possible.
510 ///
511 /// This routine accepts an APInt into which it will try to accumulate the
512 /// constant offset of this GEP.
513 ///
514 /// If \p ExternalAnalysis is provided it will be used to calculate a offset
515 /// when a operand of GEP is not constant.
516 /// For example, for a value \p ExternalAnalysis might try to calculate a
517 /// lower bound. If \p ExternalAnalysis is successful, it should return true.
518 ///
519 /// If the \p ExternalAnalysis returns false or the value returned by \p
520 /// ExternalAnalysis results in a overflow/underflow, this routine returns
521 /// false and the value of the offset APInt is undefined (it is *not*
522 /// preserved!).
523 ///
524 /// The APInt passed into this routine must be at exactly as wide as the
525 /// IntPtr type for the address space of the base GEP pointer.
527 const DataLayout &DL, APInt &Offset,
528 function_ref<bool(Value &, APInt &)> ExternalAnalysis = nullptr) const;
529
530 static bool accumulateConstantOffset(
531 Type *SourceType, ArrayRef<const Value *> Index, const DataLayout &DL,
532 APInt &Offset,
533 function_ref<bool(Value &, APInt &)> ExternalAnalysis = nullptr);
534
535 /// Collect the offset of this GEP as a map of Values to their associated
536 /// APInt multipliers, as well as a total Constant Offset.
537 bool collectOffset(const DataLayout &DL, unsigned BitWidth,
538 MapVector<Value *, APInt> &VariableOffsets,
539 APInt &ConstantOffset) const;
540};
541
542template <>
544 : public VariadicOperandTraits<GEPOperator, 1> {};
545
547
549 : public ConcreteOperator<Operator, Instruction::PtrToInt> {
550 friend class PtrToInt;
551 friend class ConstantExpr;
552
553public:
554 /// Transparently provide more efficient getOperand methods.
556
558 return getOperand(0);
559 }
560 const Value *getPointerOperand() const {
561 return getOperand(0);
562 }
563
564 static unsigned getPointerOperandIndex() {
565 return 0U; // get index for modifying correct operand
566 }
567
568 /// Method to return the pointer operand as a PointerType.
570 return getPointerOperand()->getType();
571 }
572
573 /// Method to return the address space of the pointer operand.
574 unsigned getPointerAddressSpace() const {
575 return cast<PointerType>(getPointerOperandType())->getAddressSpace();
576 }
577};
578
579template <>
581 : public FixedNumOperandTraits<PtrToIntOperator, 1> {};
582
584
586 : public ConcreteOperator<Operator, Instruction::BitCast> {
587 friend class BitCastInst;
588 friend class ConstantExpr;
589
590public:
591 /// Transparently provide more efficient getOperand methods.
593
594 Type *getSrcTy() const {
595 return getOperand(0)->getType();
596 }
597
598 Type *getDestTy() const {
599 return getType();
600 }
601};
602
603template <>
605 : public FixedNumOperandTraits<BitCastOperator, 1> {};
606
608
610 : public ConcreteOperator<Operator, Instruction::AddrSpaceCast> {
611 friend class AddrSpaceCastInst;
612 friend class ConstantExpr;
613
614public:
615 /// Transparently provide more efficient getOperand methods.
617
618 Value *getPointerOperand() { return getOperand(0); }
619
620 const Value *getPointerOperand() const { return getOperand(0); }
621
622 unsigned getSrcAddressSpace() const {
624 }
625
626 unsigned getDestAddressSpace() const {
627 return getType()->getPointerAddressSpace();
628 }
629};
630
631template <>
633 : public FixedNumOperandTraits<AddrSpaceCastOperator, 1> {};
634
636
637} // end namespace llvm
638
639#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:620
unsigned getDestAddressSpace() const
Definition: Operator.h:626
DECLARE_TRANSPARENT_OPERAND_ACCESSORS(Value)
Transparently provide more efficient getOperand methods.
unsigned getSrcAddressSpace() const
Definition: Operator.h:622
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:598
DECLARE_TRANSPARENT_OPERAND_ACCESSORS(Value)
Transparently provide more efficient getOperand methods.
Type * getSrcTy() const
Definition: Operator.h:594
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:1016
This is the shared class of boolean and integer constants.
Definition: Constants.h:79
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:200
bool hasAllowReassoc() const
Test if this operation may be simplified with reassociative transforms.
Definition: Operator.h:282
bool isFast() const
Test if this operation allows all non-strict floating-point transforms.
Definition: Operator.h:271
static bool classof(const Value *V)
Definition: Operator.h:327
bool hasNoNaNs() const
Test if this operation's arguments and results are assumed not-NaN.
Definition: Operator.h:287
FastMathFlags getFastMathFlags() const
Convenience function for getting all the fast-math flags.
Definition: Operator.h:318
bool hasAllowReciprocal() const
Test if this operation can use reciprocal multiply instead of division.
Definition: Operator.h:302
bool hasNoSignedZeros() const
Test if this operation can ignore the sign of zero.
Definition: Operator.h:297
bool hasAllowContract() const
Test if this operation can be floating-point contracted (FMA).
Definition: Operator.h:307
bool hasNoInfs() const
Test if this operation's arguments and results are assumed not-infinite.
Definition: Operator.h:292
bool hasApproxFunc() const
Test if this operation allows approximations of math library functions or intrinsics.
Definition: Operator.h:313
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:188
const_op_iterator idx_end() const
Definition: Operator.h:435
const Value * getPointerOperand() const
Definition: Operator.h:448
const_op_iterator idx_begin() const
Definition: Operator.h:433
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:456
unsigned getNumIndices() const
Definition: Operator.h:468
unsigned countNonConstantIndices() const
Definition: Operator.h:500
Type * getSourceElementType() const
Definition: Operator.cpp:60
Type * getResultElementType() const
Definition: Operator.cpp:66
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:97
bool hasAllZeroIndices() const
Return true if all of the indices of this GEP are zeros.
Definition: Operator.h:479
op_iterator idx_end()
Definition: Operator.h:434
DECLARE_TRANSPARENT_OPERAND_ACCESSORS(Value)
Transparently provide more efficient getOperand methods.
std::optional< unsigned > getInRangeIndex() const
Returns the offset of the index with an inrange attachment, or std::nullopt if none.
Definition: Operator.h:426
op_iterator idx_begin()
Definition: Operator.h:432
Value * getPointerOperand()
Definition: Operator.h:445
bool hasAllConstantIndices() const
Return true if all of the indices of this GEP are constant integers.
Definition: Operator.h:492
iterator_range< op_iterator > indices()
Definition: Operator.h:437
bool hasIndices() const
Definition: Operator.h:472
iterator_range< const_op_iterator > indices() const
Definition: Operator.h:441
Align getMaxPreservedAlignment(const DataLayout &DL) const
Compute the maximum alignment that this GEP is garranteed to preserve.
Definition: Operator.cpp:72
unsigned getPointerAddressSpace() const
Method to return the address space of the pointer operand.
Definition: Operator.h:464
static unsigned getPointerOperandIndex()
Definition: Operator.h:451
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 hasPoisonGeneratingFlags() const
Return true if this operator has flags which may cause this operator to evaluate to poison despite ha...
Definition: Operator.cpp:21
bool hasPoisonGeneratingFlagsOrMetadata() const
Return true if this operator has poison-generating flags or metadata.
Definition: Operator.cpp:53
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:75
static bool classof(const Value *V)
Definition: Operator.h:136
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:108
unsigned getNoWrapKind() const
Returns the no-wrap kind of the operation.
Definition: Operator.h:113
bool hasNoUnsignedWrap() const
Test whether this operation is known to never undergo unsigned overflow, aka the nuw property.
Definition: Operator.h:102
static bool classof(const ConstantExpr *CE)
Definition: Operator.h:130
static bool classof(const Instruction *I)
Definition: Operator.h:124
A udiv or sdiv instruction, which can be marked as "exact", indicating that no bits are destroyed.
Definition: Operator.h:150
static bool classof(const ConstantExpr *CE)
Definition: Operator.h:180
bool isExact() const
Test whether this division is known to be exact, with zero remainder.
Definition: Operator.h:169
DECLARE_TRANSPARENT_OPERAND_ACCESSORS(Value)
Transparently provide more efficient getOperand methods.
static bool isPossiblyExactOpcode(unsigned OpC)
Definition: Operator.h:173
static bool classof(const Value *V)
Definition: Operator.h:186
static bool classof(const Instruction *I)
Definition: Operator.h:183
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:569
static unsigned getPointerOperandIndex()
Definition: Operator.h:564
unsigned getPointerAddressSpace() const
Method to return the address space of the pointer operand.
Definition: Operator.h:574
const Value * getPointerOperand() const
Definition: Operator.h:560
Value * getPointerOperand()
Definition: Operator.h:557
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:1930
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