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