Movatterモバイル変換


[0]ホーム

URL:


LLVM 20.0.0git
Instructions.h
Go to the documentation of this file.
1//===- llvm/Instructions.h - Instruction subclass definitions ---*- C++ -*-===//
2//
3// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4// See https://llvm.org/LICENSE.txt for license information.
5// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6//
7//===----------------------------------------------------------------------===//
8//
9// This file 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.
12//
13//===----------------------------------------------------------------------===//
14
15#ifndef LLVM_IR_INSTRUCTIONS_H
16#define LLVM_IR_INSTRUCTIONS_H
17
18#include "llvm/ADT/ArrayRef.h"
19#include "llvm/ADT/Bitfields.h"
20#include "llvm/ADT/MapVector.h"
21#include "llvm/ADT/STLExtras.h"
22#include "llvm/ADT/SmallVector.h"
23#include "llvm/ADT/Twine.h"
24#include "llvm/ADT/iterator.h"
25#include "llvm/ADT/iterator_range.h"
26#include "llvm/IR/CFG.h"
27#include "llvm/IR/CmpPredicate.h"
28#include "llvm/IR/Constant.h"
29#include "llvm/IR/DerivedTypes.h"
30#include "llvm/IR/GEPNoWrapFlags.h"
31#include "llvm/IR/InstrTypes.h"
32#include "llvm/IR/Instruction.h"
33#include "llvm/IR/Intrinsics.h"
34#include "llvm/IR/OperandTraits.h"
35#include "llvm/IR/Use.h"
36#include "llvm/IR/User.h"
37#include "llvm/Support/AtomicOrdering.h"
38#include "llvm/Support/ErrorHandling.h"
39#include <cassert>
40#include <cstddef>
41#include <cstdint>
42#include <iterator>
43#include <optional>
44
45namespacellvm {
46
47classAPFloat;
48classAPInt;
49classBasicBlock;
50classConstantInt;
51classDataLayout;
52structKnownBits;
53classStringRef;
54classType;
55classValue;
56classUnreachableInst;
57
58//===----------------------------------------------------------------------===//
59// AllocaInst Class
60//===----------------------------------------------------------------------===//
61
62/// an instruction to allocate memory on the stack
63classAllocaInst :publicUnaryInstruction {
64Type *AllocatedType;
65
66usingAlignmentField =AlignmentBitfieldElementT<0>;
67usingUsedWithInAllocaField =BoolBitfieldElementT<AlignmentField::NextBit>;
68usingSwiftErrorField =BoolBitfieldElementT<UsedWithInAllocaField::NextBit>;
69static_assert(Bitfield::areContiguous<AlignmentField, UsedWithInAllocaField,
70 SwiftErrorField>(),
71"Bitfields must be contiguous");
72
73protected:
74// Note: Instruction needs to be a friend here to call cloneImpl.
75friendclassInstruction;
76
77AllocaInst *cloneImpl()const;
78
79public:
80explicitAllocaInst(Type *Ty,unsigned AddrSpace,Value *ArraySize,
81constTwine &Name,InsertPosition InsertBefore);
82
83AllocaInst(Type *Ty,unsigned AddrSpace,constTwine &Name,
84InsertPosition InsertBefore);
85
86AllocaInst(Type *Ty,unsigned AddrSpace,Value *ArraySize,AlignAlign,
87constTwine &Name ="",InsertPosition InsertBefore =nullptr);
88
89 /// Return true if there is an allocation size parameter to the allocation
90 /// instruction that is not 1.
91boolisArrayAllocation()const;
92
93 /// Get the number of elements allocated. For a simple allocation of a single
94 /// element, this will return a constant 1 value.
95constValue *getArraySize() const{returngetOperand(0); }
96Value *getArraySize() {returngetOperand(0); }
97
98 /// Overload to return most specific pointer type.
99PointerType *getType() const{
100return cast<PointerType>(Instruction::getType());
101 }
102
103 /// Return the address space for the allocation.
104unsignedgetAddressSpace() const{
105returngetType()->getAddressSpace();
106 }
107
108 /// Get allocation size in bytes. Returns std::nullopt if size can't be
109 /// determined, e.g. in case of a VLA.
110 std::optional<TypeSize>getAllocationSize(constDataLayout &DL)const;
111
112 /// Get allocation size in bits. Returns std::nullopt if size can't be
113 /// determined, e.g. in case of a VLA.
114 std::optional<TypeSize>getAllocationSizeInBits(constDataLayout &DL)const;
115
116 /// Return the type that is being allocated by the instruction.
117Type *getAllocatedType() const{return AllocatedType; }
118 /// for use only in special circumstances that need to generically
119 /// transform a whole instruction (eg: IR linking and vectorization).
120voidsetAllocatedType(Type *Ty) { AllocatedType = Ty; }
121
122 /// Return the alignment of the memory that is being allocated by the
123 /// instruction.
124AligngetAlign() const{
125returnAlign(1ULL << getSubclassData<AlignmentField>());
126 }
127
128voidsetAlignment(AlignAlign) {
129 setSubclassData<AlignmentField>(Log2(Align));
130 }
131
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.
135boolisStaticAlloca()const;
136
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.
139boolisUsedWithInAlloca() const{
140return getSubclassData<UsedWithInAllocaField>();
141 }
142
143 /// Specify whether this alloca is used to represent the arguments to a call.
144voidsetUsedWithInAlloca(bool V) {
145 setSubclassData<UsedWithInAllocaField>(V);
146 }
147
148 /// Return true if this alloca is used as a swifterror argument to a call.
149boolisSwiftError() const{return getSubclassData<SwiftErrorField>(); }
150 /// Specify whether this alloca is used to represent a swifterror.
151voidsetSwiftError(bool V) { setSubclassData<SwiftErrorField>(V); }
152
153// Methods for support type inquiry through isa, cast, and dyn_cast:
154staticboolclassof(constInstruction *I) {
155return (I->getOpcode() == Instruction::Alloca);
156 }
157staticboolclassof(constValue *V) {
158return isa<Instruction>(V) &&classof(cast<Instruction>(V));
159 }
160
161private:
162// Shadow Instruction::setInstructionSubclassData with a private forwarding
163// method so that subclasses cannot accidentally use it.
164template <typename Bitfield>
165void setSubclassData(typename Bitfield::TypeValue) {
166 Instruction::setSubclassData<Bitfield>(Value);
167 }
168};
169
170//===----------------------------------------------------------------------===//
171// LoadInst Class
172//===----------------------------------------------------------------------===//
173
174/// An instruction for reading from memory. This uses the SubclassData field in
175/// Value to store whether or not the load is volatile.
176classLoadInst :publicUnaryInstruction {
177usingVolatileField =BoolBitfieldElementT<0>;
178usingAlignmentField =AlignmentBitfieldElementT<VolatileField::NextBit>;
179usingOrderingField =AtomicOrderingBitfieldElementT<AlignmentField::NextBit>;
180static_assert(
181 Bitfield::areContiguous<VolatileField, AlignmentField, OrderingField>(),
182"Bitfields must be contiguous");
183
184void AssertOK();
185
186protected:
187// Note: Instruction needs to be a friend here to call cloneImpl.
188friendclassInstruction;
189
190LoadInst *cloneImpl()const;
191
192public:
193LoadInst(Type *Ty,Value *Ptr,constTwine &NameStr,
194InsertPosition InsertBefore);
195LoadInst(Type *Ty,Value *Ptr,constTwine &NameStr,boolisVolatile,
196InsertPosition InsertBefore);
197LoadInst(Type *Ty,Value *Ptr,constTwine &NameStr,boolisVolatile,
198AlignAlign,InsertPosition InsertBefore =nullptr);
199LoadInst(Type *Ty,Value *Ptr,constTwine &NameStr,boolisVolatile,
200AlignAlign,AtomicOrdering Order,
201SyncScope::ID SSID =SyncScope::System,
202InsertPosition InsertBefore =nullptr);
203
204 /// Return true if this is a load from a volatile memory location.
205boolisVolatile() const{return getSubclassData<VolatileField>(); }
206
207 /// Specify whether this is a volatile load or not.
208voidsetVolatile(bool V) { setSubclassData<VolatileField>(V); }
209
210 /// Return the alignment of the access that is being performed.
211AligngetAlign() const{
212returnAlign(1ULL << (getSubclassData<AlignmentField>()));
213 }
214
215voidsetAlignment(AlignAlign) {
216 setSubclassData<AlignmentField>(Log2(Align));
217 }
218
219 /// Returns the ordering constraint of this load instruction.
220AtomicOrderinggetOrdering() const{
221return getSubclassData<OrderingField>();
222 }
223 /// Sets the ordering constraint of this load instruction. May not be Release
224 /// or AcquireRelease.
225voidsetOrdering(AtomicOrdering Ordering) {
226 setSubclassData<OrderingField>(Ordering);
227 }
228
229 /// Returns the synchronization scope ID of this load instruction.
230SyncScope::IDgetSyncScopeID() const{
231return SSID;
232 }
233
234 /// Sets the synchronization scope ID of this load instruction.
235voidsetSyncScopeID(SyncScope::ID SSID) {
236 this->SSID = SSID;
237 }
238
239 /// Sets the ordering constraint and the synchronization scope ID of this load
240 /// instruction.
241voidsetAtomic(AtomicOrdering Ordering,
242SyncScope::ID SSID =SyncScope::System) {
243setOrdering(Ordering);
244setSyncScopeID(SSID);
245 }
246
247boolisSimple() const{return !isAtomic() && !isVolatile(); }
248
249boolisUnordered() const{
250return (getOrdering() ==AtomicOrdering::NotAtomic ||
251getOrdering() ==AtomicOrdering::Unordered) &&
252 !isVolatile();
253 }
254
255Value *getPointerOperand() {returngetOperand(0); }
256constValue *getPointerOperand() const{returngetOperand(0); }
257staticunsignedgetPointerOperandIndex() {return 0U; }
258Type *getPointerOperandType() const{returngetPointerOperand()->getType(); }
259
260 /// Returns the address space of the pointer operand.
261unsignedgetPointerAddressSpace() const{
262returngetPointerOperandType()->getPointerAddressSpace();
263 }
264
265// Methods for support type inquiry through isa, cast, and dyn_cast:
266staticboolclassof(constInstruction *I) {
267returnI->getOpcode() == Instruction::Load;
268 }
269staticboolclassof(constValue *V) {
270return isa<Instruction>(V) &&classof(cast<Instruction>(V));
271 }
272
273private:
274// Shadow Instruction::setInstructionSubclassData with a private forwarding
275// method so that subclasses cannot accidentally use it.
276template <typename Bitfield>
277void setSubclassData(typename Bitfield::TypeValue) {
278 Instruction::setSubclassData<Bitfield>(Value);
279 }
280
281 /// The synchronization scope ID of this load instruction. Not quite enough
282 /// room in SubClassData for everything, so synchronization scope ID gets its
283 /// own field.
284SyncScope::ID SSID;
285};
286
287//===----------------------------------------------------------------------===//
288// StoreInst Class
289//===----------------------------------------------------------------------===//
290
291/// An instruction for storing to memory.
292classStoreInst :publicInstruction {
293usingVolatileField =BoolBitfieldElementT<0>;
294usingAlignmentField =AlignmentBitfieldElementT<VolatileField::NextBit>;
295usingOrderingField =AtomicOrderingBitfieldElementT<AlignmentField::NextBit>;
296static_assert(
297 Bitfield::areContiguous<VolatileField, AlignmentField, OrderingField>(),
298"Bitfields must be contiguous");
299
300void AssertOK();
301
302constexprstaticIntrusiveOperandsAllocMarker AllocMarker{2};
303
304protected:
305// Note: Instruction needs to be a friend here to call cloneImpl.
306friendclassInstruction;
307
308StoreInst *cloneImpl()const;
309
310public:
311StoreInst(Value *Val,Value *Ptr,InsertPosition InsertBefore);
312StoreInst(Value *Val,Value *Ptr,boolisVolatile,
313InsertPosition InsertBefore);
314StoreInst(Value *Val,Value *Ptr,boolisVolatile,AlignAlign,
315InsertPosition InsertBefore =nullptr);
316StoreInst(Value *Val,Value *Ptr,boolisVolatile,AlignAlign,
317AtomicOrdering Order,SyncScope::ID SSID =SyncScope::System,
318InsertPosition InsertBefore =nullptr);
319
320// allocate space for exactly two operands
321void *operatornew(size_t S) {return User::operatornew(S, AllocMarker); }
322voidoperatordelete(void *Ptr) { User::operatordelete(Ptr); }
323
324 /// Return true if this is a store to a volatile memory location.
325boolisVolatile() const{return getSubclassData<VolatileField>(); }
326
327 /// Specify whether this is a volatile store or not.
328voidsetVolatile(bool V) { setSubclassData<VolatileField>(V); }
329
330 /// Transparently provide more efficient getOperand methods.
331DECLARE_TRANSPARENT_OPERAND_ACCESSORS(Value);
332
333AligngetAlign() const{
334returnAlign(1ULL << (getSubclassData<AlignmentField>()));
335 }
336
337voidsetAlignment(AlignAlign) {
338 setSubclassData<AlignmentField>(Log2(Align));
339 }
340
341 /// Returns the ordering constraint of this store instruction.
342AtomicOrderinggetOrdering() const{
343return getSubclassData<OrderingField>();
344 }
345
346 /// Sets the ordering constraint of this store instruction. May not be
347 /// Acquire or AcquireRelease.
348voidsetOrdering(AtomicOrdering Ordering) {
349 setSubclassData<OrderingField>(Ordering);
350 }
351
352 /// Returns the synchronization scope ID of this store instruction.
353SyncScope::IDgetSyncScopeID() const{
354return SSID;
355 }
356
357 /// Sets the synchronization scope ID of this store instruction.
358voidsetSyncScopeID(SyncScope::ID SSID) {
359 this->SSID = SSID;
360 }
361
362 /// Sets the ordering constraint and the synchronization scope ID of this
363 /// store instruction.
364voidsetAtomic(AtomicOrdering Ordering,
365SyncScope::ID SSID =SyncScope::System) {
366setOrdering(Ordering);
367setSyncScopeID(SSID);
368 }
369
370boolisSimple() const{return !isAtomic() && !isVolatile(); }
371
372boolisUnordered() const{
373return (getOrdering() ==AtomicOrdering::NotAtomic ||
374getOrdering() ==AtomicOrdering::Unordered) &&
375 !isVolatile();
376 }
377
378Value *getValueOperand() {returngetOperand(0); }
379constValue *getValueOperand() const{returngetOperand(0); }
380
381Value *getPointerOperand() {returngetOperand(1); }
382constValue *getPointerOperand() const{returngetOperand(1); }
383staticunsignedgetPointerOperandIndex() {return 1U; }
384Type *getPointerOperandType() const{returngetPointerOperand()->getType(); }
385
386 /// Returns the address space of the pointer operand.
387unsignedgetPointerAddressSpace() const{
388returngetPointerOperandType()->getPointerAddressSpace();
389 }
390
391// Methods for support type inquiry through isa, cast, and dyn_cast:
392staticboolclassof(constInstruction *I) {
393returnI->getOpcode() == Instruction::Store;
394 }
395staticboolclassof(constValue *V) {
396return isa<Instruction>(V) &&classof(cast<Instruction>(V));
397 }
398
399private:
400// Shadow Instruction::setInstructionSubclassData with a private forwarding
401// method so that subclasses cannot accidentally use it.
402template <typename Bitfield>
403void setSubclassData(typename Bitfield::TypeValue) {
404 Instruction::setSubclassData<Bitfield>(Value);
405 }
406
407 /// The synchronization scope ID of this store instruction. Not quite enough
408 /// room in SubClassData for everything, so synchronization scope ID gets its
409 /// own field.
410SyncScope::ID SSID;
411};
412
413template <>
414structOperandTraits<StoreInst> :publicFixedNumOperandTraits<StoreInst, 2> {
415};
416
417DEFINE_TRANSPARENT_OPERAND_ACCESSORS(StoreInst,Value)
418
419//===----------------------------------------------------------------------===//
420// FenceInst Class
421//===----------------------------------------------------------------------===//
422
423/// An instruction for ordering other memory operations.
424classFenceInst : publicInstruction {
425usingOrderingField =AtomicOrderingBitfieldElementT<0>;
426
427constexprstaticIntrusiveOperandsAllocMarker AllocMarker{0};
428
429voidInit(AtomicOrdering Ordering,SyncScope::ID SSID);
430
431protected:
432// Note: Instruction needs to be a friend here to call cloneImpl.
433friendclassInstruction;
434
435FenceInst *cloneImpl()const;
436
437public:
438// Ordering may only be Acquire, Release, AcquireRelease, or
439// SequentiallyConsistent.
440FenceInst(LLVMContext &C,AtomicOrdering Ordering,
441SyncScope::ID SSID =SyncScope::System,
442InsertPosition InsertBefore =nullptr);
443
444// allocate space for exactly zero operands
445void *operatornew(size_t S) {return User::operatornew(S, AllocMarker); }
446voidoperatordelete(void *Ptr) { User::operatordelete(Ptr); }
447
448 /// Returns the ordering constraint of this fence instruction.
449AtomicOrderinggetOrdering() const{
450return getSubclassData<OrderingField>();
451 }
452
453 /// Sets the ordering constraint of this fence instruction. May only be
454 /// Acquire, Release, AcquireRelease, or SequentiallyConsistent.
455voidsetOrdering(AtomicOrdering Ordering) {
456 setSubclassData<OrderingField>(Ordering);
457 }
458
459 /// Returns the synchronization scope ID of this fence instruction.
460SyncScope::IDgetSyncScopeID() const{
461return SSID;
462 }
463
464 /// Sets the synchronization scope ID of this fence instruction.
465voidsetSyncScopeID(SyncScope::ID SSID) {
466 this->SSID = SSID;
467 }
468
469// Methods for support type inquiry through isa, cast, and dyn_cast:
470staticboolclassof(constInstruction *I) {
471returnI->getOpcode() == Instruction::Fence;
472 }
473staticboolclassof(constValue *V) {
474return isa<Instruction>(V) && classof(cast<Instruction>(V));
475 }
476
477private:
478// Shadow Instruction::setInstructionSubclassData with a private forwarding
479// method so that subclasses cannot accidentally use it.
480template <typename Bitfield>
481void setSubclassData(typename Bitfield::TypeValue) {
482 Instruction::setSubclassData<Bitfield>(Value);
483 }
484
485 /// The synchronization scope ID of this fence instruction. Not quite enough
486 /// room in SubClassData for everything, so synchronization scope ID gets its
487 /// own field.
488SyncScope::ID SSID;
489};
490
491//===----------------------------------------------------------------------===//
492// AtomicCmpXchgInst Class
493//===----------------------------------------------------------------------===//
494
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.
500///
501classAtomicCmpXchgInst :publicInstruction {
502voidInit(Value *Ptr,Value *Cmp,Value *NewVal,AlignAlign,
503AtomicOrdering SuccessOrdering,AtomicOrdering FailureOrdering,
504SyncScope::ID SSID);
505
506template <unsigned Offset>
507usingAtomicOrderingBitfieldElement =
508typenameBitfield::Element<AtomicOrdering,Offset, 3,
509AtomicOrdering::LAST>;
510
511constexprstaticIntrusiveOperandsAllocMarker AllocMarker{3};
512
513protected:
514// Note: Instruction needs to be a friend here to call cloneImpl.
515friendclassInstruction;
516
517AtomicCmpXchgInst *cloneImpl()const;
518
519public:
520AtomicCmpXchgInst(Value *Ptr,Value *Cmp,Value *NewVal,Align Alignment,
521AtomicOrdering SuccessOrdering,
522AtomicOrdering FailureOrdering,SyncScope::ID SSID,
523InsertPosition InsertBefore =nullptr);
524
525// allocate space for exactly three operands
526void *operatornew(size_t S) {return User::operatornew(S, AllocMarker); }
527voidoperatordelete(void *Ptr) { User::operatordelete(Ptr); }
528
529usingVolatileField =BoolBitfieldElementT<0>;
530usingWeakField =BoolBitfieldElementT<VolatileField::NextBit>;
531usingSuccessOrderingField =
532AtomicOrderingBitfieldElementT<WeakField::NextBit>;
533usingFailureOrderingField =
534AtomicOrderingBitfieldElementT<SuccessOrderingField::NextBit>;
535usingAlignmentField =
536AlignmentBitfieldElementT<FailureOrderingField::NextBit>;
537static_assert(
538Bitfield::areContiguous<VolatileField,WeakField,SuccessOrderingField,
539FailureOrderingField,AlignmentField>(),
540"Bitfields must be contiguous");
541
542 /// Return the alignment of the memory that is being allocated by the
543 /// instruction.
544AligngetAlign() const{
545returnAlign(1ULL << getSubclassData<AlignmentField>());
546 }
547
548voidsetAlignment(AlignAlign) {
549 setSubclassData<AlignmentField>(Log2(Align));
550 }
551
552 /// Return true if this is a cmpxchg from a volatile memory
553 /// location.
554 ///
555boolisVolatile() const{return getSubclassData<VolatileField>(); }
556
557 /// Specify whether this is a volatile cmpxchg.
558 ///
559voidsetVolatile(bool V) { setSubclassData<VolatileField>(V); }
560
561 /// Return true if this cmpxchg may spuriously fail.
562boolisWeak() const{return getSubclassData<WeakField>(); }
563
564voidsetWeak(bool IsWeak) { setSubclassData<WeakField>(IsWeak); }
565
566 /// Transparently provide more efficient getOperand methods.
567DECLARE_TRANSPARENT_OPERAND_ACCESSORS(Value);
568
569staticboolisValidSuccessOrdering(AtomicOrdering Ordering) {
570return Ordering !=AtomicOrdering::NotAtomic &&
571 Ordering !=AtomicOrdering::Unordered;
572 }
573
574staticboolisValidFailureOrdering(AtomicOrdering Ordering) {
575return Ordering !=AtomicOrdering::NotAtomic &&
576 Ordering !=AtomicOrdering::Unordered &&
577 Ordering !=AtomicOrdering::AcquireRelease &&
578 Ordering !=AtomicOrdering::Release;
579 }
580
581 /// Returns the success ordering constraint of this cmpxchg instruction.
582AtomicOrderinggetSuccessOrdering() const{
583return getSubclassData<SuccessOrderingField>();
584 }
585
586 /// Sets the success ordering constraint of this cmpxchg instruction.
587voidsetSuccessOrdering(AtomicOrdering Ordering) {
588assert(isValidSuccessOrdering(Ordering) &&
589"invalid CmpXchg success ordering");
590 setSubclassData<SuccessOrderingField>(Ordering);
591 }
592
593 /// Returns the failure ordering constraint of this cmpxchg instruction.
594AtomicOrderinggetFailureOrdering() const{
595return getSubclassData<FailureOrderingField>();
596 }
597
598 /// Sets the failure ordering constraint of this cmpxchg instruction.
599voidsetFailureOrdering(AtomicOrdering Ordering) {
600assert(isValidFailureOrdering(Ordering) &&
601"invalid CmpXchg failure ordering");
602 setSubclassData<FailureOrderingField>(Ordering);
603 }
604
605 /// Returns a single ordering which is at least as strong as both the
606 /// success and failure orderings for this cmpxchg.
607AtomicOrderinggetMergedOrdering() const{
608if (getFailureOrdering() ==AtomicOrdering::SequentiallyConsistent)
609returnAtomicOrdering::SequentiallyConsistent;
610if (getFailureOrdering() ==AtomicOrdering::Acquire) {
611if (getSuccessOrdering() ==AtomicOrdering::Monotonic)
612returnAtomicOrdering::Acquire;
613if (getSuccessOrdering() ==AtomicOrdering::Release)
614returnAtomicOrdering::AcquireRelease;
615 }
616returngetSuccessOrdering();
617 }
618
619 /// Returns the synchronization scope ID of this cmpxchg instruction.
620SyncScope::IDgetSyncScopeID() const{
621return SSID;
622 }
623
624 /// Sets the synchronization scope ID of this cmpxchg instruction.
625voidsetSyncScopeID(SyncScope::ID SSID) {
626 this->SSID = SSID;
627 }
628
629Value *getPointerOperand() {returngetOperand(0); }
630constValue *getPointerOperand() const{returngetOperand(0); }
631staticunsignedgetPointerOperandIndex() {return 0U; }
632
633Value *getCompareOperand() {returngetOperand(1); }
634constValue *getCompareOperand() const{returngetOperand(1); }
635
636Value *getNewValOperand() {returngetOperand(2); }
637constValue *getNewValOperand() const{returngetOperand(2); }
638
639 /// Returns the address space of the pointer operand.
640unsignedgetPointerAddressSpace() const{
641returngetPointerOperand()->getType()->getPointerAddressSpace();
642 }
643
644 /// Returns the strongest permitted ordering on failure, given the
645 /// desired ordering on success.
646 ///
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.
651staticAtomicOrdering
652getStrongestFailureOrdering(AtomicOrdering SuccessOrdering) {
653switch (SuccessOrdering) {
654default:
655llvm_unreachable("invalid cmpxchg success ordering");
656caseAtomicOrdering::Release:
657caseAtomicOrdering::Monotonic:
658returnAtomicOrdering::Monotonic;
659caseAtomicOrdering::AcquireRelease:
660caseAtomicOrdering::Acquire:
661returnAtomicOrdering::Acquire;
662caseAtomicOrdering::SequentiallyConsistent:
663returnAtomicOrdering::SequentiallyConsistent;
664 }
665 }
666
667// Methods for support type inquiry through isa, cast, and dyn_cast:
668staticboolclassof(constInstruction *I) {
669returnI->getOpcode() == Instruction::AtomicCmpXchg;
670 }
671staticboolclassof(constValue *V) {
672return isa<Instruction>(V) &&classof(cast<Instruction>(V));
673 }
674
675private:
676// Shadow Instruction::setInstructionSubclassData with a private forwarding
677// method so that subclasses cannot accidentally use it.
678template <typename Bitfield>
679void setSubclassData(typename Bitfield::TypeValue) {
680 Instruction::setSubclassData<Bitfield>(Value);
681 }
682
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.
686SyncScope::ID SSID;
687};
688
689template <>
690structOperandTraits<AtomicCmpXchgInst> :
691publicFixedNumOperandTraits<AtomicCmpXchgInst, 3> {
692};
693
694DEFINE_TRANSPARENT_OPERAND_ACCESSORS(AtomicCmpXchgInst,Value)
695
696//===----------------------------------------------------------------------===//
697// AtomicRMWInst Class
698//===----------------------------------------------------------------------===//
699
700/// an instruction that atomically reads a memory location,
701/// combines it with another value, and then stores the result back. Returns
702/// the old value.
703///
704classAtomicRMWInst : publicInstruction {
705protected:
706// Note: Instruction needs to be a friend here to call cloneImpl.
707friendclassInstruction;
708
709AtomicRMWInst *cloneImpl()const;
710
711public:
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'.
716enumBinOp :unsigned {
717 /// *p = v
718Xchg,
719 /// *p = old + v
720Add,
721 /// *p = old - v
722Sub,
723 /// *p = old & v
724And,
725 /// *p = ~(old & v)
726Nand,
727 /// *p = old | v
728Or,
729 /// *p = old ^ v
730Xor,
731 /// *p = old >signed v ? old : v
732Max,
733 /// *p = old <signed v ? old : v
734Min,
735 /// *p = old >unsigned v ? old : v
736UMax,
737 /// *p = old <unsigned v ? old : v
738UMin,
739
740 /// *p = old + v
741FAdd,
742
743 /// *p = old - v
744FSub,
745
746 /// *p = maxnum(old, v)
747 /// \p maxnum matches the behavior of \p llvm.maxnum.*.
748FMax,
749
750 /// *p = minnum(old, v)
751 /// \p minnum matches the behavior of \p llvm.minnum.*.
752FMin,
753
754 /// Increment one up to a maximum value.
755 /// *p = (old u>= v) ? 0 : (old + 1)
756UIncWrap,
757
758 /// Decrement one until a minimum value or zero.
759 /// *p = ((old == 0) || (old u> v)) ? v : (old - 1)
760UDecWrap,
761
762 /// Subtract only if no unsigned overflow.
763 /// *p = (old u>= v) ? old - v : old
764USubCond,
765
766 /// *p = usub.sat(old, v)
767 /// \p usub.sat matches the behavior of \p llvm.usub.sat.*.
768USubSat,
769
770 FIRST_BINOP = Xchg,
771 LAST_BINOP = USubSat,
772 BAD_BINOP
773 };
774
775private:
776template <unsigned Offset>
777usingAtomicOrderingBitfieldElement =
778typenameBitfield::Element<AtomicOrdering,Offset, 3,
779AtomicOrdering::LAST>;
780
781template <unsigned Offset>
782usingBinOpBitfieldElement =
783typenameBitfield::Element<BinOp, Offset, 5, BinOp::LAST_BINOP>;
784
785constexprstatic IntrusiveOperandsAllocMarker AllocMarker{2};
786
787public:
788 AtomicRMWInst(BinOpOperation, Value *Ptr, Value *Val,Align Alignment,
789AtomicOrdering Ordering,SyncScope::ID SSID,
790 InsertPosition InsertBefore =nullptr);
791
792// allocate space for exactly two operands
793void *operatornew(size_t S) {return User::operatornew(S, AllocMarker); }
794voidoperatordelete(void *Ptr) { User::operatordelete(Ptr); }
795
796usingVolatileField =BoolBitfieldElementT<0>;
797usingAtomicOrderingField =
798AtomicOrderingBitfieldElementT<VolatileField::NextBit>;
799usingOperationField = BinOpBitfieldElement<AtomicOrderingField::NextBit>;
800usingAlignmentField =AlignmentBitfieldElementT<OperationField::NextBit>;
801static_assert(Bitfield::areContiguous<VolatileField,AtomicOrderingField,
802OperationField,AlignmentField>(),
803"Bitfields must be contiguous");
804
805BinOpgetOperation() const{return getSubclassData<OperationField>(); }
806
807staticStringRef getOperationName(BinOpOp);
808
809staticboolisFPOperation(BinOpOp) {
810switch (Op) {
811caseAtomicRMWInst::FAdd:
812caseAtomicRMWInst::FSub:
813caseAtomicRMWInst::FMax:
814caseAtomicRMWInst::FMin:
815returntrue;
816default:
817returnfalse;
818 }
819 }
820
821voidsetOperation(BinOpOperation) {
822 setSubclassData<OperationField>(Operation);
823 }
824
825 /// Return the alignment of the memory that is being allocated by the
826 /// instruction.
827AligngetAlign() const{
828returnAlign(1ULL << getSubclassData<AlignmentField>());
829 }
830
831voidsetAlignment(AlignAlign) {
832 setSubclassData<AlignmentField>(Log2(Align));
833 }
834
835 /// Return true if this is a RMW on a volatile memory location.
836 ///
837boolisVolatile() const{return getSubclassData<VolatileField>(); }
838
839 /// Specify whether this is a volatile RMW or not.
840 ///
841voidsetVolatile(bool V) { setSubclassData<VolatileField>(V); }
842
843 /// Transparently provide more efficient getOperand methods.
844DECLARE_TRANSPARENT_OPERAND_ACCESSORS(Value);
845
846 /// Returns the ordering constraint of this rmw instruction.
847AtomicOrderinggetOrdering() const{
848return getSubclassData<AtomicOrderingField>();
849 }
850
851 /// Sets the ordering constraint of this rmw instruction.
852voidsetOrdering(AtomicOrdering Ordering) {
853assert(Ordering !=AtomicOrdering::NotAtomic &&
854"atomicrmw instructions can only be atomic.");
855assert(Ordering !=AtomicOrdering::Unordered &&
856"atomicrmw instructions cannot be unordered.");
857 setSubclassData<AtomicOrderingField>(Ordering);
858 }
859
860 /// Returns the synchronization scope ID of this rmw instruction.
861SyncScope::IDgetSyncScopeID() const{
862return SSID;
863 }
864
865 /// Sets the synchronization scope ID of this rmw instruction.
866voidsetSyncScopeID(SyncScope::ID SSID) {
867 this->SSID = SSID;
868 }
869
870Value *getPointerOperand() {return getOperand(0); }
871constValue *getPointerOperand() const{return getOperand(0); }
872staticunsignedgetPointerOperandIndex() {return 0U; }
873
874Value *getValOperand() {return getOperand(1); }
875constValue *getValOperand() const{return getOperand(1); }
876
877 /// Returns the address space of the pointer operand.
878unsignedgetPointerAddressSpace() const{
879returngetPointerOperand()->getType()->getPointerAddressSpace();
880 }
881
882boolisFloatingPointOperation() const{
883return isFPOperation(getOperation());
884 }
885
886// Methods for support type inquiry through isa, cast, and dyn_cast:
887staticboolclassof(constInstruction *I) {
888returnI->getOpcode() == Instruction::AtomicRMW;
889 }
890staticboolclassof(constValue *V) {
891return isa<Instruction>(V) && classof(cast<Instruction>(V));
892 }
893
894private:
895voidInit(BinOpOperation,Value *Ptr,Value *Val,AlignAlign,
896AtomicOrdering Ordering,SyncScope::ID SSID);
897
898// Shadow Instruction::setInstructionSubclassData with a private forwarding
899// method so that subclasses cannot accidentally use it.
900template <typename Bitfield>
901void setSubclassData(typename Bitfield::TypeValue) {
902 Instruction::setSubclassData<Bitfield>(Value);
903 }
904
905 /// The synchronization scope ID of this rmw instruction. Not quite enough
906 /// room in SubClassData for everything, so synchronization scope ID gets its
907 /// own field.
908SyncScope::ID SSID;
909};
910
911template <>
912structOperandTraits<AtomicRMWInst>
913 :publicFixedNumOperandTraits<AtomicRMWInst,2> {
914};
915
916DEFINE_TRANSPARENT_OPERAND_ACCESSORS(AtomicRMWInst,Value)
917
918//===----------------------------------------------------------------------===//
919// GetElementPtrInst Class
920//===----------------------------------------------------------------------===//
921
922// checkGEPType - Simple wrapper function to give a better assertion failure
923// message on bad indexes for a gep instruction.
924//
925inlineType *checkGEPType(Type *Ty) {
926assert(Ty &&"Invalid GetElementPtrInst indices for type!");
927return Ty;
928}
929
930/// an instruction for type-safe pointer arithmetic to
931/// access elements of arrays and structs
932///
933classGetElementPtrInst :publicInstruction {
934Type *SourceElementType;
935Type *ResultElementType;
936
937GetElementPtrInst(constGetElementPtrInst &GEPI,AllocInfoAllocInfo);
938
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.
943inlineGetElementPtrInst(Type *PointeeType,Value *Ptr,
944ArrayRef<Value *> IdxList,AllocInfoAllocInfo,
945constTwine &NameStr,InsertPosition InsertBefore);
946
947void init(Value *Ptr,ArrayRef<Value *> IdxList,constTwine &NameStr);
948
949protected:
950// Note: Instruction needs to be a friend here to call cloneImpl.
951friendclassInstruction;
952
953GetElementPtrInst *cloneImpl()const;
954
955public:
956staticGetElementPtrInst *Create(Type *PointeeType,Value *Ptr,
957ArrayRef<Value *> IdxList,
958constTwine &NameStr ="",
959InsertPosition InsertBefore =nullptr) {
960unsigned Values = 1 +unsigned(IdxList.size());
961assert(PointeeType &&"Must specify element type");
962IntrusiveOperandsAllocMarker AllocMarker{Values};
963returnnew (AllocMarker)GetElementPtrInst(
964 PointeeType,Ptr, IdxList, AllocMarker, NameStr, InsertBefore);
965 }
966
967staticGetElementPtrInst *Create(Type *PointeeType,Value *Ptr,
968ArrayRef<Value *> IdxList,GEPNoWrapFlags NW,
969constTwine &NameStr ="",
970InsertPosition InsertBefore =nullptr) {
971GetElementPtrInst *GEP =
972Create(PointeeType,Ptr, IdxList, NameStr, InsertBefore);
973GEP->setNoWrapFlags(NW);
974returnGEP;
975 }
976
977 /// Create an "inbounds" getelementptr. See the documentation for the
978 /// "inbounds" flag in LangRef.html for details.
979staticGetElementPtrInst *
980CreateInBounds(Type *PointeeType,Value *Ptr,ArrayRef<Value *> IdxList,
981constTwine &NameStr ="",
982InsertPosition InsertBefore =nullptr) {
983returnCreate(PointeeType,Ptr, IdxList,GEPNoWrapFlags::inBounds(),
984 NameStr, InsertBefore);
985 }
986
987 /// Transparently provide more efficient getOperand methods.
988DECLARE_TRANSPARENT_OPERAND_ACCESSORS(Value);
989
990Type *getSourceElementType() const{return SourceElementType; }
991
992voidsetSourceElementType(Type *Ty) { SourceElementType = Ty; }
993voidsetResultElementType(Type *Ty) { ResultElementType = Ty; }
994
995Type *getResultElementType() const{
996return ResultElementType;
997 }
998
999 /// Returns the address space of this instruction's pointer type.
1000unsignedgetAddressSpace() const{
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.
1003returngetPointerAddressSpace();
1004 }
1005
1006 /// Returns the result type of a getelementptr with the given source
1007 /// element type and indexes.
1008 ///
1009 /// Null is returned if the indices are invalid for the specified
1010 /// source element type.
1011staticType *getIndexedType(Type *Ty,ArrayRef<Value *> IdxList);
1012staticType *getIndexedType(Type *Ty,ArrayRef<Constant *> IdxList);
1013staticType *getIndexedType(Type *Ty,ArrayRef<uint64_t> IdxList);
1014
1015 /// Return the type of the element at the given index of an indexable
1016 /// type. This is equivalent to "getIndexedType(Agg, {Zero, Idx})".
1017 ///
1018 /// Returns null if the type can't be indexed, or the given index is not
1019 /// legal for the given type.
1020staticType *getTypeAtIndex(Type *Ty,Value *Idx);
1021staticType *getTypeAtIndex(Type *Ty,uint64_tIdx);
1022
1023inlineop_iteratoridx_begin() {returnop_begin()+1; }
1024inlineconst_op_iteratoridx_begin() const{returnop_begin()+1; }
1025inlineop_iteratoridx_end() {returnop_end(); }
1026inlineconst_op_iteratoridx_end() const{returnop_end(); }
1027
1028inlineiterator_range<op_iterator>indices() {
1029returnmake_range(idx_begin(),idx_end());
1030 }
1031
1032inlineiterator_range<const_op_iterator>indices() const{
1033returnmake_range(idx_begin(),idx_end());
1034 }
1035
1036Value *getPointerOperand() {
1037returngetOperand(0);
1038 }
1039constValue *getPointerOperand() const{
1040returngetOperand(0);
1041 }
1042staticunsignedgetPointerOperandIndex() {
1043return 0U;// get index for modifying correct operand.
1044 }
1045
1046 /// Method to return the pointer operand as a
1047 /// PointerType.
1048Type *getPointerOperandType() const{
1049returngetPointerOperand()->getType();
1050 }
1051
1052 /// Returns the address space of the pointer operand.
1053unsignedgetPointerAddressSpace() const{
1054returngetPointerOperandType()->getPointerAddressSpace();
1055 }
1056
1057 /// Returns the pointer type returned by the GEP
1058 /// instruction, which may be a vector of pointers.
1059staticType *getGEPReturnType(Value *Ptr,ArrayRef<Value *> IdxList) {
1060// Vector GEP
1061Type *Ty =Ptr->getType();
1062if (Ty->isVectorTy())
1063return Ty;
1064
1065for (Value *Index : IdxList)
1066if (auto *IndexVTy = dyn_cast<VectorType>(Index->getType())) {
1067ElementCount EltCount = IndexVTy->getElementCount();
1068returnVectorType::get(Ty, EltCount);
1069 }
1070// Scalar GEP
1071return Ty;
1072 }
1073
1074unsignedgetNumIndices() const{// Note: always non-negative
1075returngetNumOperands() - 1;
1076 }
1077
1078boolhasIndices() const{
1079returngetNumOperands() > 1;
1080 }
1081
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.
1085boolhasAllZeroIndices()const;
1086
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.
1090boolhasAllConstantIndices()const;
1091
1092 /// Set nowrap flags for GEP instruction.
1093voidsetNoWrapFlags(GEPNoWrapFlags NW);
1094
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().
1098voidsetIsInBounds(bool b =true);
1099
1100 /// Get the nowrap flags for the GEP instruction.
1101GEPNoWrapFlagsgetNoWrapFlags()const;
1102
1103 /// Determine whether the GEP has the inbounds flag.
1104boolisInBounds()const;
1105
1106 /// Determine whether the GEP has the nusw flag.
1107boolhasNoUnsignedSignedWrap()const;
1108
1109 /// Determine whether the GEP has the nuw flag.
1110boolhasNoUnsignedWrap()const;
1111
1112 /// Accumulate the constant address offset of this GEP if possible.
1113 ///
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.
1120boolaccumulateConstantOffset(constDataLayout &DL,APInt &Offset)const;
1121boolcollectOffset(constDataLayout &DL,unsignedBitWidth,
1122SmallMapVector<Value *, APInt, 4> &VariableOffsets,
1123APInt &ConstantOffset)const;
1124// Methods for support type inquiry through isa, cast, and dyn_cast:
1125staticboolclassof(constInstruction *I) {
1126return (I->getOpcode() == Instruction::GetElementPtr);
1127 }
1128staticboolclassof(constValue *V) {
1129return isa<Instruction>(V) &&classof(cast<Instruction>(V));
1130 }
1131};
1132
1133template <>
1134structOperandTraits<GetElementPtrInst>
1135 :publicVariadicOperandTraits<GetElementPtrInst> {};
1136
1137GetElementPtrInst::GetElementPtrInst(Type *PointeeType,Value *Ptr,
1138ArrayRef<Value *> IdxList,
1139AllocInfoAllocInfo,constTwine &NameStr,
1140InsertPosition InsertBefore)
1141 :Instruction(getGEPReturnType(Ptr, IdxList), GetElementPtr,AllocInfo,
1142 InsertBefore),
1143 SourceElementType(PointeeType),
1144 ResultElementType(getIndexedType(PointeeType, IdxList)) {
1145 init(Ptr, IdxList, NameStr);
1146}
1147
1148DEFINE_TRANSPARENT_OPERAND_ACCESSORS(GetElementPtrInst, Value)
1149
1150//===----------------------------------------------------------------------===//
1151// ICmpInst Class
1152//===----------------------------------------------------------------------===//
1153
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.
1158classICmpInst: publicCmpInst {
1159void AssertOK() {
1160assert(isIntPredicate() &&
1161"Invalid ICmp predicate value");
1162assert(getOperand(0)->getType() == getOperand(1)->getType() &&
1163"Both operands to ICmp instruction are not of the same type!");
1164// Check that the operands are the right type
1165assert((getOperand(0)->getType()->isIntOrIntVectorTy() ||
1166 getOperand(0)->getType()->isPtrOrPtrVectorTy()) &&
1167"Invalid operand types for ICmp instruction");
1168 }
1169
1170enum { SameSign = (1 << 0) };
1171
1172protected:
1173// Note: Instruction needs to be a friend here to call cloneImpl.
1174friendclassInstruction;
1175
1176 /// Clone an identical ICmpInst
1177ICmpInst *cloneImpl()const;
1178
1179public:
1180 /// Constructor with insertion semantics.
1181ICmpInst(InsertPosition InsertBefore,///< Where to insert
1182Predicatepred,///< The predicate to use for the comparison
1183Value *LHS,///< The left-hand-side of the expression
1184Value *RHS,///< The right-hand-side of the expression
1185constTwine &NameStr =""///< Name of the instruction
1186 )
1187 :CmpInst(makeCmpResultType(LHS->getType()),Instruction::ICmp,pred,LHS,
1188RHS, NameStr, InsertBefore) {
1189#ifndef NDEBUG
1190 AssertOK();
1191#endif
1192 }
1193
1194 /// Constructor with no-insertion semantics
1195ICmpInst(
1196Predicatepred,///< The predicate to use for the comparison
1197Value *LHS,///< The left-hand-side of the expression
1198Value *RHS,///< The right-hand-side of the expression
1199constTwine &NameStr =""///< Name of the instruction
1200 ) :CmpInst(makeCmpResultType(LHS->getType()),
1201Instruction::ICmp,pred,LHS,RHS, NameStr) {
1202#ifndef NDEBUG
1203 AssertOK();
1204#endif
1205 }
1206
1207 /// @returns the predicate along with samesign information.
1208CmpPredicategetCmpPredicate() const{
1209return {getPredicate(), hasSameSign()};
1210 }
1211
1212 /// @returns the inverse predicate along with samesign information: static
1213 /// variant.
1214staticCmpPredicategetInverseCmpPredicate(CmpPredicate Pred) {
1215return {getInversePredicate(Pred), Pred.hasSameSign()};
1216 }
1217
1218 /// @returns the inverse predicate along with samesign information.
1219CmpPredicategetInverseCmpPredicate() const{
1220return getInverseCmpPredicate(getCmpPredicate());
1221 }
1222
1223 /// @returns the swapped predicate along with samesign information: static
1224 /// variant.
1225staticCmpPredicategetSwappedCmpPredicate(CmpPredicate Pred) {
1226return {getSwappedPredicate(Pred), Pred.hasSameSign()};
1227 }
1228
1229 /// @returns the swapped predicate along with samesign information.
1230CmpPredicategetSwappedCmpPredicate() const{
1231return getSwappedCmpPredicate(getCmpPredicate());
1232 }
1233
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.
1238PredicategetSignedPredicate() const{
1239return getSignedPredicate(getPredicate());
1240 }
1241
1242 /// Return the signed version of the predicate: static variant.
1243staticPredicate getSignedPredicate(Predicate Pred);
1244
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.
1249PredicategetUnsignedPredicate() const{
1250return getUnsignedPredicate(getPredicate());
1251 }
1252
1253 /// Return the unsigned version of the predicate: static variant.
1254staticPredicate getUnsignedPredicate(Predicate Pred);
1255
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.
1259 /// Static variant.
1260staticPredicate getFlippedSignednessPredicate(Predicate Pred);
1261
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.
1265PredicategetFlippedSignednessPredicate() const{
1266return getFlippedSignednessPredicate(getPredicate());
1267 }
1268
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,
1272CmpPredicate Pred2);
1273
1274voidsetSameSign(boolB =true) {
1275 SubclassOptionalData = (SubclassOptionalData & ~SameSign) | (B * SameSign);
1276 }
1277
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.
1281boolhasSameSign() const{return SubclassOptionalData & SameSign; }
1282
1283 /// Return true if this predicate is either EQ or NE. This also
1284 /// tests for commutativity.
1285staticboolisEquality(PredicateP) {
1286returnP == ICMP_EQ ||P == ICMP_NE;
1287 }
1288
1289 /// Return true if this predicate is either EQ or NE. This also
1290 /// tests for commutativity.
1291boolisEquality() const{
1292return isEquality(getPredicate());
1293 }
1294
1295 /// @returns true if the predicate is commutative
1296 /// Determine if this relation is commutative.
1297staticboolisCommutative(PredicateP) {return isEquality(P); }
1298
1299 /// @returns true if the predicate of this ICmpInst is commutative
1300 /// Determine if this relation is commutative.
1301boolisCommutative() const{returnisCommutative(getPredicate()); }
1302
1303 /// Return true if the predicate is relational (not EQ or NE).
1304 ///
1305boolisRelational() const{
1306return !isEquality();
1307 }
1308
1309 /// Return true if the predicate is relational (not EQ or NE).
1310 ///
1311staticboolisRelational(PredicateP) {
1312return !isEquality(P);
1313 }
1314
1315 /// Return true if the predicate is SGT or UGT.
1316 ///
1317staticboolisGT(PredicateP) {
1318returnP == ICMP_SGT ||P == ICMP_UGT;
1319 }
1320
1321 /// Return true if the predicate is SLT or ULT.
1322 ///
1323staticboolisLT(PredicateP) {
1324returnP == ICMP_SLT ||P == ICMP_ULT;
1325 }
1326
1327 /// Return true if the predicate is SGE or UGE.
1328 ///
1329staticboolisGE(PredicateP) {
1330returnP == ICMP_SGE ||P == ICMP_UGE;
1331 }
1332
1333 /// Return true if the predicate is SLE or ULE.
1334 ///
1335staticboolisLE(PredicateP) {
1336returnP == ICMP_SLE ||P == ICMP_ULE;
1337 }
1338
1339 /// Returns the sequence of all ICmp predicates.
1340 ///
1341staticautopredicates() {return ICmpPredicates(); }
1342
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
1346 /// (e.g. ult).
1347 /// Swap operands and adjust predicate.
1348voidswapOperands() {
1349 setPredicate(getSwappedPredicate());
1350Op<0>().swap(Op<1>());
1351 }
1352
1353 /// Return result of `LHS Pred RHS` comparison.
1354staticbool compare(constAPInt &LHS,constAPInt &RHS,
1355ICmpInst::Predicate Pred);
1356
1357 /// Return result of `LHS Pred RHS`, if it can be determined from the
1358 /// KnownBits. Otherwise return nullopt.
1359static std::optional<bool> compare(constKnownBits &LHS,constKnownBits &RHS,
1360ICmpInst::Predicate Pred);
1361
1362// Methods for support type inquiry through isa, cast, and dyn_cast:
1363staticboolclassof(constInstruction *I) {
1364returnI->getOpcode() == Instruction::ICmp;
1365 }
1366staticboolclassof(constValue *V) {
1367return isa<Instruction>(V) && classof(cast<Instruction>(V));
1368 }
1369};
1370
1371//===----------------------------------------------------------------------===//
1372// FCmpInst Class
1373//===----------------------------------------------------------------------===//
1374
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.
1379classFCmpInst:publicCmpInst {
1380void AssertOK() {
1381assert(isFPPredicate() &&"Invalid FCmp predicate value");
1382assert(getOperand(0)->getType() ==getOperand(1)->getType() &&
1383"Both operands to FCmp instruction are not of the same type!");
1384// Check that the operands are the right type
1385assert(getOperand(0)->getType()->isFPOrFPVectorTy() &&
1386"Invalid operand types for FCmp instruction");
1387 }
1388
1389protected:
1390// Note: Instruction needs to be a friend here to call cloneImpl.
1391friendclassInstruction;
1392
1393 /// Clone an identical FCmpInst
1394FCmpInst *cloneImpl()const;
1395
1396public:
1397 /// Constructor with insertion semantics.
1398FCmpInst(InsertPosition InsertBefore,///< Where to insert
1399Predicatepred,///< The predicate to use for the comparison
1400Value *LHS,///< The left-hand-side of the expression
1401Value *RHS,///< The right-hand-side of the expression
1402constTwine &NameStr =""///< Name of the instruction
1403 )
1404 :CmpInst(makeCmpResultType(LHS->getType()),Instruction::FCmp,pred,LHS,
1405RHS, NameStr, InsertBefore) {
1406 AssertOK();
1407 }
1408
1409 /// Constructor with no-insertion semantics
1410FCmpInst(Predicate Pred,///< The predicate to use for the comparison
1411Value *LHS,///< The left-hand-side of the expression
1412Value *RHS,///< The right-hand-side of the expression
1413constTwine &NameStr ="",///< Name of the instruction
1414Instruction *FlagsSource =nullptr)
1415 :CmpInst(makeCmpResultType(LHS->getType()),Instruction::FCmp, Pred,LHS,
1416RHS, NameStr, nullptr, FlagsSource) {
1417 AssertOK();
1418 }
1419
1420 /// @returns true if the predicate is EQ or NE.
1421 /// Determine if this is an equality predicate.
1422staticboolisEquality(Predicate Pred) {
1423return Pred ==FCMP_OEQ || Pred ==FCMP_ONE || Pred ==FCMP_UEQ ||
1424 Pred ==FCMP_UNE;
1425 }
1426
1427 /// @returns true if the predicate of this instruction is EQ or NE.
1428 /// Determine if this is an equality predicate.
1429boolisEquality() const{returnisEquality(getPredicate()); }
1430
1431 /// @returns true if the predicate is commutative.
1432 /// Determine if this is a commutative predicate.
1433staticboolisCommutative(Predicate Pred) {
1434returnisEquality(Pred) || Pred ==FCMP_FALSE || Pred ==FCMP_TRUE ||
1435 Pred ==FCMP_ORD || Pred ==FCMP_UNO;
1436 }
1437
1438 /// @returns true if the predicate of this instruction is commutative.
1439 /// Determine if this is a commutative predicate.
1440boolisCommutative() const{returnisCommutative(getPredicate()); }
1441
1442 /// @returns true if the predicate is relational (not EQ or NE).
1443 /// Determine if this a relational predicate.
1444boolisRelational() const{return !isEquality(); }
1445
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
1449 /// (e.g. ult).
1450 /// Swap operands and adjust predicate.
1451voidswapOperands() {
1452setPredicate(getSwappedPredicate());
1453Op<0>().swap(Op<1>());
1454 }
1455
1456 /// Returns the sequence of all FCmp predicates.
1457 ///
1458staticautopredicates() {returnFCmpPredicates(); }
1459
1460 /// Return result of `LHS Pred RHS` comparison.
1461staticboolcompare(constAPFloat &LHS,constAPFloat &RHS,
1462FCmpInst::Predicate Pred);
1463
1464 /// Methods for support type inquiry through isa, cast, and dyn_cast:
1465staticboolclassof(constInstruction *I) {
1466returnI->getOpcode() == Instruction::FCmp;
1467 }
1468staticboolclassof(constValue *V) {
1469return isa<Instruction>(V) &&classof(cast<Instruction>(V));
1470 }
1471};
1472
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.
1478///
1479classCallInst :publicCallBase {
1480CallInst(constCallInst &CI,AllocInfoAllocInfo);
1481
1482 /// Construct a CallInst from a range of arguments
1483inlineCallInst(FunctionType *Ty,Value *Func,ArrayRef<Value *> Args,
1484ArrayRef<OperandBundleDef> Bundles,constTwine &NameStr,
1485AllocInfoAllocInfo,InsertPosition InsertBefore);
1486
1487inlineCallInst(FunctionType *Ty,Value *Func,ArrayRef<Value *> Args,
1488constTwine &NameStr,AllocInfoAllocInfo,
1489InsertPosition InsertBefore)
1490 :CallInst(Ty, Func, Args, {}, NameStr,AllocInfo, InsertBefore) {}
1491
1492explicitCallInst(FunctionType *Ty,Value *F,constTwine &NameStr,
1493AllocInfoAllocInfo,InsertPosition InsertBefore);
1494
1495void init(FunctionType *FTy,Value *Func,ArrayRef<Value *> Args,
1496ArrayRef<OperandBundleDef> Bundles,constTwine &NameStr);
1497void init(FunctionType *FTy,Value *Func,constTwine &NameStr);
1498
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
1503// counts provided.
1504return 1 + NumArgs + NumBundleInputs;
1505 }
1506
1507protected:
1508// Note: Instruction needs to be a friend here to call cloneImpl.
1509friendclassInstruction;
1510
1511CallInst *cloneImpl()const;
1512
1513public:
1514staticCallInst *Create(FunctionType *Ty,Value *F,constTwine &NameStr ="",
1515InsertPosition InsertBefore =nullptr) {
1516IntrusiveOperandsAllocMarker AllocMarker{ComputeNumOperands(0)};
1517returnnew (AllocMarker)
1518CallInst(Ty,F, NameStr, AllocMarker, InsertBefore);
1519 }
1520
1521staticCallInst *Create(FunctionType *Ty,Value *Func,ArrayRef<Value *> Args,
1522constTwine &NameStr,
1523InsertPosition InsertBefore =nullptr) {
1524IntrusiveOperandsAllocMarker AllocMarker{ComputeNumOperands(Args.size())};
1525returnnew (AllocMarker)
1526CallInst(Ty, Func, Args, {}, NameStr, AllocMarker, InsertBefore);
1527 }
1528
1529staticCallInst *Create(FunctionType *Ty,Value *Func,ArrayRef<Value *> Args,
1530ArrayRef<OperandBundleDef> Bundles = {},
1531constTwine &NameStr ="",
1532InsertPosition InsertBefore =nullptr) {
1533 IntrusiveOperandsAndDescriptorAllocMarker AllocMarker{
1534 ComputeNumOperands(unsigned(Args.size()),CountBundleInputs(Bundles)),
1535unsigned(Bundles.size() *sizeof(BundleOpInfo))};
1536
1537returnnew (AllocMarker)
1538 CallInst(Ty, Func, Args, Bundles, NameStr, AllocMarker, InsertBefore);
1539 }
1540
1541staticCallInst *Create(FunctionCallee Func,constTwine &NameStr ="",
1542InsertPosition InsertBefore =nullptr) {
1543returnCreate(Func.getFunctionType(), Func.getCallee(), NameStr,
1544 InsertBefore);
1545 }
1546
1547staticCallInst *Create(FunctionCallee Func,ArrayRef<Value *> Args,
1548ArrayRef<OperandBundleDef> Bundles = {},
1549constTwine &NameStr ="",
1550InsertPosition InsertBefore =nullptr) {
1551returnCreate(Func.getFunctionType(), Func.getCallee(), Args, Bundles,
1552 NameStr, InsertBefore);
1553 }
1554
1555staticCallInst *Create(FunctionCallee Func,ArrayRef<Value *> Args,
1556constTwine &NameStr,
1557InsertPosition InsertBefore =nullptr) {
1558returnCreate(Func.getFunctionType(), Func.getCallee(), Args, NameStr,
1559 InsertBefore);
1560 }
1561
1562 /// Create a clone of \p CI with a different set of operand bundles and
1563 /// insert it before \p InsertBefore.
1564 ///
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
1567 /// in \p Bundles.
1568staticCallInst *Create(CallInst *CI,ArrayRef<OperandBundleDef> Bundles,
1569InsertPosition InsertPt =nullptr);
1570
1571// Note that 'musttail' implies 'tail'.
1572enumTailCallKind :unsigned {
1573TCK_None = 0,
1574TCK_Tail = 1,
1575TCK_MustTail = 2,
1576TCK_NoTail = 3,
1577TCK_LAST =TCK_NoTail
1578 };
1579
1580usingTailCallKindField =Bitfield::Element<TailCallKind, 0, 2, TCK_LAST>;
1581static_assert(
1582 Bitfield::areContiguous<TailCallKindField, CallBase::CallingConvField>(),
1583"Bitfields must be contiguous");
1584
1585TailCallKindgetTailCallKind() const{
1586return getSubclassData<TailCallKindField>();
1587 }
1588
1589boolisTailCall() const{
1590TailCallKind Kind =getTailCallKind();
1591return Kind ==TCK_Tail || Kind ==TCK_MustTail;
1592 }
1593
1594boolisMustTailCall() const{returngetTailCallKind() ==TCK_MustTail; }
1595
1596boolisNoTailCall() const{returngetTailCallKind() ==TCK_NoTail; }
1597
1598voidsetTailCallKind(TailCallKind TCK) {
1599 setSubclassData<TailCallKindField>(TCK);
1600 }
1601
1602voidsetTailCall(bool IsTc =true) {
1603setTailCallKind(IsTc ?TCK_Tail :TCK_None);
1604 }
1605
1606 /// Return true if the call can return twice
1607boolcanReturnTwice() const{returnhasFnAttr(Attribute::ReturnsTwice); }
1608voidsetCanReturnTwice() {addFnAttr(Attribute::ReturnsTwice); }
1609
1610 /// Return true if the call is for a noreturn trap intrinsic.
1611boolisNonContinuableTrap() const{
1612switch (getIntrinsicID()) {
1613case Intrinsic::trap:
1614case Intrinsic::ubsantrap:
1615return !hasFnAttr("trap-func-name");
1616default:
1617returnfalse;
1618 }
1619 }
1620
1621// Methods for support type inquiry through isa, cast, and dyn_cast:
1622staticboolclassof(constInstruction *I) {
1623returnI->getOpcode() == Instruction::Call;
1624 }
1625staticboolclassof(constValue *V) {
1626return isa<Instruction>(V) &&classof(cast<Instruction>(V));
1627 }
1628
1629 /// Updates profile metadata by scaling it by \p S / \p T.
1630voidupdateProfWeight(uint64_t S,uint64_tT);
1631
1632private:
1633// Shadow Instruction::setInstructionSubclassData with a private forwarding
1634// method so that subclasses cannot accidentally use it.
1635template <typename Bitfield>
1636void setSubclassData(typename Bitfield::TypeValue) {
1637 Instruction::setSubclassData<Bitfield>(Value);
1638 }
1639};
1640
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,
1645 InsertBefore) {
1646assert(AllocInfo.NumOps ==
1647unsigned(Args.size() +CountBundleInputs(Bundles) + 1));
1648init(Ty, Func, Args, Bundles, NameStr);
1649}
1650
1651//===----------------------------------------------------------------------===//
1652// SelectInst Class
1653//===----------------------------------------------------------------------===//
1654
1655/// This class represents the LLVM 'select' instruction.
1656///
1657classSelectInst :publicInstruction {
1658constexprstaticIntrusiveOperandsAllocMarker AllocMarker{3};
1659
1660SelectInst(Value *C,Value *S1,Value *S2,constTwine &NameStr,
1661InsertPosition InsertBefore)
1662 :Instruction(S1->getType(), Instruction::Select, AllocMarker,
1663 InsertBefore) {
1664 init(C,S1, S2);
1665setName(NameStr);
1666 }
1667
1668void init(Value *C,Value *S1,Value *S2) {
1669assert(!areInvalidOperands(C,S1, S2) &&"Invalid operands for select");
1670Op<0>() =C;
1671Op<1>() =S1;
1672Op<2>() = S2;
1673 }
1674
1675protected:
1676// Note: Instruction needs to be a friend here to call cloneImpl.
1677friendclassInstruction;
1678
1679SelectInst *cloneImpl()const;
1680
1681public:
1682staticSelectInst *Create(Value *C,Value *S1,Value *S2,
1683constTwine &NameStr ="",
1684InsertPosition InsertBefore =nullptr,
1685Instruction *MDFrom =nullptr) {
1686SelectInst *Sel =
1687new (AllocMarker)SelectInst(C,S1, S2, NameStr, InsertBefore);
1688if (MDFrom)
1689 Sel->copyMetadata(*MDFrom);
1690return Sel;
1691 }
1692
1693constValue *getCondition() const{returnOp<0>(); }
1694constValue *getTrueValue() const{returnOp<1>(); }
1695constValue *getFalseValue() const{returnOp<2>(); }
1696Value *getCondition() {returnOp<0>(); }
1697Value *getTrueValue() {returnOp<1>(); }
1698Value *getFalseValue() {returnOp<2>(); }
1699
1700voidsetCondition(Value *V) {Op<0>() = V; }
1701voidsetTrueValue(Value *V) {Op<1>() = V; }
1702voidsetFalseValue(Value *V) {Op<2>() = V; }
1703
1704 /// Swap the true and false values of the select instruction.
1705 /// This doesn't swap prof metadata.
1706voidswapValues() {Op<1>().swap(Op<2>()); }
1707
1708 /// Return a string if the specified operands are invalid
1709 /// for a select operation, otherwise return null.
1710staticconstchar *areInvalidOperands(Value *Cond,Value *True,Value *False);
1711
1712 /// Transparently provide more efficient getOperand methods.
1713DECLARE_TRANSPARENT_OPERAND_ACCESSORS(Value);
1714
1715OtherOpsgetOpcode() const{
1716returnstatic_cast<OtherOps>(Instruction::getOpcode());
1717 }
1718
1719// Methods for support type inquiry through isa, cast, and dyn_cast:
1720staticboolclassof(constInstruction *I) {
1721returnI->getOpcode() == Instruction::Select;
1722 }
1723staticboolclassof(constValue *V) {
1724return isa<Instruction>(V) &&classof(cast<Instruction>(V));
1725 }
1726};
1727
1728template <>
1729structOperandTraits<SelectInst> :publicFixedNumOperandTraits<SelectInst, 3> {
1730};
1731
1732DEFINE_TRANSPARENT_OPERAND_ACCESSORS(SelectInst,Value)
1733
1734//===----------------------------------------------------------------------===//
1735// VAArgInst Class
1736//===----------------------------------------------------------------------===//
1737
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
1740///
1741classVAArgInst : publicUnaryInstruction {
1742protected:
1743// Note: Instruction needs to be a friend here to call cloneImpl.
1744friendclassInstruction;
1745
1746VAArgInst *cloneImpl()const;
1747
1748public:
1749VAArgInst(Value *List,Type *Ty,constTwine &NameStr ="",
1750InsertPosition InsertBefore =nullptr)
1751 :UnaryInstruction(Ty, VAArg,List, InsertBefore) {
1752 setName(NameStr);
1753 }
1754
1755Value *getPointerOperand() {return getOperand(0); }
1756constValue *getPointerOperand() const{return getOperand(0); }
1757staticunsignedgetPointerOperandIndex() {return 0U; }
1758
1759// Methods for support type inquiry through isa, cast, and dyn_cast:
1760staticboolclassof(constInstruction *I) {
1761returnI->getOpcode() == VAArg;
1762 }
1763staticboolclassof(constValue *V) {
1764return isa<Instruction>(V) && classof(cast<Instruction>(V));
1765 }
1766};
1767
1768//===----------------------------------------------------------------------===//
1769// ExtractElementInst Class
1770//===----------------------------------------------------------------------===//
1771
1772/// This instruction extracts a single (scalar)
1773/// element from a VectorType value
1774///
1775classExtractElementInst :publicInstruction {
1776constexprstaticIntrusiveOperandsAllocMarker AllocMarker{2};
1777
1778ExtractElementInst(Value *Vec,Value *Idx,constTwine &NameStr ="",
1779InsertPosition InsertBefore =nullptr);
1780
1781protected:
1782// Note: Instruction needs to be a friend here to call cloneImpl.
1783friendclassInstruction;
1784
1785ExtractElementInst *cloneImpl()const;
1786
1787public:
1788staticExtractElementInst *Create(Value *Vec,Value *Idx,
1789constTwine &NameStr ="",
1790InsertPosition InsertBefore =nullptr) {
1791returnnew (AllocMarker)
1792ExtractElementInst(Vec,Idx, NameStr, InsertBefore);
1793 }
1794
1795 /// Return true if an extractelement instruction can be
1796 /// formed with the specified operands.
1797staticboolisValidOperands(constValue *Vec,constValue *Idx);
1798
1799Value *getVectorOperand() {returnOp<0>(); }
1800Value *getIndexOperand() {returnOp<1>(); }
1801constValue *getVectorOperand() const{returnOp<0>(); }
1802constValue *getIndexOperand() const{returnOp<1>(); }
1803
1804VectorType *getVectorOperandType() const{
1805return cast<VectorType>(getVectorOperand()->getType());
1806 }
1807
1808 /// Transparently provide more efficient getOperand methods.
1809DECLARE_TRANSPARENT_OPERAND_ACCESSORS(Value);
1810
1811// Methods for support type inquiry through isa, cast, and dyn_cast:
1812staticboolclassof(constInstruction *I) {
1813returnI->getOpcode() == Instruction::ExtractElement;
1814 }
1815staticboolclassof(constValue *V) {
1816return isa<Instruction>(V) &&classof(cast<Instruction>(V));
1817 }
1818};
1819
1820template <>
1821structOperandTraits<ExtractElementInst> :
1822publicFixedNumOperandTraits<ExtractElementInst, 2> {
1823};
1824
1825DEFINE_TRANSPARENT_OPERAND_ACCESSORS(ExtractElementInst,Value)
1826
1827//===----------------------------------------------------------------------===//
1828// InsertElementInst Class
1829//===----------------------------------------------------------------------===//
1830
1831/// This instruction inserts a single (scalar)
1832/// element into a VectorType value
1833///
1834classInsertElementInst : publicInstruction {
1835constexprstaticIntrusiveOperandsAllocMarker AllocMarker{3};
1836
1837InsertElementInst(Value *Vec,Value *NewElt,Value *Idx,
1838constTwine &NameStr ="",
1839InsertPosition InsertBefore =nullptr);
1840
1841protected:
1842// Note: Instruction needs to be a friend here to call cloneImpl.
1843friendclassInstruction;
1844
1845InsertElementInst *cloneImpl()const;
1846
1847public:
1848staticInsertElementInst *Create(Value *Vec,Value *NewElt,Value *Idx,
1849constTwine &NameStr ="",
1850InsertPosition InsertBefore =nullptr) {
1851returnnew (AllocMarker)
1852InsertElementInst(Vec, NewElt,Idx, NameStr, InsertBefore);
1853 }
1854
1855 /// Return true if an insertelement instruction can be
1856 /// formed with the specified operands.
1857staticbool isValidOperands(constValue *Vec,constValue *NewElt,
1858constValue *Idx);
1859
1860 /// Overload to return most specific vector type.
1861 ///
1862VectorType *getType() const{
1863return cast<VectorType>(Instruction::getType());
1864 }
1865
1866 /// Transparently provide more efficient getOperand methods.
1867DECLARE_TRANSPARENT_OPERAND_ACCESSORS(Value);
1868
1869// Methods for support type inquiry through isa, cast, and dyn_cast:
1870staticboolclassof(constInstruction *I) {
1871returnI->getOpcode() == Instruction::InsertElement;
1872 }
1873staticboolclassof(constValue *V) {
1874return isa<Instruction>(V) && classof(cast<Instruction>(V));
1875 }
1876};
1877
1878template <>
1879structOperandTraits<InsertElementInst> :
1880publicFixedNumOperandTraits<InsertElementInst, 3> {
1881};
1882
1883DEFINE_TRANSPARENT_OPERAND_ACCESSORS(InsertElementInst,Value)
1884
1885//===----------------------------------------------------------------------===//
1886// ShuffleVectorInst Class
1887//===----------------------------------------------------------------------===//
1888
1889constexprintPoisonMaskElem = -1;
1890
1891/// This instruction constructs a fixed permutation of two
1892/// input vectors.
1893///
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.
1898///
1899/// For scalable vectors, all the elements of the mask must be 0 or -1. This
1900/// requirement may be relaxed in the future.
1901classShuffleVectorInst : publicInstruction {
1902constexprstaticIntrusiveOperandsAllocMarker AllocMarker{2};
1903
1904SmallVector<int, 4> ShuffleMask;
1905Constant *ShuffleMaskForBitcode;
1906
1907protected:
1908// Note: Instruction needs to be a friend here to call cloneImpl.
1909friendclassInstruction;
1910
1911ShuffleVectorInst *cloneImpl()const;
1912
1913public:
1914ShuffleVectorInst(Value *V1,Value *Mask,constTwine &NameStr ="",
1915InsertPosition InsertBefore =nullptr);
1916ShuffleVectorInst(Value *V1,ArrayRef<int> Mask,constTwine &NameStr ="",
1917InsertPosition InsertBefore =nullptr);
1918ShuffleVectorInst(Value *V1,Value *V2,Value *Mask,
1919constTwine &NameStr ="",
1920InsertPosition InsertBefore =nullptr);
1921ShuffleVectorInst(Value *V1,Value *V2,ArrayRef<int> Mask,
1922constTwine &NameStr ="",
1923InsertPosition InsertBefore =nullptr);
1924
1925void *operatornew(size_t S) {return User::operatornew(S, AllocMarker); }
1926voidoperatordelete(void *Ptr) {return User::operatordelete(Ptr); }
1927
1928 /// Swap the operands and adjust the mask to preserve the semantics
1929 /// of the instruction.
1930void commute();
1931
1932 /// Return true if a shufflevector instruction can be
1933 /// formed with the specified operands.
1934staticbool isValidOperands(constValue *V1,constValue *V2,
1935constValue *Mask);
1936staticbool isValidOperands(constValue *V1,constValue *V2,
1937ArrayRef<int> Mask);
1938
1939 /// Overload to return most specific vector type.
1940 ///
1941VectorType *getType() const{
1942return cast<VectorType>(Instruction::getType());
1943 }
1944
1945 /// Transparently provide more efficient getOperand methods.
1946DECLARE_TRANSPARENT_OPERAND_ACCESSORS(Value);
1947
1948 /// Return the shuffle mask value of this instruction for the given element
1949 /// index. Return PoisonMaskElem if the element is undef.
1950intgetMaskValue(unsigned Elt) const{return ShuffleMask[Elt]; }
1951
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,
1955SmallVectorImpl<int> &Result);
1956
1957 /// Return the mask for this instruction as a vector of integers. Undefined
1958 /// elements of the mask are returned as PoisonMaskElem.
1959voidgetShuffleMask(SmallVectorImpl<int> &Result) const{
1960 Result.assign(ShuffleMask.begin(), ShuffleMask.end());
1961 }
1962
1963 /// Return the mask for this instruction, for use in bitcode.
1964 ///
1965 /// TODO: This is temporary until we decide a new bitcode encoding for
1966 /// shufflevector.
1967Constant *getShuffleMaskForBitcode() const{return ShuffleMaskForBitcode; }
1968
1969staticConstant *convertShuffleMaskForBitcode(ArrayRef<int> Mask,
1970Type *ResultTy);
1971
1972void setShuffleMask(ArrayRef<int> Mask);
1973
1974ArrayRef<int>getShuffleMask() const{return ShuffleMask; }
1975
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>
1980boolchangesLength() const{
1981unsigned NumSourceElts = cast<VectorType>(Op<0>()->getType())
1982 ->getElementCount()
1983 .getKnownMinValue();
1984unsigned NumMaskElts = ShuffleMask.size();
1985return NumSourceElts != NumMaskElts;
1986 }
1987
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>
1991boolincreasesLength() const{
1992unsigned NumSourceElts = cast<VectorType>(Op<0>()->getType())
1993 ->getElementCount()
1994 .getKnownMinValue();
1995unsigned NumMaskElts = ShuffleMask.size();
1996return NumSourceElts < NumMaskElts;
1997 }
1998
1999 /// Return true if this shuffle mask chooses elements from exactly one source
2000 /// vector.
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);
2005staticboolisSingleSourceMask(constConstant *Mask,int NumSrcElts) {
2006assert(Mask->getType()->isVectorTy() &&"Shuffle needs vector constant.");
2007SmallVector<int, 16> MaskAsInts;
2008 getShuffleMask(Mask, MaskAsInts);
2009return isSingleSourceMask(MaskAsInts, NumSrcElts);
2010 }
2011
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.
2016boolisSingleSource() const{
2017return !changesLength() &&
2018 isSingleSourceMask(ShuffleMask, ShuffleMask.size());
2019 }
2020
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);
2027staticboolisIdentityMask(constConstant *Mask,int NumSrcElts) {
2028assert(Mask->getType()->isVectorTy() &&"Shuffle needs vector constant.");
2029
2030// Not possible to express a shuffle mask for a scalable vector for this
2031// case.
2032if (isa<ScalableVectorType>(Mask->getType()))
2033returnfalse;
2034
2035SmallVector<int, 16> MaskAsInts;
2036 getShuffleMask(Mask, MaskAsInts);
2037return isIdentityMask(MaskAsInts, NumSrcElts);
2038 }
2039
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>
2044boolisIdentity() const{
2045// Not possible to express a shuffle mask for a scalable vector for this
2046// case.
2047if (isa<ScalableVectorType>(getType()))
2048returnfalse;
2049
2050return !changesLength() && isIdentityMask(ShuffleMask, ShuffleMask.size());
2051 }
2052
2053 /// Return true if this shuffle lengthens exactly one source vector with
2054 /// undefs in the high elements.
2055bool isIdentityWithPadding()const;
2056
2057 /// Return true if this shuffle extracts the first N elements of exactly one
2058 /// source vector.
2059bool isIdentityWithExtract()const;
2060
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;
2065
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).
2074staticbool isSelectMask(ArrayRef<int> Mask,int NumSrcElts);
2075staticboolisSelectMask(constConstant *Mask,int NumSrcElts) {
2076assert(Mask->getType()->isVectorTy() &&"Shuffle needs vector constant.");
2077SmallVector<int, 16> MaskAsInts;
2078 getShuffleMask(Mask, MaskAsInts);
2079return isSelectMask(MaskAsInts, NumSrcElts);
2080 }
2081
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.
2090boolisSelect() const{
2091return !changesLength() && isSelectMask(ShuffleMask, ShuffleMask.size());
2092 }
2093
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.
2099staticboolisReverseMask(ArrayRef<int> Mask,int NumSrcElts);
2100staticboolisReverseMask(constConstant *Mask,int NumSrcElts) {
2101assert(Mask->getType()->isVectorTy() &&"Shuffle needs vector constant.");
2102SmallVector<int, 16> MaskAsInts;
2103 getShuffleMask(Mask, MaskAsInts);
2104returnisReverseMask(MaskAsInts, NumSrcElts);
2105 }
2106
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.
2111boolisReverse() const{
2112return !changesLength() &&isReverseMask(ShuffleMask, ShuffleMask.size());
2113 }
2114
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);
2121staticboolisZeroEltSplatMask(constConstant *Mask,int NumSrcElts) {
2122assert(Mask->getType()->isVectorTy() &&"Shuffle needs vector constant.");
2123SmallVector<int, 16> MaskAsInts;
2124 getShuffleMask(Mask, MaskAsInts);
2125return isZeroEltSplatMask(MaskAsInts, NumSrcElts);
2126 }
2127
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
2130 /// of that vector.
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.
2134boolisZeroEltSplat() const{
2135return !changesLength() &&
2136 isZeroEltSplatMask(ShuffleMask, ShuffleMask.size());
2137 }
2138
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.
2147 ///
2148 /// For example, a simple 2x2 matrix can be transposed with:
2149 ///
2150 /// ; Original matrix
2151 /// m0 = < a, b >
2152 /// m1 = < c, d >
2153 ///
2154 /// ; Transposed matrix
2155 /// t0 = < a, c > = shufflevector m0, m1, < 0, 2 >
2156 /// t1 = < b, d > = shufflevector m0, m1, < 1, 3 >
2157 ///
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:
2163 ///
2164 /// ; Original matrix
2165 /// m0 = < a, b, c, d >
2166 /// m1 = < e, f, g, h >
2167 ///
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);
2172staticboolisTransposeMask(constConstant *Mask,int NumSrcElts) {
2173assert(Mask->getType()->isVectorTy() &&"Shuffle needs vector constant.");
2174SmallVector<int, 16> MaskAsInts;
2175 getShuffleMask(Mask, MaskAsInts);
2176return isTransposeMask(MaskAsInts, NumSrcElts);
2177 }
2178
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>
2184boolisTranspose() const{
2185return !changesLength() && isTransposeMask(ShuffleMask, ShuffleMask.size());
2186 }
2187
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.
2194staticbool isSpliceMask(ArrayRef<int> Mask,int NumSrcElts,int &Index);
2195staticboolisSpliceMask(constConstant *Mask,int NumSrcElts,int &Index) {
2196assert(Mask->getType()->isVectorTy() &&"Shuffle needs vector constant.");
2197SmallVector<int, 16> MaskAsInts;
2198 getShuffleMask(Mask, MaskAsInts);
2199return isSpliceMask(MaskAsInts, NumSrcElts,Index);
2200 }
2201
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>
2206boolisSplice(int &Index) const{
2207return !changesLength() &&
2208 isSpliceMask(ShuffleMask, ShuffleMask.size(),Index);
2209 }
2210
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,
2215int &Index);
2216staticboolisExtractSubvectorMask(constConstant *Mask,int NumSrcElts,
2217int &Index) {
2218assert(Mask->getType()->isVectorTy() &&"Shuffle needs vector constant.");
2219// Not possible to express a shuffle mask for a scalable vector for this
2220// case.
2221if (isa<ScalableVectorType>(Mask->getType()))
2222returnfalse;
2223SmallVector<int, 16> MaskAsInts;
2224 getShuffleMask(Mask, MaskAsInts);
2225return isExtractSubvectorMask(MaskAsInts, NumSrcElts,Index);
2226 }
2227
2228 /// Return true if this shuffle mask is an extract subvector mask.
2229boolisExtractSubvectorMask(int &Index) const{
2230// Not possible to express a shuffle mask for a scalable vector for this
2231// case.
2232if (isa<ScalableVectorType>(getType()))
2233returnfalse;
2234
2235int NumSrcElts =
2236 cast<FixedVectorType>(Op<0>()->getType())->getNumElements();
2237return isExtractSubvectorMask(ShuffleMask, NumSrcElts,Index);
2238 }
2239
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);
2246staticboolisInsertSubvectorMask(constConstant *Mask,int NumSrcElts,
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
2250// case.
2251if (isa<ScalableVectorType>(Mask->getType()))
2252returnfalse;
2253SmallVector<int, 16> MaskAsInts;
2254 getShuffleMask(Mask, MaskAsInts);
2255return isInsertSubvectorMask(MaskAsInts, NumSrcElts, NumSubElts,Index);
2256 }
2257
2258 /// Return true if this shuffle mask is an insert subvector mask.
2259boolisInsertSubvectorMask(int &NumSubElts,int &Index) const{
2260// Not possible to express a shuffle mask for a scalable vector for this
2261// case.
2262if (isa<ScalableVectorType>(getType()))
2263returnfalse;
2264
2265int NumSrcElts =
2266 cast<FixedVectorType>(Op<0>()->getType())->getNumElements();
2267return isInsertSubvectorMask(ShuffleMask, NumSrcElts, NumSubElts,Index);
2268 }
2269
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,
2275int &VF);
2276staticboolisReplicationMask(constConstant *Mask,int &ReplicationFactor,
2277int &VF) {
2278assert(Mask->getType()->isVectorTy() &&"Shuffle needs vector constant.");
2279// Not possible to express a shuffle mask for a scalable vector for this
2280// case.
2281if (isa<ScalableVectorType>(Mask->getType()))
2282returnfalse;
2283SmallVector<int, 16> MaskAsInts;
2284 getShuffleMask(Mask, MaskAsInts);
2285return isReplicationMask(MaskAsInts, ReplicationFactor, VF);
2286 }
2287
2288 /// Return true if this shuffle mask is a replication mask.
2289bool isReplicationMask(int &ReplicationFactor,int &VF)const;
2290
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
2293 /// size VF.
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);
2301
2302 /// Return true if this shuffle mask is a one-use-single-source("clustered")
2303 /// mask.
2304bool isOneUseSingleSourceMask(int VF)const;
2305
2306 /// Change values in a shuffle permute mask assuming the two vector operands
2307 /// of length InVecNumElts have swapped position.
2308staticvoidcommuteShuffleMask(MutableArrayRef<int> Mask,
2309unsigned InVecNumElts) {
2310for (int &Idx : Mask) {
2311if (Idx == -1)
2312continue;
2313Idx =Idx < (int)InVecNumElts ?Idx + InVecNumElts :Idx - InVecNumElts;
2314assert(Idx >= 0 &&Idx < (int)InVecNumElts * 2 &&
2315"shufflevector mask index out of range");
2316 }
2317 }
2318
2319 /// Return if this shuffle interleaves its two input vectors together.
2320bool isInterleave(unsigned Factor);
2321
2322 /// Return true if the mask interleaves one or more input vectors together.
2323 ///
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>
2331 ///
2332 /// NumInputElts is the total number of elements in the input vectors.
2333 ///
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>
2337 ///
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,
2343SmallVectorImpl<unsigned> &StartIndexes);
2344staticboolisInterleaveMask(ArrayRef<int> Mask,unsigned Factor,
2345unsigned NumInputElts) {
2346SmallVector<unsigned, 8> StartIndexes;
2347return isInterleaveMask(Mask, Factor, NumInputElts, StartIndexes);
2348 }
2349
2350 /// Check if the mask is a DE-interleave mask of the given factor
2351 /// \p Factor like:
2352 /// <Index, Index+Factor, ..., Index+(NumElts-1)*Factor>
2353staticbool isDeInterleaveMaskOfFactor(ArrayRef<int> Mask,unsigned Factor,
2354unsigned &Index);
2355staticboolisDeInterleaveMaskOfFactor(ArrayRef<int> Mask,unsigned Factor) {
2356unsigned Unused;
2357return isDeInterleaveMaskOfFactor(Mask, Factor, Unused);
2358 }
2359
2360 /// Checks if the shuffle is a bit rotation of the first operand across
2361 /// multiple subelements, e.g:
2362 ///
2363 /// shuffle <8 x i8> %a, <8 x i8> poison, <8 x i32> <1, 0, 3, 2, 5, 4, 7, 6>
2364 ///
2365 /// could be expressed as
2366 ///
2367 /// rotl <4 x i16> %a, 8
2368 ///
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);
2374
2375// Methods for support type inquiry through isa, cast, and dyn_cast:
2376staticboolclassof(constInstruction *I) {
2377returnI->getOpcode() == Instruction::ShuffleVector;
2378 }
2379staticboolclassof(constValue *V) {
2380return isa<Instruction>(V) && classof(cast<Instruction>(V));
2381 }
2382};
2383
2384template <>
2385structOperandTraits<ShuffleVectorInst>
2386 :publicFixedNumOperandTraits<ShuffleVectorInst, 2> {};
2387
2388DEFINE_TRANSPARENT_OPERAND_ACCESSORS(ShuffleVectorInst,Value)
2389
2390//===----------------------------------------------------------------------===//
2391// ExtractValueInst Class
2392//===----------------------------------------------------------------------===//
2393
2394/// This instruction extracts a struct member or array
2395/// element value from an aggregate value.
2396///
2397classExtractValueInst : publicUnaryInstruction {
2398SmallVector<unsigned, 4> Indices;
2399
2400ExtractValueInst(constExtractValueInst &EVI);
2401
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.
2406inlineExtractValueInst(Value *Agg,ArrayRef<unsigned> Idxs,
2407constTwine &NameStr,InsertPosition InsertBefore);
2408
2409void init(ArrayRef<unsigned> Idxs,constTwine &NameStr);
2410
2411protected:
2412// Note: Instruction needs to be a friend here to call cloneImpl.
2413friendclassInstruction;
2414
2415ExtractValueInst *cloneImpl()const;
2416
2417public:
2418staticExtractValueInst *Create(Value *Agg,ArrayRef<unsigned> Idxs,
2419constTwine &NameStr ="",
2420InsertPosition InsertBefore =nullptr) {
2421returnnew
2422ExtractValueInst(Agg, Idxs, NameStr, InsertBefore);
2423 }
2424
2425 /// Returns the type of the element that would be extracted
2426 /// with an extractvalue instruction with the specified parameters.
2427 ///
2428 /// Null is returned if the indices are invalid for the specified type.
2429staticType *getIndexedType(Type *Agg,ArrayRef<unsigned> Idxs);
2430
2431usingidx_iterator =constunsigned*;
2432
2433inlineidx_iteratoridx_begin() const{return Indices.begin(); }
2434inlineidx_iteratoridx_end() const{return Indices.end(); }
2435inlineiterator_range<idx_iterator>indices() const{
2436returnmake_range(idx_begin(), idx_end());
2437 }
2438
2439Value *getAggregateOperand() {
2440return getOperand(0);
2441 }
2442constValue *getAggregateOperand() const{
2443return getOperand(0);
2444 }
2445staticunsignedgetAggregateOperandIndex() {
2446return 0U;// get index for modifying correct operand
2447 }
2448
2449ArrayRef<unsigned>getIndices() const{
2450return Indices;
2451 }
2452
2453unsignedgetNumIndices() const{
2454return (unsigned)Indices.size();
2455 }
2456
2457boolhasIndices() const{
2458returntrue;
2459 }
2460
2461// Methods for support type inquiry through isa, cast, and dyn_cast:
2462staticboolclassof(constInstruction *I) {
2463returnI->getOpcode() == Instruction::ExtractValue;
2464 }
2465staticboolclassof(constValue *V) {
2466return isa<Instruction>(V) && classof(cast<Instruction>(V));
2467 }
2468};
2469
2470ExtractValueInst::ExtractValueInst(Value *Agg, ArrayRef<unsigned> Idxs,
2471const Twine &NameStr,
2472 InsertPosition InsertBefore)
2473 : UnaryInstruction(checkGEPType(getIndexedType(Agg->getType(), Idxs)),
2474 ExtractValue, Agg, InsertBefore) {
2475 init(Idxs, NameStr);
2476}
2477
2478//===----------------------------------------------------------------------===//
2479// InsertValueInst Class
2480//===----------------------------------------------------------------------===//
2481
2482/// This instruction inserts a struct field of array element
2483/// value into an aggregate value.
2484///
2485classInsertValueInst :publicInstruction {
2486constexprstaticIntrusiveOperandsAllocMarker AllocMarker{2};
2487
2488SmallVector<unsigned, 4> Indices;
2489
2490InsertValueInst(constInsertValueInst &IVI);
2491
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.
2496inlineInsertValueInst(Value *Agg,Value *Val,ArrayRef<unsigned> Idxs,
2497constTwine &NameStr,InsertPosition InsertBefore);
2498
2499 /// Constructors - These three constructors are convenience methods because
2500 /// one and two index insertvalue instructions are so common.
2501InsertValueInst(Value *Agg,Value *Val,unsignedIdx,
2502constTwine &NameStr ="",
2503InsertPosition InsertBefore =nullptr);
2504
2505void init(Value *Agg,Value *Val,ArrayRef<unsigned> Idxs,
2506constTwine &NameStr);
2507
2508protected:
2509// Note: Instruction needs to be a friend here to call cloneImpl.
2510friendclassInstruction;
2511
2512InsertValueInst *cloneImpl()const;
2513
2514public:
2515// allocate space for exactly two operands
2516void *operatornew(size_t S) {return User::operatornew(S, AllocMarker); }
2517voidoperatordelete(void *Ptr) { User::operatordelete(Ptr); }
2518
2519staticInsertValueInst *Create(Value *Agg,Value *Val,
2520ArrayRef<unsigned> Idxs,
2521constTwine &NameStr ="",
2522InsertPosition InsertBefore =nullptr) {
2523returnnewInsertValueInst(Agg, Val, Idxs, NameStr, InsertBefore);
2524 }
2525
2526 /// Transparently provide more efficient getOperand methods.
2527DECLARE_TRANSPARENT_OPERAND_ACCESSORS(Value);
2528
2529usingidx_iterator =constunsigned*;
2530
2531inlineidx_iteratoridx_begin() const{return Indices.begin(); }
2532inlineidx_iteratoridx_end() const{return Indices.end(); }
2533inlineiterator_range<idx_iterator>indices() const{
2534returnmake_range(idx_begin(),idx_end());
2535 }
2536
2537Value *getAggregateOperand() {
2538returngetOperand(0);
2539 }
2540constValue *getAggregateOperand() const{
2541returngetOperand(0);
2542 }
2543staticunsignedgetAggregateOperandIndex() {
2544return 0U;// get index for modifying correct operand
2545 }
2546
2547Value *getInsertedValueOperand() {
2548returngetOperand(1);
2549 }
2550constValue *getInsertedValueOperand() const{
2551returngetOperand(1);
2552 }
2553staticunsignedgetInsertedValueOperandIndex() {
2554return 1U;// get index for modifying correct operand
2555 }
2556
2557ArrayRef<unsigned>getIndices() const{
2558return Indices;
2559 }
2560
2561unsignedgetNumIndices() const{
2562return (unsigned)Indices.size();
2563 }
2564
2565boolhasIndices() const{
2566returntrue;
2567 }
2568
2569// Methods for support type inquiry through isa, cast, and dyn_cast:
2570staticboolclassof(constInstruction *I) {
2571returnI->getOpcode() == Instruction::InsertValue;
2572 }
2573staticboolclassof(constValue *V) {
2574return isa<Instruction>(V) &&classof(cast<Instruction>(V));
2575 }
2576};
2577
2578template <>
2579structOperandTraits<InsertValueInst> :
2580publicFixedNumOperandTraits<InsertValueInst, 2> {
2581};
2582
2583InsertValueInst::InsertValueInst(Value *Agg,Value *Val,
2584ArrayRef<unsigned> Idxs,constTwine &NameStr,
2585InsertPosition InsertBefore)
2586 :Instruction(Agg->getType(), InsertValue, AllocMarker, InsertBefore) {
2587 init(Agg, Val, Idxs, NameStr);
2588}
2589
2590DEFINE_TRANSPARENT_OPERAND_ACCESSORS(InsertValueInst, Value)
2591
2592//===----------------------------------------------------------------------===//
2593// PHINode Class
2594//===----------------------------------------------------------------------===//
2595
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.
2599//
2600classPHINode : publicInstruction {
2601constexprstaticHungOffOperandsAllocMarker AllocMarker{};
2602
2603 /// The number of operands actually allocated. NumOperands is
2604 /// the number actually in use.
2605unsigned ReservedSpace;
2606
2607PHINode(constPHINode &PN);
2608
2609explicitPHINode(Type *Ty,unsigned NumReservedValues,
2610constTwine &NameStr ="",
2611InsertPosition InsertBefore =nullptr)
2612 :Instruction(Ty, Instruction::PHI, AllocMarker, InsertBefore),
2613 ReservedSpace(NumReservedValues) {
2614assert(!Ty->isTokenTy() &&"PHI nodes cannot have token type!");
2615 setName(NameStr);
2616 allocHungoffUses(ReservedSpace);
2617 }
2618
2619protected:
2620// Note: Instruction needs to be a friend here to call cloneImpl.
2621friendclassInstruction;
2622
2623PHINode *cloneImpl()const;
2624
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.
2628voidallocHungoffUses(unsignedN) {
2629User::allocHungoffUses(N,/* IsPhi */true);
2630 }
2631
2632public:
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).
2635staticPHINode *Create(Type *Ty,unsigned NumReservedValues,
2636constTwine &NameStr ="",
2637InsertPosition InsertBefore =nullptr) {
2638returnnew (AllocMarker)
2639PHINode(Ty, NumReservedValues, NameStr, InsertBefore);
2640 }
2641
2642 /// Provide fast operand accessors
2643DECLARE_TRANSPARENT_OPERAND_ACCESSORS(Value);
2644
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.
2649
2650usingblock_iterator =BasicBlock **;
2651usingconst_block_iterator =BasicBlock *const *;
2652
2653const_block_iteratorblock_begin() const{
2654returnreinterpret_cast<const_block_iterator>(op_begin() + ReservedSpace);
2655 }
2656
2657const_block_iteratorblock_end() const{
2658return block_begin() + getNumOperands();
2659 }
2660
2661iterator_range<const_block_iterator>blocks() const{
2662returnmake_range(block_begin(), block_end());
2663 }
2664
2665op_rangeincoming_values() {return operands(); }
2666
2667const_op_rangeincoming_values() const{return operands(); }
2668
2669 /// Return the number of incoming edges
2670 ///
2671unsignedgetNumIncomingValues() const{return getNumOperands(); }
2672
2673 /// Return incoming value number x
2674 ///
2675Value *getIncomingValue(unsigned i) const{
2676return getOperand(i);
2677 }
2678voidsetIncomingValue(unsigned i,Value *V) {
2679assert(V &&"PHI node got a null value!");
2680assert(getType() == V->getType() &&
2681"All operands to PHI node must be the same type as the PHI node!");
2682 setOperand(i, V);
2683 }
2684
2685staticunsignedgetOperandNumForIncomingValue(unsigned i) {
2686return i;
2687 }
2688
2689staticunsignedgetIncomingValueNumForOperand(unsigned i) {
2690return i;
2691 }
2692
2693 /// Return incoming basic block number @p i.
2694 ///
2695BasicBlock *getIncomingBlock(unsigned i) const{
2696return block_begin()[i];
2697 }
2698
2699 /// Return incoming basic block corresponding
2700 /// to an operand of the PHI.
2701 ///
2702BasicBlock *getIncomingBlock(constUse &U) const{
2703assert(this == U.getUser() &&"Iterator doesn't point to PHI's Uses?");
2704return getIncomingBlock(unsigned(&U - op_begin()));
2705 }
2706
2707 /// Return incoming basic block corresponding
2708 /// to value use iterator.
2709 ///
2710BasicBlock *getIncomingBlock(Value::const_user_iteratorI) const{
2711return getIncomingBlock(I.getUse());
2712 }
2713
2714voidsetIncomingBlock(unsigned i,BasicBlock *BB) {
2715const_cast<block_iterator>(block_begin())[i] = BB;
2716 }
2717
2718 /// Copies the basic blocks from \p BBRange to the incoming basic block list
2719 /// of this PHINode, starting at \p ToIdx.
2720voidcopyIncomingBlocks(iterator_range<const_block_iterator> BBRange,
2721uint32_t ToIdx = 0) {
2722copy(BBRange,const_cast<block_iterator>(block_begin()) + ToIdx);
2723 }
2724
2725 /// Replace every incoming basic block \p Old to basic block \p New.
2726voidreplaceIncomingBlockWith(constBasicBlock *Old,BasicBlock *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);
2731 }
2732
2733 /// Add an incoming value to the end of the PHI list
2734 ///
2735voidaddIncoming(Value *V,BasicBlock *BB) {
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);
2742 }
2743
2744 /// Remove an incoming value. This is useful if a
2745 /// predecessor basic block is deleted. The value removed is returned.
2746 ///
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.
2751 ///
2752Value *removeIncomingValue(unsignedIdx,bool DeletePHIIfEmpty =true);
2753
2754Value *removeIncomingValue(constBasicBlock *BB,bool DeletePHIIfEmpty=true) {
2755intIdx = getBasicBlockIndex(BB);
2756assert(Idx >= 0 &&"Invalid basic block argument to remove!");
2757return removeIncomingValue(Idx, DeletePHIIfEmpty);
2758 }
2759
2760 /// Remove all incoming values for which the predicate returns true.
2761 /// The predicate accepts the incoming value index.
2762void removeIncomingValueIf(function_ref<bool(unsigned)>Predicate,
2763bool DeletePHIIfEmpty =true);
2764
2765 /// Return the first index of the specified basic
2766 /// block in the value list for this PHI. Returns -1 if no instance.
2767 ///
2768intgetBasicBlockIndex(constBasicBlock *BB) const{
2769for (unsigned i = 0, e = getNumOperands(); i != e; ++i)
2770if (block_begin()[i] == BB)
2771return i;
2772return -1;
2773 }
2774
2775Value *getIncomingValueForBlock(constBasicBlock *BB) const{
2776intIdx = getBasicBlockIndex(BB);
2777assert(Idx >= 0 &&"Invalid basic block argument!");
2778return getIncomingValue(Idx);
2779 }
2780
2781 /// Set every incoming value(s) for block \p BB to \p V.
2782voidsetIncomingValueForBlock(constBasicBlock *BB,Value *V) {
2783assert(BB &&"PHI node got a null basic block!");
2784bool Found =false;
2785for (unsignedOp = 0, NumOps = getNumOperands();Op != NumOps; ++Op)
2786if (getIncomingBlock(Op) == BB) {
2787 Found =true;
2788 setIncomingValue(Op, V);
2789 }
2790 (void)Found;
2791assert(Found &&"Invalid basic block argument to set!");
2792 }
2793
2794 /// If the specified PHI node always merges together the
2795 /// same value, return the value, otherwise return null.
2796Value *hasConstantValue()const;
2797
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;
2802
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.
2805boolisComplete() const{
2806returnllvm::all_of(predecessors(getParent()),
2807 [this](constBasicBlock *Pred) {
2808return getBasicBlockIndex(Pred) >= 0;
2809 });
2810 }
2811
2812 /// Methods for support type inquiry through isa, cast, and dyn_cast:
2813staticboolclassof(constInstruction *I) {
2814returnI->getOpcode() == Instruction::PHI;
2815 }
2816staticboolclassof(constValue *V) {
2817return isa<Instruction>(V) && classof(cast<Instruction>(V));
2818 }
2819
2820private:
2821void growOperands();
2822};
2823
2824template <>structOperandTraits<PHINode> :publicHungoffOperandTraits {};
2825
2826DEFINE_TRANSPARENT_OPERAND_ACCESSORS(PHINode,Value)
2827
2828//===----------------------------------------------------------------------===//
2829// LandingPadInst Class
2830//===----------------------------------------------------------------------===//
2831
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
2838/// cleanup.
2839///
2840classLandingPadInst : publicInstruction {
2841usingCleanupField =BoolBitfieldElementT<0>;
2842
2843constexprstaticHungOffOperandsAllocMarker AllocMarker{};
2844
2845 /// The number of operands actually allocated. NumOperands is
2846 /// the number actually in use.
2847unsigned ReservedSpace;
2848
2849LandingPadInst(constLandingPadInst &LP);
2850
2851public:
2852enumClauseType {Catch,Filter };
2853
2854private:
2855explicitLandingPadInst(Type *RetTy,unsigned NumReservedValues,
2856constTwine &NameStr,InsertPosition InsertBefore);
2857
2858// Allocate space for exactly zero operands.
2859void *operatornew(size_t S) {return User::operatornew(S, AllocMarker); }
2860
2861void growOperands(unsignedSize);
2862void init(unsigned NumReservedValues,const Twine &NameStr);
2863
2864protected:
2865// Note: Instruction needs to be a friend here to call cloneImpl.
2866friendclassInstruction;
2867
2868LandingPadInst *cloneImpl()const;
2869
2870public:
2871voidoperatordelete(void *Ptr) { User::operatordelete(Ptr); }
2872
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).
2875staticLandingPadInst *Create(Type *RetTy,unsigned NumReservedClauses,
2876constTwine &NameStr ="",
2877InsertPosition InsertBefore =nullptr);
2878
2879 /// Provide fast operand accessors
2880DECLARE_TRANSPARENT_OPERAND_ACCESSORS(Value);
2881
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>(); }
2886
2887 /// Indicate that this landingpad instruction is a cleanup.
2888voidsetCleanup(bool V) { setSubclassData<CleanupField>(V); }
2889
2890 /// Add a catch or filter clause to the landing pad.
2891void addClause(Constant *ClauseVal);
2892
2893 /// Get the value of the clause at index Idx. Use isCatch/isFilter to
2894 /// determine what type of clause this is.
2895Constant *getClause(unsignedIdx) const{
2896return cast<Constant>(getOperandList()[Idx]);
2897 }
2898
2899 /// Return 'true' if the clause and index Idx is a catch clause.
2900boolisCatch(unsignedIdx) const{
2901return !isa<ArrayType>(getOperandList()[Idx]->getType());
2902 }
2903
2904 /// Return 'true' if the clause and index Idx is a filter clause.
2905boolisFilter(unsignedIdx) const{
2906return isa<ArrayType>(getOperandList()[Idx]->getType());
2907 }
2908
2909 /// Get the number of clauses for this landing pad.
2910unsignedgetNumClauses() const{return getNumOperands(); }
2911
2912 /// Grow the size of the operand list to accommodate the new
2913 /// number of clauses.
2914voidreserveClauses(unsignedSize) { growOperands(Size); }
2915
2916// Methods for support type inquiry through isa, cast, and dyn_cast:
2917staticboolclassof(constInstruction *I) {
2918returnI->getOpcode() == Instruction::LandingPad;
2919 }
2920staticboolclassof(constValue *V) {
2921return isa<Instruction>(V) && classof(cast<Instruction>(V));
2922 }
2923};
2924
2925template <>
2926structOperandTraits<LandingPadInst> :publicHungoffOperandTraits {};
2927
2928DEFINE_TRANSPARENT_OPERAND_ACCESSORS(LandingPadInst,Value)
2929
2930//===----------------------------------------------------------------------===//
2931// ReturnInst Class
2932//===----------------------------------------------------------------------===//
2933
2934//===---------------------------------------------------------------------------
2935/// Return a value (possibly void), from a function. Execution
2936/// does not continue in this function any longer.
2937///
2938classReturnInst : publicInstruction {
2939ReturnInst(constReturnInst &RI,AllocInfoAllocInfo);
2940
2941private:
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
2952//
2953// NOTE: If the Value* passed is of type void then the constructor behaves as
2954// if it was passed NULL.
2955explicitReturnInst(LLVMContext &C,Value *retVal,AllocInfoAllocInfo,
2956InsertPosition InsertBefore);
2957
2958protected:
2959// Note: Instruction needs to be a friend here to call cloneImpl.
2960friendclassInstruction;
2961
2962ReturnInst *cloneImpl()const;
2963
2964public:
2965staticReturnInst *Create(LLVMContext &C,Value *retVal =nullptr,
2966InsertPosition InsertBefore =nullptr) {
2967IntrusiveOperandsAllocMarker AllocMarker{retVal ? 1U : 0U};
2968returnnew (AllocMarker)ReturnInst(C, retVal, AllocMarker, InsertBefore);
2969 }
2970
2971staticReturnInst *Create(LLVMContext &C,BasicBlock *InsertAtEnd) {
2972IntrusiveOperandsAllocMarker AllocMarker{0};
2973returnnew (AllocMarker)ReturnInst(C,nullptr, AllocMarker, InsertAtEnd);
2974 }
2975
2976 /// Provide fast operand accessors
2977DECLARE_TRANSPARENT_OPERAND_ACCESSORS(Value);
2978
2979 /// Convenience accessor. Returns null if there is no return value.
2980Value *getReturnValue() const{
2981return getNumOperands() != 0 ? getOperand(0) :nullptr;
2982 }
2983
2984unsignedgetNumSuccessors() const{return 0; }
2985
2986// Methods for support type inquiry through isa, cast, and dyn_cast:
2987staticboolclassof(constInstruction *I) {
2988return (I->getOpcode() == Instruction::Ret);
2989 }
2990staticboolclassof(constValue *V) {
2991return isa<Instruction>(V) && classof(cast<Instruction>(V));
2992 }
2993
2994private:
2995BasicBlock *getSuccessor(unsigned idx) const{
2996llvm_unreachable("ReturnInst has no successors!");
2997 }
2998
2999void setSuccessor(unsigned idx, BasicBlock *B) {
3000llvm_unreachable("ReturnInst has no successors!");
3001 }
3002};
3003
3004template <>
3005structOperandTraits<ReturnInst> :publicVariadicOperandTraits<ReturnInst> {};
3006
3007DEFINE_TRANSPARENT_OPERAND_ACCESSORS(ReturnInst,Value)
3008
3009//===----------------------------------------------------------------------===//
3010// BranchInst Class
3011//===----------------------------------------------------------------------===//
3012
3013//===---------------------------------------------------------------------------
3014/// Conditional or Unconditional Branch instruction.
3015///
3016classBranchInst : publicInstruction {
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().
3021BranchInst(constBranchInst &BI,AllocInfoAllocInfo);
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
3031explicitBranchInst(BasicBlock *IfTrue,AllocInfoAllocInfo,
3032InsertPosition InsertBefore);
3033BranchInst(BasicBlock *IfTrue,BasicBlock *IfFalse,Value *Cond,
3034AllocInfoAllocInfo,InsertPosition InsertBefore);
3035
3036void AssertOK();
3037
3038protected:
3039// Note: Instruction needs to be a friend here to call cloneImpl.
3040friendclassInstruction;
3041
3042BranchInst *cloneImpl()const;
3043
3044public:
3045 /// Iterator type that casts an operand to a basic block.
3046 ///
3047 /// This only makes sense because the successors are stored as adjacent
3048 /// operands for branch instructions.
3049structsucc_op_iterator
3050 :iterator_adaptor_base<succ_op_iterator, value_op_iterator,
3051 std::random_access_iterator_tag, BasicBlock *,
3052 ptrdiff_t, BasicBlock *, BasicBlock *> {
3053explicitsucc_op_iterator(value_op_iteratorI) :iterator_adaptor_base(I) {}
3054
3055BasicBlock *operator*() const{return cast<BasicBlock>(*I); }
3056BasicBlock *operator->() const{returnoperator*(); }
3057 };
3058
3059 /// The const version of `succ_op_iterator`.
3060structconst_succ_op_iterator
3061 :iterator_adaptor_base<const_succ_op_iterator, const_value_op_iterator,
3062 std::random_access_iterator_tag,
3063 const BasicBlock *, ptrdiff_t, const BasicBlock *,
3064 const BasicBlock *> {
3065explicitconst_succ_op_iterator(const_value_op_iteratorI)
3066 :iterator_adaptor_base(I) {}
3067
3068constBasicBlock *operator*() const{return cast<BasicBlock>(*I); }
3069constBasicBlock *operator->() const{returnoperator*(); }
3070 };
3071
3072staticBranchInst *Create(BasicBlock *IfTrue,
3073InsertPosition InsertBefore =nullptr) {
3074IntrusiveOperandsAllocMarker AllocMarker{1};
3075returnnew (AllocMarker)BranchInst(IfTrue, AllocMarker, InsertBefore);
3076 }
3077
3078staticBranchInst *Create(BasicBlock *IfTrue,BasicBlock *IfFalse,
3079Value *Cond,
3080InsertPosition InsertBefore =nullptr) {
3081IntrusiveOperandsAllocMarker AllocMarker{3};
3082returnnew (AllocMarker)
3083BranchInst(IfTrue, IfFalse,Cond, AllocMarker, InsertBefore);
3084 }
3085
3086 /// Transparently provide more efficient getOperand methods.
3087DECLARE_TRANSPARENT_OPERAND_ACCESSORS(Value);
3088
3089boolisUnconditional() const{return getNumOperands() == 1; }
3090boolisConditional() const{return getNumOperands() == 3; }
3091
3092Value *getCondition() const{
3093assert(isConditional() &&"Cannot get condition of an uncond branch!");
3094returnOp<-3>();
3095 }
3096
3097voidsetCondition(Value *V) {
3098assert(isConditional() &&"Cannot set condition of unconditional branch!");
3099Op<-3>() = V;
3100 }
3101
3102unsignedgetNumSuccessors() const{return 1+isConditional(); }
3103
3104BasicBlock *getSuccessor(unsigned i) const{
3105assert(i < getNumSuccessors() &&"Successor # out of range for Branch!");
3106return cast_or_null<BasicBlock>((&Op<-1>() - i)->get());
3107 }
3108
3109voidsetSuccessor(unsigned idx,BasicBlock *NewSucc) {
3110assert(idx < getNumSuccessors() &&"Successor # out of range for Branch!");
3111 *(&Op<-1>() - idx) = NewSucc;
3112 }
3113
3114 /// Swap the successors of this branch instruction.
3115 ///
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();
3120
3121iterator_range<succ_op_iterator>successors() {
3122returnmake_range(
3123succ_op_iterator(std::next(value_op_begin(), isConditional() ? 1 : 0)),
3124succ_op_iterator(value_op_end()));
3125 }
3126
3127iterator_range<const_succ_op_iterator>successors() const{
3128returnmake_range(const_succ_op_iterator(
3129 std::next(value_op_begin(), isConditional() ? 1 : 0)),
3130const_succ_op_iterator(value_op_end()));
3131 }
3132
3133// Methods for support type inquiry through isa, cast, and dyn_cast:
3134staticboolclassof(constInstruction *I) {
3135return (I->getOpcode() == Instruction::Br);
3136 }
3137staticboolclassof(constValue *V) {
3138return isa<Instruction>(V) && classof(cast<Instruction>(V));
3139 }
3140};
3141
3142template <>
3143structOperandTraits<BranchInst> :publicVariadicOperandTraits<BranchInst> {};
3144
3145DEFINE_TRANSPARENT_OPERAND_ACCESSORS(BranchInst,Value)
3146
3147//===----------------------------------------------------------------------===//
3148// SwitchInst Class
3149//===----------------------------------------------------------------------===//
3150
3151//===---------------------------------------------------------------------------
3152/// Multiway switch
3153///
3154classSwitchInst : publicInstruction {
3155constexprstaticHungOffOperandsAllocMarker AllocMarker{};
3156
3157unsigned ReservedSpace;
3158
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
3163SwitchInst(constSwitchInst &SI);
3164
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.
3169SwitchInst(Value *Value,BasicBlock *Default,unsigned NumCases,
3170InsertPosition InsertBefore);
3171
3172// allocate space for exactly zero operands
3173void *operatornew(size_t S) {return User::operatornew(S, AllocMarker); }
3174
3175void init(Value *Value,BasicBlock *Default,unsigned NumReserved);
3176void growOperands();
3177
3178protected:
3179// Note: Instruction needs to be a friend here to call cloneImpl.
3180friendclassInstruction;
3181
3182SwitchInst *cloneImpl()const;
3183
3184public:
3185voidoperatordelete(void *Ptr) { User::operatordelete(Ptr); }
3186
3187// -2
3188staticconstunsigned DefaultPseudoIndex =static_cast<unsigned>(~0L-1);
3189
3190template <typename CaseHandleT>classCaseIteratorImpl;
3191
3192 /// A handle to a particular switch case. It exposes a convenient interface
3193 /// to both the case value and the successor block.
3194 ///
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>
3198classCaseHandleImpl {
3199// Directly befriend both const and non-const iterators.
3200friendclassSwitchInst::CaseIteratorImpl<
3201CaseHandleImpl<SwitchInstT, ConstantIntT, BasicBlockT>>;
3202
3203protected:
3204// Expose the switch type we're parameterized with to the iterator.
3205usingSwitchInstType = SwitchInstT;
3206
3207 SwitchInstT *SI;
3208ptrdiff_tIndex;
3209
3210CaseHandleImpl() =default;
3211CaseHandleImpl(SwitchInstT *SI,ptrdiff_tIndex) :SI(SI),Index(Index) {}
3212
3213public:
3214 /// Resolves case value for current case.
3215 ConstantIntT *getCaseValue() const{
3216assert((unsigned)Index < SI->getNumCases() &&
3217"Index out the number of cases.");
3218returnreinterpret_cast<ConstantIntT *>(SI->getOperand(2 +Index * 2));
3219 }
3220
3221 /// Resolves successor for current case.
3222 BasicBlockT *getCaseSuccessor() const{
3223assert(((unsigned)Index < SI->getNumCases() ||
3224 (unsigned)Index == DefaultPseudoIndex) &&
3225"Index out the number of cases.");
3226returnSI->getSuccessor(getSuccessorIndex());
3227 }
3228
3229 /// Returns number of current case.
3230unsignedgetCaseIndex() const{returnIndex; }
3231
3232 /// Returns successor index for current case successor.
3233unsignedgetSuccessorIndex() const{
3234assert(((unsigned)Index == DefaultPseudoIndex ||
3235 (unsigned)Index < SI->getNumCases()) &&
3236"Index out the number of cases.");
3237return (unsigned)Index != DefaultPseudoIndex ?Index + 1 : 0;
3238 }
3239
3240booloperator==(constCaseHandleImpl &RHS) const{
3241assert(SI ==RHS.SI &&"Incompatible operators.");
3242returnIndex ==RHS.Index;
3243 }
3244 };
3245
3246usingConstCaseHandle =
3247CaseHandleImpl<const SwitchInst, const ConstantInt, const BasicBlock>;
3248
3249classCaseHandle
3250 :publicCaseHandleImpl<SwitchInst, ConstantInt, BasicBlock> {
3251friendclassSwitchInst::CaseIteratorImpl<CaseHandle>;
3252
3253public:
3254CaseHandle(SwitchInst *SI,ptrdiff_tIndex) :CaseHandleImpl(SI,Index) {}
3255
3256 /// Sets the new value for current case.
3257voidsetValue(ConstantInt *V) const{
3258assert((unsigned)Index < SI->getNumCases() &&
3259"Index out the number of cases.");
3260SI->setOperand(2 +Index*2,reinterpret_cast<Value*>(V));
3261 }
3262
3263 /// Sets the new successor for current case.
3264voidsetSuccessor(BasicBlock *S) const{
3265SI->setSuccessor(getSuccessorIndex(), S);
3266 }
3267 };
3268
3269template <typename CaseHandleT>
3270classCaseIteratorImpl
3271 :publiciterator_facade_base<CaseIteratorImpl<CaseHandleT>,
3272 std::random_access_iterator_tag,
3273 const CaseHandleT> {
3274usingSwitchInstT =typename CaseHandleT::SwitchInstType;
3275
3276 CaseHandleT Case;
3277
3278public:
3279 /// Default constructed iterator is in an invalid state until assigned to
3280 /// a case for a particular switch.
3281CaseIteratorImpl() =default;
3282
3283 /// Initializes case iterator for given SwitchInst and for given
3284 /// case number.
3285CaseIteratorImpl(SwitchInstT *SI,unsigned CaseNum) : Case(SI, CaseNum) {}
3286
3287 /// Initializes case iterator for given SwitchInst and for given
3288 /// successor index.
3289staticCaseIteratorImplfromSuccessorIndex(SwitchInstT *SI,
3290unsigned SuccessorIndex) {
3291assert(SuccessorIndex < SI->getNumSuccessors() &&
3292"Successor index # out of range!");
3293return SuccessorIndex != 0 ?CaseIteratorImpl(SI, SuccessorIndex - 1)
3294 :CaseIteratorImpl(SI, DefaultPseudoIndex);
3295 }
3296
3297 /// Support converting to the const variant. This will be a no-op for const
3298 /// variant.
3299operatorCaseIteratorImpl<ConstCaseHandle>() const{
3300returnCaseIteratorImpl<ConstCaseHandle>(Case.SI, Case.Index);
3301 }
3302
3303CaseIteratorImpl &operator+=(ptrdiff_tN) {
3304// Check index correctness after addition.
3305// Note: Index == getNumCases() means end().
3306assert(Case.Index +N >= 0 &&
3307 (unsigned)(Case.Index +N) <= Case.SI->getNumCases() &&
3308"Case.Index out the number of cases.");
3309 Case.Index +=N;
3310return *this;
3311 }
3312CaseIteratorImpl &operator-=(ptrdiff_tN) {
3313// Check index correctness after subtraction.
3314// Note: Case.Index == getNumCases() means end().
3315assert(Case.Index -N >= 0 &&
3316 (unsigned)(Case.Index -N) <= Case.SI->getNumCases() &&
3317"Case.Index out the number of cases.");
3318 Case.Index -=N;
3319return *this;
3320 }
3321ptrdiff_toperator-(constCaseIteratorImpl &RHS) const{
3322assert(Case.SI ==RHS.Case.SI &&"Incompatible operators.");
3323return Case.Index -RHS.Case.Index;
3324 }
3325booloperator==(constCaseIteratorImpl &RHS) const{
3326return Case ==RHS.Case;
3327 }
3328booloperator<(constCaseIteratorImpl &RHS) const{
3329assert(Case.SI ==RHS.Case.SI &&"Incompatible operators.");
3330return Case.Index <RHS.Case.Index;
3331 }
3332const CaseHandleT &operator*() const{return Case; }
3333 };
3334
3335usingCaseIt =CaseIteratorImpl<CaseHandle>;
3336usingConstCaseIt =CaseIteratorImpl<ConstCaseHandle>;
3337
3338staticSwitchInst *Create(Value *Value,BasicBlock *Default,
3339unsigned NumCases,
3340InsertPosition InsertBefore =nullptr) {
3341returnnewSwitchInst(Value,Default, NumCases, InsertBefore);
3342 }
3343
3344 /// Provide fast operand accessors
3345DECLARE_TRANSPARENT_OPERAND_ACCESSORS(Value);
3346
3347// Accessor Methods for Switch stmt
3348Value *getCondition() const{return getOperand(0); }
3349voidsetCondition(Value *V) { setOperand(0, V); }
3350
3351BasicBlock *getDefaultDest() const{
3352return cast<BasicBlock>(getOperand(1));
3353 }
3354
3355 /// Returns true if the default branch must result in immediate undefined
3356 /// behavior, false otherwise.
3357booldefaultDestUndefined() const{
3358return isa<UnreachableInst>(getDefaultDest()->getFirstNonPHIOrDbg());
3359 }
3360
3361voidsetDefaultDest(BasicBlock *DefaultCase) {
3362 setOperand(1,reinterpret_cast<Value*>(DefaultCase));
3363 }
3364
3365 /// Return the number of 'cases' in this switch instruction, excluding the
3366 /// default case.
3367unsignedgetNumCases() const{
3368return getNumOperands()/2 - 1;
3369 }
3370
3371 /// Returns a read/write iterator that points to the first case in the
3372 /// SwitchInst.
3373CaseItcase_begin() {
3374returnCaseIt(this, 0);
3375 }
3376
3377 /// Returns a read-only iterator that points to the first case in the
3378 /// SwitchInst.
3379ConstCaseItcase_begin() const{
3380returnConstCaseIt(this, 0);
3381 }
3382
3383 /// Returns a read/write iterator that points one past the last in the
3384 /// SwitchInst.
3385CaseItcase_end() {
3386returnCaseIt(this, getNumCases());
3387 }
3388
3389 /// Returns a read-only iterator that points one past the last in the
3390 /// SwitchInst.
3391ConstCaseItcase_end() const{
3392returnConstCaseIt(this, getNumCases());
3393 }
3394
3395 /// Iteration adapter for range-for loops.
3396iterator_range<CaseIt>cases() {
3397returnmake_range(case_begin(), case_end());
3398 }
3399
3400 /// Constant iteration adapter for range-for loops.
3401iterator_range<ConstCaseIt>cases() const{
3402returnmake_range(case_begin(), case_end());
3403 }
3404
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.
3410CaseItcase_default() {
3411returnCaseIt(this, DefaultPseudoIndex);
3412 }
3413ConstCaseItcase_default() const{
3414returnConstCaseIt(this, DefaultPseudoIndex);
3415 }
3416
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
3420 /// handler.
3421CaseItfindCaseValue(constConstantInt *C) {
3422returnCaseIt(
3423this,
3424const_cast<constSwitchInst *>(this)->findCaseValue(C)->getCaseIndex());
3425 }
3426ConstCaseItfindCaseValue(constConstantInt *C) const{
3427ConstCaseItI =llvm::find_if(cases(), [C](constConstCaseHandle &Case) {
3428return Case.getCaseValue() ==C;
3429 });
3430if (I != case_end())
3431returnI;
3432
3433return case_default();
3434 }
3435
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.
3438ConstantInt *findCaseDest(BasicBlock *BB) {
3439if (BB == getDefaultDest())
3440returnnullptr;
3441
3442ConstantInt *CI =nullptr;
3443for (auto Case : cases()) {
3444if (Case.getCaseSuccessor() != BB)
3445continue;
3446
3447if (CI)
3448returnnullptr;// Multiple cases lead to BB.
3449
3450 CI = Case.getCaseValue();
3451 }
3452
3453return CI;
3454 }
3455
3456 /// Add an entry to the switch instruction.
3457 /// Note:
3458 /// This action invalidates case_end(). Old case_end() iterator will
3459 /// point to the added case.
3460void addCase(ConstantInt *OnVal,BasicBlock *Dest);
3461
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.
3465 /// Note:
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
3468 /// case.
3469 CaseIt removeCase(CaseItI);
3470
3471unsignedgetNumSuccessors() const{return getNumOperands()/2; }
3472BasicBlock *getSuccessor(unsigned idx) const{
3473assert(idx < getNumSuccessors() &&"Successor idx out of range for switch!");
3474return cast<BasicBlock>(getOperand(idx*2+1));
3475 }
3476voidsetSuccessor(unsigned idx,BasicBlock *NewSucc) {
3477assert(idx < getNumSuccessors() &&"Successor # out of range for switch!");
3478 setOperand(idx * 2 + 1, NewSucc);
3479 }
3480
3481// Methods for support type inquiry through isa, cast, and dyn_cast:
3482staticboolclassof(constInstruction *I) {
3483returnI->getOpcode() == Instruction::Switch;
3484 }
3485staticboolclassof(constValue *V) {
3486return isa<Instruction>(V) && classof(cast<Instruction>(V));
3487 }
3488};
3489
3490/// A wrapper class to simplify modification of SwitchInst cases along with
3491/// their prof branch_weights metadata.
3492classSwitchInstProfUpdateWrapper {
3493SwitchInst &SI;
3494 std::optional<SmallVector<uint32_t, 8>> Weights;
3495bool Changed =false;
3496
3497protected:
3498MDNode *buildProfBranchWeightsMD();
3499
3500voidinit();
3501
3502public:
3503usingCaseWeightOpt = std::optional<uint32_t>;
3504SwitchInst *operator->() {return &SI; }
3505SwitchInst &operator*() {return SI; }
3506operatorSwitchInst *() {return &SI; }
3507
3508SwitchInstProfUpdateWrapper(SwitchInst &SI) : SI(SI) {init(); }
3509
3510~SwitchInstProfUpdateWrapper() {
3511if (Changed)
3512 SI.setMetadata(LLVMContext::MD_prof,buildProfBranchWeightsMD());
3513 }
3514
3515 /// Delegate the call to the underlying SwitchInst::removeCase() and remove
3516 /// correspondent branch weight.
3517SwitchInst::CaseItremoveCase(SwitchInst::CaseItI);
3518
3519 /// Delegate the call to the underlying SwitchInst::addCase() and set the
3520 /// specified branch weight for the added case.
3521voidaddCase(ConstantInt *OnVal,BasicBlock *Dest,CaseWeightOpt W);
3522
3523 /// Delegate the call to the underlying SwitchInst::eraseFromParent() and mark
3524 /// this object to not touch the underlying SwitchInst in destructor.
3525Instruction::InstListType::iteratoreraseFromParent();
3526
3527voidsetSuccessorWeight(unsigned idx,CaseWeightOpt W);
3528CaseWeightOptgetSuccessorWeight(unsigned idx);
3529
3530staticCaseWeightOptgetSuccessorWeight(constSwitchInst &SI,unsigned idx);
3531};
3532
3533template <>structOperandTraits<SwitchInst> :publicHungoffOperandTraits {};
3534
3535DEFINE_TRANSPARENT_OPERAND_ACCESSORS(SwitchInst,Value)
3536
3537//===----------------------------------------------------------------------===//
3538// IndirectBrInst Class
3539//===----------------------------------------------------------------------===//
3540
3541//===---------------------------------------------------------------------------
3542/// Indirect Branch Instruction.
3543///
3544classIndirectBrInst : publicInstruction {
3545constexprstaticHungOffOperandsAllocMarker AllocMarker{};
3546
3547unsigned ReservedSpace;
3548
3549// Operand[0] = Address to jump to
3550// Operand[n+1] = n-th destination
3551IndirectBrInst(constIndirectBrInst &IBI);
3552
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.
3557IndirectBrInst(Value *Address,unsigned NumDests,
3558InsertPosition InsertBefore);
3559
3560// allocate space for exactly zero operands
3561void *operatornew(size_t S) {return User::operatornew(S, AllocMarker); }
3562
3563void init(Value *Address,unsigned NumDests);
3564void growOperands();
3565
3566protected:
3567// Note: Instruction needs to be a friend here to call cloneImpl.
3568friendclassInstruction;
3569
3570IndirectBrInst *cloneImpl()const;
3571
3572public:
3573voidoperatordelete(void *Ptr) { User::operatordelete(Ptr); }
3574
3575 /// Iterator type that casts an operand to a basic block.
3576 ///
3577 /// This only makes sense because the successors are stored as adjacent
3578 /// operands for indirectbr instructions.
3579structsucc_op_iterator
3580 :iterator_adaptor_base<succ_op_iterator, value_op_iterator,
3581 std::random_access_iterator_tag, BasicBlock *,
3582 ptrdiff_t, BasicBlock *, BasicBlock *> {
3583explicitsucc_op_iterator(value_op_iteratorI) :iterator_adaptor_base(I) {}
3584
3585BasicBlock *operator*() const{return cast<BasicBlock>(*I); }
3586BasicBlock *operator->() const{returnoperator*(); }
3587 };
3588
3589 /// The const version of `succ_op_iterator`.
3590structconst_succ_op_iterator
3591 :iterator_adaptor_base<const_succ_op_iterator, const_value_op_iterator,
3592 std::random_access_iterator_tag,
3593 const BasicBlock *, ptrdiff_t, const BasicBlock *,
3594 const BasicBlock *> {
3595explicitconst_succ_op_iterator(const_value_op_iteratorI)
3596 :iterator_adaptor_base(I) {}
3597
3598constBasicBlock *operator*() const{return cast<BasicBlock>(*I); }
3599constBasicBlock *operator->() const{returnoperator*(); }
3600 };
3601
3602staticIndirectBrInst *Create(Value *Address,unsigned NumDests,
3603InsertPosition InsertBefore =nullptr) {
3604returnnewIndirectBrInst(Address, NumDests, InsertBefore);
3605 }
3606
3607 /// Provide fast operand accessors.
3608DECLARE_TRANSPARENT_OPERAND_ACCESSORS(Value);
3609
3610// Accessor Methods for IndirectBrInst instruction.
3611Value *getAddress() {return getOperand(0); }
3612constValue *getAddress() const{return getOperand(0); }
3613voidsetAddress(Value *V) { setOperand(0, V); }
3614
3615 /// return the number of possible destinations in this
3616 /// indirectbr instruction.
3617unsignedgetNumDestinations() const{return getNumOperands()-1; }
3618
3619 /// Return the specified destination.
3620BasicBlock *getDestination(unsigned i) {return getSuccessor(i); }
3621constBasicBlock *getDestination(unsigned i) const{return getSuccessor(i); }
3622
3623 /// Add a destination.
3624 ///
3625void addDestination(BasicBlock *Dest);
3626
3627 /// This method removes the specified successor from the
3628 /// indirectbr instruction.
3629void removeDestination(unsigned i);
3630
3631unsignedgetNumSuccessors() const{return getNumOperands()-1; }
3632BasicBlock *getSuccessor(unsigned i) const{
3633return cast<BasicBlock>(getOperand(i+1));
3634 }
3635voidsetSuccessor(unsigned i,BasicBlock *NewSucc) {
3636 setOperand(i + 1, NewSucc);
3637 }
3638
3639iterator_range<succ_op_iterator>successors() {
3640returnmake_range(succ_op_iterator(std::next(value_op_begin())),
3641succ_op_iterator(value_op_end()));
3642 }
3643
3644iterator_range<const_succ_op_iterator>successors() const{
3645returnmake_range(const_succ_op_iterator(std::next(value_op_begin())),
3646const_succ_op_iterator(value_op_end()));
3647 }
3648
3649// Methods for support type inquiry through isa, cast, and dyn_cast:
3650staticboolclassof(constInstruction *I) {
3651returnI->getOpcode() == Instruction::IndirectBr;
3652 }
3653staticboolclassof(constValue *V) {
3654return isa<Instruction>(V) && classof(cast<Instruction>(V));
3655 }
3656};
3657
3658template <>
3659structOperandTraits<IndirectBrInst> :publicHungoffOperandTraits {};
3660
3661DEFINE_TRANSPARENT_OPERAND_ACCESSORS(IndirectBrInst,Value)
3662
3663//===----------------------------------------------------------------------===//
3664// InvokeInst Class
3665//===----------------------------------------------------------------------===//
3666
3667/// Invoke instruction. The SubclassData field is used to hold the
3668/// calling convention of the call.
3669///
3670classInvokeInst : publicCallBase {
3671 /// The number of operands for this call beyond the called function,
3672 /// arguments, and operand bundles.
3673staticconstexprint NumExtraOperands = 2;
3674
3675 /// The index from the end of the operand array to the normal destination.
3676staticconstexprint NormalDestOpEndIdx = -3;
3677
3678 /// The index from the end of the operand array to the unwind destination.
3679staticconstexprint UnwindDestOpEndIdx = -2;
3680
3681InvokeInst(constInvokeInst &BI,AllocInfoAllocInfo);
3682
3683 /// Construct an InvokeInst given a range of arguments.
3684 ///
3685 /// Construct an InvokeInst from a range of arguments
3686inlineInvokeInst(FunctionType *Ty,Value *Func,BasicBlock *IfNormal,
3687BasicBlock *IfException,ArrayRef<Value *> Args,
3688ArrayRef<OperandBundleDef> Bundles,AllocInfoAllocInfo,
3689constTwine &NameStr,InsertPosition InsertBefore);
3690
3691void init(FunctionType *Ty,Value *Func,BasicBlock *IfNormal,
3692BasicBlock *IfException,ArrayRef<Value *> Args,
3693ArrayRef<OperandBundleDef> Bundles,constTwine &NameStr);
3694
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);
3701 }
3702
3703protected:
3704// Note: Instruction needs to be a friend here to call cloneImpl.
3705friendclassInstruction;
3706
3707InvokeInst *cloneImpl()const;
3708
3709public:
3710staticInvokeInst *Create(FunctionType *Ty,Value *Func,BasicBlock *IfNormal,
3711BasicBlock *IfException,ArrayRef<Value *> Args,
3712constTwine &NameStr,
3713InsertPosition InsertBefore =nullptr) {
3714IntrusiveOperandsAllocMarker AllocMarker{
3715 ComputeNumOperands(unsigned(Args.size()))};
3716returnnew (AllocMarker)InvokeInst(Ty, Func, IfNormal, IfException, Args,
3717 {}, AllocMarker, NameStr, InsertBefore);
3718 }
3719
3720staticInvokeInst *Create(FunctionType *Ty,Value *Func,BasicBlock *IfNormal,
3721BasicBlock *IfException,ArrayRef<Value *> Args,
3722ArrayRef<OperandBundleDef> Bundles = {},
3723constTwine &NameStr ="",
3724InsertPosition InsertBefore =nullptr) {
3725 IntrusiveOperandsAndDescriptorAllocMarker AllocMarker{
3726 ComputeNumOperands(Args.size(), CountBundleInputs(Bundles)),
3727unsigned(Bundles.size() *sizeof(BundleOpInfo))};
3728
3729returnnew (AllocMarker)
3730 InvokeInst(Ty, Func, IfNormal, IfException, Args, Bundles, AllocMarker,
3731 NameStr, InsertBefore);
3732 }
3733
3734staticInvokeInst *Create(FunctionCallee Func,BasicBlock *IfNormal,
3735BasicBlock *IfException,ArrayRef<Value *> Args,
3736constTwine &NameStr,
3737InsertPosition InsertBefore =nullptr) {
3738return Create(Func.getFunctionType(), Func.getCallee(), IfNormal,
3739 IfException, Args, {}, NameStr, InsertBefore);
3740 }
3741
3742staticInvokeInst *Create(FunctionCallee Func,BasicBlock *IfNormal,
3743BasicBlock *IfException,ArrayRef<Value *> Args,
3744ArrayRef<OperandBundleDef> Bundles = {},
3745constTwine &NameStr ="",
3746InsertPosition InsertBefore =nullptr) {
3747return Create(Func.getFunctionType(), Func.getCallee(), IfNormal,
3748 IfException, Args, Bundles, NameStr, InsertBefore);
3749 }
3750
3751 /// Create a clone of \p II with a different set of operand bundles and
3752 /// insert it before \p InsertBefore.
3753 ///
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);
3759
3760// get*Dest - Return the destination basic blocks...
3761BasicBlock *getNormalDest() const{
3762return cast<BasicBlock>(Op<NormalDestOpEndIdx>());
3763 }
3764BasicBlock *getUnwindDest() const{
3765return cast<BasicBlock>(Op<UnwindDestOpEndIdx>());
3766 }
3767voidsetNormalDest(BasicBlock *B) {
3768Op<NormalDestOpEndIdx>() =reinterpret_cast<Value *>(B);
3769 }
3770voidsetUnwindDest(BasicBlock *B) {
3771Op<UnwindDestOpEndIdx>() =reinterpret_cast<Value *>(B);
3772 }
3773
3774 /// Get the landingpad instruction from the landing pad
3775 /// block (the unwind destination).
3776LandingPadInst *getLandingPadInst()const;
3777
3778BasicBlock *getSuccessor(unsigned i) const{
3779assert(i < 2 &&"Successor # out of range for invoke!");
3780return i == 0 ? getNormalDest() : getUnwindDest();
3781 }
3782
3783voidsetSuccessor(unsigned i,BasicBlock *NewSucc) {
3784assert(i < 2 &&"Successor # out of range for invoke!");
3785if (i == 0)
3786 setNormalDest(NewSucc);
3787else
3788 setUnwindDest(NewSucc);
3789 }
3790
3791unsignedgetNumSuccessors() const{return 2; }
3792
3793 /// Updates profile metadata by scaling it by \p S / \p T.
3794void updateProfWeight(uint64_t S,uint64_tT);
3795
3796// Methods for support type inquiry through isa, cast, and dyn_cast:
3797staticboolclassof(constInstruction *I) {
3798return (I->getOpcode() == Instruction::Invoke);
3799 }
3800staticboolclassof(constValue *V) {
3801return isa<Instruction>(V) && classof(cast<Instruction>(V));
3802 }
3803
3804private:
3805// Shadow Instruction::setInstructionSubclassData with a private forwarding
3806// method so that subclasses cannot accidentally use it.
3807template <typename Bitfield>
3808void setSubclassData(typename Bitfield::TypeValue) {
3809 Instruction::setSubclassData<Bitfield>(Value);
3810 }
3811};
3812
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,
3818 InsertBefore) {
3819init(Ty, Func, IfNormal, IfException, Args, Bundles, NameStr);
3820}
3821
3822//===----------------------------------------------------------------------===//
3823// CallBrInst Class
3824//===----------------------------------------------------------------------===//
3825
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.
3829///
3830classCallBrInst :publicCallBase {
3831
3832unsigned NumIndirectDests;
3833
3834CallBrInst(constCallBrInst &BI,AllocInfoAllocInfo);
3835
3836 /// Construct a CallBrInst given a range of arguments.
3837 ///
3838 /// Construct a CallBrInst from a range of arguments
3839inlineCallBrInst(FunctionType *Ty,Value *Func,BasicBlock *DefaultDest,
3840ArrayRef<BasicBlock *> IndirectDests,
3841ArrayRef<Value *> Args,ArrayRef<OperandBundleDef> Bundles,
3842AllocInfoAllocInfo,constTwine &NameStr,
3843InsertPosition InsertBefore);
3844
3845void init(FunctionType *FTy,Value *Func,BasicBlock *DefaultDest,
3846ArrayRef<BasicBlock *> IndirectDests,ArrayRef<Value *> Args,
3847ArrayRef<OperandBundleDef> Bundles,constTwine &NameStr);
3848
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);
3855 }
3856
3857protected:
3858// Note: Instruction needs to be a friend here to call cloneImpl.
3859friendclassInstruction;
3860
3861CallBrInst *cloneImpl()const;
3862
3863public:
3864staticCallBrInst *Create(FunctionType *Ty,Value *Func,
3865BasicBlock *DefaultDest,
3866ArrayRef<BasicBlock *> IndirectDests,
3867ArrayRef<Value *> Args,constTwine &NameStr,
3868InsertPosition InsertBefore =nullptr) {
3869IntrusiveOperandsAllocMarker AllocMarker{
3870 ComputeNumOperands(Args.size(), IndirectDests.size())};
3871returnnew (AllocMarker)
3872CallBrInst(Ty, Func, DefaultDest, IndirectDests, Args, {}, AllocMarker,
3873 NameStr, InsertBefore);
3874 }
3875
3876staticCallBrInst *
3877Create(FunctionType *Ty,Value *Func,BasicBlock *DefaultDest,
3878ArrayRef<BasicBlock *> IndirectDests,ArrayRef<Value *> Args,
3879ArrayRef<OperandBundleDef> Bundles = {},constTwine &NameStr ="",
3880InsertPosition InsertBefore =nullptr) {
3881 IntrusiveOperandsAndDescriptorAllocMarker AllocMarker{
3882 ComputeNumOperands(Args.size(), IndirectDests.size(),
3883CountBundleInputs(Bundles)),
3884unsigned(Bundles.size() *sizeof(BundleOpInfo))};
3885
3886returnnew (AllocMarker)
3887 CallBrInst(Ty, Func, DefaultDest, IndirectDests, Args, Bundles,
3888 AllocMarker, NameStr, InsertBefore);
3889 }
3890
3891staticCallBrInst *Create(FunctionCallee Func,BasicBlock *DefaultDest,
3892ArrayRef<BasicBlock *> IndirectDests,
3893ArrayRef<Value *> Args,constTwine &NameStr,
3894InsertPosition InsertBefore =nullptr) {
3895returnCreate(Func.getFunctionType(), Func.getCallee(), DefaultDest,
3896 IndirectDests, Args, NameStr, InsertBefore);
3897 }
3898
3899staticCallBrInst *Create(FunctionCallee Func,BasicBlock *DefaultDest,
3900ArrayRef<BasicBlock *> IndirectDests,
3901ArrayRef<Value *> Args,
3902ArrayRef<OperandBundleDef> Bundles = {},
3903constTwine &NameStr ="",
3904InsertPosition InsertBefore =nullptr) {
3905returnCreate(Func.getFunctionType(), Func.getCallee(), DefaultDest,
3906 IndirectDests, Args, Bundles, NameStr, InsertBefore);
3907 }
3908
3909 /// Create a clone of \p CBI with a different set of operand bundles and
3910 /// insert it before \p InsertBefore.
3911 ///
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);
3917
3918 /// Return the number of callbr indirect dest labels.
3919 ///
3920unsignedgetNumIndirectDests() const{return NumIndirectDests; }
3921
3922 /// getIndirectDestLabel - Return the i-th indirect dest label.
3923 ///
3924Value *getIndirectDestLabel(unsigned i) const{
3925assert(i <getNumIndirectDests() &&"Out of bounds!");
3926returngetOperand(i +arg_size() +getNumTotalBundleOperands() + 1);
3927 }
3928
3929Value *getIndirectDestLabelUse(unsigned i) const{
3930assert(i <getNumIndirectDests() &&"Out of bounds!");
3931returngetOperandUse(i +arg_size() +getNumTotalBundleOperands() + 1);
3932 }
3933
3934// Return the destination basic blocks...
3935BasicBlock *getDefaultDest() const{
3936return cast<BasicBlock>(*(&Op<-1>() -getNumIndirectDests() - 1));
3937 }
3938BasicBlock *getIndirectDest(unsigned i) const{
3939return cast_or_null<BasicBlock>(*(&Op<-1>() -getNumIndirectDests() + i));
3940 }
3941SmallVector<BasicBlock *, 16>getIndirectDests() const{
3942SmallVector<BasicBlock *, 16> IndirectDests;
3943for (unsigned i = 0, e =getNumIndirectDests(); i < e; ++i)
3944 IndirectDests.push_back(getIndirectDest(i));
3945return IndirectDests;
3946 }
3947voidsetDefaultDest(BasicBlock *B) {
3948 *(&Op<-1>() -getNumIndirectDests() - 1) =reinterpret_cast<Value *>(B);
3949 }
3950voidsetIndirectDest(unsigned i,BasicBlock *B) {
3951 *(&Op<-1>() -getNumIndirectDests() + i) =reinterpret_cast<Value *>(B);
3952 }
3953
3954BasicBlock *getSuccessor(unsigned i) const{
3955assert(i <getNumSuccessors() + 1 &&
3956"Successor # out of range for callbr!");
3957return i == 0 ?getDefaultDest() :getIndirectDest(i - 1);
3958 }
3959
3960voidsetSuccessor(unsigned i,BasicBlock *NewSucc) {
3961assert(i <getNumIndirectDests() + 1 &&
3962"Successor # out of range for callbr!");
3963return i == 0 ?setDefaultDest(NewSucc) :setIndirectDest(i - 1, NewSucc);
3964 }
3965
3966unsignedgetNumSuccessors() const{returngetNumIndirectDests() + 1; }
3967
3968// Methods for support type inquiry through isa, cast, and dyn_cast:
3969staticboolclassof(constInstruction *I) {
3970return (I->getOpcode() == Instruction::CallBr);
3971 }
3972staticboolclassof(constValue *V) {
3973return isa<Instruction>(V) &&classof(cast<Instruction>(V));
3974 }
3975
3976private:
3977// Shadow Instruction::setInstructionSubclassData with a private forwarding
3978// method so that subclasses cannot accidentally use it.
3979template <typename Bitfield>
3980void setSubclassData(typename Bitfield::TypeValue) {
3981 Instruction::setSubclassData<Bitfield>(Value);
3982 }
3983};
3984
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,
3991 InsertBefore) {
3992init(Ty, Func, DefaultDest, IndirectDests, Args, Bundles, NameStr);
3993}
3994
3995//===----------------------------------------------------------------------===//
3996// ResumeInst Class
3997//===----------------------------------------------------------------------===//
3998
3999//===---------------------------------------------------------------------------
4000/// Resume the propagation of an exception.
4001///
4002classResumeInst :publicInstruction {
4003constexprstaticIntrusiveOperandsAllocMarker AllocMarker{1};
4004
4005ResumeInst(constResumeInst &RI);
4006
4007explicitResumeInst(Value *Exn,InsertPosition InsertBefore =nullptr);
4008
4009protected:
4010// Note: Instruction needs to be a friend here to call cloneImpl.
4011friendclassInstruction;
4012
4013ResumeInst *cloneImpl()const;
4014
4015public:
4016staticResumeInst *Create(Value *Exn,InsertPosition InsertBefore =nullptr) {
4017returnnew (AllocMarker)ResumeInst(Exn, InsertBefore);
4018 }
4019
4020 /// Provide fast operand accessors
4021DECLARE_TRANSPARENT_OPERAND_ACCESSORS(Value);
4022
4023 /// Convenience accessor.
4024Value *getValue() const{returnOp<0>(); }
4025
4026unsignedgetNumSuccessors() const{return 0; }
4027
4028// Methods for support type inquiry through isa, cast, and dyn_cast:
4029staticboolclassof(constInstruction *I) {
4030returnI->getOpcode() == Instruction::Resume;
4031 }
4032staticboolclassof(constValue *V) {
4033return isa<Instruction>(V) &&classof(cast<Instruction>(V));
4034 }
4035
4036private:
4037BasicBlock *getSuccessor(unsigned idx) const{
4038llvm_unreachable("ResumeInst has no successors!");
4039 }
4040
4041void setSuccessor(unsigned idx,BasicBlock *NewSucc) {
4042llvm_unreachable("ResumeInst has no successors!");
4043 }
4044};
4045
4046template <>
4047structOperandTraits<ResumeInst> :
4048publicFixedNumOperandTraits<ResumeInst, 1> {
4049};
4050
4051DEFINE_TRANSPARENT_OPERAND_ACCESSORS(ResumeInst,Value)
4052
4053//===----------------------------------------------------------------------===//
4054// CatchSwitchInst Class
4055//===----------------------------------------------------------------------===//
4056classCatchSwitchInst : publicInstruction {
4057usingUnwindDestField =BoolBitfieldElementT<0>;
4058
4059constexprstaticHungOffOperandsAllocMarker AllocMarker{};
4060
4061 /// The number of operands actually allocated. NumOperands is
4062 /// the number actually in use.
4063unsigned ReservedSpace;
4064
4065// Operand[0] = Outer scope
4066// Operand[1] = Unwind block destination
4067// Operand[n] = BasicBlock to go to on match
4068CatchSwitchInst(constCatchSwitchInst &CSI);
4069
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.
4074CatchSwitchInst(Value *ParentPad,BasicBlock *UnwindDest,
4075unsigned NumHandlers,constTwine &NameStr,
4076InsertPosition InsertBefore);
4077
4078// allocate space for exactly zero operands
4079void *operatornew(size_t S) {return User::operatornew(S, AllocMarker); }
4080
4081void init(Value *ParentPad,BasicBlock *UnwindDest,unsigned NumReserved);
4082void growOperands(unsignedSize);
4083
4084protected:
4085// Note: Instruction needs to be a friend here to call cloneImpl.
4086friendclassInstruction;
4087
4088CatchSwitchInst *cloneImpl()const;
4089
4090public:
4091voidoperatordelete(void *Ptr) {return User::operatordelete(Ptr); }
4092
4093staticCatchSwitchInst *Create(Value *ParentPad,BasicBlock *UnwindDest,
4094unsigned NumHandlers,
4095constTwine &NameStr ="",
4096InsertPosition InsertBefore =nullptr) {
4097returnnewCatchSwitchInst(ParentPad, UnwindDest, NumHandlers, NameStr,
4098 InsertBefore);
4099 }
4100
4101 /// Provide fast operand accessors
4102DECLARE_TRANSPARENT_OPERAND_ACCESSORS(Value);
4103
4104// Accessor Methods for CatchSwitch stmt
4105Value *getParentPad() const{return getOperand(0); }
4106voidsetParentPad(Value *ParentPad) { setOperand(0, ParentPad); }
4107
4108// Accessor Methods for CatchSwitch stmt
4109boolhasUnwindDest() const{return getSubclassData<UnwindDestField>(); }
4110boolunwindsToCaller() const{return !hasUnwindDest(); }
4111BasicBlock *getUnwindDest() const{
4112if (hasUnwindDest())
4113return cast<BasicBlock>(getOperand(1));
4114returnnullptr;
4115 }
4116voidsetUnwindDest(BasicBlock *UnwindDest) {
4117assert(UnwindDest);
4118assert(hasUnwindDest());
4119 setOperand(1, UnwindDest);
4120 }
4121
4122 /// return the number of 'handlers' in this catchswitch
4123 /// instruction, except the default handler
4124unsignedgetNumHandlers() const{
4125if (hasUnwindDest())
4126return getNumOperands() - 2;
4127return getNumOperands() - 1;
4128 }
4129
4130private:
4131staticBasicBlock *handler_helper(Value *V) {return cast<BasicBlock>(V); }
4132staticconst BasicBlock *handler_helper(const Value *V) {
4133return cast<BasicBlock>(V);
4134 }
4135
4136public:
4137usingDerefFnTy =BasicBlock *(*)(Value *);
4138usinghandler_iterator =mapped_iterator<op_iterator, DerefFnTy>;
4139usinghandler_range =iterator_range<handler_iterator>;
4140usingConstDerefFnTy =constBasicBlock *(*)(constValue *);
4141usingconst_handler_iterator =
4142mapped_iterator<const_op_iterator, ConstDerefFnTy>;
4143usingconst_handler_range =iterator_range<const_handler_iterator>;
4144
4145 /// Returns an iterator that points to the first handler in CatchSwitchInst.
4146handler_iteratorhandler_begin() {
4147op_iterator It = op_begin() + 1;
4148if (hasUnwindDest())
4149 ++It;
4150returnhandler_iterator(It,DerefFnTy(handler_helper));
4151 }
4152
4153 /// Returns an iterator that points to the first handler in the
4154 /// CatchSwitchInst.
4155const_handler_iteratorhandler_begin() const{
4156const_op_iterator It = op_begin() + 1;
4157if (hasUnwindDest())
4158 ++It;
4159returnconst_handler_iterator(It,ConstDerefFnTy(handler_helper));
4160 }
4161
4162 /// Returns a read-only iterator that points one past the last
4163 /// handler in the CatchSwitchInst.
4164handler_iteratorhandler_end() {
4165returnhandler_iterator(op_end(),DerefFnTy(handler_helper));
4166 }
4167
4168 /// Returns an iterator that points one past the last handler in the
4169 /// CatchSwitchInst.
4170const_handler_iteratorhandler_end() const{
4171returnconst_handler_iterator(op_end(),ConstDerefFnTy(handler_helper));
4172 }
4173
4174 /// iteration adapter for range-for loops.
4175handler_rangehandlers() {
4176returnmake_range(handler_begin(), handler_end());
4177 }
4178
4179 /// iteration adapter for range-for loops.
4180const_handler_rangehandlers() const{
4181returnmake_range(handler_begin(), handler_end());
4182 }
4183
4184 /// Add an entry to the switch instruction...
4185 /// Note:
4186 /// This action invalidates handler_end(). Old handler_end() iterator will
4187 /// point to the added handler.
4188void addHandler(BasicBlock *Dest);
4189
4190void removeHandler(handler_iterator HI);
4191
4192unsignedgetNumSuccessors() const{return getNumOperands() - 1; }
4193BasicBlock *getSuccessor(unsignedIdx) const{
4194assert(Idx < getNumSuccessors() &&
4195"Successor # out of range for catchswitch!");
4196return cast<BasicBlock>(getOperand(Idx + 1));
4197 }
4198voidsetSuccessor(unsignedIdx,BasicBlock *NewSucc) {
4199assert(Idx < getNumSuccessors() &&
4200"Successor # out of range for catchswitch!");
4201 setOperand(Idx + 1, NewSucc);
4202 }
4203
4204// Methods for support type inquiry through isa, cast, and dyn_cast:
4205staticboolclassof(constInstruction *I) {
4206returnI->getOpcode() == Instruction::CatchSwitch;
4207 }
4208staticboolclassof(constValue *V) {
4209return isa<Instruction>(V) && classof(cast<Instruction>(V));
4210 }
4211};
4212
4213template <>
4214structOperandTraits<CatchSwitchInst> :publicHungoffOperandTraits {};
4215
4216DEFINE_TRANSPARENT_OPERAND_ACCESSORS(CatchSwitchInst,Value)
4217
4218//===----------------------------------------------------------------------===//
4219// CleanupPadInst Class
4220//===----------------------------------------------------------------------===//
4221classCleanupPadInst : publicFuncletPadInst {
4222private:
4223explicitCleanupPadInst(Value *ParentPad,ArrayRef<Value *> Args,
4224AllocInfoAllocInfo,constTwine &NameStr,
4225InsertPosition InsertBefore)
4226 :FuncletPadInst(Instruction::CleanupPad, ParentPad, Args,AllocInfo,
4227 NameStr, InsertBefore) {}
4228
4229public:
4230staticCleanupPadInst *Create(Value *ParentPad,ArrayRef<Value *> Args = {},
4231constTwine &NameStr ="",
4232InsertPosition InsertBefore =nullptr) {
4233 IntrusiveOperandsAllocMarker AllocMarker{unsigned(1 + Args.size())};
4234returnnew (AllocMarker)
4235 CleanupPadInst(ParentPad, Args, AllocMarker, NameStr, InsertBefore);
4236 }
4237
4238 /// Methods for support type inquiry through isa, cast, and dyn_cast:
4239staticboolclassof(constInstruction *I) {
4240returnI->getOpcode() == Instruction::CleanupPad;
4241 }
4242staticboolclassof(constValue *V) {
4243return isa<Instruction>(V) && classof(cast<Instruction>(V));
4244 }
4245};
4246
4247//===----------------------------------------------------------------------===//
4248// CatchPadInst Class
4249//===----------------------------------------------------------------------===//
4250classCatchPadInst :publicFuncletPadInst {
4251private:
4252explicitCatchPadInst(Value *CatchSwitch,ArrayRef<Value *> Args,
4253AllocInfoAllocInfo,constTwine &NameStr,
4254InsertPosition InsertBefore)
4255 :FuncletPadInst(Instruction::CatchPad, CatchSwitch, Args,AllocInfo,
4256 NameStr, InsertBefore) {}
4257
4258public:
4259staticCatchPadInst *Create(Value *CatchSwitch,ArrayRef<Value *> Args,
4260constTwine &NameStr ="",
4261InsertPosition InsertBefore =nullptr) {
4262IntrusiveOperandsAllocMarker AllocMarker{unsigned(1 + Args.size())};
4263returnnew (AllocMarker)
4264CatchPadInst(CatchSwitch, Args, AllocMarker, NameStr, InsertBefore);
4265 }
4266
4267 /// Convenience accessors
4268CatchSwitchInst *getCatchSwitch() const{
4269return cast<CatchSwitchInst>(Op<-1>());
4270 }
4271voidsetCatchSwitch(Value *CatchSwitch) {
4272assert(CatchSwitch);
4273Op<-1>() = CatchSwitch;
4274 }
4275
4276 /// Methods for support type inquiry through isa, cast, and dyn_cast:
4277staticboolclassof(constInstruction *I) {
4278returnI->getOpcode() == Instruction::CatchPad;
4279 }
4280staticboolclassof(constValue *V) {
4281return isa<Instruction>(V) &&classof(cast<Instruction>(V));
4282 }
4283};
4284
4285//===----------------------------------------------------------------------===//
4286// CatchReturnInst Class
4287//===----------------------------------------------------------------------===//
4288
4289classCatchReturnInst :publicInstruction {
4290constexprstaticIntrusiveOperandsAllocMarker AllocMarker{2};
4291
4292CatchReturnInst(constCatchReturnInst &RI);
4293CatchReturnInst(Value *CatchPad,BasicBlock *BB,InsertPosition InsertBefore);
4294
4295void init(Value *CatchPad,BasicBlock *BB);
4296
4297protected:
4298// Note: Instruction needs to be a friend here to call cloneImpl.
4299friendclassInstruction;
4300
4301CatchReturnInst *cloneImpl()const;
4302
4303public:
4304staticCatchReturnInst *Create(Value *CatchPad,BasicBlock *BB,
4305InsertPosition InsertBefore =nullptr) {
4306assert(CatchPad);
4307assert(BB);
4308returnnew (AllocMarker)CatchReturnInst(CatchPad, BB, InsertBefore);
4309 }
4310
4311 /// Provide fast operand accessors
4312DECLARE_TRANSPARENT_OPERAND_ACCESSORS(Value);
4313
4314 /// Convenience accessors.
4315CatchPadInst *getCatchPad() const{return cast<CatchPadInst>(Op<0>()); }
4316voidsetCatchPad(CatchPadInst *CatchPad) {
4317assert(CatchPad);
4318Op<0>() = CatchPad;
4319 }
4320
4321BasicBlock *getSuccessor() const{return cast<BasicBlock>(Op<1>()); }
4322voidsetSuccessor(BasicBlock *NewSucc) {
4323assert(NewSucc);
4324Op<1>() = NewSucc;
4325 }
4326unsignedgetNumSuccessors() const{return 1; }
4327
4328 /// Get the parentPad of this catchret's catchpad's catchswitch.
4329 /// The successor block is implicitly a member of this funclet.
4330Value *getCatchSwitchParentPad() const{
4331returngetCatchPad()->getCatchSwitch()->getParentPad();
4332 }
4333
4334// Methods for support type inquiry through isa, cast, and dyn_cast:
4335staticboolclassof(constInstruction *I) {
4336return (I->getOpcode() == Instruction::CatchRet);
4337 }
4338staticboolclassof(constValue *V) {
4339return isa<Instruction>(V) &&classof(cast<Instruction>(V));
4340 }
4341
4342private:
4343BasicBlock *getSuccessor(unsignedIdx) const{
4344assert(Idx <getNumSuccessors() &&"Successor # out of range for catchret!");
4345returngetSuccessor();
4346 }
4347
4348voidsetSuccessor(unsignedIdx,BasicBlock *B) {
4349assert(Idx <getNumSuccessors() &&"Successor # out of range for catchret!");
4350setSuccessor(B);
4351 }
4352};
4353
4354template <>
4355structOperandTraits<CatchReturnInst>
4356 :publicFixedNumOperandTraits<CatchReturnInst, 2> {};
4357
4358DEFINE_TRANSPARENT_OPERAND_ACCESSORS(CatchReturnInst,Value)
4359
4360//===----------------------------------------------------------------------===//
4361// CleanupReturnInst Class
4362//===----------------------------------------------------------------------===//
4363
4364classCleanupReturnInst : publicInstruction {
4365usingUnwindDestField =BoolBitfieldElementT<0>;
4366
4367private:
4368CleanupReturnInst(constCleanupReturnInst &RI,AllocInfoAllocInfo);
4369CleanupReturnInst(Value *CleanupPad,BasicBlock *UnwindBB,
4370AllocInfoAllocInfo,InsertPosition InsertBefore =nullptr);
4371
4372void init(Value *CleanupPad,BasicBlock *UnwindBB);
4373
4374protected:
4375// Note: Instruction needs to be a friend here to call cloneImpl.
4376friendclassInstruction;
4377
4378CleanupReturnInst *cloneImpl()const;
4379
4380public:
4381staticCleanupReturnInst *Create(Value *CleanupPad,
4382BasicBlock *UnwindBB =nullptr,
4383InsertPosition InsertBefore =nullptr) {
4384assert(CleanupPad);
4385unsigned Values = 1;
4386if (UnwindBB)
4387 ++Values;
4388IntrusiveOperandsAllocMarker AllocMarker{Values};
4389returnnew (AllocMarker)
4390CleanupReturnInst(CleanupPad, UnwindBB, AllocMarker, InsertBefore);
4391 }
4392
4393 /// Provide fast operand accessors
4394DECLARE_TRANSPARENT_OPERAND_ACCESSORS(Value);
4395
4396boolhasUnwindDest() const{return getSubclassData<UnwindDestField>(); }
4397boolunwindsToCaller() const{return !hasUnwindDest(); }
4398
4399 /// Convenience accessor.
4400CleanupPadInst *getCleanupPad() const{
4401return cast<CleanupPadInst>(Op<0>());
4402 }
4403voidsetCleanupPad(CleanupPadInst *CleanupPad) {
4404assert(CleanupPad);
4405Op<0>() = CleanupPad;
4406 }
4407
4408unsignedgetNumSuccessors() const{return hasUnwindDest() ? 1 : 0; }
4409
4410BasicBlock *getUnwindDest() const{
4411return hasUnwindDest() ? cast<BasicBlock>(Op<1>()) :nullptr;
4412 }
4413voidsetUnwindDest(BasicBlock *NewDest) {
4414assert(NewDest);
4415assert(hasUnwindDest());
4416Op<1>() = NewDest;
4417 }
4418
4419// Methods for support type inquiry through isa, cast, and dyn_cast:
4420staticboolclassof(constInstruction *I) {
4421return (I->getOpcode() == Instruction::CleanupRet);
4422 }
4423staticboolclassof(constValue *V) {
4424return isa<Instruction>(V) && classof(cast<Instruction>(V));
4425 }
4426
4427private:
4428BasicBlock *getSuccessor(unsignedIdx) const{
4429assert(Idx == 0);
4430return getUnwindDest();
4431 }
4432
4433void setSuccessor(unsignedIdx, BasicBlock *B) {
4434assert(Idx == 0);
4435 setUnwindDest(B);
4436 }
4437
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);
4443 }
4444};
4445
4446template <>
4447structOperandTraits<CleanupReturnInst>
4448 :publicVariadicOperandTraits<CleanupReturnInst> {};
4449
4450DEFINE_TRANSPARENT_OPERAND_ACCESSORS(CleanupReturnInst,Value)
4451
4452//===----------------------------------------------------------------------===//
4453// UnreachableInst Class
4454//===----------------------------------------------------------------------===//
4455
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.
4460///
4461classUnreachableInst : publicInstruction {
4462constexprstaticIntrusiveOperandsAllocMarker AllocMarker{0};
4463
4464protected:
4465// Note: Instruction needs to be a friend here to call cloneImpl.
4466friendclassInstruction;
4467
4468UnreachableInst *cloneImpl()const;
4469
4470public:
4471explicitUnreachableInst(LLVMContext &C,
4472InsertPosition InsertBefore =nullptr);
4473
4474// allocate space for exactly zero operands
4475void *operatornew(size_t S) {return User::operatornew(S, AllocMarker); }
4476voidoperatordelete(void *Ptr) { User::operatordelete(Ptr); }
4477
4478unsignedgetNumSuccessors() const{return 0; }
4479
4480// Methods for support type inquiry through isa, cast, and dyn_cast:
4481staticboolclassof(constInstruction *I) {
4482returnI->getOpcode() == Instruction::Unreachable;
4483 }
4484staticboolclassof(constValue *V) {
4485return isa<Instruction>(V) && classof(cast<Instruction>(V));
4486 }
4487
4488private:
4489BasicBlock *getSuccessor(unsigned idx) const{
4490llvm_unreachable("UnreachableInst has no successors!");
4491 }
4492
4493void setSuccessor(unsigned idx, BasicBlock *B) {
4494llvm_unreachable("UnreachableInst has no successors!");
4495 }
4496};
4497
4498//===----------------------------------------------------------------------===//
4499// TruncInst Class
4500//===----------------------------------------------------------------------===//
4501
4502/// This class represents a truncation of integer types.
4503classTruncInst :publicCastInst {
4504protected:
4505// Note: Instruction needs to be a friend here to call cloneImpl.
4506friendclassInstruction;
4507
4508 /// Clone an identical TruncInst
4509TruncInst *cloneImpl()const;
4510
4511public:
4512enum {AnyWrap = 0,NoUnsignedWrap = (1 << 0),NoSignedWrap = (1 << 1) };
4513
4514 /// Constructor with insert-before-instruction semantics
4515TruncInst(Value *S,///< The value to be truncated
4516Type *Ty,///< The (smaller) type to truncate to
4517constTwine &NameStr ="",///< A name for the new instruction
4518InsertPosition InsertBefore =
4519nullptr///< Where to insert the new instruction
4520 );
4521
4522 /// Methods for support type inquiry through isa, cast, and dyn_cast:
4523staticboolclassof(constInstruction *I) {
4524returnI->getOpcode() == Trunc;
4525 }
4526staticboolclassof(constValue *V) {
4527return isa<Instruction>(V) &&classof(cast<Instruction>(V));
4528 }
4529
4530voidsetHasNoUnsignedWrap(boolB) {
4531SubclassOptionalData =
4532 (SubclassOptionalData & ~NoUnsignedWrap) | (B *NoUnsignedWrap);
4533 }
4534voidsetHasNoSignedWrap(boolB) {
4535SubclassOptionalData =
4536 (SubclassOptionalData & ~NoSignedWrap) | (B *NoSignedWrap);
4537 }
4538
4539 /// Test whether this operation is known to never
4540 /// undergo unsigned overflow, aka the nuw property.
4541boolhasNoUnsignedWrap() const{
4542returnSubclassOptionalData &NoUnsignedWrap;
4543 }
4544
4545 /// Test whether this operation is known to never
4546 /// undergo signed overflow, aka the nsw property.
4547boolhasNoSignedWrap() const{
4548return (SubclassOptionalData &NoSignedWrap) != 0;
4549 }
4550
4551 /// Returns the no-wrap kind of the operation.
4552unsignedgetNoWrapKind() const{
4553unsigned NoWrapKind = 0;
4554if (hasNoUnsignedWrap())
4555 NoWrapKind |=NoUnsignedWrap;
4556
4557if (hasNoSignedWrap())
4558 NoWrapKind |=NoSignedWrap;
4559
4560return NoWrapKind;
4561 }
4562};
4563
4564//===----------------------------------------------------------------------===//
4565// ZExtInst Class
4566//===----------------------------------------------------------------------===//
4567
4568/// This class represents zero extension of integer types.
4569classZExtInst :publicCastInst {
4570protected:
4571// Note: Instruction needs to be a friend here to call cloneImpl.
4572friendclassInstruction;
4573
4574 /// Clone an identical ZExtInst
4575ZExtInst *cloneImpl()const;
4576
4577public:
4578 /// Constructor with insert-before-instruction semantics
4579ZExtInst(Value *S,///< The value to be zero extended
4580Type *Ty,///< The type to zero extend to
4581constTwine &NameStr ="",///< A name for the new instruction
4582InsertPosition InsertBefore =
4583nullptr///< Where to insert the new instruction
4584 );
4585
4586 /// Methods for support type inquiry through isa, cast, and dyn_cast:
4587staticboolclassof(constInstruction *I) {
4588returnI->getOpcode() == ZExt;
4589 }
4590staticboolclassof(constValue *V) {
4591return isa<Instruction>(V) &&classof(cast<Instruction>(V));
4592 }
4593};
4594
4595//===----------------------------------------------------------------------===//
4596// SExtInst Class
4597//===----------------------------------------------------------------------===//
4598
4599/// This class represents a sign extension of integer types.
4600classSExtInst :publicCastInst {
4601protected:
4602// Note: Instruction needs to be a friend here to call cloneImpl.
4603friendclassInstruction;
4604
4605 /// Clone an identical SExtInst
4606SExtInst *cloneImpl()const;
4607
4608public:
4609 /// Constructor with insert-before-instruction semantics
4610SExtInst(Value *S,///< The value to be sign extended
4611Type *Ty,///< The type to sign extend to
4612constTwine &NameStr ="",///< A name for the new instruction
4613InsertPosition InsertBefore =
4614nullptr///< Where to insert the new instruction
4615 );
4616
4617 /// Methods for support type inquiry through isa, cast, and dyn_cast:
4618staticboolclassof(constInstruction *I) {
4619returnI->getOpcode() == SExt;
4620 }
4621staticboolclassof(constValue *V) {
4622return isa<Instruction>(V) &&classof(cast<Instruction>(V));
4623 }
4624};
4625
4626//===----------------------------------------------------------------------===//
4627// FPTruncInst Class
4628//===----------------------------------------------------------------------===//
4629
4630/// This class represents a truncation of floating point types.
4631classFPTruncInst :publicCastInst {
4632protected:
4633// Note: Instruction needs to be a friend here to call cloneImpl.
4634friendclassInstruction;
4635
4636 /// Clone an identical FPTruncInst
4637FPTruncInst *cloneImpl()const;
4638
4639public:/// Constructor with insert-before-instruction semantics
4640FPTruncInst(Value *S,///< The value to be truncated
4641Type *Ty,///< The type to truncate to
4642constTwine &NameStr ="",///< A name for the new instruction
4643InsertPosition InsertBefore =
4644nullptr///< Where to insert the new instruction
4645 );
4646
4647 /// Methods for support type inquiry through isa, cast, and dyn_cast:
4648staticboolclassof(constInstruction *I) {
4649returnI->getOpcode() == FPTrunc;
4650 }
4651staticboolclassof(constValue *V) {
4652return isa<Instruction>(V) &&classof(cast<Instruction>(V));
4653 }
4654};
4655
4656//===----------------------------------------------------------------------===//
4657// FPExtInst Class
4658//===----------------------------------------------------------------------===//
4659
4660/// This class represents an extension of floating point types.
4661classFPExtInst :publicCastInst {
4662protected:
4663// Note: Instruction needs to be a friend here to call cloneImpl.
4664friendclassInstruction;
4665
4666 /// Clone an identical FPExtInst
4667FPExtInst *cloneImpl()const;
4668
4669public:
4670 /// Constructor with insert-before-instruction semantics
4671FPExtInst(Value *S,///< The value to be extended
4672Type *Ty,///< The type to extend to
4673constTwine &NameStr ="",///< A name for the new instruction
4674InsertPosition InsertBefore =
4675nullptr///< Where to insert the new instruction
4676 );
4677
4678 /// Methods for support type inquiry through isa, cast, and dyn_cast:
4679staticboolclassof(constInstruction *I) {
4680returnI->getOpcode() == FPExt;
4681 }
4682staticboolclassof(constValue *V) {
4683return isa<Instruction>(V) &&classof(cast<Instruction>(V));
4684 }
4685};
4686
4687//===----------------------------------------------------------------------===//
4688// UIToFPInst Class
4689//===----------------------------------------------------------------------===//
4690
4691/// This class represents a cast unsigned integer to floating point.
4692classUIToFPInst :publicCastInst {
4693protected:
4694// Note: Instruction needs to be a friend here to call cloneImpl.
4695friendclassInstruction;
4696
4697 /// Clone an identical UIToFPInst
4698UIToFPInst *cloneImpl()const;
4699
4700public:
4701 /// Constructor with insert-before-instruction semantics
4702UIToFPInst(Value *S,///< The value to be converted
4703Type *Ty,///< The type to convert to
4704constTwine &NameStr ="",///< A name for the new instruction
4705InsertPosition InsertBefore =
4706nullptr///< Where to insert the new instruction
4707 );
4708
4709 /// Methods for support type inquiry through isa, cast, and dyn_cast:
4710staticboolclassof(constInstruction *I) {
4711returnI->getOpcode() == UIToFP;
4712 }
4713staticboolclassof(constValue *V) {
4714return isa<Instruction>(V) &&classof(cast<Instruction>(V));
4715 }
4716};
4717
4718//===----------------------------------------------------------------------===//
4719// SIToFPInst Class
4720//===----------------------------------------------------------------------===//
4721
4722/// This class represents a cast from signed integer to floating point.
4723classSIToFPInst :publicCastInst {
4724protected:
4725// Note: Instruction needs to be a friend here to call cloneImpl.
4726friendclassInstruction;
4727
4728 /// Clone an identical SIToFPInst
4729SIToFPInst *cloneImpl()const;
4730
4731public:
4732 /// Constructor with insert-before-instruction semantics
4733SIToFPInst(Value *S,///< The value to be converted
4734Type *Ty,///< The type to convert to
4735constTwine &NameStr ="",///< A name for the new instruction
4736InsertPosition InsertBefore =
4737nullptr///< Where to insert the new instruction
4738 );
4739
4740 /// Methods for support type inquiry through isa, cast, and dyn_cast:
4741staticboolclassof(constInstruction *I) {
4742returnI->getOpcode() == SIToFP;
4743 }
4744staticboolclassof(constValue *V) {
4745return isa<Instruction>(V) &&classof(cast<Instruction>(V));
4746 }
4747};
4748
4749//===----------------------------------------------------------------------===//
4750// FPToUIInst Class
4751//===----------------------------------------------------------------------===//
4752
4753/// This class represents a cast from floating point to unsigned integer
4754classFPToUIInst :publicCastInst {
4755protected:
4756// Note: Instruction needs to be a friend here to call cloneImpl.
4757friendclassInstruction;
4758
4759 /// Clone an identical FPToUIInst
4760FPToUIInst *cloneImpl()const;
4761
4762public:
4763 /// Constructor with insert-before-instruction semantics
4764FPToUIInst(Value *S,///< The value to be converted
4765Type *Ty,///< The type to convert to
4766constTwine &NameStr ="",///< A name for the new instruction
4767InsertPosition InsertBefore =
4768nullptr///< Where to insert the new instruction
4769 );
4770
4771 /// Methods for support type inquiry through isa, cast, and dyn_cast:
4772staticboolclassof(constInstruction *I) {
4773returnI->getOpcode() == FPToUI;
4774 }
4775staticboolclassof(constValue *V) {
4776return isa<Instruction>(V) &&classof(cast<Instruction>(V));
4777 }
4778};
4779
4780//===----------------------------------------------------------------------===//
4781// FPToSIInst Class
4782//===----------------------------------------------------------------------===//
4783
4784/// This class represents a cast from floating point to signed integer.
4785classFPToSIInst :publicCastInst {
4786protected:
4787// Note: Instruction needs to be a friend here to call cloneImpl.
4788friendclassInstruction;
4789
4790 /// Clone an identical FPToSIInst
4791FPToSIInst *cloneImpl()const;
4792
4793public:
4794 /// Constructor with insert-before-instruction semantics
4795FPToSIInst(Value *S,///< The value to be converted
4796Type *Ty,///< The type to convert to
4797constTwine &NameStr ="",///< A name for the new instruction
4798InsertPosition InsertBefore =
4799nullptr///< Where to insert the new instruction
4800 );
4801
4802 /// Methods for support type inquiry through isa, cast, and dyn_cast:
4803staticboolclassof(constInstruction *I) {
4804returnI->getOpcode() == FPToSI;
4805 }
4806staticboolclassof(constValue *V) {
4807return isa<Instruction>(V) &&classof(cast<Instruction>(V));
4808 }
4809};
4810
4811//===----------------------------------------------------------------------===//
4812// IntToPtrInst Class
4813//===----------------------------------------------------------------------===//
4814
4815/// This class represents a cast from an integer to a pointer.
4816classIntToPtrInst :publicCastInst {
4817public:
4818// Note: Instruction needs to be a friend here to call cloneImpl.
4819friendclassInstruction;
4820
4821 /// Constructor with insert-before-instruction semantics
4822IntToPtrInst(Value *S,///< The value to be converted
4823Type *Ty,///< The type to convert to
4824constTwine &NameStr ="",///< A name for the new instruction
4825InsertPosition InsertBefore =
4826nullptr///< Where to insert the new instruction
4827 );
4828
4829 /// Clone an identical IntToPtrInst.
4830IntToPtrInst *cloneImpl()const;
4831
4832 /// Returns the address space of this instruction's pointer type.
4833unsignedgetAddressSpace() const{
4834returngetType()->getPointerAddressSpace();
4835 }
4836
4837// Methods for support type inquiry through isa, cast, and dyn_cast:
4838staticboolclassof(constInstruction *I) {
4839returnI->getOpcode() == IntToPtr;
4840 }
4841staticboolclassof(constValue *V) {
4842return isa<Instruction>(V) &&classof(cast<Instruction>(V));
4843 }
4844};
4845
4846//===----------------------------------------------------------------------===//
4847// PtrToIntInst Class
4848//===----------------------------------------------------------------------===//
4849
4850/// This class represents a cast from a pointer to an integer.
4851classPtrToIntInst :publicCastInst {
4852protected:
4853// Note: Instruction needs to be a friend here to call cloneImpl.
4854friendclassInstruction;
4855
4856 /// Clone an identical PtrToIntInst.
4857PtrToIntInst *cloneImpl()const;
4858
4859public:
4860 /// Constructor with insert-before-instruction semantics
4861PtrToIntInst(Value *S,///< The value to be converted
4862Type *Ty,///< The type to convert to
4863constTwine &NameStr ="",///< A name for the new instruction
4864InsertPosition InsertBefore =
4865nullptr///< Where to insert the new instruction
4866 );
4867
4868 /// Gets the pointer operand.
4869Value *getPointerOperand() {returngetOperand(0); }
4870 /// Gets the pointer operand.
4871constValue *getPointerOperand() const{returngetOperand(0); }
4872 /// Gets the operand index of the pointer operand.
4873staticunsignedgetPointerOperandIndex() {return 0U; }
4874
4875 /// Returns the address space of the pointer operand.
4876unsignedgetPointerAddressSpace() const{
4877returngetPointerOperand()->getType()->getPointerAddressSpace();
4878 }
4879
4880// Methods for support type inquiry through isa, cast, and dyn_cast:
4881staticboolclassof(constInstruction *I) {
4882returnI->getOpcode() == PtrToInt;
4883 }
4884staticboolclassof(constValue *V) {
4885return isa<Instruction>(V) &&classof(cast<Instruction>(V));
4886 }
4887};
4888
4889//===----------------------------------------------------------------------===//
4890// BitCastInst Class
4891//===----------------------------------------------------------------------===//
4892
4893/// This class represents a no-op cast from one type to another.
4894classBitCastInst :publicCastInst {
4895protected:
4896// Note: Instruction needs to be a friend here to call cloneImpl.
4897friendclassInstruction;
4898
4899 /// Clone an identical BitCastInst.
4900BitCastInst *cloneImpl()const;
4901
4902public:
4903 /// Constructor with insert-before-instruction semantics
4904BitCastInst(Value *S,///< The value to be casted
4905Type *Ty,///< The type to casted to
4906constTwine &NameStr ="",///< A name for the new instruction
4907InsertPosition InsertBefore =
4908nullptr///< Where to insert the new instruction
4909 );
4910
4911// Methods for support type inquiry through isa, cast, and dyn_cast:
4912staticboolclassof(constInstruction *I) {
4913returnI->getOpcode() == BitCast;
4914 }
4915staticboolclassof(constValue *V) {
4916return isa<Instruction>(V) &&classof(cast<Instruction>(V));
4917 }
4918};
4919
4920//===----------------------------------------------------------------------===//
4921// AddrSpaceCastInst Class
4922//===----------------------------------------------------------------------===//
4923
4924/// This class represents a conversion between pointers from one address space
4925/// to another.
4926classAddrSpaceCastInst :publicCastInst {
4927protected:
4928// Note: Instruction needs to be a friend here to call cloneImpl.
4929friendclassInstruction;
4930
4931 /// Clone an identical AddrSpaceCastInst.
4932AddrSpaceCastInst *cloneImpl()const;
4933
4934public:
4935 /// Constructor with insert-before-instruction semantics
4936AddrSpaceCastInst(
4937Value *S,///< The value to be casted
4938Type *Ty,///< The type to casted to
4939constTwine &NameStr ="",///< A name for the new instruction
4940InsertPosition InsertBefore =
4941nullptr///< Where to insert the new instruction
4942 );
4943
4944// Methods for support type inquiry through isa, cast, and dyn_cast:
4945staticboolclassof(constInstruction *I) {
4946returnI->getOpcode() == AddrSpaceCast;
4947 }
4948staticboolclassof(constValue *V) {
4949return isa<Instruction>(V) &&classof(cast<Instruction>(V));
4950 }
4951
4952 /// Gets the pointer operand.
4953Value *getPointerOperand() {
4954returngetOperand(0);
4955 }
4956
4957 /// Gets the pointer operand.
4958constValue *getPointerOperand() const{
4959returngetOperand(0);
4960 }
4961
4962 /// Gets the operand index of the pointer operand.
4963staticunsignedgetPointerOperandIndex() {
4964return 0U;
4965 }
4966
4967 /// Returns the address space of the pointer operand.
4968unsignedgetSrcAddressSpace() const{
4969returngetPointerOperand()->getType()->getPointerAddressSpace();
4970 }
4971
4972 /// Returns the address space of the result.
4973unsignedgetDestAddressSpace() const{
4974returngetType()->getPointerAddressSpace();
4975 }
4976};
4977
4978//===----------------------------------------------------------------------===//
4979// Helper functions
4980//===----------------------------------------------------------------------===//
4981
4982/// A helper function that returns the pointer operand of a load or store
4983/// instruction. Returns nullptr if not load or store.
4984inlineconstValue *getLoadStorePointerOperand(constValue *V) {
4985if (auto *Load = dyn_cast<LoadInst>(V))
4986return Load->getPointerOperand();
4987if (auto *Store = dyn_cast<StoreInst>(V))
4988return Store->getPointerOperand();
4989returnnullptr;
4990}
4991inlineValue *getLoadStorePointerOperand(Value *V) {
4992returnconst_cast<Value *>(
4993getLoadStorePointerOperand(static_cast<constValue *>(V)));
4994}
4995
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.
4998inlineconstValue *getPointerOperand(constValue *V) {
4999if (auto *Ptr =getLoadStorePointerOperand(V))
5000returnPtr;
5001if (auto *Gep = dyn_cast<GetElementPtrInst>(V))
5002return Gep->getPointerOperand();
5003returnnullptr;
5004}
5005inlineValue *getPointerOperand(Value *V) {
5006returnconst_cast<Value *>(getPointerOperand(static_cast<constValue *>(V)));
5007}
5008
5009/// A helper function that returns the alignment of load or store instruction.
5010inlineAligngetLoadStoreAlignment(constValue *I) {
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();
5016}
5017
5018/// A helper function that set the alignment of load or store instruction.
5019inlinevoidsetLoadStoreAlignment(Value *I,Align NewAlign) {
5020assert((isa<LoadInst>(I) || isa<StoreInst>(I)) &&
5021"Expected Load or Store instruction");
5022if (auto *LI = dyn_cast<LoadInst>(I))
5023 LI->setAlignment(NewAlign);
5024else
5025 cast<StoreInst>(I)->setAlignment(NewAlign);
5026}
5027
5028/// A helper function that returns the address space of the pointer operand of
5029/// load or store instruction.
5030inlineunsignedgetLoadStoreAddressSpace(constValue *I) {
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();
5036}
5037
5038/// A helper function that returns the type of a load or store instruction.
5039inlineType *getLoadStoreType(constValue *I) {
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();
5045}
5046
5047/// A helper function that returns an atomic operation's sync scope; returns
5048/// std::nullopt if it is not an atomic operation.
5049inline std::optional<SyncScope::ID>getAtomicSyncScopeID(constInstruction *I) {
5050if (!I->isAtomic())
5051return std::nullopt;
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();
5062llvm_unreachable("unhandled atomic operation");
5063}
5064
5065/// A helper function that sets an atomic operation's sync scope.
5066inlinevoidsetAtomicSyncScopeID(Instruction *I,SyncScope::ID SSID) {
5067assert(I->isAtomic());
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);
5078else
5079llvm_unreachable("unhandled atomic operation");
5080}
5081
5082//===----------------------------------------------------------------------===//
5083// FreezeInst Class
5084//===----------------------------------------------------------------------===//
5085
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
5088classFreezeInst :publicUnaryInstruction {
5089protected:
5090// Note: Instruction needs to be a friend here to call cloneImpl.
5091friendclassInstruction;
5092
5093 /// Clone an identical FreezeInst
5094FreezeInst *cloneImpl()const;
5095
5096public:
5097explicitFreezeInst(Value *S,constTwine &NameStr ="",
5098InsertPosition InsertBefore =nullptr);
5099
5100// Methods for support type inquiry through isa, cast, and dyn_cast:
5101staticinlineboolclassof(constInstruction *I) {
5102returnI->getOpcode() == Freeze;
5103 }
5104staticinlineboolclassof(constValue *V) {
5105return isa<Instruction>(V) &&classof(cast<Instruction>(V));
5106 }
5107};
5108
5109}// end namespace llvm
5110
5111#endif// LLVM_IR_INSTRUCTIONS_H
S1
static const LLT S1
Definition:AMDGPULegalizerInfo.cpp:282
isReverseMask
static bool isReverseMask(ArrayRef< int > M, EVT VT)
Definition:ARMISelLowering.cpp:7610
DL
MachineBasicBlock MachineBasicBlock::iterator DebugLoc DL
Definition:ARMSLSHardening.cpp:73
inline
always inline
Definition:AlwaysInliner.cpp:161
ArrayRef.h
AtomicOrdering.h
Atomic ordering constants.
getParent
static const Function * getParent(const Value *V)
Definition:BasicAliasAnalysis.cpp:863
Bitfields.h
This file implements methods to test, set and extract typed bits from packed unsigned integers.
B
static GCRegistry::Add< OcamlGC > B("ocaml", "ocaml 3.10-compatible GC")
Type
RelocType Type
Definition:COFFYAML.cpp:410
CmpPredicate.h
RetTy
return RetTy
Definition:DeadArgumentElimination.cpp:361
Idx
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
Definition:DeadArgumentElimination.cpp:353
DerivedTypes.h
Align
uint64_t Align
Definition:ELFObjHandler.cpp:82
Name
std::string Name
Definition:ELFObjHandler.cpp:77
Index
uint32_t Index
Definition:ELFObjHandler.cpp:83
Size
uint64_t Size
Definition:ELFObjHandler.cpp:81
GEPNoWrapFlags.h
GEP
Hexagon Common GEP
Definition:HexagonCommonGEP.cpp:170
pred
hexagon gen pred
Definition:HexagonGenPredicate.cpp:134
CFG.h
This file provides various utilities for inspecting and working with the control flow graph in LLVM I...
Constant.h
Instruction.h
Use.h
This defines the Use class.
User.h
InstrTypes.h
Intrinsics.h
F
#define F(x, y, z)
Definition:MD5.cpp:55
I
#define I(x, y, z)
Definition:MD5.cpp:58
MapVector.h
This file implements a map that provides insertion order iteration.
II
uint64_t IntrinsicInst * II
Definition:NVVMIntrRange.cpp:51
OperandTraits.h
DEFINE_TRANSPARENT_OPERAND_ACCESSORS
#define DEFINE_TRANSPARENT_OPERAND_ACCESSORS(CLASS, VALUECLASS)
Macro for generating out-of-class operand accessor definitions.
Definition:OperandTraits.h:123
P
#define P(N)
Operation
PowerPC Reduce CR logical Operation
Definition:PPCReduceCRLogicals.cpp:735
SI
StandardInstrumentations SI(Mod->getContext(), Debug, VerifyEach)
Cond
const SmallVectorImpl< MachineOperand > & Cond
Definition:RISCVRedundantCopyElimination.cpp:75
assert
assert(ImpDefSCC.getReg()==AMDGPU::SCC &&ImpDefSCC.isDef())
STLExtras.h
This file contains some templates that are useful if you are working with the STL at all.
SmallVector.h
This file defines the SmallVector class.
getType
static SymbolRef::Type getType(const Symbol *Sym)
Definition:TapiFile.cpp:39
Ptr
@ Ptr
Definition:TargetLibraryInfo.cpp:77
Twine.h
RHS
Value * RHS
Definition:X86PartialReduction.cpp:74
LHS
Value * LHS
Definition:X86PartialReduction.cpp:73
FunctionType
Definition:ItaniumDemangle.h:823
Predicate
Definition:AMDGPURegBankLegalizeRules.cpp:332
T
llvm::APFloat
Definition:APFloat.h:904
llvm::APInt
Class for arbitrary precision integers.
Definition:APInt.h:78
llvm::AddrSpaceCastInst
This class represents a conversion between pointers from one address space to another.
Definition:Instructions.h:4926
llvm::AddrSpaceCastInst::getPointerOperand
const Value * getPointerOperand() const
Gets the pointer operand.
Definition:Instructions.h:4958
llvm::AddrSpaceCastInst::cloneImpl
AddrSpaceCastInst * cloneImpl() const
Clone an identical AddrSpaceCastInst.
Definition:Instructions.cpp:4375
llvm::AddrSpaceCastInst::getPointerOperand
Value * getPointerOperand()
Gets the pointer operand.
Definition:Instructions.h:4953
llvm::AddrSpaceCastInst::classof
static bool classof(const Instruction *I)
Definition:Instructions.h:4945
llvm::AddrSpaceCastInst::classof
static bool classof(const Value *V)
Definition:Instructions.h:4948
llvm::AddrSpaceCastInst::getSrcAddressSpace
unsigned getSrcAddressSpace() const
Returns the address space of the pointer operand.
Definition:Instructions.h:4968
llvm::AddrSpaceCastInst::getDestAddressSpace
unsigned getDestAddressSpace() const
Returns the address space of the result.
Definition:Instructions.h:4973
llvm::AddrSpaceCastInst::getPointerOperandIndex
static unsigned getPointerOperandIndex()
Gets the operand index of the pointer operand.
Definition:Instructions.h:4963
llvm::AllocaInst
an instruction to allocate memory on the stack
Definition:Instructions.h:63
llvm::AllocaInst::getAllocationSizeInBits
std::optional< TypeSize > getAllocationSizeInBits(const DataLayout &DL) const
Get allocation size in bits.
Definition:Instructions.cpp:81
llvm::AllocaInst::classof
static bool classof(const Value *V)
Definition:Instructions.h:157
llvm::AllocaInst::isSwiftError
bool isSwiftError() const
Return true if this alloca is used as a swifterror argument to a call.
Definition:Instructions.h:149
llvm::AllocaInst::setSwiftError
void setSwiftError(bool V)
Specify whether this alloca is used to represent a swifterror.
Definition:Instructions.h:151
llvm::AllocaInst::isStaticAlloca
bool isStaticAlloca() const
Return true if this alloca is in the entry block of the function and is a constant size.
Definition:Instructions.cpp:1234
llvm::AllocaInst::getAlign
Align getAlign() const
Return the alignment of the memory that is being allocated by the instruction.
Definition:Instructions.h:124
llvm::AllocaInst::setAllocatedType
void setAllocatedType(Type *Ty)
for use only in special circumstances that need to generically transform a whole instruction (eg: IR ...
Definition:Instructions.h:120
llvm::AllocaInst::classof
static bool classof(const Instruction *I)
Definition:Instructions.h:154
llvm::AllocaInst::getType
PointerType * getType() const
Overload to return most specific pointer type.
Definition:Instructions.h:99
llvm::AllocaInst::setUsedWithInAlloca
void setUsedWithInAlloca(bool V)
Specify whether this alloca is used to represent the arguments to a call.
Definition:Instructions.h:144
llvm::AllocaInst::cloneImpl
AllocaInst * cloneImpl() const
Definition:Instructions.cpp:4288
llvm::AllocaInst::getAllocatedType
Type * getAllocatedType() const
Return the type that is being allocated by the instruction.
Definition:Instructions.h:117
llvm::AllocaInst::isUsedWithInAlloca
bool isUsedWithInAlloca() const
Return true if this alloca is used as an inalloca argument to a call.
Definition:Instructions.h:139
llvm::AllocaInst::getArraySize
Value * getArraySize()
Definition:Instructions.h:96
llvm::AllocaInst::getAddressSpace
unsigned getAddressSpace() const
Return the address space for the allocation.
Definition:Instructions.h:104
llvm::AllocaInst::getAllocationSize
std::optional< TypeSize > getAllocationSize(const DataLayout &DL) const
Get allocation size in bytes.
Definition:Instructions.cpp:64
llvm::AllocaInst::isArrayAllocation
bool isArrayAllocation() const
Return true if there is an allocation size parameter to the allocation instruction that is not 1.
Definition:Instructions.cpp:1225
llvm::AllocaInst::setAlignment
void setAlignment(Align Align)
Definition:Instructions.h:128
llvm::AllocaInst::getArraySize
const Value * getArraySize() const
Get the number of elements allocated.
Definition:Instructions.h:95
llvm::ArrayRef
ArrayRef - Represent a constant reference to an array (0 or more elements consecutively in memory),...
Definition:ArrayRef.h:41
llvm::ArrayRef::size
size_t size() const
size - Get the array size.
Definition:ArrayRef.h:168
llvm::AtomicCmpXchgInst
An instruction that atomically checks whether a specified value is in a memory location,...
Definition:Instructions.h:501
llvm::AtomicCmpXchgInst::VolatileField
BoolBitfieldElementT< 0 > VolatileField
Definition:Instructions.h:529
llvm::AtomicCmpXchgInst::getCompareOperand
const Value * getCompareOperand() const
Definition:Instructions.h:634
llvm::AtomicCmpXchgInst::getNewValOperand
Value * getNewValOperand()
Definition:Instructions.h:636
llvm::AtomicCmpXchgInst::setSyncScopeID
void setSyncScopeID(SyncScope::ID SSID)
Sets the synchronization scope ID of this cmpxchg instruction.
Definition:Instructions.h:625
llvm::AtomicCmpXchgInst::getMergedOrdering
AtomicOrdering getMergedOrdering() const
Returns a single ordering which is at least as strong as both the success and failure orderings for t...
Definition:Instructions.h:607
llvm::AtomicCmpXchgInst::setWeak
void setWeak(bool IsWeak)
Definition:Instructions.h:564
llvm::AtomicCmpXchgInst::isVolatile
bool isVolatile() const
Return true if this is a cmpxchg from a volatile memory location.
Definition:Instructions.h:555
llvm::AtomicCmpXchgInst::getPointerAddressSpace
unsigned getPointerAddressSpace() const
Returns the address space of the pointer operand.
Definition:Instructions.h:640
llvm::AtomicCmpXchgInst::WeakField
BoolBitfieldElementT< VolatileField::NextBit > WeakField
Definition:Instructions.h:530
llvm::AtomicCmpXchgInst::FailureOrderingField
AtomicOrderingBitfieldElementT< SuccessOrderingField::NextBit > FailureOrderingField
Definition:Instructions.h:534
llvm::AtomicCmpXchgInst::getCompareOperand
Value * getCompareOperand()
Definition:Instructions.h:633
llvm::AtomicCmpXchgInst::setFailureOrdering
void setFailureOrdering(AtomicOrdering Ordering)
Sets the failure ordering constraint of this cmpxchg instruction.
Definition:Instructions.h:599
llvm::AtomicCmpXchgInst::isValidFailureOrdering
static bool isValidFailureOrdering(AtomicOrdering Ordering)
Definition:Instructions.h:574
llvm::AtomicCmpXchgInst::getFailureOrdering
AtomicOrdering getFailureOrdering() const
Returns the failure ordering constraint of this cmpxchg instruction.
Definition:Instructions.h:594
llvm::AtomicCmpXchgInst::setSuccessOrdering
void setSuccessOrdering(AtomicOrdering Ordering)
Sets the success ordering constraint of this cmpxchg instruction.
Definition:Instructions.h:587
llvm::AtomicCmpXchgInst::AlignmentField
AlignmentBitfieldElementT< FailureOrderingField::NextBit > AlignmentField
Definition:Instructions.h:536
llvm::AtomicCmpXchgInst::getPointerOperand
Value * getPointerOperand()
Definition:Instructions.h:629
llvm::AtomicCmpXchgInst::getStrongestFailureOrdering
static AtomicOrdering getStrongestFailureOrdering(AtomicOrdering SuccessOrdering)
Returns the strongest permitted ordering on failure, given the desired ordering on success.
Definition:Instructions.h:652
llvm::AtomicCmpXchgInst::DECLARE_TRANSPARENT_OPERAND_ACCESSORS
DECLARE_TRANSPARENT_OPERAND_ACCESSORS(Value)
Transparently provide more efficient getOperand methods.
llvm::AtomicCmpXchgInst::cloneImpl
AtomicCmpXchgInst * cloneImpl() const
Definition:Instructions.cpp:4306
llvm::AtomicCmpXchgInst::getAlign
Align getAlign() const
Return the alignment of the memory that is being allocated by the instruction.
Definition:Instructions.h:544
llvm::AtomicCmpXchgInst::getPointerOperand
const Value * getPointerOperand() const
Definition:Instructions.h:630
llvm::AtomicCmpXchgInst::classof
static bool classof(const Value *V)
Definition:Instructions.h:671
llvm::AtomicCmpXchgInst::isWeak
bool isWeak() const
Return true if this cmpxchg may spuriously fail.
Definition:Instructions.h:562
llvm::AtomicCmpXchgInst::setAlignment
void setAlignment(Align Align)
Definition:Instructions.h:548
llvm::AtomicCmpXchgInst::setVolatile
void setVolatile(bool V)
Specify whether this is a volatile cmpxchg.
Definition:Instructions.h:559
llvm::AtomicCmpXchgInst::isValidSuccessOrdering
static bool isValidSuccessOrdering(AtomicOrdering Ordering)
Definition:Instructions.h:569
llvm::AtomicCmpXchgInst::getSuccessOrdering
AtomicOrdering getSuccessOrdering() const
Returns the success ordering constraint of this cmpxchg instruction.
Definition:Instructions.h:582
llvm::AtomicCmpXchgInst::SuccessOrderingField
AtomicOrderingBitfieldElementT< WeakField::NextBit > SuccessOrderingField
Definition:Instructions.h:532
llvm::AtomicCmpXchgInst::getPointerOperandIndex
static unsigned getPointerOperandIndex()
Definition:Instructions.h:631
llvm::AtomicCmpXchgInst::getNewValOperand
const Value * getNewValOperand() const
Definition:Instructions.h:637
llvm::AtomicCmpXchgInst::getSyncScopeID
SyncScope::ID getSyncScopeID() const
Returns the synchronization scope ID of this cmpxchg instruction.
Definition:Instructions.h:620
llvm::AtomicCmpXchgInst::classof
static bool classof(const Instruction *I)
Definition:Instructions.h:668
llvm::AtomicRMWInst
an instruction that atomically reads a memory location, combines it with another value,...
Definition:Instructions.h:704
llvm::AtomicRMWInst::getAlign
Align getAlign() const
Return the alignment of the memory that is being allocated by the instruction.
Definition:Instructions.h:827
llvm::AtomicRMWInst::isFPOperation
static bool isFPOperation(BinOp Op)
Definition:Instructions.h:809
llvm::AtomicRMWInst::getPointerOperandIndex
static unsigned getPointerOperandIndex()
Definition:Instructions.h:872
llvm::AtomicRMWInst::isVolatile
bool isVolatile() const
Return true if this is a RMW on a volatile memory location.
Definition:Instructions.h:837
llvm::AtomicRMWInst::setVolatile
void setVolatile(bool V)
Specify whether this is a volatile RMW or not.
Definition:Instructions.h:841
llvm::AtomicRMWInst::OperationField
BinOpBitfieldElement< AtomicOrderingField::NextBit > OperationField
Definition:Instructions.h:799
llvm::AtomicRMWInst::BinOp
BinOp
This enumeration lists the possible modifications atomicrmw can make.
Definition:Instructions.h:716
llvm::AtomicRMWInst::Add
@ Add
*p = old + v
Definition:Instructions.h:720
llvm::AtomicRMWInst::FAdd
@ FAdd
*p = old + v
Definition:Instructions.h:741
llvm::AtomicRMWInst::USubCond
@ USubCond
Subtract only if no unsigned overflow.
Definition:Instructions.h:764
llvm::AtomicRMWInst::Min
@ Min
*p = old <signed v ? old : v
Definition:Instructions.h:734
llvm::AtomicRMWInst::Or
@ Or
*p = old | v
Definition:Instructions.h:728
llvm::AtomicRMWInst::Sub
@ Sub
*p = old - v
Definition:Instructions.h:722
llvm::AtomicRMWInst::And
@ And
*p = old & v
Definition:Instructions.h:724
llvm::AtomicRMWInst::Xor
@ Xor
*p = old ^ v
Definition:Instructions.h:730
llvm::AtomicRMWInst::USubSat
@ USubSat
*p = usub.sat(old, v) usub.sat matches the behavior of llvm.usub.sat.
Definition:Instructions.h:768
llvm::AtomicRMWInst::FSub
@ FSub
*p = old - v
Definition:Instructions.h:744
llvm::AtomicRMWInst::UIncWrap
@ UIncWrap
Increment one up to a maximum value.
Definition:Instructions.h:756
llvm::AtomicRMWInst::Max
@ Max
*p = old >signed v ? old : v
Definition:Instructions.h:732
llvm::AtomicRMWInst::UMin
@ UMin
*p = old <unsigned v ? old : v
Definition:Instructions.h:738
llvm::AtomicRMWInst::FMin
@ FMin
*p = minnum(old, v) minnum matches the behavior of llvm.minnum.
Definition:Instructions.h:752
llvm::AtomicRMWInst::UMax
@ UMax
*p = old >unsigned v ? old : v
Definition:Instructions.h:736
llvm::AtomicRMWInst::FMax
@ FMax
*p = maxnum(old, v) maxnum matches the behavior of llvm.maxnum.
Definition:Instructions.h:748
llvm::AtomicRMWInst::UDecWrap
@ UDecWrap
Decrement one until a minimum value or zero.
Definition:Instructions.h:760
llvm::AtomicRMWInst::Xchg
@ Xchg
*p = v
Definition:Instructions.h:718
llvm::AtomicRMWInst::Nand
@ Nand
*p = ~(old & v)
Definition:Instructions.h:726
llvm::AtomicRMWInst::AtomicOrderingField
AtomicOrderingBitfieldElementT< VolatileField::NextBit > AtomicOrderingField
Definition:Instructions.h:798
llvm::AtomicRMWInst::setSyncScopeID
void setSyncScopeID(SyncScope::ID SSID)
Sets the synchronization scope ID of this rmw instruction.
Definition:Instructions.h:866
llvm::AtomicRMWInst::DECLARE_TRANSPARENT_OPERAND_ACCESSORS
DECLARE_TRANSPARENT_OPERAND_ACCESSORS(Value)
Transparently provide more efficient getOperand methods.
llvm::AtomicRMWInst::getPointerOperand
Value * getPointerOperand()
Definition:Instructions.h:870
llvm::AtomicRMWInst::setOrdering
void setOrdering(AtomicOrdering Ordering)
Sets the ordering constraint of this rmw instruction.
Definition:Instructions.h:852
llvm::AtomicRMWInst::isFloatingPointOperation
bool isFloatingPointOperation() const
Definition:Instructions.h:882
llvm::AtomicRMWInst::classof
static bool classof(const Instruction *I)
Definition:Instructions.h:887
llvm::AtomicRMWInst::getPointerOperand
const Value * getPointerOperand() const
Definition:Instructions.h:871
llvm::AtomicRMWInst::setOperation
void setOperation(BinOp Operation)
Definition:Instructions.h:821
llvm::AtomicRMWInst::classof
static bool classof(const Value *V)
Definition:Instructions.h:890
llvm::AtomicRMWInst::getOperation
BinOp getOperation() const
Definition:Instructions.h:805
llvm::AtomicRMWInst::getValOperand
const Value * getValOperand() const
Definition:Instructions.h:875
llvm::AtomicRMWInst::getSyncScopeID
SyncScope::ID getSyncScopeID() const
Returns the synchronization scope ID of this rmw instruction.
Definition:Instructions.h:861
llvm::AtomicRMWInst::setAlignment
void setAlignment(Align Align)
Definition:Instructions.h:831
llvm::AtomicRMWInst::getValOperand
Value * getValOperand()
Definition:Instructions.h:874
llvm::AtomicRMWInst::getOrdering
AtomicOrdering getOrdering() const
Returns the ordering constraint of this rmw instruction.
Definition:Instructions.h:847
llvm::AtomicRMWInst::AlignmentField
AlignmentBitfieldElementT< OperationField::NextBit > AlignmentField
Definition:Instructions.h:800
llvm::AtomicRMWInst::VolatileField
BoolBitfieldElementT< 0 > VolatileField
Definition:Instructions.h:796
llvm::AtomicRMWInst::getPointerAddressSpace
unsigned getPointerAddressSpace() const
Returns the address space of the pointer operand.
Definition:Instructions.h:878
llvm::BasicBlock
LLVM Basic Block Representation.
Definition:BasicBlock.h:61
llvm::BitCastInst
This class represents a no-op cast from one type to another.
Definition:Instructions.h:4894
llvm::BitCastInst::classof
static bool classof(const Instruction *I)
Definition:Instructions.h:4912
llvm::BitCastInst::classof
static bool classof(const Value *V)
Definition:Instructions.h:4915
llvm::BitCastInst::cloneImpl
BitCastInst * cloneImpl() const
Clone an identical BitCastInst.
Definition:Instructions.cpp:4371
llvm::BranchInst
Conditional or Unconditional Branch instruction.
Definition:Instructions.h:3016
llvm::BranchInst::DECLARE_TRANSPARENT_OPERAND_ACCESSORS
DECLARE_TRANSPARENT_OPERAND_ACCESSORS(Value)
Transparently provide more efficient getOperand methods.
llvm::BranchInst::successors
iterator_range< succ_op_iterator > successors()
Definition:Instructions.h:3121
llvm::BranchInst::Create
static BranchInst * Create(BasicBlock *IfTrue, BasicBlock *IfFalse, Value *Cond, InsertPosition InsertBefore=nullptr)
Definition:Instructions.h:3078
llvm::BranchInst::setCondition
void setCondition(Value *V)
Definition:Instructions.h:3097
llvm::BranchInst::classof
static bool classof(const Instruction *I)
Definition:Instructions.h:3134
llvm::BranchInst::isConditional
bool isConditional() const
Definition:Instructions.h:3090
llvm::BranchInst::getNumSuccessors
unsigned getNumSuccessors() const
Definition:Instructions.h:3102
llvm::BranchInst::classof
static bool classof(const Value *V)
Definition:Instructions.h:3137
llvm::BranchInst::Create
static BranchInst * Create(BasicBlock *IfTrue, InsertPosition InsertBefore=nullptr)
Definition:Instructions.h:3072
llvm::BranchInst::getSuccessor
BasicBlock * getSuccessor(unsigned i) const
Definition:Instructions.h:3104
llvm::BranchInst::isUnconditional
bool isUnconditional() const
Definition:Instructions.h:3089
llvm::BranchInst::setSuccessor
void setSuccessor(unsigned idx, BasicBlock *NewSucc)
Definition:Instructions.h:3109
llvm::BranchInst::getCondition
Value * getCondition() const
Definition:Instructions.h:3092
llvm::BranchInst::successors
iterator_range< const_succ_op_iterator > successors() const
Definition:Instructions.h:3127
llvm::CallBase
Base class for all callable instructions (InvokeInst and CallInst) Holds everything related to callin...
Definition:InstrTypes.h:1112
llvm::CallBase::addFnAttr
void addFnAttr(Attribute::AttrKind Kind)
Adds the attribute to the function.
Definition:InstrTypes.h:1474
llvm::CallBase::hasFnAttr
bool hasFnAttr(Attribute::AttrKind Kind) const
Determine whether this call has the given attribute.
Definition:InstrTypes.h:1451
llvm::CallBase::FTy
FunctionType * FTy
Definition:InstrTypes.h:1127
llvm::CallBase::getIntrinsicID
Intrinsic::ID getIntrinsicID() const
Returns the intrinsic ID of the intrinsic called or Intrinsic::not_intrinsic if the called function i...
Definition:Instructions.cpp:356
llvm::CallBase::CountBundleInputs
static unsigned CountBundleInputs(ArrayRef< OperandBundleDef > Bundles)
Return the total number of values used in Bundles.
Definition:InstrTypes.h:2282
llvm::CallBase::arg_size
unsigned arg_size() const
Definition:InstrTypes.h:1284
llvm::CallBase::getNumTotalBundleOperands
unsigned getNumTotalBundleOperands() const
Return the total number operands (not operand bundles) used by every operand bundle in this OperandBu...
Definition:InstrTypes.h:2010
llvm::CallBrInst
CallBr instruction, tracking function calls that may not return control but instead transfer it to a ...
Definition:Instructions.h:3830
llvm::CallBrInst::classof
static bool classof(const Value *V)
Definition:Instructions.h:3972
llvm::CallBrInst::Create
static CallBrInst * Create(FunctionType *Ty, Value *Func, BasicBlock *DefaultDest, ArrayRef< BasicBlock * > IndirectDests, ArrayRef< Value * > Args, ArrayRef< OperandBundleDef > Bundles={}, const Twine &NameStr="", InsertPosition InsertBefore=nullptr)
Definition:Instructions.h:3877
llvm::CallBrInst::classof
static bool classof(const Instruction *I)
Definition:Instructions.h:3969
llvm::CallBrInst::Create
static CallBrInst * Create(FunctionCallee Func, BasicBlock *DefaultDest, ArrayRef< BasicBlock * > IndirectDests, ArrayRef< Value * > Args, ArrayRef< OperandBundleDef > Bundles={}, const Twine &NameStr="", InsertPosition InsertBefore=nullptr)
Definition:Instructions.h:3899
llvm::CallBrInst::getIndirectDests
SmallVector< BasicBlock *, 16 > getIndirectDests() const
Definition:Instructions.h:3941
llvm::CallBrInst::Create
static CallBrInst * Create(FunctionCallee Func, BasicBlock *DefaultDest, ArrayRef< BasicBlock * > IndirectDests, ArrayRef< Value * > Args, const Twine &NameStr, InsertPosition InsertBefore=nullptr)
Definition:Instructions.h:3891
llvm::CallBrInst::setSuccessor
void setSuccessor(unsigned i, BasicBlock *NewSucc)
Definition:Instructions.h:3960
llvm::CallBrInst::getSuccessor
BasicBlock * getSuccessor(unsigned i) const
Definition:Instructions.h:3954
llvm::CallBrInst::getIndirectDestLabelUse
Value * getIndirectDestLabelUse(unsigned i) const
Definition:Instructions.h:3929
llvm::CallBrInst::getIndirectDest
BasicBlock * getIndirectDest(unsigned i) const
Definition:Instructions.h:3938
llvm::CallBrInst::setDefaultDest
void setDefaultDest(BasicBlock *B)
Definition:Instructions.h:3947
llvm::CallBrInst::getNumSuccessors
unsigned getNumSuccessors() const
Definition:Instructions.h:3966
llvm::CallBrInst::setIndirectDest
void setIndirectDest(unsigned i, BasicBlock *B)
Definition:Instructions.h:3950
llvm::CallBrInst::getIndirectDestLabel
Value * getIndirectDestLabel(unsigned i) const
getIndirectDestLabel - Return the i-th indirect dest label.
Definition:Instructions.h:3924
llvm::CallBrInst::getDefaultDest
BasicBlock * getDefaultDest() const
Definition:Instructions.h:3935
llvm::CallBrInst::getNumIndirectDests
unsigned getNumIndirectDests() const
Return the number of callbr indirect dest labels.
Definition:Instructions.h:3920
llvm::CallBrInst::Create
static CallBrInst * Create(FunctionType *Ty, Value *Func, BasicBlock *DefaultDest, ArrayRef< BasicBlock * > IndirectDests, ArrayRef< Value * > Args, const Twine &NameStr, InsertPosition InsertBefore=nullptr)
Definition:Instructions.h:3864
llvm::CallBrInst::cloneImpl
CallBrInst * cloneImpl() const
Definition:Instructions.cpp:4443
llvm::CallInst
This class represents a function call, abstracting a target machine's calling convention.
Definition:Instructions.h:1479
llvm::CallInst::isNoTailCall
bool isNoTailCall() const
Definition:Instructions.h:1596
llvm::CallInst::updateProfWeight
void updateProfWeight(uint64_t S, uint64_t T)
Updates profile metadata by scaling it by S / T.
Definition:Instructions.cpp:758
llvm::CallInst::classof
static bool classof(const Value *V)
Definition:Instructions.h:1625
llvm::CallInst::isTailCall
bool isTailCall() const
Definition:Instructions.h:1589
llvm::CallInst::setCanReturnTwice
void setCanReturnTwice()
Definition:Instructions.h:1608
llvm::CallInst::setTailCallKind
void setTailCallKind(TailCallKind TCK)
Definition:Instructions.h:1598
llvm::CallInst::Create
static CallInst * Create(FunctionType *Ty, Value *Func, ArrayRef< Value * > Args, ArrayRef< OperandBundleDef > Bundles={}, const Twine &NameStr="", InsertPosition InsertBefore=nullptr)
Definition:Instructions.h:1529
llvm::CallInst::Create
static CallInst * Create(FunctionType *Ty, Value *Func, ArrayRef< Value * > Args, const Twine &NameStr, InsertPosition InsertBefore=nullptr)
Definition:Instructions.h:1521
llvm::CallInst::canReturnTwice
bool canReturnTwice() const
Return true if the call can return twice.
Definition:Instructions.h:1607
llvm::CallInst::getTailCallKind
TailCallKind getTailCallKind() const
Definition:Instructions.h:1585
llvm::CallInst::cloneImpl
CallInst * cloneImpl() const
Definition:Instructions.cpp:4379
llvm::CallInst::Create
static CallInst * Create(FunctionType *Ty, Value *F, const Twine &NameStr="", InsertPosition InsertBefore=nullptr)
Definition:Instructions.h:1514
llvm::CallInst::setTailCall
void setTailCall(bool IsTc=true)
Definition:Instructions.h:1602
llvm::CallInst::isMustTailCall
bool isMustTailCall() const
Definition:Instructions.h:1594
llvm::CallInst::TailCallKind
TailCallKind
Definition:Instructions.h:1572
llvm::CallInst::TCK_None
@ TCK_None
Definition:Instructions.h:1573
llvm::CallInst::TCK_MustTail
@ TCK_MustTail
Definition:Instructions.h:1575
llvm::CallInst::TCK_Tail
@ TCK_Tail
Definition:Instructions.h:1574
llvm::CallInst::TCK_NoTail
@ TCK_NoTail
Definition:Instructions.h:1576
llvm::CallInst::TCK_LAST
@ TCK_LAST
Definition:Instructions.h:1577
llvm::CallInst::Create
static CallInst * Create(FunctionCallee Func, ArrayRef< Value * > Args, const Twine &NameStr, InsertPosition InsertBefore=nullptr)
Definition:Instructions.h:1555
llvm::CallInst::classof
static bool classof(const Instruction *I)
Definition:Instructions.h:1622
llvm::CallInst::isNonContinuableTrap
bool isNonContinuableTrap() const
Return true if the call is for a noreturn trap intrinsic.
Definition:Instructions.h:1611
llvm::CallInst::Create
static CallInst * Create(FunctionCallee Func, const Twine &NameStr="", InsertPosition InsertBefore=nullptr)
Definition:Instructions.h:1541
llvm::CallInst::Create
static CallInst * Create(FunctionCallee Func, ArrayRef< Value * > Args, ArrayRef< OperandBundleDef > Bundles={}, const Twine &NameStr="", InsertPosition InsertBefore=nullptr)
Definition:Instructions.h:1547
llvm::CastInst
This is the base class for all instructions that perform data casts.
Definition:InstrTypes.h:444
llvm::CatchPadInst
Definition:Instructions.h:4250
llvm::CatchPadInst::getCatchSwitch
CatchSwitchInst * getCatchSwitch() const
Convenience accessors.
Definition:Instructions.h:4268
llvm::CatchPadInst::setCatchSwitch
void setCatchSwitch(Value *CatchSwitch)
Definition:Instructions.h:4271
llvm::CatchPadInst::classof
static bool classof(const Instruction *I)
Methods for support type inquiry through isa, cast, and dyn_cast:
Definition:Instructions.h:4277
llvm::CatchPadInst::Create
static CatchPadInst * Create(Value *CatchSwitch, ArrayRef< Value * > Args, const Twine &NameStr="", InsertPosition InsertBefore=nullptr)
Definition:Instructions.h:4259
llvm::CatchPadInst::classof
static bool classof(const Value *V)
Definition:Instructions.h:4280
llvm::CatchReturnInst
Definition:Instructions.h:4289
llvm::CatchReturnInst::classof
static bool classof(const Instruction *I)
Definition:Instructions.h:4335
llvm::CatchReturnInst::getSuccessor
BasicBlock * getSuccessor() const
Definition:Instructions.h:4321
llvm::CatchReturnInst::getCatchPad
CatchPadInst * getCatchPad() const
Convenience accessors.
Definition:Instructions.h:4315
llvm::CatchReturnInst::setSuccessor
void setSuccessor(BasicBlock *NewSucc)
Definition:Instructions.h:4322
llvm::CatchReturnInst::classof
static bool classof(const Value *V)
Definition:Instructions.h:4338
llvm::CatchReturnInst::Create
static CatchReturnInst * Create(Value *CatchPad, BasicBlock *BB, InsertPosition InsertBefore=nullptr)
Definition:Instructions.h:4304
llvm::CatchReturnInst::getNumSuccessors
unsigned getNumSuccessors() const
Definition:Instructions.h:4326
llvm::CatchReturnInst::DECLARE_TRANSPARENT_OPERAND_ACCESSORS
DECLARE_TRANSPARENT_OPERAND_ACCESSORS(Value)
Provide fast operand accessors.
llvm::CatchReturnInst::setCatchPad
void setCatchPad(CatchPadInst *CatchPad)
Definition:Instructions.h:4316
llvm::CatchReturnInst::cloneImpl
CatchReturnInst * cloneImpl() const
Definition:Instructions.cpp:4463
llvm::CatchReturnInst::getCatchSwitchParentPad
Value * getCatchSwitchParentPad() const
Get the parentPad of this catchret's catchpad's catchswitch.
Definition:Instructions.h:4330
llvm::CatchSwitchInst
Definition:Instructions.h:4056
llvm::CatchSwitchInst::setUnwindDest
void setUnwindDest(BasicBlock *UnwindDest)
Definition:Instructions.h:4116
llvm::CatchSwitchInst::classof
static bool classof(const Instruction *I)
Definition:Instructions.h:4205
llvm::CatchSwitchInst::DerefFnTy
BasicBlock *(*)(Value *) DerefFnTy
Definition:Instructions.h:4137
llvm::CatchSwitchInst::ConstDerefFnTy
const BasicBlock *(*)(const Value *) ConstDerefFnTy
Definition:Instructions.h:4140
llvm::CatchSwitchInst::getNumSuccessors
unsigned getNumSuccessors() const
Definition:Instructions.h:4192
llvm::CatchSwitchInst::handler_begin
const_handler_iterator handler_begin() const
Returns an iterator that points to the first handler in the CatchSwitchInst.
Definition:Instructions.h:4155
llvm::CatchSwitchInst::getNumHandlers
unsigned getNumHandlers() const
return the number of 'handlers' in this catchswitch instruction, except the default handler
Definition:Instructions.h:4124
llvm::CatchSwitchInst::setSuccessor
void setSuccessor(unsigned Idx, BasicBlock *NewSucc)
Definition:Instructions.h:4198
llvm::CatchSwitchInst::getParentPad
Value * getParentPad() const
Definition:Instructions.h:4105
llvm::CatchSwitchInst::setParentPad
void setParentPad(Value *ParentPad)
Definition:Instructions.h:4106
llvm::CatchSwitchInst::unwindsToCaller
bool unwindsToCaller() const
Definition:Instructions.h:4110
llvm::CatchSwitchInst::classof
static bool classof(const Value *V)
Definition:Instructions.h:4208
llvm::CatchSwitchInst::handler_end
handler_iterator handler_end()
Returns a read-only iterator that points one past the last handler in the CatchSwitchInst.
Definition:Instructions.h:4164
llvm::CatchSwitchInst::getUnwindDest
BasicBlock * getUnwindDest() const
Definition:Instructions.h:4111
llvm::CatchSwitchInst::getSuccessor
BasicBlock * getSuccessor(unsigned Idx) const
Definition:Instructions.h:4193
llvm::CatchSwitchInst::handler_end
const_handler_iterator handler_end() const
Returns an iterator that points one past the last handler in the CatchSwitchInst.
Definition:Instructions.h:4170
llvm::CatchSwitchInst::hasUnwindDest
bool hasUnwindDest() const
Definition:Instructions.h:4109
llvm::CatchSwitchInst::handler_begin
handler_iterator handler_begin()
Returns an iterator that points to the first handler in CatchSwitchInst.
Definition:Instructions.h:4146
llvm::CatchSwitchInst::Create
static CatchSwitchInst * Create(Value *ParentPad, BasicBlock *UnwindDest, unsigned NumHandlers, const Twine &NameStr="", InsertPosition InsertBefore=nullptr)
Definition:Instructions.h:4093
llvm::CatchSwitchInst::handlers
handler_range handlers()
iteration adapter for range-for loops.
Definition:Instructions.h:4175
llvm::CatchSwitchInst::handlers
const_handler_range handlers() const
iteration adapter for range-for loops.
Definition:Instructions.h:4180
llvm::CatchSwitchInst::DECLARE_TRANSPARENT_OPERAND_ACCESSORS
DECLARE_TRANSPARENT_OPERAND_ACCESSORS(Value)
Provide fast operand accessors.
llvm::ClauseVal
Definition:DirectiveEmitter.h:250
llvm::CleanupPadInst
Definition:Instructions.h:4221
llvm::CleanupPadInst::classof
static bool classof(const Value *V)
Definition:Instructions.h:4242
llvm::CleanupPadInst::classof
static bool classof(const Instruction *I)
Methods for support type inquiry through isa, cast, and dyn_cast:
Definition:Instructions.h:4239
llvm::CleanupPadInst::Create
static CleanupPadInst * Create(Value *ParentPad, ArrayRef< Value * > Args={}, const Twine &NameStr="", InsertPosition InsertBefore=nullptr)
Definition:Instructions.h:4230
llvm::CleanupReturnInst
Definition:Instructions.h:4364
llvm::CleanupReturnInst::classof
static bool classof(const Instruction *I)
Definition:Instructions.h:4420
llvm::CleanupReturnInst::getCleanupPad
CleanupPadInst * getCleanupPad() const
Convenience accessor.
Definition:Instructions.h:4400
llvm::CleanupReturnInst::getNumSuccessors
unsigned getNumSuccessors() const
Definition:Instructions.h:4408
llvm::CleanupReturnInst::getUnwindDest
BasicBlock * getUnwindDest() const
Definition:Instructions.h:4410
llvm::CleanupReturnInst::unwindsToCaller
bool unwindsToCaller() const
Definition:Instructions.h:4397
llvm::CleanupReturnInst::setCleanupPad
void setCleanupPad(CleanupPadInst *CleanupPad)
Definition:Instructions.h:4403
llvm::CleanupReturnInst::classof
static bool classof(const Value *V)
Definition:Instructions.h:4423
llvm::CleanupReturnInst::setUnwindDest
void setUnwindDest(BasicBlock *NewDest)
Definition:Instructions.h:4413
llvm::CleanupReturnInst::Create
static CleanupReturnInst * Create(Value *CleanupPad, BasicBlock *UnwindBB=nullptr, InsertPosition InsertBefore=nullptr)
Definition:Instructions.h:4381
llvm::CleanupReturnInst::hasUnwindDest
bool hasUnwindDest() const
Definition:Instructions.h:4396
llvm::CleanupReturnInst::DECLARE_TRANSPARENT_OPERAND_ACCESSORS
DECLARE_TRANSPARENT_OPERAND_ACCESSORS(Value)
Provide fast operand accessors.
llvm::CmpInst
This class is the base class for the comparison instructions.
Definition:InstrTypes.h:661
llvm::CmpInst::makeCmpResultType
static Type * makeCmpResultType(Type *opnd_type)
Create a result type for fcmp/icmp.
Definition:InstrTypes.h:980
llvm::CmpInst::setPredicate
void setPredicate(Predicate P)
Set the predicate for this instruction to the specified value.
Definition:InstrTypes.h:766
llvm::CmpInst::Predicate
Predicate
This enumeration lists the possible predicates for CmpInst subclasses.
Definition:InstrTypes.h:673
llvm::CmpInst::FCMP_OEQ
@ FCMP_OEQ
0 0 0 1 True if ordered and equal
Definition:InstrTypes.h:676
llvm::CmpInst::FCMP_TRUE
@ FCMP_TRUE
1 1 1 1 Always true (always folded)
Definition:InstrTypes.h:690
llvm::CmpInst::FCMP_ONE
@ FCMP_ONE
0 1 1 0 True if ordered and operands are unequal
Definition:InstrTypes.h:681
llvm::CmpInst::FCMP_UEQ
@ FCMP_UEQ
1 0 0 1 True if unordered or equal
Definition:InstrTypes.h:684
llvm::CmpInst::FCMP_ORD
@ FCMP_ORD
0 1 1 1 True if ordered (no nans)
Definition:InstrTypes.h:682
llvm::CmpInst::FCMP_UNE
@ FCMP_UNE
1 1 1 0 True if unordered or not equal
Definition:InstrTypes.h:689
llvm::CmpInst::FCMP_FALSE
@ FCMP_FALSE
0 0 0 0 Always false (always folded)
Definition:InstrTypes.h:675
llvm::CmpInst::FCMP_UNO
@ FCMP_UNO
1 0 0 0 True if unordered: isnan(X) | isnan(Y)
Definition:InstrTypes.h:683
llvm::CmpInst::getSwappedPredicate
Predicate getSwappedPredicate() const
For example, EQ->EQ, SLE->SGE, ULT->UGT, OEQ->OEQ, ULE->UGE, OLT->OGT, etc.
Definition:InstrTypes.h:825
llvm::CmpInst::FCmpPredicates
static auto FCmpPredicates()
Returns the sequence of all FCmp predicates.
Definition:InstrTypes.h:712
llvm::CmpInst::isFPPredicate
bool isFPPredicate() const
Definition:InstrTypes.h:780
llvm::CmpInst::getPredicate
Predicate getPredicate() const
Return the predicate for this instruction.
Definition:InstrTypes.h:763
llvm::CmpPredicate
An abstraction over a floating-point predicate, and a pack of an integer predicate with samesign info...
Definition:CmpPredicate.h:22
llvm::CmpPredicate::hasSameSign
bool hasSameSign() const
Query samesign information, for optimizations.
Definition:CmpPredicate.h:42
llvm::ConstantInt
This is the shared class of boolean and integer constants.
Definition:Constants.h:83
llvm::Constant
This is an important base class in LLVM.
Definition:Constant.h:42
llvm::DWARFExpression::Operation
This class represents an Operation in the Expression.
Definition:DWARFExpression.h:32
llvm::DataLayout
A parsed version of the target data layout string in and methods for querying it.
Definition:DataLayout.h:63
llvm::ElementCount
Definition:TypeSize.h:300
llvm::ExtractElementInst
This instruction extracts a single (scalar) element from a VectorType value.
Definition:Instructions.h:1775
llvm::ExtractElementInst::getVectorOperand
const Value * getVectorOperand() const
Definition:Instructions.h:1801
llvm::ExtractElementInst::cloneImpl
ExtractElementInst * cloneImpl() const
Definition:Instructions.cpp:4398
llvm::ExtractElementInst::DECLARE_TRANSPARENT_OPERAND_ACCESSORS
DECLARE_TRANSPARENT_OPERAND_ACCESSORS(Value)
Transparently provide more efficient getOperand methods.
llvm::ExtractElementInst::classof
static bool classof(const Value *V)
Definition:Instructions.h:1815
llvm::ExtractElementInst::Create
static ExtractElementInst * Create(Value *Vec, Value *Idx, const Twine &NameStr="", InsertPosition InsertBefore=nullptr)
Definition:Instructions.h:1788
llvm::ExtractElementInst::getIndexOperand
const Value * getIndexOperand() const
Definition:Instructions.h:1802
llvm::ExtractElementInst::getVectorOperand
Value * getVectorOperand()
Definition:Instructions.h:1799
llvm::ExtractElementInst::classof
static bool classof(const Instruction *I)
Definition:Instructions.h:1812
llvm::ExtractElementInst::getIndexOperand
Value * getIndexOperand()
Definition:Instructions.h:1800
llvm::ExtractElementInst::getVectorOperandType
VectorType * getVectorOperandType() const
Definition:Instructions.h:1804
llvm::ExtractElementInst::isValidOperands
static bool isValidOperands(const Value *Vec, const Value *Idx)
Return true if an extractelement instruction can be formed with the specified operands.
Definition:Instructions.cpp:1612
llvm::ExtractValueInst
This instruction extracts a struct member or array element value from an aggregate value.
Definition:Instructions.h:2397
llvm::ExtractValueInst::getIndices
ArrayRef< unsigned > getIndices() const
Definition:Instructions.h:2449
llvm::ExtractValueInst::getNumIndices
unsigned getNumIndices() const
Definition:Instructions.h:2453
llvm::ExtractValueInst::classof
static bool classof(const Value *V)
Definition:Instructions.h:2465
llvm::ExtractValueInst::classof
static bool classof(const Instruction *I)
Definition:Instructions.h:2462
llvm::ExtractValueInst::indices
iterator_range< idx_iterator > indices() const
Definition:Instructions.h:2435
llvm::ExtractValueInst::idx_end
idx_iterator idx_end() const
Definition:Instructions.h:2434
llvm::ExtractValueInst::Create
static ExtractValueInst * Create(Value *Agg, ArrayRef< unsigned > Idxs, const Twine &NameStr="", InsertPosition InsertBefore=nullptr)
Definition:Instructions.h:2418
llvm::ExtractValueInst::getAggregateOperand
const Value * getAggregateOperand() const
Definition:Instructions.h:2442
llvm::ExtractValueInst::getAggregateOperand
Value * getAggregateOperand()
Definition:Instructions.h:2439
llvm::ExtractValueInst::getAggregateOperandIndex
static unsigned getAggregateOperandIndex()
Definition:Instructions.h:2445
llvm::ExtractValueInst::hasIndices
bool hasIndices() const
Definition:Instructions.h:2457
llvm::ExtractValueInst::idx_begin
idx_iterator idx_begin() const
Definition:Instructions.h:2433
llvm::FCmpInst
This instruction compares its operands according to the predicate given to the constructor.
Definition:Instructions.h:1379
llvm::FCmpInst::isRelational
bool isRelational() const
Definition:Instructions.h:1444
llvm::FCmpInst::FCmpInst
FCmpInst(Predicate Pred, Value *LHS, Value *RHS, const Twine &NameStr="", Instruction *FlagsSource=nullptr)
Constructor with no-insertion semantics.
Definition:Instructions.h:1410
llvm::FCmpInst::isEquality
bool isEquality() const
Definition:Instructions.h:1429
llvm::FCmpInst::classof
static bool classof(const Value *V)
Definition:Instructions.h:1468
llvm::FCmpInst::isCommutative
bool isCommutative() const
Definition:Instructions.h:1440
llvm::FCmpInst::isCommutative
static bool isCommutative(Predicate Pred)
Definition:Instructions.h:1433
llvm::FCmpInst::compare
static bool compare(const APFloat &LHS, const APFloat &RHS, FCmpInst::Predicate Pred)
Return result of LHS Pred RHS comparison.
Definition:Instructions.cpp:3774
llvm::FCmpInst::isEquality
static bool isEquality(Predicate Pred)
Definition:Instructions.h:1422
llvm::FCmpInst::classof
static bool classof(const Instruction *I)
Methods for support type inquiry through isa, cast, and dyn_cast:
Definition:Instructions.h:1465
llvm::FCmpInst::predicates
static auto predicates()
Returns the sequence of all FCmp predicates.
Definition:Instructions.h:1458
llvm::FCmpInst::cloneImpl
FCmpInst * cloneImpl() const
Clone an identical FCmpInst.
Definition:Instructions.cpp:4272
llvm::FCmpInst::swapOperands
void swapOperands()
Exchange the two operands to this instruction in such a way that it does not modify the semantics of ...
Definition:Instructions.h:1451
llvm::FCmpInst::FCmpInst
FCmpInst(InsertPosition InsertBefore, Predicate pred, Value *LHS, Value *RHS, const Twine &NameStr="")
Constructor with insertion semantics.
Definition:Instructions.h:1398
llvm::FPExtInst
This class represents an extension of floating point types.
Definition:Instructions.h:4661
llvm::FPExtInst::classof
static bool classof(const Value *V)
Definition:Instructions.h:4682
llvm::FPExtInst::cloneImpl
FPExtInst * cloneImpl() const
Clone an identical FPExtInst.
Definition:Instructions.cpp:4343
llvm::FPExtInst::classof
static bool classof(const Instruction *I)
Methods for support type inquiry through isa, cast, and dyn_cast:
Definition:Instructions.h:4679
llvm::FPToSIInst
This class represents a cast from floating point to signed integer.
Definition:Instructions.h:4785
llvm::FPToSIInst::classof
static bool classof(const Value *V)
Definition:Instructions.h:4806
llvm::FPToSIInst::cloneImpl
FPToSIInst * cloneImpl() const
Clone an identical FPToSIInst.
Definition:Instructions.cpp:4359
llvm::FPToSIInst::classof
static bool classof(const Instruction *I)
Methods for support type inquiry through isa, cast, and dyn_cast:
Definition:Instructions.h:4803
llvm::FPToUIInst
This class represents a cast from floating point to unsigned integer.
Definition:Instructions.h:4754
llvm::FPToUIInst::classof
static bool classof(const Value *V)
Definition:Instructions.h:4775
llvm::FPToUIInst::classof
static bool classof(const Instruction *I)
Methods for support type inquiry through isa, cast, and dyn_cast:
Definition:Instructions.h:4772
llvm::FPToUIInst::cloneImpl
FPToUIInst * cloneImpl() const
Clone an identical FPToUIInst.
Definition:Instructions.cpp:4355
llvm::FPTruncInst
This class represents a truncation of floating point types.
Definition:Instructions.h:4631
llvm::FPTruncInst::classof
static bool classof(const Instruction *I)
Methods for support type inquiry through isa, cast, and dyn_cast:
Definition:Instructions.h:4648
llvm::FPTruncInst::classof
static bool classof(const Value *V)
Definition:Instructions.h:4651
llvm::FPTruncInst::cloneImpl
FPTruncInst * cloneImpl() const
Clone an identical FPTruncInst.
Definition:Instructions.cpp:4339
llvm::FenceInst
An instruction for ordering other memory operations.
Definition:Instructions.h:424
llvm::FenceInst::classof
static bool classof(const Value *V)
Definition:Instructions.h:473
llvm::FenceInst::getSyncScopeID
SyncScope::ID getSyncScopeID() const
Returns the synchronization scope ID of this fence instruction.
Definition:Instructions.h:460
llvm::FenceInst::setSyncScopeID
void setSyncScopeID(SyncScope::ID SSID)
Sets the synchronization scope ID of this fence instruction.
Definition:Instructions.h:465
llvm::FenceInst::classof
static bool classof(const Instruction *I)
Definition:Instructions.h:470
llvm::FenceInst::setOrdering
void setOrdering(AtomicOrdering Ordering)
Sets the ordering constraint of this fence instruction.
Definition:Instructions.h:455
llvm::FenceInst::getOrdering
AtomicOrdering getOrdering() const
Returns the ordering constraint of this fence instruction.
Definition:Instructions.h:449
llvm::FreezeInst
This class represents a freeze function that returns random concrete value if an operand is either a ...
Definition:Instructions.h:5088
llvm::FreezeInst::classof
static bool classof(const Value *V)
Definition:Instructions.h:5104
llvm::FreezeInst::cloneImpl
FreezeInst * cloneImpl() const
Clone an identical FreezeInst.
Definition:Instructions.cpp:4481
llvm::FreezeInst::classof
static bool classof(const Instruction *I)
Definition:Instructions.h:5101
llvm::FuncletPadInst
Definition:InstrTypes.h:2327
llvm::FuncletPadInst::CatchPadInst
friend class CatchPadInst
Definition:InstrTypes.h:2340
llvm::FunctionCallee
A handy container for a FunctionType+Callee-pointer pair, which can be passed around as a single enti...
Definition:DerivedTypes.h:170
llvm::FunctionType
Class to represent function types.
Definition:DerivedTypes.h:105
llvm::GEPNoWrapFlags
Represents flags for the getelementptr instruction/expression.
Definition:GEPNoWrapFlags.h:26
llvm::GEPNoWrapFlags::inBounds
static GEPNoWrapFlags inBounds()
Definition:GEPNoWrapFlags.h:50
llvm::GetElementPtrInst
an instruction for type-safe pointer arithmetic to access elements of arrays and structs
Definition:Instructions.h:933
llvm::GetElementPtrInst::isInBounds
bool isInBounds() const
Determine whether the GEP has the inbounds flag.
Definition:Instructions.cpp:1569
llvm::GetElementPtrInst::hasNoUnsignedSignedWrap
bool hasNoUnsignedSignedWrap() const
Determine whether the GEP has the nusw flag.
Definition:Instructions.cpp:1573
llvm::GetElementPtrInst::getTypeAtIndex
static Type * getTypeAtIndex(Type *Ty, Value *Idx)
Return the type of the element at the given index of an indexable type.
Definition:Instructions.cpp:1474
llvm::GetElementPtrInst::getPointerOperand
Value * getPointerOperand()
Definition:Instructions.h:1036
llvm::GetElementPtrInst::hasAllZeroIndices
bool hasAllZeroIndices() const
Return true if all of the indices of this GEP are zeros.
Definition:Instructions.cpp:1530
llvm::GetElementPtrInst::getGEPReturnType
static Type * getGEPReturnType(Value *Ptr, ArrayRef< Value * > IdxList)
Returns the pointer type returned by the GEP instruction, which may be a vector of pointers.
Definition:Instructions.h:1059
llvm::GetElementPtrInst::DECLARE_TRANSPARENT_OPERAND_ACCESSORS
DECLARE_TRANSPARENT_OPERAND_ACCESSORS(Value)
Transparently provide more efficient getOperand methods.
llvm::GetElementPtrInst::setResultElementType
void setResultElementType(Type *Ty)
Definition:Instructions.h:993
llvm::GetElementPtrInst::hasNoUnsignedWrap
bool hasNoUnsignedWrap() const
Determine whether the GEP has the nuw flag.
Definition:Instructions.cpp:1577
llvm::GetElementPtrInst::hasAllConstantIndices
bool hasAllConstantIndices() const
Return true if all of the indices of this GEP are constant integers.
Definition:Instructions.cpp:1544
llvm::GetElementPtrInst::getAddressSpace
unsigned getAddressSpace() const
Returns the address space of this instruction's pointer type.
Definition:Instructions.h:1000
llvm::GetElementPtrInst::indices
iterator_range< const_op_iterator > indices() const
Definition:Instructions.h:1032
llvm::GetElementPtrInst::getResultElementType
Type * getResultElementType() const
Definition:Instructions.h:995
llvm::GetElementPtrInst::idx_end
op_iterator idx_end()
Definition:Instructions.h:1025
llvm::GetElementPtrInst::classof
static bool classof(const Instruction *I)
Definition:Instructions.h:1125
llvm::GetElementPtrInst::classof
static bool classof(const Value *V)
Definition:Instructions.h:1128
llvm::GetElementPtrInst::indices
iterator_range< op_iterator > indices()
Definition:Instructions.h:1028
llvm::GetElementPtrInst::Create
static GetElementPtrInst * Create(Type *PointeeType, Value *Ptr, ArrayRef< Value * > IdxList, const Twine &NameStr="", InsertPosition InsertBefore=nullptr)
Definition:Instructions.h:956
llvm::GetElementPtrInst::setIsInBounds
void setIsInBounds(bool b=true)
Set or clear the inbounds flag on this GEP instruction.
Definition:Instructions.cpp:1556
llvm::GetElementPtrInst::setSourceElementType
void setSourceElementType(Type *Ty)
Definition:Instructions.h:992
llvm::GetElementPtrInst::getIndexedType
static Type * getIndexedType(Type *Ty, ArrayRef< Value * > IdxList)
Returns the result type of a getelementptr with the given source element type and indexes.
Definition:Instructions.cpp:1514
llvm::GetElementPtrInst::getSourceElementType
Type * getSourceElementType() const
Definition:Instructions.h:990
llvm::GetElementPtrInst::CreateInBounds
static GetElementPtrInst * CreateInBounds(Type *PointeeType, Value *Ptr, ArrayRef< Value * > IdxList, const Twine &NameStr="", InsertPosition InsertBefore=nullptr)
Create an "inbounds" getelementptr.
Definition:Instructions.h:980
llvm::GetElementPtrInst::getPointerOperandType
Type * getPointerOperandType() const
Method to return the pointer operand as a PointerType.
Definition:Instructions.h:1048
llvm::GetElementPtrInst::Create
static GetElementPtrInst * Create(Type *PointeeType, Value *Ptr, ArrayRef< Value * > IdxList, GEPNoWrapFlags NW, const Twine &NameStr="", InsertPosition InsertBefore=nullptr)
Definition:Instructions.h:967
llvm::GetElementPtrInst::getPointerOperandIndex
static unsigned getPointerOperandIndex()
Definition:Instructions.h:1042
llvm::GetElementPtrInst::accumulateConstantOffset
bool accumulateConstantOffset(const DataLayout &DL, APInt &Offset) const
Accumulate the constant address offset of this GEP if possible.
Definition:Instructions.cpp:1581
llvm::GetElementPtrInst::idx_begin
op_iterator idx_begin()
Definition:Instructions.h:1023
llvm::GetElementPtrInst::idx_begin
const_op_iterator idx_begin() const
Definition:Instructions.h:1024
llvm::GetElementPtrInst::cloneImpl
GetElementPtrInst * cloneImpl() const
Definition:Instructions.cpp:4259
llvm::GetElementPtrInst::collectOffset
bool collectOffset(const DataLayout &DL, unsigned BitWidth, SmallMapVector< Value *, APInt, 4 > &VariableOffsets, APInt &ConstantOffset) const
Definition:Instructions.cpp:1587
llvm::GetElementPtrInst::setNoWrapFlags
void setNoWrapFlags(GEPNoWrapFlags NW)
Set nowrap flags for GEP instruction.
Definition:Instructions.cpp:1552
llvm::GetElementPtrInst::getNumIndices
unsigned getNumIndices() const
Definition:Instructions.h:1074
llvm::GetElementPtrInst::hasIndices
bool hasIndices() const
Definition:Instructions.h:1078
llvm::GetElementPtrInst::getNoWrapFlags
GEPNoWrapFlags getNoWrapFlags() const
Get the nowrap flags for the GEP instruction.
Definition:Instructions.cpp:1565
llvm::GetElementPtrInst::idx_end
const_op_iterator idx_end() const
Definition:Instructions.h:1026
llvm::GetElementPtrInst::getPointerOperand
const Value * getPointerOperand() const
Definition:Instructions.h:1039
llvm::GetElementPtrInst::getPointerAddressSpace
unsigned getPointerAddressSpace() const
Returns the address space of the pointer operand.
Definition:Instructions.h:1053
llvm::ICmpInst
This instruction compares its operands according to the predicate given to the constructor.
Definition:Instructions.h:1158
llvm::ICmpInst::hasSameSign
bool hasSameSign() const
An icmp instruction, which can be marked as "samesign", indicating that the two operands have the sam...
Definition:Instructions.h:1281
llvm::ICmpInst::classof
static bool classof(const Value *V)
Definition:Instructions.h:1366
llvm::ICmpInst::setSameSign
void setSameSign(bool B=true)
Definition:Instructions.h:1274
llvm::ICmpInst::ICmpInst
ICmpInst(InsertPosition InsertBefore, Predicate pred, Value *LHS, Value *RHS, const Twine &NameStr="")
Constructor with insertion semantics.
Definition:Instructions.h:1181
llvm::ICmpInst::isCommutative
static bool isCommutative(Predicate P)
Definition:Instructions.h:1297
llvm::ICmpInst::getSwappedCmpPredicate
static CmpPredicate getSwappedCmpPredicate(CmpPredicate Pred)
Definition:Instructions.h:1225
llvm::ICmpInst::getCmpPredicate
CmpPredicate getCmpPredicate() const
Definition:Instructions.h:1208
llvm::ICmpInst::isCommutative
bool isCommutative() const
Definition:Instructions.h:1301
llvm::ICmpInst::isGE
static bool isGE(Predicate P)
Return true if the predicate is SGE or UGE.
Definition:Instructions.h:1329
llvm::ICmpInst::getSwappedCmpPredicate
CmpPredicate getSwappedCmpPredicate() const
Definition:Instructions.h:1230
llvm::ICmpInst::isLT
static bool isLT(Predicate P)
Return true if the predicate is SLT or ULT.
Definition:Instructions.h:1323
llvm::ICmpInst::getInverseCmpPredicate
CmpPredicate getInverseCmpPredicate() const
Definition:Instructions.h:1219
llvm::ICmpInst::isGT
static bool isGT(Predicate P)
Return true if the predicate is SGT or UGT.
Definition:Instructions.h:1317
llvm::ICmpInst::classof
static bool classof(const Instruction *I)
Definition:Instructions.h:1363
llvm::ICmpInst::getFlippedSignednessPredicate
Predicate getFlippedSignednessPredicate() const
For example, SLT->ULT, ULT->SLT, SLE->ULE, ULE->SLE, EQ->EQ.
Definition:Instructions.h:1265
llvm::ICmpInst::getSignedPredicate
Predicate getSignedPredicate() const
For example, EQ->EQ, SLE->SLE, UGT->SGT, etc.
Definition:Instructions.h:1238
llvm::ICmpInst::getInverseCmpPredicate
static CmpPredicate getInverseCmpPredicate(CmpPredicate Pred)
Definition:Instructions.h:1214
llvm::ICmpInst::isEquality
bool isEquality() const
Return true if this predicate is either EQ or NE.
Definition:Instructions.h:1291
llvm::ICmpInst::isEquality
static bool isEquality(Predicate P)
Return true if this predicate is either EQ or NE.
Definition:Instructions.h:1285
llvm::ICmpInst::isRelational
static bool isRelational(Predicate P)
Return true if the predicate is relational (not EQ or NE).
Definition:Instructions.h:1311
llvm::ICmpInst::swapOperands
void swapOperands()
Exchange the two operands to this instruction in such a way that it does not modify the semantics of ...
Definition:Instructions.h:1348
llvm::ICmpInst::predicates
static auto predicates()
Returns the sequence of all ICmp predicates.
Definition:Instructions.h:1341
llvm::ICmpInst::ICmpInst
ICmpInst(Predicate pred, Value *LHS, Value *RHS, const Twine &NameStr="")
Constructor with no-insertion semantics.
Definition:Instructions.h:1195
llvm::ICmpInst::isRelational
bool isRelational() const
Return true if the predicate is relational (not EQ or NE).
Definition:Instructions.h:1305
llvm::ICmpInst::getUnsignedPredicate
Predicate getUnsignedPredicate() const
For example, EQ->EQ, SLE->ULE, UGT->UGT, etc.
Definition:Instructions.h:1249
llvm::ICmpInst::isLE
static bool isLE(Predicate P)
Return true if the predicate is SLE or ULE.
Definition:Instructions.h:1335
llvm::IndirectBrInst
Indirect Branch Instruction.
Definition:Instructions.h:3544
llvm::IndirectBrInst::Create
static IndirectBrInst * Create(Value *Address, unsigned NumDests, InsertPosition InsertBefore=nullptr)
Definition:Instructions.h:3602
llvm::IndirectBrInst::getDestination
BasicBlock * getDestination(unsigned i)
Return the specified destination.
Definition:Instructions.h:3620
llvm::IndirectBrInst::classof
static bool classof(const Value *V)
Definition:Instructions.h:3653
llvm::IndirectBrInst::getAddress
const Value * getAddress() const
Definition:Instructions.h:3612
llvm::IndirectBrInst::getAddress
Value * getAddress()
Definition:Instructions.h:3611
llvm::IndirectBrInst::classof
static bool classof(const Instruction *I)
Definition:Instructions.h:3650
llvm::IndirectBrInst::getSuccessor
BasicBlock * getSuccessor(unsigned i) const
Definition:Instructions.h:3632
llvm::IndirectBrInst::successors
iterator_range< const_succ_op_iterator > successors() const
Definition:Instructions.h:3644
llvm::IndirectBrInst::DECLARE_TRANSPARENT_OPERAND_ACCESSORS
DECLARE_TRANSPARENT_OPERAND_ACCESSORS(Value)
Provide fast operand accessors.
llvm::IndirectBrInst::getNumDestinations
unsigned getNumDestinations() const
return the number of possible destinations in this indirectbr instruction.
Definition:Instructions.h:3617
llvm::IndirectBrInst::getDestination
const BasicBlock * getDestination(unsigned i) const
Definition:Instructions.h:3621
llvm::IndirectBrInst::setSuccessor
void setSuccessor(unsigned i, BasicBlock *NewSucc)
Definition:Instructions.h:3635
llvm::IndirectBrInst::setAddress
void setAddress(Value *V)
Definition:Instructions.h:3613
llvm::IndirectBrInst::getNumSuccessors
unsigned getNumSuccessors() const
Definition:Instructions.h:3631
llvm::IndirectBrInst::successors
iterator_range< succ_op_iterator > successors()
Definition:Instructions.h:3639
llvm::Init
Definition:Record.h:285
llvm::InsertElementInst
This instruction inserts a single (scalar) element into a VectorType value.
Definition:Instructions.h:1834
llvm::InsertElementInst::classof
static bool classof(const Value *V)
Definition:Instructions.h:1873
llvm::InsertElementInst::Create
static InsertElementInst * Create(Value *Vec, Value *NewElt, Value *Idx, const Twine &NameStr="", InsertPosition InsertBefore=nullptr)
Definition:Instructions.h:1848
llvm::InsertElementInst::getType
VectorType * getType() const
Overload to return most specific vector type.
Definition:Instructions.h:1862
llvm::InsertElementInst::classof
static bool classof(const Instruction *I)
Definition:Instructions.h:1870
llvm::InsertElementInst::DECLARE_TRANSPARENT_OPERAND_ACCESSORS
DECLARE_TRANSPARENT_OPERAND_ACCESSORS(Value)
Transparently provide more efficient getOperand methods.
llvm::InsertPosition
Definition:Instruction.h:48
llvm::InsertValueInst
This instruction inserts a struct field of array element value into an aggregate value.
Definition:Instructions.h:2485
llvm::InsertValueInst::getInsertedValueOperand
Value * getInsertedValueOperand()
Definition:Instructions.h:2547
llvm::InsertValueInst::classof
static bool classof(const Instruction *I)
Definition:Instructions.h:2570
llvm::InsertValueInst::getAggregateOperandIndex
static unsigned getAggregateOperandIndex()
Definition:Instructions.h:2543
llvm::InsertValueInst::getAggregateOperand
Value * getAggregateOperand()
Definition:Instructions.h:2537
llvm::InsertValueInst::classof
static bool classof(const Value *V)
Definition:Instructions.h:2573
llvm::InsertValueInst::getNumIndices
unsigned getNumIndices() const
Definition:Instructions.h:2561
llvm::InsertValueInst::getIndices
ArrayRef< unsigned > getIndices() const
Definition:Instructions.h:2557
llvm::InsertValueInst::indices
iterator_range< idx_iterator > indices() const
Definition:Instructions.h:2533
llvm::InsertValueInst::getInsertedValueOperandIndex
static unsigned getInsertedValueOperandIndex()
Definition:Instructions.h:2553
llvm::InsertValueInst::cloneImpl
InsertValueInst * cloneImpl() const
Definition:Instructions.cpp:4284
llvm::InsertValueInst::idx_end
idx_iterator idx_end() const
Definition:Instructions.h:2532
llvm::InsertValueInst::Create
static InsertValueInst * Create(Value *Agg, Value *Val, ArrayRef< unsigned > Idxs, const Twine &NameStr="", InsertPosition InsertBefore=nullptr)
Definition:Instructions.h:2519
llvm::InsertValueInst::DECLARE_TRANSPARENT_OPERAND_ACCESSORS
DECLARE_TRANSPARENT_OPERAND_ACCESSORS(Value)
Transparently provide more efficient getOperand methods.
llvm::InsertValueInst::getAggregateOperand
const Value * getAggregateOperand() const
Definition:Instructions.h:2540
llvm::InsertValueInst::hasIndices
bool hasIndices() const
Definition:Instructions.h:2565
llvm::InsertValueInst::getInsertedValueOperand
const Value * getInsertedValueOperand() const
Definition:Instructions.h:2550
llvm::InsertValueInst::idx_begin
idx_iterator idx_begin() const
Definition:Instructions.h:2531
llvm::Instruction
Definition:Instruction.h:68
llvm::Instruction::AtomicOrderingBitfieldElementT
typename Bitfield::Element< AtomicOrdering, Offset, 3, AtomicOrdering::LAST > AtomicOrderingBitfieldElementT
Definition:Instruction.h:153
llvm::Instruction::BoolBitfieldElementT
typename Bitfield::Element< bool, Offset, 1 > BoolBitfieldElementT
Definition:Instruction.h:148
llvm::Instruction::isAtomic
bool isAtomic() const LLVM_READONLY
Return true if this instruction has an AtomicOrdering of unordered or higher.
Definition:Instruction.cpp:1031
llvm::Instruction::AlignmentBitfieldElementT
typename Bitfield::Element< unsigned, Offset, 6, Value::MaxAlignmentExponent > AlignmentBitfieldElementT
Definition:Instruction.h:145
llvm::Instruction::OtherOps
OtherOps
Definition:Instruction.h:1017
llvm::Instruction::getOpcode
unsigned getOpcode() const
Returns a member of one of the enums like Instruction::Add.
Definition:Instruction.h:291
llvm::Instruction::copyMetadata
void copyMetadata(const Instruction &SrcInst, ArrayRef< unsigned > WL=ArrayRef< unsigned >())
Copy metadata from SrcInst to this instruction.
Definition:Instruction.cpp:1345
llvm::Instruction::BasicBlock
friend class BasicBlock
Various leaf nodes.
Definition:Instruction.h:1027
llvm::IntToPtrInst
This class represents a cast from an integer to a pointer.
Definition:Instructions.h:4816
llvm::IntToPtrInst::classof
static bool classof(const Instruction *I)
Definition:Instructions.h:4838
llvm::IntToPtrInst::cloneImpl
IntToPtrInst * cloneImpl() const
Clone an identical IntToPtrInst.
Definition:Instructions.cpp:4367
llvm::IntToPtrInst::getAddressSpace
unsigned getAddressSpace() const
Returns the address space of this instruction's pointer type.
Definition:Instructions.h:4833
llvm::IntToPtrInst::classof
static bool classof(const Value *V)
Definition:Instructions.h:4841
llvm::InvokeInst
Invoke instruction.
Definition:Instructions.h:3670
llvm::InvokeInst::classof
static bool classof(const Instruction *I)
Definition:Instructions.h:3797
llvm::InvokeInst::getUnwindDest
BasicBlock * getUnwindDest() const
Definition:Instructions.h:3764
llvm::InvokeInst::setNormalDest
void setNormalDest(BasicBlock *B)
Definition:Instructions.h:3767
llvm::InvokeInst::classof
static bool classof(const Value *V)
Definition:Instructions.h:3800
llvm::InvokeInst::Create
static InvokeInst * Create(FunctionCallee Func, BasicBlock *IfNormal, BasicBlock *IfException, ArrayRef< Value * > Args, const Twine &NameStr, InsertPosition InsertBefore=nullptr)
Definition:Instructions.h:3734
llvm::InvokeInst::setSuccessor
void setSuccessor(unsigned i, BasicBlock *NewSucc)
Definition:Instructions.h:3783
llvm::InvokeInst::Create
static InvokeInst * Create(FunctionCallee Func, BasicBlock *IfNormal, BasicBlock *IfException, ArrayRef< Value * > Args, ArrayRef< OperandBundleDef > Bundles={}, const Twine &NameStr="", InsertPosition InsertBefore=nullptr)
Definition:Instructions.h:3742
llvm::InvokeInst::getSuccessor
BasicBlock * getSuccessor(unsigned i) const
Definition:Instructions.h:3778
llvm::InvokeInst::setUnwindDest
void setUnwindDest(BasicBlock *B)
Definition:Instructions.h:3770
llvm::InvokeInst::getNormalDest
BasicBlock * getNormalDest() const
Definition:Instructions.h:3761
llvm::InvokeInst::Create
static InvokeInst * Create(FunctionType *Ty, Value *Func, BasicBlock *IfNormal, BasicBlock *IfException, ArrayRef< Value * > Args, ArrayRef< OperandBundleDef > Bundles={}, const Twine &NameStr="", InsertPosition InsertBefore=nullptr)
Definition:Instructions.h:3720
llvm::InvokeInst::getNumSuccessors
unsigned getNumSuccessors() const
Definition:Instructions.h:3791
llvm::InvokeInst::Create
static InvokeInst * Create(FunctionType *Ty, Value *Func, BasicBlock *IfNormal, BasicBlock *IfException, ArrayRef< Value * > Args, const Twine &NameStr, InsertPosition InsertBefore=nullptr)
Definition:Instructions.h:3710
llvm::LLVMContext
This is an important class for using LLVM in a threaded context.
Definition:LLVMContext.h:67
llvm::LandingPadInst
The landingpad instruction holds all of the information necessary to generate correct exception handl...
Definition:Instructions.h:2840
llvm::LandingPadInst::isCleanup
bool isCleanup() const
Return 'true' if this landingpad instruction is a cleanup.
Definition:Instructions.h:2885
llvm::LandingPadInst::getNumClauses
unsigned getNumClauses() const
Get the number of clauses for this landing pad.
Definition:Instructions.h:2910
llvm::LandingPadInst::ClauseType
ClauseType
Definition:Instructions.h:2852
llvm::LandingPadInst::Catch
@ Catch
Definition:Instructions.h:2852
llvm::LandingPadInst::DECLARE_TRANSPARENT_OPERAND_ACCESSORS
DECLARE_TRANSPARENT_OPERAND_ACCESSORS(Value)
Provide fast operand accessors.
llvm::LandingPadInst::isCatch
bool isCatch(unsigned Idx) const
Return 'true' if the clause and index Idx is a catch clause.
Definition:Instructions.h:2900
llvm::LandingPadInst::isFilter
bool isFilter(unsigned Idx) const
Return 'true' if the clause and index Idx is a filter clause.
Definition:Instructions.h:2905
llvm::LandingPadInst::getClause
Constant * getClause(unsigned Idx) const
Get the value of the clause at index Idx.
Definition:Instructions.h:2895
llvm::LandingPadInst::classof
static bool classof(const Value *V)
Definition:Instructions.h:2920
llvm::LandingPadInst::setCleanup
void setCleanup(bool V)
Indicate that this landingpad instruction is a cleanup.
Definition:Instructions.h:2888
llvm::LandingPadInst::reserveClauses
void reserveClauses(unsigned Size)
Grow the size of the operand list to accommodate the new number of clauses.
Definition:Instructions.h:2914
llvm::LandingPadInst::classof
static bool classof(const Instruction *I)
Definition:Instructions.h:2917
llvm::LoadInst
An instruction for reading from memory.
Definition:Instructions.h:176
llvm::LoadInst::getPointerAddressSpace
unsigned getPointerAddressSpace() const
Returns the address space of the pointer operand.
Definition:Instructions.h:261
llvm::LoadInst::getPointerOperand
const Value * getPointerOperand() const
Definition:Instructions.h:256
llvm::LoadInst::setAlignment
void setAlignment(Align Align)
Definition:Instructions.h:215
llvm::LoadInst::getPointerOperand
Value * getPointerOperand()
Definition:Instructions.h:255
llvm::LoadInst::isVolatile
bool isVolatile() const
Return true if this is a load from a volatile memory location.
Definition:Instructions.h:205
llvm::LoadInst::classof
static bool classof(const Instruction *I)
Definition:Instructions.h:266
llvm::LoadInst::setOrdering
void setOrdering(AtomicOrdering Ordering)
Sets the ordering constraint of this load instruction.
Definition:Instructions.h:225
llvm::LoadInst::classof
static bool classof(const Value *V)
Definition:Instructions.h:269
llvm::LoadInst::setSyncScopeID
void setSyncScopeID(SyncScope::ID SSID)
Sets the synchronization scope ID of this load instruction.
Definition:Instructions.h:235
llvm::LoadInst::setAtomic
void setAtomic(AtomicOrdering Ordering, SyncScope::ID SSID=SyncScope::System)
Sets the ordering constraint and the synchronization scope ID of this load instruction.
Definition:Instructions.h:241
llvm::LoadInst::cloneImpl
LoadInst * cloneImpl() const
Definition:Instructions.cpp:4296
llvm::LoadInst::getOrdering
AtomicOrdering getOrdering() const
Returns the ordering constraint of this load instruction.
Definition:Instructions.h:220
llvm::LoadInst::getPointerOperandType
Type * getPointerOperandType() const
Definition:Instructions.h:258
llvm::LoadInst::getPointerOperandIndex
static unsigned getPointerOperandIndex()
Definition:Instructions.h:257
llvm::LoadInst::isUnordered
bool isUnordered() const
Definition:Instructions.h:249
llvm::LoadInst::setVolatile
void setVolatile(bool V)
Specify whether this is a volatile load or not.
Definition:Instructions.h:208
llvm::LoadInst::getSyncScopeID
SyncScope::ID getSyncScopeID() const
Returns the synchronization scope ID of this load instruction.
Definition:Instructions.h:230
llvm::LoadInst::isSimple
bool isSimple() const
Definition:Instructions.h:247
llvm::LoadInst::getAlign
Align getAlign() const
Return the alignment of the access that is being performed.
Definition:Instructions.h:211
llvm::MDNode
Metadata node.
Definition:Metadata.h:1073
llvm::MutableArrayRef
MutableArrayRef - Represent a mutable reference to an array (0 or more elements consecutively in memo...
Definition:ArrayRef.h:310
llvm::PHINode
Definition:Instructions.h:2600
llvm::PHINode::getIncomingBlock
BasicBlock * getIncomingBlock(Value::const_user_iterator I) const
Return incoming basic block corresponding to value use iterator.
Definition:Instructions.h:2710
llvm::PHINode::classof
static bool classof(const Instruction *I)
Methods for support type inquiry through isa, cast, and dyn_cast:
Definition:Instructions.h:2813
llvm::PHINode::addIncoming
void addIncoming(Value *V, BasicBlock *BB)
Add an incoming value to the end of the PHI list.
Definition:Instructions.h:2735
llvm::PHINode::isComplete
bool isComplete() const
If the PHI node is complete which means all of its parent's predecessors have incoming value in this ...
Definition:Instructions.h:2805
llvm::PHINode::blocks
iterator_range< const_block_iterator > blocks() const
Definition:Instructions.h:2661
llvm::PHINode::incoming_values
op_range incoming_values()
Definition:Instructions.h:2665
llvm::PHINode::classof
static bool classof(const Value *V)
Definition:Instructions.h:2816
llvm::PHINode::allocHungoffUses
void allocHungoffUses(unsigned N)
Definition:Instructions.h:2628
llvm::PHINode::block_begin
const_block_iterator block_begin() const
Definition:Instructions.h:2653
llvm::PHINode::setIncomingValueForBlock
void setIncomingValueForBlock(const BasicBlock *BB, Value *V)
Set every incoming value(s) for block BB to V.
Definition:Instructions.h:2782
llvm::PHINode::setIncomingBlock
void setIncomingBlock(unsigned i, BasicBlock *BB)
Definition:Instructions.h:2714
llvm::PHINode::const_block_iterator
BasicBlock *const * const_block_iterator
Definition:Instructions.h:2651
llvm::PHINode::setIncomingValue
void setIncomingValue(unsigned i, Value *V)
Definition:Instructions.h:2678
llvm::PHINode::getOperandNumForIncomingValue
static unsigned getOperandNumForIncomingValue(unsigned i)
Definition:Instructions.h:2685
llvm::PHINode::copyIncomingBlocks
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,...
Definition:Instructions.h:2720
llvm::PHINode::block_end
const_block_iterator block_end() const
Definition:Instructions.h:2657
llvm::PHINode::getIncomingValueForBlock
Value * getIncomingValueForBlock(const BasicBlock *BB) const
Definition:Instructions.h:2775
llvm::PHINode::getIncomingBlock
BasicBlock * getIncomingBlock(unsigned i) const
Return incoming basic block number i.
Definition:Instructions.h:2695
llvm::PHINode::DECLARE_TRANSPARENT_OPERAND_ACCESSORS
DECLARE_TRANSPARENT_OPERAND_ACCESSORS(Value)
Provide fast operand accessors.
llvm::PHINode::getIncomingValue
Value * getIncomingValue(unsigned i) const
Return incoming value number x.
Definition:Instructions.h:2675
llvm::PHINode::getIncomingValueNumForOperand
static unsigned getIncomingValueNumForOperand(unsigned i)
Definition:Instructions.h:2689
llvm::PHINode::incoming_values
const_op_range incoming_values() const
Definition:Instructions.h:2667
llvm::PHINode::removeIncomingValue
Value * removeIncomingValue(const BasicBlock *BB, bool DeletePHIIfEmpty=true)
Definition:Instructions.h:2754
llvm::PHINode::replaceIncomingBlockWith
void replaceIncomingBlockWith(const BasicBlock *Old, BasicBlock *New)
Replace every incoming basic block Old to basic block New.
Definition:Instructions.h:2726
llvm::PHINode::getIncomingBlock
BasicBlock * getIncomingBlock(const Use &U) const
Return incoming basic block corresponding to an operand of the PHI.
Definition:Instructions.h:2702
llvm::PHINode::getBasicBlockIndex
int getBasicBlockIndex(const BasicBlock *BB) const
Return the first index of the specified basic block in the value list for this PHI.
Definition:Instructions.h:2768
llvm::PHINode::getNumIncomingValues
unsigned getNumIncomingValues() const
Return the number of incoming edges.
Definition:Instructions.h:2671
llvm::PHINode::Create
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...
Definition:Instructions.h:2635
llvm::PointerType
Class to represent pointers.
Definition:DerivedTypes.h:670
llvm::PointerType::getAddressSpace
unsigned getAddressSpace() const
Return the address space of the Pointer type.
Definition:DerivedTypes.h:703
llvm::PtrToIntInst
This class represents a cast from a pointer to an integer.
Definition:Instructions.h:4851
llvm::PtrToIntInst::getPointerOperand
Value * getPointerOperand()
Gets the pointer operand.
Definition:Instructions.h:4869
llvm::PtrToIntInst::getPointerAddressSpace
unsigned getPointerAddressSpace() const
Returns the address space of the pointer operand.
Definition:Instructions.h:4876
llvm::PtrToIntInst::classof
static bool classof(const Value *V)
Definition:Instructions.h:4884
llvm::PtrToIntInst::getPointerOperand
const Value * getPointerOperand() const
Gets the pointer operand.
Definition:Instructions.h:4871
llvm::PtrToIntInst::getPointerOperandIndex
static unsigned getPointerOperandIndex()
Gets the operand index of the pointer operand.
Definition:Instructions.h:4873
llvm::PtrToIntInst::classof
static bool classof(const Instruction *I)
Definition:Instructions.h:4881
llvm::PtrToIntInst::cloneImpl
PtrToIntInst * cloneImpl() const
Clone an identical PtrToIntInst.
Definition:Instructions.cpp:4363
llvm::ResumeInst
Resume the propagation of an exception.
Definition:Instructions.h:4002
llvm::ResumeInst::Create
static ResumeInst * Create(Value *Exn, InsertPosition InsertBefore=nullptr)
Definition:Instructions.h:4016
llvm::ResumeInst::DECLARE_TRANSPARENT_OPERAND_ACCESSORS
DECLARE_TRANSPARENT_OPERAND_ACCESSORS(Value)
Provide fast operand accessors.
llvm::ResumeInst::getValue
Value * getValue() const
Convenience accessor.
Definition:Instructions.h:4024
llvm::ResumeInst::classof
static bool classof(const Value *V)
Definition:Instructions.h:4032
llvm::ResumeInst::getNumSuccessors
unsigned getNumSuccessors() const
Definition:Instructions.h:4026
llvm::ResumeInst::cloneImpl
ResumeInst * cloneImpl() const
Definition:Instructions.cpp:4454
llvm::ResumeInst::classof
static bool classof(const Instruction *I)
Definition:Instructions.h:4029
llvm::ReturnInst
Return a value (possibly void), from a function.
Definition:Instructions.h:2938
llvm::ReturnInst::DECLARE_TRANSPARENT_OPERAND_ACCESSORS
DECLARE_TRANSPARENT_OPERAND_ACCESSORS(Value)
Provide fast operand accessors.
llvm::ReturnInst::getNumSuccessors
unsigned getNumSuccessors() const
Definition:Instructions.h:2984
llvm::ReturnInst::classof
static bool classof(const Value *V)
Definition:Instructions.h:2990
llvm::ReturnInst::classof
static bool classof(const Instruction *I)
Definition:Instructions.h:2987
llvm::ReturnInst::Create
static ReturnInst * Create(LLVMContext &C, BasicBlock *InsertAtEnd)
Definition:Instructions.h:2971
llvm::ReturnInst::getReturnValue
Value * getReturnValue() const
Convenience accessor. Returns null if there is no return value.
Definition:Instructions.h:2980
llvm::ReturnInst::Create
static ReturnInst * Create(LLVMContext &C, Value *retVal=nullptr, InsertPosition InsertBefore=nullptr)
Definition:Instructions.h:2965
llvm::SExtInst
This class represents a sign extension of integer types.
Definition:Instructions.h:4600
llvm::SExtInst::classof
static bool classof(const Value *V)
Definition:Instructions.h:4621
llvm::SExtInst::classof
static bool classof(const Instruction *I)
Methods for support type inquiry through isa, cast, and dyn_cast:
Definition:Instructions.h:4618
llvm::SExtInst::cloneImpl
SExtInst * cloneImpl() const
Clone an identical SExtInst.
Definition:Instructions.cpp:4335
llvm::SIToFPInst
This class represents a cast from signed integer to floating point.
Definition:Instructions.h:4723
llvm::SIToFPInst::cloneImpl
SIToFPInst * cloneImpl() const
Clone an identical SIToFPInst.
Definition:Instructions.cpp:4351
llvm::SIToFPInst::classof
static bool classof(const Instruction *I)
Methods for support type inquiry through isa, cast, and dyn_cast:
Definition:Instructions.h:4741
llvm::SIToFPInst::classof
static bool classof(const Value *V)
Definition:Instructions.h:4744
llvm::SelectInst
This class represents the LLVM 'select' instruction.
Definition:Instructions.h:1657
llvm::SelectInst::Create
static SelectInst * Create(Value *C, Value *S1, Value *S2, const Twine &NameStr="", InsertPosition InsertBefore=nullptr, Instruction *MDFrom=nullptr)
Definition:Instructions.h:1682
llvm::SelectInst::setFalseValue
void setFalseValue(Value *V)
Definition:Instructions.h:1702
llvm::SelectInst::getFalseValue
const Value * getFalseValue() const
Definition:Instructions.h:1695
llvm::SelectInst::setTrueValue
void setTrueValue(Value *V)
Definition:Instructions.h:1701
llvm::SelectInst::getOpcode
OtherOps getOpcode() const
Definition:Instructions.h:1715
llvm::SelectInst::getCondition
Value * getCondition()
Definition:Instructions.h:1696
llvm::SelectInst::getTrueValue
Value * getTrueValue()
Definition:Instructions.h:1697
llvm::SelectInst::swapValues
void swapValues()
Swap the true and false values of the select instruction.
Definition:Instructions.h:1706
llvm::SelectInst::getFalseValue
Value * getFalseValue()
Definition:Instructions.h:1698
llvm::SelectInst::getCondition
const Value * getCondition() const
Definition:Instructions.h:1693
llvm::SelectInst::cloneImpl
SelectInst * cloneImpl() const
Definition:Instructions.cpp:4390
llvm::SelectInst::Instruction
friend class Instruction
Definition:Instructions.h:1677
llvm::SelectInst::DECLARE_TRANSPARENT_OPERAND_ACCESSORS
DECLARE_TRANSPARENT_OPERAND_ACCESSORS(Value)
Transparently provide more efficient getOperand methods.
llvm::SelectInst::areInvalidOperands
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.
Definition:Instructions.cpp:98
llvm::SelectInst::classof
static bool classof(const Value *V)
Definition:Instructions.h:1723
llvm::SelectInst::setCondition
void setCondition(Value *V)
Definition:Instructions.h:1700
llvm::SelectInst::getTrueValue
const Value * getTrueValue() const
Definition:Instructions.h:1694
llvm::SelectInst::classof
static bool classof(const Instruction *I)
Definition:Instructions.h:1720
llvm::ShuffleVectorInst
This instruction constructs a fixed permutation of two input vectors.
Definition:Instructions.h:1901
llvm::ShuffleVectorInst::classof
static bool classof(const Value *V)
Definition:Instructions.h:2379
llvm::ShuffleVectorInst::isInterleaveMask
static bool isInterleaveMask(ArrayRef< int > Mask, unsigned Factor, unsigned NumInputElts)
Definition:Instructions.h:2344
llvm::ShuffleVectorInst::getShuffleMaskForBitcode
Constant * getShuffleMaskForBitcode() const
Return the mask for this instruction, for use in bitcode.
Definition:Instructions.h:1967
llvm::ShuffleVectorInst::isSingleSource
bool isSingleSource() const
Return true if this shuffle chooses elements from exactly one source vector without changing the leng...
Definition:Instructions.h:2016
llvm::ShuffleVectorInst::changesLength
bool changesLength() const
Return true if this shuffle returns a vector with a different number of elements than its source vect...
Definition:Instructions.h:1980
llvm::ShuffleVectorInst::isExtractSubvectorMask
bool isExtractSubvectorMask(int &Index) const
Return true if this shuffle mask is an extract subvector mask.
Definition:Instructions.h:2229
llvm::ShuffleVectorInst::getShuffleMask
ArrayRef< int > getShuffleMask() const
Definition:Instructions.h:1974
llvm::ShuffleVectorInst::isInsertSubvectorMask
static bool isInsertSubvectorMask(const Constant *Mask, int NumSrcElts, int &NumSubElts, int &Index)
Definition:Instructions.h:2246
llvm::ShuffleVectorInst::isSingleSourceMask
static bool isSingleSourceMask(const Constant *Mask, int NumSrcElts)
Definition:Instructions.h:2005
llvm::ShuffleVectorInst::getMaskValue
int getMaskValue(unsigned Elt) const
Return the shuffle mask value of this instruction for the given element index.
Definition:Instructions.h:1950
llvm::ShuffleVectorInst::getShuffleMask
void getShuffleMask(SmallVectorImpl< int > &Result) const
Return the mask for this instruction as a vector of integers.
Definition:Instructions.h:1959
llvm::ShuffleVectorInst::DECLARE_TRANSPARENT_OPERAND_ACCESSORS
DECLARE_TRANSPARENT_OPERAND_ACCESSORS(Value)
Transparently provide more efficient getOperand methods.
llvm::ShuffleVectorInst::isDeInterleaveMaskOfFactor
static bool isDeInterleaveMaskOfFactor(ArrayRef< int > Mask, unsigned Factor)
Definition:Instructions.h:2355
llvm::ShuffleVectorInst::getType
VectorType * getType() const
Overload to return most specific vector type.
Definition:Instructions.h:1941
llvm::ShuffleVectorInst::isInsertSubvectorMask
bool isInsertSubvectorMask(int &NumSubElts, int &Index) const
Return true if this shuffle mask is an insert subvector mask.
Definition:Instructions.h:2259
llvm::ShuffleVectorInst::increasesLength
bool increasesLength() const
Return true if this shuffle returns a vector with a greater number of elements than its source vector...
Definition:Instructions.h:1991
llvm::ShuffleVectorInst::isZeroEltSplat
bool isZeroEltSplat() const
Return true if all elements of this shuffle are the same value as the first element of exactly one so...
Definition:Instructions.h:2134
llvm::ShuffleVectorInst::isExtractSubvectorMask
static bool isExtractSubvectorMask(const Constant *Mask, int NumSrcElts, int &Index)
Definition:Instructions.h:2216
llvm::ShuffleVectorInst::isSelect
bool isSelect() const
Return true if this shuffle chooses elements from its source vectors without lane crossings and all o...
Definition:Instructions.h:2090
llvm::ShuffleVectorInst::isSpliceMask
static bool isSpliceMask(const Constant *Mask, int NumSrcElts, int &Index)
Definition:Instructions.h:2195
llvm::ShuffleVectorInst::isTranspose
bool isTranspose() const
Return true if this shuffle transposes the elements of its inputs without changing the length of the ...
Definition:Instructions.h:2184
llvm::ShuffleVectorInst::commuteShuffleMask
static void commuteShuffleMask(MutableArrayRef< int > Mask, unsigned InVecNumElts)
Change values in a shuffle permute mask assuming the two vector operands of length InVecNumElts have ...
Definition:Instructions.h:2308
llvm::ShuffleVectorInst::isSplice
bool isSplice(int &Index) const
Return true if this shuffle splices two inputs without changing the length of the vectors.
Definition:Instructions.h:2206
llvm::ShuffleVectorInst::isReverseMask
static bool isReverseMask(const Constant *Mask, int NumSrcElts)
Definition:Instructions.h:2100
llvm::ShuffleVectorInst::isSelectMask
static bool isSelectMask(const Constant *Mask, int NumSrcElts)
Definition:Instructions.h:2075
llvm::ShuffleVectorInst::classof
static bool classof(const Instruction *I)
Definition:Instructions.h:2376
llvm::ShuffleVectorInst::isZeroEltSplatMask
static bool isZeroEltSplatMask(const Constant *Mask, int NumSrcElts)
Definition:Instructions.h:2121
llvm::ShuffleVectorInst::isIdentity
bool isIdentity() const
Return true if this shuffle chooses elements from exactly one source vector without lane crossings an...
Definition:Instructions.h:2044
llvm::ShuffleVectorInst::isReplicationMask
static bool isReplicationMask(const Constant *Mask, int &ReplicationFactor, int &VF)
Definition:Instructions.h:2276
llvm::ShuffleVectorInst::isIdentityMask
static bool isIdentityMask(const Constant *Mask, int NumSrcElts)
Definition:Instructions.h:2027
llvm::ShuffleVectorInst::isTransposeMask
static bool isTransposeMask(const Constant *Mask, int NumSrcElts)
Definition:Instructions.h:2172
llvm::ShuffleVectorInst::isReverse
bool isReverse() const
Return true if this shuffle swaps the order of elements from exactly one source vector.
Definition:Instructions.h:2111
llvm::SmallVectorBase::size
size_t size() const
Definition:SmallVector.h:78
llvm::SmallVectorImpl
This class consists of common code factored out of the SmallVector class to reduce code duplication b...
Definition:SmallVector.h:573
llvm::SmallVectorTemplateBase::push_back
void push_back(const T &Elt)
Definition:SmallVector.h:413
llvm::SmallVectorTemplateCommon::end
iterator end()
Definition:SmallVector.h:269
llvm::SmallVectorTemplateCommon::begin
iterator begin()
Definition:SmallVector.h:267
llvm::SmallVector
This is a 'vector' (really, a variable-sized array), optimized for the case when the array is small.
Definition:SmallVector.h:1196
llvm::StoreInst
An instruction for storing to memory.
Definition:Instructions.h:292
llvm::StoreInst::classof
static bool classof(const Instruction *I)
Definition:Instructions.h:392
llvm::StoreInst::getOrdering
AtomicOrdering getOrdering() const
Returns the ordering constraint of this store instruction.
Definition:Instructions.h:342
llvm::StoreInst::getPointerOperand
const Value * getPointerOperand() const
Definition:Instructions.h:382
llvm::StoreInst::getAlign
Align getAlign() const
Definition:Instructions.h:333
llvm::StoreInst::getPointerOperandType
Type * getPointerOperandType() const
Definition:Instructions.h:384
llvm::StoreInst::setVolatile
void setVolatile(bool V)
Specify whether this is a volatile store or not.
Definition:Instructions.h:328
llvm::StoreInst::setAlignment
void setAlignment(Align Align)
Definition:Instructions.h:337
llvm::StoreInst::isSimple
bool isSimple() const
Definition:Instructions.h:370
llvm::StoreInst::getValueOperand
const Value * getValueOperand() const
Definition:Instructions.h:379
llvm::StoreInst::setOrdering
void setOrdering(AtomicOrdering Ordering)
Sets the ordering constraint of this store instruction.
Definition:Instructions.h:348
llvm::StoreInst::getValueOperand
Value * getValueOperand()
Definition:Instructions.h:378
llvm::StoreInst::classof
static bool classof(const Value *V)
Definition:Instructions.h:395
llvm::StoreInst::isUnordered
bool isUnordered() const
Definition:Instructions.h:372
llvm::StoreInst::DECLARE_TRANSPARENT_OPERAND_ACCESSORS
DECLARE_TRANSPARENT_OPERAND_ACCESSORS(Value)
Transparently provide more efficient getOperand methods.
llvm::StoreInst::setSyncScopeID
void setSyncScopeID(SyncScope::ID SSID)
Sets the synchronization scope ID of this store instruction.
Definition:Instructions.h:358
llvm::StoreInst::cloneImpl
StoreInst * cloneImpl() const
Definition:Instructions.cpp:4301
llvm::StoreInst::getPointerAddressSpace
unsigned getPointerAddressSpace() const
Returns the address space of the pointer operand.
Definition:Instructions.h:387
llvm::StoreInst::getPointerOperandIndex
static unsigned getPointerOperandIndex()
Definition:Instructions.h:383
llvm::StoreInst::getSyncScopeID
SyncScope::ID getSyncScopeID() const
Returns the synchronization scope ID of this store instruction.
Definition:Instructions.h:353
llvm::StoreInst::isVolatile
bool isVolatile() const
Return true if this is a store to a volatile memory location.
Definition:Instructions.h:325
llvm::StoreInst::getPointerOperand
Value * getPointerOperand()
Definition:Instructions.h:381
llvm::StoreInst::setAtomic
void setAtomic(AtomicOrdering Ordering, SyncScope::ID SSID=SyncScope::System)
Sets the ordering constraint and the synchronization scope ID of this store instruction.
Definition:Instructions.h:364
llvm::StringRef
StringRef - Represent a constant reference to a string, i.e.
Definition:StringRef.h:51
llvm::SwitchInstProfUpdateWrapper
A wrapper class to simplify modification of SwitchInst cases along with their prof branch_weights met...
Definition:Instructions.h:3492
llvm::SwitchInstProfUpdateWrapper::init
void init()
Definition:Instructions.cpp:4076
llvm::SwitchInstProfUpdateWrapper::setSuccessorWeight
void setSuccessorWeight(unsigned idx, CaseWeightOpt W)
Definition:Instructions.cpp:4141
llvm::SwitchInstProfUpdateWrapper::eraseFromParent
Instruction::InstListType::iterator eraseFromParent()
Delegate the call to the underlying SwitchInst::eraseFromParent() and mark this object to not touch t...
Definition:Instructions.cpp:4126
llvm::SwitchInstProfUpdateWrapper::addCase
void addCase(ConstantInt *OnVal, BasicBlock *Dest, CaseWeightOpt W)
Delegate the call to the underlying SwitchInst::addCase() and set the specified branch weight for the...
Definition:Instructions.cpp:4107
llvm::SwitchInstProfUpdateWrapper::operator*
SwitchInst & operator*()
Definition:Instructions.h:3505
llvm::SwitchInstProfUpdateWrapper::SwitchInstProfUpdateWrapper
SwitchInstProfUpdateWrapper(SwitchInst &SI)
Definition:Instructions.h:3508
llvm::SwitchInstProfUpdateWrapper::~SwitchInstProfUpdateWrapper
~SwitchInstProfUpdateWrapper()
Definition:Instructions.h:3510
llvm::SwitchInstProfUpdateWrapper::getSuccessorWeight
CaseWeightOpt getSuccessorWeight(unsigned idx)
Definition:Instructions.cpp:4135
llvm::SwitchInstProfUpdateWrapper::buildProfBranchWeightsMD
MDNode * buildProfBranchWeightsMD()
Definition:Instructions.cpp:4059
llvm::SwitchInstProfUpdateWrapper::CaseWeightOpt
std::optional< uint32_t > CaseWeightOpt
Definition:Instructions.h:3503
llvm::SwitchInstProfUpdateWrapper::operator->
SwitchInst * operator->()
Definition:Instructions.h:3504
llvm::SwitchInstProfUpdateWrapper::removeCase
SwitchInst::CaseIt removeCase(SwitchInst::CaseIt I)
Delegate the call to the underlying SwitchInst::removeCase() and remove correspondent branch weight.
Definition:Instructions.cpp:4093
llvm::SwitchInst::CaseHandleImpl
A handle to a particular switch case.
Definition:Instructions.h:3198
llvm::SwitchInst::CaseHandleImpl::getCaseIndex
unsigned getCaseIndex() const
Returns number of current case.
Definition:Instructions.h:3230
llvm::SwitchInst::CaseHandleImpl::Index
ptrdiff_t Index
Definition:Instructions.h:3208
llvm::SwitchInst::CaseHandleImpl::CaseHandleImpl
CaseHandleImpl()=default
llvm::SwitchInst::CaseHandleImpl::getSuccessorIndex
unsigned getSuccessorIndex() const
Returns successor index for current case successor.
Definition:Instructions.h:3233
llvm::SwitchInst::CaseHandleImpl::getCaseSuccessor
BasicBlockT * getCaseSuccessor() const
Resolves successor for current case.
Definition:Instructions.h:3222
llvm::SwitchInst::CaseHandleImpl::CaseHandleImpl
CaseHandleImpl(SwitchInstT *SI, ptrdiff_t Index)
Definition:Instructions.h:3211
llvm::SwitchInst::CaseHandleImpl::operator==
bool operator==(const CaseHandleImpl &RHS) const
Definition:Instructions.h:3240
llvm::SwitchInst::CaseHandleImpl::SI
SwitchInstT * SI
Definition:Instructions.h:3207
llvm::SwitchInst::CaseHandleImpl::getCaseValue
ConstantIntT * getCaseValue() const
Resolves case value for current case.
Definition:Instructions.h:3215
llvm::SwitchInst::CaseHandleImpl::SwitchInstType
SwitchInstT SwitchInstType
Definition:Instructions.h:3205
llvm::SwitchInst::CaseHandle
Definition:Instructions.h:3250
llvm::SwitchInst::CaseHandle::CaseHandle
CaseHandle(SwitchInst *SI, ptrdiff_t Index)
Definition:Instructions.h:3254
llvm::SwitchInst::CaseHandle::setValue
void setValue(ConstantInt *V) const
Sets the new value for current case.
Definition:Instructions.h:3257
llvm::SwitchInst::CaseHandle::setSuccessor
void setSuccessor(BasicBlock *S) const
Sets the new successor for current case.
Definition:Instructions.h:3264
llvm::SwitchInst::CaseIteratorImpl
Definition:Instructions.h:3273
llvm::SwitchInst::CaseIteratorImpl::operator*
const CaseHandleT & operator*() const
Definition:Instructions.h:3332
llvm::SwitchInst::CaseIteratorImpl::CaseIteratorImpl
CaseIteratorImpl()=default
Default constructed iterator is in an invalid state until assigned to a case for a particular switch.
llvm::SwitchInst::CaseIteratorImpl::operator-=
CaseIteratorImpl & operator-=(ptrdiff_t N)
Definition:Instructions.h:3312
llvm::SwitchInst::CaseIteratorImpl::operator==
bool operator==(const CaseIteratorImpl &RHS) const
Definition:Instructions.h:3325
llvm::SwitchInst::CaseIteratorImpl::operator+=
CaseIteratorImpl & operator+=(ptrdiff_t N)
Definition:Instructions.h:3303
llvm::SwitchInst::CaseIteratorImpl::operator-
ptrdiff_t operator-(const CaseIteratorImpl &RHS) const
Definition:Instructions.h:3321
llvm::SwitchInst::CaseIteratorImpl::operator<
bool operator<(const CaseIteratorImpl &RHS) const
Definition:Instructions.h:3328
llvm::SwitchInst::CaseIteratorImpl::CaseIteratorImpl
CaseIteratorImpl(SwitchInstT *SI, unsigned CaseNum)
Initializes case iterator for given SwitchInst and for given case number.
Definition:Instructions.h:3285
llvm::SwitchInst::CaseIteratorImpl::fromSuccessorIndex
static CaseIteratorImpl fromSuccessorIndex(SwitchInstT *SI, unsigned SuccessorIndex)
Initializes case iterator for given SwitchInst and for given successor index.
Definition:Instructions.h:3289
llvm::SwitchInst
Multiway switch.
Definition:Instructions.h:3154
llvm::SwitchInst::getDefaultDest
BasicBlock * getDefaultDest() const
Definition:Instructions.h:3351
llvm::SwitchInst::case_end
CaseIt case_end()
Returns a read/write iterator that points one past the last in the SwitchInst.
Definition:Instructions.h:3385
llvm::SwitchInst::getSuccessor
BasicBlock * getSuccessor(unsigned idx) const
Definition:Instructions.h:3472
llvm::SwitchInst::findCaseValue
ConstCaseIt findCaseValue(const ConstantInt *C) const
Definition:Instructions.h:3426
llvm::SwitchInst::DECLARE_TRANSPARENT_OPERAND_ACCESSORS
DECLARE_TRANSPARENT_OPERAND_ACCESSORS(Value)
Provide fast operand accessors.
llvm::SwitchInst::Create
static SwitchInst * Create(Value *Value, BasicBlock *Default, unsigned NumCases, InsertPosition InsertBefore=nullptr)
Definition:Instructions.h:3338
llvm::SwitchInst::setCondition
void setCondition(Value *V)
Definition:Instructions.h:3349
llvm::SwitchInst::case_begin
ConstCaseIt case_begin() const
Returns a read-only iterator that points to the first case in the SwitchInst.
Definition:Instructions.h:3379
llvm::SwitchInst::defaultDestUndefined
bool defaultDestUndefined() const
Returns true if the default branch must result in immediate undefined behavior, false otherwise.
Definition:Instructions.h:3357
llvm::SwitchInst::cases
iterator_range< ConstCaseIt > cases() const
Constant iteration adapter for range-for loops.
Definition:Instructions.h:3401
llvm::SwitchInst::findCaseDest
ConstantInt * findCaseDest(BasicBlock *BB)
Finds the unique case value for a given successor.
Definition:Instructions.h:3438
llvm::SwitchInst::setSuccessor
void setSuccessor(unsigned idx, BasicBlock *NewSucc)
Definition:Instructions.h:3476
llvm::SwitchInst::classof
static bool classof(const Value *V)
Definition:Instructions.h:3485
llvm::SwitchInst::getNumSuccessors
unsigned getNumSuccessors() const
Definition:Instructions.h:3471
llvm::SwitchInst::case_default
CaseIt case_default()
Returns an iterator that points to the default case.
Definition:Instructions.h:3410
llvm::SwitchInst::setDefaultDest
void setDefaultDest(BasicBlock *DefaultCase)
Definition:Instructions.h:3361
llvm::SwitchInst::getNumCases
unsigned getNumCases() const
Return the number of 'cases' in this switch instruction, excluding the default case.
Definition:Instructions.h:3367
llvm::SwitchInst::findCaseValue
CaseIt findCaseValue(const ConstantInt *C)
Search all of the case values for the specified constant.
Definition:Instructions.h:3421
llvm::SwitchInst::getCondition
Value * getCondition() const
Definition:Instructions.h:3348
llvm::SwitchInst::case_default
ConstCaseIt case_default() const
Definition:Instructions.h:3413
llvm::SwitchInst::case_begin
CaseIt case_begin()
Returns a read/write iterator that points to the first case in the SwitchInst.
Definition:Instructions.h:3373
llvm::SwitchInst::classof
static bool classof(const Instruction *I)
Definition:Instructions.h:3482
llvm::SwitchInst::cases
iterator_range< CaseIt > cases()
Iteration adapter for range-for loops.
Definition:Instructions.h:3396
llvm::SwitchInst::case_end
ConstCaseIt case_end() const
Returns a read-only iterator that points one past the last in the SwitchInst.
Definition:Instructions.h:3391
llvm::TruncInst
This class represents a truncation of integer types.
Definition:Instructions.h:4503
llvm::TruncInst::setHasNoSignedWrap
void setHasNoSignedWrap(bool B)
Definition:Instructions.h:4534
llvm::TruncInst::classof
static bool classof(const Instruction *I)
Methods for support type inquiry through isa, cast, and dyn_cast:
Definition:Instructions.h:4523
llvm::TruncInst::cloneImpl
TruncInst * cloneImpl() const
Clone an identical TruncInst.
Definition:Instructions.cpp:4327
llvm::TruncInst::setHasNoUnsignedWrap
void setHasNoUnsignedWrap(bool B)
Definition:Instructions.h:4530
llvm::TruncInst::NoUnsignedWrap
@ NoUnsignedWrap
Definition:Instructions.h:4512
llvm::TruncInst::NoSignedWrap
@ NoSignedWrap
Definition:Instructions.h:4512
llvm::TruncInst::AnyWrap
@ AnyWrap
Definition:Instructions.h:4512
llvm::TruncInst::getNoWrapKind
unsigned getNoWrapKind() const
Returns the no-wrap kind of the operation.
Definition:Instructions.h:4552
llvm::TruncInst::hasNoSignedWrap
bool hasNoSignedWrap() const
Test whether this operation is known to never undergo signed overflow, aka the nsw property.
Definition:Instructions.h:4547
llvm::TruncInst::classof
static bool classof(const Value *V)
Definition:Instructions.h:4526
llvm::TruncInst::hasNoUnsignedWrap
bool hasNoUnsignedWrap() const
Test whether this operation is known to never undergo unsigned overflow, aka the nuw property.
Definition:Instructions.h:4541
llvm::Twine
Twine - A lightweight data structure for efficiently representing the concatenation of temporary valu...
Definition:Twine.h:81
llvm::Type
The instances of the Type class are immutable: once they are created, they are never changed.
Definition:Type.h:45
llvm::Type::isVectorTy
bool isVectorTy() const
True if this is an instance of VectorType.
Definition:Type.h:270
llvm::Type::getPointerAddressSpace
unsigned getPointerAddressSpace() const
Get the address space of this pointer or pointer vector type.
llvm::Type::isTokenTy
bool isTokenTy() const
Return true if this is 'token'.
Definition:Type.h:234
llvm::UIToFPInst
This class represents a cast unsigned integer to floating point.
Definition:Instructions.h:4692
llvm::UIToFPInst::classof
static bool classof(const Value *V)
Definition:Instructions.h:4713
llvm::UIToFPInst::cloneImpl
UIToFPInst * cloneImpl() const
Clone an identical UIToFPInst.
Definition:Instructions.cpp:4347
llvm::UIToFPInst::classof
static bool classof(const Instruction *I)
Methods for support type inquiry through isa, cast, and dyn_cast:
Definition:Instructions.h:4710
llvm::UnaryInstruction
Definition:InstrTypes.h:57
llvm::UnreachableInst
This function has undefined behavior.
Definition:Instructions.h:4461
llvm::UnreachableInst::getNumSuccessors
unsigned getNumSuccessors() const
Definition:Instructions.h:4478
llvm::UnreachableInst::classof
static bool classof(const Value *V)
Definition:Instructions.h:4484
llvm::UnreachableInst::classof
static bool classof(const Instruction *I)
Definition:Instructions.h:4481
llvm::Use
A Use represents the edge between a Value definition and its users.
Definition:Use.h:43
llvm::User::allocHungoffUses
void allocHungoffUses(unsigned N, bool IsPhi=false)
Allocate the array of Uses, followed by a pointer (with bottom bit set) to the User.
Definition:User.cpp:50
llvm::User::op_begin
op_iterator op_begin()
Definition:User.h:280
llvm::User::getOperandUse
const Use & getOperandUse(unsigned i) const
Definition:User.h:241
llvm::User::getOperand
Value * getOperand(unsigned i) const
Definition:User.h:228
llvm::User::getNumOperands
unsigned getNumOperands() const
Definition:User.h:250
llvm::User::op_end
op_iterator op_end()
Definition:User.h:282
llvm::VAArgInst
This class represents the va_arg llvm instruction, which returns an argument of the specified type gi...
Definition:Instructions.h:1741
llvm::VAArgInst::classof
static bool classof(const Instruction *I)
Definition:Instructions.h:1760
llvm::VAArgInst::getPointerOperand
Value * getPointerOperand()
Definition:Instructions.h:1755
llvm::VAArgInst::VAArgInst
VAArgInst(Value *List, Type *Ty, const Twine &NameStr="", InsertPosition InsertBefore=nullptr)
Definition:Instructions.h:1749
llvm::VAArgInst::getPointerOperand
const Value * getPointerOperand() const
Definition:Instructions.h:1756
llvm::VAArgInst::classof
static bool classof(const Value *V)
Definition:Instructions.h:1763
llvm::VAArgInst::getPointerOperandIndex
static unsigned getPointerOperandIndex()
Definition:Instructions.h:1757
llvm::Value
LLVM Value Representation.
Definition:Value.h:74
llvm::Value::getType
Type * getType() const
All values are typed, get the type of this value.
Definition:Value.h:255
llvm::Value::const_user_iterator
user_iterator_impl< const User > const_user_iterator
Definition:Value.h:391
llvm::Value::SubclassOptionalData
unsigned char SubclassOptionalData
Hold subclass data that can be dropped.
Definition:Value.h:84
llvm::Value::setName
void setName(const Twine &Name)
Change the name of the value.
Definition:Value.cpp:377
llvm::VectorType
Base class of all SIMD vector types.
Definition:DerivedTypes.h:427
llvm::VectorType::get
static VectorType * get(Type *ElementType, ElementCount EC)
This static method is the primary way to construct an VectorType.
llvm::ZExtInst
This class represents zero extension of integer types.
Definition:Instructions.h:4569
llvm::ZExtInst::classof
static bool classof(const Instruction *I)
Methods for support type inquiry through isa, cast, and dyn_cast:
Definition:Instructions.h:4587
llvm::ZExtInst::classof
static bool classof(const Value *V)
Definition:Instructions.h:4590
llvm::ZExtInst::cloneImpl
ZExtInst * cloneImpl() const
Clone an identical ZExtInst.
Definition:Instructions.cpp:4331
llvm::function_ref
An efficient, type-erasing, non-owning reference to a callable.
Definition:STLFunctionalExtras.h:37
llvm::iplist_impl::iterator
base_list_type::iterator iterator
Definition:ilist.h:121
llvm::iterator_adaptor_base
CRTP base class for adapting an iterator to a different type.
Definition:iterator.h:237
llvm::iterator_facade_base
CRTP base class which implements the entire standard iterator facade in terms of a minimal subset of ...
Definition:iterator.h:80
llvm::iterator_range
A range adaptor for a pair of iterators.
Definition:iterator_range.h:42
llvm::mapped_iterator
Definition:STLExtras.h:353
ptrdiff_t
uint32_t
uint64_t
uint8_t
unsigned
iterator.h
iterator_range.h
This provides a very simple, boring adaptor for a begin and end iterator into a range type.
ErrorHandling.h
llvm_unreachable
#define llvm_unreachable(msg)
Marks that the current location is not supposed to be reachable.
Definition:ErrorHandling.h:143
llvm::AMDGPU::HSAMD::Kernel::Key::Args
constexpr char Args[]
Key for Kernel::Metadata::mArgs.
Definition:AMDGPUMetadata.h:395
llvm::CallingConv::C
@ C
The default llvm calling convention, compatible with C.
Definition:CallingConv.h:34
llvm::ISD::BasicBlock
@ BasicBlock
Various leaf nodes.
Definition:ISDOpcodes.h:71
llvm::MCID::Call
@ Call
Definition:MCInstrDesc.h:156
llvm::SyncScope::ID
uint8_t ID
Definition:LLVMContext.h:46
llvm::SyncScope::System
@ System
Synchronized with respect to all concurrently executing threads.
Definition:LLVMContext.h:57
llvm::TargetStackID::Value
Value
Definition:TargetFrameLowering.h:29
llvm::cl::init
initializer< Ty > init(const Ty &Val)
Definition:CommandLine.h:443
llvm::lltok::APFloat
@ APFloat
Definition:LLToken.h:504
llvm
This is an optimization pass for GlobalISel generic memory operations.
Definition:AddressRanges.h:18
llvm::Offset
@ Offset
Definition:DWP.cpp:480
llvm::checkGEPType
Type * checkGEPType(Type *Ty)
Definition:Instructions.h:925
llvm::all_of
bool all_of(R &&range, UnaryPredicate P)
Provide wrappers to std::all_of which take ranges instead of having to pass begin/end explicitly.
Definition:STLExtras.h:1739
llvm::getLoadStoreAddressSpace
unsigned getLoadStoreAddressSpace(const Value *I)
A helper function that returns the address space of the pointer operand of load or store instruction.
Definition:Instructions.h:5030
llvm::operator*
APInt operator*(APInt a, uint64_t RHS)
Definition:APInt.h:2204
llvm::getLoadStorePointerOperand
const Value * getLoadStorePointerOperand(const Value *V)
A helper function that returns the pointer operand of a load or store instruction.
Definition:Instructions.h:4984
llvm::make_range
iterator_range< T > make_range(T x, T y)
Convenience function for iterating over sub-ranges.
Definition:iterator_range.h:77
llvm::setAtomicSyncScopeID
void setAtomicSyncScopeID(Instruction *I, SyncScope::ID SSID)
A helper function that sets an atomic operation's sync scope.
Definition:Instructions.h:5066
llvm::getLoadStoreAlignment
Align getLoadStoreAlignment(const Value *I)
A helper function that returns the alignment of load or store instruction.
Definition:Instructions.h:5010
llvm::getPointerOperand
const Value * getPointerOperand(const Value *V)
A helper function that returns the pointer operand of a load, store or GEP instruction.
Definition:Instructions.h:4998
llvm::get
decltype(auto) get(const PointerIntPair< PointerTy, IntBits, IntType, PtrTraits, Info > &Pair)
Definition:PointerIntPair.h:270
llvm::getAtomicSyncScopeID
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...
Definition:Instructions.h:5049
llvm::CaptureComponents::Address
@ Address
llvm::PoisonMaskElem
constexpr int PoisonMaskElem
Definition:Instructions.h:1889
llvm::AtomicOrdering
AtomicOrdering
Atomic ordering for LLVM's memory model.
Definition:AtomicOrdering.h:56
llvm::AtomicOrdering::Monotonic
@ Monotonic
llvm::AtomicOrdering::Unordered
@ Unordered
llvm::AtomicOrdering::NotAtomic
@ NotAtomic
llvm::AtomicOrdering::AcquireRelease
@ AcquireRelease
llvm::AtomicOrdering::Acquire
@ Acquire
llvm::AtomicOrdering::Release
@ Release
llvm::AtomicOrdering::SequentiallyConsistent
@ SequentiallyConsistent
llvm::AtomicOrdering::LAST
@ LAST
llvm::ClrHandlerType::Filter
@ Filter
llvm::Op
DWARFExpression::Operation Op
Definition:DWARFExpression.cpp:22
llvm::copy
OutputIt copy(R &&Range, OutputIt Out)
Definition:STLExtras.h:1841
llvm::BitWidth
constexpr unsigned BitWidth
Definition:BitmaskEnum.h:217
llvm::find_if
auto find_if(R &&Range, UnaryPredicate P)
Provide wrappers to std::find_if which take ranges instead of having to pass begin/end explicitly.
Definition:STLExtras.h:1766
llvm::predecessors
auto predecessors(const MachineBasicBlock *BB)
Definition:MachineBasicBlock.h:1377
llvm::BasicBlockSection::List
@ List
llvm::getLoadStoreType
Type * getLoadStoreType(const Value *I)
A helper function that returns the type of a load or store instruction.
Definition:Instructions.h:5039
llvm::setLoadStoreAlignment
void setLoadStoreAlignment(Value *I, Align NewAlign)
A helper function that set the alignment of load or store instruction.
Definition:Instructions.h:5019
llvm::Log2
unsigned Log2(Align A)
Returns the log2 of the alignment.
Definition:Alignment.h:208
llvm::InstructionUniformity::Default
@ Default
The result values are uniform if and only if all operands are uniform.
N
#define N
llvm::Align
This struct is a compact representation of a valid (non-zero power of two) alignment.
Definition:Alignment.h:39
llvm::AllocInfo
Summary of memprof metadata on allocations.
Definition:ModuleSummaryIndex.h:405
llvm::Bitfield::Element
Describes an element of a Bitfield.
Definition:Bitfields.h:223
llvm::Bitfield::areContiguous
static constexpr bool areContiguous()
Definition:Bitfields.h:280
llvm::BranchInst::const_succ_op_iterator
The const version of succ_op_iterator.
Definition:Instructions.h:3064
llvm::BranchInst::const_succ_op_iterator::operator->
const BasicBlock * operator->() const
Definition:Instructions.h:3069
llvm::BranchInst::const_succ_op_iterator::const_succ_op_iterator
const_succ_op_iterator(const_value_op_iterator I)
Definition:Instructions.h:3065
llvm::BranchInst::const_succ_op_iterator::operator*
const BasicBlock * operator*() const
Definition:Instructions.h:3068
llvm::BranchInst::succ_op_iterator
Iterator type that casts an operand to a basic block.
Definition:Instructions.h:3052
llvm::BranchInst::succ_op_iterator::operator->
BasicBlock * operator->() const
Definition:Instructions.h:3056
llvm::BranchInst::succ_op_iterator::succ_op_iterator
succ_op_iterator(value_op_iterator I)
Definition:Instructions.h:3053
llvm::BranchInst::succ_op_iterator::operator*
BasicBlock * operator*() const
Definition:Instructions.h:3055
llvm::FixedNumOperandTraits
FixedNumOperandTraits - determine the allocation regime of the Use array when it is a prefix to the U...
Definition:OperandTraits.h:30
llvm::HungoffOperandTraits
HungoffOperandTraits - determine the allocation regime of the Use array when it is not a prefix to th...
Definition:OperandTraits.h:93
llvm::IndirectBrInst::const_succ_op_iterator
The const version of succ_op_iterator.
Definition:Instructions.h:3594
llvm::IndirectBrInst::const_succ_op_iterator::operator*
const BasicBlock * operator*() const
Definition:Instructions.h:3598
llvm::IndirectBrInst::const_succ_op_iterator::const_succ_op_iterator
const_succ_op_iterator(const_value_op_iterator I)
Definition:Instructions.h:3595
llvm::IndirectBrInst::const_succ_op_iterator::operator->
const BasicBlock * operator->() const
Definition:Instructions.h:3599
llvm::IndirectBrInst::succ_op_iterator
Iterator type that casts an operand to a basic block.
Definition:Instructions.h:3582
llvm::IndirectBrInst::succ_op_iterator::operator*
BasicBlock * operator*() const
Definition:Instructions.h:3585
llvm::IndirectBrInst::succ_op_iterator::succ_op_iterator
succ_op_iterator(value_op_iterator I)
Definition:Instructions.h:3583
llvm::IndirectBrInst::succ_op_iterator::operator->
BasicBlock * operator->() const
Definition:Instructions.h:3586
llvm::KnownBits
Definition:KnownBits.h:23
llvm::OperandTraits
Compile-time customization of User operands.
Definition:User.h:42
llvm::SmallMapVector
A MapVector that performs no allocations if smaller than a certain size.
Definition:MapVector.h:254
llvm::User::AllocInfo
Information about how a User object was allocated, to be passed into the User constructor.
Definition:User.h:79
llvm::User::HungOffOperandsAllocMarker
Indicates this User has operands "hung off" in another allocation.
Definition:User.h:57
llvm::User::IntrusiveOperandsAllocMarker
Indicates this User has operands co-allocated.
Definition:User.h:60
llvm::User::const_value_op_iterator
Definition:User.h:319
llvm::User::value_op_iterator
Iterator for directly iterating over the operand Values.
Definition:User.h:299
llvm::VariadicOperandTraits
VariadicOperandTraits - determine the allocation regime of the Use array when it is a prefix to the U...
Definition:OperandTraits.h:67

Generated on Thu Jul 17 2025 10:05:25 for LLVM by doxygen 1.9.6
[8]ページ先頭

©2009-2025 Movatter.jp