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