llvm.org GIT mirror llvm / cfa4450
[IR] Fix some Clang-tidy modernize-use-equals-delete and Include What You Use warnings; other minor fixes (NFC). Also remove obsolete comment from CommandLine.h spotted by Malcolm Parsons. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@288714 91177308-0d34-0410-b5e6-96231b3b80d8 Eugene Zelenko 3 years ago
8 changed file(s) with 353 addition(s) and 178 deletion(s). Raw diff Collapse all Expand all
1717 #ifndef LLVM_IR_DERIVEDTYPES_H
1818 #define LLVM_IR_DERIVEDTYPES_H
1919
20 #include "llvm/ADT/ArrayRef.h"
21 #include "llvm/ADT/StringRef.h"
2022 #include "llvm/IR/Type.h"
23 #include "llvm/Support/Casting.h"
2124 #include "llvm/Support/Compiler.h"
22 #include "llvm/Support/DataTypes.h"
25 #include
26 #include
2327
2428 namespace llvm {
2529
2630 class Value;
2731 class APInt;
2832 class LLVMContext;
29 template class ArrayRef;
30 class StringRef;
3133
3234 /// Class to represent integer types. Note that this class is also used to
3335 /// represent the built-in integer types: Int1Ty, Int8Ty, Int16Ty, Int32Ty and
9799 /// Class to represent function types
98100 ///
99101 class FunctionType : public Type {
102 FunctionType(Type *Result, ArrayRef Params, bool IsVarArgs);
103
104 public:
100105 FunctionType(const FunctionType &) = delete;
101 const FunctionType &operator=(const FunctionType &) = delete;
102 FunctionType(Type *Result, ArrayRef Params, bool IsVarArgs);
103
104 public:
106 FunctionType &operator=(const FunctionType &) = delete;
107
105108 /// This static method is the primary way of constructing a FunctionType.
106109 static FunctionType *get(Type *Result,
107110 ArrayRef Params, bool isVarArg);
193196 /// generator for a target expects).
194197 ///
195198 class StructType : public CompositeType {
196 StructType(const StructType &) = delete;
197 const StructType &operator=(const StructType &) = delete;
198199 StructType(LLVMContext &C)
199200 : CompositeType(C, StructTyID), SymbolTableEntry(nullptr) {}
201
200202 enum {
201203 /// This is the contents of the SubClassData field.
202204 SCDB_HasBody = 1,
212214 void *SymbolTableEntry;
213215
214216 public:
217 StructType(const StructType &) = delete;
218 StructType &operator=(const StructType &) = delete;
219
215220 /// This creates an identified struct.
216221 static StructType *create(LLVMContext &Context, StringRef Name);
217222 static StructType *create(LLVMContext &Context);
313318 class SequentialType : public CompositeType {
314319 Type *ContainedType; ///< Storage for the single contained type.
315320 uint64_t NumElements;
316 SequentialType(const SequentialType &) = delete;
317 const SequentialType &operator=(const SequentialType &) = delete;
318321
319322 protected:
320323 SequentialType(TypeID TID, Type *ElType, uint64_t NumElements)
325328 }
326329
327330 public:
331 SequentialType(const SequentialType &) = delete;
332 SequentialType &operator=(const SequentialType &) = delete;
333
328334 uint64_t getNumElements() const { return NumElements; }
329335 Type *getElementType() const { return ContainedType; }
330336
336342
337343 /// Class to represent array types.
338344 class ArrayType : public SequentialType {
345 ArrayType(Type *ElType, uint64_t NumEl);
346
347 public:
339348 ArrayType(const ArrayType &) = delete;
340 const ArrayType &operator=(const ArrayType &) = delete;
341 ArrayType(Type *ElType, uint64_t NumEl);
342
343 public:
349 ArrayType &operator=(const ArrayType &) = delete;
350
344351 /// This static method is the primary way to construct an ArrayType
345352 static ArrayType *get(Type *ElementType, uint64_t NumElements);
346353
359366
360367 /// Class to represent vector types.
361368 class VectorType : public SequentialType {
369 VectorType(Type *ElType, unsigned NumEl);
370
371 public:
362372 VectorType(const VectorType &) = delete;
363 const VectorType &operator=(const VectorType &) = delete;
364 VectorType(Type *ElType, unsigned NumEl);
365
366 public:
373 VectorType &operator=(const VectorType &) = delete;
374
367375 /// This static method is the primary way to construct an VectorType.
368376 static VectorType *get(Type *ElementType, unsigned NumElements);
369377
432440
433441 /// Class to represent pointers.
434442 class PointerType : public Type {
443 explicit PointerType(Type *ElType, unsigned AddrSpace);
444
445 Type *PointeeTy;
446
447 public:
435448 PointerType(const PointerType &) = delete;
436 const PointerType &operator=(const PointerType &) = delete;
437 explicit PointerType(Type *ElType, unsigned AddrSpace);
438
439 Type *PointeeTy;
440
441 public:
449 PointerType &operator=(const PointerType &) = delete;
450
442451 /// This constructs a pointer to an object of the specified type in a numbered
443452 /// address space.
444453 static PointerType *get(Type *ElementType, unsigned AddressSpace);
470479 return cast(getScalarType())->getAddressSpace();
471480 }
472481
473 } // End llvm namespace
474
475 #endif
482 } // end namespace llvm
483
484 #endif // LLVM_IR_DERIVEDTYPES_H
1616
1717 #include "llvm/ADT/ilist_node.h"
1818 #include "llvm/IR/GlobalIndirectSymbol.h"
19 #include "llvm/IR/Value.h"
1920
2021 namespace llvm {
2122
2627 class GlobalAlias : public GlobalIndirectSymbol,
2728 public ilist_node {
2829 friend class SymbolTableListTraits;
29 void operator=(const GlobalAlias &) = delete;
30 GlobalAlias(const GlobalAlias &) = delete;
3130
3231 GlobalAlias(Type *Ty, unsigned AddressSpace, LinkageTypes Linkage,
3332 const Twine &Name, Constant *Aliasee, Module *Parent);
3433
3534 public:
35 GlobalAlias(const GlobalAlias &) = delete;
36 GlobalAlias &operator=(const GlobalAlias &) = delete;
37
3638 /// If a parent module is specified, the alias is automatically inserted into
3739 /// the end of the specified module's alias list.
3840 static GlobalAlias *create(Type *Ty, unsigned AddressSpace,
8688 }
8789 };
8890
89 } // End llvm namespace
91 } // end namespace llvm
9092
91 #endif
93 #endif // LLVM_IR_GLOBALALIAS_H
1919
2020 #include "llvm/ADT/ilist_node.h"
2121 #include "llvm/IR/GlobalIndirectSymbol.h"
22 #include "llvm/IR/Value.h"
2223
2324 namespace llvm {
2425
3132 class GlobalIFunc final : public GlobalIndirectSymbol,
3233 public ilist_node {
3334 friend class SymbolTableListTraits;
34 void operator=(const GlobalIFunc &) = delete;
35 GlobalIFunc(const GlobalIFunc &) = delete;
3635
3736 GlobalIFunc(Type *Ty, unsigned AddressSpace, LinkageTypes Linkage,
3837 const Twine &Name, Constant *Resolver, Module *Parent);
3938
4039 public:
40 GlobalIFunc(const GlobalIFunc &) = delete;
41 GlobalIFunc &operator=(const GlobalIFunc &) = delete;
42
4143 /// If a parent module is specified, the ifunc is automatically inserted into
4244 /// the end of the specified module's ifunc list.
4345 static GlobalIFunc *create(Type *Ty, unsigned AddressSpace,
6870 }
6971 };
7072
71 } // End llvm namespace
73 } // end namespace llvm
7274
73 #endif
75 #endif // LLVM_IR_GLOBALIFUNC_H
1515 #ifndef LLVM_IR_GLOBALINDIRECTSYMBOL_H
1616 #define LLVM_IR_GLOBALINDIRECTSYMBOL_H
1717
18 #include "llvm/IR/GlobalObject.h"
1819 #include "llvm/IR/GlobalValue.h"
1920 #include "llvm/IR/OperandTraits.h"
21 #include "llvm/IR/User.h"
22 #include "llvm/IR/Value.h"
23 #include "llvm/Support/Casting.h"
24 #include
2025
2126 namespace llvm {
2227
2328 class GlobalIndirectSymbol : public GlobalValue {
24 void operator=(const GlobalIndirectSymbol &) = delete;
25 GlobalIndirectSymbol(const GlobalIndirectSymbol &) = delete;
26
2729 protected:
2830 GlobalIndirectSymbol(Type *Ty, ValueTy VTy, unsigned AddressSpace,
2931 LinkageTypes Linkage, const Twine &Name, Constant *Symbol);
3032
3133 public:
34 GlobalIndirectSymbol(const GlobalIndirectSymbol &) = delete;
35 GlobalIndirectSymbol &operator=(const GlobalIndirectSymbol &) = delete;
36
3237 // allocate space for exactly one operand
3338 void *operator new(size_t s) {
3439 return User::operator new(s, 1);
7883
7984 DEFINE_TRANSPARENT_OPERAND_ACCESSORS(GlobalIndirectSymbol, Constant)
8085
81 } // End llvm namespace
86 } // end namespace llvm
8287
83 #endif
88 #endif // LLVM_IR_GLOBALINDIRECTSYMBOL_H
1414 #ifndef LLVM_IR_GLOBALOBJECT_H
1515 #define LLVM_IR_GLOBALOBJECT_H
1616
17 #include "llvm/IR/DerivedTypes.h"
17 #include "llvm/ADT/StringRef.h"
1818 #include "llvm/IR/GlobalValue.h"
19 #include "llvm/IR/Value.h"
20 #include
21 #include
1922
2023 namespace llvm {
24
2125 class Comdat;
2226 class MDNode;
2327 class Metadata;
24 class Module;
2528
2629 class GlobalObject : public GlobalValue {
27 GlobalObject(const GlobalObject &) = delete;
28
2930 protected:
3031 GlobalObject(Type *Ty, ValueTy VTy, Use *Ops, unsigned NumOps,
3132 LinkageTypes Linkage, const Twine &Name,
5253 static const unsigned GlobalObjectMask = (1 << GlobalObjectBits) - 1;
5354
5455 public:
56 GlobalObject(const GlobalObject &) = delete;
57
5558 unsigned getAlignment() const {
5659 unsigned Data = getGlobalValueSubClassData();
5760 unsigned AlignmentData = Data & AlignmentMask;
140143 }
141144 };
142145
143 } // End llvm namespace
146 } // end namespace llvm
144147
145 #endif
148 #endif // LLVM_IR_GLOBALOBJECT_H
1616
1717 #include "llvm/ADT/ArrayRef.h"
1818 #include "llvm/ADT/ilist_node.h"
19 #include "llvm/ADT/None.h"
20 #include "llvm/ADT/StringRef.h"
1921 #include "llvm/IR/DebugLoc.h"
2022 #include "llvm/IR/SymbolTableListTraits.h"
2123 #include "llvm/IR/User.h"
24 #include "llvm/IR/Value.h"
25 #include "llvm/Support/Casting.h"
26 #include
27 #include
28 #include
29 #include
2230
2331 namespace llvm {
2432
33 class BasicBlock;
2534 class FastMathFlags;
26 class LLVMContext;
2735 class MDNode;
28 class BasicBlock;
2936 struct AAMDNodes;
3037
3138 class Instruction : public User,
3239 public ilist_node_with_parent {
33 void operator=(const Instruction &) = delete;
34 Instruction(const Instruction &) = delete;
35
3640 BasicBlock *Parent;
3741 DebugLoc DbgLoc; // 'dbg' Metadata cache.
3842
4145 /// this instruction has metadata attached to it or not.
4246 HasMetadataBit = 1 << 15
4347 };
48
4449 public:
50 Instruction(const Instruction &) = delete;
51 Instruction &operator=(const Instruction &) = delete;
52
4553 // Out of line virtual method, so the vtable, etc has a home.
4654 ~Instruction() override;
4755
351359 SmallVectorImpl> &) const;
352360 /// Clear all hashtable-based metadata from this instruction.
353361 void clearMetadataHashEntries();
362
354363 public:
355364 //===--------------------------------------------------------------------===//
356365 // Predicates and helper methods.
357366 //===--------------------------------------------------------------------===//
358
359367
360368 /// Return true if the instruction is associative:
361369 ///
545553 #define LAST_OTHER_INST(N) OtherOpsEnd = N+1
546554 #include "llvm/IR/Instruction.def"
547555 };
556
548557 private:
558 friend class SymbolTableListTraits;
559
549560 // Shadow Value::setValueSubclassData with a private forwarding method so that
550561 // subclasses cannot accidentally use it.
551562 void setValueSubclassData(unsigned short D) {
552563 Value::setValueSubclassData(D);
553564 }
565
554566 unsigned short getSubclassDataFromValue() const {
555567 return Value::getSubclassDataFromValue();
556568 }
560572 (V ? HasMetadataBit : 0));
561573 }
562574
563 friend class SymbolTableListTraits;
564575 void setParent(BasicBlock *P);
576
565577 protected:
566578 // Instruction subclasses can stick up to 15 bits of stuff into the
567579 // SubclassData field of instruction with these members.
590602 template<>
591603 class PointerLikeTypeTraits {
592604 typedef Instruction* PT;
605
593606 public:
594607 static inline void *getAsVoidPointer(PT P) { return P; }
608
595609 static inline PT getFromVoidPointer(void *P) {
596610 return static_cast(P);
597611 }
612
598613 enum { NumLowBitsAvailable = 2 };
599614 };
600615
601 } // End llvm namespace
602
603 #endif
616 } // end namespace llvm
617
618 #endif // LLVM_IR_INSTRUCTION_H
1616 #define LLVM_IR_INSTRUCTIONS_H
1717
1818 #include "llvm/ADT/ArrayRef.h"
19 #include "llvm/ADT/iterator_range.h"
20 #include "llvm/ADT/None.h"
1921 #include "llvm/ADT/SmallVector.h"
2022 #include "llvm/ADT/STLExtras.h"
21 #include "llvm/ADT/iterator_range.h"
23 #include "llvm/ADT/StringRef.h"
24 #include "llvm/ADT/Twine.h"
2225 #include "llvm/IR/Attributes.h"
2326 #include "llvm/IR/CallingConv.h"
27 #include "llvm/IR/Constant.h"
2428 #include "llvm/IR/DerivedTypes.h"
2529 #include "llvm/IR/Function.h"
2630 #include "llvm/IR/InstrTypes.h"
31 #include "llvm/IR/OperandTraits.h"
32 #include "llvm/IR/Type.h"
33 #include "llvm/IR/Use.h"
34 #include "llvm/IR/User.h"
2735 #include "llvm/Support/AtomicOrdering.h"
36 #include "llvm/Support/Casting.h"
2837 #include "llvm/Support/ErrorHandling.h"
29 #include <iterator>
38 #include <cassert>
39 #include
40 #include
3041
3142 namespace llvm {
3243
3344 class APInt;
3445 class ConstantInt;
35 class ConstantRange;
3646 class DataLayout;
3747 class LLVMContext;
3848
5262 protected:
5363 // Note: Instruction needs to be a friend here to call cloneImpl.
5464 friend class Instruction;
65
5566 AllocaInst *cloneImpl() const;
5667
5768 public:
155166 protected:
156167 // Note: Instruction needs to be a friend here to call cloneImpl.
157168 friend class Instruction;
169
158170 LoadInst *cloneImpl() const;
159171
160172 public:
189201 unsigned Align, AtomicOrdering Order,
190202 SynchronizationScope SynchScope,
191203 BasicBlock *InsertAtEnd);
192
193204 LoadInst(Value *Ptr, const char *NameStr, Instruction *InsertBefore);
194205 LoadInst(Value *Ptr, const char *NameStr, BasicBlock *InsertAtEnd);
195206 LoadInst(Type *Ty, Value *Ptr, const char *NameStr = nullptr,
286297
287298 /// An instruction for storing to memory.
288299 class StoreInst : public Instruction {
289 void *operator new(size_t, unsigned) = delete;
290300 void AssertOK();
291301
292302 protected:
293303 // Note: Instruction needs to be a friend here to call cloneImpl.
294304 friend class Instruction;
305
295306 StoreInst *cloneImpl() const;
296307
297308 public:
298 // allocate space for exactly two operands
299 void *operator new(size_t s) {
300 return User::operator new(s, 2);
301 }
302309 StoreInst(Value *Val, Value *Ptr, Instruction *InsertBefore);
303310 StoreInst(Value *Val, Value *Ptr, BasicBlock *InsertAtEnd);
304311 StoreInst(Value *Val, Value *Ptr, bool isVolatile = false,
317324 SynchronizationScope SynchScope,
318325 BasicBlock *InsertAtEnd);
319326
327 // allocate space for exactly two operands
328 void *operator new(size_t s) {
329 return User::operator new(s, 2);
330 }
331
332 void *operator new(size_t, unsigned) = delete;
333
320334 /// Return true if this is a store to a volatile memory location.
321335 bool isVolatile() const { return getSubclassDataFromInstruction() & 1; }
322336
413427
414428 /// An instruction for ordering other memory operations.
415429 class FenceInst : public Instruction {
416 void *operator new(size_t, unsigned) = delete;
417430 void Init(AtomicOrdering Ordering, SynchronizationScope SynchScope);
418431
419432 protected:
420433 // Note: Instruction needs to be a friend here to call cloneImpl.
421434 friend class Instruction;
435
422436 FenceInst *cloneImpl() const;
423437
424438 public:
425 // allocate space for exactly zero operands
426 void *operator new(size_t s) {
427 return User::operator new(s, 0);
428 }
429
430439 // Ordering may only be Acquire, Release, AcquireRelease, or
431440 // SequentiallyConsistent.
432441 FenceInst(LLVMContext &C, AtomicOrdering Ordering,
436445 SynchronizationScope SynchScope,
437446 BasicBlock *InsertAtEnd);
438447
448 // allocate space for exactly zero operands
449 void *operator new(size_t s) {
450 return User::operator new(s, 0);
451 }
452
453 void *operator new(size_t, unsigned) = delete;
454
439455 /// Returns the ordering effect of this fence.
440456 AtomicOrdering getOrdering() const {
441457 return AtomicOrdering(getSubclassDataFromInstruction() >> 1);
485501 /// there. Returns the value that was loaded.
486502 ///
487503 class AtomicCmpXchgInst : public Instruction {
488 void *operator new(size_t, unsigned) = delete;
489504 void Init(Value *Ptr, Value *Cmp, Value *NewVal,
490505 AtomicOrdering SuccessOrdering, AtomicOrdering FailureOrdering,
491506 SynchronizationScope SynchScope);
493508 protected:
494509 // Note: Instruction needs to be a friend here to call cloneImpl.
495510 friend class Instruction;
511
496512 AtomicCmpXchgInst *cloneImpl() const;
497513
498514 public:
499 // allocate space for exactly three operands
500 void *operator new(size_t s) {
501 return User::operator new(s, 3);
502 }
503515 AtomicCmpXchgInst(Value *Ptr, Value *Cmp, Value *NewVal,
504516 AtomicOrdering SuccessOrdering,
505517 AtomicOrdering FailureOrdering,
510522 AtomicOrdering FailureOrdering,
511523 SynchronizationScope SynchScope,
512524 BasicBlock *InsertAtEnd);
525
526 // allocate space for exactly three operands
527 void *operator new(size_t s) {
528 return User::operator new(s, 3);
529 }
530
531 void *operator new(size_t, unsigned) = delete;
513532
514533 /// Return true if this is a cmpxchg from a volatile memory
515534 /// location.
647666 /// the old value.
648667 ///
649668 class AtomicRMWInst : public Instruction {
650 void *operator new(size_t, unsigned) = delete;
651
652669 protected:
653670 // Note: Instruction needs to be a friend here to call cloneImpl.
654671 friend class Instruction;
672
655673 AtomicRMWInst *cloneImpl() const;
656674
657675 public:
688706 BAD_BINOP
689707 };
690708
691 // allocate space for exactly two operands
692 void *operator new(size_t s) {
693 return User::operator new(s, 2);
694 }
695709 AtomicRMWInst(BinOp Operation, Value *Ptr, Value *Val,
696710 AtomicOrdering Ordering, SynchronizationScope SynchScope,
697711 Instruction *InsertBefore = nullptr);
699713 AtomicOrdering Ordering, SynchronizationScope SynchScope,
700714 BasicBlock *InsertAtEnd);
701715
716 // allocate space for exactly two operands
717 void *operator new(size_t s) {
718 return User::operator new(s, 2);
719 }
720
721 void *operator new(size_t, unsigned) = delete;
722
702723 BinOp getOperation() const {
703724 return static_cast(getSubclassDataFromInstruction() >> 5);
704725 }
775796 private:
776797 void Init(BinOp Operation, Value *Ptr, Value *Val,
777798 AtomicOrdering Ordering, SynchronizationScope SynchScope);
799
778800 // Shadow Instruction::setInstructionSubclassData with a private forwarding
779801 // method so that subclasses cannot accidentally use it.
780802 void setInstructionSubclassData(unsigned short D) {
827849 protected:
828850 // Note: Instruction needs to be a friend here to call cloneImpl.
829851 friend class Instruction;
852
830853 GetElementPtrInst *cloneImpl() const;
831854
832855 public:
845868 return new (Values) GetElementPtrInst(PointeeType, Ptr, IdxList, Values,
846869 NameStr, InsertBefore);
847870 }
871
848872 static GetElementPtrInst *Create(Type *PointeeType, Value *Ptr,
849873 ArrayRef IdxList,
850874 const Twine &NameStr,
869893 Instruction *InsertBefore = nullptr){
870894 return CreateInBounds(nullptr, Ptr, IdxList, NameStr, InsertBefore);
871895 }
896
872897 static GetElementPtrInst *
873898 CreateInBounds(Type *PointeeType, Value *Ptr, ArrayRef IdxList,
874899 const Twine &NameStr = "",
878903 GEP->setIsInBounds(true);
879904 return GEP;
880905 }
906
881907 static GetElementPtrInst *CreateInBounds(Value *Ptr,
882908 ArrayRef IdxList,
883909 const Twine &NameStr,
884910 BasicBlock *InsertAtEnd) {
885911 return CreateInBounds(nullptr, Ptr, IdxList, NameStr, InsertAtEnd);
886912 }
913
887914 static GetElementPtrInst *CreateInBounds(Type *PointeeType, Value *Ptr,
888915 ArrayRef IdxList,
889916 const Twine &NameStr,
10381065 cast(getType()->getScalarType())->getElementType());
10391066 init(Ptr, IdxList, NameStr);
10401067 }
1068
10411069 GetElementPtrInst::GetElementPtrInst(Type *PointeeType, Value *Ptr,
10421070 ArrayRef IdxList, unsigned Values,
10431071 const Twine &NameStr,
10801108 protected:
10811109 // Note: Instruction needs to be a friend here to call cloneImpl.
10821110 friend class Instruction;
1111
10831112 /// Clone an identical ICmpInst
10841113 ICmpInst *cloneImpl() const;
10851114
12101239 protected:
12111240 // Note: Instruction needs to be a friend here to call cloneImpl.
12121241 friend class Instruction;
1242
12131243 /// Clone an identical FCmpInst
12141244 FCmpInst *cloneImpl() const;
12151245
13211351 ///
13221352 class CallInst : public Instruction,
13231353 public OperandBundleUser {
1354 friend class OperandBundleUser;
1355
13241356 AttributeSet AttributeList; ///< parameter attributes for call
13251357 FunctionType *FTy;
1358
13261359 CallInst(const CallInst &CI);
1327 void init(Value *Func, ArrayRef Args,
1328 ArrayRef Bundles, const Twine &NameStr) {
1329 init(cast(
1330 cast(Func->getType())->getElementType()),
1331 Func, Args, Bundles, NameStr);
1332 }
1333 void init(FunctionType *FTy, Value *Func, ArrayRef Args,
1334 ArrayRef Bundles, const Twine &NameStr);
1335 void init(Value *Func, const Twine &NameStr);
13361360
13371361 /// Construct a CallInst given a range of arguments.
13381362 /// Construct a CallInst from a range of arguments
13391363 inline CallInst(FunctionType *Ty, Value *Func, ArrayRef Args,
13401364 ArrayRef Bundles, const Twine &NameStr,
13411365 Instruction *InsertBefore);
1366
13421367 inline CallInst(Value *Func, ArrayRef Args,
13431368 ArrayRef Bundles, const Twine &NameStr,
13441369 Instruction *InsertBefore)
13581383
13591384 explicit CallInst(Value *F, const Twine &NameStr,
13601385 Instruction *InsertBefore);
1386
13611387 CallInst(Value *F, const Twine &NameStr, BasicBlock *InsertAtEnd);
13621388
1363 friend class OperandBundleUser;
1389 void init(Value *Func, ArrayRef Args,
1390 ArrayRef Bundles, const Twine &NameStr) {
1391 init(cast(
1392 cast(Func->getType())->getElementType()),
1393 Func, Args, Bundles, NameStr);
1394 }
1395 void init(FunctionType *FTy, Value *Func, ArrayRef Args,
1396 ArrayRef Bundles, const Twine &NameStr);
1397 void init(Value *Func, const Twine &NameStr);
1398
13641399 bool hasDescriptor() const { return HasDescriptor; }
13651400
13661401 protected:
13671402 // Note: Instruction needs to be a friend here to call cloneImpl.
13681403 friend class Instruction;
1404
13691405 CallInst *cloneImpl() const;
13701406
13711407 public:
1408 ~CallInst() override;
1409
13721410 static CallInst *Create(Value *Func, ArrayRef Args,
13731411 ArrayRef Bundles = None,
13741412 const Twine &NameStr = "",
13771415 cast(Func->getType())->getElementType()),
13781416 Func, Args, Bundles, NameStr, InsertBefore);
13791417 }
1418
13801419 static CallInst *Create(Value *Func, ArrayRef Args,
13811420 const Twine &NameStr,
13821421 Instruction *InsertBefore = nullptr) {
13841423 cast(Func->getType())->getElementType()),
13851424 Func, Args, None, NameStr, InsertBefore);
13861425 }
1426
13871427 static CallInst *Create(FunctionType *Ty, Value *Func, ArrayRef Args,
13881428 const Twine &NameStr,
13891429 Instruction *InsertBefore = nullptr) {
13901430 return new (unsigned(Args.size() + 1))
13911431 CallInst(Ty, Func, Args, None, NameStr, InsertBefore);
13921432 }
1433
13931434 static CallInst *Create(FunctionType *Ty, Value *Func, ArrayRef Args,
13941435 ArrayRef Bundles = None,
13951436 const Twine &NameStr = "",
14011442 return new (TotalOps, DescriptorBytes)
14021443 CallInst(Ty, Func, Args, Bundles, NameStr, InsertBefore);
14031444 }
1445
14041446 static CallInst *Create(Value *Func, ArrayRef Args,
14051447 ArrayRef Bundles,
14061448 const Twine &NameStr, BasicBlock *InsertAtEnd) {
14111453 return new (TotalOps, DescriptorBytes)
14121454 CallInst(Func, Args, Bundles, NameStr, InsertAtEnd);
14131455 }
1456
14141457 static CallInst *Create(Value *Func, ArrayRef Args,
14151458 const Twine &NameStr, BasicBlock *InsertAtEnd) {
14161459 return new (unsigned(Args.size() + 1))
14171460 CallInst(Func, Args, None, NameStr, InsertAtEnd);
14181461 }
1462
14191463 static CallInst *Create(Value *F, const Twine &NameStr = "",
14201464 Instruction *InsertBefore = nullptr) {
14211465 return new(1) CallInst(F, NameStr, InsertBefore);
14221466 }
1467
14231468 static CallInst *Create(Value *F, const Twine &NameStr,
14241469 BasicBlock *InsertAtEnd) {
14251470 return new(1) CallInst(F, NameStr, InsertAtEnd);
14741519 ArrayRef Bundles,
14751520 BasicBlock *InsertAtEnd);
14761521
1477 ~CallInst() override;
1478
14791522 FunctionType *getFunctionType() const { return FTy; }
14801523
14811524 void mutateFunctionType(FunctionType *FTy) {
14891532 TailCallKind getTailCallKind() const {
14901533 return TailCallKind(getSubclassDataFromInstruction() & 3);
14911534 }
1535
14921536 bool isTailCall() const {
14931537 unsigned Kind = getSubclassDataFromInstruction() & 3;
14941538 return Kind == TCK_Tail || Kind == TCK_MustTail;
14951539 }
1540
14961541 bool isMustTailCall() const {
14971542 return (getSubclassDataFromInstruction() & 3) == TCK_MustTail;
14981543 }
1544
14991545 bool isNoTailCall() const {
15001546 return (getSubclassDataFromInstruction() & 3) == TCK_NoTail;
15011547 }
1548
15021549 void setTailCall(bool isTC = true) {
15031550 setInstructionSubclassData((getSubclassDataFromInstruction() & ~3) |
15041551 unsigned(isTC ? TCK_Tail : TCK_None));
15051552 }
1553
15061554 void setTailCallKind(TailCallKind TCK) {
15071555 setInstructionSubclassData((getSubclassDataFromInstruction() & ~3) |
15081556 unsigned(TCK));
18681916 /// This class represents the LLVM 'select' instruction.
18691917 ///
18701918 class SelectInst : public Instruction {
1871 void init(Value *C, Value *S1, Value *S2) {
1872 assert(!areInvalidOperands(C, S1, S2) && "Invalid operands for select");
1873 Op<0>() = C;
1874 Op<1>() = S1;
1875 Op<2>() = S2;
1876 }
1877
18781919 SelectInst(Value *C, Value *S1, Value *S2, const Twine &NameStr,
18791920 Instruction *InsertBefore)
18801921 : Instruction(S1->getType(), Instruction::Select,
18821923 init(C, S1, S2);
18831924 setName(NameStr);
18841925 }
1926
18851927 SelectInst(Value *C, Value *S1, Value *S2, const Twine &NameStr,
18861928 BasicBlock *InsertAtEnd)
18871929 : Instruction(S1->getType(), Instruction::Select,
18901932 setName(NameStr);
18911933 }
18921934
1935 void init(Value *C, Value *S1, Value *S2) {
1936 assert(!areInvalidOperands(C, S1, S2) && "Invalid operands for select");
1937 Op<0>() = C;
1938 Op<1>() = S1;
1939 Op<2>() = S2;
1940 }
1941
18931942 protected:
18941943 // Note: Instruction needs to be a friend here to call cloneImpl.
18951944 friend class Instruction;
1945
18961946 SelectInst *cloneImpl() const;
18971947
18981948 public:
19602010 protected:
19612011 // Note: Instruction needs to be a friend here to call cloneImpl.
19622012 friend class Instruction;
2013
19632014 VAArgInst *cloneImpl() const;
19642015
19652016 public:
19682019 : UnaryInstruction(Ty, VAArg, List, InsertBefore) {
19692020 setName(NameStr);
19702021 }
2022
19712023 VAArgInst(Value *List, Type *Ty, const Twine &NameStr,
19722024 BasicBlock *InsertAtEnd)
19732025 : UnaryInstruction(Ty, VAArg, List, InsertAtEnd) {
20032055 protected:
20042056 // Note: Instruction needs to be a friend here to call cloneImpl.
20052057 friend class Instruction;
2058
20062059 ExtractElementInst *cloneImpl() const;
20072060
20082061 public:
20112064 Instruction *InsertBefore = nullptr) {
20122065 return new(2) ExtractElementInst(Vec, Idx, NameStr, InsertBefore);
20132066 }
2067
20142068 static ExtractElementInst *Create(Value *Vec, Value *Idx,
20152069 const Twine &NameStr,
20162070 BasicBlock *InsertAtEnd) {
20662120 protected:
20672121 // Note: Instruction needs to be a friend here to call cloneImpl.
20682122 friend class Instruction;
2123
20692124 InsertElementInst *cloneImpl() const;
20702125
20712126 public:
20742129 Instruction *InsertBefore = nullptr) {
20752130 return new(3) InsertElementInst(Vec, NewElt, Idx, NameStr, InsertBefore);
20762131 }
2132
20772133 static InsertElementInst *Create(Value *Vec, Value *NewElt, Value *Idx,
20782134 const Twine &NameStr,
20792135 BasicBlock *InsertAtEnd) {
21212177 protected:
21222178 // Note: Instruction needs to be a friend here to call cloneImpl.
21232179 friend class Instruction;
2180
21242181 ShuffleVectorInst *cloneImpl() const;
21252182
21262183 public:
2127 // allocate space for exactly three operands
2128 void *operator new(size_t s) {
2129 return User::operator new(s, 3);
2130 }
21312184 ShuffleVectorInst(Value *V1, Value *V2, Value *Mask,
21322185 const Twine &NameStr = "",
21332186 Instruction *InsertBefor = nullptr);
21342187 ShuffleVectorInst(Value *V1, Value *V2, Value *Mask,
21352188 const Twine &NameStr, BasicBlock *InsertAtEnd);
21362189
2190 // allocate space for exactly three operands
2191 void *operator new(size_t s) {
2192 return User::operator new(s, 3);
2193 }
2194
21372195 /// Return true if a shufflevector instruction can be
21382196 /// formed with the specified operands.
21392197 static bool isValidOperands(const Value *V1, const Value *V2,
22052263 SmallVector Indices;
22062264
22072265 ExtractValueInst(const ExtractValueInst &EVI);
2208 void init(ArrayRef Idxs, const Twine &NameStr);
2209
22102266 /// Constructors - Create a extractvalue instruction with a base aggregate
22112267 /// value and a list of indices. The first ctor can optionally insert before
22122268 /// an existing instruction, the second appends the new instruction to the
22222278 // allocate space for exactly one operand
22232279 void *operator new(size_t s) { return User::operator new(s, 1); }
22242280
2281 void init(ArrayRef Idxs, const Twine &NameStr);
2282
22252283 protected:
22262284 // Note: Instruction needs to be a friend here to call cloneImpl.
22272285 friend class Instruction;
2286
22282287 ExtractValueInst *cloneImpl() const;
22292288
22302289 public:
22352294 return new
22362295 ExtractValueInst(Agg, Idxs, NameStr, InsertBefore);
22372296 }
2297
22382298 static ExtractValueInst *Create(Value *Agg,
22392299 ArrayRef Idxs,
22402300 const Twine &NameStr,
22942354 ExtractValue, Agg, InsertBefore) {
22952355 init(Idxs, NameStr);
22962356 }
2357
22972358 ExtractValueInst::ExtractValueInst(Value *Agg,
22982359 ArrayRef Idxs,
22992360 const Twine &NameStr,
23132374 class InsertValueInst : public Instruction {
23142375 SmallVector Indices;
23152376
2316 void *operator new(size_t, unsigned) = delete;
23172377 InsertValueInst(const InsertValueInst &IVI);
2318 void init(Value *Agg, Value *Val, ArrayRef Idxs,
2319 const Twine &NameStr);
23202378
23212379 /// Constructors - Create a insertvalue instruction with a base aggregate
23222380 /// value, a value to insert, and a list of indices. The first ctor can
23382396 InsertValueInst(Value *Agg, Value *Val, unsigned Idx, const Twine &NameStr,
23392397 BasicBlock *InsertAtEnd);
23402398
2399 void init(Value *Agg, Value *Val, ArrayRef Idxs,
2400 const Twine &NameStr);
2401
23412402 protected:
23422403 // Note: Instruction needs to be a friend here to call cloneImpl.
23432404 friend class Instruction;
2405
23442406 InsertValueInst *cloneImpl() const;
23452407
23462408 public:
23482410 void *operator new(size_t s) {
23492411 return User::operator new(s, 2);
23502412 }
2413
2414 void *operator new(size_t, unsigned) = delete;
23512415
23522416 static InsertValueInst *Create(Value *Agg, Value *Val,
23532417 ArrayRef Idxs,
23552419 Instruction *InsertBefore = nullptr) {
23562420 return new InsertValueInst(Agg, Val, Idxs, NameStr, InsertBefore);
23572421 }
2422
23582423 static InsertValueInst *Create(Value *Agg, Value *Val,
23592424 ArrayRef Idxs,
23602425 const Twine &NameStr,
24282493 2, InsertBefore) {
24292494 init(Agg, Val, Idxs, NameStr);
24302495 }
2496
24312497 InsertValueInst::InsertValueInst(Value *Agg,
24322498 Value *Val,
24332499 ArrayRef Idxs,
24502516 // scientist's overactive imagination.
24512517 //
24522518 class PHINode : public Instruction {
2453 void anchor() override;
2454
2455 void *operator new(size_t, unsigned) = delete;
24562519 /// The number of operands actually allocated. NumOperands is
24572520 /// the number actually in use.
24582521 unsigned ReservedSpace;
2522
24592523 PHINode(const PHINode &PN);
24602524 // allocate space for exactly zero operands
2461 void *operator new(size_t s) {
2462 return User::operator new(s);
2463 }
2525
24642526 explicit PHINode(Type *Ty, unsigned NumReservedValues,
24652527 const Twine &NameStr = "",
24662528 Instruction *InsertBefore = nullptr)
24782540 allocHungoffUses(ReservedSpace);
24792541 }
24802542
2543 void *operator new(size_t s) {
2544 return User::operator new(s);
2545 }
2546
2547 void anchor() override;
2548
24812549 protected:
2550 // Note: Instruction needs to be a friend here to call cloneImpl.
2551 friend class Instruction;
2552
2553 PHINode *cloneImpl() const;
2554
24822555 // allocHungoffUses - this is more complicated than the generic
24832556 // User::allocHungoffUses, because we have to allocate Uses for the incoming
24842557 // values and pointers to the incoming blocks, all in one allocation.
24862559 User::allocHungoffUses(N, /* IsPhi */ true);
24872560 }
24882561
2489 // Note: Instruction needs to be a friend here to call cloneImpl.
2490 friend class Instruction;
2491 PHINode *cloneImpl() const;
2492
24932562 public:
2563 void *operator new(size_t, unsigned) = delete;
2564
24942565 /// Constructors - NumReservedValues is a hint for the number of incoming
24952566 /// edges that this phi node will have (use 0 if you really have no idea).
24962567 static PHINode *Create(Type *Ty, unsigned NumReservedValues,
24982569 Instruction *InsertBefore = nullptr) {
24992570 return new PHINode(Ty, NumReservedValues, NameStr, InsertBefore);
25002571 }
2572
25012573 static PHINode *Create(Type *Ty, unsigned NumReservedValues,
25022574 const Twine &NameStr, BasicBlock *InsertAtEnd) {
25032575 return new PHINode(Ty, NumReservedValues, NameStr, InsertAtEnd);
26782750 /// The number of operands actually allocated. NumOperands is
26792751 /// the number actually in use.
26802752 unsigned ReservedSpace;
2753
26812754 LandingPadInst(const LandingPadInst &LP);
26822755
26832756 public:
26842757 enum ClauseType { Catch, Filter };
26852758
26862759 private:
2687 void *operator new(size_t, unsigned) = delete;
2688 // Allocate space for exactly zero operands.
2689 void *operator new(size_t s) {
2690 return User::operator new(s);
2691 }
2692 void growOperands(unsigned Size);
2693 void init(unsigned NumReservedValues, const Twine &NameStr);
2694
26952760 explicit LandingPadInst(Type *RetTy, unsigned NumReservedValues,
26962761 const Twine &NameStr, Instruction *InsertBefore);
26972762 explicit LandingPadInst(Type *RetTy, unsigned NumReservedValues,
26982763 const Twine &NameStr, BasicBlock *InsertAtEnd);
26992764
2765 // Allocate space for exactly zero operands.
2766 void *operator new(size_t s) {
2767 return User::operator new(s);
2768 }
2769
2770 void growOperands(unsigned Size);
2771 void init(unsigned NumReservedValues, const Twine &NameStr);
2772
27002773 protected:
27012774 // Note: Instruction needs to be a friend here to call cloneImpl.
27022775 friend class Instruction;
2776
27032777 LandingPadInst *cloneImpl() const;
27042778
27052779 public:
2780 void *operator new(size_t, unsigned) = delete;
2781
27062782 /// Constructors - NumReservedClauses is a hint for the number of incoming
27072783 /// clauses that this landingpad will have (use 0 if you really have no idea).
27082784 static LandingPadInst *Create(Type *RetTy, unsigned NumReservedClauses,
27972873 protected:
27982874 // Note: Instruction needs to be a friend here to call cloneImpl.
27992875 friend class Instruction;
2876
28002877 ReturnInst *cloneImpl() const;
28012878
28022879 public:
2880 ~ReturnInst() override;
2881
28032882 static ReturnInst* Create(LLVMContext &C, Value *retVal = nullptr,
28042883 Instruction *InsertBefore = nullptr) {
28052884 return new(!!retVal) ReturnInst(C, retVal, InsertBefore);
28062885 }
2886
28072887 static ReturnInst* Create(LLVMContext &C, Value *retVal,
28082888 BasicBlock *InsertAtEnd) {
28092889 return new(!!retVal) ReturnInst(C, retVal, InsertAtEnd);
28102890 }
2891
28112892 static ReturnInst* Create(LLVMContext &C, BasicBlock *InsertAtEnd) {
28122893 return new(0) ReturnInst(C, InsertAtEnd);
28132894 }
2814 ~ReturnInst() override;
28152895
28162896 /// Provide fast operand accessors
28172897 DECLARE_TRANSPARENT_OPERAND_ACCESSORS(Value);
28562936 /// they don't have to check for cond/uncond branchness. These are mostly
28572937 /// accessed relative from op_end().
28582938 BranchInst(const BranchInst &BI);
2859 void AssertOK();
28602939 // BranchInst constructors (where {B, T, F} are blocks, and C is a condition):
28612940 // BranchInst(BB *B) - 'br B'
28622941 // BranchInst(BB* T, BB *F, Value *C) - 'br C, T, F'
28712950 BranchInst(BasicBlock *IfTrue, BasicBlock *IfFalse, Value *Cond,
28722951 BasicBlock *InsertAtEnd);
28732952
2953 void AssertOK();
2954
28742955 protected:
28752956 // Note: Instruction needs to be a friend here to call cloneImpl.
28762957 friend class Instruction;
2958
28772959 BranchInst *cloneImpl() const;
28782960
28792961 public:
28812963 Instruction *InsertBefore = nullptr) {
28822964 return new(1) BranchInst(IfTrue, InsertBefore);
28832965 }
2966
28842967 static BranchInst *Create(BasicBlock *IfTrue, BasicBlock *IfFalse,
28852968 Value *Cond, Instruction *InsertBefore = nullptr) {
28862969 return new(3) BranchInst(IfTrue, IfFalse, Cond, InsertBefore);
28872970 }
2971
28882972 static BranchInst *Create(BasicBlock *IfTrue, BasicBlock *InsertAtEnd) {
28892973 return new(1) BranchInst(IfTrue, InsertAtEnd);
28902974 }
2975
28912976 static BranchInst *Create(BasicBlock *IfTrue, BasicBlock *IfFalse,
28922977 Value *Cond, BasicBlock *InsertAtEnd) {
28932978 return new(3) BranchInst(IfTrue, IfFalse, Cond, InsertAtEnd);
29563041 /// Multiway switch
29573042 ///
29583043 class SwitchInst : public TerminatorInst {
2959 void *operator new(size_t, unsigned) = delete;
29603044 unsigned ReservedSpace;
3045
29613046 // Operand[0] = Value to switch on
29623047 // Operand[1] = Default basic block destination
29633048 // Operand[2n ] = Value to match
29643049 // Operand[2n+1] = BasicBlock to go to on match
29653050 SwitchInst(const SwitchInst &SI);
2966 void init(Value *Value, BasicBlock *Default, unsigned NumReserved);
2967 void growOperands();
2968 // allocate space for exactly zero operands
2969 void *operator new(size_t s) {
2970 return User::operator new(s);
2971 }
3051
29723052 /// Create a new switch instruction, specifying a value to switch on and a
29733053 /// default destination. The number of additional cases can be specified here
29743054 /// to make memory allocation more efficient. This constructor can also
29833063 SwitchInst(Value *Value, BasicBlock *Default, unsigned NumCases,
29843064 BasicBlock *InsertAtEnd);
29853065
3066 // allocate space for exactly zero operands
3067 void *operator new(size_t s) {
3068 return User::operator new(s);
3069 }
3070
3071 void init(Value *Value, BasicBlock *Default, unsigned NumReserved);
3072 void growOperands();
3073
29863074 protected:
29873075 // Note: Instruction needs to be a friend here to call cloneImpl.
29883076 friend class Instruction;
3077
29893078 SwitchInst *cloneImpl() const;
29903079
29913080 public:
3081 void *operator new(size_t, unsigned) = delete;
3082
29923083 // -2
29933084 static const unsigned DefaultPseudoIndex = static_cast(~0L-1);
29943085
30853176 ConstCaseIt;
30863177
30873178 class CaseIt : public CaseIteratorT {
3088
30893179 typedef CaseIteratorT ParentTy;
30903180
30913181 public:
31093199 Instruction *InsertBefore = nullptr) {
31103200 return new SwitchInst(Value, Default, NumCases, InsertBefore);
31113201 }
3202
31123203 static SwitchInst *Create(Value *Value, BasicBlock *Default,
31133204 unsigned NumCases, BasicBlock *InsertAtEnd) {
31143205 return new SwitchInst(Value, Default, NumCases, InsertAtEnd);
31403231 CaseIt case_begin() {
31413232 return CaseIt(this, 0);
31423233 }
3234
31433235 /// Returns a read-only iterator that points to the first case in the
31443236 /// SwitchInst.
31453237 ConstCaseIt case_begin() const {
31513243 CaseIt case_end() {
31523244 return CaseIt(this, getNumCases());
31533245 }
3246
31543247 /// Returns a read-only iterator that points one past the last in the
31553248 /// SwitchInst.
31563249 ConstCaseIt case_end() const {
32633356 /// Indirect Branch Instruction.
32643357 ///
32653358 class IndirectBrInst : public TerminatorInst {
3266 void *operator new(size_t, unsigned) = delete;
32673359 unsigned ReservedSpace;
3360
32683361 // Operand[0] = Address to jump to
32693362 // Operand[n+1] = n-th destination
32703363 IndirectBrInst(const IndirectBrInst &IBI);
3271 void init(Value *Address, unsigned NumDests);
3272 void growOperands();
3273 // allocate space for exactly zero operands
3274 void *operator new(size_t s) {
3275 return User::operator new(s);
3276 }
3364
32773365 /// Create a new indirectbr instruction, specifying an
32783366 /// Address to jump to. The number of expected destinations can be specified
32793367 /// here to make memory allocation more efficient. This constructor can also
32863374 /// autoinserts at the end of the specified BasicBlock.
32873375 IndirectBrInst(Value *Address, unsigned NumDests, BasicBlock *InsertAtEnd);
32883376
3377 // allocate space for exactly zero operands
3378 void *operator new(size_t s) {
3379 return User::operator new(s);
3380 }
3381
3382 void init(Value *Address, unsigned NumDests);
3383 void growOperands();
3384
32893385 protected:
32903386 // Note: Instruction needs to be a friend here to call cloneImpl.
32913387 friend class Instruction;
3388
32923389 IndirectBrInst *cloneImpl() const;
32933390
32943391 public:
3392 void *operator new(size_t, unsigned) = delete;
3393
32953394 static IndirectBrInst *Create(Value *Address, unsigned NumDests,
32963395 Instruction *InsertBefore = nullptr) {
32973396 return new IndirectBrInst(Address, NumDests, InsertBefore);
32983397 }
3398
32993399 static IndirectBrInst *Create(Value *Address, unsigned NumDests,
33003400 BasicBlock *InsertAtEnd) {
33013401 return new IndirectBrInst(Address, NumDests, InsertAtEnd);
33623462 ///
33633463 class InvokeInst : public TerminatorInst,
33643464 public OperandBundleUser {
3465 friend class OperandBundleUser;
3466
33653467 AttributeSet AttributeList;
33663468 FunctionType *FTy;
3469
33673470 InvokeInst(const InvokeInst &BI);
3368 void init(Value *Func, BasicBlock *IfNormal, BasicBlock *IfException,
3369 ArrayRef Args, ArrayRef Bundles,
3370 const Twine &NameStr) {
3371 init(cast(
3372 cast(Func->getType())->getElementType()),
3373 Func, IfNormal, IfException, Args, Bundles, NameStr);
3374 }
3375 void init(FunctionType *FTy, Value *Func, BasicBlock *IfNormal,
3376 BasicBlock *IfException, ArrayRef Args,
3377 ArrayRef Bundles, const Twine &NameStr);
33783471
33793472 /// Construct an InvokeInst given a range of arguments.
33803473 ///
34003493 unsigned Values, const Twine &NameStr,
34013494 BasicBlock *InsertAtEnd);
34023495
3403 friend class OperandBundleUser;
34043496 bool hasDescriptor() const { return HasDescriptor; }
3497
3498 void init(Value *Func, BasicBlock *IfNormal, BasicBlock *IfException,
3499 ArrayRef Args, ArrayRef Bundles,
3500 const Twine &NameStr) {
3501 init(cast(
3502 cast(Func->getType())->getElementType()),
3503 Func, IfNormal, IfException, Args, Bundles, NameStr);
3504 }
3505
3506 void init(FunctionType *FTy, Value *Func, BasicBlock *IfNormal,
3507 BasicBlock *IfException, ArrayRef Args,
3508 ArrayRef Bundles, const Twine &NameStr);
34053509
34063510 protected:
34073511 // Note: Instruction needs to be a friend here to call cloneImpl.
34083512 friend class Instruction;
3513
34093514 InvokeInst *cloneImpl() const;
34103515
34113516 public:
34183523 Func, IfNormal, IfException, Args, None, NameStr,
34193524 InsertBefore);
34203525 }
3526
34213527 static InvokeInst *Create(Value *Func, BasicBlock *IfNormal,
34223528 BasicBlock *IfException, ArrayRef Args,
34233529 ArrayRef Bundles = None,
34283534 Func, IfNormal, IfException, Args, Bundles, NameStr,
34293535 InsertBefore);
34303536 }
3537
34313538 static InvokeInst *Create(FunctionType *Ty, Value *Func, BasicBlock *IfNormal,
34323539 BasicBlock *IfException, ArrayRef Args,
34333540 const Twine &NameStr,
34363543 return new (Values) InvokeInst(Ty, Func, IfNormal, IfException, Args, None,
34373544 Values, NameStr, InsertBefore);
34383545 }
3546
34393547 static InvokeInst *Create(FunctionType *Ty, Value *Func, BasicBlock *IfNormal,
34403548 BasicBlock *IfException, ArrayRef Args,
34413549 ArrayRef Bundles = None,
34483556 InvokeInst(Ty, Func, IfNormal, IfException, Args, Bundles, Values,
34493557 NameStr, InsertBefore);
34503558 }
3559
34513560 static InvokeInst *Create(Value *Func,
34523561 BasicBlock *IfNormal, BasicBlock *IfException,
34533562 ArrayRef Args, const Twine &NameStr,
38413950 InsertBefore) {
38423951 init(Ty, Func, IfNormal, IfException, Args, Bundles, NameStr);
38433952 }
3953
38443954 InvokeInst::InvokeInst(Value *Func, BasicBlock *IfNormal,
38453955 BasicBlock *IfException, ArrayRef Args,
38463956 ArrayRef Bundles, unsigned Values,
38713981 protected:
38723982 // Note: Instruction needs to be a friend here to call cloneImpl.
38733983 friend class Instruction;
3984
38743985 ResumeInst *cloneImpl() const;
38753986
38763987 public:
38773988 static ResumeInst *Create(Value *Exn, Instruction *InsertBefore = nullptr) {
38783989 return new(1) ResumeInst(Exn, InsertBefore);
38793990 }
3991
38803992 static ResumeInst *Create(Value *Exn, BasicBlock *InsertAtEnd) {
38813993 return new(1) ResumeInst(Exn, InsertAtEnd);
38823994 }
39144026 // CatchSwitchInst Class
39154027 //===----------------------------------------------------------------------===//
39164028 class CatchSwitchInst : public TerminatorInst {
3917 void *operator new(size_t, unsigned) = delete;
39184029 /// The number of operands actually allocated. NumOperands is
39194030 /// the number actually in use.
39204031 unsigned ReservedSpace;
4032
39214033 // Operand[0] = Outer scope
39224034 // Operand[1] = Unwind block destination
39234035 // Operand[n] = BasicBlock to go to on match
39244036 CatchSwitchInst(const CatchSwitchInst &CSI);
3925 void init(Value *ParentPad, BasicBlock *UnwindDest, unsigned NumReserved);
3926 void growOperands(unsigned Size);
3927 // allocate space for exactly zero operands
3928 void *operator new(size_t s) { return User::operator new(s); }
4037
39294038 /// Create a new switch instruction, specifying a
39304039 /// default destination. The number of additional handlers can be specified
39314040 /// here to make memory allocation more efficient.
39424051 unsigned NumHandlers, const Twine &NameStr,
39434052 BasicBlock *InsertAtEnd);
39444053
4054 // allocate space for exactly zero operands
4055 void *operator new(size_t s) { return User::operator new(s); }
4056
4057 void init(Value *ParentPad, BasicBlock *UnwindDest, unsigned NumReserved);
4058 void growOperands(unsigned Size);
4059
39454060 protected:
39464061 // Note: Instruction needs to be a friend here to call cloneImpl.
39474062 friend class Instruction;
4063
39484064 CatchSwitchInst *cloneImpl() const;
39494065
39504066 public:
4067 void *operator new(size_t, unsigned) = delete;
4068
39514069 static CatchSwitchInst *Create(Value *ParentPad, BasicBlock *UnwindDest,
39524070 unsigned NumHandlers,
39534071 const Twine &NameStr = "",
39554073 return new CatchSwitchInst(ParentPad, UnwindDest, NumHandlers, NameStr,
39564074 InsertBefore);
39574075 }
4076
39584077 static CatchSwitchInst *Create(Value *ParentPad, BasicBlock *UnwindDest,
39594078 unsigned NumHandlers, const Twine &NameStr,
39604079 BasicBlock *InsertAtEnd) {
40014120 typedef std::pointer_to_unary_function DerefFnTy;
40024121 typedef mapped_iterator handler_iterator;
40034122 typedef iterator_range handler_range;
4004
4005
40064123 typedef std::pointer_to_unary_function
40074124 ConstDerefFnTy;
40084125 typedef mapped_iterator const_handler_iterator;
40154132 ++It;
40164133 return handler_iterator(It, DerefFnTy(handler_helper));
40174134 }
4135
40184136 /// Returns an iterator that points to the first handler in the
40194137 /// CatchSwitchInst.
40204138 const_handler_iterator handler_begin() const {
40294147 handler_iterator handler_end() {
40304148 return handler_iterator(op_end(), DerefFnTy(handler_helper));
40314149 }
4150
40324151 /// Returns an iterator that points one past the last handler in the
40334152 /// CatchSwitchInst.
40344153 const_handler_iterator handler_end() const {
41084227 return new (Values)
41094228 CleanupPadInst(ParentPad, Args, Values, NameStr, InsertBefore);
41104229 }
4230
41114231 static CleanupPadInst *Create(Value *ParentPad, ArrayRef Args,
41124232 const Twine &NameStr, BasicBlock *InsertAtEnd) {
41134233 unsigned Values = 1 + Args.size();
41484268 return new (Values)
41494269 CatchPadInst(CatchSwitch, Args, Values, NameStr, InsertBefore);
41504270 }
4271
41514272 static CatchPadInst *Create(Value *CatchSwitch, ArrayRef Args,
41524273 const Twine &NameStr, BasicBlock *InsertAtEnd) {
41534274 unsigned Values = 1 + Args.size();
41794300
41804301 class CatchReturnInst : public TerminatorInst {
41814302 CatchReturnInst(const CatchReturnInst &RI);
4182
4183 void init(Value *CatchPad, BasicBlock *BB);
41844303 CatchReturnInst(Value *CatchPad, BasicBlock *BB, Instruction *InsertBefore);
41854304 CatchReturnInst(Value *CatchPad, BasicBlock *BB, BasicBlock *InsertAtEnd);
4305
4306 void init(Value *CatchPad, BasicBlock *BB);
41864307
41874308 protected:
41884309 // Note: Instruction needs to be a friend here to call cloneImpl.
41894310 friend class Instruction;
4311
41904312 CatchReturnInst *cloneImpl() const;
41914313
41924314 public:
41964318 assert(BB);
41974319 return new (2) CatchReturnInst(CatchPad, BB, InsertBefore);
41984320 }
4321
41994322 static CatchReturnInst *Create(Value *CatchPad, BasicBlock *BB,
42004323 BasicBlock *InsertAtEnd) {
42014324 assert(CatchPad);
42534376 class CleanupReturnInst : public TerminatorInst {
42544377 private:
42554378 CleanupReturnInst(const CleanupReturnInst &RI);
4256
4257 void init(Value *CleanupPad, BasicBlock *UnwindBB);
42584379 CleanupReturnInst(Value *CleanupPad, BasicBlock *UnwindBB, unsigned Values,
42594380 Instruction *InsertBefore = nullptr);
42604381 CleanupReturnInst(Value *CleanupPad, BasicBlock *UnwindBB, unsigned Values,
42614382 BasicBlock *InsertAtEnd);
42624383
4384 void init(Value *CleanupPad, BasicBlock *UnwindBB);
4385
42634386 protected:
42644387 // Note: Instruction needs to be a friend here to call cloneImpl.
42654388 friend class Instruction;
4389
42664390 CleanupReturnInst *cloneImpl() const;
42674391
42684392 public:
42764400 return new (Values)
42774401 CleanupReturnInst(CleanupPad, UnwindBB, Values, InsertBefore);
42784402 }
4403
42794404 static CleanupReturnInst *Create(Value *CleanupPad, BasicBlock *UnwindBB,
42804405 BasicBlock *InsertAtEnd) {
42814406 assert(CleanupPad);
43484473 /// end of the block cannot be reached.
43494474 ///
43504475 class UnreachableInst : public TerminatorInst {
4351 void *operator new(size_t, unsigned) = delete;
4352
43534476 protected:
43544477 // Note: Instruction needs to be a friend here to call cloneImpl.
43554478 friend class Instruction;
4479
43564480 UnreachableInst *cloneImpl() const;
43574481
43584482 public:
4483 explicit UnreachableInst(LLVMContext &C, Instruction *InsertBefore = nullptr);
4484 explicit UnreachableInst(LLVMContext &C, BasicBlock *InsertAtEnd);
4485
43594486 // allocate space for exactly zero operands
43604487 void *operator new(size_t s) {
43614488 return User::operator new(s, 0);
43624489 }
4363 explicit UnreachableInst(LLVMContext &C, Instruction *InsertBefore = nullptr);
4364 explicit UnreachableInst(LLVMContext &C, BasicBlock *InsertAtEnd);
4490
4491 void *operator new(size_t, unsigned) = delete;
43654492
43664493 unsigned getNumSuccessors() const { return 0; }
43674494
43884515 protected:
43894516 // Note: Instruction needs to be a friend here to call cloneImpl.
43904517 friend class Instruction;
4518
43914519 /// Clone an identical TruncInst
43924520 TruncInst *cloneImpl() const;
43934521
44264554 protected:
44274555 // Note: Instruction needs to be a friend here to call cloneImpl.
44284556 friend class Instruction;
4557
44294558 /// Clone an identical ZExtInst
44304559 ZExtInst *cloneImpl() const;
44314560
44644593 protected:
44654594 // Note: Instruction needs to be a friend here to call cloneImpl.
44664595 friend class Instruction;
4596
44674597 /// Clone an identical SExtInst
44684598 SExtInst *cloneImpl() const;
44694599
45024632 protected:
45034633 // Note: Instruction needs to be a friend here to call cloneImpl.
45044634 friend class Instruction;
4635
45054636 /// Clone an identical FPTruncInst
45064637 FPTruncInst *cloneImpl() const;
45074638
45404671 protected:
45414672 // Note: Instruction needs to be a friend here to call cloneImpl.
45424673 friend class Instruction;
4674
45434675 /// Clone an identical FPExtInst
45444676 FPExtInst *cloneImpl() const;
45454677
45784710 protected:
45794711 // Note: Instruction needs to be a friend here to call cloneImpl.
45804712 friend class Instruction;
4713
45814714 /// Clone an identical UIToFPInst
45824715 UIToFPInst *cloneImpl() const;
45834716
46164749 protected:
46174750 // Note: Instruction needs to be a friend here to call cloneImpl.
46184751 friend class Instruction;
4752
46194753 /// Clone an identical SIToFPInst
46204754 SIToFPInst *cloneImpl() const;
46214755
46544788 protected:
46554789 // Note: Instruction needs to be a friend here to call cloneImpl.
46564790 friend class Instruction;
4791
46574792 /// Clone an identical FPToUIInst
46584793 FPToUIInst *cloneImpl() const;
46594794
46924827 protected:
46934828 // Note: Instruction needs to be a friend here to call cloneImpl.
46944829 friend class Instruction;
4830
46954831 /// Clone an identical FPToSIInst
46964832 FPToSIInst *cloneImpl() const;
46974833
47284864 /// This class represents a cast from an integer to a pointer.
47294865 class IntToPtrInst : public CastInst {
47304866 public:
4867 // Note: Instruction needs to be a friend here to call cloneImpl.
4868 friend class Instruction;
4869
47314870 /// Constructor with insert-before-instruction semantics
47324871 IntToPtrInst(
47334872 Value *S, ///< The value to be converted
47444883 BasicBlock *InsertAtEnd ///< The block to insert the instruction into
47454884 );
47464885
4747 // Note: Instruction needs to be a friend here to call cloneImpl.
4748 friend class Instruction;
47494886 /// Clone an identical IntToPtrInst.
47504887 IntToPtrInst *cloneImpl() const;
47514888
47724909 protected:
47734910 // Note: Instruction needs to be a friend here to call cloneImpl.
47744911 friend class Instruction;
4912
47754913 /// Clone an identical PtrToIntInst.
47764914 PtrToIntInst *cloneImpl() const;
47774915
48224960 protected:
48234961 // Note: Instruction needs to be a friend here to call cloneImpl.
48244962 friend class Instruction;
4963
48254964 /// Clone an identical BitCastInst.
48264965 BitCastInst *cloneImpl() const;
48274966
48615000 protected:
48625001 // Note: Instruction needs to be a friend here to call cloneImpl.
48635002 friend class Instruction;
5003
48645004 /// Clone an identical AddrSpaceCastInst.
48655005 AddrSpaceCastInst *cloneImpl() const;
48665006
49155055 }
49165056 };
49175057
4918 } // End llvm namespace
4919
4920 #endif
5058 } // end namespace llvm
5059
5060 #endif // LLVM_IR_INSTRUCTIONS_H
836836 typedef OptionValue OptVal;
837837
838838 protected:
839 // Workaround Clang PR22793
840839 ~basic_parser() = default;
841840 };
842841