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