1//===- llvm/Instructions.h - Instruction subclass definitions ---*- 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 exposes the class definitions of all of the subclasses of the 10// Instruction class. This is meant to be an easy way to get access to all 11// instruction subclasses. 13//===----------------------------------------------------------------------===// 15#ifndef LLVM_IR_INSTRUCTIONS_H 16#define LLVM_IR_INSTRUCTIONS_H 58//===----------------------------------------------------------------------===// 60//===----------------------------------------------------------------------===// 62/// an instruction to allocate memory on the stack 71"Bitfields must be contiguous");
74// Note: Instruction needs to be a friend here to call cloneImpl. 89 /// Return true if there is an allocation size parameter to the allocation 90 /// instruction that is not 1. 93 /// Get the number of elements allocated. For a simple allocation of a single 94 /// element, this will return a constant 1 value. 98 /// Overload to return most specific pointer type. 103 /// Return the address space for the allocation. 108 /// Get allocation size in bytes. Returns std::nullopt if size can't be 109 /// determined, e.g. in case of a VLA. 112 /// Get allocation size in bits. Returns std::nullopt if size can't be 113 /// determined, e.g. in case of a VLA. 116 /// Return the type that is being allocated by the instruction. 118 /// for use only in special circumstances that need to generically 119 /// transform a whole instruction (eg: IR linking and vectorization). 122 /// Return the alignment of the memory that is being allocated by the 125returnAlign(1ULL << getSubclassData<AlignmentField>());
129 setSubclassData<AlignmentField>(
Log2(
Align));
132 /// Return true if this alloca is in the entry block of the function and is a 133 /// constant size. If so, the code generator will fold it into the 134 /// prolog/epilog code, so it is basically free. 137 /// Return true if this alloca is used as an inalloca argument to a call. Such 138 /// allocas are never considered static even if they are in the entry block. 140return getSubclassData<UsedWithInAllocaField>();
143 /// Specify whether this alloca is used to represent the arguments to a call. 145 setSubclassData<UsedWithInAllocaField>(V);
148 /// Return true if this alloca is used as a swifterror argument to a call. 150 /// Specify whether this alloca is used to represent a swifterror. 153// Methods for support type inquiry through isa, cast, and dyn_cast: 155return (
I->getOpcode() == Instruction::Alloca);
158return isa<Instruction>(V) &&
classof(cast<Instruction>(V));
162// Shadow Instruction::setInstructionSubclassData with a private forwarding 163// method so that subclasses cannot accidentally use it. 164template <
typename Bitfield>
165void setSubclassData(
typename Bitfield::Type
Value) {
166 Instruction::setSubclassData<Bitfield>(
Value);
170//===----------------------------------------------------------------------===// 172//===----------------------------------------------------------------------===// 174/// An instruction for reading from memory. This uses the SubclassData field in 175/// Value to store whether or not the load is volatile. 181 Bitfield::areContiguous<VolatileField, AlignmentField, OrderingField>(),
182"Bitfields must be contiguous");
187// Note: Instruction needs to be a friend here to call cloneImpl. 204 /// Return true if this is a load from a volatile memory location. 205boolisVolatile()
const{
return getSubclassData<VolatileField>(); }
207 /// Specify whether this is a volatile load or not. 210 /// Return the alignment of the access that is being performed. 212returnAlign(1ULL << (getSubclassData<AlignmentField>()));
216 setSubclassData<AlignmentField>(
Log2(
Align));
219 /// Returns the ordering constraint of this load instruction. 221return getSubclassData<OrderingField>();
223 /// Sets the ordering constraint of this load instruction. May not be Release 224 /// or AcquireRelease. 226 setSubclassData<OrderingField>(Ordering);
229 /// Returns the synchronization scope ID of this load instruction. 234 /// Sets the synchronization scope ID of this load instruction. 239 /// Sets the ordering constraint and the synchronization scope ID of this load 260 /// Returns the address space of the pointer operand. 265// Methods for support type inquiry through isa, cast, and dyn_cast: 267returnI->getOpcode() == Instruction::Load;
270return isa<Instruction>(V) &&
classof(cast<Instruction>(V));
274// Shadow Instruction::setInstructionSubclassData with a private forwarding 275// method so that subclasses cannot accidentally use it. 276template <
typename Bitfield>
277void setSubclassData(
typename Bitfield::Type
Value) {
278 Instruction::setSubclassData<Bitfield>(
Value);
281 /// The synchronization scope ID of this load instruction. Not quite enough 282 /// room in SubClassData for everything, so synchronization scope ID gets its 287//===----------------------------------------------------------------------===// 289//===----------------------------------------------------------------------===// 291/// An instruction for storing to memory. 297 Bitfield::areContiguous<VolatileField, AlignmentField, OrderingField>(),
298"Bitfields must be contiguous");
305// Note: Instruction needs to be a friend here to call cloneImpl. 320// allocate space for exactly two operands 321void *
operatornew(
size_t S) {
return User::operator
new(S, AllocMarker); }
322voidoperatordelete(
void *
Ptr) { User::operator
delete(
Ptr); }
324 /// Return true if this is a store to a volatile memory location. 325boolisVolatile()
const{
return getSubclassData<VolatileField>(); }
327 /// Specify whether this is a volatile store or not. 330 /// Transparently provide more efficient getOperand methods. 334returnAlign(1ULL << (getSubclassData<AlignmentField>()));
338 setSubclassData<AlignmentField>(
Log2(
Align));
341 /// Returns the ordering constraint of this store instruction. 343return getSubclassData<OrderingField>();
346 /// Sets the ordering constraint of this store instruction. May not be 347 /// Acquire or AcquireRelease. 349 setSubclassData<OrderingField>(Ordering);
352 /// Returns the synchronization scope ID of this store instruction. 357 /// Sets the synchronization scope ID of this store instruction. 362 /// Sets the ordering constraint and the synchronization scope ID of this 363 /// store instruction. 386 /// Returns the address space of the pointer operand. 391// Methods for support type inquiry through isa, cast, and dyn_cast: 393returnI->getOpcode() == Instruction::Store;
396return isa<Instruction>(V) &&
classof(cast<Instruction>(V));
400// Shadow Instruction::setInstructionSubclassData with a private forwarding 401// method so that subclasses cannot accidentally use it. 402template <
typename Bitfield>
403void setSubclassData(
typename Bitfield::Type
Value) {
404 Instruction::setSubclassData<Bitfield>(
Value);
407 /// The synchronization scope ID of this store instruction. Not quite enough 408 /// room in SubClassData for everything, so synchronization scope ID gets its 419//===----------------------------------------------------------------------===// 421//===----------------------------------------------------------------------===// 423/// An instruction for ordering other memory operations. 432// Note: Instruction needs to be a friend here to call cloneImpl. 438// Ordering may only be Acquire, Release, AcquireRelease, or 439// SequentiallyConsistent. 444// allocate space for exactly zero operands 445void *
operatornew(
size_t S) {
return User::operator
new(S, AllocMarker); }
446voidoperatordelete(
void *
Ptr) { User::operator
delete(
Ptr); }
448 /// Returns the ordering constraint of this fence instruction. 450return getSubclassData<OrderingField>();
453 /// Sets the ordering constraint of this fence instruction. May only be 454 /// Acquire, Release, AcquireRelease, or SequentiallyConsistent. 456 setSubclassData<OrderingField>(Ordering);
459 /// Returns the synchronization scope ID of this fence instruction. 464 /// Sets the synchronization scope ID of this fence instruction. 469// Methods for support type inquiry through isa, cast, and dyn_cast: 471returnI->getOpcode() == Instruction::Fence;
474return isa<Instruction>(V) && classof(cast<Instruction>(V));
478// Shadow Instruction::setInstructionSubclassData with a private forwarding 479// method so that subclasses cannot accidentally use it. 480template <
typename Bitfield>
481void setSubclassData(
typename Bitfield::Type
Value) {
482 Instruction::setSubclassData<Bitfield>(
Value);
485 /// The synchronization scope ID of this fence instruction. Not quite enough 486 /// room in SubClassData for everything, so synchronization scope ID gets its 491//===----------------------------------------------------------------------===// 492// AtomicCmpXchgInst Class 493//===----------------------------------------------------------------------===// 495/// An instruction that atomically checks whether a 496/// specified value is in a memory location, and, if it is, stores a new value 497/// there. The value returned by this instruction is a pair containing the 498/// original value as first element, and an i1 indicating success (true) or 499/// failure (false) as second element. 506template <
unsigned Offset>
507usingAtomicOrderingBitfieldElement =
514// Note: Instruction needs to be a friend here to call cloneImpl. 525// allocate space for exactly three operands 526void *
operatornew(
size_t S) {
return User::operator
new(S, AllocMarker); }
527voidoperatordelete(
void *
Ptr) { User::operator
delete(
Ptr); }
540"Bitfields must be contiguous");
542 /// Return the alignment of the memory that is being allocated by the 545returnAlign(1ULL << getSubclassData<AlignmentField>());
549 setSubclassData<AlignmentField>(
Log2(
Align));
552 /// Return true if this is a cmpxchg from a volatile memory 555boolisVolatile()
const{
return getSubclassData<VolatileField>(); }
557 /// Specify whether this is a volatile cmpxchg. 561 /// Return true if this cmpxchg may spuriously fail. 562boolisWeak()
const{
return getSubclassData<WeakField>(); }
564voidsetWeak(
bool IsWeak) { setSubclassData<WeakField>(IsWeak); }
566 /// Transparently provide more efficient getOperand methods. 581 /// Returns the success ordering constraint of this cmpxchg instruction. 583return getSubclassData<SuccessOrderingField>();
586 /// Sets the success ordering constraint of this cmpxchg instruction. 589"invalid CmpXchg success ordering");
590 setSubclassData<SuccessOrderingField>(Ordering);
593 /// Returns the failure ordering constraint of this cmpxchg instruction. 595return getSubclassData<FailureOrderingField>();
598 /// Sets the failure ordering constraint of this cmpxchg instruction. 601"invalid CmpXchg failure ordering");
602 setSubclassData<FailureOrderingField>(Ordering);
605 /// Returns a single ordering which is at least as strong as both the 606 /// success and failure orderings for this cmpxchg. 619 /// Returns the synchronization scope ID of this cmpxchg instruction. 624 /// Sets the synchronization scope ID of this cmpxchg instruction. 639 /// Returns the address space of the pointer operand. 644 /// Returns the strongest permitted ordering on failure, given the 645 /// desired ordering on success. 647 /// If the comparison in a cmpxchg operation fails, there is no atomic store 648 /// so release semantics cannot be provided. So this function drops explicit 649 /// Release requests from the AtomicOrdering. A SequentiallyConsistent 650 /// operation would remain SequentiallyConsistent. 653switch (SuccessOrdering) {
667// Methods for support type inquiry through isa, cast, and dyn_cast: 669returnI->getOpcode() == Instruction::AtomicCmpXchg;
672return isa<Instruction>(V) &&
classof(cast<Instruction>(V));
676// Shadow Instruction::setInstructionSubclassData with a private forwarding 677// method so that subclasses cannot accidentally use it. 678template <
typename Bitfield>
679void setSubclassData(
typename Bitfield::Type
Value) {
680 Instruction::setSubclassData<Bitfield>(
Value);
683 /// The synchronization scope ID of this cmpxchg instruction. Not quite 684 /// enough room in SubClassData for everything, so synchronization scope ID 685 /// gets its own field. 696//===----------------------------------------------------------------------===// 697// AtomicRMWInst Class 698//===----------------------------------------------------------------------===// 700/// an instruction that atomically reads a memory location, 701/// combines it with another value, and then stores the result back. Returns 706// Note: Instruction needs to be a friend here to call cloneImpl. 712 /// This enumeration lists the possible modifications atomicrmw can make. In 713 /// the descriptions, 'p' is the pointer to the instruction's memory location, 714 /// 'old' is the initial value of *p, and 'v' is the other value passed to the 715 /// instruction. These instructions always return 'old'. 731 /// *p = old >signed v ? old : v 733 /// *p = old <signed v ? old : v 735 /// *p = old >unsigned v ? old : v 737 /// *p = old <unsigned v ? old : v 746 /// *p = maxnum(old, v) 747 /// \p maxnum matches the behavior of \p llvm.maxnum.*. 750 /// *p = minnum(old, v) 751 /// \p minnum matches the behavior of \p llvm.minnum.*. 754 /// Increment one up to a maximum value. 755 /// *p = (old u>= v) ? 0 : (old + 1) 758 /// Decrement one until a minimum value or zero. 759 /// *p = ((old == 0) || (old u> v)) ? v : (old - 1) 762 /// Subtract only if no unsigned overflow. 763 /// *p = (old u>= v) ? old - v : old 766 /// *p = usub.sat(old, v) 767 /// \p usub.sat matches the behavior of \p llvm.usub.sat.*. 771 LAST_BINOP = USubSat,
776template <
unsigned Offset>
777usingAtomicOrderingBitfieldElement =
781template <
unsigned Offset>
782usingBinOpBitfieldElement =
785constexprstatic IntrusiveOperandsAllocMarker AllocMarker{2};
790 InsertPosition InsertBefore =
nullptr);
792// allocate space for exactly two operands 793void *
operatornew(
size_t S) {
return User::operator
new(S, AllocMarker); }
794voidoperatordelete(
void *
Ptr) { User::operator
delete(
Ptr); }
803"Bitfields must be contiguous");
822 setSubclassData<OperationField>(
Operation);
825 /// Return the alignment of the memory that is being allocated by the 828returnAlign(1ULL << getSubclassData<AlignmentField>());
832 setSubclassData<AlignmentField>(
Log2(
Align));
835 /// Return true if this is a RMW on a volatile memory location. 837boolisVolatile()
const{
return getSubclassData<VolatileField>(); }
839 /// Specify whether this is a volatile RMW or not. 843 /// Transparently provide more efficient getOperand methods. 846 /// Returns the ordering constraint of this rmw instruction. 848return getSubclassData<AtomicOrderingField>();
851 /// Sets the ordering constraint of this rmw instruction. 854"atomicrmw instructions can only be atomic.");
856"atomicrmw instructions cannot be unordered.");
857 setSubclassData<AtomicOrderingField>(Ordering);
860 /// Returns the synchronization scope ID of this rmw instruction. 865 /// Sets the synchronization scope ID of this rmw instruction. 877 /// Returns the address space of the pointer operand. 883return isFPOperation(getOperation());
886// Methods for support type inquiry through isa, cast, and dyn_cast: 888returnI->getOpcode() == Instruction::AtomicRMW;
891return isa<Instruction>(V) && classof(cast<Instruction>(V));
898// Shadow Instruction::setInstructionSubclassData with a private forwarding 899// method so that subclasses cannot accidentally use it. 900template <
typename Bitfield>
901void setSubclassData(
typename Bitfield::Type
Value) {
902 Instruction::setSubclassData<Bitfield>(
Value);
905 /// The synchronization scope ID of this rmw instruction. Not quite enough 906 /// room in SubClassData for everything, so synchronization scope ID gets its 918//===----------------------------------------------------------------------===// 919// GetElementPtrInst Class 920//===----------------------------------------------------------------------===// 922// checkGEPType - Simple wrapper function to give a better assertion failure 923// message on bad indexes for a gep instruction. 926assert(Ty &&
"Invalid GetElementPtrInst indices for type!");
930/// an instruction for type-safe pointer arithmetic to 931/// access elements of arrays and structs 934Type *SourceElementType;
935Type *ResultElementType;
939 /// Constructors - Create a getelementptr instruction with a base pointer an 940 /// list of indices. The first and second ctor can optionally insert before an 941 /// existing instruction, the third appends the new instruction to the 942 /// specified BasicBlock. 950// Note: Instruction needs to be a friend here to call cloneImpl. 958constTwine &NameStr =
"",
961assert(PointeeType &&
"Must specify element type");
964 PointeeType,
Ptr, IdxList, AllocMarker, NameStr, InsertBefore);
969constTwine &NameStr =
"",
972Create(PointeeType,
Ptr, IdxList, NameStr, InsertBefore);
973GEP->setNoWrapFlags(NW);
977 /// Create an "inbounds" getelementptr. See the documentation for the 978 /// "inbounds" flag in LangRef.html for details. 981constTwine &NameStr =
"",
984 NameStr, InsertBefore);
987 /// Transparently provide more efficient getOperand methods. 996return ResultElementType;
999 /// Returns the address space of this instruction's pointer type. 1001// Note that this is always the same as the pointer operand's address space 1002// and that is cheaper to compute, so cheat here. 1006 /// Returns the result type of a getelementptr with the given source 1007 /// element type and indexes. 1009 /// Null is returned if the indices are invalid for the specified 1010 /// source element type. 1015 /// Return the type of the element at the given index of an indexable 1016 /// type. This is equivalent to "getIndexedType(Agg, {Zero, Idx})". 1018 /// Returns null if the type can't be indexed, or the given index is not 1019 /// legal for the given type. 1043return 0U;
// get index for modifying correct operand. 1046 /// Method to return the pointer operand as a 1052 /// Returns the address space of the pointer operand. 1057 /// Returns the pointer type returned by the GEP 1058 /// instruction, which may be a vector of pointers. 1066if (
auto *IndexVTy = dyn_cast<VectorType>(
Index->getType())) {
1082 /// Return true if all of the indices of this GEP are 1083 /// zeros. If so, the result pointer and the first operand have the same 1084 /// value, just potentially different types. 1087 /// Return true if all of the indices of this GEP are 1088 /// constant integers. If so, the result pointer and the first operand have 1089 /// a constant offset between them. 1092 /// Set nowrap flags for GEP instruction. 1095 /// Set or clear the inbounds flag on this GEP instruction. 1096 /// See LangRef.html for the meaning of inbounds on a getelementptr. 1097 /// TODO: Remove this method in favor of setNoWrapFlags(). 1100 /// Get the nowrap flags for the GEP instruction. 1103 /// Determine whether the GEP has the inbounds flag. 1106 /// Determine whether the GEP has the nusw flag. 1109 /// Determine whether the GEP has the nuw flag. 1112 /// Accumulate the constant address offset of this GEP if possible. 1114 /// This routine accepts an APInt into which it will accumulate the constant 1115 /// offset of this GEP if the GEP is in fact constant. If the GEP is not 1116 /// all-constant, it returns false and the value of the offset APInt is 1117 /// undefined (it is *not* preserved!). The APInt passed into this routine 1118 /// must be at least as wide as the IntPtr type for the address space of 1119 /// the base GEP pointer. 1123APInt &ConstantOffset)
const;
1124// Methods for support type inquiry through isa, cast, and dyn_cast: 1126return (
I->getOpcode() == Instruction::GetElementPtr);
1129return isa<Instruction>(V) &&
classof(cast<Instruction>(V));
1137GetElementPtrInst::GetElementPtrInst(
Type *PointeeType,
Value *
Ptr,
1143 SourceElementType(PointeeType),
1144 ResultElementType(getIndexedType(PointeeType, IdxList)) {
1145 init(
Ptr, IdxList, NameStr);
1150//===----------------------------------------------------------------------===// 1152//===----------------------------------------------------------------------===// 1154/// This instruction compares its operands according to the predicate given 1155/// to the constructor. It only operates on integers or pointers. The operands 1156/// must be identical types. 1157/// Represent an integer comparison operator. 1160assert(isIntPredicate() &&
1161"Invalid ICmp predicate value");
1163"Both operands to ICmp instruction are not of the same type!");
1164// Check that the operands are the right type 1166 getOperand(0)->
getType()->isPtrOrPtrVectorTy()) &&
1167"Invalid operand types for ICmp instruction");
1170enum { SameSign = (1 << 0) };
1173// Note: Instruction needs to be a friend here to call cloneImpl. 1176 /// Clone an identical ICmpInst 1180 /// Constructor with insertion semantics. 1183Value *
LHS,
///< The left-hand-side of the expression 1184Value *
RHS,
///< The right-hand-side of the expression 1185constTwine &NameStr =
""///< Name of the instruction 1188RHS, NameStr, InsertBefore) {
1194 /// Constructor with no-insertion semantics 1197Value *
LHS,
///< The left-hand-side of the expression 1198Value *
RHS,
///< The right-hand-side of the expression 1199constTwine &NameStr =
""///< Name of the instruction 1207 /// @returns the predicate along with samesign information. 1209return {getPredicate(), hasSameSign()};
1212 /// @returns the inverse predicate along with samesign information: static 1215return {getInversePredicate(Pred), Pred.
hasSameSign()};
1218 /// @returns the inverse predicate along with samesign information. 1220return getInverseCmpPredicate(getCmpPredicate());
1223 /// @returns the swapped predicate along with samesign information: static 1226return {getSwappedPredicate(Pred), Pred.
hasSameSign()};
1229 /// @returns the swapped predicate along with samesign information. 1231return getSwappedCmpPredicate(getCmpPredicate());
1234 /// For example, EQ->EQ, SLE->SLE, UGT->SGT, etc. 1235 /// @returns the predicate that would be the result if the operand were 1236 /// regarded as signed. 1237 /// Return the signed version of the predicate. 1239return getSignedPredicate(getPredicate());
1242 /// Return the signed version of the predicate: static variant. 1245 /// For example, EQ->EQ, SLE->ULE, UGT->UGT, etc. 1246 /// @returns the predicate that would be the result if the operand were 1247 /// regarded as unsigned. 1248 /// Return the unsigned version of the predicate. 1250return getUnsignedPredicate(getPredicate());
1253 /// Return the unsigned version of the predicate: static variant. 1256 /// For example, SLT->ULT, ULT->SLT, SLE->ULE, ULE->SLE, EQ->EQ 1257 /// @returns the unsigned version of the signed predicate pred or 1258 /// the signed version of the signed predicate pred. 1262 /// For example, SLT->ULT, ULT->SLT, SLE->ULE, ULE->SLE, EQ->EQ 1263 /// @returns the unsigned version of the signed predicate pred or 1264 /// the signed version of the signed predicate pred. 1266return getFlippedSignednessPredicate(getPredicate());
1269 /// Determine if Pred1 implies Pred2 is true, false, or if nothing can be 1270 /// inferred about the implication, when two compares have matching operands. 1271static std::optional<bool> isImpliedByMatchingCmp(
CmpPredicate Pred1,
1275 SubclassOptionalData = (SubclassOptionalData & ~SameSign) | (
B * SameSign);
1278 /// An icmp instruction, which can be marked as "samesign", indicating that 1279 /// the two operands have the same sign. This means that we can convert 1280 /// "slt" to "ult" and vice versa, which enables more optimizations. 1283 /// Return true if this predicate is either EQ or NE. This also 1284 /// tests for commutativity. 1286returnP == ICMP_EQ ||
P == ICMP_NE;
1289 /// Return true if this predicate is either EQ or NE. This also 1290 /// tests for commutativity. 1292return isEquality(getPredicate());
1295 /// @returns true if the predicate is commutative 1296 /// Determine if this relation is commutative. 1299 /// @returns true if the predicate of this ICmpInst is commutative 1300 /// Determine if this relation is commutative. 1303 /// Return true if the predicate is relational (not EQ or NE). 1306return !isEquality();
1309 /// Return true if the predicate is relational (not EQ or NE). 1312return !isEquality(
P);
1315 /// Return true if the predicate is SGT or UGT. 1318returnP == ICMP_SGT ||
P == ICMP_UGT;
1321 /// Return true if the predicate is SLT or ULT. 1324returnP == ICMP_SLT ||
P == ICMP_ULT;
1327 /// Return true if the predicate is SGE or UGE. 1330returnP == ICMP_SGE ||
P == ICMP_UGE;
1333 /// Return true if the predicate is SLE or ULE. 1336returnP == ICMP_SLE ||
P == ICMP_ULE;
1339 /// Returns the sequence of all ICmp predicates. 1343 /// Exchange the two operands to this instruction in such a way that it does 1344 /// not modify the semantics of the instruction. The predicate value may be 1345 /// changed to retain the same result if the predicate is order dependent 1347 /// Swap operands and adjust predicate. 1349 setPredicate(getSwappedPredicate());
1353 /// Return result of `LHS Pred RHS` comparison. 1357 /// Return result of `LHS Pred RHS`, if it can be determined from the 1358 /// KnownBits. Otherwise return nullopt. 1362// Methods for support type inquiry through isa, cast, and dyn_cast: 1364returnI->getOpcode() == Instruction::ICmp;
1367return isa<Instruction>(V) && classof(cast<Instruction>(V));
1371//===----------------------------------------------------------------------===// 1373//===----------------------------------------------------------------------===// 1375/// This instruction compares its operands according to the predicate given 1376/// to the constructor. It only operates on floating point values or packed 1377/// vectors of floating point values. The operands must be identical types. 1378/// Represents a floating point comparison operator. 1383"Both operands to FCmp instruction are not of the same type!");
1384// Check that the operands are the right type 1386"Invalid operand types for FCmp instruction");
1390// Note: Instruction needs to be a friend here to call cloneImpl. 1393 /// Clone an identical FCmpInst 1397 /// Constructor with insertion semantics. 1400Value *
LHS,
///< The left-hand-side of the expression 1401Value *
RHS,
///< The right-hand-side of the expression 1402constTwine &NameStr =
""///< Name of the instruction 1405RHS, NameStr, InsertBefore) {
1409 /// Constructor with no-insertion semantics 1411Value *
LHS,
///< The left-hand-side of the expression 1412Value *
RHS,
///< The right-hand-side of the expression 1413constTwine &NameStr =
"",
///< Name of the instruction 1416RHS, NameStr, nullptr, FlagsSource) {
1420 /// @returns true if the predicate is EQ or NE. 1421 /// Determine if this is an equality predicate. 1427 /// @returns true if the predicate of this instruction is EQ or NE. 1428 /// Determine if this is an equality predicate. 1431 /// @returns true if the predicate is commutative. 1432 /// Determine if this is a commutative predicate. 1438 /// @returns true if the predicate of this instruction is commutative. 1439 /// Determine if this is a commutative predicate. 1442 /// @returns true if the predicate is relational (not EQ or NE). 1443 /// Determine if this a relational predicate. 1446 /// Exchange the two operands to this instruction in such a way that it does 1447 /// not modify the semantics of the instruction. The predicate value may be 1448 /// changed to retain the same result if the predicate is order dependent 1450 /// Swap operands and adjust predicate. 1456 /// Returns the sequence of all FCmp predicates. 1460 /// Return result of `LHS Pred RHS` comparison. 1464 /// Methods for support type inquiry through isa, cast, and dyn_cast: 1466returnI->getOpcode() == Instruction::FCmp;
1469return isa<Instruction>(V) &&
classof(cast<Instruction>(V));
1473//===----------------------------------------------------------------------===// 1474/// This class represents a function call, abstracting a target 1475/// machine's calling convention. This class uses low bit of the SubClassData 1476/// field to indicate whether or not this is a tail call. The rest of the bits 1477/// hold the calling convention of the call. 1482 /// Construct a CallInst from a range of arguments 1499 /// Compute the number of operands to allocate. 1500staticunsigned ComputeNumOperands(
unsigned NumArgs,
1501unsigned NumBundleInputs = 0) {
1502// We need one operand for the called function, plus the input operand 1504return 1 + NumArgs + NumBundleInputs;
1508// Note: Instruction needs to be a friend here to call cloneImpl. 1517returnnew (AllocMarker)
1518CallInst(Ty,
F, NameStr, AllocMarker, InsertBefore);
1525returnnew (AllocMarker)
1526CallInst(Ty, Func, Args, {}, NameStr, AllocMarker, InsertBefore);
1531constTwine &NameStr =
"",
1533 IntrusiveOperandsAndDescriptorAllocMarker AllocMarker{
1537returnnew (AllocMarker)
1538 CallInst(Ty, Func, Args, Bundles, NameStr, AllocMarker, InsertBefore);
1543returnCreate(Func.getFunctionType(), Func.getCallee(), NameStr,
1549constTwine &NameStr =
"",
1551returnCreate(Func.getFunctionType(), Func.getCallee(), Args, Bundles,
1552 NameStr, InsertBefore);
1558returnCreate(Func.getFunctionType(), Func.getCallee(), Args, NameStr,
1562 /// Create a clone of \p CI with a different set of operand bundles and 1563 /// insert it before \p InsertBefore. 1565 /// The returned call instruction is identical \p CI in every way except that 1566 /// the operand bundles for the new instruction are set to the operand bundles 1571// Note that 'musttail' implies 'tail'. 1582 Bitfield::areContiguous<TailCallKindField, CallBase::CallingConvField>(),
1583"Bitfields must be contiguous");
1586return getSubclassData<TailCallKindField>();
1599 setSubclassData<TailCallKindField>(TCK);
1606 /// Return true if the call can return twice 1610 /// Return true if the call is for a noreturn trap intrinsic. 1613case Intrinsic::trap:
1614case Intrinsic::ubsantrap:
1621// Methods for support type inquiry through isa, cast, and dyn_cast: 1623returnI->getOpcode() == Instruction::Call;
1626return isa<Instruction>(V) &&
classof(cast<Instruction>(V));
1629 /// Updates profile metadata by scaling it by \p S / \p T. 1633// Shadow Instruction::setInstructionSubclassData with a private forwarding 1634// method so that subclasses cannot accidentally use it. 1635template <
typename Bitfield>
1636void setSubclassData(
typename Bitfield::Type
Value) {
1637 Instruction::setSubclassData<Bitfield>(
Value);
1641CallInst::CallInst(
FunctionType *Ty, Value *Func, ArrayRef<Value *> Args,
1642 ArrayRef<OperandBundleDef> Bundles,
const Twine &NameStr,
1643 AllocInfo AllocInfo, InsertPosition InsertBefore)
1644 : CallBase(Ty->getReturnType(), Instruction::
Call, AllocInfo,
1646assert(AllocInfo.NumOps ==
1648init(Ty, Func, Args, Bundles, NameStr);
1651//===----------------------------------------------------------------------===// 1653//===----------------------------------------------------------------------===// 1655/// This class represents the LLVM 'select' instruction. 1662 :
Instruction(
S1->getType(), Instruction::Select, AllocMarker,
1676// Note: Instruction needs to be a friend here to call cloneImpl. 1683constTwine &NameStr =
"",
1687new (AllocMarker)
SelectInst(
C,
S1, S2, NameStr, InsertBefore);
1704 /// Swap the true and false values of the select instruction. 1705 /// This doesn't swap prof metadata. 1708 /// Return a string if the specified operands are invalid 1709 /// for a select operation, otherwise return null. 1712 /// Transparently provide more efficient getOperand methods. 1719// Methods for support type inquiry through isa, cast, and dyn_cast: 1721returnI->getOpcode() == Instruction::Select;
1724return isa<Instruction>(V) &&
classof(cast<Instruction>(V));
1734//===----------------------------------------------------------------------===// 1736//===----------------------------------------------------------------------===// 1738/// This class represents the va_arg llvm instruction, which returns 1739/// an argument of the specified type given a va_list and increments that list 1743// Note: Instruction needs to be a friend here to call cloneImpl. 1759// Methods for support type inquiry through isa, cast, and dyn_cast: 1761returnI->getOpcode() == VAArg;
1764return isa<Instruction>(V) && classof(cast<Instruction>(V));
1768//===----------------------------------------------------------------------===// 1769// ExtractElementInst Class 1770//===----------------------------------------------------------------------===// 1772/// This instruction extracts a single (scalar) 1773/// element from a VectorType value 1782// Note: Instruction needs to be a friend here to call cloneImpl. 1789constTwine &NameStr =
"",
1791returnnew (AllocMarker)
1795 /// Return true if an extractelement instruction can be 1796 /// formed with the specified operands. 1808 /// Transparently provide more efficient getOperand methods. 1811// Methods for support type inquiry through isa, cast, and dyn_cast: 1813returnI->getOpcode() == Instruction::ExtractElement;
1816return isa<Instruction>(V) &&
classof(cast<Instruction>(V));
1827//===----------------------------------------------------------------------===// 1828// InsertElementInst Class 1829//===----------------------------------------------------------------------===// 1831/// This instruction inserts a single (scalar) 1832/// element into a VectorType value 1838constTwine &NameStr =
"",
1842// Note: Instruction needs to be a friend here to call cloneImpl. 1849constTwine &NameStr =
"",
1851returnnew (AllocMarker)
1855 /// Return true if an insertelement instruction can be 1856 /// formed with the specified operands. 1857staticbool isValidOperands(
constValue *Vec,
constValue *NewElt,
1860 /// Overload to return most specific vector type. 1866 /// Transparently provide more efficient getOperand methods. 1869// Methods for support type inquiry through isa, cast, and dyn_cast: 1871returnI->getOpcode() == Instruction::InsertElement;
1874return isa<Instruction>(V) && classof(cast<Instruction>(V));
1885//===----------------------------------------------------------------------===// 1886// ShuffleVectorInst Class 1887//===----------------------------------------------------------------------===// 1891/// This instruction constructs a fixed permutation of two 1894/// For each element of the result vector, the shuffle mask selects an element 1895/// from one of the input vectors to copy to the result. Non-negative elements 1896/// in the mask represent an index into the concatenated pair of input vectors. 1897/// PoisonMaskElem (-1) specifies that the result element is poison. 1899/// For scalable vectors, all the elements of the mask must be 0 or -1. This 1900/// requirement may be relaxed in the future. 1908// Note: Instruction needs to be a friend here to call cloneImpl. 1919constTwine &NameStr =
"",
1922constTwine &NameStr =
"",
1925void *
operatornew(
size_t S) {
return User::operator
new(S, AllocMarker); }
1926voidoperatordelete(
void *
Ptr) {
return User::operator
delete(
Ptr); }
1928 /// Swap the operands and adjust the mask to preserve the semantics 1929 /// of the instruction. 1932 /// Return true if a shufflevector instruction can be 1933 /// formed with the specified operands. 1934staticbool isValidOperands(
constValue *V1,
constValue *V2,
1936staticbool isValidOperands(
constValue *V1,
constValue *V2,
1939 /// Overload to return most specific vector type. 1945 /// Transparently provide more efficient getOperand methods. 1948 /// Return the shuffle mask value of this instruction for the given element 1949 /// index. Return PoisonMaskElem if the element is undef. 1952 /// Convert the input shuffle mask operand to a vector of integers. Undefined 1953 /// elements of the mask are returned as PoisonMaskElem. 1954staticvoid getShuffleMask(
constConstant *Mask,
1957 /// Return the mask for this instruction as a vector of integers. Undefined 1958 /// elements of the mask are returned as PoisonMaskElem. 1960 Result.assign(ShuffleMask.
begin(), ShuffleMask.
end());
1963 /// Return the mask for this instruction, for use in bitcode. 1965 /// TODO: This is temporary until we decide a new bitcode encoding for 1976 /// Return true if this shuffle returns a vector with a different number of 1977 /// elements than its source vectors. 1978 /// Examples: shufflevector <4 x n> A, <4 x n> B, <1,2,3> 1979 /// shufflevector <4 x n> A, <4 x n> B, <1,2,3,4,5> 1981unsigned NumSourceElts = cast<VectorType>(
Op<0>()->
getType())
1983 .getKnownMinValue();
1984unsigned NumMaskElts = ShuffleMask.
size();
1985return NumSourceElts != NumMaskElts;
1988 /// Return true if this shuffle returns a vector with a greater number of 1989 /// elements than its source vectors. 1990 /// Example: shufflevector <2 x n> A, <2 x n> B, <1,2,3> 1992unsigned NumSourceElts = cast<VectorType>(
Op<0>()->
getType())
1994 .getKnownMinValue();
1995unsigned NumMaskElts = ShuffleMask.
size();
1996return NumSourceElts < NumMaskElts;
1999 /// Return true if this shuffle mask chooses elements from exactly one source 2001 /// Example: <7,5,undef,7> 2002 /// This assumes that vector operands (of length \p NumSrcElts) are the same 2003 /// length as the mask. 2004staticbool isSingleSourceMask(
ArrayRef<int> Mask,
int NumSrcElts);
2006assert(Mask->getType()->isVectorTy() &&
"Shuffle needs vector constant.");
2008 getShuffleMask(Mask, MaskAsInts);
2009return isSingleSourceMask(MaskAsInts, NumSrcElts);
2012 /// Return true if this shuffle chooses elements from exactly one source 2013 /// vector without changing the length of that vector. 2014 /// Example: shufflevector <4 x n> A, <4 x n> B, <3,0,undef,3> 2015 /// TODO: Optionally allow length-changing shuffles. 2017return !changesLength() &&
2018 isSingleSourceMask(ShuffleMask, ShuffleMask.
size());
2021 /// Return true if this shuffle mask chooses elements from exactly one source 2022 /// vector without lane crossings. A shuffle using this mask is not 2023 /// necessarily a no-op because it may change the number of elements from its 2024 /// input vectors or it may provide demanded bits knowledge via undef lanes. 2025 /// Example: <undef,undef,2,3> 2026staticbool isIdentityMask(
ArrayRef<int> Mask,
int NumSrcElts);
2028assert(Mask->getType()->isVectorTy() &&
"Shuffle needs vector constant.");
2030// Not possible to express a shuffle mask for a scalable vector for this 2032if (isa<ScalableVectorType>(Mask->getType()))
2036 getShuffleMask(Mask, MaskAsInts);
2037return isIdentityMask(MaskAsInts, NumSrcElts);
2040 /// Return true if this shuffle chooses elements from exactly one source 2041 /// vector without lane crossings and does not change the number of elements 2042 /// from its input vectors. 2043 /// Example: shufflevector <4 x n> A, <4 x n> B, <4,undef,6,undef> 2045// Not possible to express a shuffle mask for a scalable vector for this 2047if (isa<ScalableVectorType>(
getType()))
2050return !changesLength() && isIdentityMask(ShuffleMask, ShuffleMask.
size());
2053 /// Return true if this shuffle lengthens exactly one source vector with 2054 /// undefs in the high elements. 2055bool isIdentityWithPadding()
const;
2057 /// Return true if this shuffle extracts the first N elements of exactly one 2059bool isIdentityWithExtract()
const;
2061 /// Return true if this shuffle concatenates its 2 source vectors. This 2062 /// returns false if either input is undefined. In that case, the shuffle is 2063 /// is better classified as an identity with padding operation. 2064bool isConcat()
const;
2066 /// Return true if this shuffle mask chooses elements from its source vectors 2067 /// without lane crossings. A shuffle using this mask would be 2068 /// equivalent to a vector select with a constant condition operand. 2069 /// Example: <4,1,6,undef> 2070 /// This returns false if the mask does not choose from both input vectors. 2071 /// In that case, the shuffle is better classified as an identity shuffle. 2072 /// This assumes that vector operands are the same length as the mask 2073 /// (a length-changing shuffle can never be equivalent to a vector select). 2076assert(Mask->getType()->isVectorTy() &&
"Shuffle needs vector constant.");
2078 getShuffleMask(Mask, MaskAsInts);
2079return isSelectMask(MaskAsInts, NumSrcElts);
2082 /// Return true if this shuffle chooses elements from its source vectors 2083 /// without lane crossings and all operands have the same number of elements. 2084 /// In other words, this shuffle is equivalent to a vector select with a 2085 /// constant condition operand. 2086 /// Example: shufflevector <4 x n> A, <4 x n> B, <undef,1,6,3> 2087 /// This returns false if the mask does not choose from both input vectors. 2088 /// In that case, the shuffle is better classified as an identity shuffle. 2089 /// TODO: Optionally allow length-changing shuffles. 2091return !changesLength() && isSelectMask(ShuffleMask, ShuffleMask.
size());
2094 /// Return true if this shuffle mask swaps the order of elements from exactly 2095 /// one source vector. 2096 /// Example: <7,6,undef,4> 2097 /// This assumes that vector operands (of length \p NumSrcElts) are the same 2098 /// length as the mask. 2101assert(Mask->getType()->isVectorTy() &&
"Shuffle needs vector constant.");
2103 getShuffleMask(Mask, MaskAsInts);
2107 /// Return true if this shuffle swaps the order of elements from exactly 2108 /// one source vector. 2109 /// Example: shufflevector <4 x n> A, <4 x n> B, <3,undef,1,undef> 2110 /// TODO: Optionally allow length-changing shuffles. 2115 /// Return true if this shuffle mask chooses all elements with the same value 2116 /// as the first element of exactly one source vector. 2117 /// Example: <4,undef,undef,4> 2118 /// This assumes that vector operands (of length \p NumSrcElts) are the same 2119 /// length as the mask. 2120staticbool isZeroEltSplatMask(
ArrayRef<int> Mask,
int NumSrcElts);
2122assert(Mask->getType()->isVectorTy() &&
"Shuffle needs vector constant.");
2124 getShuffleMask(Mask, MaskAsInts);
2125return isZeroEltSplatMask(MaskAsInts, NumSrcElts);
2128 /// Return true if all elements of this shuffle are the same value as the 2129 /// first element of exactly one source vector without changing the length 2131 /// Example: shufflevector <4 x n> A, <4 x n> B, <undef,0,undef,0> 2132 /// TODO: Optionally allow length-changing shuffles. 2133 /// TODO: Optionally allow splats from other elements. 2135return !changesLength() &&
2136 isZeroEltSplatMask(ShuffleMask, ShuffleMask.
size());
2139 /// Return true if this shuffle mask is a transpose mask. 2140 /// Transpose vector masks transpose a 2xn matrix. They read corresponding 2141 /// even- or odd-numbered vector elements from two n-dimensional source 2142 /// vectors and write each result into consecutive elements of an 2143 /// n-dimensional destination vector. Two shuffles are necessary to complete 2144 /// the transpose, one for the even elements and another for the odd elements. 2145 /// This description closely follows how the TRN1 and TRN2 AArch64 2146 /// instructions operate. 2148 /// For example, a simple 2x2 matrix can be transposed with: 2150 /// ; Original matrix 2154 /// ; Transposed matrix 2155 /// t0 = < a, c > = shufflevector m0, m1, < 0, 2 > 2156 /// t1 = < b, d > = shufflevector m0, m1, < 1, 3 > 2158 /// For matrices having greater than n columns, the resulting nx2 transposed 2159 /// matrix is stored in two result vectors such that one vector contains 2160 /// interleaved elements from all the even-numbered rows and the other vector 2161 /// contains interleaved elements from all the odd-numbered rows. For example, 2162 /// a 2x4 matrix can be transposed with: 2164 /// ; Original matrix 2165 /// m0 = < a, b, c, d > 2166 /// m1 = < e, f, g, h > 2168 /// ; Transposed matrix 2169 /// t0 = < a, e, c, g > = shufflevector m0, m1 < 0, 4, 2, 6 > 2170 /// t1 = < b, f, d, h > = shufflevector m0, m1 < 1, 5, 3, 7 > 2171staticbool isTransposeMask(
ArrayRef<int> Mask,
int NumSrcElts);
2173assert(Mask->getType()->isVectorTy() &&
"Shuffle needs vector constant.");
2175 getShuffleMask(Mask, MaskAsInts);
2176return isTransposeMask(MaskAsInts, NumSrcElts);
2179 /// Return true if this shuffle transposes the elements of its inputs without 2180 /// changing the length of the vectors. This operation may also be known as a 2181 /// merge or interleave. See the description for isTransposeMask() for the 2182 /// exact specification. 2183 /// Example: shufflevector <4 x n> A, <4 x n> B, <0,4,2,6> 2185return !changesLength() && isTransposeMask(ShuffleMask, ShuffleMask.
size());
2188 /// Return true if this shuffle mask is a splice mask, concatenating the two 2189 /// inputs together and then extracts an original width vector starting from 2190 /// the splice index. 2191 /// Example: shufflevector <4 x n> A, <4 x n> B, <1,2,3,4> 2192 /// This assumes that vector operands (of length \p NumSrcElts) are the same 2193 /// length as the mask. 2196assert(Mask->getType()->isVectorTy() &&
"Shuffle needs vector constant.");
2198 getShuffleMask(Mask, MaskAsInts);
2199return isSpliceMask(MaskAsInts, NumSrcElts,
Index);
2202 /// Return true if this shuffle splices two inputs without changing the length 2203 /// of the vectors. This operation concatenates the two inputs together and 2204 /// then extracts an original width vector starting from the splice index. 2205 /// Example: shufflevector <4 x n> A, <4 x n> B, <1,2,3,4> 2207return !changesLength() &&
2208 isSpliceMask(ShuffleMask, ShuffleMask.
size(),
Index);
2211 /// Return true if this shuffle mask is an extract subvector mask. 2212 /// A valid extract subvector mask returns a smaller vector from a single 2213 /// source operand. The base extraction index is returned as well. 2214staticbool isExtractSubvectorMask(
ArrayRef<int> Mask,
int NumSrcElts,
2218assert(Mask->getType()->isVectorTy() &&
"Shuffle needs vector constant.");
2219// Not possible to express a shuffle mask for a scalable vector for this 2221if (isa<ScalableVectorType>(Mask->getType()))
2224 getShuffleMask(Mask, MaskAsInts);
2225return isExtractSubvectorMask(MaskAsInts, NumSrcElts,
Index);
2228 /// Return true if this shuffle mask is an extract subvector mask. 2230// Not possible to express a shuffle mask for a scalable vector for this 2232if (isa<ScalableVectorType>(
getType()))
2236 cast<FixedVectorType>(
Op<0>()->
getType())->getNumElements();
2237return isExtractSubvectorMask(ShuffleMask, NumSrcElts,
Index);
2240 /// Return true if this shuffle mask is an insert subvector mask. 2241 /// A valid insert subvector mask inserts the lowest elements of a second 2242 /// source operand into an in-place first source operand. 2243 /// Both the sub vector width and the insertion index is returned. 2244staticbool isInsertSubvectorMask(
ArrayRef<int> Mask,
int NumSrcElts,
2245int &NumSubElts,
int &
Index);
2247int &NumSubElts,
int &
Index) {
2248assert(Mask->getType()->isVectorTy() &&
"Shuffle needs vector constant.");
2249// Not possible to express a shuffle mask for a scalable vector for this 2251if (isa<ScalableVectorType>(Mask->getType()))
2254 getShuffleMask(Mask, MaskAsInts);
2255return isInsertSubvectorMask(MaskAsInts, NumSrcElts, NumSubElts,
Index);
2258 /// Return true if this shuffle mask is an insert subvector mask. 2260// Not possible to express a shuffle mask for a scalable vector for this 2262if (isa<ScalableVectorType>(
getType()))
2266 cast<FixedVectorType>(
Op<0>()->
getType())->getNumElements();
2267return isInsertSubvectorMask(ShuffleMask, NumSrcElts, NumSubElts,
Index);
2270 /// Return true if this shuffle mask replicates each of the \p VF elements 2271 /// in a vector \p ReplicationFactor times. 2272 /// For example, the mask for \p ReplicationFactor=3 and \p VF=4 is: 2273 /// <0,0,0,1,1,1,2,2,2,3,3,3> 2274staticbool isReplicationMask(
ArrayRef<int> Mask,
int &ReplicationFactor,
2278assert(Mask->getType()->isVectorTy() &&
"Shuffle needs vector constant.");
2279// Not possible to express a shuffle mask for a scalable vector for this 2281if (isa<ScalableVectorType>(Mask->getType()))
2284 getShuffleMask(Mask, MaskAsInts);
2285return isReplicationMask(MaskAsInts, ReplicationFactor, VF);
2288 /// Return true if this shuffle mask is a replication mask. 2289bool isReplicationMask(
int &ReplicationFactor,
int &VF)
const;
2291 /// Return true if this shuffle mask represents "clustered" mask of size VF, 2292 /// i.e. each index between [0..VF) is used exactly once in each submask of 2294 /// For example, the mask for \p VF=4 is: 2295 /// 0, 1, 2, 3, 3, 2, 0, 1 - "clustered", because each submask of size 4 2296 /// (0,1,2,3 and 3,2,0,1) uses indices [0..VF) exactly one time. 2297 /// 0, 1, 2, 3, 3, 3, 1, 0 - not "clustered", because 2298 /// element 3 is used twice in the second submask 2299 /// (3,3,1,0) and index 2 is not used at all. 2300staticbool isOneUseSingleSourceMask(
ArrayRef<int> Mask,
int VF);
2302 /// Return true if this shuffle mask is a one-use-single-source("clustered") 2304bool isOneUseSingleSourceMask(
int VF)
const;
2306 /// Change values in a shuffle permute mask assuming the two vector operands 2307 /// of length InVecNumElts have swapped position. 2309unsigned InVecNumElts) {
2310for (
int &
Idx : Mask) {
2313Idx =
Idx < (int)InVecNumElts ?
Idx + InVecNumElts :
Idx - InVecNumElts;
2315"shufflevector mask index out of range");
2319 /// Return if this shuffle interleaves its two input vectors together. 2320bool isInterleave(
unsigned Factor);
2322 /// Return true if the mask interleaves one or more input vectors together. 2324 /// I.e. <0, LaneLen, ... , LaneLen*(Factor - 1), 1, LaneLen + 1, ...> 2325 /// E.g. For a Factor of 2 (LaneLen=4): 2326 /// <0, 4, 1, 5, 2, 6, 3, 7> 2327 /// E.g. For a Factor of 3 (LaneLen=4): 2328 /// <4, 0, 9, 5, 1, 10, 6, 2, 11, 7, 3, 12> 2329 /// E.g. For a Factor of 4 (LaneLen=2): 2330 /// <0, 2, 6, 4, 1, 3, 7, 5> 2332 /// NumInputElts is the total number of elements in the input vectors. 2334 /// StartIndexes are the first indexes of each vector being interleaved, 2335 /// substituting any indexes that were undef 2336 /// E.g. <4, -1, 2, 5, 1, 3> (Factor=3): StartIndexes=<4, 0, 2> 2338 /// Note that this does not check if the input vectors are consecutive: 2339 /// It will return true for masks such as 2340 /// <0, 4, 6, 1, 5, 7> (Factor=3, LaneLen=2) 2341staticbool isInterleaveMask(
ArrayRef<int> Mask,
unsigned Factor,
2342unsigned NumInputElts,
2345unsigned NumInputElts) {
2347return isInterleaveMask(Mask, Factor, NumInputElts, StartIndexes);
2350 /// Check if the mask is a DE-interleave mask of the given factor 2352 /// <Index, Index+Factor, ..., Index+(NumElts-1)*Factor> 2353staticbool isDeInterleaveMaskOfFactor(
ArrayRef<int> Mask,
unsigned Factor,
2357return isDeInterleaveMaskOfFactor(Mask, Factor, Unused);
2360 /// Checks if the shuffle is a bit rotation of the first operand across 2361 /// multiple subelements, e.g: 2363 /// shuffle <8 x i8> %a, <8 x i8> poison, <8 x i32> <1, 0, 3, 2, 5, 4, 7, 6> 2365 /// could be expressed as 2367 /// rotl <4 x i16> %a, 8 2369 /// If it can be expressed as a rotation, returns the number of subelements to 2370 /// group by in NumSubElts and the number of bits to rotate left in RotateAmt. 2371staticbool isBitRotateMask(
ArrayRef<int> Mask,
unsigned EltSizeInBits,
2372unsigned MinSubElts,
unsigned MaxSubElts,
2373unsigned &NumSubElts,
unsigned &RotateAmt);
2375// Methods for support type inquiry through isa, cast, and dyn_cast: 2377returnI->getOpcode() == Instruction::ShuffleVector;
2380return isa<Instruction>(V) && classof(cast<Instruction>(V));
2390//===----------------------------------------------------------------------===// 2391// ExtractValueInst Class 2392//===----------------------------------------------------------------------===// 2394/// This instruction extracts a struct member or array 2395/// element value from an aggregate value. 2402 /// Constructors - Create a extractvalue instruction with a base aggregate 2403 /// value and a list of indices. The first and second ctor can optionally 2404 /// insert before an existing instruction, the third appends the new 2405 /// instruction to the specified BasicBlock. 2412// Note: Instruction needs to be a friend here to call cloneImpl. 2419constTwine &NameStr =
"",
2425 /// Returns the type of the element that would be extracted 2426 /// with an extractvalue instruction with the specified parameters. 2428 /// Null is returned if the indices are invalid for the specified type. 2440return getOperand(0);
2443return getOperand(0);
2446return 0U;
// get index for modifying correct operand 2454return (
unsigned)Indices.
size();
2461// Methods for support type inquiry through isa, cast, and dyn_cast: 2463returnI->getOpcode() == Instruction::ExtractValue;
2466return isa<Instruction>(V) && classof(cast<Instruction>(V));
2470ExtractValueInst::ExtractValueInst(Value *Agg, ArrayRef<unsigned> Idxs,
2471const Twine &NameStr,
2472 InsertPosition InsertBefore)
2474 ExtractValue, Agg, InsertBefore) {
2475 init(Idxs, NameStr);
2478//===----------------------------------------------------------------------===// 2479// InsertValueInst Class 2480//===----------------------------------------------------------------------===// 2482/// This instruction inserts a struct field of array element 2483/// value into an aggregate value. 2492 /// Constructors - Create a insertvalue instruction with a base aggregate 2493 /// value, a value to insert, and a list of indices. The first and second ctor 2494 /// can optionally insert before an existing instruction, the third appends 2495 /// the new instruction to the specified BasicBlock. 2499 /// Constructors - These three constructors are convenience methods because 2500 /// one and two index insertvalue instructions are so common. 2502constTwine &NameStr =
"",
2506constTwine &NameStr);
2509// Note: Instruction needs to be a friend here to call cloneImpl. 2515// allocate space for exactly two operands 2516void *
operatornew(
size_t S) {
return User::operator
new(S, AllocMarker); }
2517voidoperatordelete(
void *
Ptr) { User::operator
delete(
Ptr); }
2521constTwine &NameStr =
"",
2526 /// Transparently provide more efficient getOperand methods. 2544return 0U;
// get index for modifying correct operand 2554return 1U;
// get index for modifying correct operand 2562return (
unsigned)Indices.
size();
2569// Methods for support type inquiry through isa, cast, and dyn_cast: 2571returnI->getOpcode() == Instruction::InsertValue;
2574return isa<Instruction>(V) &&
classof(cast<Instruction>(V));
2583InsertValueInst::InsertValueInst(
Value *Agg,
Value *Val,
2587 init(Agg, Val, Idxs, NameStr);
2592//===----------------------------------------------------------------------===// 2594//===----------------------------------------------------------------------===// 2596// PHINode - The PHINode class is used to represent the magical mystical PHI 2597// node, that can not exist in nature, but can be synthesized in a computer 2598// scientist's overactive imagination. 2603 /// The number of operands actually allocated. NumOperands is 2604 /// the number actually in use. 2605unsigned ReservedSpace;
2609explicitPHINode(
Type *Ty,
unsigned NumReservedValues,
2610constTwine &NameStr =
"",
2612 :
Instruction(Ty, Instruction::PHI, AllocMarker, InsertBefore),
2613 ReservedSpace(NumReservedValues) {
2616 allocHungoffUses(ReservedSpace);
2620// Note: Instruction needs to be a friend here to call cloneImpl. 2625// allocHungoffUses - this is more complicated than the generic 2626// User::allocHungoffUses, because we have to allocate Uses for the incoming 2627// values and pointers to the incoming blocks, all in one allocation. 2633 /// Constructors - NumReservedValues is a hint for the number of incoming 2634 /// edges that this phi node will have (use 0 if you really have no idea). 2636constTwine &NameStr =
"",
2638returnnew (AllocMarker)
2639PHINode(Ty, NumReservedValues, NameStr, InsertBefore);
2642 /// Provide fast operand accessors 2645// Block iterator interface. This provides access to the list of incoming 2646// basic blocks, which parallels the list of incoming values. 2647// Please note that we are not providing non-const iterators for blocks to 2648// force all updates go through an interface function. 2658return block_begin() + getNumOperands();
2669 /// Return the number of incoming edges 2673 /// Return incoming value number x 2676return getOperand(i);
2679assert(V &&
"PHI node got a null value!");
2681"All operands to PHI node must be the same type as the PHI node!");
2693 /// Return incoming basic block number @p i. 2696return block_begin()[i];
2699 /// Return incoming basic block corresponding 2700 /// to an operand of the PHI. 2703assert(
this == U.getUser() &&
"Iterator doesn't point to PHI's Uses?");
2704return getIncomingBlock(
unsigned(&U - op_begin()));
2707 /// Return incoming basic block corresponding 2708 /// to value use iterator. 2711return getIncomingBlock(
I.getUse());
2718 /// Copies the basic blocks from \p BBRange to the incoming basic block list 2719 /// of this PHINode, starting at \p ToIdx. 2725 /// Replace every incoming basic block \p Old to basic block \p New. 2727assert(New && Old &&
"PHI node got a null basic block!");
2728for (
unsignedOp = 0, NumOps = getNumOperands();
Op != NumOps; ++
Op)
2729if (getIncomingBlock(
Op) == Old)
2730 setIncomingBlock(
Op, New);
2733 /// Add an incoming value to the end of the PHI list 2736if (getNumOperands() == ReservedSpace)
2737 growOperands();
// Get more space! 2738// Initialize some new operands. 2739 setNumHungOffUseOperands(getNumOperands() + 1);
2740 setIncomingValue(getNumOperands() - 1, V);
2741 setIncomingBlock(getNumOperands() - 1, BB);
2744 /// Remove an incoming value. This is useful if a 2745 /// predecessor basic block is deleted. The value removed is returned. 2747 /// If the last incoming value for a PHI node is removed (and DeletePHIIfEmpty 2748 /// is true), the PHI node is destroyed and any uses of it are replaced with 2749 /// dummy values. The only time there should be zero incoming values to a PHI 2750 /// node is when the block is dead, so this strategy is sound. 2752Value *removeIncomingValue(
unsignedIdx,
bool DeletePHIIfEmpty =
true);
2755intIdx = getBasicBlockIndex(BB);
2756assert(
Idx >= 0 &&
"Invalid basic block argument to remove!");
2757return removeIncomingValue(
Idx, DeletePHIIfEmpty);
2760 /// Remove all incoming values for which the predicate returns true. 2761 /// The predicate accepts the incoming value index. 2763bool DeletePHIIfEmpty =
true);
2765 /// Return the first index of the specified basic 2766 /// block in the value list for this PHI. Returns -1 if no instance. 2769for (
unsigned i = 0, e = getNumOperands(); i != e; ++i)
2770if (block_begin()[i] == BB)
2776intIdx = getBasicBlockIndex(BB);
2777assert(
Idx >= 0 &&
"Invalid basic block argument!");
2778return getIncomingValue(
Idx);
2781 /// Set every incoming value(s) for block \p BB to \p V. 2783assert(BB &&
"PHI node got a null basic block!");
2785for (
unsignedOp = 0, NumOps = getNumOperands();
Op != NumOps; ++
Op)
2786if (getIncomingBlock(
Op) == BB) {
2788 setIncomingValue(
Op, V);
2791assert(Found &&
"Invalid basic block argument to set!");
2794 /// If the specified PHI node always merges together the 2795 /// same value, return the value, otherwise return null. 2796Value *hasConstantValue()
const;
2798 /// Whether the specified PHI node always merges 2799 /// together the same value, assuming undefs are equal to a unique 2800 /// non-undef value. 2801bool hasConstantOrUndefValue()
const;
2803 /// If the PHI node is complete which means all of its parent's predecessors 2804 /// have incoming value in this PHI, return true, otherwise return false. 2808return getBasicBlockIndex(Pred) >= 0;
2812 /// Methods for support type inquiry through isa, cast, and dyn_cast: 2814returnI->getOpcode() == Instruction::PHI;
2817return isa<Instruction>(V) && classof(cast<Instruction>(V));
2828//===----------------------------------------------------------------------===// 2829// LandingPadInst Class 2830//===----------------------------------------------------------------------===// 2832//===--------------------------------------------------------------------------- 2833/// The landingpad instruction holds all of the information 2834/// necessary to generate correct exception handling. The landingpad instruction 2835/// cannot be moved from the top of a landing pad block, which itself is 2836/// accessible only from the 'unwind' edge of an invoke. This uses the 2837/// SubclassData field in Value to store whether or not the landingpad is a 2845 /// The number of operands actually allocated. NumOperands is 2846 /// the number actually in use. 2847unsigned ReservedSpace;
2858// Allocate space for exactly zero operands. 2859void *
operatornew(
size_t S) {
return User::operator
new(S, AllocMarker); }
2861void growOperands(
unsignedSize);
2862void init(
unsigned NumReservedValues,
const Twine &NameStr);
2865// Note: Instruction needs to be a friend here to call cloneImpl. 2871voidoperatordelete(
void *
Ptr) { User::operator
delete(
Ptr); }
2873 /// Constructors - NumReservedClauses is a hint for the number of incoming 2874 /// clauses that this landingpad will have (use 0 if you really have no idea). 2876constTwine &NameStr =
"",
2879 /// Provide fast operand accessors 2882 /// Return 'true' if this landingpad instruction is a 2883 /// cleanup. I.e., it should be run when unwinding even if its landing pad 2884 /// doesn't catch the exception. 2885boolisCleanup()
const{
return getSubclassData<CleanupField>(); }
2887 /// Indicate that this landingpad instruction is a cleanup. 2890 /// Add a catch or filter clause to the landing pad. 2893 /// Get the value of the clause at index Idx. Use isCatch/isFilter to 2894 /// determine what type of clause this is. 2896return cast<Constant>(getOperandList()[
Idx]);
2899 /// Return 'true' if the clause and index Idx is a catch clause. 2901return !isa<ArrayType>(getOperandList()[
Idx]->
getType());
2904 /// Return 'true' if the clause and index Idx is a filter clause. 2906return isa<ArrayType>(getOperandList()[
Idx]->
getType());
2909 /// Get the number of clauses for this landing pad. 2912 /// Grow the size of the operand list to accommodate the new 2913 /// number of clauses. 2916// Methods for support type inquiry through isa, cast, and dyn_cast: 2918returnI->getOpcode() == Instruction::LandingPad;
2921return isa<Instruction>(V) && classof(cast<Instruction>(V));
2930//===----------------------------------------------------------------------===// 2932//===----------------------------------------------------------------------===// 2934//===--------------------------------------------------------------------------- 2935/// Return a value (possibly void), from a function. Execution 2936/// does not continue in this function any longer. 2942// ReturnInst constructors: 2943// ReturnInst() - 'ret void' instruction 2944// ReturnInst( null) - 'ret void' instruction 2945// ReturnInst(Value* X) - 'ret X' instruction 2946// ReturnInst(null, Iterator It) - 'ret void' instruction, insert before I 2947// ReturnInst(Value* X, Iterator It) - 'ret X' instruction, insert before I 2948// ReturnInst( null, Inst *I) - 'ret void' instruction, insert before I 2949// ReturnInst(Value* X, Inst *I) - 'ret X' instruction, insert before I 2950// ReturnInst( null, BB *B) - 'ret void' instruction, insert @ end of B 2951// ReturnInst(Value* X, BB *B) - 'ret X' instruction, insert @ end of B 2953// NOTE: If the Value* passed is of type void then the constructor behaves as 2954// if it was passed NULL. 2959// Note: Instruction needs to be a friend here to call cloneImpl. 2968returnnew (AllocMarker)
ReturnInst(
C, retVal, AllocMarker, InsertBefore);
2973returnnew (AllocMarker)
ReturnInst(
C,
nullptr, AllocMarker, InsertAtEnd);
2976 /// Provide fast operand accessors 2979 /// Convenience accessor. Returns null if there is no return value. 2981return getNumOperands() != 0 ? getOperand(0) :
nullptr;
2986// Methods for support type inquiry through isa, cast, and dyn_cast: 2988return (
I->getOpcode() == Instruction::Ret);
2991return isa<Instruction>(V) && classof(cast<Instruction>(V));
2999void setSuccessor(
unsigned idx, BasicBlock *
B) {
3009//===----------------------------------------------------------------------===// 3011//===----------------------------------------------------------------------===// 3013//===--------------------------------------------------------------------------- 3014/// Conditional or Unconditional Branch instruction. 3017 /// Ops list - Branches are strange. The operands are ordered: 3018 /// [Cond, FalseDest,] TrueDest. This makes some accessors faster because 3019 /// they don't have to check for cond/uncond branchness. These are mostly 3020 /// accessed relative from op_end(). 3022// BranchInst constructors (where {B, T, F} are blocks, and C is a condition): 3023// BranchInst(BB *B) - 'br B' 3024// BranchInst(BB* T, BB *F, Value *C) - 'br C, T, F' 3025// BranchInst(BB* B, Iter It) - 'br B' insert before I 3026// BranchInst(BB* T, BB *F, Value *C, Iter It) - 'br C, T, F', insert before I 3027// BranchInst(BB* B, Inst *I) - 'br B' insert before I 3028// BranchInst(BB* T, BB *F, Value *C, Inst *I) - 'br C, T, F', insert before I 3029// BranchInst(BB* B, BB *I) - 'br B' insert at end 3030// BranchInst(BB* T, BB *F, Value *C, BB *I) - 'br C, T, F', insert at end 3039// Note: Instruction needs to be a friend here to call cloneImpl. 3045 /// Iterator type that casts an operand to a basic block. 3047 /// This only makes sense because the successors are stored as adjacent 3048 /// operands for branch instructions. 3051 std::random_access_iterator_tag, BasicBlock *,
3052 ptrdiff_t, BasicBlock *, BasicBlock *> {
3059 /// The const version of `succ_op_iterator`. 3062 std::random_access_iterator_tag,
3063 const BasicBlock *, ptrdiff_t, const BasicBlock *,
3064 const BasicBlock *> {
3075returnnew (AllocMarker)
BranchInst(IfTrue, AllocMarker, InsertBefore);
3082returnnew (AllocMarker)
3086 /// Transparently provide more efficient getOperand methods. 3093assert(isConditional() &&
"Cannot get condition of an uncond branch!");
3098assert(isConditional() &&
"Cannot set condition of unconditional branch!");
3105assert(i < getNumSuccessors() &&
"Successor # out of range for Branch!");
3106return cast_or_null<BasicBlock>((&
Op<-1>() - i)->
get());
3110assert(idx < getNumSuccessors() &&
"Successor # out of range for Branch!");
3111 *(&
Op<-1>() - idx) = NewSucc;
3114 /// Swap the successors of this branch instruction. 3116 /// Swaps the successors of the branch instruction. This also swaps any 3117 /// branch weight metadata associated with the instruction so that it 3118 /// continues to map correctly to each operand. 3119void swapSuccessors();
3129 std::next(value_op_begin(), isConditional() ? 1 : 0)),
3133// Methods for support type inquiry through isa, cast, and dyn_cast: 3135return (
I->getOpcode() == Instruction::Br);
3138return isa<Instruction>(V) && classof(cast<Instruction>(V));
3147//===----------------------------------------------------------------------===// 3149//===----------------------------------------------------------------------===// 3151//===--------------------------------------------------------------------------- 3157unsigned ReservedSpace;
3159// Operand[0] = Value to switch on 3160// Operand[1] = Default basic block destination 3161// Operand[2n ] = Value to match 3162// Operand[2n+1] = BasicBlock to go to on match 3165 /// Create a new switch instruction, specifying a value to switch on and a 3166 /// default destination. The number of additional cases can be specified here 3167 /// to make memory allocation more efficient. This constructor can also 3168 /// auto-insert before another instruction. 3172// allocate space for exactly zero operands 3173void *
operatornew(
size_t S) {
return User::operator
new(S, AllocMarker); }
3179// Note: Instruction needs to be a friend here to call cloneImpl. 3185voidoperatordelete(
void *
Ptr) { User::operator
delete(
Ptr); }
3188staticconstunsigned DefaultPseudoIndex =
static_cast<unsigned>(~0L-1);
3192 /// A handle to a particular switch case. It exposes a convenient interface 3193 /// to both the case value and the successor block. 3195 /// We define this as a template and instantiate it to form both a const and 3196 /// non-const handle. 3197template <
typename SwitchInstT,
typename ConstantIntT,
typename BasicBlockT>
3199// Directly befriend both const and non-const iterators. 3204// Expose the switch type we're parameterized with to the iterator. 3214 /// Resolves case value for current case. 3216assert((
unsigned)Index < SI->getNumCases() &&
3217"Index out the number of cases.");
3218returnreinterpret_cast<ConstantIntT *
>(
SI->getOperand(2 +
Index * 2));
3221 /// Resolves successor for current case. 3223assert(((
unsigned)Index < SI->getNumCases() ||
3224 (
unsigned)
Index == DefaultPseudoIndex) &&
3225"Index out the number of cases.");
3226returnSI->getSuccessor(getSuccessorIndex());
3229 /// Returns number of current case. 3232 /// Returns successor index for current case successor. 3235 (
unsigned)Index < SI->getNumCases()) &&
3236"Index out the number of cases.");
3237return (
unsigned)
Index != DefaultPseudoIndex ?
Index + 1 : 0;
3256 /// Sets the new value for current case. 3258assert((
unsigned)Index < SI->getNumCases() &&
3259"Index out the number of cases.");
3263 /// Sets the new successor for current case. 3265SI->setSuccessor(getSuccessorIndex(), S);
3269template <
typename CaseHandleT>
3272 std::random_access_iterator_tag,
3273 const CaseHandleT> {
3274usingSwitchInstT =
typename CaseHandleT::SwitchInstType;
3279 /// Default constructed iterator is in an invalid state until assigned to 3280 /// a case for a particular switch. 3283 /// Initializes case iterator for given SwitchInst and for given 3287 /// Initializes case iterator for given SwitchInst and for given 3288 /// successor index. 3290unsigned SuccessorIndex) {
3291assert(SuccessorIndex < SI->getNumSuccessors() &&
3292"Successor index # out of range!");
3297 /// Support converting to the const variant. This will be a no-op for const 3304// Check index correctness after addition. 3305// Note: Index == getNumCases() means end(). 3307 (
unsigned)(Case.Index +
N) <= Case.SI->getNumCases() &&
3308"Case.Index out the number of cases.");
3313// Check index correctness after subtraction. 3314// Note: Case.Index == getNumCases() means end(). 3316 (
unsigned)(Case.Index -
N) <= Case.SI->getNumCases() &&
3317"Case.Index out the number of cases.");
3322assert(Case.SI ==
RHS.Case.SI &&
"Incompatible operators.");
3323return Case.Index -
RHS.Case.Index;
3326return Case ==
RHS.Case;
3329assert(Case.SI ==
RHS.Case.SI &&
"Incompatible operators.");
3330return Case.Index <
RHS.Case.Index;
3344 /// Provide fast operand accessors 3347// Accessor Methods for Switch stmt 3352return cast<BasicBlock>(getOperand(1));
3355 /// Returns true if the default branch must result in immediate undefined 3356 /// behavior, false otherwise. 3358return isa<UnreachableInst>(getDefaultDest()->getFirstNonPHIOrDbg());
3362 setOperand(1,
reinterpret_cast<Value*
>(DefaultCase));
3365 /// Return the number of 'cases' in this switch instruction, excluding the 3368return getNumOperands()/2 - 1;
3371 /// Returns a read/write iterator that points to the first case in the 3377 /// Returns a read-only iterator that points to the first case in the 3383 /// Returns a read/write iterator that points one past the last in the 3386returnCaseIt(
this, getNumCases());
3389 /// Returns a read-only iterator that points one past the last in the 3395 /// Iteration adapter for range-for loops. 3400 /// Constant iteration adapter for range-for loops. 3405 /// Returns an iterator that points to the default case. 3406 /// Note: this iterator allows to resolve successor only. Attempt 3407 /// to resolve case value causes an assertion. 3408 /// Also note, that increment and decrement also causes an assertion and 3409 /// makes iterator invalid. 3411returnCaseIt(
this, DefaultPseudoIndex);
3417 /// Search all of the case values for the specified constant. If it is 3418 /// explicitly handled, return the case iterator of it, otherwise return 3419 /// default case iterator to indicate that it is handled by the default 3424const_cast<constSwitchInst *
>(
this)->findCaseValue(
C)->getCaseIndex());
3433return case_default();
3436 /// Finds the unique case value for a given successor. Returns null if the 3437 /// successor is not found, not unique, or is the default case. 3439if (BB == getDefaultDest())
3443for (
auto Case : cases()) {
3444if (Case.getCaseSuccessor() != BB)
3448returnnullptr;
// Multiple cases lead to BB. 3450 CI = Case.getCaseValue();
3456 /// Add an entry to the switch instruction. 3458 /// This action invalidates case_end(). Old case_end() iterator will 3459 /// point to the added case. 3462 /// This method removes the specified case and its successor from the switch 3463 /// instruction. Note that this operation may reorder the remaining cases at 3464 /// index idx and above. 3466 /// This action invalidates iterators for all cases following the one removed, 3467 /// including the case_end() iterator. It returns an iterator for the next 3469 CaseIt removeCase(CaseIt
I);
3473assert(idx < getNumSuccessors() &&
"Successor idx out of range for switch!");
3474return cast<BasicBlock>(getOperand(idx*2+1));
3477assert(idx < getNumSuccessors() &&
"Successor # out of range for switch!");
3478 setOperand(idx * 2 + 1, NewSucc);
3481// Methods for support type inquiry through isa, cast, and dyn_cast: 3483returnI->getOpcode() == Instruction::Switch;
3486return isa<Instruction>(V) && classof(cast<Instruction>(V));
3490/// A wrapper class to simplify modification of SwitchInst cases along with 3491/// their prof branch_weights metadata. 3494 std::optional<SmallVector<uint32_t, 8>> Weights;
3515 /// Delegate the call to the underlying SwitchInst::removeCase() and remove 3516 /// correspondent branch weight. 3519 /// Delegate the call to the underlying SwitchInst::addCase() and set the 3520 /// specified branch weight for the added case. 3523 /// Delegate the call to the underlying SwitchInst::eraseFromParent() and mark 3524 /// this object to not touch the underlying SwitchInst in destructor. 3537//===----------------------------------------------------------------------===// 3538// IndirectBrInst Class 3539//===----------------------------------------------------------------------===// 3541//===--------------------------------------------------------------------------- 3542/// Indirect Branch Instruction. 3547unsigned ReservedSpace;
3549// Operand[0] = Address to jump to 3550// Operand[n+1] = n-th destination 3553 /// Create a new indirectbr instruction, specifying an 3554 /// Address to jump to. The number of expected destinations can be specified 3555 /// here to make memory allocation more efficient. This constructor can also 3556 /// autoinsert before another instruction. 3560// allocate space for exactly zero operands 3561void *
operatornew(
size_t S) {
return User::operator
new(S, AllocMarker); }
3567// Note: Instruction needs to be a friend here to call cloneImpl. 3573voidoperatordelete(
void *
Ptr) { User::operator
delete(
Ptr); }
3575 /// Iterator type that casts an operand to a basic block. 3577 /// This only makes sense because the successors are stored as adjacent 3578 /// operands for indirectbr instructions. 3581 std::random_access_iterator_tag, BasicBlock *,
3582 ptrdiff_t, BasicBlock *, BasicBlock *> {
3589 /// The const version of `succ_op_iterator`. 3592 std::random_access_iterator_tag,
3593 const BasicBlock *, ptrdiff_t, const BasicBlock *,
3594 const BasicBlock *> {
3607 /// Provide fast operand accessors. 3610// Accessor Methods for IndirectBrInst instruction. 3615 /// return the number of possible destinations in this 3616 /// indirectbr instruction. 3619 /// Return the specified destination. 3623 /// Add a destination. 3627 /// This method removes the specified successor from the 3628 /// indirectbr instruction. 3629void removeDestination(
unsigned i);
3633return cast<BasicBlock>(getOperand(i+1));
3636 setOperand(i + 1, NewSucc);
3649// Methods for support type inquiry through isa, cast, and dyn_cast: 3651returnI->getOpcode() == Instruction::IndirectBr;
3654return isa<Instruction>(V) && classof(cast<Instruction>(V));
3663//===----------------------------------------------------------------------===// 3665//===----------------------------------------------------------------------===// 3667/// Invoke instruction. The SubclassData field is used to hold the 3668/// calling convention of the call. 3671 /// The number of operands for this call beyond the called function, 3672 /// arguments, and operand bundles. 3673staticconstexprint NumExtraOperands = 2;
3675 /// The index from the end of the operand array to the normal destination. 3676staticconstexprint NormalDestOpEndIdx = -3;
3678 /// The index from the end of the operand array to the unwind destination. 3679staticconstexprint UnwindDestOpEndIdx = -2;
3683 /// Construct an InvokeInst given a range of arguments. 3685 /// Construct an InvokeInst from a range of arguments 3695 /// Compute the number of operands to allocate. 3696staticunsigned ComputeNumOperands(
unsigned NumArgs,
3697size_t NumBundleInputs = 0) {
3698// We need one operand for the called function, plus our extra operands and 3699// the input operand counts provided. 3700return 1 + NumExtraOperands + NumArgs +
unsigned(NumBundleInputs);
3704// Note: Instruction needs to be a friend here to call cloneImpl. 3715 ComputeNumOperands(
unsigned(Args.size()))};
3716returnnew (AllocMarker)
InvokeInst(Ty, Func, IfNormal, IfException, Args,
3717 {}, AllocMarker, NameStr, InsertBefore);
3723constTwine &NameStr =
"",
3725 IntrusiveOperandsAndDescriptorAllocMarker AllocMarker{
3726 ComputeNumOperands(Args.size(), CountBundleInputs(Bundles)),
3729returnnew (AllocMarker)
3730 InvokeInst(Ty, Func, IfNormal, IfException, Args, Bundles, AllocMarker,
3731 NameStr, InsertBefore);
3738return Create(Func.getFunctionType(), Func.getCallee(), IfNormal,
3739 IfException, Args, {}, NameStr, InsertBefore);
3745constTwine &NameStr =
"",
3747return Create(Func.getFunctionType(), Func.getCallee(), IfNormal,
3748 IfException, Args, Bundles, NameStr, InsertBefore);
3751 /// Create a clone of \p II with a different set of operand bundles and 3752 /// insert it before \p InsertBefore. 3754 /// The returned invoke instruction is identical to \p II in every way except 3755 /// that the operand bundles for the new instruction are set to the operand 3756 /// bundles in \p Bundles. 3757static InvokeInst *Create(InvokeInst *
II, ArrayRef<OperandBundleDef> Bundles,
3758 InsertPosition InsertPt =
nullptr);
3760// get*Dest - Return the destination basic blocks... 3774 /// Get the landingpad instruction from the landing pad 3775 /// block (the unwind destination). 3779assert(i < 2 &&
"Successor # out of range for invoke!");
3780return i == 0 ? getNormalDest() : getUnwindDest();
3784assert(i < 2 &&
"Successor # out of range for invoke!");
3786 setNormalDest(NewSucc);
3788 setUnwindDest(NewSucc);
3793 /// Updates profile metadata by scaling it by \p S / \p T. 3796// Methods for support type inquiry through isa, cast, and dyn_cast: 3798return (
I->getOpcode() == Instruction::Invoke);
3801return isa<Instruction>(V) && classof(cast<Instruction>(V));
3805// Shadow Instruction::setInstructionSubclassData with a private forwarding 3806// method so that subclasses cannot accidentally use it. 3807template <
typename Bitfield>
3808void setSubclassData(
typename Bitfield::Type
Value) {
3809 Instruction::setSubclassData<Bitfield>(
Value);
3813InvokeInst::InvokeInst(
FunctionType *Ty, Value *Func, BasicBlock *IfNormal,
3814 BasicBlock *IfException, ArrayRef<Value *> Args,
3815 ArrayRef<OperandBundleDef> Bundles, AllocInfo AllocInfo,
3816const Twine &NameStr, InsertPosition InsertBefore)
3817 : CallBase(Ty->getReturnType(), Instruction::Invoke, AllocInfo,
3819init(Ty, Func, IfNormal, IfException, Args, Bundles, NameStr);
3822//===----------------------------------------------------------------------===// 3824//===----------------------------------------------------------------------===// 3826/// CallBr instruction, tracking function calls that may not return control but 3827/// instead transfer it to a third location. The SubclassData field is used to 3828/// hold the calling convention of the call. 3832unsigned NumIndirectDests;
3836 /// Construct a CallBrInst given a range of arguments. 3838 /// Construct a CallBrInst from a range of arguments 3849 /// Compute the number of operands to allocate. 3850staticunsigned ComputeNumOperands(
int NumArgs,
int NumIndirectDests,
3851int NumBundleInputs = 0) {
3852// We need one operand for the called function, plus our extra operands and 3853// the input operand counts provided. 3854returnunsigned(2 + NumIndirectDests + NumArgs + NumBundleInputs);
3858// Note: Instruction needs to be a friend here to call cloneImpl. 3870 ComputeNumOperands(Args.size(), IndirectDests.
size())};
3871returnnew (AllocMarker)
3872CallBrInst(Ty, Func, DefaultDest, IndirectDests, Args, {}, AllocMarker,
3873 NameStr, InsertBefore);
3881 IntrusiveOperandsAndDescriptorAllocMarker AllocMarker{
3882 ComputeNumOperands(Args.size(), IndirectDests.
size(),
3886returnnew (AllocMarker)
3887 CallBrInst(Ty, Func, DefaultDest, IndirectDests, Args, Bundles,
3888 AllocMarker, NameStr, InsertBefore);
3895returnCreate(Func.getFunctionType(), Func.getCallee(), DefaultDest,
3896 IndirectDests, Args, NameStr, InsertBefore);
3903constTwine &NameStr =
"",
3905returnCreate(Func.getFunctionType(), Func.getCallee(), DefaultDest,
3906 IndirectDests, Args, Bundles, NameStr, InsertBefore);
3909 /// Create a clone of \p CBI with a different set of operand bundles and 3910 /// insert it before \p InsertBefore. 3912 /// The returned callbr instruction is identical to \p CBI in every way 3913 /// except that the operand bundles for the new instruction are set to the 3914 /// operand bundles in \p Bundles. 3915static CallBrInst *
Create(CallBrInst *CBI, ArrayRef<OperandBundleDef> Bundles,
3916 InsertPosition InsertBefore =
nullptr);
3918 /// Return the number of callbr indirect dest labels. 3922 /// getIndirectDestLabel - Return the i-th indirect dest label. 3934// Return the destination basic blocks... 3945return IndirectDests;
3956"Successor # out of range for callbr!");
3962"Successor # out of range for callbr!");
3968// Methods for support type inquiry through isa, cast, and dyn_cast: 3970return (
I->getOpcode() == Instruction::CallBr);
3973return isa<Instruction>(V) &&
classof(cast<Instruction>(V));
3977// Shadow Instruction::setInstructionSubclassData with a private forwarding 3978// method so that subclasses cannot accidentally use it. 3979template <
typename Bitfield>
3980void setSubclassData(
typename Bitfield::Type
Value) {
3981 Instruction::setSubclassData<Bitfield>(
Value);
3985CallBrInst::CallBrInst(
FunctionType *Ty, Value *Func, BasicBlock *DefaultDest,
3986 ArrayRef<BasicBlock *> IndirectDests,
3987 ArrayRef<Value *> Args,
3988 ArrayRef<OperandBundleDef> Bundles, AllocInfo AllocInfo,
3989const Twine &NameStr, InsertPosition InsertBefore)
3990 : CallBase(Ty->getReturnType(), Instruction::CallBr, AllocInfo,
3992init(Ty, Func, DefaultDest, IndirectDests, Args, Bundles, NameStr);
3995//===----------------------------------------------------------------------===// 3997//===----------------------------------------------------------------------===// 3999//===--------------------------------------------------------------------------- 4000/// Resume the propagation of an exception. 4010// Note: Instruction needs to be a friend here to call cloneImpl. 4017returnnew (AllocMarker)
ResumeInst(Exn, InsertBefore);
4020 /// Provide fast operand accessors 4023 /// Convenience accessor. 4028// Methods for support type inquiry through isa, cast, and dyn_cast: 4030returnI->getOpcode() == Instruction::Resume;
4033return isa<Instruction>(V) &&
classof(cast<Instruction>(V));
4041void setSuccessor(
unsigned idx,
BasicBlock *NewSucc) {
4053//===----------------------------------------------------------------------===// 4054// CatchSwitchInst Class 4055//===----------------------------------------------------------------------===// 4061 /// The number of operands actually allocated. NumOperands is 4062 /// the number actually in use. 4063unsigned ReservedSpace;
4065// Operand[0] = Outer scope 4066// Operand[1] = Unwind block destination 4067// Operand[n] = BasicBlock to go to on match 4070 /// Create a new switch instruction, specifying a 4071 /// default destination. The number of additional handlers can be specified 4072 /// here to make memory allocation more efficient. 4073 /// This constructor can also autoinsert before another instruction. 4075unsigned NumHandlers,
constTwine &NameStr,
4078// allocate space for exactly zero operands 4079void *
operatornew(
size_t S) {
return User::operator
new(S, AllocMarker); }
4081void init(
Value *ParentPad,
BasicBlock *UnwindDest,
unsigned NumReserved);
4082void growOperands(
unsignedSize);
4085// Note: Instruction needs to be a friend here to call cloneImpl. 4091voidoperatordelete(
void *
Ptr) {
return User::operator
delete(
Ptr); }
4094unsigned NumHandlers,
4095constTwine &NameStr =
"",
4101 /// Provide fast operand accessors 4104// Accessor Methods for CatchSwitch stmt 4108// Accessor Methods for CatchSwitch stmt 4113return cast<BasicBlock>(getOperand(1));
4119 setOperand(1, UnwindDest);
4122 /// return the number of 'handlers' in this catchswitch 4123 /// instruction, except the default handler 4126return getNumOperands() - 2;
4127return getNumOperands() - 1;
4131staticBasicBlock *handler_helper(
Value *V) {
return cast<BasicBlock>(V); }
4132staticconst BasicBlock *handler_helper(
const Value *V) {
4133return cast<BasicBlock>(V);
4145 /// Returns an iterator that points to the first handler in CatchSwitchInst. 4153 /// Returns an iterator that points to the first handler in the 4154 /// CatchSwitchInst. 4162 /// Returns a read-only iterator that points one past the last 4163 /// handler in the CatchSwitchInst. 4168 /// Returns an iterator that points one past the last handler in the 4169 /// CatchSwitchInst. 4174 /// iteration adapter for range-for loops. 4176returnmake_range(handler_begin(), handler_end());
4179 /// iteration adapter for range-for loops. 4181returnmake_range(handler_begin(), handler_end());
4184 /// Add an entry to the switch instruction... 4186 /// This action invalidates handler_end(). Old handler_end() iterator will 4187 /// point to the added handler. 4190void removeHandler(handler_iterator HI);
4195"Successor # out of range for catchswitch!");
4196return cast<BasicBlock>(getOperand(
Idx + 1));
4200"Successor # out of range for catchswitch!");
4201 setOperand(
Idx + 1, NewSucc);
4204// Methods for support type inquiry through isa, cast, and dyn_cast: 4206returnI->getOpcode() == Instruction::CatchSwitch;
4209return isa<Instruction>(V) && classof(cast<Instruction>(V));
4218//===----------------------------------------------------------------------===// 4219// CleanupPadInst Class 4220//===----------------------------------------------------------------------===// 4227 NameStr, InsertBefore) {}
4231constTwine &NameStr =
"",
4233 IntrusiveOperandsAllocMarker AllocMarker{
unsigned(1 + Args.size())};
4234returnnew (AllocMarker)
4235 CleanupPadInst(ParentPad, Args, AllocMarker, NameStr, InsertBefore);
4238 /// Methods for support type inquiry through isa, cast, and dyn_cast: 4240returnI->getOpcode() == Instruction::CleanupPad;
4243return isa<Instruction>(V) && classof(cast<Instruction>(V));
4247//===----------------------------------------------------------------------===// 4248// CatchPadInst Class 4249//===----------------------------------------------------------------------===// 4256 NameStr, InsertBefore) {}
4260constTwine &NameStr =
"",
4263returnnew (AllocMarker)
4264CatchPadInst(CatchSwitch, Args, AllocMarker, NameStr, InsertBefore);
4267 /// Convenience accessors 4269return cast<CatchSwitchInst>(
Op<-1>());
4273Op<-1>() = CatchSwitch;
4276 /// Methods for support type inquiry through isa, cast, and dyn_cast: 4278returnI->getOpcode() == Instruction::CatchPad;
4281return isa<Instruction>(V) &&
classof(cast<Instruction>(V));
4285//===----------------------------------------------------------------------===// 4286// CatchReturnInst Class 4287//===----------------------------------------------------------------------===// 4298// Note: Instruction needs to be a friend here to call cloneImpl. 4311 /// Provide fast operand accessors 4314 /// Convenience accessors. 4328 /// Get the parentPad of this catchret's catchpad's catchswitch. 4329 /// The successor block is implicitly a member of this funclet. 4334// Methods for support type inquiry through isa, cast, and dyn_cast: 4336return (
I->getOpcode() == Instruction::CatchRet);
4339return isa<Instruction>(V) &&
classof(cast<Instruction>(V));
4360//===----------------------------------------------------------------------===// 4361// CleanupReturnInst Class 4362//===----------------------------------------------------------------------===// 4375// Note: Instruction needs to be a friend here to call cloneImpl. 4389returnnew (AllocMarker)
4393 /// Provide fast operand accessors 4399 /// Convenience accessor. 4401return cast<CleanupPadInst>(
Op<0>());
4405Op<0>() = CleanupPad;
4411return hasUnwindDest() ? cast<BasicBlock>(
Op<1>()) :
nullptr;
4419// Methods for support type inquiry through isa, cast, and dyn_cast: 4421return (
I->getOpcode() == Instruction::CleanupRet);
4424return isa<Instruction>(V) && classof(cast<Instruction>(V));
4430return getUnwindDest();
4433void setSuccessor(
unsignedIdx, BasicBlock *
B) {
4438// Shadow Instruction::setInstructionSubclassData with a private forwarding 4439// method so that subclasses cannot accidentally use it. 4440template <
typename Bitfield>
4441void setSubclassData(
typename Bitfield::Type Value) {
4442 Instruction::setSubclassData<Bitfield>(Value);
4452//===----------------------------------------------------------------------===// 4453// UnreachableInst Class 4454//===----------------------------------------------------------------------===// 4456//===--------------------------------------------------------------------------- 4457/// This function has undefined behavior. In particular, the 4458/// presence of this instruction indicates some higher level knowledge that the 4459/// end of the block cannot be reached. 4465// Note: Instruction needs to be a friend here to call cloneImpl. 4474// allocate space for exactly zero operands 4475void *
operatornew(
size_t S) {
return User::operator
new(S, AllocMarker); }
4476voidoperatordelete(
void *
Ptr) { User::operator
delete(
Ptr); }
4480// Methods for support type inquiry through isa, cast, and dyn_cast: 4482returnI->getOpcode() == Instruction::Unreachable;
4485return isa<Instruction>(V) && classof(cast<Instruction>(V));
4493void setSuccessor(
unsigned idx, BasicBlock *
B) {
4498//===----------------------------------------------------------------------===// 4500//===----------------------------------------------------------------------===// 4502/// This class represents a truncation of integer types. 4505// Note: Instruction needs to be a friend here to call cloneImpl. 4508 /// Clone an identical TruncInst 4514 /// Constructor with insert-before-instruction semantics 4516Type *Ty,
///< The (smaller) type to truncate to 4517constTwine &NameStr =
"",
///< A name for the new instruction 4519nullptr///< Where to insert the new instruction 4522 /// Methods for support type inquiry through isa, cast, and dyn_cast: 4524returnI->getOpcode() == Trunc;
4527return isa<Instruction>(V) &&
classof(cast<Instruction>(V));
4539 /// Test whether this operation is known to never 4540 /// undergo unsigned overflow, aka the nuw property. 4545 /// Test whether this operation is known to never 4546 /// undergo signed overflow, aka the nsw property. 4551 /// Returns the no-wrap kind of the operation. 4553unsigned NoWrapKind = 0;
4564//===----------------------------------------------------------------------===// 4566//===----------------------------------------------------------------------===// 4568/// This class represents zero extension of integer types. 4571// Note: Instruction needs to be a friend here to call cloneImpl. 4574 /// Clone an identical ZExtInst 4578 /// Constructor with insert-before-instruction semantics 4580Type *Ty,
///< The type to zero extend to 4581constTwine &NameStr =
"",
///< A name for the new instruction 4583nullptr///< Where to insert the new instruction 4586 /// Methods for support type inquiry through isa, cast, and dyn_cast: 4588returnI->getOpcode() == ZExt;
4591return isa<Instruction>(V) &&
classof(cast<Instruction>(V));
4595//===----------------------------------------------------------------------===// 4597//===----------------------------------------------------------------------===// 4599/// This class represents a sign extension of integer types. 4602// Note: Instruction needs to be a friend here to call cloneImpl. 4605 /// Clone an identical SExtInst 4609 /// Constructor with insert-before-instruction semantics 4611Type *Ty,
///< The type to sign extend to 4612constTwine &NameStr =
"",
///< A name for the new instruction 4614nullptr///< Where to insert the new instruction 4617 /// Methods for support type inquiry through isa, cast, and dyn_cast: 4619returnI->getOpcode() == SExt;
4622return isa<Instruction>(V) &&
classof(cast<Instruction>(V));
4626//===----------------------------------------------------------------------===// 4628//===----------------------------------------------------------------------===// 4630/// This class represents a truncation of floating point types. 4633// Note: Instruction needs to be a friend here to call cloneImpl. 4636 /// Clone an identical FPTruncInst 4639public:
/// Constructor with insert-before-instruction semantics 4641Type *Ty,
///< The type to truncate to 4642constTwine &NameStr =
"",
///< A name for the new instruction 4644nullptr///< Where to insert the new instruction 4647 /// Methods for support type inquiry through isa, cast, and dyn_cast: 4649returnI->getOpcode() == FPTrunc;
4652return isa<Instruction>(V) &&
classof(cast<Instruction>(V));
4656//===----------------------------------------------------------------------===// 4658//===----------------------------------------------------------------------===// 4660/// This class represents an extension of floating point types. 4663// Note: Instruction needs to be a friend here to call cloneImpl. 4666 /// Clone an identical FPExtInst 4670 /// Constructor with insert-before-instruction semantics 4672Type *Ty,
///< The type to extend to 4673constTwine &NameStr =
"",
///< A name for the new instruction 4675nullptr///< Where to insert the new instruction 4678 /// Methods for support type inquiry through isa, cast, and dyn_cast: 4680returnI->getOpcode() == FPExt;
4683return isa<Instruction>(V) &&
classof(cast<Instruction>(V));
4687//===----------------------------------------------------------------------===// 4689//===----------------------------------------------------------------------===// 4691/// This class represents a cast unsigned integer to floating point. 4694// Note: Instruction needs to be a friend here to call cloneImpl. 4697 /// Clone an identical UIToFPInst 4701 /// Constructor with insert-before-instruction semantics 4703Type *Ty,
///< The type to convert to 4704constTwine &NameStr =
"",
///< A name for the new instruction 4706nullptr///< Where to insert the new instruction 4709 /// Methods for support type inquiry through isa, cast, and dyn_cast: 4711returnI->getOpcode() == UIToFP;
4714return isa<Instruction>(V) &&
classof(cast<Instruction>(V));
4718//===----------------------------------------------------------------------===// 4720//===----------------------------------------------------------------------===// 4722/// This class represents a cast from signed integer to floating point. 4725// Note: Instruction needs to be a friend here to call cloneImpl. 4728 /// Clone an identical SIToFPInst 4732 /// Constructor with insert-before-instruction semantics 4734Type *Ty,
///< The type to convert to 4735constTwine &NameStr =
"",
///< A name for the new instruction 4737nullptr///< Where to insert the new instruction 4740 /// Methods for support type inquiry through isa, cast, and dyn_cast: 4742returnI->getOpcode() == SIToFP;
4745return isa<Instruction>(V) &&
classof(cast<Instruction>(V));
4749//===----------------------------------------------------------------------===// 4751//===----------------------------------------------------------------------===// 4753/// This class represents a cast from floating point to unsigned integer 4756// Note: Instruction needs to be a friend here to call cloneImpl. 4759 /// Clone an identical FPToUIInst 4763 /// Constructor with insert-before-instruction semantics 4765Type *Ty,
///< The type to convert to 4766constTwine &NameStr =
"",
///< A name for the new instruction 4768nullptr///< Where to insert the new instruction 4771 /// Methods for support type inquiry through isa, cast, and dyn_cast: 4773returnI->getOpcode() == FPToUI;
4776return isa<Instruction>(V) &&
classof(cast<Instruction>(V));
4780//===----------------------------------------------------------------------===// 4782//===----------------------------------------------------------------------===// 4784/// This class represents a cast from floating point to signed integer. 4787// Note: Instruction needs to be a friend here to call cloneImpl. 4790 /// Clone an identical FPToSIInst 4794 /// Constructor with insert-before-instruction semantics 4796Type *Ty,
///< The type to convert to 4797constTwine &NameStr =
"",
///< A name for the new instruction 4799nullptr///< Where to insert the new instruction 4802 /// Methods for support type inquiry through isa, cast, and dyn_cast: 4804returnI->getOpcode() == FPToSI;
4807return isa<Instruction>(V) &&
classof(cast<Instruction>(V));
4811//===----------------------------------------------------------------------===// 4812// IntToPtrInst Class 4813//===----------------------------------------------------------------------===// 4815/// This class represents a cast from an integer to a pointer. 4818// Note: Instruction needs to be a friend here to call cloneImpl. 4821 /// Constructor with insert-before-instruction semantics 4823Type *Ty,
///< The type to convert to 4824constTwine &NameStr =
"",
///< A name for the new instruction 4826nullptr///< Where to insert the new instruction 4829 /// Clone an identical IntToPtrInst. 4832 /// Returns the address space of this instruction's pointer type. 4837// Methods for support type inquiry through isa, cast, and dyn_cast: 4839returnI->getOpcode() == IntToPtr;
4842return isa<Instruction>(V) &&
classof(cast<Instruction>(V));
4846//===----------------------------------------------------------------------===// 4847// PtrToIntInst Class 4848//===----------------------------------------------------------------------===// 4850/// This class represents a cast from a pointer to an integer. 4853// Note: Instruction needs to be a friend here to call cloneImpl. 4856 /// Clone an identical PtrToIntInst. 4860 /// Constructor with insert-before-instruction semantics 4862Type *Ty,
///< The type to convert to 4863constTwine &NameStr =
"",
///< A name for the new instruction 4865nullptr///< Where to insert the new instruction 4868 /// Gets the pointer operand. 4870 /// Gets the pointer operand. 4872 /// Gets the operand index of the pointer operand. 4875 /// Returns the address space of the pointer operand. 4880// Methods for support type inquiry through isa, cast, and dyn_cast: 4882returnI->getOpcode() == PtrToInt;
4885return isa<Instruction>(V) &&
classof(cast<Instruction>(V));
4889//===----------------------------------------------------------------------===// 4891//===----------------------------------------------------------------------===// 4893/// This class represents a no-op cast from one type to another. 4896// Note: Instruction needs to be a friend here to call cloneImpl. 4899 /// Clone an identical BitCastInst. 4903 /// Constructor with insert-before-instruction semantics 4905Type *Ty,
///< The type to casted to 4906constTwine &NameStr =
"",
///< A name for the new instruction 4908nullptr///< Where to insert the new instruction 4911// Methods for support type inquiry through isa, cast, and dyn_cast: 4913returnI->getOpcode() == BitCast;
4916return isa<Instruction>(V) &&
classof(cast<Instruction>(V));
4920//===----------------------------------------------------------------------===// 4921// AddrSpaceCastInst Class 4922//===----------------------------------------------------------------------===// 4924/// This class represents a conversion between pointers from one address space 4928// Note: Instruction needs to be a friend here to call cloneImpl. 4931 /// Clone an identical AddrSpaceCastInst. 4935 /// Constructor with insert-before-instruction semantics 4937Value *S,
///< The value to be casted 4938Type *Ty,
///< The type to casted to 4939constTwine &NameStr =
"",
///< A name for the new instruction 4941nullptr///< Where to insert the new instruction 4944// Methods for support type inquiry through isa, cast, and dyn_cast: 4946returnI->getOpcode() == AddrSpaceCast;
4949return isa<Instruction>(V) &&
classof(cast<Instruction>(V));
4952 /// Gets the pointer operand. 4957 /// Gets the pointer operand. 4962 /// Gets the operand index of the pointer operand. 4967 /// Returns the address space of the pointer operand. 4972 /// Returns the address space of the result. 4978//===----------------------------------------------------------------------===// 4980//===----------------------------------------------------------------------===// 4982/// A helper function that returns the pointer operand of a load or store 4983/// instruction. Returns nullptr if not load or store. 4985if (
auto *Load = dyn_cast<LoadInst>(V))
4986return Load->getPointerOperand();
4987if (
auto *Store = dyn_cast<StoreInst>(V))
4988return Store->getPointerOperand();
4992returnconst_cast<Value *
>(
4996/// A helper function that returns the pointer operand of a load, store 4997/// or GEP instruction. Returns nullptr if not load, store, or GEP. 5001if (
auto *Gep = dyn_cast<GetElementPtrInst>(V))
5002return Gep->getPointerOperand();
5009/// A helper function that returns the alignment of load or store instruction. 5011assert((isa<LoadInst>(
I) || isa<StoreInst>(
I)) &&
5012"Expected Load or Store instruction");
5013if (
auto *LI = dyn_cast<LoadInst>(
I))
5014return LI->getAlign();
5015return cast<StoreInst>(
I)->getAlign();
5018/// A helper function that set the alignment of load or store instruction. 5020assert((isa<LoadInst>(
I) || isa<StoreInst>(
I)) &&
5021"Expected Load or Store instruction");
5022if (
auto *LI = dyn_cast<LoadInst>(
I))
5023 LI->setAlignment(NewAlign);
5025 cast<StoreInst>(
I)->setAlignment(NewAlign);
5028/// A helper function that returns the address space of the pointer operand of 5029/// load or store instruction. 5031assert((isa<LoadInst>(
I) || isa<StoreInst>(
I)) &&
5032"Expected Load or Store instruction");
5033if (
auto *LI = dyn_cast<LoadInst>(
I))
5034return LI->getPointerAddressSpace();
5035return cast<StoreInst>(
I)->getPointerAddressSpace();
5038/// A helper function that returns the type of a load or store instruction. 5040assert((isa<LoadInst>(
I) || isa<StoreInst>(
I)) &&
5041"Expected Load or Store instruction");
5042if (
auto *LI = dyn_cast<LoadInst>(
I))
5043return LI->getType();
5044return cast<StoreInst>(
I)->getValueOperand()->getType();
5047/// A helper function that returns an atomic operation's sync scope; returns 5048/// std::nullopt if it is not an atomic operation. 5052if (
auto *AI = dyn_cast<LoadInst>(
I))
5053return AI->getSyncScopeID();
5054if (
auto *AI = dyn_cast<StoreInst>(
I))
5055return AI->getSyncScopeID();
5056if (
auto *AI = dyn_cast<FenceInst>(
I))
5057return AI->getSyncScopeID();
5058if (
auto *AI = dyn_cast<AtomicCmpXchgInst>(
I))
5059return AI->getSyncScopeID();
5060if (
auto *AI = dyn_cast<AtomicRMWInst>(
I))
5061return AI->getSyncScopeID();
5065/// A helper function that sets an atomic operation's sync scope. 5068if (
auto *AI = dyn_cast<LoadInst>(
I))
5069 AI->setSyncScopeID(SSID);
5070elseif (
auto *AI = dyn_cast<StoreInst>(
I))
5071 AI->setSyncScopeID(SSID);
5072elseif (
auto *AI = dyn_cast<FenceInst>(
I))
5073 AI->setSyncScopeID(SSID);
5074elseif (
auto *AI = dyn_cast<AtomicCmpXchgInst>(
I))
5075 AI->setSyncScopeID(SSID);
5076elseif (
auto *AI = dyn_cast<AtomicRMWInst>(
I))
5077 AI->setSyncScopeID(SSID);
5082//===----------------------------------------------------------------------===// 5084//===----------------------------------------------------------------------===// 5086/// This class represents a freeze function that returns random concrete 5087/// value if an operand is either a poison value or an undef value 5090// Note: Instruction needs to be a friend here to call cloneImpl. 5093 /// Clone an identical FreezeInst 5100// Methods for support type inquiry through isa, cast, and dyn_cast: 5102returnI->getOpcode() == Freeze;
5105return isa<Instruction>(V) &&
classof(cast<Instruction>(V));
5109}
// end namespace llvm 5111#endif// LLVM_IR_INSTRUCTIONS_H static bool isReverseMask(ArrayRef< int > M, EVT VT)
MachineBasicBlock MachineBasicBlock::iterator DebugLoc DL
Atomic ordering constants.
static const Function * getParent(const Value *V)
This file implements methods to test, set and extract typed bits from packed unsigned integers.
static GCRegistry::Add< OcamlGC > B("ocaml", "ocaml 3.10-compatible GC")
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
This file provides various utilities for inspecting and working with the control flow graph in LLVM I...
This defines the Use class.
This file implements a map that provides insertion order iteration.
uint64_t IntrinsicInst * II
#define DEFINE_TRANSPARENT_OPERAND_ACCESSORS(CLASS, VALUECLASS)
Macro for generating out-of-class operand accessor definitions.
PowerPC Reduce CR logical Operation
StandardInstrumentations SI(Mod->getContext(), Debug, VerifyEach)
const SmallVectorImpl< MachineOperand > & Cond
assert(ImpDefSCC.getReg()==AMDGPU::SCC &&ImpDefSCC.isDef())
This file contains some templates that are useful if you are working with the STL at all.
This file defines the SmallVector class.
static SymbolRef::Type getType(const Symbol *Sym)
Class for arbitrary precision integers.
This class represents a conversion between pointers from one address space to another.
const Value * getPointerOperand() const
Gets the pointer operand.
AddrSpaceCastInst * cloneImpl() const
Clone an identical AddrSpaceCastInst.
Value * getPointerOperand()
Gets the pointer operand.
static bool classof(const Instruction *I)
static bool classof(const Value *V)
unsigned getSrcAddressSpace() const
Returns the address space of the pointer operand.
unsigned getDestAddressSpace() const
Returns the address space of the result.
static unsigned getPointerOperandIndex()
Gets the operand index of the pointer operand.
an instruction to allocate memory on the stack
std::optional< TypeSize > getAllocationSizeInBits(const DataLayout &DL) const
Get allocation size in bits.
static bool classof(const Value *V)
bool isSwiftError() const
Return true if this alloca is used as a swifterror argument to a call.
void setSwiftError(bool V)
Specify whether this alloca is used to represent a swifterror.
bool isStaticAlloca() const
Return true if this alloca is in the entry block of the function and is a constant size.
Align getAlign() const
Return the alignment of the memory that is being allocated by the instruction.
void setAllocatedType(Type *Ty)
for use only in special circumstances that need to generically transform a whole instruction (eg: IR ...
static bool classof(const Instruction *I)
PointerType * getType() const
Overload to return most specific pointer type.
void setUsedWithInAlloca(bool V)
Specify whether this alloca is used to represent the arguments to a call.
AllocaInst * cloneImpl() const
Type * getAllocatedType() const
Return the type that is being allocated by the instruction.
bool isUsedWithInAlloca() const
Return true if this alloca is used as an inalloca argument to a call.
unsigned getAddressSpace() const
Return the address space for the allocation.
std::optional< TypeSize > getAllocationSize(const DataLayout &DL) const
Get allocation size in bytes.
bool isArrayAllocation() const
Return true if there is an allocation size parameter to the allocation instruction that is not 1.
void setAlignment(Align Align)
const Value * getArraySize() const
Get the number of elements allocated.
ArrayRef - Represent a constant reference to an array (0 or more elements consecutively in memory),...
size_t size() const
size - Get the array size.
An instruction that atomically checks whether a specified value is in a memory location,...
BoolBitfieldElementT< 0 > VolatileField
const Value * getCompareOperand() const
Value * getNewValOperand()
void setSyncScopeID(SyncScope::ID SSID)
Sets the synchronization scope ID of this cmpxchg instruction.
AtomicOrdering getMergedOrdering() const
Returns a single ordering which is at least as strong as both the success and failure orderings for t...
void setWeak(bool IsWeak)
bool isVolatile() const
Return true if this is a cmpxchg from a volatile memory location.
unsigned getPointerAddressSpace() const
Returns the address space of the pointer operand.
BoolBitfieldElementT< VolatileField::NextBit > WeakField
AtomicOrderingBitfieldElementT< SuccessOrderingField::NextBit > FailureOrderingField
Value * getCompareOperand()
void setFailureOrdering(AtomicOrdering Ordering)
Sets the failure ordering constraint of this cmpxchg instruction.
static bool isValidFailureOrdering(AtomicOrdering Ordering)
AtomicOrdering getFailureOrdering() const
Returns the failure ordering constraint of this cmpxchg instruction.
void setSuccessOrdering(AtomicOrdering Ordering)
Sets the success ordering constraint of this cmpxchg instruction.
AlignmentBitfieldElementT< FailureOrderingField::NextBit > AlignmentField
Value * getPointerOperand()
static AtomicOrdering getStrongestFailureOrdering(AtomicOrdering SuccessOrdering)
Returns the strongest permitted ordering on failure, given the desired ordering on success.
DECLARE_TRANSPARENT_OPERAND_ACCESSORS(Value)
Transparently provide more efficient getOperand methods.
AtomicCmpXchgInst * cloneImpl() const
Align getAlign() const
Return the alignment of the memory that is being allocated by the instruction.
const Value * getPointerOperand() const
static bool classof(const Value *V)
bool isWeak() const
Return true if this cmpxchg may spuriously fail.
void setAlignment(Align Align)
void setVolatile(bool V)
Specify whether this is a volatile cmpxchg.
static bool isValidSuccessOrdering(AtomicOrdering Ordering)
AtomicOrdering getSuccessOrdering() const
Returns the success ordering constraint of this cmpxchg instruction.
AtomicOrderingBitfieldElementT< WeakField::NextBit > SuccessOrderingField
static unsigned getPointerOperandIndex()
const Value * getNewValOperand() const
SyncScope::ID getSyncScopeID() const
Returns the synchronization scope ID of this cmpxchg instruction.
static bool classof(const Instruction *I)
an instruction that atomically reads a memory location, combines it with another value,...
Align getAlign() const
Return the alignment of the memory that is being allocated by the instruction.
static bool isFPOperation(BinOp Op)
static unsigned getPointerOperandIndex()
bool isVolatile() const
Return true if this is a RMW on a volatile memory location.
void setVolatile(bool V)
Specify whether this is a volatile RMW or not.
BinOpBitfieldElement< AtomicOrderingField::NextBit > OperationField
BinOp
This enumeration lists the possible modifications atomicrmw can make.
@ USubCond
Subtract only if no unsigned overflow.
@ Min
*p = old <signed v ? old : v
@ USubSat
*p = usub.sat(old, v) usub.sat matches the behavior of llvm.usub.sat.
@ UIncWrap
Increment one up to a maximum value.
@ Max
*p = old >signed v ? old : v
@ UMin
*p = old <unsigned v ? old : v
@ FMin
*p = minnum(old, v) minnum matches the behavior of llvm.minnum.
@ UMax
*p = old >unsigned v ? old : v
@ FMax
*p = maxnum(old, v) maxnum matches the behavior of llvm.maxnum.
@ UDecWrap
Decrement one until a minimum value or zero.
AtomicOrderingBitfieldElementT< VolatileField::NextBit > AtomicOrderingField
void setSyncScopeID(SyncScope::ID SSID)
Sets the synchronization scope ID of this rmw instruction.
DECLARE_TRANSPARENT_OPERAND_ACCESSORS(Value)
Transparently provide more efficient getOperand methods.
Value * getPointerOperand()
void setOrdering(AtomicOrdering Ordering)
Sets the ordering constraint of this rmw instruction.
bool isFloatingPointOperation() const
static bool classof(const Instruction *I)
const Value * getPointerOperand() const
void setOperation(BinOp Operation)
static bool classof(const Value *V)
BinOp getOperation() const
const Value * getValOperand() const
SyncScope::ID getSyncScopeID() const
Returns the synchronization scope ID of this rmw instruction.
void setAlignment(Align Align)
AtomicOrdering getOrdering() const
Returns the ordering constraint of this rmw instruction.
AlignmentBitfieldElementT< OperationField::NextBit > AlignmentField
BoolBitfieldElementT< 0 > VolatileField
unsigned getPointerAddressSpace() const
Returns the address space of the pointer operand.
LLVM Basic Block Representation.
This class represents a no-op cast from one type to another.
static bool classof(const Instruction *I)
static bool classof(const Value *V)
BitCastInst * cloneImpl() const
Clone an identical BitCastInst.
Conditional or Unconditional Branch instruction.
DECLARE_TRANSPARENT_OPERAND_ACCESSORS(Value)
Transparently provide more efficient getOperand methods.
iterator_range< succ_op_iterator > successors()
static BranchInst * Create(BasicBlock *IfTrue, BasicBlock *IfFalse, Value *Cond, InsertPosition InsertBefore=nullptr)
void setCondition(Value *V)
static bool classof(const Instruction *I)
bool isConditional() const
unsigned getNumSuccessors() const
static bool classof(const Value *V)
static BranchInst * Create(BasicBlock *IfTrue, InsertPosition InsertBefore=nullptr)
BasicBlock * getSuccessor(unsigned i) const
bool isUnconditional() const
void setSuccessor(unsigned idx, BasicBlock *NewSucc)
Value * getCondition() const
iterator_range< const_succ_op_iterator > successors() const
Base class for all callable instructions (InvokeInst and CallInst) Holds everything related to callin...
void addFnAttr(Attribute::AttrKind Kind)
Adds the attribute to the function.
bool hasFnAttr(Attribute::AttrKind Kind) const
Determine whether this call has the given attribute.
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.
unsigned arg_size() const
unsigned getNumTotalBundleOperands() const
Return the total number operands (not operand bundles) used by every operand bundle in this OperandBu...
CallBr instruction, tracking function calls that may not return control but instead transfer it to a ...
static bool classof(const Value *V)
static CallBrInst * Create(FunctionType *Ty, Value *Func, BasicBlock *DefaultDest, ArrayRef< BasicBlock * > IndirectDests, ArrayRef< Value * > Args, ArrayRef< OperandBundleDef > Bundles={}, const Twine &NameStr="", InsertPosition InsertBefore=nullptr)
static bool classof(const Instruction *I)
static CallBrInst * Create(FunctionCallee Func, BasicBlock *DefaultDest, ArrayRef< BasicBlock * > IndirectDests, ArrayRef< Value * > Args, ArrayRef< OperandBundleDef > Bundles={}, const Twine &NameStr="", InsertPosition InsertBefore=nullptr)
SmallVector< BasicBlock *, 16 > getIndirectDests() const
static CallBrInst * Create(FunctionCallee Func, BasicBlock *DefaultDest, ArrayRef< BasicBlock * > IndirectDests, ArrayRef< Value * > Args, const Twine &NameStr, InsertPosition InsertBefore=nullptr)
void setSuccessor(unsigned i, BasicBlock *NewSucc)
BasicBlock * getSuccessor(unsigned i) const
Value * getIndirectDestLabelUse(unsigned i) const
BasicBlock * getIndirectDest(unsigned i) const
void setDefaultDest(BasicBlock *B)
unsigned getNumSuccessors() const
void setIndirectDest(unsigned i, BasicBlock *B)
Value * getIndirectDestLabel(unsigned i) const
getIndirectDestLabel - Return the i-th indirect dest label.
BasicBlock * getDefaultDest() const
unsigned getNumIndirectDests() const
Return the number of callbr indirect dest labels.
static CallBrInst * Create(FunctionType *Ty, Value *Func, BasicBlock *DefaultDest, ArrayRef< BasicBlock * > IndirectDests, ArrayRef< Value * > Args, const Twine &NameStr, InsertPosition InsertBefore=nullptr)
CallBrInst * cloneImpl() const
This class represents a function call, abstracting a target machine's calling convention.
bool isNoTailCall() const
void updateProfWeight(uint64_t S, uint64_t T)
Updates profile metadata by scaling it by S / T.
static bool classof(const Value *V)
void setTailCallKind(TailCallKind TCK)
static CallInst * Create(FunctionType *Ty, Value *Func, ArrayRef< Value * > Args, ArrayRef< OperandBundleDef > Bundles={}, const Twine &NameStr="", InsertPosition InsertBefore=nullptr)
static CallInst * Create(FunctionType *Ty, Value *Func, ArrayRef< Value * > Args, const Twine &NameStr, InsertPosition InsertBefore=nullptr)
bool canReturnTwice() const
Return true if the call can return twice.
TailCallKind getTailCallKind() const
CallInst * cloneImpl() const
static CallInst * Create(FunctionType *Ty, Value *F, const Twine &NameStr="", InsertPosition InsertBefore=nullptr)
void setTailCall(bool IsTc=true)
bool isMustTailCall() const
static CallInst * Create(FunctionCallee Func, ArrayRef< Value * > Args, const Twine &NameStr, InsertPosition InsertBefore=nullptr)
static bool classof(const Instruction *I)
bool isNonContinuableTrap() const
Return true if the call is for a noreturn trap intrinsic.
static CallInst * Create(FunctionCallee Func, const Twine &NameStr="", InsertPosition InsertBefore=nullptr)
static CallInst * Create(FunctionCallee Func, ArrayRef< Value * > Args, ArrayRef< OperandBundleDef > Bundles={}, const Twine &NameStr="", InsertPosition InsertBefore=nullptr)
This is the base class for all instructions that perform data casts.
CatchSwitchInst * getCatchSwitch() const
Convenience accessors.
void setCatchSwitch(Value *CatchSwitch)
static bool classof(const Instruction *I)
Methods for support type inquiry through isa, cast, and dyn_cast:
static CatchPadInst * Create(Value *CatchSwitch, ArrayRef< Value * > Args, const Twine &NameStr="", InsertPosition InsertBefore=nullptr)
static bool classof(const Value *V)
static bool classof(const Instruction *I)
BasicBlock * getSuccessor() const
CatchPadInst * getCatchPad() const
Convenience accessors.
void setSuccessor(BasicBlock *NewSucc)
static bool classof(const Value *V)
static CatchReturnInst * Create(Value *CatchPad, BasicBlock *BB, InsertPosition InsertBefore=nullptr)
unsigned getNumSuccessors() const
DECLARE_TRANSPARENT_OPERAND_ACCESSORS(Value)
Provide fast operand accessors.
void setCatchPad(CatchPadInst *CatchPad)
CatchReturnInst * cloneImpl() const
Value * getCatchSwitchParentPad() const
Get the parentPad of this catchret's catchpad's catchswitch.
void setUnwindDest(BasicBlock *UnwindDest)
static bool classof(const Instruction *I)
BasicBlock *(*)(Value *) DerefFnTy
const BasicBlock *(*)(const Value *) ConstDerefFnTy
unsigned getNumSuccessors() const
const_handler_iterator handler_begin() const
Returns an iterator that points to the first handler in the CatchSwitchInst.
unsigned getNumHandlers() const
return the number of 'handlers' in this catchswitch instruction, except the default handler
void setSuccessor(unsigned Idx, BasicBlock *NewSucc)
Value * getParentPad() const
void setParentPad(Value *ParentPad)
bool unwindsToCaller() const
static bool classof(const Value *V)
handler_iterator handler_end()
Returns a read-only iterator that points one past the last handler in the CatchSwitchInst.
BasicBlock * getUnwindDest() const
BasicBlock * getSuccessor(unsigned Idx) const
const_handler_iterator handler_end() const
Returns an iterator that points one past the last handler in the CatchSwitchInst.
bool hasUnwindDest() const
handler_iterator handler_begin()
Returns an iterator that points to the first handler in CatchSwitchInst.
static CatchSwitchInst * Create(Value *ParentPad, BasicBlock *UnwindDest, unsigned NumHandlers, const Twine &NameStr="", InsertPosition InsertBefore=nullptr)
handler_range handlers()
iteration adapter for range-for loops.
const_handler_range handlers() const
iteration adapter for range-for loops.
DECLARE_TRANSPARENT_OPERAND_ACCESSORS(Value)
Provide fast operand accessors.
static bool classof(const Value *V)
static bool classof(const Instruction *I)
Methods for support type inquiry through isa, cast, and dyn_cast:
static CleanupPadInst * Create(Value *ParentPad, ArrayRef< Value * > Args={}, const Twine &NameStr="", InsertPosition InsertBefore=nullptr)
static bool classof(const Instruction *I)
CleanupPadInst * getCleanupPad() const
Convenience accessor.
unsigned getNumSuccessors() const
BasicBlock * getUnwindDest() const
bool unwindsToCaller() const
void setCleanupPad(CleanupPadInst *CleanupPad)
static bool classof(const Value *V)
void setUnwindDest(BasicBlock *NewDest)
static CleanupReturnInst * Create(Value *CleanupPad, BasicBlock *UnwindBB=nullptr, InsertPosition InsertBefore=nullptr)
bool hasUnwindDest() const
DECLARE_TRANSPARENT_OPERAND_ACCESSORS(Value)
Provide fast operand accessors.
This class is the base class for the comparison instructions.
static Type * makeCmpResultType(Type *opnd_type)
Create a result type for fcmp/icmp.
void setPredicate(Predicate P)
Set the predicate for this instruction to the specified value.
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)
@ FCMP_ONE
0 1 1 0 True if ordered and operands are unequal
@ FCMP_UEQ
1 0 0 1 True if unordered or equal
@ FCMP_ORD
0 1 1 1 True if ordered (no nans)
@ FCMP_UNE
1 1 1 0 True if unordered or not equal
@ FCMP_FALSE
0 0 0 0 Always false (always folded)
@ FCMP_UNO
1 0 0 0 True if unordered: isnan(X) | isnan(Y)
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 isFPPredicate() const
Predicate getPredicate() const
Return the predicate for this instruction.
An abstraction over a floating-point predicate, and a pack of an integer predicate with samesign info...
bool hasSameSign() const
Query samesign information, for optimizations.
This is the shared class of boolean and integer constants.
This is an important base class in LLVM.
This class represents an Operation in the Expression.
A parsed version of the target data layout string in and methods for querying it.
This instruction extracts a single (scalar) element from a VectorType value.
const Value * getVectorOperand() const
ExtractElementInst * cloneImpl() const
DECLARE_TRANSPARENT_OPERAND_ACCESSORS(Value)
Transparently provide more efficient getOperand methods.
static bool classof(const Value *V)
static ExtractElementInst * Create(Value *Vec, Value *Idx, const Twine &NameStr="", InsertPosition InsertBefore=nullptr)
const Value * getIndexOperand() const
Value * getVectorOperand()
static bool classof(const Instruction *I)
Value * getIndexOperand()
VectorType * getVectorOperandType() const
static bool isValidOperands(const Value *Vec, const Value *Idx)
Return true if an extractelement instruction can be formed with the specified operands.
This instruction extracts a struct member or array element value from an aggregate value.
ArrayRef< unsigned > getIndices() const
unsigned getNumIndices() const
static bool classof(const Value *V)
static bool classof(const Instruction *I)
iterator_range< idx_iterator > indices() const
idx_iterator idx_end() const
static ExtractValueInst * Create(Value *Agg, ArrayRef< unsigned > Idxs, const Twine &NameStr="", InsertPosition InsertBefore=nullptr)
const Value * getAggregateOperand() const
Value * getAggregateOperand()
static unsigned getAggregateOperandIndex()
idx_iterator idx_begin() const
This instruction compares its operands according to the predicate given to the constructor.
bool isRelational() const
FCmpInst(Predicate Pred, Value *LHS, Value *RHS, const Twine &NameStr="", Instruction *FlagsSource=nullptr)
Constructor with no-insertion semantics.
static bool classof(const Value *V)
bool isCommutative() const
static bool isCommutative(Predicate Pred)
static bool compare(const APFloat &LHS, const APFloat &RHS, FCmpInst::Predicate Pred)
Return result of LHS Pred RHS comparison.
static bool isEquality(Predicate Pred)
static bool classof(const Instruction *I)
Methods for support type inquiry through isa, cast, and dyn_cast:
static auto predicates()
Returns the sequence of all FCmp predicates.
FCmpInst * cloneImpl() const
Clone an identical FCmpInst.
void swapOperands()
Exchange the two operands to this instruction in such a way that it does not modify the semantics of ...
FCmpInst(InsertPosition InsertBefore, Predicate pred, Value *LHS, Value *RHS, const Twine &NameStr="")
Constructor with insertion semantics.
This class represents an extension of floating point types.
static bool classof(const Value *V)
FPExtInst * cloneImpl() const
Clone an identical FPExtInst.
static bool classof(const Instruction *I)
Methods for support type inquiry through isa, cast, and dyn_cast:
This class represents a cast from floating point to signed integer.
static bool classof(const Value *V)
FPToSIInst * cloneImpl() const
Clone an identical FPToSIInst.
static bool classof(const Instruction *I)
Methods for support type inquiry through isa, cast, and dyn_cast:
This class represents a cast from floating point to unsigned integer.
static bool classof(const Value *V)
static bool classof(const Instruction *I)
Methods for support type inquiry through isa, cast, and dyn_cast:
FPToUIInst * cloneImpl() const
Clone an identical FPToUIInst.
This class represents a truncation of floating point types.
static bool classof(const Instruction *I)
Methods for support type inquiry through isa, cast, and dyn_cast:
static bool classof(const Value *V)
FPTruncInst * cloneImpl() const
Clone an identical FPTruncInst.
An instruction for ordering other memory operations.
static bool classof(const Value *V)
SyncScope::ID getSyncScopeID() const
Returns the synchronization scope ID of this fence instruction.
void setSyncScopeID(SyncScope::ID SSID)
Sets the synchronization scope ID of this fence instruction.
static bool classof(const Instruction *I)
void setOrdering(AtomicOrdering Ordering)
Sets the ordering constraint of this fence instruction.
AtomicOrdering getOrdering() const
Returns the ordering constraint of this fence instruction.
This class represents a freeze function that returns random concrete value if an operand is either a ...
static bool classof(const Value *V)
FreezeInst * cloneImpl() const
Clone an identical FreezeInst.
static bool classof(const Instruction *I)
friend class CatchPadInst
A handy container for a FunctionType+Callee-pointer pair, which can be passed around as a single enti...
Class to represent function types.
Represents flags for the getelementptr instruction/expression.
static GEPNoWrapFlags inBounds()
an instruction for type-safe pointer arithmetic to access elements of arrays and structs
bool isInBounds() const
Determine whether the GEP has the inbounds flag.
bool hasNoUnsignedSignedWrap() const
Determine whether the GEP has the nusw flag.
static Type * getTypeAtIndex(Type *Ty, Value *Idx)
Return the type of the element at the given index of an indexable type.
Value * getPointerOperand()
bool hasAllZeroIndices() const
Return true if all of the indices of this GEP are zeros.
static Type * getGEPReturnType(Value *Ptr, ArrayRef< Value * > IdxList)
Returns the pointer type returned by the GEP instruction, which may be a vector of pointers.
DECLARE_TRANSPARENT_OPERAND_ACCESSORS(Value)
Transparently provide more efficient getOperand methods.
void setResultElementType(Type *Ty)
bool hasNoUnsignedWrap() const
Determine whether the GEP has the nuw flag.
bool hasAllConstantIndices() const
Return true if all of the indices of this GEP are constant integers.
unsigned getAddressSpace() const
Returns the address space of this instruction's pointer type.
iterator_range< const_op_iterator > indices() const
Type * getResultElementType() const
static bool classof(const Instruction *I)
static bool classof(const Value *V)
iterator_range< op_iterator > indices()
static GetElementPtrInst * Create(Type *PointeeType, Value *Ptr, ArrayRef< Value * > IdxList, const Twine &NameStr="", InsertPosition InsertBefore=nullptr)
void setIsInBounds(bool b=true)
Set or clear the inbounds flag on this GEP instruction.
void setSourceElementType(Type *Ty)
static Type * getIndexedType(Type *Ty, ArrayRef< Value * > IdxList)
Returns the result type of a getelementptr with the given source element type and indexes.
Type * getSourceElementType() const
static GetElementPtrInst * CreateInBounds(Type *PointeeType, Value *Ptr, ArrayRef< Value * > IdxList, const Twine &NameStr="", InsertPosition InsertBefore=nullptr)
Create an "inbounds" getelementptr.
Type * getPointerOperandType() const
Method to return the pointer operand as a PointerType.
static GetElementPtrInst * Create(Type *PointeeType, Value *Ptr, ArrayRef< Value * > IdxList, GEPNoWrapFlags NW, const Twine &NameStr="", InsertPosition InsertBefore=nullptr)
static unsigned getPointerOperandIndex()
bool accumulateConstantOffset(const DataLayout &DL, APInt &Offset) const
Accumulate the constant address offset of this GEP if possible.
const_op_iterator idx_begin() const
GetElementPtrInst * cloneImpl() const
bool collectOffset(const DataLayout &DL, unsigned BitWidth, SmallMapVector< Value *, APInt, 4 > &VariableOffsets, APInt &ConstantOffset) const
void setNoWrapFlags(GEPNoWrapFlags NW)
Set nowrap flags for GEP instruction.
unsigned getNumIndices() const
GEPNoWrapFlags getNoWrapFlags() const
Get the nowrap flags for the GEP instruction.
const_op_iterator idx_end() const
const Value * getPointerOperand() const
unsigned getPointerAddressSpace() const
Returns the address space of the pointer operand.
This instruction compares its operands according to the predicate given to the constructor.
bool hasSameSign() const
An icmp instruction, which can be marked as "samesign", indicating that the two operands have the sam...
static bool classof(const Value *V)
void setSameSign(bool B=true)
ICmpInst(InsertPosition InsertBefore, Predicate pred, Value *LHS, Value *RHS, const Twine &NameStr="")
Constructor with insertion semantics.
static bool isCommutative(Predicate P)
static CmpPredicate getSwappedCmpPredicate(CmpPredicate Pred)
CmpPredicate getCmpPredicate() const
bool isCommutative() const
static bool isGE(Predicate P)
Return true if the predicate is SGE or UGE.
CmpPredicate getSwappedCmpPredicate() const
static bool isLT(Predicate P)
Return true if the predicate is SLT or ULT.
CmpPredicate getInverseCmpPredicate() const
static bool isGT(Predicate P)
Return true if the predicate is SGT or UGT.
static bool classof(const Instruction *I)
Predicate getFlippedSignednessPredicate() const
For example, SLT->ULT, ULT->SLT, SLE->ULE, ULE->SLE, EQ->EQ.
Predicate getSignedPredicate() const
For example, EQ->EQ, SLE->SLE, UGT->SGT, etc.
static CmpPredicate getInverseCmpPredicate(CmpPredicate Pred)
bool isEquality() const
Return true if this predicate is either EQ or NE.
static bool isEquality(Predicate P)
Return true if this predicate is either EQ or NE.
static bool isRelational(Predicate P)
Return true if the predicate is relational (not EQ or NE).
void swapOperands()
Exchange the two operands to this instruction in such a way that it does not modify the semantics of ...
static auto predicates()
Returns the sequence of all ICmp predicates.
ICmpInst(Predicate pred, Value *LHS, Value *RHS, const Twine &NameStr="")
Constructor with no-insertion semantics.
bool isRelational() const
Return true if the predicate is relational (not EQ or NE).
Predicate getUnsignedPredicate() const
For example, EQ->EQ, SLE->ULE, UGT->UGT, etc.
static bool isLE(Predicate P)
Return true if the predicate is SLE or ULE.
Indirect Branch Instruction.
static IndirectBrInst * Create(Value *Address, unsigned NumDests, InsertPosition InsertBefore=nullptr)
BasicBlock * getDestination(unsigned i)
Return the specified destination.
static bool classof(const Value *V)
const Value * getAddress() const
static bool classof(const Instruction *I)
BasicBlock * getSuccessor(unsigned i) const
iterator_range< const_succ_op_iterator > successors() const
DECLARE_TRANSPARENT_OPERAND_ACCESSORS(Value)
Provide fast operand accessors.
unsigned getNumDestinations() const
return the number of possible destinations in this indirectbr instruction.
const BasicBlock * getDestination(unsigned i) const
void setSuccessor(unsigned i, BasicBlock *NewSucc)
void setAddress(Value *V)
unsigned getNumSuccessors() const
iterator_range< succ_op_iterator > successors()
This instruction inserts a single (scalar) element into a VectorType value.
static bool classof(const Value *V)
static InsertElementInst * Create(Value *Vec, Value *NewElt, Value *Idx, const Twine &NameStr="", InsertPosition InsertBefore=nullptr)
VectorType * getType() const
Overload to return most specific vector type.
static bool classof(const Instruction *I)
DECLARE_TRANSPARENT_OPERAND_ACCESSORS(Value)
Transparently provide more efficient getOperand methods.
This instruction inserts a struct field of array element value into an aggregate value.
Value * getInsertedValueOperand()
static bool classof(const Instruction *I)
static unsigned getAggregateOperandIndex()
Value * getAggregateOperand()
static bool classof(const Value *V)
unsigned getNumIndices() const
ArrayRef< unsigned > getIndices() const
iterator_range< idx_iterator > indices() const
static unsigned getInsertedValueOperandIndex()
InsertValueInst * cloneImpl() const
idx_iterator idx_end() const
static InsertValueInst * Create(Value *Agg, Value *Val, ArrayRef< unsigned > Idxs, const Twine &NameStr="", InsertPosition InsertBefore=nullptr)
DECLARE_TRANSPARENT_OPERAND_ACCESSORS(Value)
Transparently provide more efficient getOperand methods.
const Value * getAggregateOperand() const
const Value * getInsertedValueOperand() const
idx_iterator idx_begin() const
typename Bitfield::Element< AtomicOrdering, Offset, 3, AtomicOrdering::LAST > AtomicOrderingBitfieldElementT
typename Bitfield::Element< bool, Offset, 1 > BoolBitfieldElementT
bool isAtomic() const LLVM_READONLY
Return true if this instruction has an AtomicOrdering of unordered or higher.
typename Bitfield::Element< unsigned, Offset, 6, Value::MaxAlignmentExponent > AlignmentBitfieldElementT
unsigned getOpcode() const
Returns a member of one of the enums like Instruction::Add.
void copyMetadata(const Instruction &SrcInst, ArrayRef< unsigned > WL=ArrayRef< unsigned >())
Copy metadata from SrcInst to this instruction.
friend class BasicBlock
Various leaf nodes.
This class represents a cast from an integer to a pointer.
static bool classof(const Instruction *I)
IntToPtrInst * cloneImpl() const
Clone an identical IntToPtrInst.
unsigned getAddressSpace() const
Returns the address space of this instruction's pointer type.
static bool classof(const Value *V)
static bool classof(const Instruction *I)
BasicBlock * getUnwindDest() const
void setNormalDest(BasicBlock *B)
static bool classof(const Value *V)
static InvokeInst * Create(FunctionCallee Func, BasicBlock *IfNormal, BasicBlock *IfException, ArrayRef< Value * > Args, const Twine &NameStr, InsertPosition InsertBefore=nullptr)
void setSuccessor(unsigned i, BasicBlock *NewSucc)
static InvokeInst * Create(FunctionCallee Func, BasicBlock *IfNormal, BasicBlock *IfException, ArrayRef< Value * > Args, ArrayRef< OperandBundleDef > Bundles={}, const Twine &NameStr="", InsertPosition InsertBefore=nullptr)
BasicBlock * getSuccessor(unsigned i) const
void setUnwindDest(BasicBlock *B)
BasicBlock * getNormalDest() const
static InvokeInst * Create(FunctionType *Ty, Value *Func, BasicBlock *IfNormal, BasicBlock *IfException, ArrayRef< Value * > Args, ArrayRef< OperandBundleDef > Bundles={}, const Twine &NameStr="", InsertPosition InsertBefore=nullptr)
unsigned getNumSuccessors() const
static InvokeInst * Create(FunctionType *Ty, Value *Func, BasicBlock *IfNormal, BasicBlock *IfException, ArrayRef< Value * > Args, const Twine &NameStr, InsertPosition InsertBefore=nullptr)
This is an important class for using LLVM in a threaded context.
The landingpad instruction holds all of the information necessary to generate correct exception handl...
bool isCleanup() const
Return 'true' if this landingpad instruction is a cleanup.
unsigned getNumClauses() const
Get the number of clauses for this landing pad.
DECLARE_TRANSPARENT_OPERAND_ACCESSORS(Value)
Provide fast operand accessors.
bool isCatch(unsigned Idx) const
Return 'true' if the clause and index Idx is a catch clause.
bool isFilter(unsigned Idx) const
Return 'true' if the clause and index Idx is a filter clause.
Constant * getClause(unsigned Idx) const
Get the value of the clause at index Idx.
static bool classof(const Value *V)
void setCleanup(bool V)
Indicate that this landingpad instruction is a cleanup.
void reserveClauses(unsigned Size)
Grow the size of the operand list to accommodate the new number of clauses.
static bool classof(const Instruction *I)
An instruction for reading from memory.
unsigned getPointerAddressSpace() const
Returns the address space of the pointer operand.
const Value * getPointerOperand() const
void setAlignment(Align Align)
Value * getPointerOperand()
bool isVolatile() const
Return true if this is a load from a volatile memory location.
static bool classof(const Instruction *I)
void setOrdering(AtomicOrdering Ordering)
Sets the ordering constraint of this load instruction.
static bool classof(const Value *V)
void setSyncScopeID(SyncScope::ID SSID)
Sets the synchronization scope ID of this load instruction.
void setAtomic(AtomicOrdering Ordering, SyncScope::ID SSID=SyncScope::System)
Sets the ordering constraint and the synchronization scope ID of this load instruction.
LoadInst * cloneImpl() const
AtomicOrdering getOrdering() const
Returns the ordering constraint of this load instruction.
Type * getPointerOperandType() const
static unsigned getPointerOperandIndex()
void setVolatile(bool V)
Specify whether this is a volatile load or not.
SyncScope::ID getSyncScopeID() const
Returns the synchronization scope ID of this load instruction.
Align getAlign() const
Return the alignment of the access that is being performed.
MutableArrayRef - Represent a mutable reference to an array (0 or more elements consecutively in memo...
BasicBlock * getIncomingBlock(Value::const_user_iterator I) const
Return incoming basic block corresponding to value use iterator.
static bool classof(const Instruction *I)
Methods for support type inquiry through isa, cast, and dyn_cast:
void addIncoming(Value *V, BasicBlock *BB)
Add an incoming value to the end of the PHI list.
bool isComplete() const
If the PHI node is complete which means all of its parent's predecessors have incoming value in this ...
iterator_range< const_block_iterator > blocks() const
op_range incoming_values()
static bool classof(const Value *V)
void allocHungoffUses(unsigned N)
const_block_iterator block_begin() const
void setIncomingValueForBlock(const BasicBlock *BB, Value *V)
Set every incoming value(s) for block BB to V.
void setIncomingBlock(unsigned i, BasicBlock *BB)
BasicBlock *const * const_block_iterator
void setIncomingValue(unsigned i, Value *V)
static unsigned getOperandNumForIncomingValue(unsigned i)
void copyIncomingBlocks(iterator_range< const_block_iterator > BBRange, uint32_t ToIdx=0)
Copies the basic blocks from BBRange to the incoming basic block list of this PHINode,...
const_block_iterator block_end() const
Value * getIncomingValueForBlock(const BasicBlock *BB) const
BasicBlock * getIncomingBlock(unsigned i) const
Return incoming basic block number i.
DECLARE_TRANSPARENT_OPERAND_ACCESSORS(Value)
Provide fast operand accessors.
Value * getIncomingValue(unsigned i) const
Return incoming value number x.
static unsigned getIncomingValueNumForOperand(unsigned i)
const_op_range incoming_values() const
Value * removeIncomingValue(const BasicBlock *BB, bool DeletePHIIfEmpty=true)
void replaceIncomingBlockWith(const BasicBlock *Old, BasicBlock *New)
Replace every incoming basic block Old to basic block New.
BasicBlock * getIncomingBlock(const Use &U) const
Return incoming basic block corresponding to an operand of the PHI.
int getBasicBlockIndex(const BasicBlock *BB) const
Return the first index of the specified basic block in the value list for this PHI.
unsigned getNumIncomingValues() const
Return the number of incoming edges.
static PHINode * Create(Type *Ty, unsigned NumReservedValues, const Twine &NameStr="", InsertPosition InsertBefore=nullptr)
Constructors - NumReservedValues is a hint for the number of incoming edges that this phi node will h...
Class to represent pointers.
unsigned getAddressSpace() const
Return the address space of the Pointer type.
This class represents a cast from a pointer to an integer.
Value * getPointerOperand()
Gets the pointer operand.
unsigned getPointerAddressSpace() const
Returns the address space of the pointer operand.
static bool classof(const Value *V)
const Value * getPointerOperand() const
Gets the pointer operand.
static unsigned getPointerOperandIndex()
Gets the operand index of the pointer operand.
static bool classof(const Instruction *I)
PtrToIntInst * cloneImpl() const
Clone an identical PtrToIntInst.
Resume the propagation of an exception.
static ResumeInst * Create(Value *Exn, InsertPosition InsertBefore=nullptr)
DECLARE_TRANSPARENT_OPERAND_ACCESSORS(Value)
Provide fast operand accessors.
Value * getValue() const
Convenience accessor.
static bool classof(const Value *V)
unsigned getNumSuccessors() const
ResumeInst * cloneImpl() const
static bool classof(const Instruction *I)
Return a value (possibly void), from a function.
DECLARE_TRANSPARENT_OPERAND_ACCESSORS(Value)
Provide fast operand accessors.
unsigned getNumSuccessors() const
static bool classof(const Value *V)
static bool classof(const Instruction *I)
static ReturnInst * Create(LLVMContext &C, BasicBlock *InsertAtEnd)
Value * getReturnValue() const
Convenience accessor. Returns null if there is no return value.
static ReturnInst * Create(LLVMContext &C, Value *retVal=nullptr, InsertPosition InsertBefore=nullptr)
This class represents a sign extension of integer types.
static bool classof(const Value *V)
static bool classof(const Instruction *I)
Methods for support type inquiry through isa, cast, and dyn_cast:
SExtInst * cloneImpl() const
Clone an identical SExtInst.
This class represents a cast from signed integer to floating point.
SIToFPInst * cloneImpl() const
Clone an identical SIToFPInst.
static bool classof(const Instruction *I)
Methods for support type inquiry through isa, cast, and dyn_cast:
static bool classof(const Value *V)
This class represents the LLVM 'select' instruction.
static SelectInst * Create(Value *C, Value *S1, Value *S2, const Twine &NameStr="", InsertPosition InsertBefore=nullptr, Instruction *MDFrom=nullptr)
void setFalseValue(Value *V)
const Value * getFalseValue() const
void setTrueValue(Value *V)
OtherOps getOpcode() const
void swapValues()
Swap the true and false values of the select instruction.
const Value * getCondition() const
SelectInst * cloneImpl() const
DECLARE_TRANSPARENT_OPERAND_ACCESSORS(Value)
Transparently provide more efficient getOperand methods.
static const char * areInvalidOperands(Value *Cond, Value *True, Value *False)
Return a string if the specified operands are invalid for a select operation, otherwise return null.
static bool classof(const Value *V)
void setCondition(Value *V)
const Value * getTrueValue() const
static bool classof(const Instruction *I)
This instruction constructs a fixed permutation of two input vectors.
static bool classof(const Value *V)
static bool isInterleaveMask(ArrayRef< int > Mask, unsigned Factor, unsigned NumInputElts)
Constant * getShuffleMaskForBitcode() const
Return the mask for this instruction, for use in bitcode.
bool isSingleSource() const
Return true if this shuffle chooses elements from exactly one source vector without changing the leng...
bool changesLength() const
Return true if this shuffle returns a vector with a different number of elements than its source vect...
bool isExtractSubvectorMask(int &Index) const
Return true if this shuffle mask is an extract subvector mask.
ArrayRef< int > getShuffleMask() const
static bool isInsertSubvectorMask(const Constant *Mask, int NumSrcElts, int &NumSubElts, int &Index)
static bool isSingleSourceMask(const Constant *Mask, int NumSrcElts)
int getMaskValue(unsigned Elt) const
Return the shuffle mask value of this instruction for the given element index.
void getShuffleMask(SmallVectorImpl< int > &Result) const
Return the mask for this instruction as a vector of integers.
DECLARE_TRANSPARENT_OPERAND_ACCESSORS(Value)
Transparently provide more efficient getOperand methods.
static bool isDeInterleaveMaskOfFactor(ArrayRef< int > Mask, unsigned Factor)
VectorType * getType() const
Overload to return most specific vector type.
bool isInsertSubvectorMask(int &NumSubElts, int &Index) const
Return true if this shuffle mask is an insert subvector mask.
bool increasesLength() const
Return true if this shuffle returns a vector with a greater number of elements than its source vector...
bool isZeroEltSplat() const
Return true if all elements of this shuffle are the same value as the first element of exactly one so...
static bool isExtractSubvectorMask(const Constant *Mask, int NumSrcElts, int &Index)
bool isSelect() const
Return true if this shuffle chooses elements from its source vectors without lane crossings and all o...
static bool isSpliceMask(const Constant *Mask, int NumSrcElts, int &Index)
bool isTranspose() const
Return true if this shuffle transposes the elements of its inputs without changing the length of the ...
static void commuteShuffleMask(MutableArrayRef< int > Mask, unsigned InVecNumElts)
Change values in a shuffle permute mask assuming the two vector operands of length InVecNumElts have ...
bool isSplice(int &Index) const
Return true if this shuffle splices two inputs without changing the length of the vectors.
static bool isReverseMask(const Constant *Mask, int NumSrcElts)
static bool isSelectMask(const Constant *Mask, int NumSrcElts)
static bool classof(const Instruction *I)
static bool isZeroEltSplatMask(const Constant *Mask, int NumSrcElts)
bool isIdentity() const
Return true if this shuffle chooses elements from exactly one source vector without lane crossings an...
static bool isReplicationMask(const Constant *Mask, int &ReplicationFactor, int &VF)
static bool isIdentityMask(const Constant *Mask, int NumSrcElts)
static bool isTransposeMask(const Constant *Mask, int NumSrcElts)
bool isReverse() const
Return true if this shuffle swaps the order of elements from exactly one source vector.
This class consists of common code factored out of the SmallVector class to reduce code duplication b...
void push_back(const T &Elt)
This is a 'vector' (really, a variable-sized array), optimized for the case when the array is small.
An instruction for storing to memory.
static bool classof(const Instruction *I)
AtomicOrdering getOrdering() const
Returns the ordering constraint of this store instruction.
const Value * getPointerOperand() const
Type * getPointerOperandType() const
void setVolatile(bool V)
Specify whether this is a volatile store or not.
void setAlignment(Align Align)
const Value * getValueOperand() const
void setOrdering(AtomicOrdering Ordering)
Sets the ordering constraint of this store instruction.
Value * getValueOperand()
static bool classof(const Value *V)
DECLARE_TRANSPARENT_OPERAND_ACCESSORS(Value)
Transparently provide more efficient getOperand methods.
void setSyncScopeID(SyncScope::ID SSID)
Sets the synchronization scope ID of this store instruction.
StoreInst * cloneImpl() const
unsigned getPointerAddressSpace() const
Returns the address space of the pointer operand.
static unsigned getPointerOperandIndex()
SyncScope::ID getSyncScopeID() const
Returns the synchronization scope ID of this store instruction.
bool isVolatile() const
Return true if this is a store to a volatile memory location.
Value * getPointerOperand()
void setAtomic(AtomicOrdering Ordering, SyncScope::ID SSID=SyncScope::System)
Sets the ordering constraint and the synchronization scope ID of this store instruction.
StringRef - Represent a constant reference to a string, i.e.
A wrapper class to simplify modification of SwitchInst cases along with their prof branch_weights met...
void setSuccessorWeight(unsigned idx, CaseWeightOpt W)
Instruction::InstListType::iterator eraseFromParent()
Delegate the call to the underlying SwitchInst::eraseFromParent() and mark this object to not touch t...
void addCase(ConstantInt *OnVal, BasicBlock *Dest, CaseWeightOpt W)
Delegate the call to the underlying SwitchInst::addCase() and set the specified branch weight for the...
SwitchInstProfUpdateWrapper(SwitchInst &SI)
~SwitchInstProfUpdateWrapper()
CaseWeightOpt getSuccessorWeight(unsigned idx)
MDNode * buildProfBranchWeightsMD()
std::optional< uint32_t > CaseWeightOpt
SwitchInst * operator->()
SwitchInst::CaseIt removeCase(SwitchInst::CaseIt I)
Delegate the call to the underlying SwitchInst::removeCase() and remove correspondent branch weight.
A handle to a particular switch case.
unsigned getCaseIndex() const
Returns number of current case.
unsigned getSuccessorIndex() const
Returns successor index for current case successor.
BasicBlockT * getCaseSuccessor() const
Resolves successor for current case.
CaseHandleImpl(SwitchInstT *SI, ptrdiff_t Index)
bool operator==(const CaseHandleImpl &RHS) const
ConstantIntT * getCaseValue() const
Resolves case value for current case.
SwitchInstT SwitchInstType
CaseHandle(SwitchInst *SI, ptrdiff_t Index)
void setValue(ConstantInt *V) const
Sets the new value for current case.
void setSuccessor(BasicBlock *S) const
Sets the new successor for current case.
const CaseHandleT & operator*() const
CaseIteratorImpl()=default
Default constructed iterator is in an invalid state until assigned to a case for a particular switch.
CaseIteratorImpl & operator-=(ptrdiff_t N)
bool operator==(const CaseIteratorImpl &RHS) const
CaseIteratorImpl & operator+=(ptrdiff_t N)
ptrdiff_t operator-(const CaseIteratorImpl &RHS) const
bool operator<(const CaseIteratorImpl &RHS) const
CaseIteratorImpl(SwitchInstT *SI, unsigned CaseNum)
Initializes case iterator for given SwitchInst and for given case number.
static CaseIteratorImpl fromSuccessorIndex(SwitchInstT *SI, unsigned SuccessorIndex)
Initializes case iterator for given SwitchInst and for given successor index.
BasicBlock * getDefaultDest() const
CaseIt case_end()
Returns a read/write iterator that points one past the last in the SwitchInst.
BasicBlock * getSuccessor(unsigned idx) const
ConstCaseIt findCaseValue(const ConstantInt *C) const
DECLARE_TRANSPARENT_OPERAND_ACCESSORS(Value)
Provide fast operand accessors.
static SwitchInst * Create(Value *Value, BasicBlock *Default, unsigned NumCases, InsertPosition InsertBefore=nullptr)
void setCondition(Value *V)
ConstCaseIt case_begin() const
Returns a read-only iterator that points to the first case in the SwitchInst.
bool defaultDestUndefined() const
Returns true if the default branch must result in immediate undefined behavior, false otherwise.
iterator_range< ConstCaseIt > cases() const
Constant iteration adapter for range-for loops.
ConstantInt * findCaseDest(BasicBlock *BB)
Finds the unique case value for a given successor.
void setSuccessor(unsigned idx, BasicBlock *NewSucc)
static bool classof(const Value *V)
unsigned getNumSuccessors() const
CaseIt case_default()
Returns an iterator that points to the default case.
void setDefaultDest(BasicBlock *DefaultCase)
unsigned getNumCases() const
Return the number of 'cases' in this switch instruction, excluding the default case.
CaseIt findCaseValue(const ConstantInt *C)
Search all of the case values for the specified constant.
Value * getCondition() const
ConstCaseIt case_default() const
CaseIt case_begin()
Returns a read/write iterator that points to the first case in the SwitchInst.
static bool classof(const Instruction *I)
iterator_range< CaseIt > cases()
Iteration adapter for range-for loops.
ConstCaseIt case_end() const
Returns a read-only iterator that points one past the last in the SwitchInst.
This class represents a truncation of integer types.
void setHasNoSignedWrap(bool B)
static bool classof(const Instruction *I)
Methods for support type inquiry through isa, cast, and dyn_cast:
TruncInst * cloneImpl() const
Clone an identical TruncInst.
void setHasNoUnsignedWrap(bool B)
unsigned getNoWrapKind() const
Returns the no-wrap kind of the operation.
bool hasNoSignedWrap() const
Test whether this operation is known to never undergo signed overflow, aka the nsw property.
static bool classof(const Value *V)
bool hasNoUnsignedWrap() const
Test whether this operation is known to never undergo unsigned overflow, aka the nuw property.
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.
bool isVectorTy() const
True if this is an instance of VectorType.
unsigned getPointerAddressSpace() const
Get the address space of this pointer or pointer vector type.
bool isTokenTy() const
Return true if this is 'token'.
This class represents a cast unsigned integer to floating point.
static bool classof(const Value *V)
UIToFPInst * cloneImpl() const
Clone an identical UIToFPInst.
static bool classof(const Instruction *I)
Methods for support type inquiry through isa, cast, and dyn_cast:
This function has undefined behavior.
unsigned getNumSuccessors() const
static bool classof(const Value *V)
static bool classof(const Instruction *I)
A Use represents the edge between a Value definition and its users.
void allocHungoffUses(unsigned N, bool IsPhi=false)
Allocate the array of Uses, followed by a pointer (with bottom bit set) to the User.
const Use & getOperandUse(unsigned i) const
Value * getOperand(unsigned i) const
unsigned getNumOperands() const
This class represents the va_arg llvm instruction, which returns an argument of the specified type gi...
static bool classof(const Instruction *I)
Value * getPointerOperand()
VAArgInst(Value *List, Type *Ty, const Twine &NameStr="", InsertPosition InsertBefore=nullptr)
const Value * getPointerOperand() const
static bool classof(const Value *V)
static unsigned getPointerOperandIndex()
LLVM Value Representation.
Type * getType() const
All values are typed, get the type of this value.
user_iterator_impl< const User > const_user_iterator
unsigned char SubclassOptionalData
Hold subclass data that can be dropped.
void setName(const Twine &Name)
Change the name of the value.
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.
This class represents zero extension of integer types.
static bool classof(const Instruction *I)
Methods for support type inquiry through isa, cast, and dyn_cast:
static bool classof(const Value *V)
ZExtInst * cloneImpl() const
Clone an identical ZExtInst.
An efficient, type-erasing, non-owning reference to a callable.
base_list_type::iterator iterator
CRTP base class for adapting an iterator to a different type.
CRTP base class which implements the entire standard iterator facade in terms of a minimal subset of ...
A range adaptor for a pair of iterators.
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.
constexpr char Args[]
Key for Kernel::Metadata::mArgs.
@ C
The default llvm calling convention, compatible with C.
@ BasicBlock
Various leaf nodes.
@ System
Synchronized with respect to all concurrently executing threads.
initializer< Ty > init(const Ty &Val)
This is an optimization pass for GlobalISel generic memory operations.
Type * checkGEPType(Type *Ty)
bool all_of(R &&range, UnaryPredicate P)
Provide wrappers to std::all_of which take ranges instead of having to pass begin/end explicitly.
unsigned getLoadStoreAddressSpace(const Value *I)
A helper function that returns the address space of the pointer operand of load or store instruction.
APInt operator*(APInt a, uint64_t RHS)
const Value * getLoadStorePointerOperand(const Value *V)
A helper function that returns the pointer operand of a load or store instruction.
iterator_range< T > make_range(T x, T y)
Convenience function for iterating over sub-ranges.
void setAtomicSyncScopeID(Instruction *I, SyncScope::ID SSID)
A helper function that sets an atomic operation's sync scope.
Align getLoadStoreAlignment(const Value *I)
A helper function that returns the alignment of load or store instruction.
const Value * getPointerOperand(const Value *V)
A helper function that returns the pointer operand of a load, store or GEP instruction.
decltype(auto) get(const PointerIntPair< PointerTy, IntBits, IntType, PtrTraits, Info > &Pair)
std::optional< SyncScope::ID > getAtomicSyncScopeID(const Instruction *I)
A helper function that returns an atomic operation's sync scope; returns std::nullopt if it is not an...
constexpr int PoisonMaskElem
AtomicOrdering
Atomic ordering for LLVM's memory model.
DWARFExpression::Operation Op
OutputIt copy(R &&Range, OutputIt Out)
constexpr unsigned BitWidth
auto find_if(R &&Range, UnaryPredicate P)
Provide wrappers to std::find_if which take ranges instead of having to pass begin/end explicitly.
auto predecessors(const MachineBasicBlock *BB)
Type * getLoadStoreType(const Value *I)
A helper function that returns the type of a load or store instruction.
void setLoadStoreAlignment(Value *I, Align NewAlign)
A helper function that set the alignment of load or store instruction.
unsigned Log2(Align A)
Returns the log2 of the alignment.
@ Default
The result values are uniform if and only if all operands are uniform.
This struct is a compact representation of a valid (non-zero power of two) alignment.
Summary of memprof metadata on allocations.
Describes an element of a Bitfield.
static constexpr bool areContiguous()
The const version of succ_op_iterator.
const BasicBlock * operator->() const
const_succ_op_iterator(const_value_op_iterator I)
const BasicBlock * operator*() const
Iterator type that casts an operand to a basic block.
BasicBlock * operator->() const
succ_op_iterator(value_op_iterator I)
BasicBlock * operator*() const
FixedNumOperandTraits - determine the allocation regime of the Use array when it is a prefix to the U...
HungoffOperandTraits - determine the allocation regime of the Use array when it is not a prefix to th...
The const version of succ_op_iterator.
const BasicBlock * operator*() const
const_succ_op_iterator(const_value_op_iterator I)
const BasicBlock * operator->() const
Iterator type that casts an operand to a basic block.
BasicBlock * operator*() const
succ_op_iterator(value_op_iterator I)
BasicBlock * operator->() const
Compile-time customization of User operands.
A MapVector that performs no allocations if smaller than a certain size.
Information about how a User object was allocated, to be passed into the User constructor.
Indicates this User has operands "hung off" in another allocation.
Indicates this User has operands co-allocated.
Iterator for directly iterating over the operand Values.
VariadicOperandTraits - determine the allocation regime of the Use array when it is a prefix to the U...