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 };
408
409 void setIsInBounds(bool B) {
411 (SubclassOptionalData & ~IsInBounds) | (B * IsInBounds);
412 }
413
414public:
415 /// Transparently provide more efficient getOperand methods.
417
418 /// Test whether this is an inbounds GEP, as defined by LangRef.html.
419 bool isInBounds() const {
420 return SubclassOptionalData & IsInBounds;
421 }
422
423 /// Returns the offset of the index with an inrange attachment, or
424 /// std::nullopt if none.
425 std::optional<ConstantRange> getInRange() const;
426
427 inline op_iterator idx_begin() { return op_begin()+1; }
428 inline const_op_iterator idx_begin() const { return op_begin()+1; }
429 inline op_iterator idx_end() { return op_end(); }
430 inline const_op_iterator idx_end() const { return op_end(); }
431
433 return make_range(idx_begin(), idx_end());
434 }
435
437 return make_range(idx_begin(), idx_end());
438 }
439
441 return getOperand(0);
442 }
443 const Value *getPointerOperand() const {
444 return getOperand(0);
445 }
446 static unsigned getPointerOperandIndex() {
447 return 0U; // get index for modifying correct operand
448 }
449
450 /// Method to return the pointer operand as a PointerType.
452 return getPointerOperand()->getType();
453 }
454
455 Type *getSourceElementType() const;
456 Type *getResultElementType() const;
457
458 /// Method to return the address space of the pointer operand.
459 unsigned getPointerAddressSpace() const {
461 }
462
463 unsigned getNumIndices() const { // Note: always non-negative
464 return getNumOperands() - 1;
465 }
466
467 bool hasIndices() const {
468 return getNumOperands() > 1;
469 }
470
471 /// Return true if all of the indices of this GEP are zeros.
472 /// If so, the result pointer and the first operand have the same
473 /// value, just potentially different types.
474 bool hasAllZeroIndices() const {
475 for (const_op_iterator I = idx_begin(), E = idx_end(); I != E; ++I) {
476 if (ConstantInt *C = dyn_cast<ConstantInt>(I))
477 if (C->isZero())
478 continue;
479 return false;
480 }
481 return true;
482 }
483
484 /// Return true if all of the indices of this GEP are constant integers.
485 /// If so, the result pointer and the first operand have
486 /// a constant offset between them.
488 for (const_op_iterator I = idx_begin(), E = idx_end(); I != E; ++I) {
489 if (!isa<ConstantInt>(I))
490 return false;
491 }
492 return true;
493 }
494
495 unsigned countNonConstantIndices() const {
496 return count_if(indices(), [](const Use& use) {
497 return !isa<ConstantInt>(*use);
498 });
499 }
500
501 /// Compute the maximum alignment that this GEP is garranteed to preserve.
503
504 /// Accumulate the constant address offset of this GEP if possible.
505 ///
506 /// This routine accepts an APInt into which it will try to accumulate the
507 /// constant offset of this GEP.
508 ///
509 /// If \p ExternalAnalysis is provided it will be used to calculate a offset
510 /// when a operand of GEP is not constant.
511 /// For example, for a value \p ExternalAnalysis might try to calculate a
512 /// lower bound. If \p ExternalAnalysis is successful, it should return true.
513 ///
514 /// If the \p ExternalAnalysis returns false or the value returned by \p
515 /// ExternalAnalysis results in a overflow/underflow, this routine returns
516 /// false and the value of the offset APInt is undefined (it is *not*
517 /// preserved!).
518 ///
519 /// The APInt passed into this routine must be at exactly as wide as the
520 /// IntPtr type for the address space of the base GEP pointer.
522 const DataLayout &DL, APInt &Offset,
523 function_ref<bool(Value &, APInt &)> ExternalAnalysis = nullptr) const;
524
525 static bool accumulateConstantOffset(
526 Type *SourceType, ArrayRef<const Value *> Index, const DataLayout &DL,
527 APInt &Offset,
528 function_ref<bool(Value &, APInt &)> ExternalAnalysis = nullptr);
529
530 /// Collect the offset of this GEP as a map of Values to their associated
531 /// APInt multipliers, as well as a total Constant Offset.
532 bool collectOffset(const DataLayout &DL, unsigned BitWidth,
533 MapVector<Value *, APInt> &VariableOffsets,
534 APInt &ConstantOffset) const;
535};
536
537template <>
539 : public VariadicOperandTraits<GEPOperator, 1> {};
540
542
544 : public ConcreteOperator<Operator, Instruction::PtrToInt> {
545 friend class PtrToInt;
546 friend class ConstantExpr;
547
548public:
549 /// Transparently provide more efficient getOperand methods.
551
553 return getOperand(0);
554 }
555 const Value *getPointerOperand() const {
556 return getOperand(0);
557 }
558
559 static unsigned getPointerOperandIndex() {
560 return 0U; // get index for modifying correct operand
561 }
562
563 /// Method to return the pointer operand as a PointerType.
565 return getPointerOperand()->getType();
566 }
567
568 /// Method to return the address space of the pointer operand.
569 unsigned getPointerAddressSpace() const {
570 return cast<PointerType>(getPointerOperandType())->getAddressSpace();
571 }
572};
573
574template <>
576 : public FixedNumOperandTraits<PtrToIntOperator, 1> {};
577
579
581 : public ConcreteOperator<Operator, Instruction::BitCast> {
582 friend class BitCastInst;
583 friend class ConstantExpr;
584
585public:
586 /// Transparently provide more efficient getOperand methods.
588
589 Type *getSrcTy() const {
590 return getOperand(0)->getType();
591 }
592
593 Type *getDestTy() const {
594 return getType();
595 }
596};
597
598template <>
600 : public FixedNumOperandTraits<BitCastOperator, 1> {};
601
603
605 : public ConcreteOperator<Operator, Instruction::AddrSpaceCast> {
606 friend class AddrSpaceCastInst;
607 friend class ConstantExpr;
608
609public:
610 /// Transparently provide more efficient getOperand methods.
612
613 Value *getPointerOperand() { return getOperand(0); }
614
615 const Value *getPointerOperand() const { return getOperand(0); }
616
617 unsigned getSrcAddressSpace() const {
619 }
620
621 unsigned getDestAddressSpace() const {
622 return getType()->getPointerAddressSpace();
623 }
624};
625
626template <>
628 : public FixedNumOperandTraits<AddrSpaceCastOperator, 1> {};
629
631
632} // end namespace llvm
633
634#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:615
unsigned getDestAddressSpace() const
Definition: Operator.h:621
DECLARE_TRANSPARENT_OPERAND_ACCESSORS(Value)
Transparently provide more efficient getOperand methods.
unsigned getSrcAddressSpace() const
Definition: Operator.h:617
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:593
DECLARE_TRANSPARENT_OPERAND_ACCESSORS(Value)
Transparently provide more efficient getOperand methods.
Type * getSrcTy() const
Definition: Operator.h:589
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: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: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:200
const_op_iterator idx_end() const
Definition: Operator.h:430
const Value * getPointerOperand() const
Definition: Operator.h:443
const_op_iterator idx_begin() const
Definition: Operator.h:428
bool isInBounds() const
Test whether this is an inbounds GEP, as defined by LangRef.html.
Definition: Operator.h:419
Type * getPointerOperandType() const
Method to return the pointer operand as a PointerType.
Definition: Operator.h:451
unsigned getNumIndices() const
Definition: Operator.h:463
std::optional< ConstantRange > getInRange() const
Returns the offset of the index with an inrange attachment, or std::nullopt if none.
Definition: Operator.cpp:78
unsigned countNonConstantIndices() const
Definition: Operator.h:495
Type * getSourceElementType() const
Definition: Operator.cpp:66
Type * getResultElementType() const
Definition: Operator.cpp:72
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:109
bool hasAllZeroIndices() const
Return true if all of the indices of this GEP are zeros.
Definition: Operator.h:474
op_iterator idx_end()
Definition: Operator.h:429
DECLARE_TRANSPARENT_OPERAND_ACCESSORS(Value)
Transparently provide more efficient getOperand methods.
op_iterator idx_begin()
Definition: Operator.h:427
Value * getPointerOperand()
Definition: Operator.h:440
bool hasAllConstantIndices() const
Return true if all of the indices of this GEP are constant integers.
Definition: Operator.h:487
iterator_range< op_iterator > indices()
Definition: Operator.h:432
bool hasIndices() const
Definition: Operator.h:467
iterator_range< const_op_iterator > indices() const
Definition: Operator.h:436
Align getMaxPreservedAlignment(const DataLayout &DL) const
Compute the maximum alignment that this GEP is garranteed to preserve.
Definition: Operator.cpp:84
unsigned getPointerAddressSpace() const
Method to return the address space of the pointer operand.
Definition: Operator.h:459
static unsigned getPointerOperandIndex()
Definition: Operator.h:446
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:59
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:564
static unsigned getPointerOperandIndex()
Definition: Operator.h:559
unsigned getPointerAddressSpace() const
Method to return the address space of the pointer operand.
Definition: Operator.h:569
const Value * getPointerOperand() const
Definition: Operator.h:555
Value * getPointerOperand()
Definition: Operator.h:552
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