LLVM  14.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/ADT/None.h"
19 #include "llvm/ADT/Optional.h"
20 #include "llvm/IR/Constants.h"
21 #include "llvm/IR/Instruction.h"
22 #include "llvm/IR/Type.h"
23 #include "llvm/IR/Value.h"
24 #include "llvm/Support/Casting.h"
25 #include <cstddef>
26 
27 namespace llvm {
28 
29 /// This is a utility class that provides an abstraction for the common
30 /// functionality between Instructions and ConstantExprs.
31 class Operator : public User {
32 public:
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 
68 /// Utility class for integer operators which may exhibit overflow - Add, Sub,
69 /// Mul, and Shl. It does not include SDiv, despite that operator having the
70 /// potential for overflow.
72 public:
73  enum {
74  AnyWrap = 0,
75  NoUnsignedWrap = (1 << 0),
76  NoSignedWrap = (1 << 1)
77  };
78 
79 private:
80  friend class Instruction;
81  friend class ConstantExpr;
82 
83  void setHasNoUnsignedWrap(bool B) {
86  }
87  void setHasNoSignedWrap(bool B) {
90  }
91 
92 public:
93  /// Test whether this operation is known to never
94  /// undergo unsigned overflow, aka the nuw property.
95  bool hasNoUnsignedWrap() const {
97  }
98 
99  /// Test whether this operation is known to never
100  /// undergo signed overflow, aka the nsw property.
101  bool hasNoSignedWrap() const {
102  return (SubclassOptionalData & NoSignedWrap) != 0;
103  }
104 
105  static bool classof(const Instruction *I) {
106  return I->getOpcode() == Instruction::Add ||
107  I->getOpcode() == Instruction::Sub ||
108  I->getOpcode() == Instruction::Mul ||
109  I->getOpcode() == Instruction::Shl;
110  }
111  static bool classof(const ConstantExpr *CE) {
112  return CE->getOpcode() == Instruction::Add ||
113  CE->getOpcode() == Instruction::Sub ||
114  CE->getOpcode() == Instruction::Mul ||
115  CE->getOpcode() == Instruction::Shl;
116  }
117  static bool classof(const Value *V) {
118  return (isa<Instruction>(V) && classof(cast<Instruction>(V))) ||
119  (isa<ConstantExpr>(V) && classof(cast<ConstantExpr>(V)));
120  }
121 };
122 
123 /// A udiv or sdiv instruction, which can be marked as "exact",
124 /// indicating that no bits are destroyed.
126 public:
127  enum {
128  IsExact = (1 << 0)
129  };
130 
131 private:
132  friend class Instruction;
133  friend class ConstantExpr;
134 
135  void setIsExact(bool B) {
137  }
138 
139 public:
140  /// Test whether this division is known to be exact, with zero remainder.
141  bool isExact() const {
142  return SubclassOptionalData & IsExact;
143  }
144 
145  static bool isPossiblyExactOpcode(unsigned OpC) {
146  return OpC == Instruction::SDiv ||
147  OpC == Instruction::UDiv ||
148  OpC == Instruction::AShr ||
149  OpC == Instruction::LShr;
150  }
151 
152  static bool classof(const ConstantExpr *CE) {
153  return isPossiblyExactOpcode(CE->getOpcode());
154  }
155  static bool classof(const Instruction *I) {
156  return isPossiblyExactOpcode(I->getOpcode());
157  }
158  static bool classof(const Value *V) {
159  return (isa<Instruction>(V) && classof(cast<Instruction>(V))) ||
160  (isa<ConstantExpr>(V) && classof(cast<ConstantExpr>(V)));
161  }
162 };
163 
164 /// Convenience struct for specifying and reasoning about fast-math flags.
166 private:
167  friend class FPMathOperator;
168 
169  unsigned Flags = 0;
170 
171  FastMathFlags(unsigned F) {
172  // If all 7 bits are set, turn this into -1. If the number of bits grows,
173  // this must be updated. This is intended to provide some forward binary
174  // compatibility insurance for the meaning of 'fast' in case bits are added.
175  if (F == 0x7F) Flags = ~0U;
176  else Flags = F;
177  }
178 
179 public:
180  // This is how the bits are used in Value::SubclassOptionalData so they
181  // should fit there too.
182  // WARNING: We're out of space. SubclassOptionalData only has 7 bits. New
183  // functionality will require a change in how this information is stored.
184  enum {
185  AllowReassoc = (1 << 0),
186  NoNaNs = (1 << 1),
187  NoInfs = (1 << 2),
188  NoSignedZeros = (1 << 3),
189  AllowReciprocal = (1 << 4),
190  AllowContract = (1 << 5),
191  ApproxFunc = (1 << 6)
192  };
193 
194  FastMathFlags() = default;
195 
197  FastMathFlags FMF;
198  FMF.setFast();
199  return FMF;
200  }
201 
202  bool any() const { return Flags != 0; }
203  bool none() const { return Flags == 0; }
204  bool all() const { return Flags == ~0U; }
205 
206  void clear() { Flags = 0; }
207  void set() { Flags = ~0U; }
208 
209  /// Flag queries
210  bool allowReassoc() const { return 0 != (Flags & AllowReassoc); }
211  bool noNaNs() const { return 0 != (Flags & NoNaNs); }
212  bool noInfs() const { return 0 != (Flags & NoInfs); }
213  bool noSignedZeros() const { return 0 != (Flags & NoSignedZeros); }
214  bool allowReciprocal() const { return 0 != (Flags & AllowReciprocal); }
215  bool allowContract() const { return 0 != (Flags & AllowContract); }
216  bool approxFunc() const { return 0 != (Flags & ApproxFunc); }
217  /// 'Fast' means all bits are set.
218  bool isFast() const { return all(); }
219 
220  /// Flag setters
221  void setAllowReassoc(bool B = true) {
222  Flags = (Flags & ~AllowReassoc) | B * AllowReassoc;
223  }
224  void setNoNaNs(bool B = true) {
225  Flags = (Flags & ~NoNaNs) | B * NoNaNs;
226  }
227  void setNoInfs(bool B = true) {
228  Flags = (Flags & ~NoInfs) | B * NoInfs;
229  }
230  void setNoSignedZeros(bool B = true) {
231  Flags = (Flags & ~NoSignedZeros) | B * NoSignedZeros;
232  }
233  void setAllowReciprocal(bool B = true) {
234  Flags = (Flags & ~AllowReciprocal) | B * AllowReciprocal;
235  }
236  void setAllowContract(bool B = true) {
237  Flags = (Flags & ~AllowContract) | B * AllowContract;
238  }
239  void setApproxFunc(bool B = true) {
240  Flags = (Flags & ~ApproxFunc) | B * ApproxFunc;
241  }
242  void setFast(bool B = true) { B ? set() : clear(); }
243 
244  void operator&=(const FastMathFlags &OtherFlags) {
245  Flags &= OtherFlags.Flags;
246  }
247  void operator|=(const FastMathFlags &OtherFlags) {
248  Flags |= OtherFlags.Flags;
249  }
250  bool operator!=(const FastMathFlags &OtherFlags) const {
251  return Flags != OtherFlags.Flags;
252  }
253 
254  /// Print fast-math flags to \p O.
255  void print(raw_ostream &O) const;
256 };
257 
259  FMF.print(O);
260  return O;
261 }
262 
263 /// Utility class for floating point operations which can have
264 /// information about relaxed accuracy requirements attached to them.
265 class FPMathOperator : public Operator {
266 private:
267  friend class Instruction;
268 
269  /// 'Fast' means all bits are set.
270  void setFast(bool B) {
271  setHasAllowReassoc(B);
272  setHasNoNaNs(B);
273  setHasNoInfs(B);
274  setHasNoSignedZeros(B);
275  setHasAllowReciprocal(B);
276  setHasAllowContract(B);
277  setHasApproxFunc(B);
278  }
279 
280  void setHasAllowReassoc(bool B) {
284  }
285 
286  void setHasNoNaNs(bool B) {
288  (SubclassOptionalData & ~FastMathFlags::NoNaNs) |
290  }
291 
292  void setHasNoInfs(bool B) {
294  (SubclassOptionalData & ~FastMathFlags::NoInfs) |
296  }
297 
298  void setHasNoSignedZeros(bool B) {
300  (SubclassOptionalData & ~FastMathFlags::NoSignedZeros) |
302  }
303 
304  void setHasAllowReciprocal(bool B) {
306  (SubclassOptionalData & ~FastMathFlags::AllowReciprocal) |
308  }
309 
310  void setHasAllowContract(bool B) {
312  (SubclassOptionalData & ~FastMathFlags::AllowContract) |
314  }
315 
316  void setHasApproxFunc(bool B) {
318  (SubclassOptionalData & ~FastMathFlags::ApproxFunc) |
320  }
321 
322  /// Convenience function for setting multiple fast-math flags.
323  /// FMF is a mask of the bits to set.
324  void setFastMathFlags(FastMathFlags FMF) {
325  SubclassOptionalData |= FMF.Flags;
326  }
327 
328  /// Convenience function for copying all fast-math flags.
329  /// All values in FMF are transferred to this operator.
330  void copyFastMathFlags(FastMathFlags FMF) {
331  SubclassOptionalData = FMF.Flags;
332  }
333 
334 public:
335  /// Test if this operation allows all non-strict floating-point transforms.
336  bool isFast() const {
344  }
345 
346  /// Test if this operation may be simplified with reassociative transforms.
347  bool hasAllowReassoc() const {
349  }
350 
351  /// Test if this operation's arguments and results are assumed not-NaN.
352  bool hasNoNaNs() const {
354  }
355 
356  /// Test if this operation's arguments and results are assumed not-infinite.
357  bool hasNoInfs() const {
359  }
360 
361  /// Test if this operation can ignore the sign of zero.
362  bool hasNoSignedZeros() const {
364  }
365 
366  /// Test if this operation can use reciprocal multiply instead of division.
367  bool hasAllowReciprocal() const {
369  }
370 
371  /// Test if this operation can be floating-point contracted (FMA).
372  bool hasAllowContract() const {
374  }
375 
376  /// Test if this operation allows approximations of math library functions or
377  /// intrinsics.
378  bool hasApproxFunc() const {
380  }
381 
382  /// Convenience function for getting all the fast-math flags
385  }
386 
387  /// Get the maximum error permitted by this operation in ULPs. An accuracy of
388  /// 0.0 means that the operation should be performed with the default
389  /// precision.
390  float getFPAccuracy() const;
391 
392  static bool classof(const Value *V) {
393  unsigned Opcode;
394  if (auto *I = dyn_cast<Instruction>(V))
395  Opcode = I->getOpcode();
396  else if (auto *CE = dyn_cast<ConstantExpr>(V))
397  Opcode = CE->getOpcode();
398  else
399  return false;
400 
401  switch (Opcode) {
402  case Instruction::FNeg:
403  case Instruction::FAdd:
404  case Instruction::FSub:
405  case Instruction::FMul:
406  case Instruction::FDiv:
407  case Instruction::FRem:
408  // FIXME: To clean up and correct the semantics of fast-math-flags, FCmp
409  // should not be treated as a math op, but the other opcodes should.
410  // This would make things consistent with Select/PHI (FP value type
411  // determines whether they are math ops and, therefore, capable of
412  // having fast-math-flags).
413  case Instruction::FCmp:
414  return true;
415  case Instruction::PHI:
416  case Instruction::Select:
417  case Instruction::Call: {
418  Type *Ty = V->getType();
419  while (ArrayType *ArrTy = dyn_cast<ArrayType>(Ty))
420  Ty = ArrTy->getElementType();
421  return Ty->isFPOrFPVectorTy();
422  }
423  default:
424  return false;
425  }
426  }
427 };
428 
429 /// A helper template for defining operators for individual opcodes.
430 template<typename SuperClass, unsigned Opc>
431 class ConcreteOperator : public SuperClass {
432 public:
433  static bool classof(const Instruction *I) {
434  return I->getOpcode() == Opc;
435  }
436  static bool classof(const ConstantExpr *CE) {
437  return CE->getOpcode() == Opc;
438  }
439  static bool classof(const Value *V) {
440  return (isa<Instruction>(V) && classof(cast<Instruction>(V))) ||
441  (isa<ConstantExpr>(V) && classof(cast<ConstantExpr>(V)));
442  }
443 };
444 
446  : public ConcreteOperator<OverflowingBinaryOperator, Instruction::Add> {
447 };
449  : public ConcreteOperator<OverflowingBinaryOperator, Instruction::Sub> {
450 };
452  : public ConcreteOperator<OverflowingBinaryOperator, Instruction::Mul> {
453 };
455  : public ConcreteOperator<OverflowingBinaryOperator, Instruction::Shl> {
456 };
457 
459  : public ConcreteOperator<PossiblyExactOperator, Instruction::SDiv> {
460 };
462  : public ConcreteOperator<PossiblyExactOperator, Instruction::UDiv> {
463 };
465  : public ConcreteOperator<PossiblyExactOperator, Instruction::AShr> {
466 };
468  : public ConcreteOperator<PossiblyExactOperator, Instruction::LShr> {
469 };
470 
471 class ZExtOperator : public ConcreteOperator<Operator, Instruction::ZExt> {};
472 
474  : public ConcreteOperator<Operator, Instruction::GetElementPtr> {
475  friend class GetElementPtrInst;
476  friend class ConstantExpr;
477 
478  enum {
479  IsInBounds = (1 << 0),
480  // InRangeIndex: bits 1-6
481  };
482 
483  void setIsInBounds(bool B) {
485  (SubclassOptionalData & ~IsInBounds) | (B * IsInBounds);
486  }
487 
488 public:
489  /// Test whether this is an inbounds GEP, as defined by LangRef.html.
490  bool isInBounds() const {
491  return SubclassOptionalData & IsInBounds;
492  }
493 
494  /// Returns the offset of the index with an inrange attachment, or None if
495  /// none.
497  if (SubclassOptionalData >> 1 == 0) return None;
498  return (SubclassOptionalData >> 1) - 1;
499  }
500 
501  inline op_iterator idx_begin() { return op_begin()+1; }
502  inline const_op_iterator idx_begin() const { return op_begin()+1; }
503  inline op_iterator idx_end() { return op_end(); }
504  inline const_op_iterator idx_end() const { return op_end(); }
505 
507  return make_range(idx_begin(), idx_end());
508  }
509 
511  return make_range(idx_begin(), idx_end());
512  }
513 
515  return getOperand(0);
516  }
517  const Value *getPointerOperand() const {
518  return getOperand(0);
519  }
520  static unsigned getPointerOperandIndex() {
521  return 0U; // get index for modifying correct operand
522  }
523 
524  /// Method to return the pointer operand as a PointerType.
526  return getPointerOperand()->getType();
527  }
528 
529  Type *getSourceElementType() const;
530  Type *getResultElementType() const;
531 
532  /// Method to return the address space of the pointer operand.
533  unsigned getPointerAddressSpace() const {
535  }
536 
537  unsigned getNumIndices() const { // Note: always non-negative
538  return getNumOperands() - 1;
539  }
540 
541  bool hasIndices() const {
542  return getNumOperands() > 1;
543  }
544 
545  /// Return true if all of the indices of this GEP are zeros.
546  /// If so, the result pointer and the first operand have the same
547  /// value, just potentially different types.
548  bool hasAllZeroIndices() const {
549  for (const_op_iterator I = idx_begin(), E = idx_end(); I != E; ++I) {
550  if (ConstantInt *C = dyn_cast<ConstantInt>(I))
551  if (C->isZero())
552  continue;
553  return false;
554  }
555  return true;
556  }
557 
558  /// Return true if all of the indices of this GEP are constant integers.
559  /// If so, the result pointer and the first operand have
560  /// a constant offset between them.
561  bool hasAllConstantIndices() const {
562  for (const_op_iterator I = idx_begin(), E = idx_end(); I != E; ++I) {
563  if (!isa<ConstantInt>(I))
564  return false;
565  }
566  return true;
567  }
568 
569  unsigned countNonConstantIndices() const {
570  return count_if(indices(), [](const Use& use) {
571  return !isa<ConstantInt>(*use);
572  });
573  }
574 
575  /// Compute the maximum alignment that this GEP is garranteed to preserve.
577 
578  /// Accumulate the constant address offset of this GEP if possible.
579  ///
580  /// This routine accepts an APInt into which it will try to accumulate the
581  /// constant offset of this GEP.
582  ///
583  /// If \p ExternalAnalysis is provided it will be used to calculate a offset
584  /// when a operand of GEP is not constant.
585  /// For example, for a value \p ExternalAnalysis might try to calculate a
586  /// lower bound. If \p ExternalAnalysis is successful, it should return true.
587  ///
588  /// If the \p ExternalAnalysis returns false or the value returned by \p
589  /// ExternalAnalysis results in a overflow/underflow, this routine returns
590  /// false and the value of the offset APInt is undefined (it is *not*
591  /// preserved!).
592  ///
593  /// The APInt passed into this routine must be at exactly as wide as the
594  /// IntPtr type for the address space of the base GEP pointer.
596  const DataLayout &DL, APInt &Offset,
597  function_ref<bool(Value &, APInt &)> ExternalAnalysis = nullptr) const;
598 
599  static bool accumulateConstantOffset(
600  Type *SourceType, ArrayRef<const Value *> Index, const DataLayout &DL,
601  APInt &Offset,
602  function_ref<bool(Value &, APInt &)> ExternalAnalysis = nullptr);
603 
604  /// Collect the offset of this GEP as a map of Values to their associated
605  /// APInt multipliers, as well as a total Constant Offset.
606  bool collectOffset(const DataLayout &DL, unsigned BitWidth,
607  MapVector<Value *, APInt> &VariableOffsets,
608  APInt &ConstantOffset) const;
609 };
610 
612  : public ConcreteOperator<Operator, Instruction::PtrToInt> {
613  friend class PtrToInt;
614  friend class ConstantExpr;
615 
616 public:
618  return getOperand(0);
619  }
620  const Value *getPointerOperand() const {
621  return getOperand(0);
622  }
623 
624  static unsigned getPointerOperandIndex() {
625  return 0U; // get index for modifying correct operand
626  }
627 
628  /// Method to return the pointer operand as a PointerType.
630  return getPointerOperand()->getType();
631  }
632 
633  /// Method to return the address space of the pointer operand.
634  unsigned getPointerAddressSpace() const {
635  return cast<PointerType>(getPointerOperandType())->getAddressSpace();
636  }
637 };
638 
640  : public ConcreteOperator<Operator, Instruction::BitCast> {
641  friend class BitCastInst;
642  friend class ConstantExpr;
643 
644 public:
645  Type *getSrcTy() const {
646  return getOperand(0)->getType();
647  }
648 
649  Type *getDestTy() const {
650  return getType();
651  }
652 };
653 
655  : public ConcreteOperator<Operator, Instruction::AddrSpaceCast> {
656  friend class AddrSpaceCastInst;
657  friend class ConstantExpr;
658 
659 public:
661 
662  const Value *getPointerOperand() const { return getOperand(0); }
663 
664  unsigned getSrcAddressSpace() const {
666  }
667 
668  unsigned getDestAddressSpace() const {
669  return getType()->getPointerAddressSpace();
670  }
671 };
672 
673 } // end namespace llvm
674 
675 #endif // LLVM_IR_OPERATOR_H
use
Move duplicate certain instructions close to their use
Definition: Localizer.cpp:31
llvm
This is an optimization pass for GlobalISel generic memory operations.
Definition: AllocatorList.h:22
llvm::FPMathOperator::isFast
bool isFast() const
Test if this operation allows all non-strict floating-point transforms.
Definition: Operator.h:336
llvm::bitc::NoInfs
@ NoInfs
Definition: LLVMBitCodes.h:474
llvm::FastMathFlags::NoNaNs
@ NoNaNs
Definition: Operator.h:186
llvm::FastMathFlags::getFast
static FastMathFlags getFast()
Definition: Operator.h:196
llvm::FastMathFlags::AllowReciprocal
@ AllowReciprocal
Definition: Operator.h:189
llvm::Operator
This is a utility class that provides an abstraction for the common functionality between Instruction...
Definition: Operator.h:31
llvm::make_range
iterator_range< T > make_range(T x, T y)
Convenience function for iterating over sub-ranges.
Definition: iterator_range.h:53
llvm::PtrToIntOperator::getPointerOperand
const Value * getPointerOperand() const
Definition: Operator.h:620
Optional.h
llvm::Operator::Operator
Operator()=delete
llvm::DataLayout
A parsed version of the target data layout string in and methods for querying it.
Definition: DataLayout.h:113
llvm::GEPOperator::getNumIndices
unsigned getNumIndices() const
Definition: Operator.h:537
llvm::Value::SubclassOptionalData
unsigned char SubclassOptionalData
Hold subclass data that can be dropped.
Definition: Value.h:90
llvm::GEPOperator::hasIndices
bool hasIndices() const
Definition: Operator.h:541
llvm::FastMathFlags::setNoSignedZeros
void setNoSignedZeros(bool B=true)
Definition: Operator.h:230
llvm::GEPOperator::indices
iterator_range< const_op_iterator > indices() const
Definition: Operator.h:510
llvm::Operator::~Operator
~Operator()=delete
llvm::ConcreteOperator::classof
static bool classof(const Instruction *I)
Definition: Operator.h:433
llvm::BitCastInst
This class represents a no-op cast from one type to another.
Definition: Instructions.h:5218
llvm::PossiblyExactOperator::classof
static bool classof(const ConstantExpr *CE)
Definition: Operator.h:152
llvm::Type::getPointerAddressSpace
unsigned getPointerAddressSpace() const
Get the address space of this pointer or pointer vector type.
Definition: DerivedTypes.h:736
MapVector.h
llvm::Type::isFPOrFPVectorTy
bool isFPOrFPVectorTy() const
Return true if this is a FP type or a vector of FP.
Definition: Type.h:178
llvm::GEPOperator::getInRangeIndex
Optional< unsigned > getInRangeIndex() const
Returns the offset of the index with an inrange attachment, or None if none.
Definition: Operator.h:496
llvm::FastMathFlags::AllowContract
@ AllowContract
Definition: Operator.h:190
llvm::Type
The instances of the Type class are immutable: once they are created, they are never changed.
Definition: Type.h:45
llvm::FastMathFlags::setAllowReciprocal
void setAllowReciprocal(bool B=true)
Definition: Operator.h:233
llvm::FastMathFlags::noSignedZeros
bool noSignedZeros() const
Definition: Operator.h:213
llvm::BitCastOperator::getSrcTy
Type * getSrcTy() const
Definition: Operator.h:645
llvm::FastMathFlags::operator!=
bool operator!=(const FastMathFlags &OtherFlags) const
Definition: Operator.h:250
llvm::Optional< unsigned >
llvm::FastMathFlags::operator&=
void operator&=(const FastMathFlags &OtherFlags)
Definition: Operator.h:244
llvm::AddrSpaceCastOperator::getPointerOperand
const Value * getPointerOperand() const
Definition: Operator.h:662
llvm::MapVector
This class implements a map that also provides access to all stored values in a deterministic order.
Definition: MapVector.h:36
Offset
uint64_t Offset
Definition: ELFObjHandler.cpp:80
llvm::FastMathFlags::ApproxFunc
@ ApproxFunc
Definition: Operator.h:191
llvm::OverflowingBinaryOperator::hasNoUnsignedWrap
bool hasNoUnsignedWrap() const
Test whether this operation is known to never undergo unsigned overflow, aka the nuw property.
Definition: Operator.h:95
llvm::FPMathOperator::hasNoNaNs
bool hasNoNaNs() const
Test if this operation's arguments and results are assumed not-NaN.
Definition: Operator.h:352
llvm::FastMathFlags::none
bool none() const
Definition: Operator.h:203
llvm::ArrayType
Class to represent array types.
Definition: DerivedTypes.h:357
llvm::PossiblyExactOperator::classof
static bool classof(const Value *V)
Definition: Operator.h:158
llvm::FastMathFlags
Convenience struct for specifying and reasoning about fast-math flags.
Definition: Operator.h:165
llvm::FastMathFlags::noNaNs
bool noNaNs() const
Definition: Operator.h:211
llvm::count_if
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:1682
llvm::PossiblyExactOperator
A udiv or sdiv instruction, which can be marked as "exact", indicating that no bits are destroyed.
Definition: Operator.h:125
F
#define F(x, y, z)
Definition: MD5.cpp:55
llvm::FPMathOperator::hasNoInfs
bool hasNoInfs() const
Test if this operation's arguments and results are assumed not-infinite.
Definition: Operator.h:357
llvm::FastMathFlags::FastMathFlags
FastMathFlags()=default
llvm::PossiblyExactOperator::isPossiblyExactOpcode
static bool isPossiblyExactOpcode(unsigned OpC)
Definition: Operator.h:145
llvm::PossiblyExactOperator::IsExact
@ IsExact
Definition: Operator.h:128
Instruction.h
llvm::ConstantInt
This is the shared class of boolean and integer constants.
Definition: Constants.h:79
llvm::GEPOperator::idx_begin
const_op_iterator idx_begin() const
Definition: Operator.h:502
llvm::FastMathFlags::setApproxFunc
void setApproxFunc(bool B=true)
Definition: Operator.h:239
llvm::GEPOperator::getResultElementType
Type * getResultElementType() const
Definition: Operator.cpp:54
llvm::FastMathFlags::any
bool any() const
Definition: Operator.h:202
llvm::OverflowingBinaryOperator::classof
static bool classof(const ConstantExpr *CE)
Definition: Operator.h:111
llvm::FastMathFlags::approxFunc
bool approxFunc() const
Definition: Operator.h:216
llvm::AddrSpaceCastInst
This class represents a conversion between pointers from one address space to another.
Definition: Instructions.h:5258
llvm::BitCastOperator
Definition: Operator.h:639
llvm::AddrSpaceCastOperator::getDestAddressSpace
unsigned getDestAddressSpace() const
Definition: Operator.h:668
Constants.h
E
static GCRegistry::Add< CoreCLRGC > E("coreclr", "CoreCLR-compatible GC")
llvm::User
Definition: User.h:44
C
(vector float) vec_cmpeq(*A, *B) C
Definition: README_ALTIVEC.txt:86
llvm::GEPOperator::getPointerOperand
Value * getPointerOperand()
Definition: Operator.h:514
llvm::FastMathFlags::print
void print(raw_ostream &O) const
Print fast-math flags to O.
Definition: Operator.cpp:231
llvm::FastMathFlags::allowReassoc
bool allowReassoc() const
Flag queries.
Definition: Operator.h:210
llvm::ConcreteOperator
A helper template for defining operators for individual opcodes.
Definition: Operator.h:431
llvm::AShrOperator
Definition: Operator.h:464
llvm::FastMathFlags::allowReciprocal
bool allowReciprocal() const
Definition: Operator.h:214
B
static GCRegistry::Add< OcamlGC > B("ocaml", "ocaml 3.10-compatible GC")
llvm::ShlOperator
Definition: Operator.h:454
llvm::Instruction
Definition: Instruction.h:45
llvm::Operator::getOpcode
unsigned getOpcode() const
Return the opcode for this Instruction or ConstantExpr.
Definition: Operator.h:41
llvm::BitCastOperator::getDestTy
Type * getDestTy() const
Definition: Operator.h:649
llvm::raw_ostream
This class implements an extremely fast bulk output stream that can only output to a stream.
Definition: raw_ostream.h:54
llvm::operator<<
raw_ostream & operator<<(raw_ostream &OS, const APFixedPoint &FX)
Definition: APFixedPoint.h:230
llvm::bitc::NoNaNs
@ NoNaNs
Definition: LLVMBitCodes.h:473
llvm::PtrToIntOperator::getPointerOperandIndex
static unsigned getPointerOperandIndex()
Definition: Operator.h:624
llvm::FastMathFlags::operator|=
void operator|=(const FastMathFlags &OtherFlags)
Definition: Operator.h:247
llvm::GEPOperator::getMaxPreservedAlignment
Align getMaxPreservedAlignment(const DataLayout &DL) const
Compute the maximum alignment that this GEP is garranteed to preserve.
Definition: Operator.cpp:60
llvm::LShrOperator
Definition: Operator.h:467
llvm::FPMathOperator::hasNoSignedZeros
bool hasNoSignedZeros() const
Test if this operation can ignore the sign of zero.
Definition: Operator.h:362
llvm::Align
This struct is a compact representation of a valid (non-zero power of two) alignment.
Definition: Alignment.h:39
llvm::MCID::Call
@ Call
Definition: MCInstrDesc.h:153
llvm::AddrSpaceCastOperator::getPointerOperand
Value * getPointerOperand()
Definition: Operator.h:660
llvm::FastMathFlags::setAllowContract
void setAllowContract(bool B=true)
Definition: Operator.h:236
llvm::FPMathOperator::classof
static bool classof(const Value *V)
Definition: Operator.h:392
llvm::None
const NoneType None
Definition: None.h:23
Type.h
llvm::FastMathFlags::set
void set()
Definition: Operator.h:207
llvm::PtrToIntOperator::getPointerOperand
Value * getPointerOperand()
Definition: Operator.h:617
llvm::function_ref
An efficient, type-erasing, non-owning reference to a callable.
Definition: STLFunctionalExtras.h:36
llvm::ConcreteOperator::classof
static bool classof(const Value *V)
Definition: Operator.h:439
llvm::OverflowingBinaryOperator::classof
static bool classof(const Value *V)
Definition: Operator.h:117
llvm::GEPOperator::hasAllZeroIndices
bool hasAllZeroIndices() const
Return true if all of the indices of this GEP are zeros.
Definition: Operator.h:548
llvm::RISCVFenceField::O
@ O
Definition: RISCVBaseInfo.h:207
llvm::OverflowingBinaryOperator::classof
static bool classof(const Instruction *I)
Definition: Operator.h:105
llvm::AddrSpaceCastOperator
Definition: Operator.h:654
llvm::FastMathFlags::noInfs
bool noInfs() const
Definition: Operator.h:212
Index
uint32_t Index
Definition: ELFObjHandler.cpp:83
llvm::ZExtOperator
Definition: Operator.h:471
llvm::Operator::classof
static bool classof(const ConstantExpr *)
Definition: Operator.h:58
llvm::GEPOperator::countNonConstantIndices
unsigned countNonConstantIndices() const
Definition: Operator.h:569
s
multiplies can be turned into SHL s
Definition: README.txt:370
llvm::FPMathOperator::hasAllowReciprocal
bool hasAllowReciprocal() const
Test if this operation can use reciprocal multiply instead of division.
Definition: Operator.h:367
llvm::AddOperator
Definition: Operator.h:445
I
#define I(x, y, z)
Definition: MD5.cpp:58
llvm::UDivOperator
Definition: Operator.h:461
llvm::GetElementPtrInst
an instruction for type-safe pointer arithmetic to access elements of arrays and structs
Definition: Instructions.h:933
llvm::OverflowingBinaryOperator::NoUnsignedWrap
@ NoUnsignedWrap
Definition: Operator.h:75
llvm::FPMathOperator::hasAllowReassoc
bool hasAllowReassoc() const
Test if this operation may be simplified with reassociative transforms.
Definition: Operator.h:347
llvm::FPMathOperator
Utility class for floating point operations which can have information about relaxed accuracy require...
Definition: Operator.h:265
llvm::FastMathFlags::setAllowReassoc
void setAllowReassoc(bool B=true)
Flag setters.
Definition: Operator.h:221
llvm::Operator::hasPoisonGeneratingFlags
bool hasPoisonGeneratingFlags() const
Return true if this operator has flags which may cause this operator to evaluate to poison despite ha...
Definition: Operator.cpp:22
llvm::Operator::getOpcode
static unsigned getOpcode(const Value *V)
If V is an Instruction or ConstantExpr, return its opcode.
Definition: Operator.h:49
llvm::Operator::classof
static bool classof(const Value *V)
Definition: Operator.h:59
llvm::bitc::NoSignedZeros
@ NoSignedZeros
Definition: LLVMBitCodes.h:475
llvm::PtrToIntOperator::getPointerAddressSpace
unsigned getPointerAddressSpace() const
Method to return the address space of the pointer operand.
Definition: Operator.h:634
llvm::GEPOperator
Definition: Operator.h:473
llvm::FPMathOperator::hasApproxFunc
bool hasApproxFunc() const
Test if this operation allows approximations of math library functions or intrinsics.
Definition: Operator.h:378
llvm::APInt
Class for arbitrary precision integers.
Definition: APInt.h:75
llvm::FastMathFlags::NoSignedZeros
@ NoSignedZeros
Definition: Operator.h:188
llvm::GEPOperator::hasAllConstantIndices
bool hasAllConstantIndices() const
Return true if all of the indices of this GEP are constant integers.
Definition: Operator.h:561
llvm::bitc::AllowReassoc
@ AllowReassoc
Definition: LLVMBitCodes.h:479
llvm::OverflowingBinaryOperator::NoSignedWrap
@ NoSignedWrap
Definition: Operator.h:76
llvm::ArrayRef
ArrayRef - Represent a constant reference to an array (0 or more elements consecutively in memory),...
Definition: APInt.h:32
llvm::GEPOperator::indices
iterator_range< op_iterator > indices()
Definition: Operator.h:506
None.h
Mul
BinaryOperator * Mul
Definition: X86PartialReduction.cpp:68
llvm::Value::getType
Type * getType() const
All values are typed, get the type of this value.
Definition: Value.h:255
llvm::Operator::classof
static bool classof(const Instruction *)
Definition: Operator.h:57
DL
MachineBasicBlock MachineBasicBlock::iterator DebugLoc DL
Definition: AArch64SLSHardening.cpp:76
llvm::FastMathFlags::setFast
void setFast(bool B=true)
Definition: Operator.h:242
llvm::GEPOperator::getPointerOperandIndex
static unsigned getPointerOperandIndex()
Definition: Operator.h:520
llvm::OverflowingBinaryOperator
Utility class for integer operators which may exhibit overflow - Add, Sub, Mul, and Shl.
Definition: Operator.h:71
llvm::FPMathOperator::hasAllowContract
bool hasAllowContract() const
Test if this operation can be floating-point contracted (FMA).
Definition: Operator.h:372
llvm::FastMathFlags::setNoInfs
void setNoInfs(bool B=true)
Definition: Operator.h:227
llvm::GEPOperator::getPointerAddressSpace
unsigned getPointerAddressSpace() const
Method to return the address space of the pointer operand.
Definition: Operator.h:533
llvm::MCID::Select
@ Select
Definition: MCInstrDesc.h:162
llvm::FastMathFlags::clear
void clear()
Definition: Operator.h:206
llvm::ConstantExpr
A constant value that is initialized with an expression using other constant values.
Definition: Constants.h:971
llvm::OverflowingBinaryOperator::hasNoSignedWrap
bool hasNoSignedWrap() const
Test whether this operation is known to never undergo signed overflow, aka the nsw property.
Definition: Operator.h:101
llvm::AddrSpaceCastOperator::getSrcAddressSpace
unsigned getSrcAddressSpace() const
Definition: Operator.h:664
llvm::MulOperator
Definition: Operator.h:451
llvm::FPMathOperator::getFastMathFlags
FastMathFlags getFastMathFlags() const
Convenience function for getting all the fast-math flags.
Definition: Operator.h:383
llvm::GEPOperator::isInBounds
bool isInBounds() const
Test whether this is an inbounds GEP, as defined by LangRef.html.
Definition: Operator.h:490
llvm::SubOperator
Definition: Operator.h:448
llvm::PtrToIntOperator::getPointerOperandType
Type * getPointerOperandType() const
Method to return the pointer operand as a PointerType.
Definition: Operator.h:629
llvm::GEPOperator::accumulateConstantOffset
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:87
Casting.h
llvm::FastMathFlags::isFast
bool isFast() const
'Fast' means all bits are set.
Definition: Operator.h:218
llvm::PtrToIntOperator
Definition: Operator.h:611
llvm::BitWidth
constexpr unsigned BitWidth
Definition: BitmaskEnum.h:147
llvm::GEPOperator::collectOffset
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:172
llvm::MCID::Add
@ Add
Definition: MCInstrDesc.h:183
llvm::PtrToIntOperator::PtrToInt
friend class PtrToInt
Definition: Operator.h:613
llvm::ConcreteOperator::classof
static bool classof(const ConstantExpr *CE)
Definition: Operator.h:436
llvm::FastMathFlags::AllowReassoc
@ AllowReassoc
Definition: Operator.h:185
llvm::GEPOperator::getSourceElementType
Type * getSourceElementType() const
Definition: Operator.cpp:48
llvm::User::getNumOperands
unsigned getNumOperands() const
Definition: User.h:191
SuperClass
llvm::FPMathOperator::getFPAccuracy
float getFPAccuracy() const
Get the maximum error permitted by this operation in ULPs.
Definition: Instructions.cpp:2835
llvm::GEPOperator::idx_end
const_op_iterator idx_end() const
Definition: Operator.h:504
llvm::User::op_begin
op_iterator op_begin()
Definition: User.h:234
llvm::PossiblyExactOperator::classof
static bool classof(const Instruction *I)
Definition: Operator.h:155
llvm::SDivOperator
Definition: Operator.h:458
llvm::iterator_range
A range adaptor for a pair of iterators.
Definition: iterator_range.h:30
llvm::FastMathFlags::all
bool all() const
Definition: Operator.h:204
llvm::GEPOperator::getPointerOperand
const Value * getPointerOperand() const
Definition: Operator.h:517
llvm::GEPOperator::idx_begin
op_iterator idx_begin()
Definition: Operator.h:501
llvm::FastMathFlags::NoInfs
@ NoInfs
Definition: Operator.h:187
llvm::FastMathFlags::allowContract
bool allowContract() const
Definition: Operator.h:215
llvm::User::getOperand
Value * getOperand(unsigned i) const
Definition: User.h:169
llvm::bitc::AllowContract
@ AllowContract
Definition: LLVMBitCodes.h:477
llvm::PossiblyExactOperator::isExact
bool isExact() const
Test whether this division is known to be exact, with zero remainder.
Definition: Operator.h:141
Value.h
llvm::GEPOperator::getPointerOperandType
Type * getPointerOperandType() const
Method to return the pointer operand as a PointerType.
Definition: Operator.h:525
llvm::Value
LLVM Value Representation.
Definition: Value.h:74
llvm::OverflowingBinaryOperator::AnyWrap
@ AnyWrap
Definition: Operator.h:74
llvm::FastMathFlags::setNoNaNs
void setNoNaNs(bool B=true)
Definition: Operator.h:224
llvm::bitc::ApproxFunc
@ ApproxFunc
Definition: LLVMBitCodes.h:478
llvm::GEPOperator::idx_end
op_iterator idx_end()
Definition: Operator.h:503
llvm::bitc::AllowReciprocal
@ AllowReciprocal
Definition: LLVMBitCodes.h:476
llvm::Use
A Use represents the edge between a Value definition and its users.
Definition: Use.h:44
llvm::User::op_end
op_iterator op_end()
Definition: User.h:236