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 static bool classof(const Instruction *I) {
113 return I->getOpcode() == Instruction::Add ||
114 I->getOpcode() == Instruction::Sub ||
115 I->getOpcode() == Instruction::Mul ||
116 I->getOpcode() == Instruction::Shl;
117 }
118 static bool classof(const ConstantExpr *CE) {
119 return CE->getOpcode() == Instruction::Add ||
120 CE->getOpcode() == Instruction::Sub ||
121 CE->getOpcode() == Instruction::Mul ||
122 CE->getOpcode() == Instruction::Shl;
123 }
124 static bool classof(const Value *V) {
125 return (isa<Instruction>(V) && classof(cast<Instruction>(V))) ||
126 (isa<ConstantExpr>(V) && classof(cast<ConstantExpr>(V)));
127 }
128};
129
130template <>
132 : public FixedNumOperandTraits<OverflowingBinaryOperator, 2> {};
133
135
136/// A udiv or sdiv instruction, which can be marked as "exact",
137/// indicating that no bits are destroyed.
139public:
140 enum {
141 IsExact = (1 << 0)
142 };
143
144private:
145 friend class Instruction;
146 friend class ConstantExpr;
147
148 void setIsExact(bool B) {
149 SubclassOptionalData = (SubclassOptionalData & ~IsExact) | (B * IsExact);
150 }
151
152public:
153 /// Transparently provide more efficient getOperand methods.
155
156 /// Test whether this division is known to be exact, with zero remainder.
157 bool isExact() const {
158 return SubclassOptionalData & IsExact;
159 }
160
161 static bool isPossiblyExactOpcode(unsigned OpC) {
162 return OpC == Instruction::SDiv ||
163 OpC == Instruction::UDiv ||
164 OpC == Instruction::AShr ||
165 OpC == Instruction::LShr;
166 }
167
168 static bool classof(const ConstantExpr *CE) {
169 return isPossiblyExactOpcode(CE->getOpcode());
170 }
171 static bool classof(const Instruction *I) {
172 return isPossiblyExactOpcode(I->getOpcode());
173 }
174 static bool classof(const Value *V) {
175 return (isa<Instruction>(V) && classof(cast<Instruction>(V))) ||
176 (isa<ConstantExpr>(V) && classof(cast<ConstantExpr>(V)));
177 }
178};
179
180template <>
182 : public FixedNumOperandTraits<PossiblyExactOperator, 2> {};
183
185
186/// Utility class for floating point operations which can have
187/// information about relaxed accuracy requirements attached to them.
188class FPMathOperator : public Operator {
189private:
190 friend class Instruction;
191
192 /// 'Fast' means all bits are set.
193 void setFast(bool B) {
194 setHasAllowReassoc(B);
195 setHasNoNaNs(B);
196 setHasNoInfs(B);
197 setHasNoSignedZeros(B);
198 setHasAllowReciprocal(B);
199 setHasAllowContract(B);
200 setHasApproxFunc(B);
201 }
202
203 void setHasAllowReassoc(bool B) {
204 SubclassOptionalData =
205 (SubclassOptionalData & ~FastMathFlags::AllowReassoc) |
207 }
208
209 void setHasNoNaNs(bool B) {
210 SubclassOptionalData =
211 (SubclassOptionalData & ~FastMathFlags::NoNaNs) |
213 }
214
215 void setHasNoInfs(bool B) {
216 SubclassOptionalData =
217 (SubclassOptionalData & ~FastMathFlags::NoInfs) |
219 }
220
221 void setHasNoSignedZeros(bool B) {
222 SubclassOptionalData =
223 (SubclassOptionalData & ~FastMathFlags::NoSignedZeros) |
225 }
226
227 void setHasAllowReciprocal(bool B) {
228 SubclassOptionalData =
229 (SubclassOptionalData & ~FastMathFlags::AllowReciprocal) |
231 }
232
233 void setHasAllowContract(bool B) {
234 SubclassOptionalData =
235 (SubclassOptionalData & ~FastMathFlags::AllowContract) |
237 }
238
239 void setHasApproxFunc(bool B) {
240 SubclassOptionalData =
241 (SubclassOptionalData & ~FastMathFlags::ApproxFunc) |
243 }
244
245 /// Convenience function for setting multiple fast-math flags.
246 /// FMF is a mask of the bits to set.
247 void setFastMathFlags(FastMathFlags FMF) {
248 SubclassOptionalData |= FMF.Flags;
249 }
250
251 /// Convenience function for copying all fast-math flags.
252 /// All values in FMF are transferred to this operator.
253 void copyFastMathFlags(FastMathFlags FMF) {
254 SubclassOptionalData = FMF.Flags;
255 }
256
257public:
258 /// Test if this operation allows all non-strict floating-point transforms.
259 bool isFast() const {
260 return ((SubclassOptionalData & FastMathFlags::AllowReassoc) != 0 &&
261 (SubclassOptionalData & FastMathFlags::NoNaNs) != 0 &&
262 (SubclassOptionalData & FastMathFlags::NoInfs) != 0 &&
263 (SubclassOptionalData & FastMathFlags::NoSignedZeros) != 0 &&
264 (SubclassOptionalData & FastMathFlags::AllowReciprocal) != 0 &&
265 (SubclassOptionalData & FastMathFlags::AllowContract) != 0 &&
266 (SubclassOptionalData & FastMathFlags::ApproxFunc) != 0);
267 }
268
269 /// Test if this operation may be simplified with reassociative transforms.
270 bool hasAllowReassoc() const {
271 return (SubclassOptionalData & FastMathFlags::AllowReassoc) != 0;
272 }
273
274 /// Test if this operation's arguments and results are assumed not-NaN.
275 bool hasNoNaNs() const {
276 return (SubclassOptionalData & FastMathFlags::NoNaNs) != 0;
277 }
278
279 /// Test if this operation's arguments and results are assumed not-infinite.
280 bool hasNoInfs() const {
281 return (SubclassOptionalData & FastMathFlags::NoInfs) != 0;
282 }
283
284 /// Test if this operation can ignore the sign of zero.
285 bool hasNoSignedZeros() const {
286 return (SubclassOptionalData & FastMathFlags::NoSignedZeros) != 0;
287 }
288
289 /// Test if this operation can use reciprocal multiply instead of division.
290 bool hasAllowReciprocal() const {
291 return (SubclassOptionalData & FastMathFlags::AllowReciprocal) != 0;
292 }
293
294 /// Test if this operation can be floating-point contracted (FMA).
295 bool hasAllowContract() const {
296 return (SubclassOptionalData & FastMathFlags::AllowContract) != 0;
297 }
298
299 /// Test if this operation allows approximations of math library functions or
300 /// intrinsics.
301 bool hasApproxFunc() const {
302 return (SubclassOptionalData & FastMathFlags::ApproxFunc) != 0;
303 }
304
305 /// Convenience function for getting all the fast-math flags
307 return FastMathFlags(SubclassOptionalData);
308 }
309
310 /// Get the maximum error permitted by this operation in ULPs. An accuracy of
311 /// 0.0 means that the operation should be performed with the default
312 /// precision.
313 float getFPAccuracy() const;
314
315 static bool classof(const Value *V) {
316 unsigned Opcode;
317 if (auto *I = dyn_cast<Instruction>(V))
318 Opcode = I->getOpcode();
319 else if (auto *CE = dyn_cast<ConstantExpr>(V))
320 Opcode = CE->getOpcode();
321 else
322 return false;
323
324 switch (Opcode) {
325 case Instruction::FNeg:
326 case Instruction::FAdd:
327 case Instruction::FSub:
328 case Instruction::FMul:
329 case Instruction::FDiv:
330 case Instruction::FRem:
331 // FIXME: To clean up and correct the semantics of fast-math-flags, FCmp
332 // should not be treated as a math op, but the other opcodes should.
333 // This would make things consistent with Select/PHI (FP value type
334 // determines whether they are math ops and, therefore, capable of
335 // having fast-math-flags).
336 case Instruction::FCmp:
337 return true;
338 case Instruction::PHI:
339 case Instruction::Select:
340 case Instruction::Call: {
341 Type *Ty = V->getType();
342 while (ArrayType *ArrTy = dyn_cast<ArrayType>(Ty))
343 Ty = ArrTy->getElementType();
344 return Ty->isFPOrFPVectorTy();
345 }
346 default:
347 return false;
348 }
349 }
350};
351
352/// A helper template for defining operators for individual opcodes.
353template<typename SuperClass, unsigned Opc>
355public:
356 static bool classof(const Instruction *I) {
357 return I->getOpcode() == Opc;
358 }
359 static bool classof(const ConstantExpr *CE) {
360 return CE->getOpcode() == Opc;
361 }
362 static bool classof(const Value *V) {
363 return (isa<Instruction>(V) && classof(cast<Instruction>(V))) ||
364 (isa<ConstantExpr>(V) && classof(cast<ConstantExpr>(V)));
365 }
366};
367
369 : public ConcreteOperator<OverflowingBinaryOperator, Instruction::Add> {
370};
372 : public ConcreteOperator<OverflowingBinaryOperator, Instruction::Sub> {
373};
375 : public ConcreteOperator<OverflowingBinaryOperator, Instruction::Mul> {
376};
378 : public ConcreteOperator<OverflowingBinaryOperator, Instruction::Shl> {
379};
380
382 : public ConcreteOperator<PossiblyExactOperator, Instruction::AShr> {
383};
385 : public ConcreteOperator<PossiblyExactOperator, Instruction::LShr> {
386};
387
389 : public ConcreteOperator<Operator, Instruction::GetElementPtr> {
390 friend class GetElementPtrInst;
391 friend class ConstantExpr;
392
393 enum {
394 IsInBounds = (1 << 0),
395 // InRangeIndex: bits 1-6
396 };
397
398 void setIsInBounds(bool B) {
400 (SubclassOptionalData & ~IsInBounds) | (B * IsInBounds);
401 }
402
403public:
404 /// Transparently provide more efficient getOperand methods.
406
407 /// Test whether this is an inbounds GEP, as defined by LangRef.html.
408 bool isInBounds() const {
409 return SubclassOptionalData & IsInBounds;
410 }
411
412 /// Returns the offset of the index with an inrange attachment, or
413 /// std::nullopt if none.
414 std::optional<unsigned> getInRangeIndex() const {
415 if (SubclassOptionalData >> 1 == 0)
416 return std::nullopt;
417 return (SubclassOptionalData >> 1) - 1;
418 }
419
420 inline op_iterator idx_begin() { return op_begin()+1; }
421 inline const_op_iterator idx_begin() const { return op_begin()+1; }
422 inline op_iterator idx_end() { return op_end(); }
423 inline const_op_iterator idx_end() const { return op_end(); }
424
426 return make_range(idx_begin(), idx_end());
427 }
428
430 return make_range(idx_begin(), idx_end());
431 }
432
434 return getOperand(0);
435 }
436 const Value *getPointerOperand() const {
437 return getOperand(0);
438 }
439 static unsigned getPointerOperandIndex() {
440 return 0U; // get index for modifying correct operand
441 }
442
443 /// Method to return the pointer operand as a PointerType.
445 return getPointerOperand()->getType();
446 }
447
448 Type *getSourceElementType() const;
449 Type *getResultElementType() const;
450
451 /// Method to return the address space of the pointer operand.
452 unsigned getPointerAddressSpace() const {
454 }
455
456 unsigned getNumIndices() const { // Note: always non-negative
457 return getNumOperands() - 1;
458 }
459
460 bool hasIndices() const {
461 return getNumOperands() > 1;
462 }
463
464 /// Return true if all of the indices of this GEP are zeros.
465 /// If so, the result pointer and the first operand have the same
466 /// value, just potentially different types.
467 bool hasAllZeroIndices() const {
468 for (const_op_iterator I = idx_begin(), E = idx_end(); I != E; ++I) {
469 if (ConstantInt *C = dyn_cast<ConstantInt>(I))
470 if (C->isZero())
471 continue;
472 return false;
473 }
474 return true;
475 }
476
477 /// Return true if all of the indices of this GEP are constant integers.
478 /// If so, the result pointer and the first operand have
479 /// a constant offset between them.
481 for (const_op_iterator I = idx_begin(), E = idx_end(); I != E; ++I) {
482 if (!isa<ConstantInt>(I))
483 return false;
484 }
485 return true;
486 }
487
488 unsigned countNonConstantIndices() const {
489 return count_if(indices(), [](const Use& use) {
490 return !isa<ConstantInt>(*use);
491 });
492 }
493
494 /// Compute the maximum alignment that this GEP is garranteed to preserve.
496
497 /// Accumulate the constant address offset of this GEP if possible.
498 ///
499 /// This routine accepts an APInt into which it will try to accumulate the
500 /// constant offset of this GEP.
501 ///
502 /// If \p ExternalAnalysis is provided it will be used to calculate a offset
503 /// when a operand of GEP is not constant.
504 /// For example, for a value \p ExternalAnalysis might try to calculate a
505 /// lower bound. If \p ExternalAnalysis is successful, it should return true.
506 ///
507 /// If the \p ExternalAnalysis returns false or the value returned by \p
508 /// ExternalAnalysis results in a overflow/underflow, this routine returns
509 /// false and the value of the offset APInt is undefined (it is *not*
510 /// preserved!).
511 ///
512 /// The APInt passed into this routine must be at exactly as wide as the
513 /// IntPtr type for the address space of the base GEP pointer.
515 const DataLayout &DL, APInt &Offset,
516 function_ref<bool(Value &, APInt &)> ExternalAnalysis = nullptr) const;
517
518 static bool accumulateConstantOffset(
519 Type *SourceType, ArrayRef<const Value *> Index, const DataLayout &DL,
520 APInt &Offset,
521 function_ref<bool(Value &, APInt &)> ExternalAnalysis = nullptr);
522
523 /// Collect the offset of this GEP as a map of Values to their associated
524 /// APInt multipliers, as well as a total Constant Offset.
525 bool collectOffset(const DataLayout &DL, unsigned BitWidth,
526 MapVector<Value *, APInt> &VariableOffsets,
527 APInt &ConstantOffset) const;
528};
529
530template <>
532 : public VariadicOperandTraits<GEPOperator, 1> {};
533
535
537 : public ConcreteOperator<Operator, Instruction::PtrToInt> {
538 friend class PtrToInt;
539 friend class ConstantExpr;
540
541public:
542 /// Transparently provide more efficient getOperand methods.
544
546 return getOperand(0);
547 }
548 const Value *getPointerOperand() const {
549 return getOperand(0);
550 }
551
552 static unsigned getPointerOperandIndex() {
553 return 0U; // get index for modifying correct operand
554 }
555
556 /// Method to return the pointer operand as a PointerType.
558 return getPointerOperand()->getType();
559 }
560
561 /// Method to return the address space of the pointer operand.
562 unsigned getPointerAddressSpace() const {
563 return cast<PointerType>(getPointerOperandType())->getAddressSpace();
564 }
565};
566
567template <>
569 : public FixedNumOperandTraits<PtrToIntOperator, 1> {};
570
572
574 : public ConcreteOperator<Operator, Instruction::BitCast> {
575 friend class BitCastInst;
576 friend class ConstantExpr;
577
578public:
579 /// Transparently provide more efficient getOperand methods.
581
582 Type *getSrcTy() const {
583 return getOperand(0)->getType();
584 }
585
586 Type *getDestTy() const {
587 return getType();
588 }
589};
590
591template <>
593 : public FixedNumOperandTraits<BitCastOperator, 1> {};
594
596
598 : public ConcreteOperator<Operator, Instruction::AddrSpaceCast> {
599 friend class AddrSpaceCastInst;
600 friend class ConstantExpr;
601
602public:
603 /// Transparently provide more efficient getOperand methods.
605
606 Value *getPointerOperand() { return getOperand(0); }
607
608 const Value *getPointerOperand() const { return getOperand(0); }
609
610 unsigned getSrcAddressSpace() const {
612 }
613
614 unsigned getDestAddressSpace() const {
615 return getType()->getPointerAddressSpace();
616 }
617};
618
619template <>
621 : public FixedNumOperandTraits<AddrSpaceCastOperator, 1> {};
622
624
625} // end namespace llvm
626
627#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:608
unsigned getDestAddressSpace() const
Definition: Operator.h:614
DECLARE_TRANSPARENT_OPERAND_ACCESSORS(Value)
Transparently provide more efficient getOperand methods.
unsigned getSrcAddressSpace() const
Definition: Operator.h:610
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:586
DECLARE_TRANSPARENT_OPERAND_ACCESSORS(Value)
Transparently provide more efficient getOperand methods.
Type * getSrcTy() const
Definition: Operator.h:582
A helper template for defining operators for individual opcodes.
Definition: Operator.h:354
static bool classof(const Value *V)
Definition: Operator.h:362
static bool classof(const ConstantExpr *CE)
Definition: Operator.h:359
static bool classof(const Instruction *I)
Definition: Operator.h:356
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:188
bool hasAllowReassoc() const
Test if this operation may be simplified with reassociative transforms.
Definition: Operator.h:270
bool isFast() const
Test if this operation allows all non-strict floating-point transforms.
Definition: Operator.h:259
static bool classof(const Value *V)
Definition: Operator.h:315
bool hasNoNaNs() const
Test if this operation's arguments and results are assumed not-NaN.
Definition: Operator.h:275
FastMathFlags getFastMathFlags() const
Convenience function for getting all the fast-math flags.
Definition: Operator.h:306
bool hasAllowReciprocal() const
Test if this operation can use reciprocal multiply instead of division.
Definition: Operator.h:290
bool hasNoSignedZeros() const
Test if this operation can ignore the sign of zero.
Definition: Operator.h:285
bool hasAllowContract() const
Test if this operation can be floating-point contracted (FMA).
Definition: Operator.h:295
bool hasNoInfs() const
Test if this operation's arguments and results are assumed not-infinite.
Definition: Operator.h:280
bool hasApproxFunc() const
Test if this operation allows approximations of math library functions or intrinsics.
Definition: Operator.h:301
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:423
const Value * getPointerOperand() const
Definition: Operator.h:436
const_op_iterator idx_begin() const
Definition: Operator.h:421
bool isInBounds() const
Test whether this is an inbounds GEP, as defined by LangRef.html.
Definition: Operator.h:408
Type * getPointerOperandType() const
Method to return the pointer operand as a PointerType.
Definition: Operator.h:444
unsigned getNumIndices() const
Definition: Operator.h:456
unsigned countNonConstantIndices() const
Definition: Operator.h:488
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:467
op_iterator idx_end()
Definition: Operator.h:422
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:414
op_iterator idx_begin()
Definition: Operator.h:420
Value * getPointerOperand()
Definition: Operator.h:433
bool hasAllConstantIndices() const
Return true if all of the indices of this GEP are constant integers.
Definition: Operator.h:480
iterator_range< op_iterator > indices()
Definition: Operator.h:425
bool hasIndices() const
Definition: Operator.h:460
iterator_range< const_op_iterator > indices() const
Definition: Operator.h:429
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:452
static unsigned getPointerOperandIndex()
Definition: Operator.h:439
an instruction for type-safe pointer arithmetic to access elements of arrays and structs
Definition: Instructions.h:949
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:124
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
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:118
static bool classof(const Instruction *I)
Definition: Operator.h:112
A udiv or sdiv instruction, which can be marked as "exact", indicating that no bits are destroyed.
Definition: Operator.h:138
static bool classof(const ConstantExpr *CE)
Definition: Operator.h:168
bool isExact() const
Test whether this division is known to be exact, with zero remainder.
Definition: Operator.h:157
DECLARE_TRANSPARENT_OPERAND_ACCESSORS(Value)
Transparently provide more efficient getOperand methods.
static bool isPossiblyExactOpcode(unsigned OpC)
Definition: Operator.h:161
static bool classof(const Value *V)
Definition: Operator.h:174
static bool classof(const Instruction *I)
Definition: Operator.h:171
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:557
static unsigned getPointerOperandIndex()
Definition: Operator.h:552
unsigned getPointerAddressSpace() const
Method to return the address space of the pointer operand.
Definition: Operator.h:562
const Value * getPointerOperand() const
Definition: Operator.h:548
Value * getPointerOperand()
Definition: Operator.h:545
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