[RemoveDIs] Add iterator-taking constructors and Create methods (#82778)
Part of removing debug-intrinsics from LLVM requires using iterators whenever we insert an instruction into a block. That means we need all instruction constructors and factory functions to have an iterator taking option, which this patch adds. The whole of this patch should be NFC: it's adding new flavours of existing constructors, and plumbing those through to the Instruction constructor that takes iterators. It's almost entirely boilerplate copy-and-paste too.
This commit is contained in:
1 parent
749384c08e
commit
76dd4bc036
5 files changed
+1350
-16
No files matched your search
@@ -54,6 +54,10 @@ typedef unsigned ID;
|
||||
|
||||
class UnaryInstruction : public Instruction {
|
||||
protected:
|
||||
UnaryInstruction(Type *Ty, unsigned iType, Value *V, BasicBlock::iterator IB)
|
||||
: Instruction(Ty, iType, &Op<0>(), 1, IB) {
|
||||
Op<0>() = V;
|
||||
}
|
||||
UnaryInstruction(Type *Ty, unsigned iType, Value *V,
|
||||
Instruction *IB = nullptr)
|
||||
: Instruction(Ty, iType, &Op<0>(), 1, IB) {
|
||||
@@ -101,6 +105,8 @@ class UnaryOperator : public UnaryInstruction {
|
||||
void AssertOK();
|
||||
|
||||
protected:
|
||||
UnaryOperator(UnaryOps iType, Value *S, Type *Ty,
|
||||
const Twine &Name, BasicBlock::iterator InsertBefore);
|
||||
UnaryOperator(UnaryOps iType, Value *S, Type *Ty,
|
||||
const Twine &Name, Instruction *InsertBefore);
|
||||
UnaryOperator(UnaryOps iType, Value *S, Type *Ty,
|
||||
@@ -112,6 +118,12 @@ protected:
|
||||
UnaryOperator *cloneImpl() const;
|
||||
|
||||
public:
|
||||
/// Construct a unary instruction, given the opcode and an operand.
|
||||
/// Insert the instruction into a BasicBlock right before the specified
|
||||
/// instruction (InsertBefore must be a valid iterator).
|
||||
///
|
||||
static UnaryOperator *Create(UnaryOps Op, Value *S, const Twine &Name,
|
||||
BasicBlock::iterator InsertBefore);
|
||||
|
||||
/// Construct a unary instruction, given the opcode and an operand.
|
||||
/// Optionally (if InstBefore is specified) insert the instruction
|
||||
@@ -150,6 +162,20 @@ public:
|
||||
return Create(Instruction::OPC, V, Name, I);\
|
||||
}
|
||||
#include "llvm/IR/Instruction.def"
|
||||
#define HANDLE_UNARY_INST(N, OPC, CLASS) \
|
||||
static UnaryOperator *Create##OPC(Value *V, const Twine &Name, \
|
||||
BasicBlock::iterator It) {\
|
||||
return Create(Instruction::OPC, V, Name, It);\
|
||||
}
|
||||
#include "llvm/IR/Instruction.def"
|
||||
|
||||
static UnaryOperator *
|
||||
CreateWithCopiedFlags(UnaryOps Opc, Value *V, Instruction *CopyO,
|
||||
const Twine &Name, BasicBlock::iterator InsertBefore) {
|
||||
UnaryOperator *UO = Create(Opc, V, Name, InsertBefore);
|
||||
UO->copyIRFlags(CopyO);
|
||||
return UO;
|
||||
}
|
||||
|
||||
static UnaryOperator *
|
||||
CreateWithCopiedFlags(UnaryOps Opc, Value *V, Instruction *CopyO,
|
||||
@@ -160,6 +186,13 @@ public:
|
||||
return UO;
|
||||
}
|
||||
|
||||
static UnaryOperator *CreateFNegFMF(Value *Op, Instruction *FMFSource,
|
||||
const Twine &Name,
|
||||
BasicBlock::iterator InsertBefore) {
|
||||
return CreateWithCopiedFlags(Instruction::FNeg, Op, FMFSource, Name,
|
||||
InsertBefore);
|
||||
}
|
||||
|
||||
static UnaryOperator *CreateFNegFMF(Value *Op, Instruction *FMFSource,
|
||||
const Twine &Name = "",
|
||||
Instruction *InsertBefore = nullptr) {
|
||||
@@ -188,6 +221,8 @@ class BinaryOperator : public Instruction {
|
||||
void AssertOK();
|
||||
|
||||
protected:
|
||||
BinaryOperator(BinaryOps iType, Value *S1, Value *S2, Type *Ty,
|
||||
const Twine &Name, BasicBlock::iterator InsertBefore);
|
||||
BinaryOperator(BinaryOps iType, Value *S1, Value *S2, Type *Ty,
|
||||
const Twine &Name, Instruction *InsertBefore);
|
||||
BinaryOperator(BinaryOps iType, Value *S1, Value *S2, Type *Ty,
|
||||
@@ -206,6 +241,14 @@ public:
|
||||
/// Transparently provide more efficient getOperand methods.
|
||||
DECLARE_TRANSPARENT_OPERAND_ACCESSORS(Value);
|
||||
|
||||
/// Construct a binary instruction, given the opcode and the two
|
||||
/// operands. Insert the instruction into a BasicBlock right before the
|
||||
/// specified instruction.
|
||||
///
|
||||
static BinaryOperator *Create(BinaryOps Op, Value *S1, Value *S2,
|
||||
const Twine &Name,
|
||||
BasicBlock::iterator InsertBefore);
|
||||
|
||||
/// Construct a binary instruction, given the opcode and the two
|
||||
/// operands. Optionally (if InstBefore is specified) insert the instruction
|
||||
/// into a BasicBlock right before the specified instruction. The specified
|
||||
@@ -243,6 +286,20 @@ public:
|
||||
return Create(Instruction::OPC, V1, V2, Name, I);\
|
||||
}
|
||||
#include "llvm/IR/Instruction.def"
|
||||
#define HANDLE_BINARY_INST(N, OPC, CLASS) \
|
||||
static BinaryOperator *Create##OPC(Value *V1, Value *V2, \
|
||||
const Twine &Name, BasicBlock::iterator It) {\
|
||||
return Create(Instruction::OPC, V1, V2, Name, It);\
|
||||
}
|
||||
#include "llvm/IR/Instruction.def"
|
||||
|
||||
static BinaryOperator *
|
||||
CreateWithCopiedFlags(BinaryOps Opc, Value *V1, Value *V2, Value *CopyO,
|
||||
const Twine &Name, BasicBlock::iterator InsertBefore) {
|
||||
BinaryOperator *BO = Create(Opc, V1, V2, Name, InsertBefore);
|
||||
BO->copyIRFlags(CopyO);
|
||||
return BO;
|
||||
}
|
||||
|
||||
static BinaryOperator *
|
||||
CreateWithCopiedFlags(BinaryOps Opc, Value *V1, Value *V2, Value *CopyO,
|
||||
@@ -297,6 +354,12 @@ public:
|
||||
BO->setHasNoSignedWrap(true);
|
||||
return BO;
|
||||
}
|
||||
static BinaryOperator *CreateNSW(BinaryOps Opc, Value *V1, Value *V2,
|
||||
const Twine &Name, BasicBlock::iterator It) {
|
||||
BinaryOperator *BO = Create(Opc, V1, V2, Name, It);
|
||||
BO->setHasNoSignedWrap(true);
|
||||
return BO;
|
||||
}
|
||||
|
||||
static BinaryOperator *CreateNUW(BinaryOps Opc, Value *V1, Value *V2,
|
||||
const Twine &Name = "") {
|
||||
@@ -316,6 +379,12 @@ public:
|
||||
BO->setHasNoUnsignedWrap(true);
|
||||
return BO;
|
||||
}
|
||||
static BinaryOperator *CreateNUW(BinaryOps Opc, Value *V1, Value *V2,
|
||||
const Twine &Name, BasicBlock::iterator It) {
|
||||
BinaryOperator *BO = Create(Opc, V1, V2, Name, It);
|
||||
BO->setHasNoUnsignedWrap(true);
|
||||
return BO;
|
||||
}
|
||||
|
||||
static BinaryOperator *CreateExact(BinaryOps Opc, Value *V1, Value *V2,
|
||||
const Twine &Name = "") {
|
||||
@@ -335,6 +404,13 @@ public:
|
||||
BO->setIsExact(true);
|
||||
return BO;
|
||||
}
|
||||
static BinaryOperator *CreateExact(BinaryOps Opc, Value *V1, Value *V2,
|
||||
const Twine &Name,
|
||||
BasicBlock::iterator It) {
|
||||
BinaryOperator *BO = Create(Opc, V1, V2, Name, It);
|
||||
BO->setIsExact(true);
|
||||
return BO;
|
||||
}
|
||||
|
||||
static inline BinaryOperator *
|
||||
CreateDisjoint(BinaryOps Opc, Value *V1, Value *V2, const Twine &Name = "");
|
||||
@@ -344,6 +420,9 @@ public:
|
||||
static inline BinaryOperator *CreateDisjoint(BinaryOps Opc, Value *V1,
|
||||
Value *V2, const Twine &Name,
|
||||
Instruction *I);
|
||||
static inline BinaryOperator *CreateDisjoint(BinaryOps Opc, Value *V1,
|
||||
Value *V2, const Twine &Name,
|
||||
BasicBlock::iterator It);
|
||||
|
||||
#define DEFINE_HELPERS(OPC, NUWNSWEXACT) \
|
||||
static BinaryOperator *Create##NUWNSWEXACT##OPC(Value *V1, Value *V2, \
|
||||
@@ -357,6 +436,10 @@ public:
|
||||
static BinaryOperator *Create##NUWNSWEXACT##OPC( \
|
||||
Value *V1, Value *V2, const Twine &Name, Instruction *I) { \
|
||||
return Create##NUWNSWEXACT(Instruction::OPC, V1, V2, Name, I); \
|
||||
} \
|
||||
static BinaryOperator *Create##NUWNSWEXACT##OPC( \
|
||||
Value *V1, Value *V2, const Twine &Name, BasicBlock::iterator It) { \
|
||||
return Create##NUWNSWEXACT(Instruction::OPC, V1, V2, Name, It); \
|
||||
}
|
||||
|
||||
DEFINE_HELPERS(Add, NSW) // CreateNSWAdd
|
||||
@@ -382,18 +465,26 @@ public:
|
||||
///
|
||||
/// Create the NEG and NOT instructions out of SUB and XOR instructions.
|
||||
///
|
||||
static BinaryOperator *CreateNeg(Value *Op, const Twine &Name,
|
||||
BasicBlock::iterator InsertBefore);
|
||||
static BinaryOperator *CreateNeg(Value *Op, const Twine &Name = "",
|
||||
Instruction *InsertBefore = nullptr);
|
||||
static BinaryOperator *CreateNeg(Value *Op, const Twine &Name,
|
||||
BasicBlock *InsertAtEnd);
|
||||
static BinaryOperator *CreateNSWNeg(Value *Op, const Twine &Name,
|
||||
BasicBlock::iterator InsertBefore);
|
||||
static BinaryOperator *CreateNSWNeg(Value *Op, const Twine &Name = "",
|
||||
Instruction *InsertBefore = nullptr);
|
||||
static BinaryOperator *CreateNSWNeg(Value *Op, const Twine &Name,
|
||||
BasicBlock *InsertAtEnd);
|
||||
static BinaryOperator *CreateNUWNeg(Value *Op, const Twine &Name,
|
||||
BasicBlock::iterator InsertBefore);
|
||||
static BinaryOperator *CreateNUWNeg(Value *Op, const Twine &Name = "",
|
||||
Instruction *InsertBefore = nullptr);
|
||||
static BinaryOperator *CreateNUWNeg(Value *Op, const Twine &Name,
|
||||
BasicBlock *InsertAtEnd);
|
||||
static BinaryOperator *CreateNot(Value *Op, const Twine &Name,
|
||||
BasicBlock::iterator InsertBefore);
|
||||
static BinaryOperator *CreateNot(Value *Op, const Twine &Name = "",
|
||||
Instruction *InsertBefore = nullptr);
|
||||
static BinaryOperator *CreateNot(Value *Op, const Twine &Name,
|
||||
@@ -469,6 +560,13 @@ BinaryOperator *BinaryOperator::CreateDisjoint(BinaryOps Opc, Value *V1,
|
||||
cast<PossiblyDisjointInst>(BO)->setIsDisjoint(true);
|
||||
return BO;
|
||||
}
|
||||
BinaryOperator *BinaryOperator::CreateDisjoint(BinaryOps Opc, Value *V1,
|
||||
Value *V2, const Twine &Name,
|
||||
BasicBlock::iterator It) {
|
||||
BinaryOperator *BO = Create(Opc, V1, V2, Name, It);
|
||||
cast<PossiblyDisjointInst>(BO)->setIsDisjoint(true);
|
||||
return BO;
|
||||
}
|
||||
|
||||
//===----------------------------------------------------------------------===//
|
||||
// CastInst Class
|
||||
@@ -482,6 +580,12 @@ BinaryOperator *BinaryOperator::CreateDisjoint(BinaryOps Opc, Value *V1,
|
||||
/// Base class of casting instructions.
|
||||
class CastInst : public UnaryInstruction {
|
||||
protected:
|
||||
/// Constructor with insert-before-instruction semantics for subclasses
|
||||
CastInst(Type *Ty, unsigned iType, Value *S, const Twine &NameStr,
|
||||
BasicBlock::iterator InsertBefore)
|
||||
: UnaryInstruction(Ty, iType, S, InsertBefore) {
|
||||
setName(NameStr);
|
||||
}
|
||||
/// Constructor with insert-before-instruction semantics for subclasses
|
||||
CastInst(Type *Ty, unsigned iType, Value *S,
|
||||
const Twine &NameStr = "", Instruction *InsertBefore = nullptr)
|
||||
@@ -496,6 +600,19 @@ protected:
|
||||
}
|
||||
|
||||
public:
|
||||
/// Provides a way to construct any of the CastInst subclasses using an
|
||||
/// opcode instead of the subclass's constructor. The opcode must be in the
|
||||
/// CastOps category (Instruction::isCast(opcode) returns true). This
|
||||
/// constructor has insert-before-instruction semantics to automatically
|
||||
/// insert the new CastInst before InsertBefore, which must be a valid
|
||||
/// iterator. Construct any of the CastInst subclasses.
|
||||
static CastInst *
|
||||
Create(Instruction::CastOps, ///< The opcode of the cast instruction
|
||||
Value *S, ///< The value to be casted (operand 0)
|
||||
Type *Ty, ///< The type to which cast should be made
|
||||
const Twine &Name, ///< Name for the instruction
|
||||
BasicBlock::iterator InsertBefore ///< Place to insert the instruction
|
||||
);
|
||||
/// Provides a way to construct any of the CastInst subclasses using an
|
||||
/// opcode instead of the subclass's constructor. The opcode must be in the
|
||||
/// CastOps category (Instruction::isCast(opcode) returns true). This
|
||||
@@ -523,6 +640,14 @@ public:
|
||||
BasicBlock *InsertAtEnd ///< The block to insert the instruction into
|
||||
);
|
||||
|
||||
/// Create a ZExt or BitCast cast instruction
|
||||
static CastInst *CreateZExtOrBitCast(
|
||||
Value *S, ///< The value to be casted (operand 0)
|
||||
Type *Ty, ///< The type to which cast should be made
|
||||
const Twine &Name, ///< Name for the instruction
|
||||
BasicBlock::iterator InsertBefore ///< Place to insert the instruction
|
||||
);
|
||||
|
||||
/// Create a ZExt or BitCast cast instruction
|
||||
static CastInst *CreateZExtOrBitCast(
|
||||
Value *S, ///< The value to be casted (operand 0)
|
||||
@@ -539,6 +664,14 @@ public:
|
||||
BasicBlock *InsertAtEnd ///< The block to insert the instruction into
|
||||
);
|
||||
|
||||
/// Create a SExt or BitCast cast instruction
|
||||
static CastInst *CreateSExtOrBitCast(
|
||||
Value *S, ///< The value to be casted (operand 0)
|
||||
Type *Ty, ///< The type to which cast should be made
|
||||
const Twine &Name, ///< Name for the instruction
|
||||
BasicBlock::iterator InsertBefore ///< Place to insert the instruction
|
||||
);
|
||||
|
||||
/// Create a SExt or BitCast cast instruction
|
||||
static CastInst *CreateSExtOrBitCast(
|
||||
Value *S, ///< The value to be casted (operand 0)
|
||||
@@ -563,6 +696,14 @@ public:
|
||||
BasicBlock *InsertAtEnd ///< The block to insert the instruction into
|
||||
);
|
||||
|
||||
/// Create a BitCast, AddrSpaceCast or a PtrToInt cast instruction.
|
||||
static CastInst *CreatePointerCast(
|
||||
Value *S, ///< The pointer value to be casted (operand 0)
|
||||
Type *Ty, ///< The type to which cast should be made
|
||||
const Twine &Name, ///< Name for the instruction
|
||||
BasicBlock::iterator InsertBefore ///< Place to insert the instruction
|
||||
);
|
||||
|
||||
/// Create a BitCast, AddrSpaceCast or a PtrToInt cast instruction.
|
||||
static CastInst *CreatePointerCast(
|
||||
Value *S, ///< The pointer value to be casted (operand 0)
|
||||
@@ -579,6 +720,14 @@ public:
|
||||
BasicBlock *InsertAtEnd ///< The block to insert the instruction into
|
||||
);
|
||||
|
||||
/// Create a BitCast or an AddrSpaceCast cast instruction.
|
||||
static CastInst *CreatePointerBitCastOrAddrSpaceCast(
|
||||
Value *S, ///< The pointer value to be casted (operand 0)
|
||||
Type *Ty, ///< The type to which cast should be made
|
||||
const Twine &Name, ///< Name for the instruction
|
||||
BasicBlock::iterator InsertBefore ///< Place to insert the instruction
|
||||
);
|
||||
|
||||
/// Create a BitCast or an AddrSpaceCast cast instruction.
|
||||
static CastInst *CreatePointerBitCastOrAddrSpaceCast(
|
||||
Value *S, ///< The pointer value to be casted (operand 0)
|
||||
@@ -587,6 +736,19 @@ public:
|
||||
Instruction *InsertBefore = nullptr ///< Place to insert the instruction
|
||||
);
|
||||
|
||||
/// Create a BitCast, a PtrToInt, or an IntToPTr cast instruction.
|
||||
///
|
||||
/// If the value is a pointer type and the destination an integer type,
|
||||
/// creates a PtrToInt cast. If the value is an integer type and the
|
||||
/// destination a pointer type, creates an IntToPtr cast. Otherwise, creates
|
||||
/// a bitcast.
|
||||
static CastInst *CreateBitOrPointerCast(
|
||||
Value *S, ///< The pointer value to be casted (operand 0)
|
||||
Type *Ty, ///< The type to which cast should be made
|
||||
const Twine &Name, ///< Name for the instruction
|
||||
BasicBlock::iterator InsertBefore ///< Place to insert the instruction
|
||||
);
|
||||
|
||||
/// Create a BitCast, a PtrToInt, or an IntToPTr cast instruction.
|
||||
///
|
||||
/// If the value is a pointer type and the destination an integer type,
|
||||
@@ -600,6 +762,15 @@ public:
|
||||
Instruction *InsertBefore = nullptr ///< Place to insert the instruction
|
||||
);
|
||||
|
||||
/// Create a ZExt, BitCast, or Trunc for int -> int casts.
|
||||
static CastInst *CreateIntegerCast(
|
||||
Value *S, ///< The pointer value to be casted (operand 0)
|
||||
Type *Ty, ///< The type to which cast should be made
|
||||
bool isSigned, ///< Whether to regard S as signed or not
|
||||
const Twine &Name, ///< Name for the instruction
|
||||
BasicBlock::iterator InsertBefore ///< Place to insert the instruction
|
||||
);
|
||||
|
||||
/// Create a ZExt, BitCast, or Trunc for int -> int casts.
|
||||
static CastInst *CreateIntegerCast(
|
||||
Value *S, ///< The pointer value to be casted (operand 0)
|
||||
@@ -618,6 +789,14 @@ public:
|
||||
BasicBlock *InsertAtEnd ///< The block to insert the instruction into
|
||||
);
|
||||
|
||||
/// Create an FPExt, BitCast, or FPTrunc for fp -> fp casts
|
||||
static CastInst *CreateFPCast(
|
||||
Value *S, ///< The floating point value to be casted
|
||||
Type *Ty, ///< The floating point type to cast to
|
||||
const Twine &Name, ///< Name for the instruction
|
||||
BasicBlock::iterator InsertBefore ///< Place to insert the instruction
|
||||
);
|
||||
|
||||
/// Create an FPExt, BitCast, or FPTrunc for fp -> fp casts
|
||||
static CastInst *CreateFPCast(
|
||||
Value *S, ///< The floating point value to be casted
|
||||
@@ -634,6 +813,14 @@ public:
|
||||
BasicBlock *InsertAtEnd ///< The block to insert the instruction into
|
||||
);
|
||||
|
||||
/// Create a Trunc or BitCast cast instruction
|
||||
static CastInst *CreateTruncOrBitCast(
|
||||
Value *S, ///< The value to be casted (operand 0)
|
||||
Type *Ty, ///< The type to which cast should be made
|
||||
const Twine &Name, ///< Name for the instruction
|
||||
BasicBlock::iterator InsertBefore ///< Place to insert the instruction
|
||||
);
|
||||
|
||||
/// Create a Trunc or BitCast cast instruction
|
||||
static CastInst *CreateTruncOrBitCast(
|
||||
Value *S, ///< The value to be casted (operand 0)
|
||||
@@ -830,6 +1017,10 @@ public:
|
||||
}
|
||||
|
||||
protected:
|
||||
CmpInst(Type *ty, Instruction::OtherOps op, Predicate pred, Value *LHS,
|
||||
Value *RHS, const Twine &Name, BasicBlock::iterator InsertBefore,
|
||||
Instruction *FlagsSource = nullptr);
|
||||
|
||||
CmpInst(Type *ty, Instruction::OtherOps op, Predicate pred,
|
||||
Value *LHS, Value *RHS, const Twine &Name = "",
|
||||
Instruction *InsertBefore = nullptr,
|
||||
@@ -844,6 +1035,13 @@ public:
|
||||
void *operator new(size_t S) { return User::operator new(S, 2); }
|
||||
void operator delete(void *Ptr) { User::operator delete(Ptr); }
|
||||
|
||||
/// Construct a compare instruction, given the opcode, the predicate and
|
||||
/// the two operands. Insert the instruction into a BasicBlock right before
|
||||
/// the specified instruction.
|
||||
/// Create a CmpInst
|
||||
static CmpInst *Create(OtherOps Op, Predicate predicate, Value *S1, Value *S2,
|
||||
const Twine &Name, BasicBlock::iterator InsertBefore);
|
||||
|
||||
/// Construct a compare instruction, given the opcode, the predicate and
|
||||
/// the two operands. Optionally (if InstBefore is specified) insert the
|
||||
/// instruction into a BasicBlock right before the specified instruction.
|
||||
@@ -1300,6 +1498,15 @@ protected:
|
||||
public:
|
||||
using Instruction::getContext;
|
||||
|
||||
/// Create a clone of \p CB with a different set of operand bundles and
|
||||
/// insert it before \p InsertPt.
|
||||
///
|
||||
/// The returned call instruction is identical \p CB in every way except that
|
||||
/// the operand bundles for the new instruction are set to the operand bundles
|
||||
/// in \p Bundles.
|
||||
static CallBase *Create(CallBase *CB, ArrayRef<OperandBundleDef> Bundles,
|
||||
BasicBlock::iterator InsertPt);
|
||||
|
||||
/// Create a clone of \p CB with a different set of operand bundles and
|
||||
/// insert it before \p InsertPt.
|
||||
///
|
||||
@@ -1309,6 +1516,14 @@ public:
|
||||
static CallBase *Create(CallBase *CB, ArrayRef<OperandBundleDef> Bundles,
|
||||
Instruction *InsertPt = nullptr);
|
||||
|
||||
/// Create a clone of \p CB with the operand bundle with the tag matching
|
||||
/// \p Bundle's tag replaced with Bundle, and insert it before \p InsertPt.
|
||||
///
|
||||
/// The returned call instruction is identical \p CI in every way except that
|
||||
/// the specified operand bundle has been replaced.
|
||||
static CallBase *Create(CallBase *CB, OperandBundleDef Bundle,
|
||||
BasicBlock::iterator InsertPt);
|
||||
|
||||
/// Create a clone of \p CB with the operand bundle with the tag matching
|
||||
/// \p Bundle's tag replaced with Bundle, and insert it before \p InsertPt.
|
||||
///
|
||||
@@ -2391,6 +2606,10 @@ class FuncletPadInst : public Instruction {
|
||||
private:
|
||||
FuncletPadInst(const FuncletPadInst &CPI);
|
||||
|
||||
explicit FuncletPadInst(Instruction::FuncletPadOps Op, Value *ParentPad,
|
||||
ArrayRef<Value *> Args, unsigned Values,
|
||||
const Twine &NameStr,
|
||||
BasicBlock::iterator InsertBefore);
|
||||
explicit FuncletPadInst(Instruction::FuncletPadOps Op, Value *ParentPad,
|
||||
ArrayRef<Value *> Args, unsigned Values,
|
||||
const Twine &NameStr, Instruction *InsertBefore);
|
||||
|
||||
@@ -1007,6 +1007,8 @@ protected:
|
||||
setValueSubclassData(Storage);
|
||||
}
|
||||
|
||||
Instruction(Type *Ty, unsigned iType, Use *Ops, unsigned NumOps,
|
||||
InstListType::iterator InsertBefore);
|
||||
Instruction(Type *Ty, unsigned iType, Use *Ops, unsigned NumOps,
|
||||
Instruction *InsertBefore = nullptr);
|
||||
Instruction(Type *Ty, unsigned iType, Use *Ops, unsigned NumOps,
|
||||
|
||||
File diff suppressed because it is too large.
Load diff
@@ -22,6 +22,16 @@
|
||||
#include "llvm/IR/Type.h"
|
||||
using namespace llvm;
|
||||
|
||||
Instruction::Instruction(Type *ty, unsigned it, Use *Ops, unsigned NumOps,
|
||||
InstListType::iterator InsertBefore)
|
||||
: User(ty, Value::InstructionVal + it, Ops, NumOps), Parent(nullptr) {
|
||||
|
||||
// When called with an iterator, there must be a block to insert into.
|
||||
BasicBlock *BB = InsertBefore->getParent();
|
||||
assert(BB && "Instruction to insert before is not in a basic block!");
|
||||
insertInto(BB, InsertBefore);
|
||||
}
|
||||
|
||||
Instruction::Instruction(Type *ty, unsigned it, Use *Ops, unsigned NumOps,
|
||||
Instruction *InsertBefore)
|
||||
: User(ty, Value::InstructionVal + it, Ops, NumOps), Parent(nullptr) {
|
||||
|
||||
@@ -230,6 +230,13 @@ bool PHINode::hasConstantOrUndefValue() const {
|
||||
// LandingPadInst Implementation
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
LandingPadInst::LandingPadInst(Type *RetTy, unsigned NumReservedValues,
|
||||
const Twine &NameStr,
|
||||
BasicBlock::iterator InsertBefore)
|
||||
: Instruction(RetTy, Instruction::LandingPad, nullptr, 0, InsertBefore) {
|
||||
init(NumReservedValues, NameStr);
|
||||
}
|
||||
|
||||
LandingPadInst::LandingPadInst(Type *RetTy, unsigned NumReservedValues,
|
||||
const Twine &NameStr, Instruction *InsertBefore)
|
||||
: Instruction(RetTy, Instruction::LandingPad, nullptr, 0, InsertBefore) {
|
||||
@@ -736,6 +743,20 @@ CallInst::CallInst(const CallInst &CI)
|
||||
SubclassOptionalData = CI.SubclassOptionalData;
|
||||
}
|
||||
|
||||
CallInst *CallInst::Create(CallInst *CI, ArrayRef<OperandBundleDef> OpB,
|
||||
BasicBlock::iterator InsertPt) {
|
||||
std::vector<Value *> Args(CI->arg_begin(), CI->arg_end());
|
||||
|
||||
auto *NewCI = CallInst::Create(CI->getFunctionType(), CI->getCalledOperand(),
|
||||
Args, OpB, CI->getName(), InsertPt);
|
||||
NewCI->setTailCallKind(CI->getTailCallKind());
|
||||
NewCI->setCallingConv(CI->getCallingConv());
|
||||
NewCI->SubclassOptionalData = CI->SubclassOptionalData;
|
||||
NewCI->setAttributes(CI->getAttributes());
|
||||
NewCI->setDebugLoc(CI->getDebugLoc());
|
||||
return NewCI;
|
||||
}
|
||||
|
||||
CallInst *CallInst::Create(CallInst *CI, ArrayRef<OperandBundleDef> OpB,
|
||||
Instruction *InsertPt) {
|
||||
std::vector<Value *> Args(CI->arg_begin(), CI->arg_end());
|
||||
@@ -960,7 +981,17 @@ ReturnInst::ReturnInst(const ReturnInst &RI)
|
||||
SubclassOptionalData = RI.SubclassOptionalData;
|
||||
}
|
||||
|
||||
ReturnInst::ReturnInst(LLVMContext &C, Value *retVal, Instruction *InsertBefore)
|
||||
ReturnInst::ReturnInst(LLVMContext &C, Value *retVal,
|
||||
BasicBlock::iterator InsertBefore)
|
||||
: Instruction(Type::getVoidTy(C), Instruction::Ret,
|
||||
OperandTraits<ReturnInst>::op_end(this) - !!retVal, !!retVal,
|
||||
InsertBefore) {
|
||||
if (retVal)
|
||||
Op<0>() = retVal;
|
||||
}
|
||||
|
||||
ReturnInst::ReturnInst(LLVMContext &C, Value *retVal,
|
||||
Instruction *InsertBefore)
|
||||
: Instruction(Type::getVoidTy(C), Instruction::Ret,
|
||||
OperandTraits<ReturnInst>::op_end(this) - !!retVal, !!retVal,
|
||||
InsertBefore) {
|
||||
@@ -990,6 +1021,12 @@ ResumeInst::ResumeInst(const ResumeInst &RI)
|
||||
Op<0>() = RI.Op<0>();
|
||||
}
|
||||
|
||||
ResumeInst::ResumeInst(Value *Exn, BasicBlock::iterator InsertBefore)
|
||||
: Instruction(Type::getVoidTy(Exn->getContext()), Instruction::Resume,
|
||||
OperandTraits<ResumeInst>::op_begin(this), 1, InsertBefore) {
|
||||
Op<0>() = Exn;
|
||||
}
|
||||
|
||||
ResumeInst::ResumeInst(Value *Exn, Instruction *InsertBefore)
|
||||
: Instruction(Type::getVoidTy(Exn->getContext()), Instruction::Resume,
|
||||
OperandTraits<ResumeInst>::op_begin(this), 1, InsertBefore) {
|
||||
@@ -1027,6 +1064,16 @@ void CleanupReturnInst::init(Value *CleanupPad, BasicBlock *UnwindBB) {
|
||||
Op<1>() = UnwindBB;
|
||||
}
|
||||
|
||||
CleanupReturnInst::CleanupReturnInst(Value *CleanupPad, BasicBlock *UnwindBB,
|
||||
unsigned Values,
|
||||
BasicBlock::iterator InsertBefore)
|
||||
: Instruction(Type::getVoidTy(CleanupPad->getContext()),
|
||||
Instruction::CleanupRet,
|
||||
OperandTraits<CleanupReturnInst>::op_end(this) - Values,
|
||||
Values, InsertBefore) {
|
||||
init(CleanupPad, UnwindBB);
|
||||
}
|
||||
|
||||
CleanupReturnInst::CleanupReturnInst(Value *CleanupPad, BasicBlock *UnwindBB,
|
||||
unsigned Values, Instruction *InsertBefore)
|
||||
: Instruction(Type::getVoidTy(CleanupPad->getContext()),
|
||||
@@ -1060,6 +1107,14 @@ CatchReturnInst::CatchReturnInst(const CatchReturnInst &CRI)
|
||||
Op<1>() = CRI.Op<1>();
|
||||
}
|
||||
|
||||
CatchReturnInst::CatchReturnInst(Value *CatchPad, BasicBlock *BB,
|
||||
BasicBlock::iterator InsertBefore)
|
||||
: Instruction(Type::getVoidTy(BB->getContext()), Instruction::CatchRet,
|
||||
OperandTraits<CatchReturnInst>::op_begin(this), 2,
|
||||
InsertBefore) {
|
||||
init(CatchPad, BB);
|
||||
}
|
||||
|
||||
CatchReturnInst::CatchReturnInst(Value *CatchPad, BasicBlock *BB,
|
||||
Instruction *InsertBefore)
|
||||
: Instruction(Type::getVoidTy(BB->getContext()), Instruction::CatchRet,
|
||||
@@ -1179,6 +1234,16 @@ FuncletPadInst::FuncletPadInst(const FuncletPadInst &FPI)
|
||||
setParentPad(FPI.getParentPad());
|
||||
}
|
||||
|
||||
FuncletPadInst::FuncletPadInst(Instruction::FuncletPadOps Op, Value *ParentPad,
|
||||
ArrayRef<Value *> Args, unsigned Values,
|
||||
const Twine &NameStr,
|
||||
BasicBlock::iterator InsertBefore)
|
||||
: Instruction(ParentPad->getType(), Op,
|
||||
OperandTraits<FuncletPadInst>::op_end(this) - Values, Values,
|
||||
InsertBefore) {
|
||||
init(ParentPad, Args, NameStr);
|
||||
}
|
||||
|
||||
FuncletPadInst::FuncletPadInst(Instruction::FuncletPadOps Op, Value *ParentPad,
|
||||
ArrayRef<Value *> Args, unsigned Values,
|
||||
const Twine &NameStr, Instruction *InsertBefore)
|
||||
@@ -1201,6 +1266,10 @@ FuncletPadInst::FuncletPadInst(Instruction::FuncletPadOps Op, Value *ParentPad,
|
||||
// UnreachableInst Implementation
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
UnreachableInst::UnreachableInst(LLVMContext &Context,
|
||||
BasicBlock::iterator InsertBefore)
|
||||
: Instruction(Type::getVoidTy(Context), Instruction::Unreachable, nullptr,
|
||||
0, InsertBefore) {}
|
||||
UnreachableInst::UnreachableInst(LLVMContext &Context,
|
||||
Instruction *InsertBefore)
|
||||
: Instruction(Type::getVoidTy(Context), Instruction::Unreachable, nullptr,
|
||||
@@ -1219,6 +1288,14 @@ void BranchInst::AssertOK() {
|
||||
"May only branch on boolean predicates!");
|
||||
}
|
||||
|
||||
BranchInst::BranchInst(BasicBlock *IfTrue, BasicBlock::iterator InsertBefore)
|
||||
: Instruction(Type::getVoidTy(IfTrue->getContext()), Instruction::Br,
|
||||
OperandTraits<BranchInst>::op_end(this) - 1, 1,
|
||||
InsertBefore) {
|
||||
assert(IfTrue && "Branch destination may not be null!");
|
||||
Op<-1>() = IfTrue;
|
||||
}
|
||||
|
||||
BranchInst::BranchInst(BasicBlock *IfTrue, Instruction *InsertBefore)
|
||||
: Instruction(Type::getVoidTy(IfTrue->getContext()), Instruction::Br,
|
||||
OperandTraits<BranchInst>::op_end(this) - 1, 1,
|
||||
@@ -1227,6 +1304,20 @@ BranchInst::BranchInst(BasicBlock *IfTrue, Instruction *InsertBefore)
|
||||
Op<-1>() = IfTrue;
|
||||
}
|
||||
|
||||
BranchInst::BranchInst(BasicBlock *IfTrue, BasicBlock *IfFalse, Value *Cond,
|
||||
BasicBlock::iterator InsertBefore)
|
||||
: Instruction(Type::getVoidTy(IfTrue->getContext()), Instruction::Br,
|
||||
OperandTraits<BranchInst>::op_end(this) - 3, 3,
|
||||
InsertBefore) {
|
||||
// Assign in order of operand index to make use-list order predictable.
|
||||
Op<-3>() = Cond;
|
||||
Op<-2>() = IfFalse;
|
||||
Op<-1>() = IfTrue;
|
||||
#ifndef NDEBUG
|
||||
AssertOK();
|
||||
#endif
|
||||
}
|
||||
|
||||
BranchInst::BranchInst(BasicBlock *IfTrue, BasicBlock *IfFalse, Value *Cond,
|
||||
Instruction *InsertBefore)
|
||||
: Instruction(Type::getVoidTy(IfTrue->getContext()), Instruction::Br,
|
||||
@@ -1309,11 +1400,19 @@ static Align computeAllocaDefaultAlign(Type *Ty, BasicBlock *BB) {
|
||||
return DL.getPrefTypeAlign(Ty);
|
||||
}
|
||||
|
||||
static Align computeAllocaDefaultAlign(Type *Ty, BasicBlock::iterator It) {
|
||||
return computeAllocaDefaultAlign(Ty, It->getParent());
|
||||
}
|
||||
|
||||
static Align computeAllocaDefaultAlign(Type *Ty, Instruction *I) {
|
||||
assert(I && "Insertion position cannot be null when alignment not provided!");
|
||||
return computeAllocaDefaultAlign(Ty, I->getParent());
|
||||
}
|
||||
|
||||
AllocaInst::AllocaInst(Type *Ty, unsigned AddrSpace, const Twine &Name,
|
||||
BasicBlock::iterator InsertBefore)
|
||||
: AllocaInst(Ty, AddrSpace, /*ArraySize=*/nullptr, Name, InsertBefore) {}
|
||||
|
||||
AllocaInst::AllocaInst(Type *Ty, unsigned AddrSpace, const Twine &Name,
|
||||
Instruction *InsertBefore)
|
||||
: AllocaInst(Ty, AddrSpace, /*ArraySize=*/nullptr, Name, InsertBefore) {}
|
||||
@@ -1322,6 +1421,12 @@ AllocaInst::AllocaInst(Type *Ty, unsigned AddrSpace, const Twine &Name,
|
||||
BasicBlock *InsertAtEnd)
|
||||
: AllocaInst(Ty, AddrSpace, /*ArraySize=*/nullptr, Name, InsertAtEnd) {}
|
||||
|
||||
AllocaInst::AllocaInst(Type *Ty, unsigned AddrSpace, Value *ArraySize,
|
||||
const Twine &Name, BasicBlock::iterator InsertBefore)
|
||||
: AllocaInst(Ty, AddrSpace, ArraySize,
|
||||
computeAllocaDefaultAlign(Ty, InsertBefore), Name,
|
||||
InsertBefore) {}
|
||||
|
||||
AllocaInst::AllocaInst(Type *Ty, unsigned AddrSpace, Value *ArraySize,
|
||||
const Twine &Name, Instruction *InsertBefore)
|
||||
: AllocaInst(Ty, AddrSpace, ArraySize,
|
||||
@@ -1334,6 +1439,17 @@ AllocaInst::AllocaInst(Type *Ty, unsigned AddrSpace, Value *ArraySize,
|
||||
computeAllocaDefaultAlign(Ty, InsertAtEnd), Name,
|
||||
InsertAtEnd) {}
|
||||
|
||||
AllocaInst::AllocaInst(Type *Ty, unsigned AddrSpace, Value *ArraySize,
|
||||
Align Align, const Twine &Name,
|
||||
BasicBlock::iterator InsertBefore)
|
||||
: UnaryInstruction(PointerType::get(Ty, AddrSpace), Alloca,
|
||||
getAISize(Ty->getContext(), ArraySize), InsertBefore),
|
||||
AllocatedType(Ty) {
|
||||
setAlignment(Align);
|
||||
assert(!Ty->isVoidTy() && "Cannot allocate void!");
|
||||
setName(Name);
|
||||
}
|
||||
|
||||
AllocaInst::AllocaInst(Type *Ty, unsigned AddrSpace, Value *ArraySize,
|
||||
Align Align, const Twine &Name,
|
||||
Instruction *InsertBefore)
|
||||
@@ -1391,11 +1507,19 @@ static Align computeLoadStoreDefaultAlign(Type *Ty, BasicBlock *BB) {
|
||||
return DL.getABITypeAlign(Ty);
|
||||
}
|
||||
|
||||
static Align computeLoadStoreDefaultAlign(Type *Ty, BasicBlock::iterator It) {
|
||||
return computeLoadStoreDefaultAlign(Ty, It->getParent());
|
||||
}
|
||||
|
||||
static Align computeLoadStoreDefaultAlign(Type *Ty, Instruction *I) {
|
||||
assert(I && "Insertion position cannot be null when alignment not provided!");
|
||||
return computeLoadStoreDefaultAlign(Ty, I->getParent());
|
||||
}
|
||||
|
||||
LoadInst::LoadInst(Type *Ty, Value *Ptr, const Twine &Name,
|
||||
BasicBlock::iterator InsertBef)
|
||||
: LoadInst(Ty, Ptr, Name, /*isVolatile=*/false, InsertBef) {}
|
||||
|
||||
LoadInst::LoadInst(Type *Ty, Value *Ptr, const Twine &Name,
|
||||
Instruction *InsertBef)
|
||||
: LoadInst(Ty, Ptr, Name, /*isVolatile=*/false, InsertBef) {}
|
||||
@@ -1404,6 +1528,11 @@ LoadInst::LoadInst(Type *Ty, Value *Ptr, const Twine &Name,
|
||||
BasicBlock *InsertAE)
|
||||
: LoadInst(Ty, Ptr, Name, /*isVolatile=*/false, InsertAE) {}
|
||||
|
||||
LoadInst::LoadInst(Type *Ty, Value *Ptr, const Twine &Name, bool isVolatile,
|
||||
BasicBlock::iterator InsertBef)
|
||||
: LoadInst(Ty, Ptr, Name, isVolatile,
|
||||
computeLoadStoreDefaultAlign(Ty, InsertBef), InsertBef) {}
|
||||
|
||||
LoadInst::LoadInst(Type *Ty, Value *Ptr, const Twine &Name, bool isVolatile,
|
||||
Instruction *InsertBef)
|
||||
: LoadInst(Ty, Ptr, Name, isVolatile,
|
||||
@@ -1414,6 +1543,11 @@ LoadInst::LoadInst(Type *Ty, Value *Ptr, const Twine &Name, bool isVolatile,
|
||||
: LoadInst(Ty, Ptr, Name, isVolatile,
|
||||
computeLoadStoreDefaultAlign(Ty, InsertAE), InsertAE) {}
|
||||
|
||||
LoadInst::LoadInst(Type *Ty, Value *Ptr, const Twine &Name, bool isVolatile,
|
||||
Align Align, BasicBlock::iterator InsertBef)
|
||||
: LoadInst(Ty, Ptr, Name, isVolatile, Align, AtomicOrdering::NotAtomic,
|
||||
SyncScope::System, InsertBef) {}
|
||||
|
||||
LoadInst::LoadInst(Type *Ty, Value *Ptr, const Twine &Name, bool isVolatile,
|
||||
Align Align, Instruction *InsertBef)
|
||||
: LoadInst(Ty, Ptr, Name, isVolatile, Align, AtomicOrdering::NotAtomic,
|
||||
@@ -1424,6 +1558,17 @@ LoadInst::LoadInst(Type *Ty, Value *Ptr, const Twine &Name, bool isVolatile,
|
||||
: LoadInst(Ty, Ptr, Name, isVolatile, Align, AtomicOrdering::NotAtomic,
|
||||
SyncScope::System, InsertAE) {}
|
||||
|
||||
LoadInst::LoadInst(Type *Ty, Value *Ptr, const Twine &Name, bool isVolatile,
|
||||
Align Align, AtomicOrdering Order, SyncScope::ID SSID,
|
||||
BasicBlock::iterator InsertBef)
|
||||
: UnaryInstruction(Ty, Load, Ptr, InsertBef) {
|
||||
setVolatile(isVolatile);
|
||||
setAlignment(Align);
|
||||
setAtomic(Order, SSID);
|
||||
AssertOK();
|
||||
setName(Name);
|
||||
}
|
||||
|
||||
LoadInst::LoadInst(Type *Ty, Value *Ptr, const Twine &Name, bool isVolatile,
|
||||
Align Align, AtomicOrdering Order, SyncScope::ID SSID,
|
||||
Instruction *InsertBef)
|
||||
@@ -1565,6 +1710,19 @@ void AtomicCmpXchgInst::Init(Value *Ptr, Value *Cmp, Value *NewVal,
|
||||
"Cmp type and NewVal type must be same!");
|
||||
}
|
||||
|
||||
AtomicCmpXchgInst::AtomicCmpXchgInst(Value *Ptr, Value *Cmp, Value *NewVal,
|
||||
Align Alignment,
|
||||
AtomicOrdering SuccessOrdering,
|
||||
AtomicOrdering FailureOrdering,
|
||||
SyncScope::ID SSID,
|
||||
BasicBlock::iterator InsertBefore)
|
||||
: Instruction(
|
||||
StructType::get(Cmp->getType(), Type::getInt1Ty(Cmp->getContext())),
|
||||
AtomicCmpXchg, OperandTraits<AtomicCmpXchgInst>::op_begin(this),
|
||||
OperandTraits<AtomicCmpXchgInst>::operands(this), InsertBefore) {
|
||||
Init(Ptr, Cmp, NewVal, Alignment, SuccessOrdering, FailureOrdering, SSID);
|
||||
}
|
||||
|
||||
AtomicCmpXchgInst::AtomicCmpXchgInst(Value *Ptr, Value *Cmp, Value *NewVal,
|
||||
Align Alignment,
|
||||
AtomicOrdering SuccessOrdering,
|
||||
@@ -1617,6 +1775,16 @@ void AtomicRMWInst::Init(BinOp Operation, Value *Ptr, Value *Val,
|
||||
"AtomicRMW instructions must be atomic!");
|
||||
}
|
||||
|
||||
AtomicRMWInst::AtomicRMWInst(BinOp Operation, Value *Ptr, Value *Val,
|
||||
Align Alignment, AtomicOrdering Ordering,
|
||||
SyncScope::ID SSID,
|
||||
BasicBlock::iterator InsertBefore)
|
||||
: Instruction(Val->getType(), AtomicRMW,
|
||||
OperandTraits<AtomicRMWInst>::op_begin(this),
|
||||
OperandTraits<AtomicRMWInst>::operands(this), InsertBefore) {
|
||||
Init(Operation, Ptr, Val, Alignment, Ordering, SSID);
|
||||
}
|
||||
|
||||
AtomicRMWInst::AtomicRMWInst(BinOp Operation, Value *Ptr, Value *Val,
|
||||
Align Alignment, AtomicOrdering Ordering,
|
||||
SyncScope::ID SSID, Instruction *InsertBefore)
|
||||
@@ -1682,6 +1850,13 @@ StringRef AtomicRMWInst::getOperationName(BinOp Op) {
|
||||
// FenceInst Implementation
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
FenceInst::FenceInst(LLVMContext &C, AtomicOrdering Ordering,
|
||||
SyncScope::ID SSID, BasicBlock::iterator InsertBefore)
|
||||
: Instruction(Type::getVoidTy(C), Fence, nullptr, 0, InsertBefore) {
|
||||
setOrdering(Ordering);
|
||||
setSyncScopeID(SSID);
|
||||
}
|
||||
|
||||
FenceInst::FenceInst(LLVMContext &C, AtomicOrdering Ordering,
|
||||
SyncScope::ID SSID,
|
||||
Instruction *InsertBefore)
|
||||
@@ -1827,6 +2002,19 @@ bool GetElementPtrInst::collectOffset(
|
||||
// ExtractElementInst Implementation
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
ExtractElementInst::ExtractElementInst(Value *Val, Value *Index,
|
||||
const Twine &Name,
|
||||
BasicBlock::iterator InsertBef)
|
||||
: Instruction(
|
||||
cast<VectorType>(Val->getType())->getElementType(), ExtractElement,
|
||||
OperandTraits<ExtractElementInst>::op_begin(this), 2, InsertBef) {
|
||||
assert(isValidOperands(Val, Index) &&
|
||||
"Invalid extractelement instruction operands!");
|
||||
Op<0>() = Val;
|
||||
Op<1>() = Index;
|
||||
setName(Name);
|
||||
}
|
||||
|
||||
ExtractElementInst::ExtractElementInst(Value *Val, Value *Index,
|
||||
const Twine &Name,
|
||||
Instruction *InsertBef)
|
||||
@@ -1866,6 +2054,20 @@ bool ExtractElementInst::isValidOperands(const Value *Val, const Value *Index) {
|
||||
// InsertElementInst Implementation
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
InsertElementInst::InsertElementInst(Value *Vec, Value *Elt, Value *Index,
|
||||
const Twine &Name,
|
||||
BasicBlock::iterator InsertBef)
|
||||
: Instruction(Vec->getType(), InsertElement,
|
||||
OperandTraits<InsertElementInst>::op_begin(this), 3,
|
||||
InsertBef) {
|
||||
assert(isValidOperands(Vec, Elt, Index) &&
|
||||
"Invalid insertelement instruction operands!");
|
||||
Op<0>() = Vec;
|
||||
Op<1>() = Elt;
|
||||
Op<2>() = Index;
|
||||
setName(Name);
|
||||
}
|
||||
|
||||
InsertElementInst::InsertElementInst(Value *Vec, Value *Elt, Value *Index,
|
||||
const Twine &Name,
|
||||
Instruction *InsertBef)
|
||||
@@ -1917,6 +2119,11 @@ static Value *createPlaceholderForShuffleVector(Value *V) {
|
||||
return PoisonValue::get(V->getType());
|
||||
}
|
||||
|
||||
ShuffleVectorInst::ShuffleVectorInst(Value *V1, Value *Mask, const Twine &Name,
|
||||
BasicBlock::iterator InsertBefore)
|
||||
: ShuffleVectorInst(V1, createPlaceholderForShuffleVector(V1), Mask, Name,
|
||||
InsertBefore) {}
|
||||
|
||||
ShuffleVectorInst::ShuffleVectorInst(Value *V1, Value *Mask, const Twine &Name,
|
||||
Instruction *InsertBefore)
|
||||
: ShuffleVectorInst(V1, createPlaceholderForShuffleVector(V1), Mask, Name,
|
||||
@@ -1927,6 +2134,12 @@ ShuffleVectorInst::ShuffleVectorInst(Value *V1, Value *Mask, const Twine &Name,
|
||||
: ShuffleVectorInst(V1, createPlaceholderForShuffleVector(V1), Mask, Name,
|
||||
InsertAtEnd) {}
|
||||
|
||||
ShuffleVectorInst::ShuffleVectorInst(Value *V1, ArrayRef<int> Mask,
|
||||
const Twine &Name,
|
||||
BasicBlock::iterator InsertBefore)
|
||||
: ShuffleVectorInst(V1, createPlaceholderForShuffleVector(V1), Mask, Name,
|
||||
InsertBefore) {}
|
||||
|
||||
ShuffleVectorInst::ShuffleVectorInst(Value *V1, ArrayRef<int> Mask,
|
||||
const Twine &Name,
|
||||
Instruction *InsertBefore)
|
||||
@@ -1938,6 +2151,25 @@ ShuffleVectorInst::ShuffleVectorInst(Value *V1, ArrayRef<int> Mask,
|
||||
: ShuffleVectorInst(V1, createPlaceholderForShuffleVector(V1), Mask, Name,
|
||||
InsertAtEnd) {}
|
||||
|
||||
ShuffleVectorInst::ShuffleVectorInst(Value *V1, Value *V2, Value *Mask,
|
||||
const Twine &Name,
|
||||
BasicBlock::iterator InsertBefore)
|
||||
: Instruction(
|
||||
VectorType::get(cast<VectorType>(V1->getType())->getElementType(),
|
||||
cast<VectorType>(Mask->getType())->getElementCount()),
|
||||
ShuffleVector, OperandTraits<ShuffleVectorInst>::op_begin(this),
|
||||
OperandTraits<ShuffleVectorInst>::operands(this), InsertBefore) {
|
||||
assert(isValidOperands(V1, V2, Mask) &&
|
||||
"Invalid shuffle vector instruction operands!");
|
||||
|
||||
Op<0>() = V1;
|
||||
Op<1>() = V2;
|
||||
SmallVector<int, 16> MaskArr;
|
||||
getShuffleMask(cast<Constant>(Mask), MaskArr);
|
||||
setShuffleMask(MaskArr);
|
||||
setName(Name);
|
||||
}
|
||||
|
||||
ShuffleVectorInst::ShuffleVectorInst(Value *V1, Value *V2, Value *Mask,
|
||||
const Twine &Name,
|
||||
Instruction *InsertBefore)
|
||||
@@ -1975,6 +2207,22 @@ ShuffleVectorInst::ShuffleVectorInst(Value *V1, Value *V2, Value *Mask,
|
||||
setName(Name);
|
||||
}
|
||||
|
||||
ShuffleVectorInst::ShuffleVectorInst(Value *V1, Value *V2, ArrayRef<int> Mask,
|
||||
const Twine &Name,
|
||||
BasicBlock::iterator InsertBefore)
|
||||
: Instruction(
|
||||
VectorType::get(cast<VectorType>(V1->getType())->getElementType(),
|
||||
Mask.size(), isa<ScalableVectorType>(V1->getType())),
|
||||
ShuffleVector, OperandTraits<ShuffleVectorInst>::op_begin(this),
|
||||
OperandTraits<ShuffleVectorInst>::operands(this), InsertBefore) {
|
||||
assert(isValidOperands(V1, V2, Mask) &&
|
||||
"Invalid shuffle vector instruction operands!");
|
||||
Op<0>() = V1;
|
||||
Op<1>() = V2;
|
||||
setShuffleMask(Mask);
|
||||
setName(Name);
|
||||
}
|
||||
|
||||
ShuffleVectorInst::ShuffleVectorInst(Value *V1, Value *V2, ArrayRef<int> Mask,
|
||||
const Twine &Name,
|
||||
Instruction *InsertBefore)
|
||||
@@ -2802,6 +3050,15 @@ Type *ExtractValueInst::getIndexedType(Type *Agg,
|
||||
// UnaryOperator Class
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
UnaryOperator::UnaryOperator(UnaryOps iType, Value *S, Type *Ty,
|
||||
const Twine &Name,
|
||||
BasicBlock::iterator InsertBefore)
|
||||
: UnaryInstruction(Ty, iType, S, InsertBefore) {
|
||||
Op<0>() = S;
|
||||
setName(Name);
|
||||
AssertOK();
|
||||
}
|
||||
|
||||
UnaryOperator::UnaryOperator(UnaryOps iType, Value *S,
|
||||
Type *Ty, const Twine &Name,
|
||||
Instruction *InsertBefore)
|
||||
@@ -2820,6 +3077,11 @@ UnaryOperator::UnaryOperator(UnaryOps iType, Value *S,
|
||||
AssertOK();
|
||||
}
|
||||
|
||||
UnaryOperator *UnaryOperator::Create(UnaryOps Op, Value *S, const Twine &Name,
|
||||
BasicBlock::iterator InsertBefore) {
|
||||
return new UnaryOperator(Op, S, S->getType(), Name, InsertBefore);
|
||||
}
|
||||
|
||||
UnaryOperator *UnaryOperator::Create(UnaryOps Op, Value *S,
|
||||
const Twine &Name,
|
||||
Instruction *InsertBefore) {
|
||||
@@ -2855,6 +3117,17 @@ void UnaryOperator::AssertOK() {
|
||||
// BinaryOperator Class
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
BinaryOperator::BinaryOperator(BinaryOps iType, Value *S1, Value *S2, Type *Ty,
|
||||
const Twine &Name,
|
||||
BasicBlock::iterator InsertBefore)
|
||||
: Instruction(Ty, iType, OperandTraits<BinaryOperator>::op_begin(this),
|
||||
OperandTraits<BinaryOperator>::operands(this), InsertBefore) {
|
||||
Op<0>() = S1;
|
||||
Op<1>() = S2;
|
||||
setName(Name);
|
||||
AssertOK();
|
||||
}
|
||||
|
||||
BinaryOperator::BinaryOperator(BinaryOps iType, Value *S1, Value *S2,
|
||||
Type *Ty, const Twine &Name,
|
||||
Instruction *InsertBefore)
|
||||
@@ -2965,6 +3238,13 @@ BinaryOperator *BinaryOperator::Create(BinaryOps Op, Value *S1, Value *S2,
|
||||
return Res;
|
||||
}
|
||||
|
||||
BinaryOperator *BinaryOperator::CreateNeg(Value *Op, const Twine &Name,
|
||||
BasicBlock::iterator InsertBefore) {
|
||||
Value *Zero = ConstantInt::get(Op->getType(), 0);
|
||||
return new BinaryOperator(Instruction::Sub, Zero, Op, Op->getType(), Name,
|
||||
InsertBefore);
|
||||
}
|
||||
|
||||
BinaryOperator *BinaryOperator::CreateNeg(Value *Op, const Twine &Name,
|
||||
Instruction *InsertBefore) {
|
||||
Value *Zero = ConstantInt::get(Op->getType(), 0);
|
||||
@@ -3324,6 +3604,29 @@ unsigned CastInst::isEliminableCastPair(
|
||||
}
|
||||
}
|
||||
|
||||
CastInst *CastInst::Create(Instruction::CastOps op, Value *S, Type *Ty,
|
||||
const Twine &Name,
|
||||
BasicBlock::iterator InsertBefore) {
|
||||
assert(castIsValid(op, S, Ty) && "Invalid cast!");
|
||||
// Construct and return the appropriate CastInst subclass
|
||||
switch (op) {
|
||||
case Trunc: return new TruncInst (S, Ty, Name, InsertBefore);
|
||||
case ZExt: return new ZExtInst (S, Ty, Name, InsertBefore);
|
||||
case SExt: return new SExtInst (S, Ty, Name, InsertBefore);
|
||||
case FPTrunc: return new FPTruncInst (S, Ty, Name, InsertBefore);
|
||||
case FPExt: return new FPExtInst (S, Ty, Name, InsertBefore);
|
||||
case UIToFP: return new UIToFPInst (S, Ty, Name, InsertBefore);
|
||||
case SIToFP: return new SIToFPInst (S, Ty, Name, InsertBefore);
|
||||
case FPToUI: return new FPToUIInst (S, Ty, Name, InsertBefore);
|
||||
case FPToSI: return new FPToSIInst (S, Ty, Name, InsertBefore);
|
||||
case PtrToInt: return new PtrToIntInst (S, Ty, Name, InsertBefore);
|
||||
case IntToPtr: return new IntToPtrInst (S, Ty, Name, InsertBefore);
|
||||
case BitCast: return new BitCastInst (S, Ty, Name, InsertBefore);
|
||||
case AddrSpaceCast: return new AddrSpaceCastInst (S, Ty, Name, InsertBefore);
|
||||
default: llvm_unreachable("Invalid opcode provided");
|
||||
}
|
||||
}
|
||||
|
||||
CastInst *CastInst::Create(Instruction::CastOps op, Value *S, Type *Ty,
|
||||
const Twine &Name, Instruction *InsertBefore) {
|
||||
assert(castIsValid(op, S, Ty) && "Invalid cast!");
|
||||
@@ -3368,6 +3671,13 @@ CastInst *CastInst::Create(Instruction::CastOps op, Value *S, Type *Ty,
|
||||
}
|
||||
}
|
||||
|
||||
CastInst *CastInst::CreateZExtOrBitCast(Value *S, Type *Ty, const Twine &Name,
|
||||
BasicBlock::iterator InsertBefore) {
|
||||
if (S->getType()->getScalarSizeInBits() == Ty->getScalarSizeInBits())
|
||||
return Create(Instruction::BitCast, S, Ty, Name, InsertBefore);
|
||||
return Create(Instruction::ZExt, S, Ty, Name, InsertBefore);
|
||||
}
|
||||
|
||||
CastInst *CastInst::CreateZExtOrBitCast(Value *S, Type *Ty,
|
||||
const Twine &Name,
|
||||
Instruction *InsertBefore) {
|
||||
@@ -3384,6 +3694,13 @@ CastInst *CastInst::CreateZExtOrBitCast(Value *S, Type *Ty,
|
||||
return Create(Instruction::ZExt, S, Ty, Name, InsertAtEnd);
|
||||
}
|
||||
|
||||
CastInst *CastInst::CreateSExtOrBitCast(Value *S, Type *Ty, const Twine &Name,
|
||||
BasicBlock::iterator InsertBefore) {
|
||||
if (S->getType()->getScalarSizeInBits() == Ty->getScalarSizeInBits())
|
||||
return Create(Instruction::BitCast, S, Ty, Name, InsertBefore);
|
||||
return Create(Instruction::SExt, S, Ty, Name, InsertBefore);
|
||||
}
|
||||
|
||||
CastInst *CastInst::CreateSExtOrBitCast(Value *S, Type *Ty,
|
||||
const Twine &Name,
|
||||
Instruction *InsertBefore) {
|
||||
@@ -3400,6 +3717,13 @@ CastInst *CastInst::CreateSExtOrBitCast(Value *S, Type *Ty,
|
||||
return Create(Instruction::SExt, S, Ty, Name, InsertAtEnd);
|
||||
}
|
||||
|
||||
CastInst *CastInst::CreateTruncOrBitCast(Value *S, Type *Ty, const Twine &Name,
|
||||
BasicBlock::iterator InsertBefore) {
|
||||
if (S->getType()->getScalarSizeInBits() == Ty->getScalarSizeInBits())
|
||||
return Create(Instruction::BitCast, S, Ty, Name, InsertBefore);
|
||||
return Create(Instruction::Trunc, S, Ty, Name, InsertBefore);
|
||||
}
|
||||
|
||||
CastInst *CastInst::CreateTruncOrBitCast(Value *S, Type *Ty,
|
||||
const Twine &Name,
|
||||
Instruction *InsertBefore) {
|
||||
@@ -3435,8 +3759,25 @@ CastInst *CastInst::CreatePointerCast(Value *S, Type *Ty,
|
||||
}
|
||||
|
||||
/// Create a BitCast or a PtrToInt cast instruction
|
||||
CastInst *CastInst::CreatePointerCast(Value *S, Type *Ty,
|
||||
const Twine &Name,
|
||||
CastInst *CastInst::CreatePointerCast(Value *S, Type *Ty, const Twine &Name,
|
||||
BasicBlock::iterator InsertBefore) {
|
||||
assert(S->getType()->isPtrOrPtrVectorTy() && "Invalid cast");
|
||||
assert((Ty->isIntOrIntVectorTy() || Ty->isPtrOrPtrVectorTy()) &&
|
||||
"Invalid cast");
|
||||
assert(Ty->isVectorTy() == S->getType()->isVectorTy() && "Invalid cast");
|
||||
assert((!Ty->isVectorTy() ||
|
||||
cast<VectorType>(Ty)->getElementCount() ==
|
||||
cast<VectorType>(S->getType())->getElementCount()) &&
|
||||
"Invalid cast");
|
||||
|
||||
if (Ty->isIntOrIntVectorTy())
|
||||
return Create(Instruction::PtrToInt, S, Ty, Name, InsertBefore);
|
||||
|
||||
return CreatePointerBitCastOrAddrSpaceCast(S, Ty, Name, InsertBefore);
|
||||
}
|
||||
|
||||
/// Create a BitCast or a PtrToInt cast instruction
|
||||
CastInst *CastInst::CreatePointerCast(Value *S, Type *Ty, const Twine &Name,
|
||||
Instruction *InsertBefore) {
|
||||
assert(S->getType()->isPtrOrPtrVectorTy() && "Invalid cast");
|
||||
assert((Ty->isIntOrIntVectorTy() || Ty->isPtrOrPtrVectorTy()) &&
|
||||
@@ -3467,9 +3808,18 @@ CastInst *CastInst::CreatePointerBitCastOrAddrSpaceCast(
|
||||
}
|
||||
|
||||
CastInst *CastInst::CreatePointerBitCastOrAddrSpaceCast(
|
||||
Value *S, Type *Ty,
|
||||
const Twine &Name,
|
||||
Instruction *InsertBefore) {
|
||||
Value *S, Type *Ty, const Twine &Name, BasicBlock::iterator InsertBefore) {
|
||||
assert(S->getType()->isPtrOrPtrVectorTy() && "Invalid cast");
|
||||
assert(Ty->isPtrOrPtrVectorTy() && "Invalid cast");
|
||||
|
||||
if (S->getType()->getPointerAddressSpace() != Ty->getPointerAddressSpace())
|
||||
return Create(Instruction::AddrSpaceCast, S, Ty, Name, InsertBefore);
|
||||
|
||||
return Create(Instruction::BitCast, S, Ty, Name, InsertBefore);
|
||||
}
|
||||
|
||||
CastInst *CastInst::CreatePointerBitCastOrAddrSpaceCast(
|
||||
Value *S, Type *Ty, const Twine &Name, Instruction *InsertBefore) {
|
||||
assert(S->getType()->isPtrOrPtrVectorTy() && "Invalid cast");
|
||||
assert(Ty->isPtrOrPtrVectorTy() && "Invalid cast");
|
||||
|
||||
@@ -3490,6 +3840,20 @@ CastInst *CastInst::CreateBitOrPointerCast(Value *S, Type *Ty,
|
||||
return Create(Instruction::BitCast, S, Ty, Name, InsertBefore);
|
||||
}
|
||||
|
||||
CastInst *CastInst::CreateIntegerCast(Value *C, Type *Ty, bool isSigned,
|
||||
const Twine &Name,
|
||||
BasicBlock::iterator InsertBefore) {
|
||||
assert(C->getType()->isIntOrIntVectorTy() && Ty->isIntOrIntVectorTy() &&
|
||||
"Invalid integer cast");
|
||||
unsigned SrcBits = C->getType()->getScalarSizeInBits();
|
||||
unsigned DstBits = Ty->getScalarSizeInBits();
|
||||
Instruction::CastOps opcode =
|
||||
(SrcBits == DstBits ? Instruction::BitCast :
|
||||
(SrcBits > DstBits ? Instruction::Trunc :
|
||||
(isSigned ? Instruction::SExt : Instruction::ZExt)));
|
||||
return Create(opcode, C, Ty, Name, InsertBefore);
|
||||
}
|
||||
|
||||
CastInst *CastInst::CreateIntegerCast(Value *C, Type *Ty,
|
||||
bool isSigned, const Twine &Name,
|
||||
Instruction *InsertBefore) {
|
||||
@@ -3518,6 +3882,18 @@ CastInst *CastInst::CreateIntegerCast(Value *C, Type *Ty,
|
||||
return Create(opcode, C, Ty, Name, InsertAtEnd);
|
||||
}
|
||||
|
||||
CastInst *CastInst::CreateFPCast(Value *C, Type *Ty, const Twine &Name,
|
||||
BasicBlock::iterator InsertBefore) {
|
||||
assert(C->getType()->isFPOrFPVectorTy() && Ty->isFPOrFPVectorTy() &&
|
||||
"Invalid cast");
|
||||
unsigned SrcBits = C->getType()->getScalarSizeInBits();
|
||||
unsigned DstBits = Ty->getScalarSizeInBits();
|
||||
Instruction::CastOps opcode =
|
||||
(SrcBits == DstBits ? Instruction::BitCast :
|
||||
(SrcBits > DstBits ? Instruction::FPTrunc : Instruction::FPExt));
|
||||
return Create(opcode, C, Ty, Name, InsertBefore);
|
||||
}
|
||||
|
||||
CastInst *CastInst::CreateFPCast(Value *C, Type *Ty,
|
||||
const Twine &Name,
|
||||
Instruction *InsertBefore) {
|
||||
@@ -3809,6 +4185,12 @@ CastInst::castIsValid(Instruction::CastOps op, Type *SrcTy, Type *DstTy) {
|
||||
}
|
||||
}
|
||||
|
||||
TruncInst::TruncInst(Value *S, Type *Ty, const Twine &Name,
|
||||
BasicBlock::iterator InsertBefore)
|
||||
: CastInst(Ty, Trunc, S, Name, InsertBefore) {
|
||||
assert(castIsValid(getOpcode(), S, Ty) && "Illegal Trunc");
|
||||
}
|
||||
|
||||
TruncInst::TruncInst(
|
||||
Value *S, Type *Ty, const Twine &Name, Instruction *InsertBefore
|
||||
) : CastInst(Ty, Trunc, S, Name, InsertBefore) {
|
||||
@@ -3821,6 +4203,12 @@ TruncInst::TruncInst(
|
||||
assert(castIsValid(getOpcode(), S, Ty) && "Illegal Trunc");
|
||||
}
|
||||
|
||||
ZExtInst::ZExtInst(Value *S, Type *Ty, const Twine &Name,
|
||||
BasicBlock::iterator InsertBefore)
|
||||
: CastInst(Ty, ZExt, S, Name, InsertBefore) {
|
||||
assert(castIsValid(getOpcode(), S, Ty) && "Illegal ZExt");
|
||||
}
|
||||
|
||||
ZExtInst::ZExtInst(
|
||||
Value *S, Type *Ty, const Twine &Name, Instruction *InsertBefore
|
||||
) : CastInst(Ty, ZExt, S, Name, InsertBefore) {
|
||||
@@ -3832,6 +4220,13 @@ ZExtInst::ZExtInst(
|
||||
) : CastInst(Ty, ZExt, S, Name, InsertAtEnd) {
|
||||
assert(castIsValid(getOpcode(), S, Ty) && "Illegal ZExt");
|
||||
}
|
||||
|
||||
SExtInst::SExtInst(Value *S, Type *Ty, const Twine &Name,
|
||||
BasicBlock::iterator InsertBefore)
|
||||
: CastInst(Ty, SExt, S, Name, InsertBefore) {
|
||||
assert(castIsValid(getOpcode(), S, Ty) && "Illegal SExt");
|
||||
}
|
||||
|
||||
SExtInst::SExtInst(
|
||||
Value *S, Type *Ty, const Twine &Name, Instruction *InsertBefore
|
||||
) : CastInst(Ty, SExt, S, Name, InsertBefore) {
|
||||
@@ -3844,6 +4239,12 @@ SExtInst::SExtInst(
|
||||
assert(castIsValid(getOpcode(), S, Ty) && "Illegal SExt");
|
||||
}
|
||||
|
||||
FPTruncInst::FPTruncInst(Value *S, Type *Ty, const Twine &Name,
|
||||
BasicBlock::iterator InsertBefore)
|
||||
: CastInst(Ty, FPTrunc, S, Name, InsertBefore) {
|
||||
assert(castIsValid(getOpcode(), S, Ty) && "Illegal FPTrunc");
|
||||
}
|
||||
|
||||
FPTruncInst::FPTruncInst(
|
||||
Value *S, Type *Ty, const Twine &Name, Instruction *InsertBefore
|
||||
) : CastInst(Ty, FPTrunc, S, Name, InsertBefore) {
|
||||
@@ -3856,6 +4257,12 @@ FPTruncInst::FPTruncInst(
|
||||
assert(castIsValid(getOpcode(), S, Ty) && "Illegal FPTrunc");
|
||||
}
|
||||
|
||||
FPExtInst::FPExtInst(Value *S, Type *Ty, const Twine &Name,
|
||||
BasicBlock::iterator InsertBefore)
|
||||
: CastInst(Ty, FPExt, S, Name, InsertBefore) {
|
||||
assert(castIsValid(getOpcode(), S, Ty) && "Illegal FPExt");
|
||||
}
|
||||
|
||||
FPExtInst::FPExtInst(
|
||||
Value *S, Type *Ty, const Twine &Name, Instruction *InsertBefore
|
||||
) : CastInst(Ty, FPExt, S, Name, InsertBefore) {
|
||||
@@ -3868,6 +4275,12 @@ FPExtInst::FPExtInst(
|
||||
assert(castIsValid(getOpcode(), S, Ty) && "Illegal FPExt");
|
||||
}
|
||||
|
||||
UIToFPInst::UIToFPInst(Value *S, Type *Ty, const Twine &Name,
|
||||
BasicBlock::iterator InsertBefore)
|
||||
: CastInst(Ty, UIToFP, S, Name, InsertBefore) {
|
||||
assert(castIsValid(getOpcode(), S, Ty) && "Illegal UIToFP");
|
||||
}
|
||||
|
||||
UIToFPInst::UIToFPInst(
|
||||
Value *S, Type *Ty, const Twine &Name, Instruction *InsertBefore
|
||||
) : CastInst(Ty, UIToFP, S, Name, InsertBefore) {
|
||||
@@ -3880,6 +4293,12 @@ UIToFPInst::UIToFPInst(
|
||||
assert(castIsValid(getOpcode(), S, Ty) && "Illegal UIToFP");
|
||||
}
|
||||
|
||||
SIToFPInst::SIToFPInst(Value *S, Type *Ty, const Twine &Name,
|
||||
BasicBlock::iterator InsertBefore)
|
||||
: CastInst(Ty, SIToFP, S, Name, InsertBefore) {
|
||||
assert(castIsValid(getOpcode(), S, Ty) && "Illegal SIToFP");
|
||||
}
|
||||
|
||||
SIToFPInst::SIToFPInst(
|
||||
Value *S, Type *Ty, const Twine &Name, Instruction *InsertBefore
|
||||
) : CastInst(Ty, SIToFP, S, Name, InsertBefore) {
|
||||
@@ -3892,6 +4311,12 @@ SIToFPInst::SIToFPInst(
|
||||
assert(castIsValid(getOpcode(), S, Ty) && "Illegal SIToFP");
|
||||
}
|
||||
|
||||
FPToUIInst::FPToUIInst(Value *S, Type *Ty, const Twine &Name,
|
||||
BasicBlock::iterator InsertBefore)
|
||||
: CastInst(Ty, FPToUI, S, Name, InsertBefore) {
|
||||
assert(castIsValid(getOpcode(), S, Ty) && "Illegal FPToUI");
|
||||
}
|
||||
|
||||
FPToUIInst::FPToUIInst(
|
||||
Value *S, Type *Ty, const Twine &Name, Instruction *InsertBefore
|
||||
) : CastInst(Ty, FPToUI, S, Name, InsertBefore) {
|
||||
@@ -3904,6 +4329,12 @@ FPToUIInst::FPToUIInst(
|
||||
assert(castIsValid(getOpcode(), S, Ty) && "Illegal FPToUI");
|
||||
}
|
||||
|
||||
FPToSIInst::FPToSIInst(Value *S, Type *Ty, const Twine &Name,
|
||||
BasicBlock::iterator InsertBefore)
|
||||
: CastInst(Ty, FPToSI, S, Name, InsertBefore) {
|
||||
assert(castIsValid(getOpcode(), S, Ty) && "Illegal FPToSI");
|
||||
}
|
||||
|
||||
FPToSIInst::FPToSIInst(
|
||||
Value *S, Type *Ty, const Twine &Name, Instruction *InsertBefore
|
||||
) : CastInst(Ty, FPToSI, S, Name, InsertBefore) {
|
||||
@@ -3916,6 +4347,12 @@ FPToSIInst::FPToSIInst(
|
||||
assert(castIsValid(getOpcode(), S, Ty) && "Illegal FPToSI");
|
||||
}
|
||||
|
||||
PtrToIntInst::PtrToIntInst(Value *S, Type *Ty, const Twine &Name,
|
||||
BasicBlock::iterator InsertBefore)
|
||||
: CastInst(Ty, PtrToInt, S, Name, InsertBefore) {
|
||||
assert(castIsValid(getOpcode(), S, Ty) && "Illegal PtrToInt");
|
||||
}
|
||||
|
||||
PtrToIntInst::PtrToIntInst(
|
||||
Value *S, Type *Ty, const Twine &Name, Instruction *InsertBefore
|
||||
) : CastInst(Ty, PtrToInt, S, Name, InsertBefore) {
|
||||
@@ -3928,6 +4365,12 @@ PtrToIntInst::PtrToIntInst(
|
||||
assert(castIsValid(getOpcode(), S, Ty) && "Illegal PtrToInt");
|
||||
}
|
||||
|
||||
IntToPtrInst::IntToPtrInst(Value *S, Type *Ty, const Twine &Name,
|
||||
BasicBlock::iterator InsertBefore)
|
||||
: CastInst(Ty, IntToPtr, S, Name, InsertBefore) {
|
||||
assert(castIsValid(getOpcode(), S, Ty) && "Illegal IntToPtr");
|
||||
}
|
||||
|
||||
IntToPtrInst::IntToPtrInst(
|
||||
Value *S, Type *Ty, const Twine &Name, Instruction *InsertBefore
|
||||
) : CastInst(Ty, IntToPtr, S, Name, InsertBefore) {
|
||||
@@ -3940,6 +4383,12 @@ IntToPtrInst::IntToPtrInst(
|
||||
assert(castIsValid(getOpcode(), S, Ty) && "Illegal IntToPtr");
|
||||
}
|
||||
|
||||
BitCastInst::BitCastInst(Value *S, Type *Ty, const Twine &Name,
|
||||
BasicBlock::iterator InsertBefore)
|
||||
: CastInst(Ty, BitCast, S, Name, InsertBefore) {
|
||||
assert(castIsValid(getOpcode(), S, Ty) && "Illegal BitCast");
|
||||
}
|
||||
|
||||
BitCastInst::BitCastInst(
|
||||
Value *S, Type *Ty, const Twine &Name, Instruction *InsertBefore
|
||||
) : CastInst(Ty, BitCast, S, Name, InsertBefore) {
|
||||
@@ -3952,6 +4401,12 @@ BitCastInst::BitCastInst(
|
||||
assert(castIsValid(getOpcode(), S, Ty) && "Illegal BitCast");
|
||||
}
|
||||
|
||||
AddrSpaceCastInst::AddrSpaceCastInst(Value *S, Type *Ty, const Twine &Name,
|
||||
BasicBlock::iterator InsertBefore)
|
||||
: CastInst(Ty, AddrSpaceCast, S, Name, InsertBefore) {
|
||||
assert(castIsValid(getOpcode(), S, Ty) && "Illegal AddrSpaceCast");
|
||||
}
|
||||
|
||||
AddrSpaceCastInst::AddrSpaceCastInst(
|
||||
Value *S, Type *Ty, const Twine &Name, Instruction *InsertBefore
|
||||
) : CastInst(Ty, AddrSpaceCast, S, Name, InsertBefore) {
|
||||
@@ -3968,6 +4423,19 @@ AddrSpaceCastInst::AddrSpaceCastInst(
|
||||
// CmpInst Classes
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
CmpInst::CmpInst(Type *ty, OtherOps op, Predicate predicate, Value *LHS,
|
||||
Value *RHS, const Twine &Name,
|
||||
BasicBlock::iterator InsertBefore, Instruction *FlagsSource)
|
||||
: Instruction(ty, op, OperandTraits<CmpInst>::op_begin(this),
|
||||
OperandTraits<CmpInst>::operands(this), InsertBefore) {
|
||||
Op<0>() = LHS;
|
||||
Op<1>() = RHS;
|
||||
setPredicate((Predicate)predicate);
|
||||
setName(Name);
|
||||
if (FlagsSource)
|
||||
copyIRFlags(FlagsSource);
|
||||
}
|
||||
|
||||
CmpInst::CmpInst(Type *ty, OtherOps op, Predicate predicate, Value *LHS,
|
||||
Value *RHS, const Twine &Name, Instruction *InsertBefore,
|
||||
Instruction *FlagsSource)
|
||||
@@ -4471,6 +4939,17 @@ void SwitchInst::init(Value *Value, BasicBlock *Default, unsigned NumReserved) {
|
||||
Op<1>() = Default;
|
||||
}
|
||||
|
||||
/// SwitchInst ctor - Create a new switch instruction, specifying a value to
|
||||
/// switch on and a default destination. The number of additional cases can
|
||||
/// be specified here to make memory allocation more efficient. This
|
||||
/// constructor can also autoinsert before another instruction.
|
||||
SwitchInst::SwitchInst(Value *Value, BasicBlock *Default, unsigned NumCases,
|
||||
BasicBlock::iterator InsertBefore)
|
||||
: Instruction(Type::getVoidTy(Value->getContext()), Instruction::Switch,
|
||||
nullptr, 0, InsertBefore) {
|
||||
init(Value, Default, 2 + NumCases * 2);
|
||||
}
|
||||
|
||||
/// SwitchInst ctor - Create a new switch instruction, specifying a value to
|
||||
/// switch on and a default destination. The number of additional cases can
|
||||
/// be specified here to make memory allocation more efficient. This
|
||||
@@ -4693,6 +5172,13 @@ void IndirectBrInst::growOperands() {
|
||||
growHungoffUses(ReservedSpace);
|
||||
}
|
||||
|
||||
IndirectBrInst::IndirectBrInst(Value *Address, unsigned NumCases,
|
||||
BasicBlock::iterator InsertBefore)
|
||||
: Instruction(Type::getVoidTy(Address->getContext()),
|
||||
Instruction::IndirectBr, nullptr, 0, InsertBefore) {
|
||||
init(Address, NumCases);
|
||||
}
|
||||
|
||||
IndirectBrInst::IndirectBrInst(Value *Address, unsigned NumCases,
|
||||
Instruction *InsertBefore)
|
||||
: Instruction(Type::getVoidTy(Address->getContext()),
|
||||
@@ -4750,6 +5236,12 @@ void IndirectBrInst::removeDestination(unsigned idx) {
|
||||
// FreezeInst Implementation
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
FreezeInst::FreezeInst(Value *S, const Twine &Name,
|
||||
BasicBlock::iterator InsertBefore)
|
||||
: UnaryInstruction(S->getType(), Freeze, S, InsertBefore) {
|
||||
setName(Name);
|
||||
}
|
||||
|
||||
FreezeInst::FreezeInst(Value *S,
|
||||
const Twine &Name, Instruction *InsertBefore)
|
||||
: UnaryInstruction(S->getType(), Freeze, S, InsertBefore) {
|
||||
|
||||
Reference in new issue
Block a user