LLVM  9.0.0svn
InstrTypes.h
Go to the documentation of this file.
1 //===- llvm/InstrTypes.h - Important Instruction subclasses -----*- 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 meta classes of instructions that exist in the VM
10 // representation. Specific concrete subclasses of these may be found in the
11 // i*.h files...
12 //
13 //===----------------------------------------------------------------------===//
14 
15 #ifndef LLVM_IR_INSTRTYPES_H
16 #define LLVM_IR_INSTRTYPES_H
17 
18 #include "llvm/ADT/ArrayRef.h"
19 #include "llvm/ADT/None.h"
20 #include "llvm/ADT/Optional.h"
21 #include "llvm/ADT/STLExtras.h"
22 #include "llvm/ADT/StringMap.h"
23 #include "llvm/ADT/StringRef.h"
24 #include "llvm/ADT/Twine.h"
26 #include "llvm/IR/Attributes.h"
27 #include "llvm/IR/CallingConv.h"
28 #include "llvm/IR/Constants.h"
29 #include "llvm/IR/DerivedTypes.h"
30 #include "llvm/IR/Function.h"
31 #include "llvm/IR/Instruction.h"
32 #include "llvm/IR/LLVMContext.h"
33 #include "llvm/IR/OperandTraits.h"
34 #include "llvm/IR/Type.h"
35 #include "llvm/IR/User.h"
36 #include "llvm/IR/Value.h"
37 #include "llvm/Support/Casting.h"
39 #include <algorithm>
40 #include <cassert>
41 #include <cstddef>
42 #include <cstdint>
43 #include <iterator>
44 #include <string>
45 #include <vector>
46 
47 namespace llvm {
48 
49 namespace Intrinsic {
50 enum ID : unsigned;
51 }
52 
53 //===----------------------------------------------------------------------===//
54 // UnaryInstruction Class
55 //===----------------------------------------------------------------------===//
56 
57 class UnaryInstruction : public Instruction {
58 protected:
59  UnaryInstruction(Type *Ty, unsigned iType, Value *V,
60  Instruction *IB = nullptr)
61  : Instruction(Ty, iType, &Op<0>(), 1, IB) {
62  Op<0>() = V;
63  }
64  UnaryInstruction(Type *Ty, unsigned iType, Value *V, BasicBlock *IAE)
65  : Instruction(Ty, iType, &Op<0>(), 1, IAE) {
66  Op<0>() = V;
67  }
68 
69 public:
70  // allocate space for exactly one operand
71  void *operator new(size_t s) {
72  return User::operator new(s, 1);
73  }
74 
75  /// Transparently provide more efficient getOperand methods.
77 
78  // Methods for support type inquiry through isa, cast, and dyn_cast:
79  static bool classof(const Instruction *I) {
80  return I->getOpcode() == Instruction::Alloca ||
81  I->getOpcode() == Instruction::Load ||
82  I->getOpcode() == Instruction::VAArg ||
83  I->getOpcode() == Instruction::ExtractValue ||
84  (I->getOpcode() >= CastOpsBegin && I->getOpcode() < CastOpsEnd);
85  }
86  static bool classof(const Value *V) {
87  return isa<Instruction>(V) && classof(cast<Instruction>(V));
88  }
89 };
90 
91 template <>
93  public FixedNumOperandTraits<UnaryInstruction, 1> {
94 };
95 
97 
98 //===----------------------------------------------------------------------===//
99 // UnaryOperator Class
100 //===----------------------------------------------------------------------===//
101 
102 class UnaryOperator : public UnaryInstruction {
103  void AssertOK();
104 
105 protected:
106  UnaryOperator(UnaryOps iType, Value *S, Type *Ty,
107  const Twine &Name, Instruction *InsertBefore);
108  UnaryOperator(UnaryOps iType, Value *S, Type *Ty,
109  const Twine &Name, BasicBlock *InsertAtEnd);
110 
111  // Note: Instruction needs to be a friend here to call cloneImpl.
112  friend class Instruction;
113 
114  UnaryOperator *cloneImpl() const;
115 
116 public:
117 
118  /// Construct a unary instruction, given the opcode and an operand.
119  /// Optionally (if InstBefore is specified) insert the instruction
120  /// into a BasicBlock right before the specified instruction. The specified
121  /// Instruction is allowed to be a dereferenced end iterator.
122  ///
123  static UnaryOperator *Create(UnaryOps Op, Value *S,
124  const Twine &Name = Twine(),
125  Instruction *InsertBefore = nullptr);
126 
127  /// Construct a unary instruction, given the opcode and an operand.
128  /// Also automatically insert this instruction to the end of the
129  /// BasicBlock specified.
130  ///
131  static UnaryOperator *Create(UnaryOps Op, Value *S,
132  const Twine &Name,
133  BasicBlock *InsertAtEnd);
134 
135  /// These methods just forward to Create, and are useful when you
136  /// statically know what type of instruction you're going to create. These
137  /// helpers just save some typing.
138 #define HANDLE_UNARY_INST(N, OPC, CLASS) \
139  static UnaryOperator *Create##OPC(Value *V, const Twine &Name = "") {\
140  return Create(Instruction::OPC, V, Name);\
141  }
142 #include "llvm/IR/Instruction.def"
143 #define HANDLE_UNARY_INST(N, OPC, CLASS) \
144  static UnaryOperator *Create##OPC(Value *V, const Twine &Name, \
145  BasicBlock *BB) {\
146  return Create(Instruction::OPC, V, Name, BB);\
147  }
148 #include "llvm/IR/Instruction.def"
149 #define HANDLE_UNARY_INST(N, OPC, CLASS) \
150  static UnaryOperator *Create##OPC(Value *V, const Twine &Name, \
151  Instruction *I) {\
152  return Create(Instruction::OPC, V, Name, I);\
153  }
154 #include "llvm/IR/Instruction.def"
155 
156  UnaryOps getOpcode() const {
157  return static_cast<UnaryOps>(Instruction::getOpcode());
158  }
159 };
160 
161 //===----------------------------------------------------------------------===//
162 // BinaryOperator Class
163 //===----------------------------------------------------------------------===//
164 
165 class BinaryOperator : public Instruction {
166  void AssertOK();
167 
168 protected:
169  BinaryOperator(BinaryOps iType, Value *S1, Value *S2, Type *Ty,
170  const Twine &Name, Instruction *InsertBefore);
171  BinaryOperator(BinaryOps iType, Value *S1, Value *S2, Type *Ty,
172  const Twine &Name, BasicBlock *InsertAtEnd);
173 
174  // Note: Instruction needs to be a friend here to call cloneImpl.
175  friend class Instruction;
176 
177  BinaryOperator *cloneImpl() const;
178 
179 public:
180  // allocate space for exactly two operands
181  void *operator new(size_t s) {
182  return User::operator new(s, 2);
183  }
184 
185  /// Transparently provide more efficient getOperand methods.
187 
188  /// Construct a binary instruction, given the opcode and the two
189  /// operands. Optionally (if InstBefore is specified) insert the instruction
190  /// into a BasicBlock right before the specified instruction. The specified
191  /// Instruction is allowed to be a dereferenced end iterator.
192  ///
193  static BinaryOperator *Create(BinaryOps Op, Value *S1, Value *S2,
194  const Twine &Name = Twine(),
195  Instruction *InsertBefore = nullptr);
196 
197  /// Construct a binary instruction, given the opcode and the two
198  /// operands. Also automatically insert this instruction to the end of the
199  /// BasicBlock specified.
200  ///
201  static BinaryOperator *Create(BinaryOps Op, Value *S1, Value *S2,
202  const Twine &Name, BasicBlock *InsertAtEnd);
203 
204  /// These methods just forward to Create, and are useful when you
205  /// statically know what type of instruction you're going to create. These
206  /// helpers just save some typing.
207 #define HANDLE_BINARY_INST(N, OPC, CLASS) \
208  static BinaryOperator *Create##OPC(Value *V1, Value *V2, \
209  const Twine &Name = "") {\
210  return Create(Instruction::OPC, V1, V2, Name);\
211  }
212 #include "llvm/IR/Instruction.def"
213 #define HANDLE_BINARY_INST(N, OPC, CLASS) \
214  static BinaryOperator *Create##OPC(Value *V1, Value *V2, \
215  const Twine &Name, BasicBlock *BB) {\
216  return Create(Instruction::OPC, V1, V2, Name, BB);\
217  }
218 #include "llvm/IR/Instruction.def"
219 #define HANDLE_BINARY_INST(N, OPC, CLASS) \
220  static BinaryOperator *Create##OPC(Value *V1, Value *V2, \
221  const Twine &Name, Instruction *I) {\
222  return Create(Instruction::OPC, V1, V2, Name, I);\
223  }
224 #include "llvm/IR/Instruction.def"
225 
227  Value *V1, Value *V2,
228  BinaryOperator *CopyBO,
229  const Twine &Name = "") {
230  BinaryOperator *BO = Create(Opc, V1, V2, Name);
231  BO->copyIRFlags(CopyBO);
232  return BO;
233  }
234 
236  BinaryOperator *FMFSource,
237  const Twine &Name = "") {
238  return CreateWithCopiedFlags(Instruction::FAdd, V1, V2, FMFSource, Name);
239  }
241  BinaryOperator *FMFSource,
242  const Twine &Name = "") {
243  return CreateWithCopiedFlags(Instruction::FSub, V1, V2, FMFSource, Name);
244  }
246  BinaryOperator *FMFSource,
247  const Twine &Name = "") {
248  return CreateWithCopiedFlags(Instruction::FMul, V1, V2, FMFSource, Name);
249  }
251  BinaryOperator *FMFSource,
252  const Twine &Name = "") {
253  return CreateWithCopiedFlags(Instruction::FDiv, V1, V2, FMFSource, Name);
254  }
256  BinaryOperator *FMFSource,
257  const Twine &Name = "") {
258  return CreateWithCopiedFlags(Instruction::FRem, V1, V2, FMFSource, Name);
259  }
261  const Twine &Name = "") {
263  return CreateWithCopiedFlags(Instruction::FSub, Zero, Op, FMFSource);
264  }
265 
267  const Twine &Name = "") {
268  BinaryOperator *BO = Create(Opc, V1, V2, Name);
269  BO->setHasNoSignedWrap(true);
270  return BO;
271  }
273  const Twine &Name, BasicBlock *BB) {
274  BinaryOperator *BO = Create(Opc, V1, V2, Name, BB);
275  BO->setHasNoSignedWrap(true);
276  return BO;
277  }
279  const Twine &Name, Instruction *I) {
280  BinaryOperator *BO = Create(Opc, V1, V2, Name, I);
281  BO->setHasNoSignedWrap(true);
282  return BO;
283  }
284 
286  const Twine &Name = "") {
287  BinaryOperator *BO = Create(Opc, V1, V2, Name);
288  BO->setHasNoUnsignedWrap(true);
289  return BO;
290  }
292  const Twine &Name, BasicBlock *BB) {
293  BinaryOperator *BO = Create(Opc, V1, V2, Name, BB);
294  BO->setHasNoUnsignedWrap(true);
295  return BO;
296  }
298  const Twine &Name, Instruction *I) {
299  BinaryOperator *BO = Create(Opc, V1, V2, Name, I);
300  BO->setHasNoUnsignedWrap(true);
301  return BO;
302  }
303 
305  const Twine &Name = "") {
306  BinaryOperator *BO = Create(Opc, V1, V2, Name);
307  BO->setIsExact(true);
308  return BO;
309  }
311  const Twine &Name, BasicBlock *BB) {
312  BinaryOperator *BO = Create(Opc, V1, V2, Name, BB);
313  BO->setIsExact(true);
314  return BO;
315  }
317  const Twine &Name, Instruction *I) {
318  BinaryOperator *BO = Create(Opc, V1, V2, Name, I);
319  BO->setIsExact(true);
320  return BO;
321  }
322 
323 #define DEFINE_HELPERS(OPC, NUWNSWEXACT) \
324  static BinaryOperator *Create##NUWNSWEXACT##OPC(Value *V1, Value *V2, \
325  const Twine &Name = "") { \
326  return Create##NUWNSWEXACT(Instruction::OPC, V1, V2, Name); \
327  } \
328  static BinaryOperator *Create##NUWNSWEXACT##OPC( \
329  Value *V1, Value *V2, const Twine &Name, BasicBlock *BB) { \
330  return Create##NUWNSWEXACT(Instruction::OPC, V1, V2, Name, BB); \
331  } \
332  static BinaryOperator *Create##NUWNSWEXACT##OPC( \
333  Value *V1, Value *V2, const Twine &Name, Instruction *I) { \
334  return Create##NUWNSWEXACT(Instruction::OPC, V1, V2, Name, I); \
335  }
336 
337  DEFINE_HELPERS(Add, NSW) // CreateNSWAdd
338  DEFINE_HELPERS(Add, NUW) // CreateNUWAdd
339  DEFINE_HELPERS(Sub, NSW) // CreateNSWSub
340  DEFINE_HELPERS(Sub, NUW) // CreateNUWSub
341  DEFINE_HELPERS(Mul, NSW) // CreateNSWMul
342  DEFINE_HELPERS(Mul, NUW) // CreateNUWMul
343  DEFINE_HELPERS(Shl, NSW) // CreateNSWShl
344  DEFINE_HELPERS(Shl, NUW) // CreateNUWShl
345 
346  DEFINE_HELPERS(SDiv, Exact) // CreateExactSDiv
347  DEFINE_HELPERS(UDiv, Exact) // CreateExactUDiv
348  DEFINE_HELPERS(AShr, Exact) // CreateExactAShr
349  DEFINE_HELPERS(LShr, Exact) // CreateExactLShr
350 
351 #undef DEFINE_HELPERS
352 
353  /// Helper functions to construct and inspect unary operations (NEG and NOT)
354  /// via binary operators SUB and XOR:
355  ///
356  /// Create the NEG and NOT instructions out of SUB and XOR instructions.
357  ///
358  static BinaryOperator *CreateNeg(Value *Op, const Twine &Name = "",
359  Instruction *InsertBefore = nullptr);
360  static BinaryOperator *CreateNeg(Value *Op, const Twine &Name,
361  BasicBlock *InsertAtEnd);
362  static BinaryOperator *CreateNSWNeg(Value *Op, const Twine &Name = "",
363  Instruction *InsertBefore = nullptr);
364  static BinaryOperator *CreateNSWNeg(Value *Op, const Twine &Name,
365  BasicBlock *InsertAtEnd);
366  static BinaryOperator *CreateNUWNeg(Value *Op, const Twine &Name = "",
367  Instruction *InsertBefore = nullptr);
368  static BinaryOperator *CreateNUWNeg(Value *Op, const Twine &Name,
369  BasicBlock *InsertAtEnd);
370  static BinaryOperator *CreateFNeg(Value *Op, const Twine &Name = "",
371  Instruction *InsertBefore = nullptr);
372  static BinaryOperator *CreateFNeg(Value *Op, const Twine &Name,
373  BasicBlock *InsertAtEnd);
374  static BinaryOperator *CreateNot(Value *Op, const Twine &Name = "",
375  Instruction *InsertBefore = nullptr);
376  static BinaryOperator *CreateNot(Value *Op, const Twine &Name,
377  BasicBlock *InsertAtEnd);
378 
380  return static_cast<BinaryOps>(Instruction::getOpcode());
381  }
382 
383  /// Exchange the two operands to this instruction.
384  /// This instruction is safe to use on any binary instruction and
385  /// does not modify the semantics of the instruction. If the instruction
386  /// cannot be reversed (ie, it's a Div), then return true.
387  ///
388  bool swapOperands();
389 
390  // Methods for support type inquiry through isa, cast, and dyn_cast:
391  static bool classof(const Instruction *I) {
392  return I->isBinaryOp();
393  }
394  static bool classof(const Value *V) {
395  return isa<Instruction>(V) && classof(cast<Instruction>(V));
396  }
397 };
398 
399 template <>
401  public FixedNumOperandTraits<BinaryOperator, 2> {
402 };
403 
405 
406 //===----------------------------------------------------------------------===//
407 // CastInst Class
408 //===----------------------------------------------------------------------===//
409 
410 /// This is the base class for all instructions that perform data
411 /// casts. It is simply provided so that instruction category testing
412 /// can be performed with code like:
413 ///
414 /// if (isa<CastInst>(Instr)) { ... }
415 /// Base class of casting instructions.
416 class CastInst : public UnaryInstruction {
417 protected:
418  /// Constructor with insert-before-instruction semantics for subclasses
419  CastInst(Type *Ty, unsigned iType, Value *S,
420  const Twine &NameStr = "", Instruction *InsertBefore = nullptr)
421  : UnaryInstruction(Ty, iType, S, InsertBefore) {
422  setName(NameStr);
423  }
424  /// Constructor with insert-at-end-of-block semantics for subclasses
425  CastInst(Type *Ty, unsigned iType, Value *S,
426  const Twine &NameStr, BasicBlock *InsertAtEnd)
427  : UnaryInstruction(Ty, iType, S, InsertAtEnd) {
428  setName(NameStr);
429  }
430 
431 public:
432  /// Provides a way to construct any of the CastInst subclasses using an
433  /// opcode instead of the subclass's constructor. The opcode must be in the
434  /// CastOps category (Instruction::isCast(opcode) returns true). This
435  /// constructor has insert-before-instruction semantics to automatically
436  /// insert the new CastInst before InsertBefore (if it is non-null).
437  /// Construct any of the CastInst subclasses
438  static CastInst *Create(
439  Instruction::CastOps, ///< The opcode of the cast instruction
440  Value *S, ///< The value to be casted (operand 0)
441  Type *Ty, ///< The type to which cast should be made
442  const Twine &Name = "", ///< Name for the instruction
443  Instruction *InsertBefore = nullptr ///< Place to insert the instruction
444  );
445  /// Provides a way to construct any of the CastInst subclasses using an
446  /// opcode instead of the subclass's constructor. The opcode must be in the
447  /// CastOps category. This constructor has insert-at-end-of-block semantics
448  /// to automatically insert the new CastInst at the end of InsertAtEnd (if
449  /// its non-null).
450  /// Construct any of the CastInst subclasses
451  static CastInst *Create(
452  Instruction::CastOps, ///< The opcode for the cast instruction
453  Value *S, ///< The value to be casted (operand 0)
454  Type *Ty, ///< The type to which operand is casted
455  const Twine &Name, ///< The name for the instruction
456  BasicBlock *InsertAtEnd ///< The block to insert the instruction into
457  );
458 
459  /// Create a ZExt or BitCast cast instruction
460  static CastInst *CreateZExtOrBitCast(
461  Value *S, ///< The value to be casted (operand 0)
462  Type *Ty, ///< The type to which cast should be made
463  const Twine &Name = "", ///< Name for the instruction
464  Instruction *InsertBefore = nullptr ///< Place to insert the instruction
465  );
466 
467  /// Create a ZExt or BitCast cast instruction
468  static CastInst *CreateZExtOrBitCast(
469  Value *S, ///< The value to be casted (operand 0)
470  Type *Ty, ///< The type to which operand is casted
471  const Twine &Name, ///< The name for the instruction
472  BasicBlock *InsertAtEnd ///< The block to insert the instruction into
473  );
474 
475  /// Create a SExt or BitCast cast instruction
476  static CastInst *CreateSExtOrBitCast(
477  Value *S, ///< The value to be casted (operand 0)
478  Type *Ty, ///< The type to which cast should be made
479  const Twine &Name = "", ///< Name for the instruction
480  Instruction *InsertBefore = nullptr ///< Place to insert the instruction
481  );
482 
483  /// Create a SExt or BitCast cast instruction
484  static CastInst *CreateSExtOrBitCast(
485  Value *S, ///< The value to be casted (operand 0)
486  Type *Ty, ///< The type to which operand is casted
487  const Twine &Name, ///< The name for the instruction
488  BasicBlock *InsertAtEnd ///< The block to insert the instruction into
489  );
490 
491  /// Create a BitCast AddrSpaceCast, or a PtrToInt cast instruction.
492  static CastInst *CreatePointerCast(
493  Value *S, ///< The pointer value to be casted (operand 0)
494  Type *Ty, ///< The type to which operand is casted
495  const Twine &Name, ///< The name for the instruction
496  BasicBlock *InsertAtEnd ///< The block to insert the instruction into
497  );
498 
499  /// Create a BitCast, AddrSpaceCast or a PtrToInt cast instruction.
500  static CastInst *CreatePointerCast(
501  Value *S, ///< The pointer value to be casted (operand 0)
502  Type *Ty, ///< The type to which cast should be made
503  const Twine &Name = "", ///< Name for the instruction
504  Instruction *InsertBefore = nullptr ///< Place to insert the instruction
505  );
506 
507  /// Create a BitCast or an AddrSpaceCast cast instruction.
508  static CastInst *CreatePointerBitCastOrAddrSpaceCast(
509  Value *S, ///< The pointer value to be casted (operand 0)
510  Type *Ty, ///< The type to which operand is casted
511  const Twine &Name, ///< The name for the instruction
512  BasicBlock *InsertAtEnd ///< The block to insert the instruction into
513  );
514 
515  /// Create a BitCast or an AddrSpaceCast cast instruction.
516  static CastInst *CreatePointerBitCastOrAddrSpaceCast(
517  Value *S, ///< The pointer value to be casted (operand 0)
518  Type *Ty, ///< The type to which cast should be made
519  const Twine &Name = "", ///< Name for the instruction
520  Instruction *InsertBefore = nullptr ///< Place to insert the instruction
521  );
522 
523  /// Create a BitCast, a PtrToInt, or an IntToPTr cast instruction.
524  ///
525  /// If the value is a pointer type and the destination an integer type,
526  /// creates a PtrToInt cast. If the value is an integer type and the
527  /// destination a pointer type, creates an IntToPtr cast. Otherwise, creates
528  /// a bitcast.
529  static CastInst *CreateBitOrPointerCast(
530  Value *S, ///< The pointer value to be casted (operand 0)
531  Type *Ty, ///< The type to which cast should be made
532  const Twine &Name = "", ///< Name for the instruction
533  Instruction *InsertBefore = nullptr ///< Place to insert the instruction
534  );
535 
536  /// Create a ZExt, BitCast, or Trunc for int -> int casts.
537  static CastInst *CreateIntegerCast(
538  Value *S, ///< The pointer value to be casted (operand 0)
539  Type *Ty, ///< The type to which cast should be made
540  bool isSigned, ///< Whether to regard S as signed or not
541  const Twine &Name = "", ///< Name for the instruction
542  Instruction *InsertBefore = nullptr ///< Place to insert the instruction
543  );
544 
545  /// Create a ZExt, BitCast, or Trunc for int -> int casts.
546  static CastInst *CreateIntegerCast(
547  Value *S, ///< The integer value to be casted (operand 0)
548  Type *Ty, ///< The integer type to which operand is casted
549  bool isSigned, ///< Whether to regard S as signed or not
550  const Twine &Name, ///< The name for the instruction
551  BasicBlock *InsertAtEnd ///< The block to insert the instruction into
552  );
553 
554  /// Create an FPExt, BitCast, or FPTrunc for fp -> fp casts
555  static CastInst *CreateFPCast(
556  Value *S, ///< The floating point value to be casted
557  Type *Ty, ///< The floating point type to cast to
558  const Twine &Name = "", ///< Name for the instruction
559  Instruction *InsertBefore = nullptr ///< Place to insert the instruction
560  );
561 
562  /// Create an FPExt, BitCast, or FPTrunc for fp -> fp casts
563  static CastInst *CreateFPCast(
564  Value *S, ///< The floating point value to be casted
565  Type *Ty, ///< The floating point type to cast to
566  const Twine &Name, ///< The name for the instruction
567  BasicBlock *InsertAtEnd ///< The block to insert the instruction into
568  );
569 
570  /// Create a Trunc or BitCast cast instruction
571  static CastInst *CreateTruncOrBitCast(
572  Value *S, ///< The value to be casted (operand 0)
573  Type *Ty, ///< The type to which cast should be made
574  const Twine &Name = "", ///< Name for the instruction
575  Instruction *InsertBefore = nullptr ///< Place to insert the instruction
576  );
577 
578  /// Create a Trunc or BitCast cast instruction
579  static CastInst *CreateTruncOrBitCast(
580  Value *S, ///< The value to be casted (operand 0)
581  Type *Ty, ///< The type to which operand is casted
582  const Twine &Name, ///< The name for the instruction
583  BasicBlock *InsertAtEnd ///< The block to insert the instruction into
584  );
585 
586  /// Check whether it is valid to call getCastOpcode for these types.
587  static bool isCastable(
588  Type *SrcTy, ///< The Type from which the value should be cast.
589  Type *DestTy ///< The Type to which the value should be cast.
590  );
591 
592  /// Check whether a bitcast between these types is valid
593  static bool isBitCastable(
594  Type *SrcTy, ///< The Type from which the value should be cast.
595  Type *DestTy ///< The Type to which the value should be cast.
596  );
597 
598  /// Check whether a bitcast, inttoptr, or ptrtoint cast between these
599  /// types is valid and a no-op.
600  ///
601  /// This ensures that any pointer<->integer cast has enough bits in the
602  /// integer and any other cast is a bitcast.
603  static bool isBitOrNoopPointerCastable(
604  Type *SrcTy, ///< The Type from which the value should be cast.
605  Type *DestTy, ///< The Type to which the value should be cast.
606  const DataLayout &DL);
607 
608  /// Returns the opcode necessary to cast Val into Ty using usual casting
609  /// rules.
610  /// Infer the opcode for cast operand and type
611  static Instruction::CastOps getCastOpcode(
612  const Value *Val, ///< The value to cast
613  bool SrcIsSigned, ///< Whether to treat the source as signed
614  Type *Ty, ///< The Type to which the value should be casted
615  bool DstIsSigned ///< Whether to treate the dest. as signed
616  );
617 
618  /// There are several places where we need to know if a cast instruction
619  /// only deals with integer source and destination types. To simplify that
620  /// logic, this method is provided.
621  /// @returns true iff the cast has only integral typed operand and dest type.
622  /// Determine if this is an integer-only cast.
623  bool isIntegerCast() const;
624 
625  /// A lossless cast is one that does not alter the basic value. It implies
626  /// a no-op cast but is more stringent, preventing things like int->float,
627  /// long->double, or int->ptr.
628  /// @returns true iff the cast is lossless.
629  /// Determine if this is a lossless cast.
630  bool isLosslessCast() const;
631 
632  /// A no-op cast is one that can be effected without changing any bits.
633  /// It implies that the source and destination types are the same size. The
634  /// DataLayout argument is to determine the pointer size when examining casts
635  /// involving Integer and Pointer types. They are no-op casts if the integer
636  /// is the same size as the pointer. However, pointer size varies with
637  /// platform.
638  /// Determine if the described cast is a no-op cast.
639  static bool isNoopCast(
640  Instruction::CastOps Opcode, ///< Opcode of cast
641  Type *SrcTy, ///< SrcTy of cast
642  Type *DstTy, ///< DstTy of cast
643  const DataLayout &DL ///< DataLayout to get the Int Ptr type from.
644  );
645 
646  /// Determine if this cast is a no-op cast.
647  ///
648  /// \param DL is the DataLayout to determine pointer size.
649  bool isNoopCast(const DataLayout &DL) const;
650 
651  /// Determine how a pair of casts can be eliminated, if they can be at all.
652  /// This is a helper function for both CastInst and ConstantExpr.
653  /// @returns 0 if the CastInst pair can't be eliminated, otherwise
654  /// returns Instruction::CastOps value for a cast that can replace
655  /// the pair, casting SrcTy to DstTy.
656  /// Determine if a cast pair is eliminable
657  static unsigned isEliminableCastPair(
658  Instruction::CastOps firstOpcode, ///< Opcode of first cast
659  Instruction::CastOps secondOpcode, ///< Opcode of second cast
660  Type *SrcTy, ///< SrcTy of 1st cast
661  Type *MidTy, ///< DstTy of 1st cast & SrcTy of 2nd cast
662  Type *DstTy, ///< DstTy of 2nd cast
663  Type *SrcIntPtrTy, ///< Integer type corresponding to Ptr SrcTy, or null
664  Type *MidIntPtrTy, ///< Integer type corresponding to Ptr MidTy, or null
665  Type *DstIntPtrTy ///< Integer type corresponding to Ptr DstTy, or null
666  );
667 
668  /// Return the opcode of this CastInst
671  }
672 
673  /// Return the source type, as a convenience
674  Type* getSrcTy() const { return getOperand(0)->getType(); }
675  /// Return the destination type, as a convenience
676  Type* getDestTy() const { return getType(); }
677 
678  /// This method can be used to determine if a cast from S to DstTy using
679  /// Opcode op is valid or not.
680  /// @returns true iff the proposed cast is valid.
681  /// Determine if a cast is valid without creating one.
682  static bool castIsValid(Instruction::CastOps op, Value *S, Type *DstTy);
683 
684  /// Methods for support type inquiry through isa, cast, and dyn_cast:
685  static bool classof(const Instruction *I) {
686  return I->isCast();
687  }
688  static bool classof(const Value *V) {
689  return isa<Instruction>(V) && classof(cast<Instruction>(V));
690  }
691 };
692 
693 //===----------------------------------------------------------------------===//
694 // CmpInst Class
695 //===----------------------------------------------------------------------===//
696 
697 /// This class is the base class for the comparison instructions.
698 /// Abstract base class of comparison instructions.
699 class CmpInst : public Instruction {
700 public:
701  /// This enumeration lists the possible predicates for CmpInst subclasses.
702  /// Values in the range 0-31 are reserved for FCmpInst, while values in the
703  /// range 32-64 are reserved for ICmpInst. This is necessary to ensure the
704  /// predicate values are not overlapping between the classes.
705  ///
706  /// Some passes (e.g. InstCombine) depend on the bit-wise characteristics of
707  /// FCMP_* values. Changing the bit patterns requires a potential change to
708  /// those passes.
709  enum Predicate {
710  // Opcode U L G E Intuitive operation
711  FCMP_FALSE = 0, ///< 0 0 0 0 Always false (always folded)
712  FCMP_OEQ = 1, ///< 0 0 0 1 True if ordered and equal
713  FCMP_OGT = 2, ///< 0 0 1 0 True if ordered and greater than
714  FCMP_OGE = 3, ///< 0 0 1 1 True if ordered and greater than or equal
715  FCMP_OLT = 4, ///< 0 1 0 0 True if ordered and less than
716  FCMP_OLE = 5, ///< 0 1 0 1 True if ordered and less than or equal
717  FCMP_ONE = 6, ///< 0 1 1 0 True if ordered and operands are unequal
718  FCMP_ORD = 7, ///< 0 1 1 1 True if ordered (no nans)
719  FCMP_UNO = 8, ///< 1 0 0 0 True if unordered: isnan(X) | isnan(Y)
720  FCMP_UEQ = 9, ///< 1 0 0 1 True if unordered or equal
721  FCMP_UGT = 10, ///< 1 0 1 0 True if unordered or greater than
722  FCMP_UGE = 11, ///< 1 0 1 1 True if unordered, greater than, or equal
723  FCMP_ULT = 12, ///< 1 1 0 0 True if unordered or less than
724  FCMP_ULE = 13, ///< 1 1 0 1 True if unordered, less than, or equal
725  FCMP_UNE = 14, ///< 1 1 1 0 True if unordered or not equal
726  FCMP_TRUE = 15, ///< 1 1 1 1 Always true (always folded)
727  FIRST_FCMP_PREDICATE = FCMP_FALSE,
728  LAST_FCMP_PREDICATE = FCMP_TRUE,
729  BAD_FCMP_PREDICATE = FCMP_TRUE + 1,
730  ICMP_EQ = 32, ///< equal
731  ICMP_NE = 33, ///< not equal
732  ICMP_UGT = 34, ///< unsigned greater than
733  ICMP_UGE = 35, ///< unsigned greater or equal
734  ICMP_ULT = 36, ///< unsigned less than
735  ICMP_ULE = 37, ///< unsigned less or equal
736  ICMP_SGT = 38, ///< signed greater than
737  ICMP_SGE = 39, ///< signed greater or equal
738  ICMP_SLT = 40, ///< signed less than
739  ICMP_SLE = 41, ///< signed less or equal
740  FIRST_ICMP_PREDICATE = ICMP_EQ,
741  LAST_ICMP_PREDICATE = ICMP_SLE,
742  BAD_ICMP_PREDICATE = ICMP_SLE + 1
743  };
744 
745 protected:
747  Value *LHS, Value *RHS, const Twine &Name = "",
748  Instruction *InsertBefore = nullptr,
749  Instruction *FlagsSource = nullptr);
750 
752  Value *LHS, Value *RHS, const Twine &Name,
753  BasicBlock *InsertAtEnd);
754 
755 public:
756  // allocate space for exactly two operands
757  void *operator new(size_t s) {
758  return User::operator new(s, 2);
759  }
760 
761  /// Construct a compare instruction, given the opcode, the predicate and
762  /// the two operands. Optionally (if InstBefore is specified) insert the
763  /// instruction into a BasicBlock right before the specified instruction.
764  /// The specified Instruction is allowed to be a dereferenced end iterator.
765  /// Create a CmpInst
766  static CmpInst *Create(OtherOps Op,
767  Predicate predicate, Value *S1,
768  Value *S2, const Twine &Name = "",
769  Instruction *InsertBefore = nullptr);
770 
771  /// Construct a compare instruction, given the opcode, the predicate and the
772  /// two operands. Also automatically insert this instruction to the end of
773  /// the BasicBlock specified.
774  /// Create a CmpInst
775  static CmpInst *Create(OtherOps Op, Predicate predicate, Value *S1,
776  Value *S2, const Twine &Name, BasicBlock *InsertAtEnd);
777 
778  /// Get the opcode casted to the right type
779  OtherOps getOpcode() const {
780  return static_cast<OtherOps>(Instruction::getOpcode());
781  }
782 
783  /// Return the predicate for this instruction.
785  return Predicate(getSubclassDataFromInstruction());
786  }
787 
788  /// Set the predicate for this instruction to the specified value.
789  void setPredicate(Predicate P) { setInstructionSubclassData(P); }
790 
791  static bool isFPPredicate(Predicate P) {
792  return P >= FIRST_FCMP_PREDICATE && P <= LAST_FCMP_PREDICATE;
793  }
794 
795  static bool isIntPredicate(Predicate P) {
796  return P >= FIRST_ICMP_PREDICATE && P <= LAST_ICMP_PREDICATE;
797  }
798 
799  static StringRef getPredicateName(Predicate P);
800 
801  bool isFPPredicate() const { return isFPPredicate(getPredicate()); }
802  bool isIntPredicate() const { return isIntPredicate(getPredicate()); }
803 
804  /// For example, EQ -> NE, UGT -> ULE, SLT -> SGE,
805  /// OEQ -> UNE, UGT -> OLE, OLT -> UGE, etc.
806  /// @returns the inverse predicate for the instruction's current predicate.
807  /// Return the inverse of the instruction's predicate.
809  return getInversePredicate(getPredicate());
810  }
811 
812  /// For example, EQ -> NE, UGT -> ULE, SLT -> SGE,
813  /// OEQ -> UNE, UGT -> OLE, OLT -> UGE, etc.
814  /// @returns the inverse predicate for predicate provided in \p pred.
815  /// Return the inverse of a given predicate
816  static Predicate getInversePredicate(Predicate pred);
817 
818  /// For example, EQ->EQ, SLE->SGE, ULT->UGT,
819  /// OEQ->OEQ, ULE->UGE, OLT->OGT, etc.
820  /// @returns the predicate that would be the result of exchanging the two
821  /// operands of the CmpInst instruction without changing the result
822  /// produced.
823  /// Return the predicate as if the operands were swapped
826  }
827 
828  /// This is a static version that you can use without an instruction
829  /// available.
830  /// Return the predicate as if the operands were swapped.
832 
833  /// For predicate of kind "is X or equal to 0" returns the predicate "is X".
834  /// For predicate of kind "is X" returns the predicate "is X or equal to 0".
835  /// does not support other kind of predicates.
836  /// @returns the predicate that does not contains is equal to zero if
837  /// it had and vice versa.
838  /// Return the flipped strictness of predicate
840  return getFlippedStrictnessPredicate(getPredicate());
841  }
842 
843  /// This is a static version that you can use without an instruction
844  /// available.
845  /// Return the flipped strictness of predicate
846  static Predicate getFlippedStrictnessPredicate(Predicate pred);
847 
848  /// For example, SGT -> SGE, SLT -> SLE, ULT -> ULE, UGT -> UGE.
849  /// Returns the non-strict version of strict comparisons.
851  return getNonStrictPredicate(getPredicate());
852  }
853 
854  /// This is a static version that you can use without an instruction
855  /// available.
856  /// @returns the non-strict version of comparison provided in \p pred.
857  /// If \p pred is not a strict comparison predicate, returns \p pred.
858  /// Returns the non-strict version of strict comparisons.
859  static Predicate getNonStrictPredicate(Predicate pred);
860 
861  /// Provide more efficient getOperand methods.
863 
864  /// This is just a convenience that dispatches to the subclasses.
865  /// Swap the operands and adjust predicate accordingly to retain
866  /// the same comparison.
867  void swapOperands();
868 
869  /// This is just a convenience that dispatches to the subclasses.
870  /// Determine if this CmpInst is commutative.
871  bool isCommutative() const;
872 
873  /// This is just a convenience that dispatches to the subclasses.
874  /// Determine if this is an equals/not equals predicate.
875  bool isEquality() const;
876 
877  /// @returns true if the comparison is signed, false otherwise.
878  /// Determine if this instruction is using a signed comparison.
879  bool isSigned() const {
880  return isSigned(getPredicate());
881  }
882 
883  /// @returns true if the comparison is unsigned, false otherwise.
884  /// Determine if this instruction is using an unsigned comparison.
885  bool isUnsigned() const {
886  return isUnsigned(getPredicate());
887  }
888 
889  /// For example, ULT->SLT, ULE->SLE, UGT->SGT, UGE->SGE, SLT->Failed assert
890  /// @returns the signed version of the unsigned predicate pred.
891  /// return the signed version of a predicate
892  static Predicate getSignedPredicate(Predicate pred);
893 
894  /// For example, ULT->SLT, ULE->SLE, UGT->SGT, UGE->SGE, SLT->Failed assert
895  /// @returns the signed version of the predicate for this instruction (which
896  /// has to be an unsigned predicate).
897  /// return the signed version of a predicate
899  return getSignedPredicate(getPredicate());
900  }
901 
902  /// This is just a convenience.
903  /// Determine if this is true when both operands are the same.
904  bool isTrueWhenEqual() const {
905  return isTrueWhenEqual(getPredicate());
906  }
907 
908  /// This is just a convenience.
909  /// Determine if this is false when both operands are the same.
910  bool isFalseWhenEqual() const {
911  return isFalseWhenEqual(getPredicate());
912  }
913 
914  /// @returns true if the predicate is unsigned, false otherwise.
915  /// Determine if the predicate is an unsigned operation.
916  static bool isUnsigned(Predicate predicate);
917 
918  /// @returns true if the predicate is signed, false otherwise.
919  /// Determine if the predicate is an signed operation.
920  static bool isSigned(Predicate predicate);
921 
922  /// Determine if the predicate is an ordered operation.
923  static bool isOrdered(Predicate predicate);
924 
925  /// Determine if the predicate is an unordered operation.
926  static bool isUnordered(Predicate predicate);
927 
928  /// Determine if the predicate is true when comparing a value with itself.
929  static bool isTrueWhenEqual(Predicate predicate);
930 
931  /// Determine if the predicate is false when comparing a value with itself.
932  static bool isFalseWhenEqual(Predicate predicate);
933 
934  /// Determine if Pred1 implies Pred2 is true when two compares have matching
935  /// operands.
936  static bool isImpliedTrueByMatchingCmp(Predicate Pred1, Predicate Pred2);
937 
938  /// Determine if Pred1 implies Pred2 is false when two compares have matching
939  /// operands.
940  static bool isImpliedFalseByMatchingCmp(Predicate Pred1, Predicate Pred2);
941 
942  /// Methods for support type inquiry through isa, cast, and dyn_cast:
943  static bool classof(const Instruction *I) {
944  return I->getOpcode() == Instruction::ICmp ||
945  I->getOpcode() == Instruction::FCmp;
946  }
947  static bool classof(const Value *V) {
948  return isa<Instruction>(V) && classof(cast<Instruction>(V));
949  }
950 
951  /// Create a result type for fcmp/icmp
952  static Type* makeCmpResultType(Type* opnd_type) {
953  if (VectorType* vt = dyn_cast<VectorType>(opnd_type)) {
954  return VectorType::get(Type::getInt1Ty(opnd_type->getContext()),
955  vt->getNumElements());
956  }
957  return Type::getInt1Ty(opnd_type->getContext());
958  }
959 
960 private:
961  // Shadow Value::setValueSubclassData with a private forwarding method so that
962  // subclasses cannot accidentally use it.
963  void setValueSubclassData(unsigned short D) {
965  }
966 };
967 
968 // FIXME: these are redundant if CmpInst < BinaryOperator
969 template <>
970 struct OperandTraits<CmpInst> : public FixedNumOperandTraits<CmpInst, 2> {
971 };
972 
974 
975 /// A lightweight accessor for an operand bundle meant to be passed
976 /// around by value.
979 
980  OperandBundleUse() = default;
982  : Inputs(Inputs), Tag(Tag) {}
983 
984  /// Return true if the operand at index \p Idx in this operand bundle
985  /// has the attribute A.
986  bool operandHasAttr(unsigned Idx, Attribute::AttrKind A) const {
987  if (isDeoptOperandBundle())
988  if (A == Attribute::ReadOnly || A == Attribute::NoCapture)
989  return Inputs[Idx]->getType()->isPointerTy();
990 
991  // Conservative answer: no operands have any attributes.
992  return false;
993  }
994 
995  /// Return the tag of this operand bundle as a string.
997  return Tag->getKey();
998  }
999 
1000  /// Return the tag of this operand bundle as an integer.
1001  ///
1002  /// Operand bundle tags are interned by LLVMContextImpl::getOrInsertBundleTag,
1003  /// and this function returns the unique integer getOrInsertBundleTag
1004  /// associated the tag of this operand bundle to.
1005  uint32_t getTagID() const {
1006  return Tag->getValue();
1007  }
1008 
1009  /// Return true if this is a "deopt" operand bundle.
1010  bool isDeoptOperandBundle() const {
1011  return getTagID() == LLVMContext::OB_deopt;
1012  }
1013 
1014  /// Return true if this is a "funclet" operand bundle.
1015  bool isFuncletOperandBundle() const {
1016  return getTagID() == LLVMContext::OB_funclet;
1017  }
1018 
1019 private:
1020  /// Pointer to an entry in LLVMContextImpl::getOrInsertBundleTag.
1022 };
1023 
1024 /// A container for an operand bundle being viewed as a set of values
1025 /// rather than a set of uses.
1026 ///
1027 /// Unlike OperandBundleUse, OperandBundleDefT owns the memory it carries, and
1028 /// so it is possible to create and pass around "self-contained" instances of
1029 /// OperandBundleDef and ConstOperandBundleDef.
1030 template <typename InputTy> class OperandBundleDefT {
1031  std::string Tag;
1032  std::vector<InputTy> Inputs;
1033 
1034 public:
1035  explicit OperandBundleDefT(std::string Tag, std::vector<InputTy> Inputs)
1036  : Tag(std::move(Tag)), Inputs(std::move(Inputs)) {}
1037  explicit OperandBundleDefT(std::string Tag, ArrayRef<InputTy> Inputs)
1038  : Tag(std::move(Tag)), Inputs(Inputs) {}
1039 
1040  explicit OperandBundleDefT(const OperandBundleUse &OBU) {
1041  Tag = OBU.getTagName();
1042  Inputs.insert(Inputs.end(), OBU.Inputs.begin(), OBU.Inputs.end());
1043  }
1044 
1045  ArrayRef<InputTy> inputs() const { return Inputs; }
1046 
1047  using input_iterator = typename std::vector<InputTy>::const_iterator;
1048 
1049  size_t input_size() const { return Inputs.size(); }
1050  input_iterator input_begin() const { return Inputs.begin(); }
1051  input_iterator input_end() const { return Inputs.end(); }
1052 
1053  StringRef getTag() const { return Tag; }
1054 };
1055 
1058 
1059 //===----------------------------------------------------------------------===//
1060 // CallBase Class
1061 //===----------------------------------------------------------------------===//
1062 
1063 /// Base class for all callable instructions (InvokeInst and CallInst)
1064 /// Holds everything related to calling a function.
1065 ///
1066 /// All call-like instructions are required to use a common operand layout:
1067 /// - Zero or more arguments to the call,
1068 /// - Zero or more operand bundles with zero or more operand inputs each
1069 /// bundle,
1070 /// - Zero or more subclass controlled operands
1071 /// - The called function.
1072 ///
1073 /// This allows this base class to easily access the called function and the
1074 /// start of the arguments without knowing how many other operands a particular
1075 /// subclass requires. Note that accessing the end of the argument list isn't
1076 /// as cheap as most other operations on the base class.
1077 class CallBase : public Instruction {
1078 protected:
1079  /// The last operand is the called operand.
1080  static constexpr int CalledOperandOpEndIdx = -1;
1081 
1082  AttributeList Attrs; ///< parameter attributes for callable
1084 
1085  template <class... ArgsTy>
1086  CallBase(AttributeList const &A, FunctionType *FT, ArgsTy &&... Args)
1087  : Instruction(std::forward<ArgsTy>(Args)...), Attrs(A), FTy(FT) {}
1088 
1090 
1091  bool hasDescriptor() const { return Value::HasDescriptor; }
1092 
1093  unsigned getNumSubclassExtraOperands() const {
1094  switch (getOpcode()) {
1095  case Instruction::Call:
1096  return 0;
1097  case Instruction::Invoke:
1098  return 2;
1099  case Instruction::CallBr:
1100  return getNumSubclassExtraOperandsDynamic();
1101  }
1102  llvm_unreachable("Invalid opcode!");
1103  }
1104 
1105  /// Get the number of extra operands for instructions that don't have a fixed
1106  /// number of extra operands.
1107  unsigned getNumSubclassExtraOperandsDynamic() const;
1108 
1109 public:
1111 
1112  static bool classof(const Instruction *I) {
1113  return I->getOpcode() == Instruction::Call ||
1114  I->getOpcode() == Instruction::Invoke ||
1115  I->getOpcode() == Instruction::CallBr;
1116  }
1117  static bool classof(const Value *V) {
1118  return isa<Instruction>(V) && classof(cast<Instruction>(V));
1119  }
1120 
1121  FunctionType *getFunctionType() const { return FTy; }
1122 
1125  this->FTy = FTy;
1126  }
1127 
1129 
1130  /// data_operands_begin/data_operands_end - Return iterators iterating over
1131  /// the call / invoke argument list and bundle operands. For invokes, this is
1132  /// the set of instruction operands except the invoke target and the two
1133  /// successor blocks; and for calls this is the set of instruction operands
1134  /// except the call target.
1135  User::op_iterator data_operands_begin() { return op_begin(); }
1137  return const_cast<CallBase *>(this)->data_operands_begin();
1138  }
1140  // Walk from the end of the operands over the called operand and any
1141  // subclass operands.
1142  return op_end() - getNumSubclassExtraOperands() - 1;
1143  }
1145  return const_cast<CallBase *>(this)->data_operands_end();
1146  }
1148  return make_range(data_operands_begin(), data_operands_end());
1149  }
1151  return make_range(data_operands_begin(), data_operands_end());
1152  }
1153  bool data_operands_empty() const {
1154  return data_operands_end() == data_operands_begin();
1155  }
1156  unsigned data_operands_size() const {
1157  return std::distance(data_operands_begin(), data_operands_end());
1158  }
1159 
1160  bool isDataOperand(const Use *U) const {
1161  assert(this == U->getUser() &&
1162  "Only valid to query with a use of this instruction!");
1163  return data_operands_begin() <= U && U < data_operands_end();
1164  }
1166  return isDataOperand(&UI.getUse());
1167  }
1168 
1169  /// Given a value use iterator, return the data operand corresponding to it.
1170  /// Iterator must actually correspond to a data operand.
1172  return getDataOperandNo(&UI.getUse());
1173  }
1174 
1175  /// Given a use for a data operand, get the data operand number that
1176  /// corresponds to it.
1177  unsigned getDataOperandNo(const Use *U) const {
1178  assert(isDataOperand(U) && "Data operand # out of range!");
1179  return U - data_operands_begin();
1180  }
1181 
1182  /// Return the iterator pointing to the beginning of the argument list.
1183  User::op_iterator arg_begin() { return op_begin(); }
1185  return const_cast<CallBase *>(this)->arg_begin();
1186  }
1187 
1188  /// Return the iterator pointing to the end of the argument list.
1190  // From the end of the data operands, walk backwards past the bundle
1191  // operands.
1192  return data_operands_end() - getNumTotalBundleOperands();
1193  }
1195  return const_cast<CallBase *>(this)->arg_end();
1196  }
1197 
1198  /// Iteration adapter for range-for loops.
1200  return make_range(arg_begin(), arg_end());
1201  }
1203  return make_range(arg_begin(), arg_end());
1204  }
1205  bool arg_empty() const { return arg_end() == arg_begin(); }
1206  unsigned arg_size() const { return arg_end() - arg_begin(); }
1207 
1208  // Legacy API names that duplicate the above and will be removed once users
1209  // are migrated.
1211  return make_range(arg_begin(), arg_end());
1212  }
1214  return make_range(arg_begin(), arg_end());
1215  }
1216  unsigned getNumArgOperands() const { return arg_size(); }
1217 
1218  Value *getArgOperand(unsigned i) const {
1219  assert(i < getNumArgOperands() && "Out of bounds!");
1220  return getOperand(i);
1221  }
1222 
1223  void setArgOperand(unsigned i, Value *v) {
1224  assert(i < getNumArgOperands() && "Out of bounds!");
1225  setOperand(i, v);
1226  }
1227 
1228  /// Wrappers for getting the \c Use of a call argument.
1229  const Use &getArgOperandUse(unsigned i) const {
1230  assert(i < getNumArgOperands() && "Out of bounds!");
1231  return User::getOperandUse(i);
1232  }
1233  Use &getArgOperandUse(unsigned i) {
1234  assert(i < getNumArgOperands() && "Out of bounds!");
1235  return User::getOperandUse(i);
1236  }
1237 
1238  bool isArgOperand(const Use *U) const {
1239  assert(this == U->getUser() &&
1240  "Only valid to query with a use of this instruction!");
1241  return arg_begin() <= U && U < arg_end();
1242  }
1244  return isArgOperand(&UI.getUse());
1245  }
1246 
1247  /// Returns true if this CallSite passes the given Value* as an argument to
1248  /// the called function.
1249  bool hasArgument(const Value *V) const {
1250  return llvm::any_of(args(), [V](const Value *Arg) { return Arg == V; });
1251  }
1252 
1253  Value *getCalledOperand() const { return Op<CalledOperandOpEndIdx>(); }
1254 
1255  // DEPRECATED: This routine will be removed in favor of `getCalledOperand` in
1256  // the near future.
1257  Value *getCalledValue() const { return getCalledOperand(); }
1258 
1259  const Use &getCalledOperandUse() const { return Op<CalledOperandOpEndIdx>(); }
1260  Use &getCalledOperandUse() { return Op<CalledOperandOpEndIdx>(); }
1261 
1262  /// Returns the function called, or null if this is an
1263  /// indirect function invocation.
1265  return dyn_cast_or_null<Function>(getCalledOperand());
1266  }
1267 
1268  /// Return true if the callsite is an indirect call.
1269  bool isIndirectCall() const;
1270 
1271  /// Determine whether the passed iterator points to the callee operand's Use.
1273  return isCallee(&UI.getUse());
1274  }
1275 
1276  /// Determine whether this Use is the callee operand's Use.
1277  bool isCallee(const Use *U) const { return &getCalledOperandUse() == U; }
1278 
1279  /// Helper to get the caller (the parent function).
1280  Function *getCaller();
1281  const Function *getCaller() const {
1282  return const_cast<CallBase *>(this)->getCaller();
1283  }
1284 
1285  /// Tests if this call site must be tail call optimized. Only a CallInst can
1286  /// be tail call optimized.
1287  bool isMustTailCall() const;
1288 
1289  /// Tests if this call site is marked as a tail call.
1290  bool isTailCall() const;
1291 
1292  /// Returns the intrinsic ID of the intrinsic called or
1293  /// Intrinsic::not_intrinsic if the called function is not an intrinsic, or if
1294  /// this is an indirect call.
1295  Intrinsic::ID getIntrinsicID() const;
1296 
1297  void setCalledOperand(Value *V) { Op<CalledOperandOpEndIdx>() = V; }
1298 
1299  /// Sets the function called, including updating the function type.
1301  setCalledFunction(Fn->getFunctionType(), Fn);
1302  }
1303 
1304  /// Sets the function called, including updating the function type.
1306  setCalledFunction(Fn.getFunctionType(), Fn.getCallee());
1307  }
1308 
1309  /// Sets the function called, including updating to the specified function
1310  /// type.
1312  this->FTy = FTy;
1313  assert(FTy == cast<FunctionType>(
1314  cast<PointerType>(Fn->getType())->getElementType()));
1315  // This function doesn't mutate the return type, only the function
1316  // type. Seems broken, but I'm just gonna stick an assert in for now.
1317  assert(getType() == FTy->getReturnType());
1318  setCalledOperand(Fn);
1319  }
1320 
1322  return static_cast<CallingConv::ID>(getSubclassDataFromInstruction() >> 2);
1323  }
1324 
1326  auto ID = static_cast<unsigned>(CC);
1327  assert(!(ID & ~CallingConv::MaxID) && "Unsupported calling convention");
1328  setInstructionSubclassData((getSubclassDataFromInstruction() & 3) |
1329  (ID << 2));
1330  }
1331 
1332  /// Check if this call is an inline asm statement.
1333  bool isInlineAsm() const { return isa<InlineAsm>(getCalledOperand()); }
1334 
1335  /// \name Attribute API
1336  ///
1337  /// These methods access and modify attributes on this call (including
1338  /// looking through to the attributes on the called function when necessary).
1339  ///@{
1340 
1341  /// Return the parameter attributes for this call.
1342  ///
1343  AttributeList getAttributes() const { return Attrs; }
1344 
1345  /// Set the parameter attributes for this call.
1346  ///
1347  void setAttributes(AttributeList A) { Attrs = A; }
1348 
1349  /// Determine whether this call has the given attribute.
1351  assert(Kind != Attribute::NoBuiltin &&
1352  "Use CallBase::isNoBuiltin() to check for Attribute::NoBuiltin");
1353  return hasFnAttrImpl(Kind);
1354  }
1355 
1356  /// Determine whether this call has the given attribute.
1357  bool hasFnAttr(StringRef Kind) const { return hasFnAttrImpl(Kind); }
1358 
1359  /// adds the attribute to the list of attributes.
1361  AttributeList PAL = getAttributes();
1362  PAL = PAL.addAttribute(getContext(), i, Kind);
1363  setAttributes(PAL);
1364  }
1365 
1366  /// adds the attribute to the list of attributes.
1367  void addAttribute(unsigned i, Attribute Attr) {
1368  AttributeList PAL = getAttributes();
1369  PAL = PAL.addAttribute(getContext(), i, Attr);
1370  setAttributes(PAL);
1371  }
1372 
1373  /// Adds the attribute to the indicated argument
1374  void addParamAttr(unsigned ArgNo, Attribute::AttrKind Kind) {
1375  assert(ArgNo < getNumArgOperands() && "Out of bounds");
1376  AttributeList PAL = getAttributes();
1377  PAL = PAL.addParamAttribute(getContext(), ArgNo, Kind);
1378  setAttributes(PAL);
1379  }
1380 
1381  /// Adds the attribute to the indicated argument
1382  void addParamAttr(unsigned ArgNo, Attribute Attr) {
1383  assert(ArgNo < getNumArgOperands() && "Out of bounds");
1384  AttributeList PAL = getAttributes();
1385  PAL = PAL.addParamAttribute(getContext(), ArgNo, Attr);
1386  setAttributes(PAL);
1387  }
1388 
1389  /// removes the attribute from the list of attributes.
1391  AttributeList PAL = getAttributes();
1392  PAL = PAL.removeAttribute(getContext(), i, Kind);
1393  setAttributes(PAL);
1394  }
1395 
1396  /// removes the attribute from the list of attributes.
1397  void removeAttribute(unsigned i, StringRef Kind) {
1398  AttributeList PAL = getAttributes();
1399  PAL = PAL.removeAttribute(getContext(), i, Kind);
1400  setAttributes(PAL);
1401  }
1402 
1403  /// Removes the attribute from the given argument
1404  void removeParamAttr(unsigned ArgNo, Attribute::AttrKind Kind) {
1405  assert(ArgNo < getNumArgOperands() && "Out of bounds");
1406  AttributeList PAL = getAttributes();
1407  PAL = PAL.removeParamAttribute(getContext(), ArgNo, Kind);
1408  setAttributes(PAL);
1409  }
1410 
1411  /// Removes the attribute from the given argument
1412  void removeParamAttr(unsigned ArgNo, StringRef Kind) {
1413  assert(ArgNo < getNumArgOperands() && "Out of bounds");
1414  AttributeList PAL = getAttributes();
1415  PAL = PAL.removeParamAttribute(getContext(), ArgNo, Kind);
1416  setAttributes(PAL);
1417  }
1418 
1419  /// adds the dereferenceable attribute to the list of attributes.
1420  void addDereferenceableAttr(unsigned i, uint64_t Bytes) {
1421  AttributeList PAL = getAttributes();
1422  PAL = PAL.addDereferenceableAttr(getContext(), i, Bytes);
1423  setAttributes(PAL);
1424  }
1425 
1426  /// adds the dereferenceable_or_null attribute to the list of
1427  /// attributes.
1428  void addDereferenceableOrNullAttr(unsigned i, uint64_t Bytes) {
1429  AttributeList PAL = getAttributes();
1430  PAL = PAL.addDereferenceableOrNullAttr(getContext(), i, Bytes);
1431  setAttributes(PAL);
1432  }
1433 
1434  /// Determine whether the return value has the given attribute.
1435  bool hasRetAttr(Attribute::AttrKind Kind) const;
1436 
1437  /// Determine whether the argument or parameter has the given attribute.
1438  bool paramHasAttr(unsigned ArgNo, Attribute::AttrKind Kind) const;
1439 
1440  /// Get the attribute of a given kind at a position.
1441  Attribute getAttribute(unsigned i, Attribute::AttrKind Kind) const {
1442  return getAttributes().getAttribute(i, Kind);
1443  }
1444 
1445  /// Get the attribute of a given kind at a position.
1446  Attribute getAttribute(unsigned i, StringRef Kind) const {
1447  return getAttributes().getAttribute(i, Kind);
1448  }
1449 
1450  /// Get the attribute of a given kind from a given arg
1451  Attribute getParamAttr(unsigned ArgNo, Attribute::AttrKind Kind) const {
1452  assert(ArgNo < getNumArgOperands() && "Out of bounds");
1453  return getAttributes().getParamAttr(ArgNo, Kind);
1454  }
1455 
1456  /// Get the attribute of a given kind from a given arg
1457  Attribute getParamAttr(unsigned ArgNo, StringRef Kind) const {
1458  assert(ArgNo < getNumArgOperands() && "Out of bounds");
1459  return getAttributes().getParamAttr(ArgNo, Kind);
1460  }
1461 
1462  /// Return true if the data operand at index \p i has the attribute \p
1463  /// A.
1464  ///
1465  /// Data operands include call arguments and values used in operand bundles,
1466  /// but does not include the callee operand. This routine dispatches to the
1467  /// underlying AttributeList or the OperandBundleUser as appropriate.
1468  ///
1469  /// The index \p i is interpreted as
1470  ///
1471  /// \p i == Attribute::ReturnIndex -> the return value
1472  /// \p i in [1, arg_size + 1) -> argument number (\p i - 1)
1473  /// \p i in [arg_size + 1, data_operand_size + 1) -> bundle operand at index
1474  /// (\p i - 1) in the operand list.
1475  bool dataOperandHasImpliedAttr(unsigned i, Attribute::AttrKind Kind) const {
1476  // Note that we have to add one because `i` isn't zero-indexed.
1477  assert(i < (getNumArgOperands() + getNumTotalBundleOperands() + 1) &&
1478  "Data operand index out of bounds!");
1479 
1480  // The attribute A can either be directly specified, if the operand in
1481  // question is a call argument; or be indirectly implied by the kind of its
1482  // containing operand bundle, if the operand is a bundle operand.
1483 
1484  if (i == AttributeList::ReturnIndex)
1485  return hasRetAttr(Kind);
1486 
1487  // FIXME: Avoid these i - 1 calculations and update the API to use
1488  // zero-based indices.
1489  if (i < (getNumArgOperands() + 1))
1490  return paramHasAttr(i - 1, Kind);
1491 
1492  assert(hasOperandBundles() && i >= (getBundleOperandsStartIndex() + 1) &&
1493  "Must be either a call argument or an operand bundle!");
1494  return bundleOperandHasAttr(i - 1, Kind);
1495  }
1496 
1497  /// Determine whether this data operand is not captured.
1498  // FIXME: Once this API is no longer duplicated in `CallSite`, rename this to
1499  // better indicate that this may return a conservative answer.
1500  bool doesNotCapture(unsigned OpNo) const {
1501  return dataOperandHasImpliedAttr(OpNo + 1, Attribute::NoCapture);
1502  }
1503 
1504  /// Determine whether this argument is passed by value.
1505  bool isByValArgument(unsigned ArgNo) const {
1506  return paramHasAttr(ArgNo, Attribute::ByVal);
1507  }
1508 
1509  /// Determine whether this argument is passed in an alloca.
1510  bool isInAllocaArgument(unsigned ArgNo) const {
1511  return paramHasAttr(ArgNo, Attribute::InAlloca);
1512  }
1513 
1514  /// Determine whether this argument is passed by value or in an alloca.
1515  bool isByValOrInAllocaArgument(unsigned ArgNo) const {
1516  return paramHasAttr(ArgNo, Attribute::ByVal) ||
1517  paramHasAttr(ArgNo, Attribute::InAlloca);
1518  }
1519 
1520  /// Determine if there are is an inalloca argument. Only the last argument can
1521  /// have the inalloca attribute.
1522  bool hasInAllocaArgument() const {
1523  return !arg_empty() && paramHasAttr(arg_size() - 1, Attribute::InAlloca);
1524  }
1525 
1526  // FIXME: Once this API is no longer duplicated in `CallSite`, rename this to
1527  // better indicate that this may return a conservative answer.
1528  bool doesNotAccessMemory(unsigned OpNo) const {
1529  return dataOperandHasImpliedAttr(OpNo + 1, Attribute::ReadNone);
1530  }
1531 
1532  // FIXME: Once this API is no longer duplicated in `CallSite`, rename this to
1533  // better indicate that this may return a conservative answer.
1534  bool onlyReadsMemory(unsigned OpNo) const {
1535  return dataOperandHasImpliedAttr(OpNo + 1, Attribute::ReadOnly) ||
1536  dataOperandHasImpliedAttr(OpNo + 1, Attribute::ReadNone);
1537  }
1538 
1539  // FIXME: Once this API is no longer duplicated in `CallSite`, rename this to
1540  // better indicate that this may return a conservative answer.
1541  bool doesNotReadMemory(unsigned OpNo) const {
1542  return dataOperandHasImpliedAttr(OpNo + 1, Attribute::WriteOnly) ||
1543  dataOperandHasImpliedAttr(OpNo + 1, Attribute::ReadNone);
1544  }
1545 
1546  /// Extract the alignment of the return value.
1547  unsigned getRetAlignment() const { return Attrs.getRetAlignment(); }
1548 
1549  /// Extract the alignment for a call or parameter (0=unknown).
1550  unsigned getParamAlignment(unsigned ArgNo) const {
1551  return Attrs.getParamAlignment(ArgNo);
1552  }
1553 
1554  /// Extract the number of dereferenceable bytes for a call or
1555  /// parameter (0=unknown).
1556  uint64_t getDereferenceableBytes(unsigned i) const {
1557  return Attrs.getDereferenceableBytes(i);
1558  }
1559 
1560  /// Extract the number of dereferenceable_or_null bytes for a call or
1561  /// parameter (0=unknown).
1562  uint64_t getDereferenceableOrNullBytes(unsigned i) const {
1563  return Attrs.getDereferenceableOrNullBytes(i);
1564  }
1565 
1566  /// Return true if the return value is known to be not null.
1567  /// This may be because it has the nonnull attribute, or because at least
1568  /// one byte is dereferenceable and the pointer is in addrspace(0).
1569  bool isReturnNonNull() const;
1570 
1571  /// Determine if the return value is marked with NoAlias attribute.
1572  bool returnDoesNotAlias() const {
1574  }
1575 
1576  /// If one of the arguments has the 'returned' attribute, returns its
1577  /// operand value. Otherwise, return nullptr.
1578  Value *getReturnedArgOperand() const;
1579 
1580  /// Return true if the call should not be treated as a call to a
1581  /// builtin.
1582  bool isNoBuiltin() const {
1583  return hasFnAttrImpl(Attribute::NoBuiltin) &&
1584  !hasFnAttrImpl(Attribute::Builtin);
1585  }
1586 
1587  /// Determine if the call requires strict floating point semantics.
1588  bool isStrictFP() const { return hasFnAttr(Attribute::StrictFP); }
1589 
1590  /// Return true if the call should not be inlined.
1591  bool isNoInline() const { return hasFnAttr(Attribute::NoInline); }
1592  void setIsNoInline() {
1593  addAttribute(AttributeList::FunctionIndex, Attribute::NoInline);
1594  }
1595  /// Determine if the call does not access memory.
1596  bool doesNotAccessMemory() const { return hasFnAttr(Attribute::ReadNone); }
1598  addAttribute(AttributeList::FunctionIndex, Attribute::ReadNone);
1599  }
1600 
1601  /// Determine if the call does not access or only reads memory.
1602  bool onlyReadsMemory() const {
1603  return doesNotAccessMemory() || hasFnAttr(Attribute::ReadOnly);
1604  }
1606  addAttribute(AttributeList::FunctionIndex, Attribute::ReadOnly);
1607  }
1608 
1609  /// Determine if the call does not access or only writes memory.
1610  bool doesNotReadMemory() const {
1611  return doesNotAccessMemory() || hasFnAttr(Attribute::WriteOnly);
1612  }
1614  addAttribute(AttributeList::FunctionIndex, Attribute::WriteOnly);
1615  }
1616 
1617  /// Determine if the call can access memmory only using pointers based
1618  /// on its arguments.
1619  bool onlyAccessesArgMemory() const {
1620  return hasFnAttr(Attribute::ArgMemOnly);
1621  }
1623  addAttribute(AttributeList::FunctionIndex, Attribute::ArgMemOnly);
1624  }
1625 
1626  /// Determine if the function may only access memory that is
1627  /// inaccessible from the IR.
1629  return hasFnAttr(Attribute::InaccessibleMemOnly);
1630  }
1632  addAttribute(AttributeList::FunctionIndex, Attribute::InaccessibleMemOnly);
1633  }
1634 
1635  /// Determine if the function may only access memory that is
1636  /// either inaccessible from the IR or pointed to by its arguments.
1638  return hasFnAttr(Attribute::InaccessibleMemOrArgMemOnly);
1639  }
1641  addAttribute(AttributeList::FunctionIndex,
1642  Attribute::InaccessibleMemOrArgMemOnly);
1643  }
1644  /// Determine if the call cannot return.
1645  bool doesNotReturn() const { return hasFnAttr(Attribute::NoReturn); }
1647  addAttribute(AttributeList::FunctionIndex, Attribute::NoReturn);
1648  }
1649 
1650  /// Determine if the call should not perform indirect branch tracking.
1651  bool doesNoCfCheck() const { return hasFnAttr(Attribute::NoCfCheck); }
1652 
1653  /// Determine if the call cannot unwind.
1654  bool doesNotThrow() const { return hasFnAttr(Attribute::NoUnwind); }
1656  addAttribute(AttributeList::FunctionIndex, Attribute::NoUnwind);
1657  }
1658 
1659  /// Determine if the invoke cannot be duplicated.
1660  bool cannotDuplicate() const { return hasFnAttr(Attribute::NoDuplicate); }
1662  addAttribute(AttributeList::FunctionIndex, Attribute::NoDuplicate);
1663  }
1664 
1665  /// Determine if the invoke is convergent
1666  bool isConvergent() const { return hasFnAttr(Attribute::Convergent); }
1667  void setConvergent() {
1669  }
1672  }
1673 
1674  /// Determine if the call returns a structure through first
1675  /// pointer argument.
1676  bool hasStructRetAttr() const {
1677  if (getNumArgOperands() == 0)
1678  return false;
1679 
1680  // Be friendly and also check the callee.
1681  return paramHasAttr(0, Attribute::StructRet);
1682  }
1683 
1684  /// Determine if any call argument is an aggregate passed by value.
1685  bool hasByValArgument() const {
1686  return Attrs.hasAttrSomewhere(Attribute::ByVal);
1687  }
1688 
1689  ///@{
1690  // End of attribute API.
1691 
1692  /// \name Operand Bundle API
1693  ///
1694  /// This group of methods provides the API to access and manipulate operand
1695  /// bundles on this call.
1696  /// @{
1697 
1698  /// Return the number of operand bundles associated with this User.
1699  unsigned getNumOperandBundles() const {
1700  return std::distance(bundle_op_info_begin(), bundle_op_info_end());
1701  }
1702 
1703  /// Return true if this User has any operand bundles.
1704  bool hasOperandBundles() const { return getNumOperandBundles() != 0; }
1705 
1706  /// Return the index of the first bundle operand in the Use array.
1707  unsigned getBundleOperandsStartIndex() const {
1708  assert(hasOperandBundles() && "Don't call otherwise!");
1709  return bundle_op_info_begin()->Begin;
1710  }
1711 
1712  /// Return the index of the last bundle operand in the Use array.
1713  unsigned getBundleOperandsEndIndex() const {
1714  assert(hasOperandBundles() && "Don't call otherwise!");
1715  return bundle_op_info_end()[-1].End;
1716  }
1717 
1718  /// Return true if the operand at index \p Idx is a bundle operand.
1719  bool isBundleOperand(unsigned Idx) const {
1720  return hasOperandBundles() && Idx >= getBundleOperandsStartIndex() &&
1721  Idx < getBundleOperandsEndIndex();
1722  }
1723 
1724  /// Returns true if the use is a bundle operand.
1725  bool isBundleOperand(const Use *U) const {
1726  assert(this == U->getUser() &&
1727  "Only valid to query with a use of this instruction!");
1728  return hasOperandBundles() && isBundleOperand(U - op_begin());
1729  }
1731  return isBundleOperand(&UI.getUse());
1732  }
1733 
1734  /// Return the total number operands (not operand bundles) used by
1735  /// every operand bundle in this OperandBundleUser.
1736  unsigned getNumTotalBundleOperands() const {
1737  if (!hasOperandBundles())
1738  return 0;
1739 
1740  unsigned Begin = getBundleOperandsStartIndex();
1741  unsigned End = getBundleOperandsEndIndex();
1742 
1743  assert(Begin <= End && "Should be!");
1744  return End - Begin;
1745  }
1746 
1747  /// Return the operand bundle at a specific index.
1749  assert(Index < getNumOperandBundles() && "Index out of bounds!");
1750  return operandBundleFromBundleOpInfo(*(bundle_op_info_begin() + Index));
1751  }
1752 
1753  /// Return the number of operand bundles with the tag Name attached to
1754  /// this instruction.
1756  unsigned Count = 0;
1757  for (unsigned i = 0, e = getNumOperandBundles(); i != e; ++i)
1758  if (getOperandBundleAt(i).getTagName() == Name)
1759  Count++;
1760 
1761  return Count;
1762  }
1763 
1764  /// Return the number of operand bundles with the tag ID attached to
1765  /// this instruction.
1767  unsigned Count = 0;
1768  for (unsigned i = 0, e = getNumOperandBundles(); i != e; ++i)
1769  if (getOperandBundleAt(i).getTagID() == ID)
1770  Count++;
1771 
1772  return Count;
1773  }
1774 
1775  /// Return an operand bundle by name, if present.
1776  ///
1777  /// It is an error to call this for operand bundle types that may have
1778  /// multiple instances of them on the same instruction.
1780  assert(countOperandBundlesOfType(Name) < 2 && "Precondition violated!");
1781 
1782  for (unsigned i = 0, e = getNumOperandBundles(); i != e; ++i) {
1783  OperandBundleUse U = getOperandBundleAt(i);
1784  if (U.getTagName() == Name)
1785  return U;
1786  }
1787 
1788  return None;
1789  }
1790 
1791  /// Return an operand bundle by tag ID, if present.
1792  ///
1793  /// It is an error to call this for operand bundle types that may have
1794  /// multiple instances of them on the same instruction.
1796  assert(countOperandBundlesOfType(ID) < 2 && "Precondition violated!");
1797 
1798  for (unsigned i = 0, e = getNumOperandBundles(); i != e; ++i) {
1799  OperandBundleUse U = getOperandBundleAt(i);
1800  if (U.getTagID() == ID)
1801  return U;
1802  }
1803 
1804  return None;
1805  }
1806 
1807  /// Return the list of operand bundles attached to this instruction as
1808  /// a vector of OperandBundleDefs.
1809  ///
1810  /// This function copies the OperandBundeUse instances associated with this
1811  /// OperandBundleUser to a vector of OperandBundleDefs. Note:
1812  /// OperandBundeUses and OperandBundleDefs are non-trivially *different*
1813  /// representations of operand bundles (see documentation above).
1815  for (unsigned i = 0, e = getNumOperandBundles(); i != e; ++i)
1816  Defs.emplace_back(getOperandBundleAt(i));
1817  }
1818 
1819  /// Return the operand bundle for the operand at index OpIdx.
1820  ///
1821  /// It is an error to call this with an OpIdx that does not correspond to an
1822  /// bundle operand.
1824  return operandBundleFromBundleOpInfo(getBundleOpInfoForOperand(OpIdx));
1825  }
1826 
1827  /// Return true if this operand bundle user has operand bundles that
1828  /// may read from the heap.
1830  // Implementation note: this is a conservative implementation of operand
1831  // bundle semantics, where *any* operand bundle forces a callsite to be at
1832  // least readonly.
1833  return hasOperandBundles();
1834  }
1835 
1836  /// Return true if this operand bundle user has operand bundles that
1837  /// may write to the heap.
1839  for (auto &BOI : bundle_op_infos()) {
1840  if (BOI.Tag->second == LLVMContext::OB_deopt ||
1841  BOI.Tag->second == LLVMContext::OB_funclet)
1842  continue;
1843 
1844  // This instruction has an operand bundle that is not known to us.
1845  // Assume the worst.
1846  return true;
1847  }
1848 
1849  return false;
1850  }
1851 
1852  /// Return true if the bundle operand at index \p OpIdx has the
1853  /// attribute \p A.
1854  bool bundleOperandHasAttr(unsigned OpIdx, Attribute::AttrKind A) const {
1855  auto &BOI = getBundleOpInfoForOperand(OpIdx);
1856  auto OBU = operandBundleFromBundleOpInfo(BOI);
1857  return OBU.operandHasAttr(OpIdx - BOI.Begin, A);
1858  }
1859 
1860  /// Return true if \p Other has the same sequence of operand bundle
1861  /// tags with the same number of operands on each one of them as this
1862  /// OperandBundleUser.
1863  bool hasIdenticalOperandBundleSchema(const CallBase &Other) const {
1864  if (getNumOperandBundles() != Other.getNumOperandBundles())
1865  return false;
1866 
1867  return std::equal(bundle_op_info_begin(), bundle_op_info_end(),
1868  Other.bundle_op_info_begin());
1869  }
1870 
1871  /// Return true if this operand bundle user contains operand bundles
1872  /// with tags other than those specified in \p IDs.
1874  for (unsigned i = 0, e = getNumOperandBundles(); i != e; ++i) {
1875  uint32_t ID = getOperandBundleAt(i).getTagID();
1876  if (!is_contained(IDs, ID))
1877  return true;
1878  }
1879  return false;
1880  }
1881 
1882  /// Is the function attribute S disallowed by some operand bundle on
1883  /// this operand bundle user?
1885  // Operand bundles only possibly disallow readnone, readonly and argmenonly
1886  // attributes. All String attributes are fine.
1887  return false;
1888  }
1889 
1890  /// Is the function attribute A disallowed by some operand bundle on
1891  /// this operand bundle user?
1893  switch (A) {
1894  default:
1895  return false;
1896 
1897  case Attribute::InaccessibleMemOrArgMemOnly:
1898  return hasReadingOperandBundles();
1899 
1900  case Attribute::InaccessibleMemOnly:
1901  return hasReadingOperandBundles();
1902 
1903  case Attribute::ArgMemOnly:
1904  return hasReadingOperandBundles();
1905 
1906  case Attribute::ReadNone:
1907  return hasReadingOperandBundles();
1908 
1909  case Attribute::ReadOnly:
1910  return hasClobberingOperandBundles();
1911  }
1912 
1913  llvm_unreachable("switch has a default case!");
1914  }
1915 
1916  /// Used to keep track of an operand bundle. See the main comment on
1917  /// OperandBundleUser above.
1918  struct BundleOpInfo {
1919  /// The operand bundle tag, interned by
1920  /// LLVMContextImpl::getOrInsertBundleTag.
1922 
1923  /// The index in the Use& vector where operands for this operand
1924  /// bundle starts.
1926 
1927  /// The index in the Use& vector where operands for this operand
1928  /// bundle ends.
1930 
1931  bool operator==(const BundleOpInfo &Other) const {
1932  return Tag == Other.Tag && Begin == Other.Begin && End == Other.End;
1933  }
1934  };
1935 
1936  /// Simple helper function to map a BundleOpInfo to an
1937  /// OperandBundleUse.
1940  auto begin = op_begin();
1941  ArrayRef<Use> Inputs(begin + BOI.Begin, begin + BOI.End);
1942  return OperandBundleUse(BOI.Tag, Inputs);
1943  }
1944 
1947 
1948  /// Return the start of the list of BundleOpInfo instances associated
1949  /// with this OperandBundleUser.
1950  ///
1951  /// OperandBundleUser uses the descriptor area co-allocated with the host User
1952  /// to store some meta information about which operands are "normal" operands,
1953  /// and which ones belong to some operand bundle.
1954  ///
1955  /// The layout of an operand bundle user is
1956  ///
1957  /// +-----------uint32_t End-------------------------------------+
1958  /// | |
1959  /// | +--------uint32_t Begin--------------------+ |
1960  /// | | | |
1961  /// ^ ^ v v
1962  /// |------|------|----|----|----|----|----|---------|----|---------|----|-----
1963  /// | BOI0 | BOI1 | .. | DU | U0 | U1 | .. | BOI0_U0 | .. | BOI1_U0 | .. | Un
1964  /// |------|------|----|----|----|----|----|---------|----|---------|----|-----
1965  /// v v ^ ^
1966  /// | | | |
1967  /// | +--------uint32_t Begin------------+ |
1968  /// | |
1969  /// +-----------uint32_t End-----------------------------+
1970  ///
1971  ///
1972  /// BOI0, BOI1 ... are descriptions of operand bundles in this User's use
1973  /// list. These descriptions are installed and managed by this class, and
1974  /// they're all instances of OperandBundleUser<T>::BundleOpInfo.
1975  ///
1976  /// DU is an additional descriptor installed by User's 'operator new' to keep
1977  /// track of the 'BOI0 ... BOIN' co-allocation. OperandBundleUser does not
1978  /// access or modify DU in any way, it's an implementation detail private to
1979  /// User.
1980  ///
1981  /// The regular Use& vector for the User starts at U0. The operand bundle
1982  /// uses are part of the Use& vector, just like normal uses. In the diagram
1983  /// above, the operand bundle uses start at BOI0_U0. Each instance of
1984  /// BundleOpInfo has information about a contiguous set of uses constituting
1985  /// an operand bundle, and the total set of operand bundle uses themselves
1986  /// form a contiguous set of uses (i.e. there are no gaps between uses
1987  /// corresponding to individual operand bundles).
1988  ///
1989  /// This class does not know the location of the set of operand bundle uses
1990  /// within the use list -- that is decided by the User using this class via
1991  /// the BeginIdx argument in populateBundleOperandInfos.
1992  ///
1993  /// Currently operand bundle users with hung-off operands are not supported.
1995  if (!hasDescriptor())
1996  return nullptr;
1997 
1998  uint8_t *BytesBegin = getDescriptor().begin();
1999  return reinterpret_cast<bundle_op_iterator>(BytesBegin);
2000  }
2001 
2002  /// Return the start of the list of BundleOpInfo instances associated
2003  /// with this OperandBundleUser.
2005  auto *NonConstThis = const_cast<CallBase *>(this);
2006  return NonConstThis->bundle_op_info_begin();
2007  }
2008 
2009  /// Return the end of the list of BundleOpInfo instances associated
2010  /// with this OperandBundleUser.
2012  if (!hasDescriptor())
2013  return nullptr;
2014 
2015  uint8_t *BytesEnd = getDescriptor().end();
2016  return reinterpret_cast<bundle_op_iterator>(BytesEnd);
2017  }
2018 
2019  /// Return the end of the list of BundleOpInfo instances associated
2020  /// with this OperandBundleUser.
2022  auto *NonConstThis = const_cast<CallBase *>(this);
2023  return NonConstThis->bundle_op_info_end();
2024  }
2025 
2026  /// Return the range [\p bundle_op_info_begin, \p bundle_op_info_end).
2028  return make_range(bundle_op_info_begin(), bundle_op_info_end());
2029  }
2030 
2031  /// Return the range [\p bundle_op_info_begin, \p bundle_op_info_end).
2033  return make_range(bundle_op_info_begin(), bundle_op_info_end());
2034  }
2035 
2036  /// Populate the BundleOpInfo instances and the Use& vector from \p
2037  /// Bundles. Return the op_iterator pointing to the Use& one past the last
2038  /// last bundle operand use.
2039  ///
2040  /// Each \p OperandBundleDef instance is tracked by a OperandBundleInfo
2041  /// instance allocated in this User's descriptor.
2042  op_iterator populateBundleOperandInfos(ArrayRef<OperandBundleDef> Bundles,
2043  const unsigned BeginIndex);
2044 
2045  /// Return the BundleOpInfo for the operand at index OpIdx.
2046  ///
2047  /// It is an error to call this with an OpIdx that does not correspond to an
2048  /// bundle operand.
2049  const BundleOpInfo &getBundleOpInfoForOperand(unsigned OpIdx) const {
2050  for (auto &BOI : bundle_op_infos())
2051  if (BOI.Begin <= OpIdx && OpIdx < BOI.End)
2052  return BOI;
2053 
2054  llvm_unreachable("Did not find operand bundle for operand!");
2055  }
2056 
2057 protected:
2058  /// Return the total number of values used in \p Bundles.
2060  unsigned Total = 0;
2061  for (auto &B : Bundles)
2062  Total += B.input_size();
2063  return Total;
2064  }
2065 
2066  /// @}
2067  // End of operand bundle API.
2068 
2069 private:
2070  bool hasFnAttrOnCalledFunction(Attribute::AttrKind Kind) const;
2071  bool hasFnAttrOnCalledFunction(StringRef Kind) const;
2072 
2073  template <typename AttrKind> bool hasFnAttrImpl(AttrKind Kind) const {
2074  if (Attrs.hasAttribute(AttributeList::FunctionIndex, Kind))
2075  return true;
2076 
2077  // Operand bundles override attributes on the called function, but don't
2078  // override attributes directly present on the call instruction.
2079  if (isFnAttrDisallowedByOpBundle(Kind))
2080  return false;
2081 
2082  return hasFnAttrOnCalledFunction(Kind);
2083  }
2084 };
2085 
2086 template <>
2087 struct OperandTraits<CallBase> : public VariadicOperandTraits<CallBase, 1> {};
2088 
2090 
2091 //===----------------------------------------------------------------------===//
2092 // FuncletPadInst Class
2093 //===----------------------------------------------------------------------===//
2094 class FuncletPadInst : public Instruction {
2095 private:
2096  FuncletPadInst(const FuncletPadInst &CPI);
2097 
2098  explicit FuncletPadInst(Instruction::FuncletPadOps Op, Value *ParentPad,
2099  ArrayRef<Value *> Args, unsigned Values,
2100  const Twine &NameStr, Instruction *InsertBefore);
2101  explicit FuncletPadInst(Instruction::FuncletPadOps Op, Value *ParentPad,
2102  ArrayRef<Value *> Args, unsigned Values,
2103  const Twine &NameStr, BasicBlock *InsertAtEnd);
2104 
2105  void init(Value *ParentPad, ArrayRef<Value *> Args, const Twine &NameStr);
2106 
2107 protected:
2108  // Note: Instruction needs to be a friend here to call cloneImpl.
2109  friend class Instruction;
2110  friend class CatchPadInst;
2111  friend class CleanupPadInst;
2112 
2113  FuncletPadInst *cloneImpl() const;
2114 
2115 public:
2116  /// Provide fast operand accessors
2118 
2119  /// getNumArgOperands - Return the number of funcletpad arguments.
2120  ///
2121  unsigned getNumArgOperands() const { return getNumOperands() - 1; }
2122 
2123  /// Convenience accessors
2124 
2125  /// Return the outer EH-pad this funclet is nested within.
2126  ///
2127  /// Note: This returns the associated CatchSwitchInst if this FuncletPadInst
2128  /// is a CatchPadInst.
2129  Value *getParentPad() const { return Op<-1>(); }
2130  void setParentPad(Value *ParentPad) {
2131  assert(ParentPad);
2132  Op<-1>() = ParentPad;
2133  }
2134 
2135  /// getArgOperand/setArgOperand - Return/set the i-th funcletpad argument.
2136  ///
2137  Value *getArgOperand(unsigned i) const { return getOperand(i); }
2138  void setArgOperand(unsigned i, Value *v) { setOperand(i, v); }
2139 
2140  /// arg_operands - iteration adapter for range-for loops.
2141  op_range arg_operands() { return op_range(op_begin(), op_end() - 1); }
2142 
2143  /// arg_operands - iteration adapter for range-for loops.
2145  return const_op_range(op_begin(), op_end() - 1);
2146  }
2147 
2148  // Methods for support type inquiry through isa, cast, and dyn_cast:
2149  static bool classof(const Instruction *I) { return I->isFuncletPad(); }
2150  static bool classof(const Value *V) {
2151  return isa<Instruction>(V) && classof(cast<Instruction>(V));
2152  }
2153 };
2154 
2155 template <>
2157  : public VariadicOperandTraits<FuncletPadInst, /*MINARITY=*/1> {};
2158 
2160 
2161 } // end namespace llvm
2162 
2163 #endif // LLVM_IR_INSTRTYPES_H
bool isFPPredicate() const
Definition: InstrTypes.h:801
void setArgOperand(unsigned i, Value *v)
Definition: InstrTypes.h:2138
static BinaryOperator * CreateFMulFMF(Value *V1, Value *V2, BinaryOperator *FMFSource, const Twine &Name="")
Definition: InstrTypes.h:245
const NoneType None
Definition: None.h:23
bool hasOperandBundles() const
Return true if this User has any operand bundles.
Definition: InstrTypes.h:1704
iterator_range< User::op_iterator > data_ops()
Definition: InstrTypes.h:1147
bool hasReadingOperandBundles() const
Return true if this operand bundle user has operand bundles that may read from the heap...
Definition: InstrTypes.h:1829
Predicate getNonStrictPredicate() const
For example, SGT -> SGE, SLT -> SLE, ULT -> ULE, UGT -> UGE.
Definition: InstrTypes.h:850
bool hasClobberingOperandBundles() const
Return true if this operand bundle user has operand bundles that may write to the heap...
Definition: InstrTypes.h:1838
User::op_iterator data_operands_end()
Definition: InstrTypes.h:1139
A parsed version of the target data layout string in and methods for querying it. ...
Definition: DataLayout.h:110
reference emplace_back(ArgTypes &&... Args)
Definition: SmallVector.h:645
bool data_operands_empty() const
Definition: InstrTypes.h:1153
Attribute getParamAttr(unsigned ArgNo, Attribute::AttrKind Kind) const
Return the attribute object that exists at the arg index.
Definition: Attributes.h:586
bool cannotDuplicate() const
Determine if the invoke cannot be duplicated.
Definition: InstrTypes.h:1660
void setCalledFunction(FunctionCallee Fn)
Sets the function called, including updating the function type.
Definition: InstrTypes.h:1305
This class is the base class for the comparison instructions.
Definition: InstrTypes.h:699
unsigned HasDescriptor
Definition: Value.h:120
Type * getSrcTy() const
Return the source type, as a convenience.
Definition: InstrTypes.h:674
static IntegerType * getInt1Ty(LLVMContext &C)
Definition: Type.cpp:172
bool doesNotAccessMemory(unsigned OpNo) const
Definition: InstrTypes.h:1528
const_iterator begin(StringRef path, Style style=Style::native)
Get begin iterator over path.
Definition: Path.cpp:224
OperandBundleDefT(std::string Tag, ArrayRef< InputTy > Inputs)
Definition: InstrTypes.h:1037
static Type * makeCmpResultType(Type *opnd_type)
Create a result type for fcmp/icmp.
Definition: InstrTypes.h:952
bool isFuncletPad() const
Definition: Instruction.h:134
static BinaryOperator * CreateNUW(BinaryOps Opc, Value *V1, Value *V2, const Twine &Name, Instruction *I)
Definition: InstrTypes.h:297
This class represents lattice values for constants.
Definition: AllocatorList.h:23
BinaryOps getOpcode() const
Definition: InstrTypes.h:379
Various leaf nodes.
Definition: ISDOpcodes.h:59
static BinaryOperator * CreateExact(BinaryOps Opc, Value *V1, Value *V2, const Twine &Name="")
Definition: InstrTypes.h:304
static BinaryOperator * CreateNSW(BinaryOps Opc, Value *V1, Value *V2, const Twine &Name, BasicBlock *BB)
Definition: InstrTypes.h:272
bool isConvergent() const
Determine if the invoke is convergent.
Definition: InstrTypes.h:1666
amdgpu Simplify well known AMD library false FunctionCallee Value const Twine & Name
UnaryInstruction(Type *Ty, unsigned iType, Value *V, BasicBlock *IAE)
Definition: InstrTypes.h:64
A handy container for a FunctionType+Callee-pointer pair, which can be passed around as a single enti...
Definition: DerivedTypes.h:164
This provides a very simple, boring adaptor for a begin and end iterator into a range type...
unsigned getBundleOperandsStartIndex() const
Return the index of the first bundle operand in the Use array.
Definition: InstrTypes.h:1707
bool isArgOperand(const Use *U) const
Definition: InstrTypes.h:1238
unsigned getNumSubclassExtraOperands() const
Definition: InstrTypes.h:1093
void setDoesNotAccessMemory()
Definition: InstrTypes.h:1597
The two locations do not alias at all.
Definition: AliasAnalysis.h:84
unsigned getDataOperandNo(Value::const_user_iterator UI) const
Given a value use iterator, return the data operand corresponding to it.
Definition: InstrTypes.h:1171
LLVMContext & getContext() const
All values hold a context through their type.
Definition: Value.cpp:709
const Use & getOperandUse(unsigned i) const
Definition: User.h:182
void addParamAttr(unsigned ArgNo, Attribute Attr)
Adds the attribute to the indicated argument.
Definition: InstrTypes.h:1382
static bool classof(const Value *V)
Definition: InstrTypes.h:688
bool bundleOperandHasAttr(unsigned OpIdx, Attribute::AttrKind A) const
Return true if the bundle operand at index OpIdx has the attribute A.
Definition: InstrTypes.h:1854
void setArgOperand(unsigned i, Value *v)
Definition: InstrTypes.h:1223
Base class for all callable instructions (InvokeInst and CallInst) Holds everything related to callin...
Definition: InstrTypes.h:1077
User::op_iterator arg_end()
Return the iterator pointing to the end of the argument list.
Definition: InstrTypes.h:1189
unsigned getRetAlignment() const
Return the alignment of the return value.
typename std::vector< InputTy >::const_iterator input_iterator
Definition: InstrTypes.h:1047
Attribute getParamAttr(unsigned ArgNo, StringRef Kind) const
Get the attribute of a given kind from a given arg.
Definition: InstrTypes.h:1457
#define op(i)
OperandBundleUse getOperandBundleAt(unsigned Index) const
Return the operand bundle at a specific index.
Definition: InstrTypes.h:1748
User::op_iterator data_operands_begin()
data_operands_begin/data_operands_end - Return iterators iterating over the call / invoke argument li...
Definition: InstrTypes.h:1135
void addAttribute(unsigned i, Attribute::AttrKind Kind)
adds the attribute to the list of attributes.
Definition: InstrTypes.h:1360
ArrayRef< InputTy > inputs() const
Definition: InstrTypes.h:1045
bool isTrueWhenEqual(CondCode Cond)
Return true if the specified condition returns true if the two operands to the condition are equal...
Definition: ISDOpcodes.h:1036
void copyIRFlags(const Value *V, bool IncludeWrapFlags=true)
Convenience method to copy supported exact, fast-math, and (optionally) wrapping flags from V to this...
void setCalledFunction(FunctionType *FTy, Value *Fn)
Sets the function called, including updating to the specified function type.
Definition: InstrTypes.h:1311
unsigned getParamAlignment(unsigned ArgNo) const
Extract the alignment for a call or parameter (0=unknown).
Definition: InstrTypes.h:1550
UnaryInstruction(Type *Ty, unsigned iType, Value *V, Instruction *IB=nullptr)
Definition: InstrTypes.h:59
static BinaryOperator * CreateFSubFMF(Value *V1, Value *V2, BinaryOperator *FMFSource, const Twine &Name="")
Definition: InstrTypes.h:240
static bool classof(const Instruction *I)
Definition: InstrTypes.h:1112
void addDereferenceableOrNullAttr(unsigned i, uint64_t Bytes)
adds the dereferenceable_or_null attribute to the list of attributes.
Definition: InstrTypes.h:1428
CallBase(AttributeList const &A, FunctionType *FT, ArgsTy &&... Args)
Definition: InstrTypes.h:1086
bool hasAttribute(unsigned Index, Attribute::AttrKind Kind) const
Return true if the attribute exists at the given index.
static BinaryOperator * CreateNSW(BinaryOps Opc, Value *V1, Value *V2, const Twine &Name, Instruction *I)
Definition: InstrTypes.h:278
LLVMContext & getContext() const
Return the LLVMContext in which this type was uniqued.
Definition: Type.h:129
Predicate getSignedPredicate()
For example, ULT->SLT, ULE->SLE, UGT->SGT, UGE->SGE, SLT->Failed assert.
Definition: InstrTypes.h:898
bool isBundleOperand(unsigned Idx) const
Return true if the operand at index Idx is a bundle operand.
Definition: InstrTypes.h:1719
Value * getArgOperand(unsigned i) const
Definition: InstrTypes.h:1218
static BinaryOperator * CreateNSW(BinaryOps Opc, Value *V1, Value *V2, const Twine &Name="")
Definition: InstrTypes.h:266
iterator_range< User::const_op_iterator > arg_operands() const
Definition: InstrTypes.h:1213
void removeParamAttr(unsigned ArgNo, StringRef Kind)
Removes the attribute from the given argument.
Definition: InstrTypes.h:1412
bool doesNotCapture(unsigned OpNo) const
Determine whether this data operand is not captured.
Definition: InstrTypes.h:1500
Definition: BitVector.h:937
bool isSigned() const
Definition: InstrTypes.h:879
size_t input_size() const
Definition: InstrTypes.h:1049
unsigned countOperandBundlesOfType(StringRef Name) const
Return the number of operand bundles with the tag Name attached to this instruction.
Definition: InstrTypes.h:1755
bool onlyAccessesInaccessibleMemory() const
Determine if the function may only access memory that is inaccessible from the IR.
Definition: InstrTypes.h:1628
Used to keep track of an operand bundle.
Definition: InstrTypes.h:1918
Predicate getInversePredicate() const
For example, EQ -> NE, UGT -> ULE, SLT -> SGE, OEQ -> UNE, UGT -> OLE, OLT -> UGE, etc.
Definition: InstrTypes.h:808
Twine - A lightweight data structure for efficiently representing the concatenation of temporary valu...
Definition: Twine.h:80
bool onlyAccessesArgMemory() const
Determine if the call can access memmory only using pointers based on its arguments.
Definition: InstrTypes.h:1619
uint64_t getDereferenceableBytes(unsigned Index) const
Get the number of dereferenceable bytes (or zero if unknown).
This is the base class for all instructions that perform data casts.
Definition: InstrTypes.h:416
static Constant * getNegativeZero(Type *Ty)
Definition: Constants.cpp:768
bool arg_empty() const
Definition: InstrTypes.h:1205
bool doesNotReadMemory() const
Determine if the call does not access or only writes memory.
Definition: InstrTypes.h:1610
bundle_op_iterator bundle_op_info_end()
Return the end of the list of BundleOpInfo instances associated with this OperandBundleUser.
Definition: InstrTypes.h:2011
CastInst(Type *Ty, unsigned iType, Value *S, const Twine &NameStr, BasicBlock *InsertAtEnd)
Constructor with insert-at-end-of-block semantics for subclasses.
Definition: InstrTypes.h:425
A Use represents the edge between a Value definition and its users.
Definition: Use.h:55
static Optional< unsigned > getOpcode(ArrayRef< VPValue *> Values)
Returns the opcode of Values or ~0 if they do not all agree.
Definition: VPlanSLP.cpp:196
This class consists of common code factored out of the SmallVector class to reduce code duplication b...
Definition: APFloat.h:41
uint32_t getTagID() const
Return the tag of this operand bundle as an integer.
Definition: InstrTypes.h:1005
bool isUnsigned() const
Definition: InstrTypes.h:885
static bool classof(const Value *V)
Definition: InstrTypes.h:1117
This file contains the simple types necessary to represent the attributes associated with functions a...
void removeAttribute(unsigned i, StringRef Kind)
removes the attribute from the list of attributes.
Definition: InstrTypes.h:1397
bool operator==(const BundleOpInfo &Other) const
Definition: InstrTypes.h:1931
static bool isOrdered(const Instruction *I)
Definition: MemorySSA.cpp:1703
bool isBundleOperand(const Use *U) const
Returns true if the use is a bundle operand.
Definition: InstrTypes.h:1725
static BinaryOperator * CreateFRemFMF(Value *V1, Value *V2, BinaryOperator *FMFSource, const Twine &Name="")
Definition: InstrTypes.h:255
AttributeList getAttributes(LLVMContext &C, ID id)
Return the attributes for an intrinsic.
static unsigned CountBundleInputs(ArrayRef< OperandBundleDef > Bundles)
Return the total number of values used in Bundles.
Definition: InstrTypes.h:2059
OtherOps getOpcode() const
Get the opcode casted to the right type.
Definition: InstrTypes.h:779
bool doesNotThrow() const
Determine if the call cannot unwind.
Definition: InstrTypes.h:1654
#define DEFINE_TRANSPARENT_OPERAND_ACCESSORS(CLASS, VALUECLASS)
Macro for generating out-of-class operand accessor definitions.
Class to represent function types.
Definition: DerivedTypes.h:102
static BinaryOperator * CreateFAddFMF(Value *V1, Value *V2, BinaryOperator *FMFSource, const Twine &Name="")
Definition: InstrTypes.h:235
void setIsExact(bool b=true)
Set or clear the exact flag on this instruction, which must be an operator which supports this flag...
Instruction::CastOps getOpcode() const
Return the opcode of this CastInst.
Definition: InstrTypes.h:669
bool hasOperandBundlesOtherThan(ArrayRef< uint32_t > IDs) const
Return true if this operand bundle user contains operand bundles with tags other than those specified...
Definition: InstrTypes.h:1873
const BundleOpInfo & getBundleOpInfoForOperand(unsigned OpIdx) const
Return the BundleOpInfo for the operand at index OpIdx.
Definition: InstrTypes.h:2049
Type * getType() const
All values are typed, get the type of this value.
Definition: Value.h:244
User::const_op_iterator data_operands_end() const
Definition: InstrTypes.h:1144
void setConvergent()
Definition: InstrTypes.h:1667
bool isFuncletOperandBundle() const
Return true if this is a "funclet" operand bundle.
Definition: InstrTypes.h:1015
unsigned getRetAlignment() const
Extract the alignment of the return value.
Definition: InstrTypes.h:1547
void setOnlyReadsMemory()
Definition: InstrTypes.h:1605
void setCalledFunction(Function *Fn)
Sets the function called, including updating the function type.
Definition: InstrTypes.h:1300
Value * getCalledOperand() const
Definition: InstrTypes.h:1253
void setParentPad(Value *ParentPad)
Definition: InstrTypes.h:2130
const_op_range arg_operands() const
arg_operands - iteration adapter for range-for loops.
Definition: InstrTypes.h:2144
void setCalledOperand(Value *V)
Definition: InstrTypes.h:1297
uint64_t getDereferenceableOrNullBytes(unsigned Index) const
Get the number of dereferenceable_or_null bytes (or zero if unknown).
ArrayRef - Represent a constant reference to an array (0 or more elements consecutively in memory)...
Definition: APInt.h:32
OperandBundleUse getOperandBundleForOperand(unsigned OpIdx) const
Return the operand bundle for the operand at index OpIdx.
Definition: InstrTypes.h:1823
unsigned getOpcode() const
Returns a member of one of the enums like Instruction::Add.
Definition: Instruction.h:125
iterator_range< User::op_iterator > arg_operands()
Definition: InstrTypes.h:1210
OperandBundleUse(StringMapEntry< uint32_t > *Tag, ArrayRef< Use > Inputs)
Definition: InstrTypes.h:981
bool doesNoCfCheck() const
Determine if the call should not perform indirect branch tracking.
Definition: InstrTypes.h:1651
unsigned getNumOperandBundles() const
Return the number of operand bundles associated with this User.
Definition: InstrTypes.h:1699
constexpr char Attrs[]
Key for Kernel::Metadata::mAttrs.
uint32_t Begin
The index in the Use& vector where operands for this operand bundle starts.
Definition: InstrTypes.h:1925
void setOnlyAccessesInaccessibleMemOrArgMem()
Definition: InstrTypes.h:1640
Optional< OperandBundleUse > getOperandBundle(StringRef Name) const
Return an operand bundle by name, if present.
Definition: InstrTypes.h:1779
bool hasFnAttr(StringRef Kind) const
Determine whether this call has the given attribute.
Definition: InstrTypes.h:1357
bool hasAttrSomewhere(Attribute::AttrKind Kind, unsigned *Index=nullptr) const
Return true if the specified attribute is set for at least one parameter or for the return value...
static bool classof(const Instruction *I)
Methods for support type inquiry through isa, cast, and dyn_cast:
Definition: InstrTypes.h:943
#define P(N)
initializer< Ty > init(const Ty &Val)
Definition: CommandLine.h:432
uint64_t getDereferenceableOrNullBytes(unsigned i) const
Extract the number of dereferenceable_or_null bytes for a call or parameter (0=unknown).
Definition: InstrTypes.h:1562
static bool isIntPredicate(Predicate P)
Definition: InstrTypes.h:795
static GCRegistry::Add< OcamlGC > B("ocaml", "ocaml 3.10-compatible GC")
LLVM_NODISCARD AttributeList addDereferenceableOrNullAttr(LLVMContext &C, unsigned Index, uint64_t Bytes) const
Add the dereferenceable_or_null attribute to the attribute set at the given index.
bool isNoInline() const
Return true if the call should not be inlined.
Definition: InstrTypes.h:1591
unsigned arg_size() const
Definition: InstrTypes.h:1206
Value * getCalledValue() const
Definition: InstrTypes.h:1257
LLVM Basic Block Representation.
Definition: BasicBlock.h:57
void setCannotDuplicate()
Definition: InstrTypes.h:1661
LLVM_NODISCARD AttributeList addParamAttribute(LLVMContext &C, unsigned ArgNo, Attribute::AttrKind Kind) const
Add an argument attribute to the list.
Definition: Attributes.h:402
The instances of the Type class are immutable: once they are created, they are never changed...
Definition: Type.h:45
bool isNoBuiltin() const
Return true if the call should not be treated as a call to a builtin.
Definition: InstrTypes.h:1582
unsigned countOperandBundlesOfType(uint32_t ID) const
Return the number of operand bundles with the tag ID attached to this instruction.
Definition: InstrTypes.h:1766
bool isInlineAsm() const
Check if this call is an inline asm statement.
Definition: InstrTypes.h:1333
ArrayRef< Use > Inputs
Definition: InstrTypes.h:978
This file contains the declarations for the subclasses of Constant, which represent the different fla...
bool hasInAllocaArgument() const
Determine if there are is an inalloca argument.
Definition: InstrTypes.h:1522
void setIsNoInline()
Definition: InstrTypes.h:1592
static BinaryOperator * CreateNUW(BinaryOps Opc, Value *V1, Value *V2, const Twine &Name="")
Definition: InstrTypes.h:285
FunctionType * getFunctionType() const
Definition: InstrTypes.h:1121
void mutateFunctionType(FunctionType *FTy)
Definition: InstrTypes.h:1123
unsigned getNumTotalBundleOperands() const
Return the total number operands (not operand bundles) used by every operand bundle in this OperandBu...
Definition: InstrTypes.h:1736
iterator_range< User::const_op_iterator > args() const
Definition: InstrTypes.h:1202
static BinaryOperator * CreateNUW(BinaryOps Opc, Value *V1, Value *V2, const Twine &Name, BasicBlock *BB)
Definition: InstrTypes.h:291
bool any_of(R &&range, UnaryPredicate P)
Provide wrappers to std::any_of which take ranges instead of having to pass begin/end explicitly...
Definition: STLExtras.h:1192
static BinaryOperator * CreateExact(BinaryOps Opc, Value *V1, Value *V2, const Twine &Name, BasicBlock *BB)
Definition: InstrTypes.h:310
bool isBinaryOp() const
Definition: Instruction.h:130
void setCallingConv(CallingConv::ID CC)
Definition: InstrTypes.h:1325
amdgpu Simplify well known AMD library false FunctionCallee Value * Arg
static bool classof(const Value *V)
Definition: InstrTypes.h:394
bool isDeoptOperandBundle() const
Return true if this is a "deopt" operand bundle.
Definition: InstrTypes.h:1010
unsigned getBundleOperandsEndIndex() const
Return the index of the last bundle operand in the Use array.
Definition: InstrTypes.h:1713
bool hasDescriptor() const
Definition: InstrTypes.h:1091
bool onlyAccessesInaccessibleMemOrArgMem() const
Determine if the function may only access memory that is either inaccessible from the IR or pointed t...
Definition: InstrTypes.h:1637
bool isFnAttrDisallowedByOpBundle(Attribute::AttrKind A) const
Is the function attribute A disallowed by some operand bundle on this operand bundle user...
Definition: InstrTypes.h:1892
static bool classof(const Instruction *I)
Definition: InstrTypes.h:79
uint64_t getDereferenceableBytes(unsigned i) const
Extract the number of dereferenceable bytes for a call or parameter (0=unknown).
Definition: InstrTypes.h:1556
const_bundle_op_iterator bundle_op_info_begin() const
Return the start of the list of BundleOpInfo instances associated with this OperandBundleUser.
Definition: InstrTypes.h:2004
bool isByValOrInAllocaArgument(unsigned ArgNo) const
Determine whether this argument is passed by value or in an alloca.
Definition: InstrTypes.h:1515
#define DECLARE_TRANSPARENT_OPERAND_ACCESSORS(VALUECLASS)
Macro for generating in-class operand accessor declarations.
Attribute getAttribute(unsigned Index, Attribute::AttrKind Kind) const
Return the attribute object that exists at the given index.
bool isCast() const
Definition: Instruction.h:133
bool hasFnAttr(Attribute::AttrKind Kind) const
Determine whether this call has the given attribute.
Definition: InstrTypes.h:1350
bool onlyReadsMemory() const
Determine if the call does not access or only reads memory.
Definition: InstrTypes.h:1602
iterator_range< User::op_iterator > args()
Iteration adapter for range-for loops.
Definition: InstrTypes.h:1199
#define llvm_unreachable(msg)
Marks that the current location is not supposed to be reachable.
const_bundle_op_iterator bundle_op_info_end() const
Return the end of the list of BundleOpInfo instances associated with this OperandBundleUser.
Definition: InstrTypes.h:2021
bool isByValArgument(unsigned ArgNo) const
Determine whether this argument is passed by value.
Definition: InstrTypes.h:1505
User::const_op_iterator arg_begin() const
Definition: InstrTypes.h:1184
Value * getParentPad() const
Convenience accessors.
Definition: InstrTypes.h:2129
hexagon gen pred
iterator_range< T > make_range(T x, T y)
Convenience function for iterating over sub-ranges.
bool operandHasAttr(unsigned Idx, Attribute::AttrKind A) const
Return true if the operand at index Idx in this operand bundle has the attribute A.
Definition: InstrTypes.h:986
LLVM_NODISCARD AttributeList removeParamAttribute(LLVMContext &C, unsigned ArgNo, Attribute::AttrKind Kind) const
Remove the specified attribute at the specified arg index from this attribute list.
Definition: Attributes.h:451
void setHasNoSignedWrap(bool b=true)
Set or clear the nsw flag on this instruction, which must be an operator which supports this flag...
void addParamAttr(unsigned ArgNo, Attribute::AttrKind Kind)
Adds the attribute to the indicated argument.
Definition: InstrTypes.h:1374
Predicate getPredicate(unsigned Condition, unsigned Hint)
Return predicate consisting of specified condition and hint bits.
Definition: PPCPredicates.h:87
bool doesNotReturn() const
Determine if the call cannot return.
Definition: InstrTypes.h:1645
bool returnDoesNotAlias() const
Determine if the return value is marked with NoAlias attribute.
Definition: InstrTypes.h:1572
OperandBundleUse operandBundleFromBundleOpInfo(const BundleOpInfo &BOI) const
Simple helper function to map a BundleOpInfo to an OperandBundleUse.
Definition: InstrTypes.h:1939
bool isCallee(Value::const_user_iterator UI) const
Determine whether the passed iterator points to the callee operand&#39;s Use.
Definition: InstrTypes.h:1272
static unsigned getIntrinsicID(const SDNode *N)
void setOnlyAccessesInaccessibleMemory()
Definition: InstrTypes.h:1631
OperandBundleDefT(std::string Tag, std::vector< InputTy > Inputs)
Definition: InstrTypes.h:1035
bool isInAllocaArgument(unsigned ArgNo) const
Determine whether this argument is passed in an alloca.
Definition: InstrTypes.h:1510
FunctionType * getType(LLVMContext &Context, ID id, ArrayRef< Type *> Tys=None)
Return the function type for an intrinsic.
Definition: Function.cpp:978
CastInst(Type *Ty, unsigned iType, Value *S, const Twine &NameStr="", Instruction *InsertBefore=nullptr)
Constructor with insert-before-instruction semantics for subclasses.
Definition: InstrTypes.h:419
Predicate
Predicate - These are "(BI << 5) | BO" for various predicates.
Definition: PPCPredicates.h:26
void setDoesNotReadMemory()
Definition: InstrTypes.h:1613
User::const_op_iterator arg_end() const
Definition: InstrTypes.h:1194
Type * getReturnType() const
Definition: DerivedTypes.h:123
#define DEFINE_HELPERS(OPC, NUWNSWEXACT)
Definition: InstrTypes.h:323
bool hasByValArgument() const
Determine if any call argument is an aggregate passed by value.
Definition: InstrTypes.h:1685
void getOperandBundlesAsDefs(SmallVectorImpl< OperandBundleDef > &Defs) const
Return the list of operand bundles attached to this instruction as a vector of OperandBundleDefs.
Definition: InstrTypes.h:1814
static GCRegistry::Add< StatepointGC > D("statepoint-example", "an example strategy for statepoint")
StringMapEntry< uint32_t > * Tag
The operand bundle tag, interned by LLVMContextImpl::getOrInsertBundleTag.
Definition: InstrTypes.h:1921
Type * getDestTy() const
Return the destination type, as a convenience.
Definition: InstrTypes.h:676
Use & getArgOperandUse(unsigned i)
Definition: InstrTypes.h:1233
AttributeList getAttributes() const
Return the parameter attributes for this call.
Definition: InstrTypes.h:1343
unsigned getNumArgOperands() const
getNumArgOperands - Return the number of funcletpad arguments.
Definition: InstrTypes.h:2121
static BinaryOperator * CreateFDivFMF(Value *V1, Value *V2, BinaryOperator *FMFSource, const Twine &Name="")
Definition: InstrTypes.h:250
void setValueSubclassData(unsigned short D)
Definition: Value.h:655
void setPredicate(Predicate P)
Set the predicate for this instruction to the specified value.
Definition: InstrTypes.h:789
Predicate getFlippedStrictnessPredicate() const
For predicate of kind "is X or equal to 0" returns the predicate "is X".
Definition: InstrTypes.h:839
FunctionType * getFunctionType() const
Returns the FunctionType for me.
Definition: Function.h:163
bool isIntPredicate() const
Definition: InstrTypes.h:802
bool isTrueWhenEqual() const
This is just a convenience.
Definition: InstrTypes.h:904
A range adaptor for a pair of iterators.
Class to represent vector types.
Definition: DerivedTypes.h:424
bool isFalseWhenEqual() const
This is just a convenience.
Definition: InstrTypes.h:910
void setNotConvergent()
Definition: InstrTypes.h:1670
static bool isFPPredicate(Predicate P)
Definition: InstrTypes.h:791
StringRef getTag() const
Definition: InstrTypes.h:1053
A lightweight accessor for an operand bundle meant to be passed around by value.
Definition: InstrTypes.h:977
Attribute getAttribute(unsigned i, StringRef Kind) const
Get the attribute of a given kind at a position.
Definition: InstrTypes.h:1446
bool doesNotAccessMemory() const
Determine if the call does not access memory.
Definition: InstrTypes.h:1596
Use & getCalledOperandUse()
Definition: InstrTypes.h:1260
static BinaryOperator * CreateExact(BinaryOps Opc, Value *V1, Value *V2, const Twine &Name, Instruction *I)
Definition: InstrTypes.h:316
bool isFnAttrDisallowedByOpBundle(StringRef S) const
Is the function attribute S disallowed by some operand bundle on this operand bundle user...
Definition: InstrTypes.h:1884
Attribute getAttribute(unsigned i, Attribute::AttrKind Kind) const
Get the attribute of a given kind at a position.
Definition: InstrTypes.h:1441
user_iterator_impl< const User > const_user_iterator
Definition: Value.h:369
bool hasStructRetAttr() const
Determine if the call returns a structure through first pointer argument.
Definition: InstrTypes.h:1676
User::op_iterator arg_begin()
Return the iterator pointing to the beginning of the argument list.
Definition: InstrTypes.h:1183
void addDereferenceableAttr(unsigned i, uint64_t Bytes)
adds the dereferenceable attribute to the list of attributes.
Definition: InstrTypes.h:1420
OperandBundleDefT(const OperandBundleUse &OBU)
Definition: InstrTypes.h:1040
Predicate getPredicate() const
Return the predicate for this instruction.
Definition: InstrTypes.h:784
static BinaryOperator * CreateWithCopiedFlags(BinaryOps Opc, Value *V1, Value *V2, BinaryOperator *CopyBO, const Twine &Name="")
Definition: InstrTypes.h:226
unsigned getParamAlignment(unsigned ArgNo) const
Return the alignment for the specified function parameter.
bool isBundleOperand(Value::const_user_iterator UI) const
Definition: InstrTypes.h:1730
LLVM_NODISCARD AttributeList addAttribute(LLVMContext &C, unsigned Index, Attribute::AttrKind Kind) const
Add an attribute to the attribute set at the given index.
unsigned getNumArgOperands() const
Definition: InstrTypes.h:1216
Optional< OperandBundleUse > getOperandBundle(uint32_t ID) const
Return an operand bundle by tag ID, if present.
Definition: InstrTypes.h:1795
LLVM_NODISCARD AttributeList addDereferenceableAttr(LLVMContext &C, unsigned Index, uint64_t Bytes) const
Add the dereferenceable attribute to the attribute set at the given index.
The highest possible calling convention ID. Must be some 2^k - 1.
Definition: CallingConv.h:226
bool isArgOperand(Value::const_user_iterator UI) const
Definition: InstrTypes.h:1243
UnaryOps getOpcode() const
Definition: InstrTypes.h:156
AttributeList Attrs
parameter attributes for callable
Definition: InstrTypes.h:1082
iterator_range< const_bundle_op_iterator > bundle_op_infos() const
Return the range [bundle_op_info_begin, bundle_op_info_end).
Definition: InstrTypes.h:2032
CallingConv::ID getCallingConv() const
Definition: InstrTypes.h:1321
input_iterator input_begin() const
Definition: InstrTypes.h:1050
LLVM_NODISCARD AttributeList removeAttribute(LLVMContext &C, unsigned Index, Attribute::AttrKind Kind) const
Remove the specified attribute at the specified index from this attribute list.
Function * getCalledFunction() const
Returns the function called, or null if this is an indirect function invocation.
Definition: InstrTypes.h:1264
bool isDataOperand(const Use *U) const
Definition: InstrTypes.h:1160
bool onlyReadsMemory(unsigned OpNo) const
Definition: InstrTypes.h:1534
input_iterator input_end() const
Definition: InstrTypes.h:1051
#define I(x, y, z)
Definition: MD5.cpp:58
StringRef getTagName() const
Return the tag of this operand bundle as a string.
Definition: InstrTypes.h:996
unsigned getDataOperandNo(const Use *U) const
Given a use for a data operand, get the data operand number that corresponds to it.
Definition: InstrTypes.h:1177
unsigned data_operands_size() const
Definition: InstrTypes.h:1156
uint32_t End
The index in the Use& vector where operands for this operand bundle ends.
Definition: InstrTypes.h:1929
const Use & getArgOperandUse(unsigned i) const
Wrappers for getting the Use of a call argument.
Definition: InstrTypes.h:1229
Compile-time customization of User operands.
Definition: User.h:42
void setAttributes(AttributeList A)
Set the parameter attributes for this call.
Definition: InstrTypes.h:1347
void removeParamAttr(unsigned ArgNo, Attribute::AttrKind Kind)
Removes the attribute from the given argument.
Definition: InstrTypes.h:1404
FunctionType * getFunctionType()
Definition: DerivedTypes.h:181
static BinaryOperator * CreateFNegFMF(Value *Op, BinaryOperator *FMFSource, const Twine &Name="")
Definition: InstrTypes.h:260
static BinaryOperator * CreateNeg(Value *S1, const Twine &Name, Instruction *InsertBefore, Value *FlagsOp)
bool doesNotReadMemory(unsigned OpNo) const
Definition: InstrTypes.h:1541
void setDoesNotReturn()
Definition: InstrTypes.h:1646
static bool isReturnNonNull(Function *F, const SCCNodeSet &SCCNodes, bool &Speculative)
Tests whether this function is known to not return null.
bool isStrictFP() const
Determine if the call requires strict floating point semantics.
Definition: InstrTypes.h:1588
void mutateType(Type *Ty)
Mutate the type of this Value to be of the specified type.
Definition: Value.h:603
bool hasIdenticalOperandBundleSchema(const CallBase &Other) const
Return true if Other has the same sequence of operand bundle tags with the same number of operands on...
Definition: InstrTypes.h:1863
Instruction(const Instruction &)=delete
static bool classof(const Value *V)
Definition: InstrTypes.h:947
void setHasNoUnsignedWrap(bool b=true)
Set or clear the nuw flag on this instruction, which must be an operator which supports this flag...
assert(ImpDefSCC.getReg()==AMDGPU::SCC &&ImpDefSCC.isDef())
op_range arg_operands()
arg_operands - iteration adapter for range-for loops.
Definition: InstrTypes.h:2141
bool hasArgument(const Value *V) const
Returns true if this CallSite passes the given Value* as an argument to the called function...
Definition: InstrTypes.h:1249
bool isDataOperand(Value::const_user_iterator UI) const
Definition: InstrTypes.h:1165
const Function * getCaller() const
Definition: InstrTypes.h:1281
LLVM Value Representation.
Definition: Value.h:72
void setOnlyAccessesArgMemory()
Definition: InstrTypes.h:1622
static bool classof(const Value *V)
Definition: InstrTypes.h:86
static VectorType * get(Type *ElementType, unsigned NumElements)
This static method is the primary way to construct an VectorType.
Definition: Type.cpp:605
A container for an operand bundle being viewed as a set of values rather than a set of uses...
Definition: InstrTypes.h:1030
static bool isCommutative(Instruction *I)
bundle_op_iterator bundle_op_info_begin()
Return the start of the list of BundleOpInfo instances associated with this OperandBundleUser.
Definition: InstrTypes.h:1994
StringRef - Represent a constant reference to a string, i.e.
Definition: StringRef.h:48
Predicate getSwappedPredicate() const
For example, EQ->EQ, SLE->SGE, ULT->UGT, OEQ->OEQ, ULE->UGE, OLT->OGT, etc.
Definition: InstrTypes.h:824
iterator_range< bundle_op_iterator > bundle_op_infos()
Return the range [bundle_op_info_begin, bundle_op_info_end).
Definition: InstrTypes.h:2027
FixedNumOperandTraits - determine the allocation regime of the Use array when it is a prefix to the U...
Definition: OperandTraits.h:30
Value * getArgOperand(unsigned i) const
getArgOperand/setArgOperand - Return/set the i-th funcletpad argument.
Definition: InstrTypes.h:2137
Attribute getParamAttr(unsigned ArgNo, Attribute::AttrKind Kind) const
Get the attribute of a given kind from a given arg.
Definition: InstrTypes.h:1451
static bool classof(const Instruction *I)
Definition: InstrTypes.h:391
VariadicOperandTraits - determine the allocation regime of the Use array when it is a prefix to the U...
Definition: OperandTraits.h:68
const Use & getCalledOperandUse() const
Definition: InstrTypes.h:1259
static bool classof(const Instruction *I)
Definition: InstrTypes.h:2149
bool dataOperandHasImpliedAttr(unsigned i, Attribute::AttrKind Kind) const
Return true if the data operand at index i has the attribute A.
Definition: InstrTypes.h:1475
static bool classof(const Instruction *I)
Methods for support type inquiry through isa, cast, and dyn_cast:
Definition: InstrTypes.h:685
void setDoesNotThrow()
Definition: InstrTypes.h:1655
FunctionType * FTy
Definition: InstrTypes.h:1083
constexpr char Args[]
Key for Kernel::Metadata::mArgs.
User::const_op_iterator data_operands_begin() const
Definition: InstrTypes.h:1136
static bool classof(const Value *V)
Definition: InstrTypes.h:2150
void removeAttribute(unsigned i, Attribute::AttrKind Kind)
removes the attribute from the list of attributes.
Definition: InstrTypes.h:1390
void addAttribute(unsigned i, Attribute Attr)
adds the attribute to the list of attributes.
Definition: InstrTypes.h:1367
bool isCallee(const Use *U) const
Determine whether this Use is the callee operand&#39;s Use.
Definition: InstrTypes.h:1277
AttrKind
This enumeration lists the attributes that can be associated with parameters, function results...
Definition: Attributes.h:69
iterator_range< User::const_op_iterator > data_ops() const
Definition: InstrTypes.h:1150
bool is_contained(R &&Range, const E &Element)
Wrapper function around std::find to detect if an element exists in a container.
Definition: STLExtras.h:1244
Predicate getSwappedPredicate(Predicate Opcode)
Assume the condition register is set by MI(a,b), return the predicate if we modify the instructions s...