1//===- llvm/InstrTypes.h - Important Instruction subclasses -----*- C++ -*-===// 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 7//===----------------------------------------------------------------------===// 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 13//===----------------------------------------------------------------------===// 15#ifndef LLVM_IR_INSTRTYPES_H 16#define LLVM_IR_INSTRTYPES_H 53//===----------------------------------------------------------------------===// 54// UnaryInstruction Class 55//===----------------------------------------------------------------------===// 63 :
Instruction(Ty, iType, AllocMarker, InsertBefore) {
68// allocate space for exactly one operand 69void *
operatornew(
size_t S) {
return User::operator
new(S, AllocMarker); }
70voidoperatordelete(
void *
Ptr) { User::operator
delete(
Ptr); }
72 /// Transparently provide more efficient getOperand methods. 75// Methods for support type inquiry through isa, cast, and dyn_cast: 77returnI->isUnaryOp() ||
I->getOpcode() == Instruction::Alloca ||
78I->getOpcode() == Instruction::Load ||
79I->getOpcode() == Instruction::VAArg ||
80I->getOpcode() == Instruction::ExtractValue ||
81I->getOpcode() == Instruction::Freeze ||
82 (
I->getOpcode() >= CastOpsBegin &&
I->getOpcode() < CastOpsEnd);
85return isa<Instruction>(V) &&
classof(cast<Instruction>(V));
96//===----------------------------------------------------------------------===// 98//===----------------------------------------------------------------------===// 107// Note: Instruction needs to be a friend here to call cloneImpl. 113 /// Construct a unary instruction, given the opcode and an operand. 114 /// Optionally (if InstBefore is specified) insert the instruction 115 /// into a BasicBlock right before the specified instruction. The specified 116 /// Instruction is allowed to be a dereferenced end iterator. 122 /// These methods just forward to Create, and are useful when you 123 /// statically know what type of instruction you're going to create. These 124 /// helpers just save some typing. 125#define HANDLE_UNARY_INST(N, OPC, CLASS) \ 126 static UnaryOperator *Create##OPC(Value *V, const Twine &Name = "") { \
127 return Create(Instruction::OPC, V, Name); \
129#include "llvm/IR/Instruction.def" 130#define HANDLE_UNARY_INST(N, OPC, CLASS) \ 131 static UnaryOperator *Create##OPC(Value *V, const Twine &Name, \ 132 InsertPosition InsertBefore = nullptr) { \ 133 return Create(Instruction::OPC, V, Name, InsertBefore); \ 135#include "llvm/IR/Instruction.def" 137static UnaryOperator *
157// Methods for support type inquiry through isa, cast, and dyn_cast: 162return isa<Instruction>(V) && classof(cast<Instruction>(V));
166//===----------------------------------------------------------------------===// 167// BinaryOperator Class 168//===----------------------------------------------------------------------===// 179// Note: Instruction needs to be a friend here to call cloneImpl. 185// allocate space for exactly two operands 186void *
operatornew(
size_t S) {
return User::operator
new(S, AllocMarker); }
187voidoperatordelete(
void *
Ptr) { User::operator
delete(
Ptr); }
189 /// Transparently provide more efficient getOperand methods. 192 /// Construct a binary instruction, given the opcode and the two 193 /// operands. Optionally (if InstBefore is specified) insert the instruction 194 /// into a BasicBlock right before the specified instruction. The specified 195 /// Instruction is allowed to be a dereferenced end iterator. 201 /// These methods just forward to Create, and are useful when you 202 /// statically know what type of instruction you're going to create. These 203 /// helpers just save some typing. 204#define HANDLE_BINARY_INST(N, OPC, CLASS) \ 205 static BinaryOperator *Create##OPC(Value *V1, Value *V2, \ 206 const Twine &Name = "") { \
207 return Create(Instruction::OPC, V1, V2, Name); \
209#include "llvm/IR/Instruction.def" 210#define HANDLE_BINARY_INST(N, OPC, CLASS) \ 211 static BinaryOperator *Create##OPC(Value *V1, Value *V2, const Twine &Name, \ 212 InsertPosition InsertBefore) { \ 213 return Create(Instruction::OPC, V1, V2, Name, InsertBefore); \ 215#include "llvm/IR/Instruction.def" 217static BinaryOperator *
329#define DEFINE_HELPERS(OPC, NUWNSWEXACT) \ 330 static BinaryOperator *Create##NUWNSWEXACT##OPC(Value *V1, Value *V2, \ 331 const Twine &Name = "") { \
332 return Create##NUWNSWEXACT(Instruction::OPC, V1, V2, Name); \
334 static BinaryOperator *Create##NUWNSWEXACT##OPC( \
335 Value *V1, Value *V2, const Twine &Name, \
336 InsertPosition InsertBefore = nullptr) { \
337 return Create##NUWNSWEXACT(Instruction::OPC, V1, V2, Name, InsertBefore); \
358 /// Helper functions to construct and inspect unary operations (NEG and NOT) 359 /// via binary operators SUB and XOR: 361 /// Create the NEG and NOT instructions out of SUB and XOR instructions. 364 InsertPosition InsertBefore =
nullptr);
366 InsertPosition InsertBefore =
nullptr);
368 InsertPosition InsertBefore =
nullptr);
374 /// Exchange the two operands to this instruction. 375 /// This instruction is safe to use on any binary instruction and 376 /// does not modify the semantics of the instruction. If the instruction 377 /// cannot be reversed (ie, it's a Div), then return true. 381// Methods for support type inquiry through isa, cast, and dyn_cast: 383returnI->isBinaryOp();
386return isa<Instruction>(V) &&
classof(cast<Instruction>(V));
397/// An or instruction, which can be marked as "disjoint", indicating that the 398/// inputs don't have a 1 in the same bit position. Meaning this instruction 399/// can also be treated as an add. 402enum { IsDisjoint = (1 << 0) };
405 SubclassOptionalData =
406 (SubclassOptionalData & ~IsDisjoint) | (
B * IsDisjoint);
409boolisDisjoint()
const{
return SubclassOptionalData & IsDisjoint; }
412returnI->getOpcode() == Instruction::Or;
416return isa<Instruction>(V) && classof(cast<Instruction>(V));
423 cast<PossiblyDisjointInst>(BO)->setIsDisjoint(
true);
430 cast<PossiblyDisjointInst>(BO)->setIsDisjoint(
true);
434//===----------------------------------------------------------------------===// 436//===----------------------------------------------------------------------===// 438/// This is the base class for all instructions that perform data 439/// casts. It is simply provided so that instruction category testing 440/// can be performed with code like: 442/// if (isa<CastInst>(Instr)) { ... } 443/// Base class of casting instructions. 446 /// Constructor with insert-before-instruction semantics for subclasses 454 /// Provides a way to construct any of the CastInst subclasses using an 455 /// opcode instead of the subclass's constructor. The opcode must be in the 456 /// CastOps category (Instruction::isCast(opcode) returns true). This 457 /// constructor has insert-before-instruction semantics to automatically 458 /// insert the new CastInst before InsertBefore (if it is non-null). 459 /// Construct any of the CastInst subclasses 462Value *S,
///< The value to be casted (operand 0) 463Type *Ty,
///< The type to which cast should be made 464constTwine &
Name =
"",
///< Name for the instruction 465InsertPosition InsertBefore =
nullptr///< Place to insert the instruction 468 /// Create a ZExt or BitCast cast instruction 470Value *S,
///< The value to be casted (operand 0) 471Type *Ty,
///< The type to which cast should be made 472constTwine &
Name =
"",
///< Name for the instruction 473InsertPosition InsertBefore =
nullptr///< Place to insert the instruction 476 /// Create a SExt or BitCast cast instruction 478Value *S,
///< The value to be casted (operand 0) 479Type *Ty,
///< The type to which cast should be made 480constTwine &
Name =
"",
///< Name for the instruction 481InsertPosition InsertBefore =
nullptr///< Place to insert the instruction 484 /// Create a BitCast, AddrSpaceCast or a PtrToInt cast instruction. 486Value *S,
///< The pointer value to be casted (operand 0) 487Type *Ty,
///< The type to which cast should be made 488constTwine &
Name =
"",
///< Name for the instruction 489InsertPosition InsertBefore =
nullptr///< Place to insert the instruction 492 /// Create a BitCast or an AddrSpaceCast cast instruction. 494Value *S,
///< The pointer value to be casted (operand 0) 495Type *Ty,
///< The type to which cast should be made 496constTwine &
Name =
"",
///< Name for the instruction 497InsertPosition InsertBefore =
nullptr///< Place to insert the instruction 500 /// Create a BitCast, a PtrToInt, or an IntToPTr cast instruction. 502 /// If the value is a pointer type and the destination an integer type, 503 /// creates a PtrToInt cast. If the value is an integer type and the 504 /// destination a pointer type, creates an IntToPtr cast. Otherwise, creates 507Value *S,
///< The pointer value to be casted (operand 0) 508Type *Ty,
///< The type to which cast should be made 509constTwine &
Name =
"",
///< Name for the instruction 510InsertPosition InsertBefore =
nullptr///< Place to insert the instruction 513 /// Create a ZExt, BitCast, or Trunc for int -> int casts. 515Value *S,
///< The pointer value to be casted (operand 0) 516Type *Ty,
///< The type to which cast should be made 517boolisSigned,
///< Whether to regard S as signed or not 518constTwine &
Name =
"",
///< Name for the instruction 519InsertPosition InsertBefore =
nullptr///< Place to insert the instruction 522 /// Create an FPExt, BitCast, or FPTrunc for fp -> fp casts 524Value *S,
///< The floating point value to be casted 525Type *Ty,
///< The floating point type to cast to 526constTwine &
Name =
"",
///< Name for the instruction 527InsertPosition InsertBefore =
nullptr///< Place to insert the instruction 530 /// Create a Trunc or BitCast cast instruction 532Value *S,
///< The value to be casted (operand 0) 533Type *Ty,
///< The type to which cast should be made 534constTwine &
Name =
"",
///< Name for the instruction 535InsertPosition InsertBefore =
nullptr///< Place to insert the instruction 538 /// Check whether a bitcast between these types is valid 540Type *SrcTy,
///< The Type from which the value should be cast. 541Type *DestTy
///< The Type to which the value should be cast. 544 /// Check whether a bitcast, inttoptr, or ptrtoint cast between these 545 /// types is valid and a no-op. 547 /// This ensures that any pointer<->integer cast has enough bits in the 548 /// integer and any other cast is a bitcast. 550Type *SrcTy,
///< The Type from which the value should be cast. 551Type *DestTy,
///< The Type to which the value should be cast. 554 /// Returns the opcode necessary to cast Val into Ty using usual casting 556 /// Infer the opcode for cast operand and type 558constValue *Val,
///< The value to cast 559bool SrcIsSigned,
///< Whether to treat the source as signed 560Type *Ty,
///< The Type to which the value should be casted 561bool DstIsSigned
///< Whether to treate the dest. as signed 564 /// There are several places where we need to know if a cast instruction 565 /// only deals with integer source and destination types. To simplify that 566 /// logic, this method is provided. 567 /// @returns true iff the cast has only integral typed operand and dest type. 568 /// Determine if this is an integer-only cast. 571 /// A no-op cast is one that can be effected without changing any bits. 572 /// It implies that the source and destination types are the same size. The 573 /// DataLayout argument is to determine the pointer size when examining casts 574 /// involving Integer and Pointer types. They are no-op casts if the integer 575 /// is the same size as the pointer. However, pointer size varies with 576 /// platform. Note that a precondition of this method is that the cast is 577 /// legal - i.e. the instruction formed with these operands would verify. 580Type *SrcTy,
///< SrcTy of cast 581Type *DstTy,
///< DstTy of cast 582constDataLayout &
DL///< DataLayout to get the Int Ptr type from. 585 /// Determine if this cast is a no-op cast. 587 /// \param DL is the DataLayout to determine pointer size. 590 /// Determine how a pair of casts can be eliminated, if they can be at all. 591 /// This is a helper function for both CastInst and ConstantExpr. 592 /// @returns 0 if the CastInst pair can't be eliminated, otherwise 593 /// returns Instruction::CastOps value for a cast that can replace 594 /// the pair, casting SrcTy to DstTy. 595 /// Determine if a cast pair is eliminable 599Type *SrcTy,
///< SrcTy of 1st cast 600Type *MidTy,
///< DstTy of 1st cast & SrcTy of 2nd cast 601Type *DstTy,
///< DstTy of 2nd cast 602Type *SrcIntPtrTy,
///< Integer type corresponding to Ptr SrcTy, or null 603Type *MidIntPtrTy,
///< Integer type corresponding to Ptr MidTy, or null 604Type *DstIntPtrTy
///< Integer type corresponding to Ptr DstTy, or null 607 /// Return the opcode of this CastInst 612 /// Return the source type, as a convenience 614 /// Return the destination type, as a convenience 617 /// This method can be used to determine if a cast from SrcTy to DstTy using 618 /// Opcode op is valid or not. 619 /// @returns true iff the proposed cast is valid. 620 /// Determine if a cast is valid without creating one. 626 /// Methods for support type inquiry through isa, cast, and dyn_cast: 631return isa<Instruction>(V) &&
classof(cast<Instruction>(V));
635/// Instruction that can have a nneg flag (zext/uitofp). 641switch (
I->getOpcode()) {
642case Instruction::ZExt:
643case Instruction::UIToFP:
651return isa<Instruction>(V) &&
classof(cast<Instruction>(V));
655//===----------------------------------------------------------------------===// 657//===----------------------------------------------------------------------===// 659/// This class is the base class for the comparison instructions. 660/// Abstract base class of comparison instructions. 665 /// This enumeration lists the possible predicates for CmpInst subclasses. 666 /// Values in the range 0-31 are reserved for FCmpInst, while values in the 667 /// range 32-64 are reserved for ICmpInst. This is necessary to ensure the 668 /// predicate values are not overlapping between the classes. 670 /// Some passes (e.g. InstCombine) depend on the bit-wise characteristics of 671 /// FCMP_* values. Changing the bit patterns requires a potential change to 674// Opcode U L G E Intuitive operation 677FCMP_OGT = 2,
///< 0 0 1 0 True if ordered and greater than 678FCMP_OGE = 3,
///< 0 0 1 1 True if ordered and greater than or equal 679FCMP_OLT = 4,
///< 0 1 0 0 True if ordered and less than 680FCMP_OLE = 5,
///< 0 1 0 1 True if ordered and less than or equal 681FCMP_ONE = 6,
///< 0 1 1 0 True if ordered and operands are unequal 683FCMP_UNO = 8,
///< 1 0 0 0 True if unordered: isnan(X) | isnan(Y) 684FCMP_UEQ = 9,
///< 1 0 0 1 True if unordered or equal 685FCMP_UGT = 10,
///< 1 0 1 0 True if unordered or greater than 686FCMP_UGE = 11,
///< 1 0 1 1 True if unordered, greater than, or equal 687FCMP_ULT = 12,
///< 1 1 0 0 True if unordered or less than 688FCMP_ULE = 13,
///< 1 1 0 1 True if unordered, less than, or equal 689FCMP_UNE = 14,
///< 1 1 1 0 True if unordered or not equal 711 /// Returns the sequence of all FCmp predicates. 718 /// Returns the sequence of all ICmp predicates. 732// allocate space for exactly two operands 733void *
operatornew(
size_t S) {
return User::operator
new(S, AllocMarker); }
734voidoperatordelete(
void *
Ptr) { User::operator
delete(
Ptr); }
736 /// Construct a compare instruction, given the opcode, the predicate and 737 /// the two operands. Optionally (if InstBefore is specified) insert the 738 /// instruction into a BasicBlock right before the specified instruction. 739 /// The specified Instruction is allowed to be a dereferenced end iterator. 745 /// Construct a compare instruction, given the opcode, the predicate, 746 /// the two operands and the instruction to copy the flags from. Optionally 747 /// (if InstBefore is specified) insert the instruction into a BasicBlock 748 /// right before the specified instruction. The specified Instruction is 749 /// allowed to be a dereferenced end iterator. 757 /// Get the opcode casted to the right type 762 /// Return the predicate for this instruction. 765 /// Set the predicate for this instruction to the specified value. 770"FIRST_FCMP_PREDICATE is required to be 0");
783 /// For example, EQ -> NE, UGT -> ULE, SLT -> SGE, 784 /// OEQ -> UNE, UGT -> OLE, OLT -> UGE, etc. 785 /// @returns the inverse predicate for the instruction's current predicate. 786 /// Return the inverse of the instruction's predicate. 791 /// Returns the ordered variant of a floating point compare. 793 /// For example, UEQ -> OEQ, ULT -> OLT, OEQ -> OEQ 802 /// Returns the unordered variant of a floating point compare. 804 /// For example, OEQ -> UEQ, OLT -> ULT, OEQ -> UEQ 813 /// For example, EQ -> NE, UGT -> ULE, SLT -> SGE, 814 /// OEQ -> UNE, UGT -> OLE, OLT -> UGE, etc. 815 /// @returns the inverse predicate for predicate provided in \p pred. 816 /// Return the inverse of a given predicate 819 /// For example, EQ->EQ, SLE->SGE, ULT->UGT, 820 /// OEQ->OEQ, ULE->UGE, OLT->OGT, etc. 821 /// @returns the predicate that would be the result of exchanging the two 822 /// operands of the CmpInst instruction without changing the result 824 /// Return the predicate as if the operands were swapped 829 /// This is a static version that you can use without an instruction 831 /// Return the predicate as if the operands were swapped. 834 /// This is a static version that you can use without an instruction 836 /// @returns true if the comparison predicate is strict, false otherwise. 839 /// @returns true if the comparison predicate is strict, false otherwise. 840 /// Determine if this instruction is using an strict comparison predicate. 843 /// This is a static version that you can use without an instruction 845 /// @returns true if the comparison predicate is non-strict, false otherwise. 848 /// @returns true if the comparison predicate is non-strict, false otherwise. 849 /// Determine if this instruction is using an non-strict comparison predicate. 854 /// For example, SGE -> SGT, SLE -> SLT, ULE -> ULT, UGE -> UGT. 855 /// Returns the strict version of non-strict comparisons. 860 /// This is a static version that you can use without an instruction 862 /// @returns the strict version of comparison provided in \p pred. 863 /// If \p pred is not a strict comparison predicate, returns \p pred. 864 /// Returns the strict version of non-strict comparisons. 867 /// For example, SGT -> SGE, SLT -> SLE, ULT -> ULE, UGT -> UGE. 868 /// Returns the non-strict version of strict comparisons. 873 /// This is a static version that you can use without an instruction 875 /// @returns the non-strict version of comparison provided in \p pred. 876 /// If \p pred is not a strict comparison predicate, returns \p pred. 877 /// Returns the non-strict version of strict comparisons. 880 /// This is a static version that you can use without an instruction 882 /// Return the flipped strictness of predicate 885 /// For predicate of kind "is X or equal to 0" returns the predicate "is X". 886 /// For predicate of kind "is X" returns the predicate "is X or equal to 0". 887 /// does not support other kind of predicates. 888 /// @returns the predicate that does not contains is equal to zero if 889 /// it had and vice versa. 890 /// Return the flipped strictness of predicate 895 /// Provide more efficient getOperand methods. 898 /// This is just a convenience that dispatches to the subclasses. 899 /// Swap the operands and adjust predicate accordingly to retain 900 /// the same comparison. 903 /// This is just a convenience that dispatches to the subclasses. 904 /// Determine if this CmpInst is commutative. 907 /// Determine if this is an equals/not equals predicate. 908 /// This is a static version that you can use without an instruction 912 /// Determine if this is an equals/not equals predicate. 915 /// Determine if one operand of this compare can always be replaced by the 916 /// other operand, ignoring provenance considerations. If \p Invert, check for 917 /// equivalence with the inverse predicate. 920 /// Return true if the predicate is relational (not EQ or NE). 923 /// Return true if the predicate is relational (not EQ or NE). 926 /// @returns true if the comparison is signed, false otherwise. 927 /// Determine if this instruction is using a signed comparison. 932 /// @returns true if the comparison is unsigned, false otherwise. 933 /// Determine if this instruction is using an unsigned comparison. 938 /// This is just a convenience. 939 /// Determine if this is true when both operands are the same. 944 /// This is just a convenience. 945 /// Determine if this is false when both operands are the same. 950 /// @returns true if the predicate is unsigned, false otherwise. 951 /// Determine if the predicate is an unsigned operation. 954 /// @returns true if the predicate is signed, false otherwise. 955 /// Determine if the predicate is an signed operation. 958 /// Determine if the predicate is an ordered operation. 961 /// Determine if the predicate is an unordered operation. 964 /// Determine if the predicate is true when comparing a value with itself. 967 /// Determine if the predicate is false when comparing a value with itself. 970 /// Methods for support type inquiry through isa, cast, and dyn_cast: 972returnI->getOpcode() == Instruction::ICmp ||
973I->getOpcode() == Instruction::FCmp;
976return isa<Instruction>(V) &&
classof(cast<Instruction>(V));
979 /// Create a result type for fcmp/icmp 981if (
VectorType* vt = dyn_cast<VectorType>(opnd_type)) {
983 vt->getElementCount());
989// Shadow Value::setValueSubclassData with a private forwarding method so that 990// subclasses cannot accidentally use it. 991void setValueSubclassData(
unsignedshortD) {
996// FIXME: these are redundant if CmpInst < BinaryOperator 1005/// A lightweight accessor for an operand bundle meant to be passed 1014 /// Return true if the operand at index \p Idx in this operand bundle 1015 /// has the attribute A. 1018if (
A == Attribute::ReadOnly ||
A == Attribute::NoCapture)
1019returnInputs[
Idx]->getType()->isPointerTy();
1021// Conservative answer: no operands have any attributes. 1025 /// Return the tag of this operand bundle as a string. 1030 /// Return the tag of this operand bundle as an integer. 1032 /// Operand bundle tags are interned by LLVMContextImpl::getOrInsertBundleTag, 1033 /// and this function returns the unique integer getOrInsertBundleTag 1034 /// associated the tag of this operand bundle to. 1039 /// Return true if this is a "deopt" operand bundle. 1044 /// Return true if this is a "funclet" operand bundle. 1049 /// Return true if this is a "cfguardtarget" operand bundle. 1055 /// Pointer to an entry in LLVMContextImpl::getOrInsertBundleTag. 1059/// A container for an operand bundle being viewed as a set of values 1060/// rather than a set of uses. 1062/// Unlike OperandBundleUse, OperandBundleDefT owns the memory it carries, and 1063/// so it is possible to create and pass around "self-contained" instances of 1064/// OperandBundleDef and ConstOperandBundleDef. 1067 std::vector<InputTy> Inputs;
1073 : Tag(
std::
move(Tag)), Inputs(Inputs) {}
1094//===----------------------------------------------------------------------===// 1096//===----------------------------------------------------------------------===// 1098/// Base class for all callable instructions (InvokeInst and CallInst) 1099/// Holds everything related to calling a function. 1101/// All call-like instructions are required to use a common operand layout: 1102/// - Zero or more arguments to the call, 1103/// - Zero or more operand bundles with zero or more operand inputs each 1105/// - Zero or more subclass controlled operands 1106/// - The called function. 1108/// This allows this base class to easily access the called function and the 1109/// start of the arguments without knowing how many other operands a particular 1110/// subclass requires. Note that accessing the end of the argument list isn't 1111/// as cheap as most other operations on the base class. 1114// The first two bits are reserved by CallInst for fast retrieval, 1120 Bitfield::areContiguous<CallInstReservedField, CallingConvField>(),
1121"Bitfields must be contiguous");
1123 /// The last operand is the called operand. 1129template <
class... ArgsTy>
1139case Instruction::Call:
1141case Instruction::Invoke:
1143case Instruction::CallBr:
1149 /// Get the number of extra operands for instructions that don't have a fixed 1150 /// number of extra operands. 1156 /// Create a clone of \p CB with a different set of operand bundles and 1157 /// insert it before \p InsertPt. 1159 /// The returned call instruction is identical \p CB in every way except that 1160 /// the operand bundles for the new instruction are set to the operand bundles 1165 /// Create a clone of \p CB with the operand bundle with the tag matching 1166 /// \p Bundle's tag replaced with Bundle, and insert it before \p InsertPt. 1168 /// The returned call instruction is identical \p CI in every way except that 1169 /// the specified operand bundle has been replaced. 1173 /// Create a clone of \p CB with operand bundle \p OB added. 1178 /// Create a clone of \p CB with operand bundle \p ID removed. 1182 /// Return the convergence control token for this call, if it exists. 1185return Bundle->Inputs[0].get();
1191returnI->getOpcode() == Instruction::Call ||
1192I->getOpcode() == Instruction::Invoke ||
1193I->getOpcode() == Instruction::CallBr;
1196return isa<Instruction>(V) &&
classof(cast<Instruction>(V));
1208 /// data_operands_begin/data_operands_end - Return iterators iterating over 1209 /// the call / invoke argument list and bundle operands. For invokes, this is 1210 /// the set of instruction operands except the invoke target and the two 1211 /// successor blocks; and for calls this is the set of instruction operands 1212 /// except the call target. 1218// Walk from the end of the operands over the called operand and any 1219// subclass operands. 1239assert(
this == U->getUser() &&
1240"Only valid to query with a use of this instruction!");
1247 /// Given a value use iterator, return the data operand corresponding to it. 1248 /// Iterator must actually correspond to a data operand. 1253 /// Given a use for a data operand, get the data operand number that 1254 /// corresponds to it. 1260 /// Return the iterator pointing to the beginning of the argument list. 1266 /// Return the iterator pointing to the end of the argument list. 1268// From the end of the data operands, walk backwards past the bundle 1276 /// Iteration adapter for range-for loops. 1296 /// Wrappers for getting the \c Use of a call argument. 1307assert(
this == U->getUser() &&
1308"Only valid to query with a use of this instruction!");
1315 /// Given a use for a arg operand, get the arg operand number that 1316 /// corresponds to it. 1322 /// Given a value use iterator, return the arg operand number corresponding to 1323 /// it. Iterator must actually correspond to a data operand. 1328 /// Returns true if this CallSite passes the given Value* as an argument to 1329 /// the called function. 1339 /// Returns the function called, or null if this is an indirect function 1340 /// invocation or the function signature does not match the call signature. 1348 /// Return true if the callsite is an indirect call. 1351 /// Determine whether the passed iterator points to the callee operand's Use. 1356 /// Determine whether this Use is the callee operand's Use. 1359 /// Helper to get the caller (the parent function). 1365 /// Tests if this call site must be tail call optimized. Only a CallInst can 1366 /// be tail call optimized. 1369 /// Tests if this call site is marked as a tail call. 1372 /// Returns the intrinsic ID of the intrinsic called or 1373 /// Intrinsic::not_intrinsic if the called function is not an intrinsic, or if 1374 /// this is an indirect call. 1379 /// Sets the function called, including updating the function type. 1384 /// Sets the function called, including updating the function type. 1389 /// Sets the function called, including updating to the specified function 1393// This function doesn't mutate the return type, only the function 1394// type. Seems broken, but I'm just gonna stick an assert in for now. 1400return getSubclassData<CallingConvField>();
1404 setSubclassData<CallingConvField>(
CC);
1407 /// Check if this call is an inline asm statement. 1410 /// \name Attribute API 1412 /// These methods access and modify attributes on this call (including 1413 /// looking through to the attributes on the called function when necessary). 1416 /// Return the attributes for this call. 1419 /// Set the attributes for this call. 1422 /// Return the return attributes for this call. 1427 /// Return the param attributes for this call. 1432 /// Try to intersect the attributes from 'this' CallBase and the 1433 /// 'Other' CallBase. Sets the intersected attributes to 'this' and 1434 /// return true if successful. Doesn't modify 'this' and returns 1435 /// false if unsuccessful. 1441auto Intersected = AL.intersectWith(
getContext(), ALOther);
1448 /// Determine whether this call has the given attribute. If it does not 1449 /// then determine if the called function has the attribute, but only if 1450 /// the attribute is allowed for the call. 1452assert(Kind != Attribute::NoBuiltin &&
1453"Use CallBase::isNoBuiltin() to check for Attribute::NoBuiltin");
1454return hasFnAttrImpl(Kind);
1457 /// Determine whether this call has the given attribute. If it does not 1458 /// then determine if the called function has the attribute, but only if 1459 /// the attribute is allowed for the call. 1462// TODO: remove non-AtIndex versions of these methods. 1463 /// adds the attribute to the list of attributes. 1468 /// adds the attribute to the list of attributes. 1473 /// Adds the attribute to the function. 1478 /// Adds the attribute to the function. 1483 /// Adds the attribute to the return value. 1488 /// Adds the attribute to the return value. 1493 /// Adds the attribute to the indicated argument 1499 /// Adds the attribute to the indicated argument 1505 /// removes the attribute from the list of attributes. 1510 /// removes the attribute from the list of attributes. 1515 /// Removes the attributes from the function 1520 /// Removes the attribute from the function 1525 /// Removes the attribute from the function 1530 /// Removes the attribute from the return value 1535 /// Removes the attributes from the return value 1540 /// Removes the attribute from the given argument 1546 /// Removes the attribute from the given argument 1552 /// Removes the attributes from the given argument 1557 /// adds the dereferenceable attribute to the list of attributes. 1562 /// adds the dereferenceable attribute to the list of attributes. 1567 /// adds the range attribute to the list of attributes. 1572 /// Determine whether the return value has the given attribute. 1574return hasRetAttrImpl(Kind);
1576 /// Determine whether the return value has the given attribute. 1579 /// Return the attribute for the given attribute kind for the return value. 1585// Look at the callee, if available. 1587returnF->getRetAttribute(Kind);
1591 /// Determine whether the argument or parameter has the given attribute. 1594 /// Get the attribute of a given kind at a position. 1599 /// Get the attribute of a given kind at a position. 1604 /// Get the attribute of a given kind for the function. 1609return getFnAttrOnCalledFunction(Kind);
1612 /// Get the attribute of a given kind for the function. 1617return getFnAttrOnCalledFunction(Kind);
1620 /// Get the attribute of a given kind from a given arg 1626return getParamAttrOnCalledFunction(ArgNo, Kind);
1629 /// Get the attribute of a given kind from a given arg 1635return getParamAttrOnCalledFunction(ArgNo, Kind);
1638 /// Return true if the data operand at index \p i has the attribute \p 1641 /// Data operands include call arguments and values used in operand bundles, 1642 /// but does not include the callee operand. 1644 /// The index \p i is interpreted as 1646 /// \p i in [0, arg_size) -> argument number (\p i) 1647 /// \p i in [arg_size, data_operand_size) -> bundle operand at index 1648 /// (\p i) in the operand list. 1650// Note that we have to add one because `i` isn't zero-indexed. 1652"Data operand index out of bounds!");
1654// The attribute A can either be directly specified, if the operand in 1655// question is a call argument; or be indirectly implied by the kind of its 1656// containing operand bundle, if the operand is a bundle operand. 1662"Must be either a call argument or an operand bundle!");
1666 /// Determine whether this data operand is not captured. 1667// FIXME: Once this API is no longer duplicated in `CallSite`, rename this to 1668// better indicate that this may return a conservative answer. 1670// If the argument is passed byval, the callee does not have access to the 1671// original pointer and thus cannot capture it. 1678 /// Determine whether this argument is passed by value. 1683 /// Determine whether this argument is passed in an alloca. 1688 /// Determine whether this argument is passed by value, in an alloca, or is 1696 /// Determine whether passing undef to this argument is undefined behavior. 1697 /// If passing undef to this argument is UB, passing poison is UB as well 1698 /// because poison is more undefined than undef. 1701// dereferenceable implies noundef. 1703// dereferenceable implies noundef, and null is a well-defined value. 1707 /// Determine if there are is an inalloca argument. Only the last argument can 1708 /// have the inalloca attribute. 1713// FIXME: Once this API is no longer duplicated in `CallSite`, rename this to 1714// better indicate that this may return a conservative answer. 1719// FIXME: Once this API is no longer duplicated in `CallSite`, rename this to 1720// better indicate that this may return a conservative answer. 1722// If the argument is passed byval, the callee does not have access to the 1723// original pointer and thus cannot write to it. 1731// FIXME: Once this API is no longer duplicated in `CallSite`, rename this to 1732// better indicate that this may return a conservative answer. 1738 /// Extract the alignment of the return value. 1743returnF->getAttributes().getRetAlignment();
1747 /// Extract the alignment for a call or parameter (0=unknown). 1756 /// Extract the byref type for a call or parameter. 1761returnF->getAttributes().getParamByRefType(ArgNo);
1765 /// Extract the byval type for a call or parameter. 1770returnF->getAttributes().getParamByValType(ArgNo);
1774 /// Extract the preallocated type for a call or parameter. 1779returnF->getAttributes().getParamPreallocatedType(ArgNo);
1783 /// Extract the inalloca type for a call or parameter. 1788returnF->getAttributes().getParamInAllocaType(ArgNo);
1792 /// Extract the sret type for a call or parameter. 1797returnF->getAttributes().getParamStructRetType(ArgNo);
1801 /// Extract the elementtype type for a parameter. 1802 /// Note that elementtype() can only be applied to call arguments, not 1803 /// function declaration parameters. 1808 /// Extract the number of dereferenceable bytes for a call or 1809 /// parameter (0=unknown). 1813 Bytes = std::max(Bytes,
F->getAttributes().getRetDereferenceableBytes());
1817 /// Extract the number of dereferenceable bytes for a call or 1818 /// parameter (0=unknown). 1823 /// Extract the number of dereferenceable_or_null bytes for a call 1828 Bytes = std::max(Bytes,
1829F->getAttributes().getRetDereferenceableOrNullBytes());
1835 /// Extract the number of dereferenceable_or_null bytes for a 1836 /// parameter (0=unknown). 1841 /// Extract a test mask for disallowed floating-point value classes for the 1845 /// Extract a test mask for disallowed floating-point value classes for the 1849 /// If this return value has a range attribute, return the value range of the 1850 /// argument. Otherwise, std::nullopt is returned. 1851 std::optional<ConstantRange>
getRange()
const;
1853 /// Return true if the return value is known to be not null. 1854 /// This may be because it has the nonnull attribute, or because at least 1855 /// one byte is dereferenceable and the pointer is in addrspace(0). 1858 /// Determine if the return value is marked with NoAlias attribute. 1863 /// If one of the arguments has the 'returned' attribute, returns its 1864 /// operand value. Otherwise, return nullptr. 1869 /// If one of the arguments has the specified attribute, returns its 1870 /// operand value. Otherwise, return nullptr. 1873 /// Return true if the call should not be treated as a call to a 1876return hasFnAttrImpl(Attribute::NoBuiltin) &&
1877 !hasFnAttrImpl(Attribute::Builtin);
1880 /// Determine if the call requires strict floating point semantics. 1883 /// Return true if the call should not be inlined. 1890 /// Determine if the call does not access memory. 1894 /// Determine if the call does not access or only reads memory. 1898 /// Determine if the call does not access or only writes memory. 1902 /// Determine if the call can access memmory only using pointers based 1903 /// on its arguments. 1907 /// Determine if the function may only access memory that is 1908 /// inaccessible from the IR. 1912 /// Determine if the function may only access memory that is 1913 /// either inaccessible from the IR or pointed to by its arguments. 1917 /// Determine if the call cannot return. 1921 /// Determine if the call should not perform indirect branch tracking. 1924 /// Determine if the call cannot unwind. 1928 /// Determine if the invoke cannot be duplicated. 1932 /// Determine if the call cannot be tail merged. 1936 /// Determine if the invoke is convergent 1941 /// Determine if the call returns a structure through first 1942 /// pointer argument. 1947// Be friendly and also check the callee. 1951 /// Determine if any call argument is an aggregate passed by value. 1957// End of attribute API. 1959 /// \name Operand Bundle API 1961 /// This group of methods provides the API to access and manipulate operand 1962 /// bundles on this call. 1965 /// Return the number of operand bundles associated with this User. 1970 /// Return true if this User has any operand bundles. 1973 /// Return the index of the first bundle operand in the Use array. 1979 /// Return the index of the last bundle operand in the Use array. 1985 /// Return true if the operand at index \p Idx is a bundle operand. 1991 /// Return true if the operand at index \p Idx is a bundle operand that has 1998 /// Returns true if the use is a bundle operand. 2000assert(
this == U->getUser() &&
2001"Only valid to query with a use of this instruction!");
2008 /// Return the total number operands (not operand bundles) used by 2009 /// every operand bundle in this OperandBundleUser. 2021 /// Return the operand bundle at a specific index. 2027 /// Return the number of operand bundles with the tag Name attached to 2028 /// this instruction. 2038 /// Return the number of operand bundles with the tag ID attached to 2039 /// this instruction. 2049 /// Return an operand bundle by name, if present. 2051 /// It is an error to call this for operand bundle types that may have 2052 /// multiple instances of them on the same instruction. 2058if (U.getTagName() ==
Name)
2065 /// Return an operand bundle by tag ID, if present. 2067 /// It is an error to call this for operand bundle types that may have 2068 /// multiple instances of them on the same instruction. 2074if (U.getTagID() ==
ID)
2081 /// Return the list of operand bundles attached to this instruction as 2082 /// a vector of OperandBundleDefs. 2084 /// This function copies the OperandBundeUse instances associated with this 2085 /// OperandBundleUser to a vector of OperandBundleDefs. Note: 2086 /// OperandBundeUses and OperandBundleDefs are non-trivially *different* 2087 /// representations of operand bundles (see documentation above). 2090 /// Return the operand bundle for the operand at index OpIdx. 2092 /// It is an error to call this with an OpIdx that does not correspond to an 2098 /// Return true if this operand bundle user has operand bundles that 2099 /// may read from the heap. 2102 /// Return true if this operand bundle user has operand bundles that 2103 /// may write to the heap. 2106 /// Return true if the bundle operand at index \p OpIdx has the 2111return OBU.operandHasAttr(OpIdx - BOI.Begin,
A);
2114 /// Return true if \p Other has the same sequence of operand bundle 2115 /// tags with the same number of operands on each one of them as this 2116 /// OperandBundleUser. 2122Other.bundle_op_info_begin());
2125 /// Return true if this operand bundle user contains operand bundles 2126 /// with tags other than those specified in \p IDs. 2136 /// Used to keep track of an operand bundle. See the main comment on 2137 /// OperandBundleUser above. 2139 /// The operand bundle tag, interned by 2140 /// LLVMContextImpl::getOrInsertBundleTag. 2143 /// The index in the Use& vector where operands for this operand 2147 /// The index in the Use& vector where operands for this operand 2156 /// Simple helper function to map a BundleOpInfo to an 2157 /// OperandBundleUse. 2168 /// Return the start of the list of BundleOpInfo instances associated 2169 /// with this OperandBundleUser. 2171 /// OperandBundleUser uses the descriptor area co-allocated with the host User 2172 /// to store some meta information about which operands are "normal" operands, 2173 /// and which ones belong to some operand bundle. 2175 /// The layout of an operand bundle user is 2177 /// +-----------uint32_t End-------------------------------------+ 2179 /// | +--------uint32_t Begin--------------------+ | 2182 /// |------|------|----|----|----|----|----|---------|----|---------|----|----- 2183 /// | BOI0 | BOI1 | .. | DU | U0 | U1 | .. | BOI0_U0 | .. | BOI1_U0 | .. | Un 2184 /// |------|------|----|----|----|----|----|---------|----|---------|----|----- 2187 /// | +--------uint32_t Begin------------+ | 2189 /// +-----------uint32_t End-----------------------------+ 2192 /// BOI0, BOI1 ... are descriptions of operand bundles in this User's use 2193 /// list. These descriptions are installed and managed by this class, and 2194 /// they're all instances of OperandBundleUser<T>::BundleOpInfo. 2196 /// DU is an additional descriptor installed by User's 'operator new' to keep 2197 /// track of the 'BOI0 ... BOIN' co-allocation. OperandBundleUser does not 2198 /// access or modify DU in any way, it's an implementation detail private to 2201 /// The regular Use& vector for the User starts at U0. The operand bundle 2202 /// uses are part of the Use& vector, just like normal uses. In the diagram 2203 /// above, the operand bundle uses start at BOI0_U0. Each instance of 2204 /// BundleOpInfo has information about a contiguous set of uses constituting 2205 /// an operand bundle, and the total set of operand bundle uses themselves 2206 /// form a contiguous set of uses (i.e. there are no gaps between uses 2207 /// corresponding to individual operand bundles). 2209 /// This class does not know the location of the set of operand bundle uses 2210 /// within the use list -- that is decided by the User using this class via 2211 /// the BeginIdx argument in populateBundleOperandInfos. 2213 /// Currently operand bundle users with hung-off operands are not supported. 2222 /// Return the start of the list of BundleOpInfo instances associated 2223 /// with this OperandBundleUser. 2225auto *NonConstThis =
const_cast<CallBase *
>(
this);
2229 /// Return the end of the list of BundleOpInfo instances associated 2230 /// with this OperandBundleUser. 2239 /// Return the end of the list of BundleOpInfo instances associated 2240 /// with this OperandBundleUser. 2242auto *NonConstThis =
const_cast<CallBase *
>(
this);
2246 /// Return the range [\p bundle_op_info_begin, \p bundle_op_info_end). 2251 /// Return the range [\p bundle_op_info_begin, \p bundle_op_info_end). 2256 /// Populate the BundleOpInfo instances and the Use& vector from \p 2257 /// Bundles. Return the op_iterator pointing to the Use& one past the last 2258 /// last bundle operand use. 2260 /// Each \p OperandBundleDef instance is tracked by a OperandBundleInfo 2261 /// instance allocated in this User's descriptor. 2263constunsigned BeginIndex);
2265 /// Return true if the call has deopt state bundle. 2271 /// Return the BundleOpInfo for the operand at index OpIdx. 2273 /// It is an error to call this with an OpIdx that does not correspond to an 2281 /// Return the total number of values used in \p Bundles. 2284for (
constauto &
B : Bundles)
2290// End of operand bundle API. 2294bool hasFnAttrOnCalledFunction(
StringRef Kind)
const;
2296template <
typename AttrKind>
bool hasFnAttrImpl(AttrKind Kind)
const{
2300return hasFnAttrOnCalledFunction(Kind);
2302template <
typename AK> Attribute getFnAttrOnCalledFunction(AK Kind)
const;
2303template <
typename AK>
2304 Attribute getParamAttrOnCalledFunction(
unsigned ArgNo, AK Kind)
const;
2306 /// Determine whether the return value has the given attribute. Supports 2307 /// Attribute::AttrKind and StringRef as \p AttrKind types. 2308template <
typename AttrKind>
bool hasRetAttrImpl(AttrKind Kind)
const{
2312// Look at the callee, if available. 2314returnF->getAttributes().hasRetAttr(Kind);
2324//===----------------------------------------------------------------------===// 2325// FuncletPadInst Class 2326//===----------------------------------------------------------------------===// 2338// Note: Instruction needs to be a friend here to call cloneImpl. 2346 /// Provide fast operand accessors 2349 /// arg_size - Return the number of funcletpad arguments. 2353 /// Convenience accessors 2355 /// Return the outer EH-pad this funclet is nested within. 2357 /// Note: This returns the associated CatchSwitchInst if this FuncletPadInst 2358 /// is a CatchPadInst. 2362Op<-1>() = ParentPad;
2365 /// getArgOperand/setArgOperand - Return/set the i-th funcletpad argument. 2370 /// arg_operands - iteration adapter for range-for loops. 2373 /// arg_operands - iteration adapter for range-for loops. 2378// Methods for support type inquiry through isa, cast, and dyn_cast: 2381return isa<Instruction>(V) && classof(cast<Instruction>(V));
2391}
// end namespace llvm 2393#endif// LLVM_IR_INSTRTYPES_H OperandBundleDefT< Value * > OperandBundleDef
This file defines the StringMap class.
MachineBasicBlock MachineBasicBlock::iterator DebugLoc DL
This file contains the simple types necessary to represent the attributes associated with functions a...
static GCRegistry::Add< OcamlGC > B("ocaml", "ocaml 3.10-compatible GC")
static GCRegistry::Add< ErlangGC > A("erlang", "erlang-compatible garbage collector")
static GCRegistry::Add< StatepointGC > D("statepoint-example", "an example strategy for statepoint")
Returns the sub type a function will return at a given Idx Should correspond to the result type of an ExtractValue instruction executed with just that one unsigned Idx
static bool isSigned(unsigned int Opcode)
#define DEFINE_HELPERS(OPC, NUWNSWEXACT)
#define DEFINE_TRANSPARENT_OPERAND_ACCESSORS(CLASS, VALUECLASS)
Macro for generating out-of-class operand accessor definitions.
assert(ImpDefSCC.getReg()==AMDGPU::SCC &&ImpDefSCC.isDef())
This file contains some templates that are useful if you are working with the STL at all.
Provides some synthesis utilities to produce sequences of values.
ArrayRef - Represent a constant reference to an array (0 or more elements consecutively in memory),...
Type * getParamStructRetType(unsigned ArgNo) const
Return the sret type for the specified function parameter.
AttributeList addDereferenceableParamAttr(LLVMContext &C, unsigned ArgNo, uint64_t Bytes) const
Add the dereferenceable attribute to the attribute set at the given arg index.
AttributeList removeAttributeAtIndex(LLVMContext &C, unsigned Index, Attribute::AttrKind Kind) const
Remove the specified attribute at the specified index from this attribute list.
AttributeList removeParamAttributes(LLVMContext &C, unsigned ArgNo, const AttributeMask &AttrsToRemove) const
Remove the specified attribute at the specified arg index from this attribute list.
AttributeList addRangeRetAttr(LLVMContext &C, const ConstantRange &CR) const
Add the range attribute to the attribute set at the return value index.
AttributeList addRetAttribute(LLVMContext &C, Attribute::AttrKind Kind) const
Add a return value attribute to the list.
AttributeList addDereferenceableRetAttr(LLVMContext &C, uint64_t Bytes) const
Add the dereferenceable attribute to the attribute set at the given index.
AttributeList removeRetAttributes(LLVMContext &C, const AttributeMask &AttrsToRemove) const
Remove the specified attribute at the return value index from this attribute list.
Attribute getParamAttr(unsigned ArgNo, Attribute::AttrKind Kind) const
Return the attribute object that exists at the arg index.
AttributeList addFnAttribute(LLVMContext &C, Attribute::AttrKind Kind) const
Add a function attribute to the list.
AttributeSet getRetAttrs() const
The attributes for the ret value are returned.
bool hasFnAttr(Attribute::AttrKind Kind) const
Return true if the attribute exists for the function.
uint64_t getParamDereferenceableBytes(unsigned Index) const
Get the number of dereferenceable bytes (or zero if unknown) of an arg.
MaybeAlign getParamAlignment(unsigned ArgNo) const
Return the alignment for the specified function parameter.
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.
Type * getParamInAllocaType(unsigned ArgNo) const
Return the inalloca type for the specified function parameter.
Attribute getFnAttr(Attribute::AttrKind Kind) const
Return the attribute object that exists for the function.
MaybeAlign getRetAlignment() const
Return the alignment of the return value.
Type * getParamElementType(unsigned ArgNo) const
Return the elementtype type for the specified function parameter.
Attribute getAttributeAtIndex(unsigned Index, Attribute::AttrKind Kind) const
Return the attribute object that exists at the given index.
Type * getParamPreallocatedType(unsigned ArgNo) const
Return the preallocated type for the specified function parameter.
AttributeList removeParamAttribute(LLVMContext &C, unsigned ArgNo, Attribute::AttrKind Kind) const
Remove the specified attribute at the specified arg index from this attribute list.
Type * getParamByValType(unsigned ArgNo) const
Return the byval type for the specified function parameter.
Attribute getRetAttr(Attribute::AttrKind Kind) const
Return the attribute for the given attribute kind for the return value.
MaybeAlign getParamStackAlignment(unsigned ArgNo) const
Return the stack alignment for the specified function parameter.
uint64_t getRetDereferenceableBytes() const
Get the number of dereferenceable bytes (or zero if unknown) of the return value.
AttributeList removeFnAttribute(LLVMContext &C, Attribute::AttrKind Kind) const
Remove the specified attribute at the function index from this attribute list.
uint64_t getParamDereferenceableOrNullBytes(unsigned ArgNo) const
Get the number of dereferenceable_or_null bytes (or zero if unknown) of an arg.
AttributeList removeFnAttributes(LLVMContext &C, const AttributeMask &AttrsToRemove) const
Remove the specified attribute at the function index from this attribute list.
Type * getParamByRefType(unsigned ArgNo) const
Return the byref type for the specified function parameter.
AttributeList addAttributeAtIndex(LLVMContext &C, unsigned Index, Attribute::AttrKind Kind) const
Add an attribute to the attribute set at the given index.
AttributeSet getParamAttrs(unsigned ArgNo) const
The attributes for the argument or parameter at the given index are returned.
uint64_t getRetDereferenceableOrNullBytes() const
Get the number of dereferenceable_or_null bytes (or zero if unknown) of the return value.
AttributeList removeRetAttribute(LLVMContext &C, Attribute::AttrKind Kind) const
Remove the specified attribute at the return value index from this attribute list.
AttributeList addParamAttribute(LLVMContext &C, unsigned ArgNo, Attribute::AttrKind Kind) const
Add an argument attribute to the list.
bool hasRetAttr(Attribute::AttrKind Kind) const
Return true if the attribute exists for the return value.
AttrKind
This enumeration lists the attributes that can be associated with parameters, function results,...
bool isValid() const
Return true if the attribute is any kind of attribute.
static BinaryOperator * CreateFAddFMF(Value *V1, Value *V2, FastMathFlags FMF, const Twine &Name="")
static BinaryOperator * CreateNeg(Value *Op, const Twine &Name="", InsertPosition InsertBefore=nullptr)
Helper functions to construct and inspect unary operations (NEG and NOT) via binary operators SUB and...
static BinaryOperator * CreateFDivFMF(Value *V1, Value *V2, Instruction *FMFSource, const Twine &Name="")
BinaryOps getOpcode() const
static BinaryOperator * CreateNSW(BinaryOps Opc, Value *V1, Value *V2, const Twine &Name="")
DECLARE_TRANSPARENT_OPERAND_ACCESSORS(Value)
Transparently provide more efficient getOperand methods.
static bool classof(const Value *V)
static BinaryOperator * CreateFRemFMF(Value *V1, Value *V2, Instruction *FMFSource, const Twine &Name="")
static BinaryOperator * CreateWithFMF(BinaryOps Opc, Value *V1, Value *V2, FastMathFlags FMF, const Twine &Name="", InsertPosition InsertBefore=nullptr)
static BinaryOperator * CreateExact(BinaryOps Opc, Value *V1, Value *V2, const Twine &Name="")
static BinaryOperator * CreateFMulFMF(Value *V1, Value *V2, Instruction *FMFSource, const Twine &Name="")
bool swapOperands()
Exchange the two operands to this instruction.
static BinaryOperator * CreateExact(BinaryOps Opc, Value *V1, Value *V2, const Twine &Name, InsertPosition InsertBefore)
static BinaryOperator * CreateNot(Value *Op, const Twine &Name="", InsertPosition InsertBefore=nullptr)
static BinaryOperator * CreateFSubFMF(Value *V1, Value *V2, Instruction *FMFSource, const Twine &Name="")
static BinaryOperator * Create(BinaryOps Op, Value *S1, Value *S2, const Twine &Name=Twine(), InsertPosition InsertBefore=nullptr)
Construct a binary instruction, given the opcode and the two operands.
static BinaryOperator * CreateNUW(BinaryOps Opc, Value *V1, Value *V2, const Twine &Name="")
static BinaryOperator * CreateFAddFMF(Value *V1, Value *V2, Instruction *FMFSource, const Twine &Name="")
static BinaryOperator * CreateFMulFMF(Value *V1, Value *V2, FastMathFlags FMF, const Twine &Name="")
static BinaryOperator * CreateFDivFMF(Value *V1, Value *V2, FastMathFlags FMF, const Twine &Name="")
static BinaryOperator * CreateNUW(BinaryOps Opc, Value *V1, Value *V2, const Twine &Name, InsertPosition InsertBefore)
static BinaryOperator * CreateFSubFMF(Value *V1, Value *V2, FastMathFlags FMF, const Twine &Name="")
static BinaryOperator * CreateDisjoint(BinaryOps Opc, Value *V1, Value *V2, const Twine &Name="")
static BinaryOperator * CreateWithCopiedFlags(BinaryOps Opc, Value *V1, Value *V2, Value *CopyO, const Twine &Name="", InsertPosition InsertBefore=nullptr)
static BinaryOperator * CreateNSWNeg(Value *Op, const Twine &Name="", InsertPosition InsertBefore=nullptr)
BinaryOperator * cloneImpl() const
static BinaryOperator * CreateNSW(BinaryOps Opc, Value *V1, Value *V2, const Twine &Name, InsertPosition InsertBefore)
static bool classof(const Instruction *I)
Base class for all callable instructions (InvokeInst and CallInst) Holds everything related to callin...
MaybeAlign getParamStackAlign(unsigned ArgNo) const
void setCalledFunction(FunctionType *FTy, Value *Fn)
Sets the function called, including updating to the specified function type.
FPClassTest getParamNoFPClass(unsigned i) const
Extract a test mask for disallowed floating-point value classes for the parameter.
bool isInlineAsm() const
Check if this call is an inline asm statement.
void addFnAttr(Attribute Attr)
Adds the attribute to the function.
bool hasDescriptor() const
BundleOpInfo & getBundleOpInfoForOperand(unsigned OpIdx)
Return the BundleOpInfo for the operand at index OpIdx.
Attribute getRetAttr(Attribute::AttrKind Kind) const
Return the attribute for the given attribute kind for the return value.
void setCallingConv(CallingConv::ID CC)
FPClassTest getRetNoFPClass() const
Extract a test mask for disallowed floating-point value classes for the return value.
bool cannotMerge() const
Determine if the call cannot be tail merged.
unsigned getBundleOperandsEndIndex() const
Return the index of the last bundle operand in the Use array.
bundle_op_iterator bundle_op_info_begin()
Return the start of the list of BundleOpInfo instances associated with this OperandBundleUser.
MemoryEffects getMemoryEffects() const
void addRangeRetAttr(const ConstantRange &CR)
adds the range attribute to the list of attributes.
void addFnAttr(Attribute::AttrKind Kind)
Adds the attribute to the function.
bool hasInAllocaArgument() const
Determine if there are is an inalloca argument.
void removeParamAttrs(unsigned ArgNo, const AttributeMask &AttrsToRemove)
Removes the attributes from the given argument.
bool hasByValArgument() const
Determine if any call argument is an aggregate passed by value.
bool doesNotAccessMemory() const
Determine if the call does not access memory.
MaybeAlign getRetAlign() const
Extract the alignment of the return value.
void getOperandBundlesAsDefs(SmallVectorImpl< OperandBundleDef > &Defs) const
Return the list of operand bundles attached to this instruction as a vector of OperandBundleDefs.
Type * getParamByRefType(unsigned ArgNo) const
Extract the byref type for a call or parameter.
void setOnlyAccessesArgMemory()
iterator_range< const_bundle_op_iterator > bundle_op_infos() const
Return the range [bundle_op_info_begin, bundle_op_info_end).
OperandBundleUse getOperandBundleAt(unsigned Index) const
Return the operand bundle at a specific index.
OperandBundleUse operandBundleFromBundleOpInfo(const BundleOpInfo &BOI) const
Simple helper function to map a BundleOpInfo to an OperandBundleUse.
bool isPassingUndefUB(unsigned ArgNo) const
Determine whether passing undef to this argument is undefined behavior.
bool hasArgument(const Value *V) const
Returns true if this CallSite passes the given Value* as an argument to the called function.
Type * getParamPreallocatedType(unsigned ArgNo) const
Extract the preallocated type for a call or parameter.
void setOnlyAccessesInaccessibleMemOrArgMem()
bool data_operands_empty() const
bool isNoBuiltin() const
Return true if the call should not be treated as a call to a builtin.
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.
void addAttributeAtIndex(unsigned i, Attribute Attr)
adds the attribute to the list of attributes.
unsigned getDataOperandNo(const Use *U) const
Given a use for a data operand, get the data operand number that corresponds to it.
std::optional< OperandBundleUse > getOperandBundle(StringRef Name) const
Return an operand bundle by name, if present.
bool doesNotCapture(unsigned OpNo) const
Determine whether this data operand is not captured.
Type * getParamStructRetType(unsigned ArgNo) const
Extract the sret type for a call or parameter.
Attribute getParamAttr(unsigned ArgNo, StringRef Kind) const
Get the attribute of a given kind from a given arg.
void removeParamAttr(unsigned ArgNo, Attribute::AttrKind Kind)
Removes the attribute from the given argument.
Function * getCalledFunction() const
Returns the function called, or null if this is an indirect function invocation or the function signa...
Type * getParamInAllocaType(unsigned ArgNo) const
Extract the inalloca type for a call or parameter.
bool doesNotAccessMemory(unsigned OpNo) const
void removeRetAttrs(const AttributeMask &AttrsToRemove)
Removes the attributes from the return value.
void setDoesNotAccessMemory()
bool isInAllocaArgument(unsigned ArgNo) const
Determine whether this argument is passed in an alloca.
Use & getArgOperandUse(unsigned i)
bool hasFnAttr(Attribute::AttrKind Kind) const
Determine whether this call has the given attribute.
bool isStrictFP() const
Determine if the call requires strict floating point semantics.
User::op_iterator data_operands_begin()
data_operands_begin/data_operands_end - Return iterators iterating over the call / invoke argument li...
bool cannotDuplicate() const
Determine if the invoke cannot be duplicated.
AttributeSet getParamAttributes(unsigned ArgNo) const
Return the param attributes for this call.
bool hasRetAttr(Attribute::AttrKind Kind) const
Determine whether the return value has the given attribute.
User::const_op_iterator data_operands_end() const
bool onlyAccessesInaccessibleMemory() const
Determine if the function may only access memory that is inaccessible from the IR.
unsigned getNumOperandBundles() const
Return the number of operand bundles associated with this User.
uint64_t getParamDereferenceableBytes(unsigned i) const
Extract the number of dereferenceable bytes for a call or parameter (0=unknown).
void removeAttributeAtIndex(unsigned i, StringRef Kind)
removes the attribute from the list of attributes.
unsigned getDataOperandNo(Value::const_user_iterator UI) const
Given a value use iterator, return the data operand corresponding to it.
CallingConv::ID getCallingConv() const
bundle_op_iterator bundle_op_info_end()
Return the end of the list of BundleOpInfo instances associated with this OperandBundleUser.
unsigned getNumSubclassExtraOperandsDynamic() const
Get the number of extra operands for instructions that don't have a fixed number of extra operands.
void addParamAttr(unsigned ArgNo, Attribute Attr)
Adds the attribute to the indicated argument.
unsigned getNumSubclassExtraOperands() const
bool doesNoCfCheck() const
Determine if the call should not perform indirect branch tracking.
bool hasFnAttr(StringRef Kind) const
Determine whether this call has the given attribute.
bool paramHasAttr(unsigned ArgNo, Attribute::AttrKind Kind) const
Determine whether the argument or parameter has the given attribute.
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...
User::const_op_iterator arg_begin() const
User::op_iterator arg_begin()
Return the iterator pointing to the beginning of the argument list.
bool isMustTailCall() const
Tests if this call site must be tail call optimized.
Attribute getParamAttr(unsigned ArgNo, Attribute::AttrKind Kind) const
Get the attribute of a given kind from a given arg.
bool hasRetAttr(StringRef Kind) const
Determine whether the return value has the given attribute.
static bool classof(const Instruction *I)
bool isDataOperand(Value::const_user_iterator UI) const
Use & getCalledOperandUse()
bool isIndirectCall() const
Return true if the callsite is an indirect call.
bool isNoInline() const
Return true if the call should not be inlined.
bool dataOperandHasImpliedAttr(unsigned i, Attribute::AttrKind Kind) const
Return true if the data operand at index i has the attribute A.
static constexpr int CalledOperandOpEndIdx
The last operand is the called operand.
bool onlyReadsMemory() const
Determine if the call does not access or only reads memory.
bool isBundleOperand(const Use *U) const
Returns true if the use is a bundle operand.
bool isByValArgument(unsigned ArgNo) const
Determine whether this argument is passed by value.
iterator_range< bundle_op_iterator > bundle_op_infos()
Return the range [bundle_op_info_begin, bundle_op_info_end).
bool onlyWritesMemory(unsigned OpNo) const
unsigned countOperandBundlesOfType(StringRef Name) const
Return the number of operand bundles with the tag Name attached to this instruction.
void setOnlyReadsMemory()
void removeFnAttrs(const AttributeMask &AttrsToRemove)
Removes the attributes from the function.
iterator_range< User::op_iterator > data_ops()
const_bundle_op_iterator bundle_op_info_begin() const
Return the start of the list of BundleOpInfo instances associated with this OperandBundleUser.
static CallBase * addOperandBundle(CallBase *CB, uint32_t ID, OperandBundleDef OB, InsertPosition InsertPt=nullptr)
Create a clone of CB with operand bundle OB added.
bool isCallee(Value::const_user_iterator UI) const
Determine whether the passed iterator points to the callee operand's Use.
iterator_range< User::const_op_iterator > args() const
MaybeAlign getParamAlign(unsigned ArgNo) const
Extract the alignment for a call or parameter (0=unknown).
unsigned getBundleOperandsStartIndex() const
Return the index of the first bundle operand in the Use array.
bool onlyAccessesInaccessibleMemOrArgMem() const
Determine if the function may only access memory that is either inaccessible from the IR or pointed t...
DECLARE_TRANSPARENT_OPERAND_ACCESSORS(Value)
AttributeSet getRetAttributes() const
Return the return attributes for this call.
Attribute getFnAttr(Attribute::AttrKind Kind) const
Get the attribute of a given kind for the function.
User::op_iterator data_operands_end()
bool onlyReadsMemory(unsigned OpNo) const
Type * getParamByValType(unsigned ArgNo) const
Extract the byval type for a call or parameter.
bool isCallee(const Use *U) const
Determine whether this Use is the callee operand's Use.
CallBase(AttributeList const &A, FunctionType *FT, ArgsTy &&... Args)
const BundleOpInfo & getBundleOpInfoForOperand(unsigned OpIdx) const
Value * getCalledOperand() const
void setCalledFunction(FunctionCallee Fn)
Sets the function called, including updating the function type.
const Use & getCalledOperandUse() const
bool isArgOperand(Value::const_user_iterator UI) const
void setOnlyWritesMemory()
op_iterator populateBundleOperandInfos(ArrayRef< OperandBundleDef > Bundles, const unsigned BeginIndex)
Populate the BundleOpInfo instances and the Use& vector from Bundles.
void removeRetAttr(Attribute::AttrKind Kind)
Removes the attribute from the return value.
AttributeList Attrs
parameter attributes for callable
void addDereferenceableRetAttr(uint64_t Bytes)
adds the dereferenceable attribute to the list of attributes.
unsigned getArgOperandNo(Value::const_user_iterator UI) const
Given a value use iterator, return the arg operand number corresponding to it.
void setAttributes(AttributeList A)
Set the attributes for this call.
Attribute getFnAttr(StringRef Kind) const
Get the attribute of a given kind for the function.
void addAttributeAtIndex(unsigned i, Attribute::AttrKind Kind)
adds the attribute to the list of attributes.
unsigned countOperandBundlesOfType(uint32_t ID) const
Return the number of operand bundles with the tag ID attached to this instruction.
const Use & getArgOperandUse(unsigned i) const
Wrappers for getting the Use of a call argument.
bool hasOperandBundlesOtherThan(ArrayRef< uint32_t > IDs) const
Return true if this operand bundle user contains operand bundles with tags other than those specified...
bool returnDoesNotAlias() const
Determine if the return value is marked with NoAlias attribute.
OperandBundleUse getOperandBundleForOperand(unsigned OpIdx) const
Return the operand bundle for the operand at index OpIdx.
std::optional< ConstantRange > getRange() const
If this return value has a range attribute, return the value range of the argument.
bool doesNotThrow() const
Determine if the call cannot unwind.
void addRetAttr(Attribute::AttrKind Kind)
Adds the attribute to the return value.
Type * getParamElementType(unsigned ArgNo) const
Extract the elementtype type for a parameter.
bool isReturnNonNull() const
Return true if the return value is known to be not null.
Value * getArgOperand(unsigned i) const
bool hasStructRetAttr() const
Determine if the call returns a structure through first pointer argument.
uint64_t getRetDereferenceableBytes() const
Extract the number of dereferenceable bytes for a call or parameter (0=unknown).
void removeAttributeAtIndex(unsigned i, Attribute::AttrKind Kind)
removes the attribute from the list of attributes.
void setCannotDuplicate()
User::const_op_iterator data_operands_begin() const
void mutateFunctionType(FunctionType *FTy)
uint64_t getParamDereferenceableOrNullBytes(unsigned i) const
Extract the number of dereferenceable_or_null bytes for a parameter (0=unknown).
void setArgOperand(unsigned i, Value *v)
Attribute getAttributeAtIndex(unsigned i, Attribute::AttrKind Kind) const
Get the attribute of a given kind at a position.
bool bundleOperandHasAttr(unsigned OpIdx, Attribute::AttrKind A) const
Return true if the bundle operand at index OpIdx has the attribute A.
User::op_iterator arg_end()
Return the iterator pointing to the end of the argument list.
bool isBundleOperand(unsigned Idx) const
Return true if the operand at index Idx is a bundle operand.
bool isConvergent() const
Determine if the invoke is convergent.
FunctionType * getFunctionType() const
Intrinsic::ID getIntrinsicID() const
Returns the intrinsic ID of the intrinsic called or Intrinsic::not_intrinsic if the called function i...
static unsigned CountBundleInputs(ArrayRef< OperandBundleDef > Bundles)
Return the total number of values used in Bundles.
Value * getArgOperandWithAttribute(Attribute::AttrKind Kind) const
If one of the arguments has the specified attribute, returns its operand value.
Value * getReturnedArgOperand() const
If one of the arguments has the 'returned' attribute, returns its operand value.
void setOnlyAccessesInaccessibleMemory()
static CallBase * Create(CallBase *CB, ArrayRef< OperandBundleDef > Bundles, InsertPosition InsertPt=nullptr)
Create a clone of CB with a different set of operand bundles and insert it before InsertPt.
bool onlyWritesMemory() const
Determine if the call does not access or only writes memory.
unsigned data_operands_size() const
void removeFnAttr(Attribute::AttrKind Kind)
Removes the attribute from the function.
uint64_t getRetDereferenceableOrNullBytes() const
Extract the number of dereferenceable_or_null bytes for a call (0=unknown).
iterator_range< User::op_iterator > args()
Iteration adapter for range-for loops.
unsigned getArgOperandNo(const Use *U) const
Given a use for a arg operand, get the arg operand number that corresponds to it.
bool isBundleOperand(Value::const_user_iterator UI) const
bool hasClobberingOperandBundles() const
Return true if this operand bundle user has operand bundles that may write to the heap.
static bool classof(const Value *V)
Value * getConvergenceControlToken() const
Return the convergence control token for this call, if it exists.
void setCalledOperand(Value *V)
static CallBase * removeOperandBundle(CallBase *CB, uint32_t ID, InsertPosition InsertPt=nullptr)
Create a clone of CB with operand bundle ID removed.
bool doesNotReturn() const
Determine if the call cannot return.
bool hasReadingOperandBundles() const
Return true if this operand bundle user has operand bundles that may read from the heap.
void removeFnAttr(StringRef Kind)
Removes the attribute from the function.
bool onlyAccessesArgMemory() const
Determine if the call can access memmory only using pointers based on its arguments.
unsigned arg_size() const
void addDereferenceableParamAttr(unsigned i, uint64_t Bytes)
adds the dereferenceable attribute to the list of attributes.
AttributeList getAttributes() const
Return the attributes for this call.
std::optional< OperandBundleUse > getOperandBundle(uint32_t ID) const
Return an operand bundle by tag ID, if present.
void addRetAttr(Attribute Attr)
Adds the attribute to the return value.
void addParamAttr(unsigned ArgNo, Attribute::AttrKind Kind)
Adds the attribute to the indicated argument.
iterator_range< User::const_op_iterator > data_ops() const
bool isArgOperand(const Use *U) const
bool isDataOperand(const Use *U) const
bool hasDeoptState() const
Return true if the call has deopt state bundle.
void setMemoryEffects(MemoryEffects ME)
bool hasOperandBundles() const
Return true if this User has any operand bundles.
void setCalledFunction(Function *Fn)
Sets the function called, including updating the function type.
const_bundle_op_iterator bundle_op_info_end() const
Return the end of the list of BundleOpInfo instances associated with this OperandBundleUser.
bool isPassPointeeByValueArgument(unsigned ArgNo) const
Determine whether this argument is passed by value, in an alloca, or is preallocated.
bool isTailCall() const
Tests if this call site is marked as a tail call.
const Function * getCaller() const
void removeParamAttr(unsigned ArgNo, StringRef Kind)
Removes the attribute from the given argument.
User::const_op_iterator arg_end() const
Function * getCaller()
Helper to get the caller (the parent function).
bool tryIntersectAttributes(const CallBase *Other)
Try to intersect the attributes from 'this' CallBase and the 'Other' CallBase.
unsigned getNumTotalBundleOperands() const
Return the total number operands (not operand bundles) used by every operand bundle in this OperandBu...
Attribute getAttributeAtIndex(unsigned i, StringRef Kind) const
Get the attribute of a given kind at a position.
This is the base class for all instructions that perform data casts.
Type * getSrcTy() const
Return the source type, as a convenience.
static Instruction::CastOps getCastOpcode(const Value *Val, bool SrcIsSigned, Type *Ty, bool DstIsSigned)
Returns the opcode necessary to cast Val into Ty using usual casting rules.
static CastInst * CreatePointerBitCastOrAddrSpaceCast(Value *S, Type *Ty, const Twine &Name="", InsertPosition InsertBefore=nullptr)
Create a BitCast or an AddrSpaceCast cast instruction.
Instruction::CastOps getOpcode() const
Return the opcode of this CastInst.
static bool classof(const Value *V)
static CastInst * CreateIntegerCast(Value *S, Type *Ty, bool isSigned, const Twine &Name="", InsertPosition InsertBefore=nullptr)
Create a ZExt, BitCast, or Trunc for int -> int casts.
static CastInst * CreateFPCast(Value *S, Type *Ty, const Twine &Name="", InsertPosition InsertBefore=nullptr)
Create an FPExt, BitCast, or FPTrunc for fp -> fp casts.
static unsigned isEliminableCastPair(Instruction::CastOps firstOpcode, Instruction::CastOps secondOpcode, Type *SrcTy, Type *MidTy, Type *DstTy, Type *SrcIntPtrTy, Type *MidIntPtrTy, Type *DstIntPtrTy)
Determine how a pair of casts can be eliminated, if they can be at all.
CastInst(Type *Ty, unsigned iType, Value *S, const Twine &NameStr="", InsertPosition InsertBefore=nullptr)
Constructor with insert-before-instruction semantics for subclasses.
static bool isBitOrNoopPointerCastable(Type *SrcTy, Type *DestTy, const DataLayout &DL)
Check whether a bitcast, inttoptr, or ptrtoint cast between these types is valid and a no-op.
static bool castIsValid(Instruction::CastOps op, Value *S, Type *DstTy)
static bool isBitCastable(Type *SrcTy, Type *DestTy)
Check whether a bitcast between these types is valid.
static CastInst * CreateTruncOrBitCast(Value *S, Type *Ty, const Twine &Name="", InsertPosition InsertBefore=nullptr)
Create a Trunc or BitCast cast instruction.
static CastInst * CreatePointerCast(Value *S, Type *Ty, const Twine &Name="", InsertPosition InsertBefore=nullptr)
Create a BitCast, AddrSpaceCast or a PtrToInt cast instruction.
static CastInst * CreateBitOrPointerCast(Value *S, Type *Ty, const Twine &Name="", InsertPosition InsertBefore=nullptr)
Create a BitCast, a PtrToInt, or an IntToPTr cast instruction.
static bool isNoopCast(Instruction::CastOps Opcode, Type *SrcTy, Type *DstTy, const DataLayout &DL)
A no-op cast is one that can be effected without changing any bits.
static CastInst * CreateZExtOrBitCast(Value *S, Type *Ty, const Twine &Name="", InsertPosition InsertBefore=nullptr)
Create a ZExt or BitCast cast instruction.
static CastInst * Create(Instruction::CastOps, Value *S, Type *Ty, const Twine &Name="", InsertPosition InsertBefore=nullptr)
Provides a way to construct any of the CastInst subclasses using an opcode instead of the subclass's ...
bool isIntegerCast() const
There are several places where we need to know if a cast instruction only deals with integer source a...
Type * getDestTy() const
Return the destination type, as a convenience.
static CastInst * CreateSExtOrBitCast(Value *S, Type *Ty, const Twine &Name="", InsertPosition InsertBefore=nullptr)
Create a SExt or BitCast cast instruction.
static bool castIsValid(Instruction::CastOps op, Type *SrcTy, Type *DstTy)
This method can be used to determine if a cast from SrcTy to DstTy using Opcode op is valid or not.
static bool classof(const Instruction *I)
Methods for support type inquiry through isa, cast, and dyn_cast:
This class is the base class for the comparison instructions.
static Type * makeCmpResultType(Type *opnd_type)
Create a result type for fcmp/icmp.
Predicate getStrictPredicate() const
For example, SGE -> SGT, SLE -> SLT, ULE -> ULT, UGE -> UGT.
bool isEquality() const
Determine if this is an equals/not equals predicate.
void setPredicate(Predicate P)
Set the predicate for this instruction to the specified value.
bool isFalseWhenEqual() const
This is just a convenience.
static bool classof(const Instruction *I)
Methods for support type inquiry through isa, cast, and dyn_cast:
Predicate
This enumeration lists the possible predicates for CmpInst subclasses.
@ FCMP_OEQ
0 0 0 1 True if ordered and equal
@ FCMP_TRUE
1 1 1 1 Always true (always folded)
@ ICMP_SLT
signed less than
@ ICMP_SLE
signed less or equal
@ FCMP_OLT
0 1 0 0 True if ordered and less than
@ FCMP_ULE
1 1 0 1 True if unordered, less than, or equal
@ FCMP_OGT
0 0 1 0 True if ordered and greater than
@ FCMP_OGE
0 0 1 1 True if ordered and greater than or equal
@ ICMP_UGE
unsigned greater or equal
@ ICMP_UGT
unsigned greater than
@ ICMP_SGT
signed greater than
@ FCMP_ULT
1 1 0 0 True if unordered or less than
@ FCMP_ONE
0 1 1 0 True if ordered and operands are unequal
@ FCMP_UEQ
1 0 0 1 True if unordered or equal
@ ICMP_ULT
unsigned less than
@ FCMP_UGT
1 0 1 0 True if unordered or greater than
@ FCMP_OLE
0 1 0 1 True if ordered and less than or equal
@ FCMP_ORD
0 1 1 1 True if ordered (no nans)
@ ICMP_SGE
signed greater or equal
@ FCMP_UNE
1 1 1 0 True if unordered or not equal
@ ICMP_ULE
unsigned less or equal
@ FCMP_UGE
1 0 1 1 True if unordered, greater than, or equal
@ FCMP_FALSE
0 0 0 0 Always false (always folded)
@ FCMP_UNO
1 0 0 0 True if unordered: isnan(X) | isnan(Y)
static auto ICmpPredicates()
Returns the sequence of all ICmp predicates.
bool isEquivalence(bool Invert=false) const
Determine if one operand of this compare can always be replaced by the other operand,...
Predicate getSwappedPredicate() const
For example, EQ->EQ, SLE->SGE, ULT->UGT, OEQ->OEQ, ULE->UGE, OLT->OGT, etc.
static auto FCmpPredicates()
Returns the sequence of all FCmp predicates.
bool isTrueWhenEqual() const
This is just a convenience.
static CmpInst * Create(OtherOps Op, Predicate Pred, Value *S1, Value *S2, const Twine &Name="", InsertPosition InsertBefore=nullptr)
Construct a compare instruction, given the opcode, the predicate and the two operands.
Predicate getOrderedPredicate() const
static bool isFPPredicate(Predicate P)
Predicate getNonStrictPredicate() const
For example, SGT -> SGE, SLT -> SLE, ULT -> ULE, UGT -> UGE.
static CmpInst * CreateWithCopiedFlags(OtherOps Op, Predicate Pred, Value *S1, Value *S2, const Instruction *FlagsSource, const Twine &Name="", InsertPosition InsertBefore=nullptr)
Construct a compare instruction, given the opcode, the predicate, the two operands and the instructio...
bool isNonStrictPredicate() const
bool isFPPredicate() const
void swapOperands()
This is just a convenience that dispatches to the subclasses.
static bool isRelational(Predicate P)
Return true if the predicate is relational (not EQ or NE).
Predicate getInversePredicate() const
For example, EQ -> NE, UGT -> ULE, SLT -> SGE, OEQ -> UNE, UGT -> OLE, OLT -> UGE,...
static StringRef getPredicateName(Predicate P)
Predicate getPredicate() const
Return the predicate for this instruction.
bool isStrictPredicate() const
static bool isUnordered(Predicate predicate)
Determine if the predicate is an unordered operation.
Predicate getFlippedStrictnessPredicate() const
For predicate of kind "is X or equal to 0" returns the predicate "is X".
static Predicate getOrderedPredicate(Predicate Pred)
Returns the ordered variant of a floating point compare.
DECLARE_TRANSPARENT_OPERAND_ACCESSORS(Value)
Provide more efficient getOperand methods.
bool isIntPredicate() const
static bool isIntPredicate(Predicate P)
Predicate getUnorderedPredicate() const
static bool isOrdered(Predicate predicate)
Determine if the predicate is an ordered operation.
static bool classof(const Value *V)
static Predicate getUnorderedPredicate(Predicate Pred)
Returns the unordered variant of a floating point compare.
OtherOps getOpcode() const
Get the opcode casted to the right type.
bool isCommutative() const
This is just a convenience that dispatches to the subclasses.
bool isRelational() const
Return true if the predicate is relational (not EQ or NE).
This class represents a range of values.
This class represents an Operation in the Expression.
A parsed version of the target data layout string in and methods for querying it.
This provides a helper for copying FMF from an instruction or setting specified flags.
Convenience struct for specifying and reasoning about fast-math flags.
static bool classof(const Instruction *I)
op_range arg_operands()
arg_operands - iteration adapter for range-for loops.
void setArgOperand(unsigned i, Value *v)
unsigned arg_size() const
arg_size - Return the number of funcletpad arguments.
static bool classof(const Value *V)
void setParentPad(Value *ParentPad)
DECLARE_TRANSPARENT_OPERAND_ACCESSORS(Value)
Provide fast operand accessors.
Value * getParentPad() const
Convenience accessors.
const_op_range arg_operands() const
arg_operands - iteration adapter for range-for loops.
Value * getArgOperand(unsigned i) const
getArgOperand/setArgOperand - Return/set the i-th funcletpad argument.
A handy container for a FunctionType+Callee-pointer pair, which can be passed around as a single enti...
FunctionType * getFunctionType()
Class to represent function types.
Type * getReturnType() const
FunctionType * getFunctionType() const
Returns the FunctionType for me.
void setHasNoUnsignedWrap(bool b=true)
Set or clear the nuw flag on this instruction, which must be an operator which supports this flag.
void copyIRFlags(const Value *V, bool IncludeWrapFlags=true)
Convenience method to copy supported exact, fast-math, and (optionally) wrapping flags from V to this...
void setHasNoSignedWrap(bool b=true)
Set or clear the nsw flag on this instruction, which must be an operator which supports this flag.
void setFastMathFlags(FastMathFlags FMF)
Convenience function for setting multiple fast-math flags on this instruction, which must be an opera...
unsigned getOpcode() const
Returns a member of one of the enums like Instruction::Add.
void setIsExact(bool b=true)
Set or clear the exact flag on this instruction, which must be an operator which supports this flag.
Instruction(const Instruction &)=delete
A container for an operand bundle being viewed as a set of values rather than a set of uses.
size_t input_size() const
input_iterator input_end() const
OperandBundleDefT(const OperandBundleUse &OBU)
ArrayRef< InputTy > inputs() const
typename std::vector< InputTy >::const_iterator input_iterator
OperandBundleDefT(std::string Tag, std::vector< InputTy > Inputs)
input_iterator input_begin() const
OperandBundleDefT(std::string Tag, ArrayRef< InputTy > Inputs)
An or instruction, which can be marked as "disjoint", indicating that the inputs don't have a 1 in th...
void setIsDisjoint(bool B)
static bool classof(const Value *V)
static bool classof(const Instruction *I)
Instruction that can have a nneg flag (zext/uitofp).
static bool classof(const Instruction *I)
static bool classof(const Value *V)
This class consists of common code factored out of the SmallVector class to reduce code duplication b...
const ValueTy & getValue() const
StringMapEntry - This is used to represent one value that is inserted into a StringMap.
StringRef - Represent a constant reference to a string, i.e.
Twine - A lightweight data structure for efficiently representing the concatenation of temporary valu...
The instances of the Type class are immutable: once they are created, they are never changed.
static IntegerType * getInt1Ty(LLVMContext &C)
LLVMContext & getContext() const
Return the LLVMContext in which this type was uniqued.
static bool classof(const Instruction *I)
DECLARE_TRANSPARENT_OPERAND_ACCESSORS(Value)
Transparently provide more efficient getOperand methods.
static bool classof(const Value *V)
UnaryInstruction(Type *Ty, unsigned iType, Value *V, InsertPosition InsertBefore=nullptr)
static UnaryOperator * CreateWithCopiedFlags(UnaryOps Opc, Value *V, Instruction *CopyO, const Twine &Name="", InsertPosition InsertBefore=nullptr)
UnaryOps getOpcode() const
static UnaryOperator * CreateFNegFMF(Value *Op, Instruction *FMFSource, const Twine &Name="", InsertPosition InsertBefore=nullptr)
static bool classof(const Value *V)
static bool classof(const Instruction *I)
A Use represents the edge between a Value definition and its users.
ArrayRef< const uint8_t > getDescriptor() const
Returns the descriptor co-allocated with this User instance.
const Use & getOperandUse(unsigned i) const
void setOperand(unsigned i, Value *Val)
Value * getOperand(unsigned i) const
LLVM Value Representation.
Type * getType() const
All values are typed, get the type of this value.
user_iterator_impl< const User > const_user_iterator
void setName(const Twine &Name)
Change the name of the value.
void setValueSubclassData(unsigned short D)
LLVMContext & getContext() const
All values hold a context through their type.
void mutateType(Type *Ty)
Mutate the type of this Value to be of the specified type.
Base class of all SIMD vector types.
static VectorType * get(Type *ElementType, ElementCount EC)
This static method is the primary way to construct an VectorType.
A range adaptor for a pair of iterators.
This class implements an extremely fast bulk output stream that can only output to a stream.
This provides a very simple, boring adaptor for a begin and end iterator into a range type.
#define llvm_unreachable(msg)
Marks that the current location is not supposed to be reachable.
@ MaxID
The highest possible ID. Must be some 2^k - 1.
unsigned ID
LLVM IR allows to use arbitrary numbers as calling convention identifiers.
This is an optimization pass for GlobalISel generic memory operations.
auto enum_seq_inclusive(EnumT Begin, EnumT End)
Iterate over an enum type from Begin to End inclusive.
iterator_range< T > make_range(T x, T y)
Convenience function for iterating over sub-ranges.
void append_range(Container &C, Range &&R)
Wrapper function to append range R to container C.
constexpr force_iteration_on_noniterable_enum_t force_iteration_on_noniterable_enum
FPClassTest
Floating-point class tests, supported by 'is_fpclass' intrinsic.
@ Or
Bitwise or logical OR of integers.
@ Mul
Product of integers.
DWARFExpression::Operation Op
raw_ostream & operator<<(raw_ostream &OS, const APFixedPoint &FX)
OutputIt move(R &&Range, OutputIt Out)
Provide wrappers to std::move which take ranges instead of having to pass begin/end explicitly.
bool is_contained(R &&Range, const E &Element)
Returns true if Element is found in Range.
Implement std::hash so that hash_code can be used in STL containers.
This struct is a compact representation of a valid (non-zero power of two) alignment.
Describes an element of a Bitfield.
static constexpr unsigned NextBit
Used to keep track of an operand bundle.
bool operator==(const BundleOpInfo &Other) const
StringMapEntry< uint32_t > * Tag
The operand bundle tag, interned by LLVMContextImpl::getOrInsertBundleTag.
uint32_t End
The index in the Use& vector where operands for this operand bundle ends.
uint32_t Begin
The index in the Use& vector where operands for this operand bundle starts.
FixedNumOperandTraits - determine the allocation regime of the Use array when it is a prefix to the U...
This struct is a compact representation of a valid (power of two) or undefined (0) alignment.
A lightweight accessor for an operand bundle meant to be passed around by value.
bool isFuncletOperandBundle() const
Return true if this is a "funclet" operand bundle.
StringRef getTagName() const
Return the tag of this operand bundle as a string.
bool isDeoptOperandBundle() const
Return true if this is a "deopt" operand bundle.
OperandBundleUse()=default
OperandBundleUse(StringMapEntry< uint32_t > *Tag, ArrayRef< Use > Inputs)
uint32_t getTagID() const
Return the tag of this operand bundle as an integer.
bool operandHasAttr(unsigned Idx, Attribute::AttrKind A) const
Return true if the operand at index Idx in this operand bundle has the attribute A.
bool isCFGuardTargetOperandBundle() const
Return true if this is a "cfguardtarget" operand bundle.
Compile-time customization of User operands.
Information about how a User object was allocated, to be passed into the User constructor.
Indicates this User has operands co-allocated.
VariadicOperandTraits - determine the allocation regime of the Use array when it is a prefix to the U...