protected:
TerminatorInst(Type *Ty, Instruction::TermOps iType,
Use *Ops, unsigned NumOps,
- Instruction *InsertBefore = 0)
+ Instruction *InsertBefore = nullptr)
: Instruction(Ty, iType, Ops, NumOps, InsertBefore) {}
TerminatorInst(Type *Ty, Instruction::TermOps iType,
virtual BasicBlock *getSuccessorV(unsigned idx) const = 0;
virtual unsigned getNumSuccessorsV() const = 0;
virtual void setSuccessorV(unsigned idx, BasicBlock *B) = 0;
- virtual TerminatorInst *clone_impl() const = 0;
+ TerminatorInst *clone_impl() const override = 0;
public:
/// getNumSuccessors - Return the number of successors that this terminator
protected:
UnaryInstruction(Type *Ty, unsigned iType, Value *V,
- Instruction *IB = 0)
+ Instruction *IB = nullptr)
: Instruction(Ty, iType, &Op<0>(), 1, IB) {
Op<0>() = V;
}
const Twine &Name, Instruction *InsertBefore);
BinaryOperator(BinaryOps iType, Value *S1, Value *S2, Type *Ty,
const Twine &Name, BasicBlock *InsertAtEnd);
- virtual BinaryOperator *clone_impl() const LLVM_OVERRIDE;
+ BinaryOperator *clone_impl() const override;
public:
// allocate space for exactly two operands
void *operator new(size_t s) {
///
static BinaryOperator *Create(BinaryOps Op, Value *S1, Value *S2,
const Twine &Name = Twine(),
- Instruction *InsertBefore = 0);
+ Instruction *InsertBefore = nullptr);
/// Create() - Construct a binary instruction, given the opcode and the two
/// operands. Also automatically insert this instruction to the end of the
BO->setHasNoSignedWrap(true);
return BO;
}
-
+
static BinaryOperator *CreateNUW(BinaryOps Opc, Value *V1, Value *V2,
const Twine &Name = "") {
BinaryOperator *BO = Create(Opc, V1, V2, Name);
BO->setHasNoUnsignedWrap(true);
return BO;
}
-
+
static BinaryOperator *CreateExact(BinaryOps Opc, Value *V1, Value *V2,
const Twine &Name = "") {
BinaryOperator *BO = Create(Opc, V1, V2, Name);
BO->setIsExact(true);
return BO;
}
-
+
#define DEFINE_HELPERS(OPC, NUWNSWEXACT) \
static BinaryOperator *Create ## NUWNSWEXACT ## OPC \
(Value *V1, Value *V2, const Twine &Name = "") { \
(Value *V1, Value *V2, const Twine &Name, Instruction *I) { \
return Create ## NUWNSWEXACT(Instruction::OPC, V1, V2, Name, I); \
}
-
+
DEFINE_HELPERS(Add, NSW) // CreateNSWAdd
DEFINE_HELPERS(Add, NUW) // CreateNUWAdd
DEFINE_HELPERS(Sub, NSW) // CreateNSWSub
DEFINE_HELPERS(LShr, Exact) // CreateExactLShr
#undef DEFINE_HELPERS
-
+
/// Helper functions to construct and inspect unary operations (NEG and NOT)
/// via binary operators SUB and XOR:
///
/// instructions out of SUB and XOR instructions.
///
static BinaryOperator *CreateNeg(Value *Op, const Twine &Name = "",
- Instruction *InsertBefore = 0);
+ Instruction *InsertBefore = nullptr);
static BinaryOperator *CreateNeg(Value *Op, const Twine &Name,
BasicBlock *InsertAtEnd);
static BinaryOperator *CreateNSWNeg(Value *Op, const Twine &Name = "",
- Instruction *InsertBefore = 0);
+ Instruction *InsertBefore = nullptr);
static BinaryOperator *CreateNSWNeg(Value *Op, const Twine &Name,
BasicBlock *InsertAtEnd);
static BinaryOperator *CreateNUWNeg(Value *Op, const Twine &Name = "",
- Instruction *InsertBefore = 0);
+ Instruction *InsertBefore = nullptr);
static BinaryOperator *CreateNUWNeg(Value *Op, const Twine &Name,
BasicBlock *InsertAtEnd);
static BinaryOperator *CreateFNeg(Value *Op, const Twine &Name = "",
- Instruction *InsertBefore = 0);
+ Instruction *InsertBefore = nullptr);
static BinaryOperator *CreateFNeg(Value *Op, const Twine &Name,
BasicBlock *InsertAtEnd);
static BinaryOperator *CreateNot(Value *Op, const Twine &Name = "",
- Instruction *InsertBefore = 0);
+ Instruction *InsertBefore = nullptr);
static BinaryOperator *CreateNot(Value *Op, const Twine &Name,
BasicBlock *InsertAtEnd);
/// if (isa<CastInst>(Instr)) { ... }
/// @brief Base class of casting instructions.
class CastInst : public UnaryInstruction {
- virtual void anchor() LLVM_OVERRIDE;
+ void anchor() override;
protected:
/// @brief Constructor with insert-before-instruction semantics for subclasses
CastInst(Type *Ty, unsigned iType, Value *S,
- const Twine &NameStr = "", Instruction *InsertBefore = 0)
+ const Twine &NameStr = "", Instruction *InsertBefore = nullptr)
: UnaryInstruction(Ty, iType, S, InsertBefore) {
setName(NameStr);
}
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
- Instruction *InsertBefore = 0 ///< Place to insert the instruction
+ Instruction *InsertBefore = nullptr ///< 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
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
- Instruction *InsertBefore = 0 ///< Place to insert the instruction
+ Instruction *InsertBefore = nullptr ///< Place to insert the instruction
);
/// @brief Create a ZExt or BitCast 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
- Instruction *InsertBefore = 0 ///< Place to insert the instruction
+ Instruction *InsertBefore = nullptr ///< Place to insert the instruction
);
/// @brief Create a SExt or BitCast cast instruction
BasicBlock *InsertAtEnd ///< The block to insert the instruction into
);
- /// @brief Create a BitCast or a PtrToInt cast instruction
+ /// @brief 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 operand is casted
BasicBlock *InsertAtEnd ///< The block to insert the instruction into
);
- /// @brief Create a BitCast or a PtrToInt cast instruction
+ /// @brief 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
+ Instruction *InsertBefore = nullptr ///< Place to insert the instruction
+ );
+
+ /// @brief 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 operand is casted
+ const Twine &Name, ///< The name for the instruction
+ BasicBlock *InsertAtEnd ///< The block to insert the instruction into
+ );
+
+ /// @brief 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
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
- Instruction *InsertBefore = 0 ///< Place to insert the instruction
+ Instruction *InsertBefore = nullptr ///< Place to insert the instruction
);
/// @brief Create a ZExt, BitCast, or Trunc for int -> int casts.
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
- Instruction *InsertBefore = 0 ///< Place to insert the instruction
+ Instruction *InsertBefore = nullptr ///< Place to insert the instruction
);
/// @brief Create an FPExt, BitCast, or FPTrunc for fp -> fp casts
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
- Instruction *InsertBefore = 0 ///< Place to insert the instruction
+ Instruction *InsertBefore = nullptr ///< Place to insert the instruction
);
/// @brief Create a Trunc or BitCast cast instruction
BasicBlock *InsertAtEnd ///< The block to insert the instruction into
);
+ /// @brief Check whether it is valid to call getCastOpcode for these types.
+ static bool isCastable(
+ Type *SrcTy, ///< The Type from which the value should be cast.
+ Type *DestTy ///< The Type to which the value should be cast.
+ );
+
/// @brief Check whether a bitcast between these types is valid
static bool isBitCastable(
Type *SrcTy, ///< The Type from which the value should be cast.
Type *IntPtrTy ///< Integer type corresponding to pointer
) const;
+ /// @brief Determine if this cast is a no-op cast.
+ bool isNoopCast(
+ const DataLayout *DL ///< DataLayout to get the Int Ptr type from.
+ ) const;
+
/// Determine how a pair of casts can be eliminated, if they can be at all.
/// This is a helper function for both CastInst and ConstantExpr.
/// @returns 0 if the CastInst pair can't be eliminated, otherwise
protected:
CmpInst(Type *ty, Instruction::OtherOps op, unsigned short pred,
Value *LHS, Value *RHS, const Twine &Name = "",
- Instruction *InsertBefore = 0);
+ Instruction *InsertBefore = nullptr);
CmpInst(Type *ty, Instruction::OtherOps op, unsigned short pred,
Value *LHS, Value *RHS, const Twine &Name,
BasicBlock *InsertAtEnd);
- virtual void anchor() LLVM_OVERRIDE; // Out of line virtual method.
+ void anchor() override; // Out of line virtual method.
public:
/// This enumeration lists the possible predicates for CmpInst subclasses.
/// Values in the range 0-31 are reserved for FCmpInst, while values in the
static CmpInst *Create(OtherOps Op,
unsigned short predicate, Value *S1,
Value *S2, const Twine &Name = "",
- Instruction *InsertBefore = 0);
+ Instruction *InsertBefore = nullptr);
/// Construct a compare instruction, given the opcode, the predicate and the
/// two operands. Also automatically insert this instruction to the end of