diff options
author | Gabor Greif <ggreif@gmail.com> | 2008-05-16 19:29:10 +0000 |
---|---|---|
committer | Gabor Greif <ggreif@gmail.com> | 2008-05-16 19:29:10 +0000 |
commit | 7cbd8a3e92221437048b484d5ef9c0a22d0f8c58 (patch) | |
tree | 9c9985d8a294246ec942188ae322e6ce4b5d4efe | |
parent | 446efddfcd655131bd0ceeacce9c1166e30ed479 (diff) | |
download | external_llvm-7cbd8a3e92221437048b484d5ef9c0a22d0f8c58.zip external_llvm-7cbd8a3e92221437048b484d5ef9c0a22d0f8c58.tar.gz external_llvm-7cbd8a3e92221437048b484d5ef9c0a22d0f8c58.tar.bz2 |
API change for {BinaryOperator|CmpInst|CastInst}::create*() --> Create. Legacy interfaces will be in place for some time. (Merge from use-diet branch.)
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@51200 91177308-0d34-0410-b5e6-96231b3b80d8
31 files changed, 617 insertions, 524 deletions
diff --git a/examples/Fibonacci/fibonacci.cpp b/examples/Fibonacci/fibonacci.cpp index f5ef0d0..73dff11 100644 --- a/examples/Fibonacci/fibonacci.cpp +++ b/examples/Fibonacci/fibonacci.cpp @@ -66,18 +66,18 @@ static Function *CreateFibFunction(Module *M) { ReturnInst::Create(One, RetBB); // create fib(x-1) - Value *Sub = BinaryOperator::createSub(ArgX, One, "arg", RecurseBB); + Value *Sub = BinaryOperator::CreateSub(ArgX, One, "arg", RecurseBB); CallInst *CallFibX1 = CallInst::Create(FibF, Sub, "fibx1", RecurseBB); CallFibX1->setTailCall(); // create fib(x-2) - Sub = BinaryOperator::createSub(ArgX, Two, "arg", RecurseBB); + Sub = BinaryOperator::CreateSub(ArgX, Two, "arg", RecurseBB); CallInst *CallFibX2 = CallInst::Create(FibF, Sub, "fibx2", RecurseBB); CallFibX2->setTailCall(); // fib(x-1)+fib(x-2) - Value *Sum = BinaryOperator::createAdd(CallFibX1, CallFibX2, + Value *Sum = BinaryOperator::CreateAdd(CallFibX1, CallFibX2, "addresult", RecurseBB); // Create the return instruction and add it to the basic block diff --git a/examples/HowToUseJIT/HowToUseJIT.cpp b/examples/HowToUseJIT/HowToUseJIT.cpp index 2aba8e1..5fa4237 100644 --- a/examples/HowToUseJIT/HowToUseJIT.cpp +++ b/examples/HowToUseJIT/HowToUseJIT.cpp @@ -69,7 +69,7 @@ int main() { ArgX->setName("AnArg"); // Give it a nice symbolic name for fun. // Create the add instruction, inserting it into the end of BB. - Instruction *Add = BinaryOperator::createAdd(One, ArgX, "addresult", BB); + Instruction *Add = BinaryOperator::CreateAdd(One, ArgX, "addresult", BB); // Create the return instruction and add it to the basic block ReturnInst::Create(Add, BB); diff --git a/examples/ModuleMaker/ModuleMaker.cpp b/examples/ModuleMaker/ModuleMaker.cpp index 40d2fa9..154e240 100644 --- a/examples/ModuleMaker/ModuleMaker.cpp +++ b/examples/ModuleMaker/ModuleMaker.cpp @@ -43,7 +43,7 @@ int main() { Value *Three = ConstantInt::get(Type::Int32Ty, 3); // Create the add instruction... does not insert... - Instruction *Add = BinaryOperator::create(Instruction::Add, Two, Three, + Instruction *Add = BinaryOperator::Create(Instruction::Add, Two, Three, "addresult"); // explicitly insert it into the basic block... diff --git a/examples/ParallelJIT/ParallelJIT.cpp b/examples/ParallelJIT/ParallelJIT.cpp index 634bffa..e812d84 100644 --- a/examples/ParallelJIT/ParallelJIT.cpp +++ b/examples/ParallelJIT/ParallelJIT.cpp @@ -50,7 +50,7 @@ static Function* createAdd1(Module *M) { ArgX->setName("AnArg"); // Give it a nice symbolic name for fun. // Create the add instruction, inserting it into the end of BB. - Instruction *Add = BinaryOperator::createAdd(One, ArgX, "addresult", BB); + Instruction *Add = BinaryOperator::CreateAdd(One, ArgX, "addresult", BB); // Create the return instruction and add it to the basic block ReturnInst::Create(Add, BB); @@ -90,16 +90,16 @@ static Function *CreateFibFunction(Module *M) { ReturnInst::Create(One, RetBB); // create fib(x-1) - Value *Sub = BinaryOperator::createSub(ArgX, One, "arg", RecurseBB); + Value *Sub = BinaryOperator::CreateSub(ArgX, One, "arg", RecurseBB); Value *CallFibX1 = CallInst::Create(FibF, Sub, "fibx1", RecurseBB); // create fib(x-2) - Sub = BinaryOperator::createSub(ArgX, Two, "arg", RecurseBB); + Sub = BinaryOperator::CreateSub(ArgX, Two, "arg", RecurseBB); Value *CallFibX2 = CallInst::Create(FibF, Sub, "fibx2", RecurseBB); // fib(x-1)+fib(x-2) Value *Sum = - BinaryOperator::createAdd(CallFibX1, CallFibX2, "addresult", RecurseBB); + BinaryOperator::CreateAdd(CallFibX1, CallFibX2, "addresult", RecurseBB); // Create the return instruction and add it to the basic block ReturnInst::Create(Sum, RecurseBB); diff --git a/include/llvm/Analysis/ScalarEvolutionExpander.h b/include/llvm/Analysis/ScalarEvolutionExpander.h index 584e488..ed520f5 100644 --- a/include/llvm/Analysis/ScalarEvolutionExpander.h +++ b/include/llvm/Analysis/ScalarEvolutionExpander.h @@ -101,17 +101,17 @@ namespace llvm { Value *visitTruncateExpr(SCEVTruncateExpr *S) { Value *V = expand(S->getOperand()); - return CastInst::createTruncOrBitCast(V, S->getType(), "tmp.", InsertPt); + return CastInst::CreateTruncOrBitCast(V, S->getType(), "tmp.", InsertPt); } Value *visitZeroExtendExpr(SCEVZeroExtendExpr *S) { Value *V = expand(S->getOperand()); - return CastInst::createZExtOrBitCast(V, S->getType(), "tmp.", InsertPt); + return CastInst::CreateZExtOrBitCast(V, S->getType(), "tmp.", InsertPt); } Value *visitSignExtendExpr(SCEVSignExtendExpr *S) { Value *V = expand(S->getOperand()); - return CastInst::createSExtOrBitCast(V, S->getType(), "tmp.", InsertPt); + return CastInst::CreateSExtOrBitCast(V, S->getType(), "tmp.", InsertPt); } Value *visitAddExpr(SCEVAddExpr *S) { diff --git a/include/llvm/InstrTypes.h b/include/llvm/InstrTypes.h index a320ad0..3748b0c 100644 --- a/include/llvm/InstrTypes.h +++ b/include/llvm/InstrTypes.h @@ -152,42 +152,42 @@ public: /// Transparently provide more efficient getOperand methods. DECLARE_TRANSPARENT_OPERAND_ACCESSORS(Value); - /// create() - Construct a binary instruction, given the opcode and the two + /// Create() - 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 /// Instruction is allowed to be a dereferenced end iterator. /// - static BinaryOperator *create(BinaryOps Op, Value *S1, Value *S2, + static BinaryOperator *Create(BinaryOps Op, Value *S1, Value *S2, const std::string &Name = "", Instruction *InsertBefore = 0); - /// create() - Construct a binary instruction, given the opcode and the two + /// Create() - Construct a binary instruction, given the opcode and the two /// operands. Also automatically insert this instruction to the end of the /// BasicBlock specified. /// - static BinaryOperator *create(BinaryOps Op, Value *S1, Value *S2, + static BinaryOperator *Create(BinaryOps Op, Value *S1, Value *S2, const std::string &Name, BasicBlock *InsertAtEnd); - /// create* - These methods just forward to create, and are useful when you + /// Create* - These methods just forward to create, and are useful when you /// statically know what type of instruction you're going to create. These /// helpers just save some typing. #define HANDLE_BINARY_INST(N, OPC, CLASS) \ - static BinaryOperator *create##OPC(Value *V1, Value *V2, \ + static BinaryOperator *Create##OPC(Value *V1, Value *V2, \ const std::string &Name = "") {\ - return create(Instruction::OPC, V1, V2, Name);\ + return Create(Instruction::OPC, V1, V2, Name);\ } #include "llvm/Instruction.def" #define HANDLE_BINARY_INST(N, OPC, CLASS) \ - static BinaryOperator *create##OPC(Value *V1, Value *V2, \ + static BinaryOperator *Create##OPC(Value *V1, Value *V2, \ const std::string &Name, BasicBlock *BB) {\ - return create(Instruction::OPC, V1, V2, Name, BB);\ + return Create(Instruction::OPC, V1, V2, Name, BB);\ } #include "llvm/Instruction.def" #define HANDLE_BINARY_INST(N, OPC, CLASS) \ - static BinaryOperator *create##OPC(Value *V1, Value *V2, \ + static BinaryOperator *Create##OPC(Value *V1, Value *V2, \ const std::string &Name, Instruction *I) {\ - return create(Instruction::OPC, V1, V2, Name, I);\ + return Create(Instruction::OPC, V1, V2, Name, I);\ } #include "llvm/Instruction.def" @@ -195,16 +195,16 @@ public: /// Helper functions to construct and inspect unary operations (NEG and NOT) /// via binary operators SUB and XOR: /// - /// createNeg, createNot - Create the NEG and NOT + /// CreateNeg, CreateNot - Create the NEG and NOT /// instructions out of SUB and XOR instructions. /// - static BinaryOperator *createNeg(Value *Op, const std::string &Name = "", + static BinaryOperator *CreateNeg(Value *Op, const std::string &Name = "", Instruction *InsertBefore = 0); - static BinaryOperator *createNeg(Value *Op, const std::string &Name, + static BinaryOperator *CreateNeg(Value *Op, const std::string &Name, BasicBlock *InsertAtEnd); - static BinaryOperator *createNot(Value *Op, const std::string &Name = "", + static BinaryOperator *CreateNot(Value *Op, const std::string &Name = "", Instruction *InsertBefore = 0); - static BinaryOperator *createNot(Value *Op, const std::string &Name, + static BinaryOperator *CreateNot(Value *Op, const std::string &Name, BasicBlock *InsertAtEnd); /// isNeg, isNot - Check if the given Value is a NEG or NOT instruction. @@ -241,6 +241,53 @@ public: static inline bool classof(const Value *V) { return isa<Instruction>(V) && classof(cast<Instruction>(V)); } + + /// Backward-compatible interfaces + /// @deprecated in 2.4, do not use, will disappear soon + static BinaryOperator *create(BinaryOps Op, Value *S1, Value *S2, + const std::string &Name = "", + Instruction *InsertBefore = 0) { + return Create(Op, S1, S2, Name, InsertBefore); + } + static BinaryOperator *create(BinaryOps Op, Value *S1, Value *S2, + const std::string &Name, + BasicBlock *InsertAtEnd) { + return Create(Op, S1, S2, Name, InsertAtEnd); + } +#define HANDLE_BINARY_INST(N, OPC, CLASS) \ + static BinaryOperator *create##OPC(Value *V1, Value *V2, \ + const std::string &Name = "") {\ + return Create(Instruction::OPC, V1, V2, Name);\ + } +#include "llvm/Instruction.def" +#define HANDLE_BINARY_INST(N, OPC, CLASS) \ + static BinaryOperator *create##OPC(Value *V1, Value *V2, \ + const std::string &Name, BasicBlock *BB) {\ + return Create(Instruction::OPC, V1, V2, Name, BB);\ + } +#include "llvm/Instruction.def" +#define HANDLE_BINARY_INST(N, OPC, CLASS) \ + static BinaryOperator *create##OPC(Value *V1, Value *V2, \ + const std::string &Name, Instruction *I) {\ + return Create(Instruction::OPC, V1, V2, Name, I);\ + } +#include "llvm/Instruction.def" + static BinaryOperator *createNeg(Value *Op, const std::string &Name = "", + Instruction *InsertBefore = 0) { + return CreateNeg(Op, Name, InsertBefore); + } + static BinaryOperator *createNeg(Value *Op, const std::string &Name, + BasicBlock *InsertAtEnd) { + return CreateNeg(Op, Name, InsertAtEnd); + } + static BinaryOperator *createNot(Value *Op, const std::string &Name = "", + Instruction *InsertBefore = 0) { + return CreateNot(Op, Name, InsertBefore); + } + static BinaryOperator *createNot(Value *Op, const std::string &Name, + BasicBlock *InsertAtEnd) { + return CreateNot(Op, Name, InsertAtEnd); + } }; template <> @@ -286,7 +333,7 @@ public: /// constructor has insert-before-instruction semantics to automatically /// insert the new CastInst before InsertBefore (if it is non-null). /// @brief Construct any of the CastInst subclasses - static CastInst *create( + static CastInst *Create( Instruction::CastOps, ///< The opcode of the cast instruction Value *S, ///< The value to be casted (operand 0) const Type *Ty, ///< The type to which cast should be made @@ -299,7 +346,7 @@ public: /// to automatically insert the new CastInst at the end of InsertAtEnd (if /// its non-null). /// @brief Construct any of the CastInst subclasses - static CastInst *create( + static CastInst *Create( Instruction::CastOps, ///< The opcode for the cast instruction Value *S, ///< The value to be casted (operand 0) const Type *Ty, ///< The type to which operand is casted @@ -308,7 +355,7 @@ public: ); /// @brief Create a ZExt or BitCast cast instruction - static CastInst *createZExtOrBitCast( + static CastInst *CreateZExtOrBitCast( Value *S, ///< The value to be casted (operand 0) const Type *Ty, ///< The type to which cast should be made const std::string &Name = "", ///< Name for the instruction @@ -316,7 +363,7 @@ public: ); /// @brief Create a ZExt or BitCast cast instruction - static CastInst *createZExtOrBitCast( + static CastInst *CreateZExtOrBitCast( Value *S, ///< The value to be casted (operand 0) const Type *Ty, ///< The type to which operand is casted const std::string &Name, ///< The name for the instruction @@ -324,15 +371,23 @@ public: ); /// @brief Create a SExt or BitCast cast instruction - static CastInst *createSExtOrBitCast( + static CastInst *CreateSExtOrBitCast( Value *S, ///< The value to be casted (operand 0) const Type *Ty, ///< The type to which cast should be made const std::string &Name = "", ///< Name for the instruction Instruction *InsertBefore = 0 ///< Place to insert the instruction ); + /// @brief Create a SExt or BitCast cast instruction + static CastInst *CreateSExtOrBitCast( + Value *S, ///< The value to be casted (operand 0) + const Type *Ty, ///< The type to which operand is casted + const std::string &Name, ///< The name for the instruction + BasicBlock *InsertAtEnd ///< The block to insert the instruction into + ); + /// @brief Create a BitCast or a PtrToInt cast instruction - static CastInst *createPointerCast( + static CastInst *CreatePointerCast( Value *S, ///< The pointer value to be casted (operand 0) const Type *Ty, ///< The type to which operand is casted const std::string &Name, ///< The name for the instruction @@ -340,7 +395,7 @@ public: ); /// @brief Create a BitCast or a PtrToInt cast instruction - static CastInst *createPointerCast( + static CastInst *CreatePointerCast( Value *S, ///< The pointer value to be casted (operand 0) const Type *Ty, ///< The type to which cast should be made const std::string &Name = "", ///< Name for the instruction @@ -348,7 +403,7 @@ public: ); /// @brief Create a ZExt, BitCast, or Trunc for int -> int casts. - static CastInst *createIntegerCast( + static CastInst *CreateIntegerCast( Value *S, ///< The pointer value to be casted (operand 0) const Type *Ty, ///< The type to which cast should be made bool isSigned, ///< Whether to regard S as signed or not @@ -357,7 +412,7 @@ public: ); /// @brief Create a ZExt, BitCast, or Trunc for int -> int casts. - static CastInst *createIntegerCast( + static CastInst *CreateIntegerCast( Value *S, ///< The integer value to be casted (operand 0) const Type *Ty, ///< The integer type to which operand is casted bool isSigned, ///< Whether to regard S as signed or not @@ -366,7 +421,7 @@ public: ); /// @brief Create an FPExt, BitCast, or FPTrunc for fp -> fp casts - static CastInst *createFPCast( + static CastInst *CreateFPCast( Value *S, ///< The floating point value to be casted const Type *Ty, ///< The floating point type to cast to const std::string &Name = "", ///< Name for the instruction @@ -374,23 +429,15 @@ public: ); /// @brief Create an FPExt, BitCast, or FPTrunc for fp -> fp casts - static CastInst *createFPCast( + static CastInst *CreateFPCast( Value *S, ///< The floating point value to be casted const Type *Ty, ///< The floating point type to cast to const std::string &Name, ///< The name for the instruction BasicBlock *InsertAtEnd ///< The block to insert the instruction into ); - /// @brief Create a SExt or BitCast cast instruction - static CastInst *createSExtOrBitCast( - Value *S, ///< The value to be casted (operand 0) - const Type *Ty, ///< The type to which operand is casted - const std::string &Name, ///< The name for the instruction - BasicBlock *InsertAtEnd ///< The block to insert the instruction into - ); - /// @brief Create a Trunc or BitCast cast instruction - static CastInst *createTruncOrBitCast( + static CastInst *CreateTruncOrBitCast( Value *S, ///< The value to be casted (operand 0) const Type *Ty, ///< The type to which cast should be made const std::string &Name = "", ///< Name for the instruction @@ -398,7 +445,7 @@ public: ); /// @brief Create a Trunc or BitCast cast instruction - static CastInst *createTruncOrBitCast( + static CastInst *CreateTruncOrBitCast( Value *S, ///< The value to be casted (operand 0) const Type *Ty, ///< The type to which operand is casted const std::string &Name, ///< The name for the instruction @@ -487,6 +534,40 @@ public: static inline bool classof(const Value *V) { return isa<Instruction>(V) && classof(cast<Instruction>(V)); } + /// Backward-compatible interfaces + /// @deprecated in 2.4, do not use, will disappear soon + static CastInst *create(Instruction::CastOps Op,Value *S,const Type *Ty, + const std::string &Name = "",Instruction *InsertBefore = 0) { + return Create(Op,S,Ty,Name,InsertBefore); + } + static CastInst *create(Instruction::CastOps Op,Value *S,const Type *Ty, + const std::string &Name,BasicBlock *InsertAtEnd) { + return Create(Op,S,Ty,Name,InsertAtEnd); + } + +#define DEFINE_CASTINST_DEPRECATED(OP) \ + static CastInst *create ## OP ## Cast(Value *S, const Type *Ty, \ + const std::string &Name = "", Instruction *InsertBefore = 0) { \ + return Create ## OP ## Cast(S, Ty, Name, InsertBefore); \ + } \ + static CastInst *create ## OP ## Cast(Value *S, const Type *Ty, \ + const std::string &Name, BasicBlock *InsertAtEnd) { \ + return Create ## OP ## Cast(S, Ty, Name, InsertAtEnd); \ + } + DEFINE_CASTINST_DEPRECATED(ZExtOrBit) + DEFINE_CASTINST_DEPRECATED(SExtOrBit) + DEFINE_CASTINST_DEPRECATED(Pointer) + DEFINE_CASTINST_DEPRECATED(FP) + DEFINE_CASTINST_DEPRECATED(TruncOrBit) +#undef DEFINE_CASTINST_DEPRECATED + static CastInst *createIntegerCast(Value *S, const Type *Ty, bool isSigned, + const std::string &Name = "", Instruction *InsertBefore = 0) { + return CreateIntegerCast(S, Ty, isSigned, Name, InsertBefore); + } + static CastInst *createIntegerCast(Value *S, const Type *Ty, bool isSigned, + const std::string &Name, BasicBlock *InsertAtEnd) { + return CreateIntegerCast(S, Ty, isSigned, Name, InsertAtEnd); + } }; //===----------------------------------------------------------------------===// @@ -558,7 +639,7 @@ public: /// instruction into a BasicBlock right before the specified instruction. /// The specified Instruction is allowed to be a dereferenced end iterator. /// @brief Create a CmpInst - static CmpInst *create(OtherOps Op, unsigned short predicate, Value *S1, + static CmpInst *Create(OtherOps Op, unsigned short predicate, Value *S1, Value *S2, const std::string &Name = "", Instruction *InsertBefore = 0); @@ -566,7 +647,7 @@ public: /// two operands. Also automatically insert this instruction to the end of /// the BasicBlock specified. /// @brief Create a CmpInst - static CmpInst *create(OtherOps Op, unsigned short predicate, Value *S1, + static CmpInst *Create(OtherOps Op, unsigned short predicate, Value *S1, Value *S2, const std::string &Name, BasicBlock *InsertAtEnd); @@ -627,6 +708,18 @@ public: static inline bool classof(const Value *V) { return isa<Instruction>(V) && classof(cast<Instruction>(V)); } + /// Backward-compatible interfaces + /// @deprecated in 2.4, do not use, will disappear soon + static CmpInst *create(OtherOps Op, unsigned short predicate, Value *S1, + Value *S2, const std::string &Name = "", + Instruction *InsertBefore = 0) { + return Create(Op, predicate, S1, S2, Name, InsertBefore); + } + static CmpInst *create(OtherOps Op, unsigned short predicate, Value *S1, + Value *S2, const std::string &Name, + BasicBlock *InsertAtEnd) { + return Create(Op, predicate, S1, S2, Name, InsertAtEnd); + } }; diff --git a/include/llvm/Support/IRBuilder.h b/include/llvm/Support/IRBuilder.h index e2610ea..65236b2 100644 --- a/include/llvm/Support/IRBuilder.h +++ b/include/llvm/Support/IRBuilder.h @@ -149,103 +149,103 @@ public: if (Constant *LC = dyn_cast<Constant>(LHS)) if (Constant *RC = dyn_cast<Constant>(RHS)) return ConstantExpr::getAdd(LC, RC); - return Insert(BinaryOperator::createAdd(LHS, RHS, Name)); + return Insert(BinaryOperator::CreateAdd(LHS, RHS, Name)); } Value *CreateSub(Value *LHS, Value *RHS, const char *Name = "") { if (Constant *LC = dyn_cast<Constant>(LHS)) if (Constant *RC = dyn_cast<Constant>(RHS)) return ConstantExpr::getSub(LC, RC); - return Insert(BinaryOperator::createSub(LHS, RHS, Name)); + return Insert(BinaryOperator::CreateSub(LHS, RHS, Name)); } Value *CreateMul(Value *LHS, Value *RHS, const char *Name = "") { if (Constant *LC = dyn_cast<Constant>(LHS)) if (Constant *RC = dyn_cast<Constant>(RHS)) return ConstantExpr::getMul(LC, RC); - return Insert(BinaryOperator::createMul(LHS, RHS, Name)); + return Insert(BinaryOperator::CreateMul(LHS, RHS, Name)); } Value *CreateUDiv(Value *LHS, Value *RHS, const char *Name = "") { if (Constant *LC = dyn_cast<Constant>(LHS)) if (Constant *RC = dyn_cast<Constant>(RHS)) return ConstantExpr::getUDiv(LC, RC); - return Insert(BinaryOperator::createUDiv(LHS, RHS, Name)); + return Insert(BinaryOperator::CreateUDiv(LHS, RHS, Name)); } Value *CreateSDiv(Value *LHS, Value *RHS, const char *Name = "") { if (Constant *LC = dyn_cast<Constant>(LHS)) if (Constant *RC = dyn_cast<Constant>(RHS)) return ConstantExpr::getSDiv(LC, RC); - return Insert(BinaryOperator::createSDiv(LHS, RHS, Name)); + return Insert(BinaryOperator::CreateSDiv(LHS, RHS, Name)); } Value *CreateFDiv(Value *LHS, Value *RHS, const char *Name = "") { if (Constant *LC = dyn_cast<Constant>(LHS)) if (Constant *RC = dyn_cast<Constant>(RHS)) return ConstantExpr::getFDiv(LC, RC); - return Insert(BinaryOperator::createFDiv(LHS, RHS, Name)); + return Insert(BinaryOperator::CreateFDiv(LHS, RHS, Name)); } Value *CreateURem(Value *LHS, Value *RHS, const char *Name = "") { if (Constant *LC = dyn_cast<Constant>(LHS)) if (Constant *RC = dyn_cast<Constant>(RHS)) return ConstantExpr::getURem(LC, RC); - return Insert(BinaryOperator::createURem(LHS, RHS, Name)); + return Insert(BinaryOperator::CreateURem(LHS, RHS, Name)); } Value *CreateSRem(Value *LHS, Value *RHS, const char *Name = "") { if (Constant *LC = dyn_cast<Constant>(LHS)) if (Constant *RC = dyn_cast<Constant>(RHS)) return ConstantExpr::getSRem(LC, RC); - return Insert(BinaryOperator::createSRem(LHS, RHS, Name)); + return Insert(BinaryOperator::CreateSRem(LHS, RHS, Name)); } Value *CreateFRem(Value *LHS, Value *RHS, const char *Name = "") { if (Constant *LC = dyn_cast<Constant>(LHS)) if (Constant *RC = dyn_cast<Constant>(RHS)) return ConstantExpr::getFRem(LC, RC); - return Insert(BinaryOperator::createFRem(LHS, RHS, Name)); + return Insert(BinaryOperator::CreateFRem(LHS, RHS, Name)); } Value *CreateShl(Value *LHS, Value *RHS, const char *Name = "") { if (Constant *LC = dyn_cast<Constant>(LHS)) if (Constant *RC = dyn_cast<Constant>(RHS)) return ConstantExpr::getShl(LC, RC); - return Insert(BinaryOperator::createShl(LHS, RHS, Name)); + return Insert(BinaryOperator::CreateShl(LHS, RHS, Name)); } Value *CreateLShr(Value *LHS, Value *RHS, const char *Name = "") { if (Constant *LC = dyn_cast<Constant>(LHS)) if (Constant *RC = dyn_cast<Constant>(RHS)) return ConstantExpr::getLShr(LC, RC); - return Insert(BinaryOperator::createLShr(LHS, RHS, Name)); + return Insert(BinaryOperator::CreateLShr(LHS, RHS, Name)); } Value *CreateAShr(Value *LHS, Value *RHS, const char *Name = "") { if (Constant *LC = dyn_cast<Constant>(LHS)) if (Constant *RC = dyn_cast<Constant>(RHS)) return ConstantExpr::getAShr(LC, RC); - return Insert(BinaryOperator::createAShr(LHS, RHS, Name)); + return Insert(BinaryOperator::CreateAShr(LHS, RHS, Name)); } Value *CreateAnd(Value *LHS, Value *RHS, const char *Name = "") { if (Constant *LC = dyn_cast<Constant>(LHS)) if (Constant *RC = dyn_cast<Constant>(RHS)) return ConstantExpr::getAnd(LC, RC); - return Insert(BinaryOperator::createAnd(LHS, RHS, Name)); + return Insert(BinaryOperator::CreateAnd(LHS, RHS, Name)); } Value *CreateOr(Value *LHS, Value *RHS, const char *Name = "") { if (Constant *LC = dyn_cast<Constant>(LHS)) if (Constant *RC = dyn_cast<Constant>(RHS)) return ConstantExpr::getOr(LC, RC); - return Insert(BinaryOperator::createOr(LHS, RHS, Name)); + return Insert(BinaryOperator::CreateOr(LHS, RHS, Name)); } Value *CreateXor(Value *LHS, Value *RHS, const char *Name = "") { if (Constant *LC = dyn_cast<Constant>(LHS)) if (Constant *RC = dyn_cast<Constant>(RHS)) return ConstantExpr::getXor(LC, RC); - return Insert(BinaryOperator::createXor(LHS, RHS, Name)); + return Insert(BinaryOperator::CreateXor(LHS, RHS, Name)); } BinaryOperator *CreateBinOp(Instruction::BinaryOps Opc, Value *LHS, Value *RHS, const char *Name = "") { - return Insert(BinaryOperator::create(Opc, LHS, RHS, Name)); + return Insert(BinaryOperator::Create(Opc, LHS, RHS, Name)); } BinaryOperator *CreateNeg(Value *V, const char *Name = "") { - return Insert(BinaryOperator::createNeg(V, Name)); + return Insert(BinaryOperator::CreateNeg(V, Name)); } BinaryOperator *CreateNot(Value *V, const char *Name = "") { - return Insert(BinaryOperator::createNot(V, Name)); + return Insert(BinaryOperator::CreateNot(V, Name)); } //===--------------------------------------------------------------------===// @@ -357,7 +357,7 @@ public: return V; if (Constant *VC = dyn_cast<Constant>(V)) return ConstantExpr::getCast(Op, VC, DestTy); - return Insert(CastInst::create(Op, V, DestTy, Name)); + return Insert(CastInst::Create(Op, V, DestTy, Name)); } Value *CreateIntCast(Value *V, const Type *DestTy, bool isSigned, const char *Name = "") { @@ -365,7 +365,7 @@ public: return V; if (Constant *VC = dyn_cast<Constant>(V)) return ConstantExpr::getIntegerCast(VC, DestTy, isSigned); - return Insert(CastInst::createIntegerCast(V, DestTy, isSigned, Name)); + return Insert(CastInst::CreateIntegerCast(V, DestTy, isSigned, Name)); } //===--------------------------------------------------------------------===// diff --git a/lib/Analysis/ScalarEvolutionExpander.cpp b/lib/Analysis/ScalarEvolutionExpander.cpp index 7ef1948..e249421 100644 --- a/lib/Analysis/ScalarEvolutionExpander.cpp +++ b/lib/Analysis/ScalarEvolutionExpander.cpp @@ -40,7 +40,7 @@ Value *SCEVExpander::InsertCastOfTo(Instruction::CastOps opcode, Value *V, return CI; } } - return CastInst::create(opcode, V, Ty, V->getName(), + return CastInst::Create(opcode, V, Ty, V->getName(), A->getParent()->getEntryBlock().begin()); } @@ -67,7 +67,7 @@ Value *SCEVExpander::InsertCastOfTo(Instruction::CastOps opcode, Value *V, if (InvokeInst *II = dyn_cast<InvokeInst>(I)) IP = II->getNormalDest()->begin(); while (isa<PHINode>(IP)) ++IP; - return CastInst::create(opcode, V, Ty, V->getName(), IP); + return CastInst::Create(opcode, V, Ty, V->getName(), IP); } /// InsertBinop - Insert the specified binary operator, doing a small amount @@ -96,7 +96,7 @@ Value *SCEVExpander::InsertBinop(Instruction::BinaryOps Opcode, Value *LHS, } // If we don't have - return BinaryOperator::create(Opcode, LHS, RHS, "tmp", InsertPt); + return BinaryOperator::Create(Opcode, LHS, RHS, "tmp", InsertPt); } Value *SCEVExpander::visitMulExpr(SCEVMulExpr *S) { @@ -155,7 +155,7 @@ Value *SCEVExpander::visitAddRecExpr(SCEVAddRecExpr *S) { // Insert a unit add instruction right before the terminator corresponding // to the back-edge. Constant *One = ConstantInt::get(Ty, 1); - Instruction *Add = BinaryOperator::createAdd(PN, One, "indvar.next", + Instruction *Add = BinaryOperator::CreateAdd(PN, One, "indvar.next", (*HPI)->getTerminator()); pred_iterator PI = pred_begin(Header); diff --git a/lib/AsmParser/llvmAsmParser.y b/lib/AsmParser/llvmAsmParser.y index 90fe540..8c8a3c6 100644 --- a/lib/AsmParser/llvmAsmParser.y +++ b/lib/AsmParser/llvmAsmParser.y @@ -2852,7 +2852,7 @@ InstVal : ArithmeticOps Types ValueRef ',' ValueRef { CHECK_FOR_ERROR Value* val2 = getVal(*$2, $5); CHECK_FOR_ERROR - $$ = BinaryOperator::create($1, val1, val2); + $$ = BinaryOperator::Create($1, val1, val2); if ($$ == 0) GEN_ERROR("binary operator returned null"); delete $2; @@ -2869,7 +2869,7 @@ InstVal : ArithmeticOps Types ValueRef ',' ValueRef { CHECK_FOR_ERROR Value* tmpVal2 = getVal(*$2, $5); CHECK_FOR_ERROR - $$ = BinaryOperator::create($1, tmpVal1, tmpVal2); + $$ = BinaryOperator::Create($1, tmpVal1, tmpVal2); if ($$ == 0) GEN_ERROR("binary operator returned null"); delete $2; @@ -2883,7 +2883,7 @@ InstVal : ArithmeticOps Types ValueRef ',' ValueRef { CHECK_FOR_ERROR Value* tmpVal2 = getVal(*$3, $6); CHECK_FOR_ERROR - $$ = CmpInst::create($1, $2, tmpVal1, tmpVal2); + $$ = CmpInst::Create($1, $2, tmpVal1, tmpVal2); if ($$ == 0) GEN_ERROR("icmp operator returned null"); delete $3; @@ -2897,7 +2897,7 @@ InstVal : ArithmeticOps Types ValueRef ',' ValueRef { CHECK_FOR_ERROR Value* tmpVal2 = getVal(*$3, $6); CHECK_FOR_ERROR - $$ = CmpInst::create($1, $2, tmpVal1, tmpVal2); + $$ = CmpInst::Create($1, $2, tmpVal1, tmpVal2); if ($$ == 0) GEN_ERROR("fcmp operator returned null"); delete $3; @@ -2911,7 +2911,7 @@ InstVal : ArithmeticOps Types ValueRef ',' ValueRef { CHECK_FOR_ERROR Value* tmpVal2 = getVal(*$3, $6); CHECK_FOR_ERROR - $$ = CmpInst::create($1, $2, tmpVal1, tmpVal2); + $$ = CmpInst::Create($1, $2, tmpVal1, tmpVal2); if ($$ == 0) GEN_ERROR("icmp operator returned null"); delete $3; @@ -2925,7 +2925,7 @@ InstVal : ArithmeticOps Types ValueRef ',' ValueRef { CHECK_FOR_ERROR Value* tmpVal2 = getVal(*$3, $6); CHECK_FOR_ERROR - $$ = CmpInst::create($1, $2, tmpVal1, tmpVal2); + $$ = CmpInst::Create($1, $2, tmpVal1, tmpVal2); if ($$ == 0) GEN_ERROR("fcmp operator returned null"); delete $3; @@ -2939,7 +2939,7 @@ InstVal : ArithmeticOps Types ValueRef ',' ValueRef { GEN_ERROR("invalid cast opcode for cast from '" + Val->getType()->getDescription() + "' to '" + DestTy->getDescription() + "'"); - $$ = CastInst::create($1, Val, DestTy); + $$ = CastInst::Create($1, Val, DestTy); delete $4; } | SELECT ResolvedVal ',' ResolvedVal ',' ResolvedVal { diff --git a/lib/Bitcode/Reader/BitcodeReader.cpp b/lib/Bitcode/Reader/BitcodeReader.cpp index 1fba6a4..c4f2247 100644 --- a/lib/Bitcode/Reader/BitcodeReader.cpp +++ b/lib/Bitcode/Reader/BitcodeReader.cpp @@ -1266,7 +1266,7 @@ bool BitcodeReader::ParseFunctionBody(Function *F) { int Opc = GetDecodedBinaryOpcode(Record[OpNum], LHS->getType()); if (Opc == -1) return Error("Invalid BINOP record"); - I = BinaryOperator::create((Instruction::BinaryOps)Opc, LHS, RHS); + I = BinaryOperator::Create((Instruction::BinaryOps)Opc, LHS, RHS); break; } case bitc::FUNC_CODE_INST_CAST: { // CAST: [opval, opty, destty, castopc] @@ -1280,7 +1280,7 @@ bool BitcodeReader::ParseFunctionBody(Function *F) { int Opc = GetDecodedCastOpcode(Record[OpNum+1]); if (Opc == -1 || ResTy == 0) return Error("Invalid CAST record"); - I = CastInst::create((Instruction::CastOps)Opc, Op, ResTy); + I = CastInst::Create((Instruction::CastOps)Opc, Op, ResTy); break; } case bitc::FUNC_CODE_INST_GEP: { // GEP: [n x operands] diff --git a/lib/CodeGen/IntrinsicLowering.cpp b/lib/CodeGen/IntrinsicLowering.cpp index 0500bfb..bd3c8c7 100644 --- a/lib/CodeGen/IntrinsicLowering.cpp +++ b/lib/CodeGen/IntrinsicLowering.cpp @@ -173,76 +173,76 @@ static Value *LowerBSWAP(Value *V, Instruction *IP) { switch(BitSize) { default: assert(0 && "Unhandled type size of value to byteswap!"); case 16: { - Value *Tmp1 = BinaryOperator::createShl(V, + Value *Tmp1 = BinaryOperator::CreateShl(V, ConstantInt::get(V->getType(),8),"bswap.2",IP); - Value *Tmp2 = BinaryOperator::createLShr(V, + Value *Tmp2 = BinaryOperator::CreateLShr(V, ConstantInt::get(V->getType(),8),"bswap.1",IP); - V = BinaryOperator::createOr(Tmp1, Tmp2, "bswap.i16", IP); + V = BinaryOperator::CreateOr(Tmp1, Tmp2, "bswap.i16", IP); break; } case 32: { - Value *Tmp4 = BinaryOperator::createShl(V, + Value *Tmp4 = BinaryOperator::CreateShl(V, ConstantInt::get(V->getType(),24),"bswap.4", IP); - Value *Tmp3 = BinaryOperator::createShl(V, + Value *Tmp3 = BinaryOperator::CreateShl(V, ConstantInt::get(V->getType(),8),"bswap.3",IP); - Value *Tmp2 = BinaryOperator::createLShr(V, + Value *Tmp2 = BinaryOperator::CreateLShr(V, ConstantInt::get(V->getType(),8),"bswap.2",IP); - Value *Tmp1 = BinaryOperator::createLShr(V, + Value *Tmp1 = BinaryOperator::CreateLShr(V, ConstantInt::get(V->getType(),24),"bswap.1", IP); - Tmp3 = BinaryOperator::createAnd(Tmp3, + Tmp3 = BinaryOperator::CreateAnd(Tmp3, ConstantInt::get(Type::Int32Ty, 0xFF0000), "bswap.and3", IP); - Tmp2 = BinaryOperator::createAnd(Tmp2, + Tmp2 = BinaryOperator::CreateAnd(Tmp2, ConstantInt::get(Type::Int32Ty, 0xFF00), "bswap.and2", IP); - Tmp4 = BinaryOperator::createOr(Tmp4, Tmp3, "bswap.or1", IP); - Tmp2 = BinaryOperator::createOr(Tmp2, Tmp1, "bswap.or2", IP); - V = BinaryOperator::createOr(Tmp4, Tmp2, "bswap.i32", IP); + Tmp4 = BinaryOperator::CreateOr(Tmp4, Tmp3, "bswap.or1", IP); + Tmp2 = BinaryOperator::CreateOr(Tmp2, Tmp1, "bswap.or2", IP); + V = BinaryOperator::CreateOr(Tmp4, Tmp2, "bswap.i32", IP); break; } case 64: { - Value *Tmp8 = BinaryOperator::createShl(V, + Value *Tmp8 = BinaryOperator::CreateShl(V, ConstantInt::get(V->getType(),56),"bswap.8", IP); - Value *Tmp7 = BinaryOperator::createShl(V, + Value *Tmp7 = BinaryOperator::CreateShl(V, ConstantInt::get(V->getType(),40),"bswap.7", IP); - Value *Tmp6 = BinaryOperator::createShl(V, + Value *Tmp6 = BinaryOperator::CreateShl(V, ConstantInt::get(V->getType(),24),"bswap.6", IP); - Value *Tmp5 = BinaryOperator::createShl(V, + Value *Tmp5 = BinaryOperator::CreateShl(V, ConstantInt::get(V->getType(),8),"bswap.5", IP); - Value* Tmp4 = BinaryOperator::createLShr(V, + Value* Tmp4 = BinaryOperator::CreateLShr(V, ConstantInt::get(V->getType(),8),"bswap.4", IP); - Value* Tmp3 = BinaryOperator::createLShr(V, + Value* Tmp3 = BinaryOperator::CreateLShr(V, ConstantInt::get(V->getType(),24),"bswap.3", IP); - Value* Tmp2 = BinaryOperator::createLShr(V, + Value* Tmp2 = BinaryOperator::CreateLShr(V, ConstantInt::get(V->getType(),40),"bswap.2", IP); - Value* Tmp1 = BinaryOperator::createLShr(V, + Value* Tmp1 = BinaryOperator::CreateLShr(V, ConstantInt::get(V->getType(),56),"bswap.1", IP); - Tmp7 = BinaryOperator::createAnd(Tmp7, + Tmp7 = BinaryOperator::CreateAnd(Tmp7, ConstantInt::get(Type::Int64Ty, 0xFF000000000000ULL), "bswap.and7", IP); - Tmp6 = BinaryOperator::createAnd(Tmp6, + Tmp6 = BinaryOperator::CreateAnd(Tmp6, ConstantInt::get(Type::Int64Ty, 0xFF0000000000ULL), "bswap.and6", IP); - Tmp5 = BinaryOperator::createAnd(Tmp5, + Tmp5 = BinaryOperator::CreateAnd(Tmp5, ConstantInt::get(Type::Int64Ty, 0xFF00000000ULL), "bswap.and5", IP); - Tmp4 = BinaryOperator::createAnd(Tmp4, + Tmp4 = BinaryOperator::CreateAnd(Tmp4, ConstantInt::get(Type::Int64Ty, 0xFF000000ULL), "bswap.and4", IP); - Tmp3 = BinaryOperator::createAnd(Tmp3, + Tmp3 = BinaryOperator::CreateAnd(Tmp3, ConstantInt::get(Type::Int64Ty, 0xFF0000ULL), "bswap.and3", IP); - Tmp2 = BinaryOperator::createAnd(Tmp2, + Tmp2 = BinaryOperator::CreateAnd(Tmp2, ConstantInt::get(Type::Int64Ty, 0xFF00ULL), "bswap.and2", IP); - Tmp8 = BinaryOperator::createOr(Tmp8, Tmp7, "bswap.or1", IP); - Tmp6 = BinaryOperator::createOr(Tmp6, Tmp5, "bswap.or2", IP); - Tmp4 = BinaryOperator::createOr(Tmp4, Tmp3, "bswap.or3", IP); - Tmp2 = BinaryOperator::createOr(Tmp2, Tmp1, "bswap.or4", IP); - Tmp8 = BinaryOperator::createOr(Tmp8, Tmp6, "bswap.or5", IP); - Tmp4 = BinaryOperator::createOr(Tmp4, Tmp2, "bswap.or6", IP); - V = BinaryOperator::createOr(Tmp8, Tmp4, "bswap.i64", IP); + Tmp8 = BinaryOperator::CreateOr(Tmp8, Tmp7, "bswap.or1", IP); + Tmp6 = BinaryOperator::CreateOr(Tmp6, Tmp5, "bswap.or2", IP); + Tmp4 = BinaryOperator::CreateOr(Tmp4, Tmp3, "bswap.or3", IP); + Tmp2 = BinaryOperator::CreateOr(Tmp2, Tmp1, "bswap.or4", IP); + Tmp8 = BinaryOperator::CreateOr(Tmp8, Tmp6, "bswap.or5", IP); + Tmp4 = BinaryOperator::CreateOr(Tmp4, Tmp2, "bswap.or6", IP); + V = BinaryOperator::CreateOr(Tmp8, Tmp4, "bswap.i64", IP); break; } } @@ -269,16 +269,16 @@ static Value *LowerCTPOP(Value *V, Instruction *IP) { for (unsigned i = 1, ct = 0; i < (BitSize>64 ? 64 : BitSize); i <<= 1, ++ct) { Value *MaskCst = ConstantInt::get(V->getType(), MaskValues[ct]); - Value *LHS = BinaryOperator::createAnd( + Value *LHS = BinaryOperator::CreateAnd( PartValue, MaskCst, "cppop.and1", IP); - Value *VShift = BinaryOperator::createLShr(PartValue, + Value *VShift = BinaryOperator::CreateLShr(PartValue, ConstantInt::get(V->getType(), i), "ctpop.sh", IP); - Value *RHS = BinaryOperator::createAnd(VShift, MaskCst, "cppop.and2", IP); - PartValue = BinaryOperator::createAdd(LHS, RHS, "ctpop.step", IP); + Value *RHS = BinaryOperator::CreateAnd(VShift, MaskCst, "cppop.and2", IP); + PartValue = BinaryOperator::CreateAdd(LHS, RHS, "ctpop.step", IP); } - Count = BinaryOperator::createAdd(PartValue, Count, "ctpop.part", IP); + Count = BinaryOperator::CreateAdd(PartValue, Count, "ctpop.part", IP); if (BitSize > 64) { - V = BinaryOperator::createLShr(V, ConstantInt::get(V->getType(), 64), + V = BinaryOperator::CreateLShr(V, ConstantInt::get(V->getType(), 64), "ctpop.part.sh", IP); BitSize -= 64; } @@ -294,11 +294,11 @@ static Value *LowerCTLZ(Value *V, Instruction *IP) { unsigned BitSize = V->getType()->getPrimitiveSizeInBits(); for (unsigned i = 1; i < BitSize; i <<= 1) { Value *ShVal = ConstantInt::get(V->getType(), i); - ShVal = BinaryOperator::createLShr(V, ShVal, "ctlz.sh", IP); - V = BinaryOperator::createOr(V, ShVal, "ctlz.step", IP); + ShVal = BinaryOperator::CreateLShr(V, ShVal, "ctlz.sh", IP); + V = BinaryOperator::CreateOr(V, ShVal, "ctlz.step", IP); } - V = BinaryOperator::createNot(V, "", IP); + V = BinaryOperator::CreateNot(V, "", IP); return LowerCTPOP(V, IP); } @@ -355,10 +355,10 @@ static Instruction *LowerPartSelect(CallInst *CI) { // Cast Hi and Lo to the size of Val so the widths are all the same if (Hi->getType() != Val->getType()) - Hi = CastInst::createIntegerCast(Hi, Val->getType(), false, + Hi = CastInst::CreateIntegerCast(Hi, Val->getType(), false, "tmp", CurBB); if (Lo->getType() != Val->getType()) - Lo = CastInst::createIntegerCast(Lo, Val->getType(), false, + Lo = CastInst::CreateIntegerCast(Lo, Val->getType(), false, "tmp", CurBB); // Compute a few things that both cases will need, up front. @@ -373,12 +373,12 @@ static Instruction *LowerPartSelect(CallInst *CI) { // First, copmute the number of bits in the forward case. Instruction* FBitSize = - BinaryOperator::createSub(Hi, Lo,"fbits", FwdSize); + BinaryOperator::CreateSub(Hi, Lo,"fbits", FwdSize); BranchInst::Create(Compute, FwdSize); // Second, compute the number of bits in the reverse case. Instruction* RBitSize = - BinaryOperator::createSub(Lo, Hi, "rbits", RevSize); + BinaryOperator::CreateSub(Lo, Hi, "rbits", RevSize); BranchInst::Create(Compute, RevSize); // Now, compute the bit range. Start by getting the bitsize and the shift @@ -402,17 +402,17 @@ static Instruction *LowerPartSelect(CallInst *CI) { // Increment the bit size Instruction *BitSizePlusOne = - BinaryOperator::createAdd(BitSize, One, "bits", Compute); + BinaryOperator::CreateAdd(BitSize, One, "bits", Compute); // Create a Mask to zero out the high order bits. Instruction* Mask = - BinaryOperator::createShl(AllOnes, BitSizePlusOne, "mask", Compute); - Mask = BinaryOperator::createNot(Mask, "mask", Compute); + BinaryOperator::CreateShl(AllOnes, BitSizePlusOne, "mask", Compute); + Mask = BinaryOperator::CreateNot(Mask, "mask", Compute); // Shift the bits down and apply the mask Instruction* FRes = - BinaryOperator::createLShr(Val, ShiftAmt, "fres", Compute); - FRes = BinaryOperator::createAnd(FRes, Mask, "fres", Compute); + BinaryOperator::CreateLShr(Val, ShiftAmt, "fres", Compute); + FRes = BinaryOperator::CreateAnd(FRes, Mask, "fres", Compute); BranchInst::Create(Reverse, RsltBlk, Cmp, Compute); // In the Reverse block we have the mask already in FRes but we must reverse @@ -435,22 +435,22 @@ static Instruction *LowerPartSelect(CallInst *CI) { RRes->addIncoming(Zero, Compute); // Decrement the counter - Instruction *Decr = BinaryOperator::createSub(Count, One, "decr", Reverse); + Instruction *Decr = BinaryOperator::CreateSub(Count, One, "decr", Reverse); Count->addIncoming(Decr, Reverse); // Compute the Bit that we want to move Instruction *Bit = - BinaryOperator::createAnd(BitsToShift, One, "bit", Reverse); + BinaryOperator::CreateAnd(BitsToShift, One, "bit", Reverse); // Compute the new value for next iteration. Instruction *NewVal = - BinaryOperator::createLShr(BitsToShift, One, "rshift", Reverse); + BinaryOperator::CreateLShr(BitsToShift, One, "rshift", Reverse); BitsToShift->addIncoming(NewVal, Reverse); // Shift the bit into the low bits of the result. Instruction *NewRes = - BinaryOperator::createShl(RRes, One, "lshift", Reverse); - NewRes = BinaryOperator::createOr(NewRes, Bit, "addbit", Reverse); + BinaryOperator::CreateShl(RRes, One, "lshift", Reverse); + NewRes = BinaryOperator::CreateOr(NewRes, Bit, "addbit", Reverse); RRes->addIncoming(NewRes, Reverse); // Terminate loop if we've moved all the bits. @@ -543,8 +543,8 @@ static Instruction *LowerPartSet(CallInst *CI) { new ICmpInst(ICmpInst::ICMP_ULT, Lo, Hi, "", entry); SelectInst* Hi_pn = SelectInst::Create(is_forward, Hi, Lo, "", entry); SelectInst* Lo_pn = SelectInst::Create(is_forward, Lo, Hi, "", entry); - BinaryOperator* NumBits = BinaryOperator::createSub(Hi_pn, Lo_pn, "",entry); - NumBits = BinaryOperator::createAdd(NumBits, One, "", entry); + BinaryOperator* NumBits = BinaryOperator::CreateSub(Hi_pn, Lo_pn, "",entry); + NumBits = BinaryOperator::CreateAdd(NumBits, One, "", entry); // Now, convert Lo and Hi to ValTy bit width if (ValBits > 32) { Lo = new ZExtInst(Lo_pn, ValTy, "", entry); @@ -559,12 +559,12 @@ static Instruction *LowerPartSet(CallInst *CI) { // BASIC BLOCK: large Instruction* MaskBits = - BinaryOperator::createSub(RepBitWidth, NumBits, "", large); - MaskBits = CastInst::createIntegerCast(MaskBits, RepMask->getType(), + BinaryOperator::CreateSub(RepBitWidth, NumBits, "", large); + MaskBits = CastInst::CreateIntegerCast(MaskBits, RepMask->getType(), false, "", large); BinaryOperator* Mask1 = - BinaryOperator::createLShr(RepMask, MaskBits, "", large); - BinaryOperator* Rep2 = BinaryOperator::createAnd(Mask1, Rep, "", large); + BinaryOperator::CreateLShr(RepMask, MaskBits, "", large); + BinaryOperator* Rep2 = BinaryOperator::CreateAnd(Mask1, Rep, "", large); BranchInst::Create(small, large); // BASIC BLOCK: small @@ -598,19 +598,19 @@ static Instruction *LowerPartSet(CallInst *CI) { RRes->addIncoming(ValZero, small); // Decrement the loop counter by one - Instruction *Decr = BinaryOperator::createSub(Count, One, "", reverse); + Instruction *Decr = BinaryOperator::CreateSub(Count, One, "", reverse); Count->addIncoming(Decr, reverse); // Get the bit that we want to move into the result - Value *Bit = BinaryOperator::createAnd(BitsToShift, ValOne, "", reverse); + Value *Bit = BinaryOperator::CreateAnd(BitsToShift, ValOne, "", reverse); // Compute the new value of the bits to shift for the next iteration. - Value *NewVal = BinaryOperator::createLShr(BitsToShift, ValOne,"", reverse); + Value *NewVal = BinaryOperator::CreateLShr(BitsToShift, ValOne,"", reverse); BitsToShift->addIncoming(NewVal, reverse); // Shift the bit we extracted into the low bit of the result. - Instruction *NewRes = BinaryOperator::createShl(RRes, ValOne, "", reverse); - NewRes = BinaryOperator::createOr(NewRes, Bit, "", reverse); + Instruction *NewRes = BinaryOperator::CreateShl(RRes, ValOne, "", reverse); + NewRes = BinaryOperator::CreateOr(NewRes, Bit, "", reverse); RRes->addIncoming(NewRes, reverse); // Terminate loop if we've moved all the bits. @@ -622,14 +622,14 @@ static Instruction *LowerPartSet(CallInst *CI) { Rplcmnt->reserveOperandSpace(2); Rplcmnt->addIncoming(NewRes, reverse); Rplcmnt->addIncoming(Rep4, small); - Value* t0 = CastInst::createIntegerCast(NumBits,ValTy,false,"",result); - Value* t1 = BinaryOperator::createShl(ValMask, Lo, "", result); - Value* t2 = BinaryOperator::createNot(t1, "", result); - Value* t3 = BinaryOperator::createShl(t1, t0, "", result); - Value* t4 = BinaryOperator::createOr(t2, t3, "", result); - Value* t5 = BinaryOperator::createAnd(t4, Val, "", result); - Value* t6 = BinaryOperator::createShl(Rplcmnt, Lo, "", result); - Value* Rslt = BinaryOperator::createOr(t5, t6, "part_set", result); + Value* t0 = CastInst::CreateIntegerCast(NumBits,ValTy,false,"",result); + Value* t1 = BinaryOperator::CreateShl(ValMask, Lo, "", result); + Value* t2 = BinaryOperator::CreateNot(t1, "", result); + Value* t3 = BinaryOperator::CreateShl(t1, t0, "", result); + Value* t4 = BinaryOperator::CreateOr(t2, t3, "", result); + Value* t5 = BinaryOperator::CreateAnd(t4, Val, "", result); + Value* t6 = BinaryOperator::CreateShl(Rplcmnt, Lo, "", result); + Value* Rslt = BinaryOperator::CreateOr(t5, t6, "part_set", result); ReturnInst::Create(Rslt, result); } @@ -704,10 +704,10 @@ void IntrinsicLowering::LowerIntrinsicCall(CallInst *CI) { case Intrinsic::cttz: { // cttz(x) -> ctpop(~X & (X-1)) Value *Src = CI->getOperand(1); - Value *NotSrc = BinaryOperator::createNot(Src, Src->getName()+".not", CI); + Value *NotSrc = BinaryOperator::CreateNot(Src, Src->getName()+".not", CI); Value *SrcM1 = ConstantInt::get(Src->getType(), 1); - SrcM1 = BinaryOperator::createSub(Src, SrcM1, "", CI); - Src = LowerCTPOP(BinaryOperator::createAnd(NotSrc, SrcM1, "", CI), CI); + SrcM1 = BinaryOperator::CreateSub(Src, SrcM1, "", CI); + Src = LowerCTPOP(BinaryOperator::CreateAnd(NotSrc, SrcM1, "", CI), CI); CI->replaceAllUsesWith(Src); break; } diff --git a/lib/Target/CppBackend/CPPBackend.cpp b/lib/Target/CppBackend/CPPBackend.cpp index dc9a11e..a16b720 100644 --- a/lib/Target/CppBackend/CPPBackend.cpp +++ b/lib/Target/CppBackend/CPPBackend.cpp @@ -1155,7 +1155,7 @@ namespace { case Instruction::Shl: case Instruction::LShr: case Instruction::AShr:{ - Out << "BinaryOperator* " << iName << " = BinaryOperator::create("; + Out << "BinaryOperator* " << iName << " = BinaryOperator::Create("; switch (I->getOpcode()) { case Instruction::Add: Out << "Instruction::Add"; break; case Instruction::Sub: Out << "Instruction::Sub"; break; diff --git a/lib/Transforms/IPO/GlobalOpt.cpp b/lib/Transforms/IPO/GlobalOpt.cpp index 29a98cb..5d3dbcd 100644 --- a/lib/Transforms/IPO/GlobalOpt.cpp +++ b/lib/Transforms/IPO/GlobalOpt.cpp @@ -872,7 +872,7 @@ static GlobalVariable *OptimizeGlobalAddressOfMalloc(GlobalVariable *GV, case ICmpInst::ICMP_ULE: case ICmpInst::ICMP_SLE: case ICmpInst::ICMP_EQ: - LV = BinaryOperator::createNot(LV, "notinit", CI); + LV = BinaryOperator::CreateNot(LV, "notinit", CI); break; case ICmpInst::ICMP_NE: case ICmpInst::ICMP_UGE: @@ -1193,7 +1193,7 @@ static GlobalVariable *PerformHeapAllocSRoA(GlobalVariable *GV, MallocInst *MI){ if (!RunningOr) RunningOr = Cond; // First seteq else - RunningOr = BinaryOperator::createOr(RunningOr, Cond, "tmp", MI); + RunningOr = BinaryOperator::CreateOr(RunningOr, Cond, "tmp", MI); } // Split the basic block at the old malloc. diff --git a/lib/Transforms/IPO/IndMemRemoval.cpp b/lib/Transforms/IPO/IndMemRemoval.cpp index a623135..8448374 100644 --- a/lib/Transforms/IPO/IndMemRemoval.cpp +++ b/lib/Transforms/IPO/IndMemRemoval.cpp @@ -72,7 +72,7 @@ bool IndMemRemPass::runOnModule(Module &M) { GlobalValue::LinkOnceLinkage, "malloc_llvm_bounce", &M); BasicBlock* bb = BasicBlock::Create("entry",FN); - Instruction* c = CastInst::createIntegerCast( + Instruction* c = CastInst::CreateIntegerCast( FN->arg_begin(), Type::Int32Ty, false, "c", bb); Instruction* a = new MallocInst(Type::Int8Ty, c, "m", bb); ReturnInst::Create(a, bb); diff --git a/lib/Transforms/IPO/RaiseAllocations.cpp b/lib/Transforms/IPO/RaiseAllocations.cpp index 0931dec..58fd682 100644 --- a/lib/Transforms/IPO/RaiseAllocations.cpp +++ b/lib/Transforms/IPO/RaiseAllocations.cpp @@ -164,7 +164,7 @@ bool RaiseAllocations::runOnModule(Module &M) { // source size. if (Source->getType() != Type::Int32Ty) Source = - CastInst::createIntegerCast(Source, Type::Int32Ty, false/*ZExt*/, + CastInst::CreateIntegerCast(Source, Type::Int32Ty, false/*ZExt*/, "MallocAmtCast", I); MallocInst *MI = new MallocInst(Type::Int8Ty, Source, "", I); diff --git a/lib/Transforms/Instrumentation/ProfilingUtils.cpp b/lib/Transforms/Instrumentation/ProfilingUtils.cpp index 4617fbb..d94522f 100644 --- a/lib/Transforms/Instrumentation/ProfilingUtils.cpp +++ b/lib/Transforms/Instrumentation/ProfilingUtils.cpp @@ -68,7 +68,7 @@ void llvm::InsertProfilingInitCall(Function *MainFn, const char *FnName, Instruction::CastOps opcode = CastInst::getCastOpcode(AI, false, ArgVTy, false); InitCall->setOperand(2, - CastInst::create(opcode, AI, ArgVTy, "argv.cast", InitCall)); + CastInst::Create(opcode, AI, ArgVTy, "argv.cast", InitCall)); } else { InitCall->setOperand(2, AI); } @@ -83,11 +83,11 @@ void llvm::InsertProfilingInitCall(Function *MainFn, const char *FnName, if (!AI->use_empty()) { opcode = CastInst::getCastOpcode(InitCall, true, AI->getType(), true); AI->replaceAllUsesWith( - CastInst::create(opcode, InitCall, AI->getType(), "", InsertPos)); + CastInst::Create(opcode, InitCall, AI->getType(), "", InsertPos)); } opcode = CastInst::getCastOpcode(AI, true, Type::Int32Ty, true); InitCall->setOperand(1, - CastInst::create(opcode, AI, Type::Int32Ty, "argc.cast", InitCall)); + CastInst::Create(opcode, AI, Type::Int32Ty, "argc.cast", InitCall)); } else { AI->replaceAllUsesWith(InitCall); InitCall->setOperand(1, AI); @@ -113,7 +113,7 @@ void llvm::IncrementCounterInBlock(BasicBlock *BB, unsigned CounterNum, // Load, increment and store the value back. Value *OldVal = new LoadInst(ElementPtr, "OldFuncCounter", InsertPos); - Value *NewVal = BinaryOperator::create(Instruction::Add, OldVal, + Value *NewVal = BinaryOperator::Create(Instruction::Add, OldVal, ConstantInt::get(Type::Int32Ty, 1), "NewFuncCounter", InsertPos); new StoreInst(NewVal, ElementPtr, InsertPos); diff --git a/lib/Transforms/Instrumentation/RSProfiling.cpp b/lib/Transforms/Instrumentation/RSProfiling.cpp index 7d16692..a9406c8 100644 --- a/lib/Transforms/Instrumentation/RSProfiling.cpp +++ b/lib/Transforms/Instrumentation/RSProfiling.cpp @@ -215,7 +215,7 @@ void GlobalRandomCounter::ProcessChoicePoint(BasicBlock* bb) { ICmpInst* s = new ICmpInst(ICmpInst::ICMP_EQ, l, ConstantInt::get(T, 0), "countercc", t); - Value* nv = BinaryOperator::createSub(l, ConstantInt::get(T, 1), + Value* nv = BinaryOperator::CreateSub(l, ConstantInt::get(T, 1), "counternew", t); new StoreInst(nv, Counter, t); t->setCondition(s); @@ -290,7 +290,7 @@ void GlobalRandomCounterOpt::ProcessChoicePoint(BasicBlock* bb) { ICmpInst* s = new ICmpInst(ICmpInst::ICMP_EQ, l, ConstantInt::get(T, 0), "countercc", t); - Value* nv = BinaryOperator::createSub(l, ConstantInt::get(T, 1), + Value* nv = BinaryOperator::CreateSub(l, ConstantInt::get(T, 1), "counternew", t); new StoreInst(nv, AI, t); t->setCondition(s); @@ -319,7 +319,7 @@ void CycleCounter::ProcessChoicePoint(BasicBlock* bb) { CallInst* c = CallInst::Create(F, "rdcc", t); BinaryOperator* b = - BinaryOperator::createAnd(c, ConstantInt::get(Type::Int64Ty, rm), + BinaryOperator::CreateAnd(c, ConstantInt::get(Type::Int64Ty, rm), "mrdcc", t); ICmpInst *s = new ICmpInst(ICmpInst::ICMP_EQ, b, @@ -357,7 +357,7 @@ void RSProfilers_std::IncrementCounterInBlock(BasicBlock *BB, unsigned CounterNu // Load, increment and store the value back. Value *OldVal = new LoadInst(ElementPtr, "OldCounter", InsertPos); profcode.insert(OldVal); - Value *NewVal = BinaryOperator::createAdd(OldVal, + Value *NewVal = BinaryOperator::CreateAdd(OldVal, ConstantInt::get(Type::Int32Ty, 1), "NewCounter", InsertPos); profcode.insert(NewVal); diff --git a/lib/Transforms/Scalar/CodeGenPrepare.cpp b/lib/Transforms/Scalar/CodeGenPrepare.cpp index 2dfd4d7..959a832 100644 --- a/lib/Transforms/Scalar/CodeGenPrepare.cpp +++ b/lib/Transforms/Scalar/CodeGenPrepare.cpp @@ -389,7 +389,7 @@ static bool OptimizeNoopCopyExpression(CastInst *CI, const TargetLowering &TLI){ while (isa<PHINode>(InsertPt)) ++InsertPt; InsertedCast = - CastInst::create(CI->getOpcode(), CI->getOperand(0), CI->getType(), "", + CastInst::Create(CI->getOpcode(), CI->getOperand(0), CI->getType(), "", InsertPt); MadeChange = true; } @@ -447,7 +447,7 @@ static bool OptimizeCmpExpression(CmpInst *CI){ while (isa<PHINode>(InsertPt)) ++InsertPt; InsertedCmp = - CmpInst::create(CI->getOpcode(), CI->getPredicate(), CI->getOperand(0), + CmpInst::Create(CI->getOpcode(), CI->getPredicate(), CI->getOperand(0), CI->getOperand(1), "", InsertPt); MadeChange = true; } @@ -880,7 +880,7 @@ bool CodeGenPrepare::OptimizeLoadStoreInst(Instruction *LdStInst, Value *Addr, V = new SExtInst(V, IntPtrTy, "sunkaddr", InsertPt); } if (AddrMode.Scale != 1) - V = BinaryOperator::createMul(V, ConstantInt::get(IntPtrTy, + V = BinaryOperator::CreateMul(V, ConstantInt::get(IntPtrTy, AddrMode.Scale), "sunkaddr", InsertPt); Result = V; @@ -892,7 +892,7 @@ bool CodeGenPrepare::OptimizeLoadStoreInst(Instruction *LdStInst, Value *Addr, if (V->getType() != IntPtrTy) V = new PtrToIntInst(V, IntPtrTy, "sunkaddr", InsertPt); if (Result) - Result = BinaryOperator::createAdd(Result, V, "sunkaddr", InsertPt); + Result = BinaryOperator::CreateAdd(Result, V, "sunkaddr", InsertPt); else Result = V; } @@ -902,7 +902,7 @@ bool CodeGenPrepare::OptimizeLoadStoreInst(Instruction *LdStInst, Value *Addr, Value *V = new PtrToIntInst(AddrMode.BaseGV, IntPtrTy, "sunkaddr", InsertPt); if (Result) - Result = BinaryOperator::createAdd(Result, V, "sunkaddr", InsertPt); + Result = BinaryOperator::CreateAdd(Result, V, "sunkaddr", InsertPt); else Result = V; } @@ -911,7 +911,7 @@ bool CodeGenPrepare::OptimizeLoadStoreInst(Instruction *LdStInst, Value *Addr, if (AddrMode.BaseOffs) { Value *V = ConstantInt::get(IntPtrTy, AddrMode.BaseOffs); if (Result) - Result = BinaryOperator::createAdd(Result, V, "sunkaddr", InsertPt); + Result = BinaryOperator::CreateAdd(Result, V, "sunkaddr", InsertPt); else Result = V; } diff --git a/lib/Transforms/Scalar/GVNPRE.cpp b/lib/Transforms/Scalar/GVNPRE.cpp index 90e6a71..1746fd8 100644 --- a/lib/Transforms/Scalar/GVNPRE.cpp +++ b/lib/Transforms/Scalar/GVNPRE.cpp @@ -804,7 +804,7 @@ Value* GVNPRE::phi_translate(Value* V, BasicBlock* pred, BasicBlock* succ) { if (newOp1 != U->getOperand(0)) { Instruction* newVal = 0; if (CastInst* C = dyn_cast<CastInst>(U)) - newVal = CastInst::create(C->getOpcode(), + newVal = CastInst::Create(C->getOpcode(), newOp1, C->getType(), C->getName()+".expr"); @@ -847,11 +847,11 @@ Value* GVNPRE::phi_translate(Value* V, BasicBlock* pred, BasicBlock* succ) { if (newOp1 != U->getOperand(0) || newOp2 != U->getOperand(1)) { Instruction* newVal = 0; if (BinaryOperator* BO = dyn_cast<BinaryOperator>(U)) - newVal = BinaryOperator::create(BO->getOpcode(), + newVal = BinaryOperator::Create(BO->getOpcode(), newOp1, newOp2, BO->getName()+".expr"); else if (CmpInst* C = dyn_cast<CmpInst>(U)) - newVal = CmpInst::create(C->getOpcode(), + newVal = CmpInst::Create(C->getOpcode(), C->getPredicate(), newOp1, newOp2, C->getName()+".expr"); @@ -1665,11 +1665,11 @@ void GVNPRE::insertion_pre(Value* e, BasicBlock* BB, Value* newVal = 0; if (BinaryOperator* BO = dyn_cast<BinaryOperator>(U)) - newVal = BinaryOperator::create(BO->getOpcode(), s1, s2, + newVal = BinaryOperator::Create(BO->getOpcode(), s1, s2, BO->getName()+".gvnpre", (*PI)->getTerminator()); else if (CmpInst* C = dyn_cast<CmpInst>(U)) - newVal = CmpInst::create(C->getOpcode(), C->getPredicate(), s1, s2, + newVal = CmpInst::Create(C->getOpcode(), C->getPredicate(), s1, s2, C->getName()+".gvnpre", (*PI)->getTerminator()); else if (ShuffleVectorInst* S = dyn_cast<ShuffleVectorInst>(U)) @@ -1685,7 +1685,7 @@ void GVNPRE::insertion_pre(Value* e, BasicBlock* BB, newVal = SelectInst::Create(s1, s2, s3, S->getName()+".gvnpre", (*PI)->getTerminator()); else if (CastInst* C = dyn_cast<CastInst>(U)) - newVal = CastInst::create(C->getOpcode(), s1, C->getType(), + newVal = CastInst::Create(C->getOpcode(), s1, C->getType(), C->getName()+".gvnpre", (*PI)->getTerminator()); else if (GetElementPtrInst* G = dyn_cast<GetElementPtrInst>(U)) diff --git a/lib/Transforms/Scalar/IndVarSimplify.cpp b/lib/Transforms/Scalar/IndVarSimplify.cpp index 4de19a9..ed37765 100644 --- a/lib/Transforms/Scalar/IndVarSimplify.cpp +++ b/lib/Transforms/Scalar/IndVarSimplify.cpp @@ -151,7 +151,7 @@ void IndVarSimplify::EliminatePointerRecurrence(PHINode *PN, NewPhi->addIncoming(Constant::getNullValue(NewPhi->getType()), Preheader); // Create the new add instruction. - Value *NewAdd = BinaryOperator::createAdd(NewPhi, AddedVal, + Value *NewAdd = BinaryOperator::CreateAdd(NewPhi, AddedVal, GEPI->getName()+".rec", GEPI); NewPhi->addIncoming(NewAdd, PN->getIncomingBlock(BackedgeIdx)); diff --git a/lib/Transforms/Scalar/InstructionCombining.cpp b/lib/Transforms/Scalar/InstructionCombining.cpp index 0f9df27..41282f2 100644 --- a/lib/Transforms/Scalar/InstructionCombining.cpp +++ b/lib/Transforms/Scalar/InstructionCombining.cpp @@ -263,7 +263,7 @@ namespace { if (Constant *CV = dyn_cast<Constant>(V)) return ConstantExpr::getCast(opc, CV, Ty); - Instruction *C = CastInst::create(opc, V, Ty, V->getName(), &Pos); + Instruction *C = CastInst::Create(opc, V, Ty, V->getName(), &Pos); AddToWorkList(C); return C; } @@ -513,7 +513,7 @@ bool InstCombiner::SimplifyCommutative(BinaryOperator &I) { // Fold (op (op V1, C1), (op V2, C2)) ==> (op (op V1, V2), (op C1,C2)) Constant *Folded = ConstantExpr::get(I.getOpcode(), C1, C2); - Instruction *New = BinaryOperator::create(Opcode, Op->getOperand(0), + Instruction *New = BinaryOperator::Create(Opcode, Op->getOperand(0), Op1->getOperand(0), Op1->getName(), &I); AddToWorkList(New); @@ -1393,7 +1393,7 @@ bool InstCombiner::SimplifyDemandedBits(Value *V, APInt DemandedMask, // e.g. (A & C1)^(B & C2) -> (A & C1)|(B & C2) iff C1&C2 == 0 if ((DemandedMask & ~RHSKnownZero & ~LHSKnownZero) == 0) { Instruction *Or = - BinaryOperator::createOr(I->getOperand(0), I->getOperand(1), + BinaryOperator::CreateOr(I->getOperand(0), I->getOperand(1), I->getName()); InsertNewInstBefore(Or, *I); return UpdateValueUsesWith(I, Or); @@ -1408,7 +1408,7 @@ bool InstCombiner::SimplifyDemandedBits(Value *V, APInt DemandedMask, if ((RHSKnownOne & LHSKnownOne) == RHSKnownOne) { Constant *AndC = ConstantInt::get(~RHSKnownOne & DemandedMask); Instruction *And = - BinaryOperator::createAnd(I->getOperand(0), AndC, "tmp"); + BinaryOperator::CreateAnd(I->getOperand(0), AndC, "tmp"); InsertNewInstBefore(And, *I); return UpdateValueUsesWith(I, And); } @@ -1567,7 +1567,7 @@ bool InstCombiner::SimplifyDemandedBits(Value *V, APInt DemandedMask, // Turn it into OR if input bits are zero. if ((LHSKnownZero & RHS->getValue()) == RHS->getValue()) { Instruction *Or = - BinaryOperator::createOr(I->getOperand(0), I->getOperand(1), + BinaryOperator::CreateOr(I->getOperand(0), I->getOperand(1), I->getName()); InsertNewInstBefore(Or, *I); return UpdateValueUsesWith(I, Or); @@ -1675,7 +1675,7 @@ bool InstCombiner::SimplifyDemandedBits(Value *V, APInt DemandedMask, // the shift amount is >= the size of the datatype, which is undefined. if (DemandedMask == 1) { // Perform the logical shift right. - Value *NewVal = BinaryOperator::createLShr( + Value *NewVal = BinaryOperator::CreateLShr( I->getOperand(0), I->getOperand(1), I->getName()); InsertNewInstBefore(cast<Instruction>(NewVal), *I); return UpdateValueUsesWith(I, NewVal); @@ -1716,7 +1716,7 @@ bool InstCombiner::SimplifyDemandedBits(Value *V, APInt DemandedMask, if (RHSKnownZero[BitWidth-ShiftAmt-1] || (HighBits & ~DemandedMask) == HighBits) { // Perform the logical shift right. - Value *NewVal = BinaryOperator::createLShr( + Value *NewVal = BinaryOperator::CreateLShr( I->getOperand(0), SA, I->getName()); InsertNewInstBefore(cast<Instruction>(NewVal), *I); return UpdateValueUsesWith(I, NewVal); @@ -2026,12 +2026,12 @@ Value *InstCombiner::SimplifyDemandedVectorElts(Value *V, uint64_t DemandedElts, default: assert(0 && "Case stmts out of sync!"); case Intrinsic::x86_sse_sub_ss: case Intrinsic::x86_sse2_sub_sd: - TmpV = InsertNewInstBefore(BinaryOperator::createSub(LHS, RHS, + TmpV = InsertNewInstBefore(BinaryOperator::CreateSub(LHS, RHS, II->getName()), *II); break; case Intrinsic::x86_sse_mul_ss: case Intrinsic::x86_sse2_mul_sd: - TmpV = InsertNewInstBefore(BinaryOperator::createMul(LHS, RHS, + TmpV = InsertNewInstBefore(BinaryOperator::CreateMul(LHS, RHS, II->getName()), *II); break; } @@ -2160,7 +2160,7 @@ struct AddRHS { AddRHS(Value *rhs) : RHS(rhs) {} bool shouldApply(Value *LHS) const { return LHS == RHS; } Instruction *apply(BinaryOperator &Add) const { - return BinaryOperator::createShl(Add.getOperand(0), + return BinaryOperator::CreateShl(Add.getOperand(0), ConstantInt::get(Add.getType(), 1)); } }; @@ -2176,7 +2176,7 @@ struct AddMaskingAnd { ConstantExpr::getAnd(C1, C2)->isNullValue(); } Instruction *apply(BinaryOperator &Add) const { - return BinaryOperator::createOr(Add.getOperand(0), Add.getOperand(1)); + return BinaryOperator::CreateOr(Add.getOperand(0), Add.getOperand(1)); } }; @@ -2188,7 +2188,7 @@ static Value *FoldOperationIntoSelectOperand(Instruction &I, Value *SO, if (Constant *SOC = dyn_cast<Constant>(SO)) return ConstantExpr::getCast(CI->getOpcode(), SOC, I.getType()); - return IC->InsertNewInstBefore(CastInst::create( + return IC->InsertNewInstBefore(CastInst::Create( CI->getOpcode(), SO, I.getType(), SO->getName() + ".cast"), I); } @@ -2207,9 +2207,9 @@ static Value *FoldOperationIntoSelectOperand(Instruction &I, Value *SO, std::swap(Op0, Op1); Instruction *New; if (BinaryOperator *BO = dyn_cast<BinaryOperator>(&I)) - New = BinaryOperator::create(BO->getOpcode(), Op0, Op1,SO->getName()+".op"); + New = BinaryOperator::Create(BO->getOpcode(), Op0, Op1,SO->getName()+".op"); else if (CmpInst *CI = dyn_cast<CmpInst>(&I)) - New = CmpInst::create(CI->getOpcode(), CI->getPredicate(), Op0, Op1, + New = CmpInst::Create(CI->getOpcode(), CI->getPredicate(), Op0, Op1, SO->getName()+".cmp"); else { assert(0 && "Unknown binary instruction type!"); @@ -2295,11 +2295,11 @@ Instruction *InstCombiner::FoldOpIntoPhi(Instruction &I) { } else { assert(PN->getIncomingBlock(i) == NonConstBB); if (BinaryOperator *BO = dyn_cast<BinaryOperator>(&I)) - InV = BinaryOperator::create(BO->getOpcode(), + InV = BinaryOperator::Create(BO->getOpcode(), PN->getIncomingValue(i), C, "phitmp", NonConstBB->getTerminator()); else if (CmpInst *CI = dyn_cast<CmpInst>(&I)) - InV = CmpInst::create(CI->getOpcode(), + InV = CmpInst::Create(CI->getOpcode(), CI->getPredicate(), PN->getIncomingValue(i), C, "phitmp", NonConstBB->getTerminator()); @@ -2319,7 +2319,7 @@ Instruction *InstCombiner::FoldOpIntoPhi(Instruction &I) { InV = ConstantExpr::getCast(CI->getOpcode(), InC, RetTy); } else { assert(PN->getIncomingBlock(i) == NonConstBB); - InV = CastInst::create(CI->getOpcode(), PN->getIncomingValue(i), + InV = CastInst::Create(CI->getOpcode(), PN->getIncomingValue(i), I.getType(), "phitmp", NonConstBB->getTerminator()); AddToWorkList(cast<Instruction>(InV)); @@ -2396,7 +2396,7 @@ Instruction *InstCombiner::visitAdd(BinaryOperator &I) { const APInt& Val = CI->getValue(); uint32_t BitWidth = Val.getBitWidth(); if (Val == APInt::getSignBit(BitWidth)) - return BinaryOperator::createXor(LHS, RHS); + return BinaryOperator::CreateXor(LHS, RHS); // See if SimplifyDemandedBits can simplify this. This handles stuff like // (X & 254)+1 -> (X&254)|1 @@ -2480,35 +2480,35 @@ Instruction *InstCombiner::visitAdd(BinaryOperator &I) { if (Value *LHSV = dyn_castNegVal(LHS)) { if (LHS->getType()->isIntOrIntVector()) { if (Value *RHSV = dyn_castNegVal(RHS)) { - Instruction *NewAdd = BinaryOperator::createAdd(LHSV, RHSV, "sum"); + Instruction *NewAdd = BinaryOperator::CreateAdd(LHSV, RHSV, "sum"); InsertNewInstBefore(NewAdd, I); - return BinaryOperator::createNeg(NewAdd); + return BinaryOperator::CreateNeg(NewAdd); } } - return BinaryOperator::createSub(RHS, LHSV); + return BinaryOperator::CreateSub(RHS, LHSV); } // A + -B --> A - B if (!isa<Constant>(RHS)) if (Value *V = dyn_castNegVal(RHS)) - return BinaryOperator::createSub(LHS, V); + return BinaryOperator::CreateSub(LHS, V); ConstantInt *C2; if (Value *X = dyn_castFoldableMul(LHS, C2)) { if (X == RHS) // X*C + X --> X * (C+1) - return BinaryOperator::createMul(RHS, AddOne(C2)); + return BinaryOperator::CreateMul(RHS, AddOne(C2)); // X*C1 + X*C2 --> X * (C1+C2) ConstantInt *C1; if (X == dyn_castFoldableMul(RHS, C1)) - return BinaryOperator::createMul(X, Add(C1, C2)); + return BinaryOperator::CreateMul(X, Add(C1, C2)); } // X + X*C --> X * (C+1) if (dyn_castFoldableMul(RHS, C2) == LHS) - return BinaryOperator::createMul(LHS, AddOne(C2)); + return BinaryOperator::CreateMul(LHS, AddOne(C2)); // X + ~X --> -1 since ~X = -X-1 if (dyn_castNotVal(LHS) == RHS || dyn_castNotVal(RHS) == LHS) @@ -2537,9 +2537,9 @@ Instruction *InstCombiner::visitAdd(BinaryOperator &I) { } if (W == Y) { - Value *NewAdd = InsertNewInstBefore(BinaryOperator::createAdd(X, Z, + Value *NewAdd = InsertNewInstBefore(BinaryOperator::CreateAdd(X, Z, LHS->getName()), I); - return BinaryOperator::createMul(W, NewAdd); + return BinaryOperator::CreateMul(W, NewAdd); } } } @@ -2547,7 +2547,7 @@ Instruction *InstCombiner::visitAdd(BinaryOperator &I) { if (ConstantInt *CRHS = dyn_cast<ConstantInt>(RHS)) { Value *X = 0; if (match(LHS, m_Not(m_Value(X)))) // ~X + C --> (C-1) - X - return BinaryOperator::createSub(SubOne(CRHS), X); + return BinaryOperator::CreateSub(SubOne(CRHS), X); // (X & FF00) + xx00 -> (X+xx00) & FF00 if (LHS->hasOneUse() && match(LHS, m_And(m_Value(X), m_ConstantInt(C2)))) { @@ -2565,9 +2565,9 @@ Instruction *InstCombiner::visitAdd(BinaryOperator &I) { if (AddRHSHighBits == AddRHSHighBitsAnd) { // Okay, the xform is safe. Insert the new add pronto. - Value *NewAdd = InsertNewInstBefore(BinaryOperator::createAdd(X, CRHS, + Value *NewAdd = InsertNewInstBefore(BinaryOperator::CreateAdd(X, CRHS, LHS->getName()), I); - return BinaryOperator::createAnd(NewAdd, C2); + return BinaryOperator::CreateAnd(NewAdd, C2); } } } @@ -2647,7 +2647,7 @@ Instruction *InstCombiner::visitSub(BinaryOperator &I) { // If this is a 'B = x-(-A)', change to B = x+A... if (Value *V = dyn_castNegVal(Op1)) - return BinaryOperator::createAdd(Op0, V); + return BinaryOperator::CreateAdd(Op0, V); if (isa<UndefValue>(Op0)) return ReplaceInstUsesWith(I, Op0); // undef - X -> undef @@ -2657,12 +2657,12 @@ Instruction *InstCombiner::visitSub(BinaryOperator &I) { if (ConstantInt *C = dyn_cast<ConstantInt>(Op0)) { // Replace (-1 - A) with (~A)... if (C->isAllOnesValue()) - return BinaryOperator::createNot(Op1); + return BinaryOperator::CreateNot(Op1); // C - ~X == X + (1+C) Value *X = 0; if (match(Op1, m_Not(m_Value(X)))) - return BinaryOperator::createAdd(X, AddOne(C)); + return BinaryOperator::CreateAdd(X, AddOne(C)); // -(X >>u 31) -> (X >>s 31) // -(X >>s 31) -> (X >>u 31) @@ -2674,7 +2674,7 @@ Instruction *InstCombiner::visitSub(BinaryOperator &I) { if (CU->getLimitedValue(SI->getType()->getPrimitiveSizeInBits()) == SI->getType()->getPrimitiveSizeInBits()-1) { // Ok, the transformation is safe. Insert AShr. - return BinaryOperator::create(Instruction::AShr, + return BinaryOperator::Create(Instruction::AShr, SI->getOperand(0), CU, SI->getName()); } } @@ -2685,7 +2685,7 @@ Instruction *InstCombiner::visitSub(BinaryOperator &I) { if (CU->getLimitedValue(SI->getType()->getPrimitiveSizeInBits()) == SI->getType()->getPrimitiveSizeInBits()-1) { // Ok, the transformation is safe. Insert LShr. - return BinaryOperator::createLShr( + return BinaryOperator::CreateLShr( SI->getOperand(0), CU, SI->getName()); } } @@ -2707,13 +2707,13 @@ Instruction *InstCombiner::visitSub(BinaryOperator &I) { if (Op1I->getOpcode() == Instruction::Add && !Op0->getType()->isFPOrFPVector()) { if (Op1I->getOperand(0) == Op0) // X-(X+Y) == -Y - return BinaryOperator::createNeg(Op1I->getOperand(1), I.getName()); + return BinaryOperator::CreateNeg(Op1I->getOperand(1), I.getName()); else if (Op1I->getOperand(1) == Op0) // X-(Y+X) == -Y - return BinaryOperator::createNeg(Op1I->getOperand(0), I.getName()); + return BinaryOperator::CreateNeg(Op1I->getOperand(0), I.getName()); else if (ConstantInt *CI1 = dyn_cast<ConstantInt>(I.getOperand(0))) { if (ConstantInt *CI2 = dyn_cast<ConstantInt>(Op1I->getOperand(1))) // C1-(X+C2) --> (C1-C2)-X - return BinaryOperator::createSub(Subtract(CI1, CI2), + return BinaryOperator::CreateSub(Subtract(CI1, CI2), Op1I->getOperand(0)); } } @@ -2730,7 +2730,7 @@ Instruction *InstCombiner::visitSub(BinaryOperator &I) { Op1I->setOperand(1, IIOp0); // Create the new top level add instruction... - return BinaryOperator::createAdd(Op0, Op1); + return BinaryOperator::CreateAdd(Op0, Op1); } // Replace (A - (A & B)) with (A & ~B) if this is the only use of (A&B)... @@ -2740,8 +2740,8 @@ Instruction *InstCombiner::visitSub(BinaryOperator &I) { Value *OtherOp = Op1I->getOperand(Op1I->getOperand(0) == Op0); Value *NewNot = - InsertNewInstBefore(BinaryOperator::createNot(OtherOp, "B.not"), I); - return BinaryOperator::createAnd(Op0, NewNot); + InsertNewInstBefore(BinaryOperator::CreateNot(OtherOp, "B.not"), I); + return BinaryOperator::CreateAnd(Op0, NewNot); } // 0 - (X sdiv C) -> (X sdiv -C) @@ -2749,14 +2749,14 @@ Instruction *InstCombiner::visitSub(BinaryOperator &I) { if (ConstantInt *CSI = dyn_cast<ConstantInt>(Op0)) if (CSI->isZero()) if (Constant *DivRHS = dyn_cast<Constant>(Op1I->getOperand(1))) - return BinaryOperator::createSDiv(Op1I->getOperand(0), + return BinaryOperator::CreateSDiv(Op1I->getOperand(0), ConstantExpr::getNeg(DivRHS)); // X - X*C --> X * (1-C) ConstantInt *C2 = 0; if (dyn_castFoldableMul(Op1I, C2) == Op0) { Constant *CP1 = Subtract(ConstantInt::get(I.getType(), 1), C2); - return BinaryOperator::createMul(Op0, CP1); + return BinaryOperator::CreateMul(Op0, CP1); } // X - ((X / Y) * Y) --> X % Y @@ -2765,9 +2765,9 @@ Instruction *InstCombiner::visitSub(BinaryOperator &I) { if (Op0 == I->getOperand(0) && Op1I->getOperand(1) == I->getOperand(1)) { if (I->getOpcode() == Instruction::SDiv) - return BinaryOperator::createSRem(Op0, Op1I->getOperand(1)); + return BinaryOperator::CreateSRem(Op0, Op1I->getOperand(1)); if (I->getOpcode() == Instruction::UDiv) - return BinaryOperator::createURem(Op0, Op1I->getOperand(1)); + return BinaryOperator::CreateURem(Op0, Op1I->getOperand(1)); } } } @@ -2781,18 +2781,18 @@ Instruction *InstCombiner::visitSub(BinaryOperator &I) { return ReplaceInstUsesWith(I, Op0I->getOperand(0)); } else if (Op0I->getOpcode() == Instruction::Sub) { if (Op0I->getOperand(0) == Op1) // (X-Y)-X == -Y - return BinaryOperator::createNeg(Op0I->getOperand(1), I.getName()); + return BinaryOperator::CreateNeg(Op0I->getOperand(1), I.getName()); } } ConstantInt *C1; if (Value *X = dyn_castFoldableMul(Op0, C1)) { if (X == Op1) // X*C - X --> X * (C-1) - return BinaryOperator::createMul(Op1, SubOne(C1)); + return BinaryOperator::CreateMul(Op1, SubOne(C1)); ConstantInt *C2; // X*C1 - X*C2 -> X * (C1-C2) if (X == dyn_castFoldableMul(Op1, C2)) - return BinaryOperator::createMul(X, Subtract(C1, C2)); + return BinaryOperator::CreateMul(X, Subtract(C1, C2)); } return 0; } @@ -2843,7 +2843,7 @@ Instruction *InstCombiner::visitMul(BinaryOperator &I) { if (BinaryOperator *SI = dyn_cast<BinaryOperator>(Op0)) if (SI->getOpcode() == Instruction::Shl) if (Constant *ShOp = dyn_cast<Constant>(SI->getOperand(1))) - return BinaryOperator::createMul(SI->getOperand(0), + return BinaryOperator::CreateMul(SI->getOperand(0), ConstantExpr::getShl(CI, ShOp)); if (CI->isZero()) @@ -2851,11 +2851,11 @@ Instruction *InstCombiner::visitMul(BinaryOperator &I) { if (CI->equalsInt(1)) // X * 1 == X return ReplaceInstUsesWith(I, Op0); if (CI->isAllOnesValue()) // X * -1 == 0 - X - return BinaryOperator::createNeg(Op0, I.getName()); + return BinaryOperator::CreateNeg(Op0, I.getName()); const APInt& Val = cast<ConstantInt>(CI)->getValue(); if (Val.isPowerOf2()) { // Replace X*(2^C) with X << C - return BinaryOperator::createShl(Op0, + return BinaryOperator::CreateShl(Op0, ConstantInt::get(Op0->getType(), Val.logBase2())); } } else if (ConstantFP *Op1F = dyn_cast<ConstantFP>(Op1)) { @@ -2874,12 +2874,12 @@ Instruction *InstCombiner::visitMul(BinaryOperator &I) { if (Op0I->getOpcode() == Instruction::Add && Op0I->hasOneUse() && isa<ConstantInt>(Op0I->getOperand(1))) { // Canonicalize (X+C1)*C2 -> X*C2+C1*C2. - Instruction *Add = BinaryOperator::createMul(Op0I->getOperand(0), + Instruction *Add = BinaryOperator::CreateMul(Op0I->getOperand(0), Op1, "tmp"); InsertNewInstBefore(Add, I); Value *C1C2 = ConstantExpr::getMul(Op1, cast<Constant>(Op0I->getOperand(1))); - return BinaryOperator::createAdd(Add, C1C2); + return BinaryOperator::CreateAdd(Add, C1C2); } @@ -2895,7 +2895,7 @@ Instruction *InstCombiner::visitMul(BinaryOperator &I) { if (Value *Op0v = dyn_castNegVal(Op0)) // -X * -Y = X*Y if (Value *Op1v = dyn_castNegVal(I.getOperand(1))) - return BinaryOperator::createMul(Op0v, Op1v); + return BinaryOperator::CreateMul(Op0v, Op1v); // If one of the operands of the multiply is a cast from a boolean value, then // we know the bool is either zero or one, so this is a 'masking' multiply. @@ -2925,7 +2925,7 @@ Instruction *InstCombiner::visitMul(BinaryOperator &I) { SCOpTy->getPrimitiveSizeInBits()-1); Value *V = InsertNewInstBefore( - BinaryOperator::create(Instruction::AShr, SCIOp0, Amt, + BinaryOperator::Create(Instruction::AShr, SCIOp0, Amt, BoolCast->getOperand(0)->getName()+ ".mask"), I); @@ -2941,7 +2941,7 @@ Instruction *InstCombiner::visitMul(BinaryOperator &I) { } Value *OtherOp = Op0 == BoolCast ? I.getOperand(1) : Op0; - return BinaryOperator::createAnd(V, OtherOp); + return BinaryOperator::CreateAnd(V, OtherOp); } } } @@ -3031,7 +3031,7 @@ Instruction *InstCombiner::commonIDivTransforms(BinaryOperator &I) { if (MultiplyOverflows(RHS, LHSRHS, I.getOpcode()==Instruction::SDiv)) return ReplaceInstUsesWith(I, Constant::getNullValue(I.getType())); else - return BinaryOperator::create(I.getOpcode(), LHS->getOperand(0), + return BinaryOperator::Create(I.getOpcode(), LHS->getOperand(0), Multiply(RHS, LHSRHS)); } @@ -3065,7 +3065,7 @@ Instruction *InstCombiner::visitUDiv(BinaryOperator &I) { // if so, convert to a right shift. if (ConstantInt *C = dyn_cast<ConstantInt>(Op1)) { if (C->getValue().isPowerOf2()) // 0 not included in isPowerOf2 - return BinaryOperator::createLShr(Op0, + return BinaryOperator::CreateLShr(Op0, ConstantInt::get(Op0->getType(), C->getValue().logBase2())); } @@ -3079,9 +3079,9 @@ Instruction *InstCombiner::visitUDiv(BinaryOperator &I) { const Type *NTy = N->getType(); if (uint32_t C2 = C1.logBase2()) { Constant *C2V = ConstantInt::get(NTy, C2); - N = InsertNewInstBefore(BinaryOperator::createAdd(N, C2V, "tmp"), I); + N = InsertNewInstBefore(BinaryOperator::CreateAdd(N, C2V, "tmp"), I); } - return BinaryOperator::createLShr(Op0, N); + return BinaryOperator::CreateLShr(Op0, N); } } } @@ -3097,13 +3097,13 @@ Instruction *InstCombiner::visitUDiv(BinaryOperator &I) { uint32_t TSA = TVA.logBase2(), FSA = FVA.logBase2(); // Construct the "on true" case of the select Constant *TC = ConstantInt::get(Op0->getType(), TSA); - Instruction *TSI = BinaryOperator::createLShr( + Instruction *TSI = BinaryOperator::CreateLShr( Op0, TC, SI->getName()+".t"); TSI = InsertNewInstBefore(TSI, I); // Construct the "on false" case of the select Constant *FC = ConstantInt::get(Op0->getType(), FSA); - Instruction *FSI = BinaryOperator::createLShr( + Instruction *FSI = BinaryOperator::CreateLShr( Op0, FC, SI->getName()+".f"); FSI = InsertNewInstBefore(FSI, I); @@ -3124,11 +3124,11 @@ Instruction *InstCombiner::visitSDiv(BinaryOperator &I) { if (ConstantInt *RHS = dyn_cast<ConstantInt>(Op1)) { // sdiv X, -1 == -X if (RHS->isAllOnesValue()) - return BinaryOperator::createNeg(Op0); + return BinaryOperator::CreateNeg(Op0); // -X/C -> X/-C if (Value *LHSNeg = dyn_castNegVal(Op0)) - return BinaryOperator::createSDiv(LHSNeg, ConstantExpr::getNeg(RHS)); + return BinaryOperator::CreateSDiv(LHSNeg, ConstantExpr::getNeg(RHS)); } // If the sign bits of both operands are zero (i.e. we can prove they are @@ -3137,7 +3137,7 @@ Instruction *InstCombiner::visitSDiv(BinaryOperator &I) { APInt Mask(APInt::getSignBit(I.getType()->getPrimitiveSizeInBits())); if (MaskedValueIsZero(Op1, Mask) && MaskedValueIsZero(Op0, Mask)) { // X sdiv Y -> X udiv Y, iff X and Y don't have sign bit set - return BinaryOperator::createUDiv(Op0, Op1, I.getName()); + return BinaryOperator::CreateUDiv(Op0, Op1, I.getName()); } } @@ -3254,7 +3254,7 @@ Instruction *InstCombiner::visitURem(BinaryOperator &I) { // if so, convert to a bitwise and. if (ConstantInt *C = dyn_cast<ConstantInt>(RHS)) if (C->getValue().isPowerOf2()) - return BinaryOperator::createAnd(Op0, SubOne(C)); + return BinaryOperator::CreateAnd(Op0, SubOne(C)); } if (Instruction *RHSI = dyn_cast<Instruction>(I.getOperand(1))) { @@ -3263,9 +3263,9 @@ Instruction *InstCombiner::visitURem(BinaryOperator &I) { isa<ConstantInt>(RHSI->getOperand(0))) { if (cast<ConstantInt>(RHSI->getOperand(0))->getValue().isPowerOf2()) { Constant *N1 = ConstantInt::getAllOnesValue(I.getType()); - Value *Add = InsertNewInstBefore(BinaryOperator::createAdd(RHSI, N1, + Value *Add = InsertNewInstBefore(BinaryOperator::CreateAdd(RHSI, N1, "tmp"), I); - return BinaryOperator::createAnd(Op0, Add); + return BinaryOperator::CreateAnd(Op0, Add); } } } @@ -3279,9 +3279,9 @@ Instruction *InstCombiner::visitURem(BinaryOperator &I) { if ((STO->getValue().isPowerOf2()) && (SFO->getValue().isPowerOf2())) { Value *TrueAnd = InsertNewInstBefore( - BinaryOperator::createAnd(Op0, SubOne(STO), SI->getName()+".t"), I); + BinaryOperator::CreateAnd(Op0, SubOne(STO), SI->getName()+".t"), I); Value *FalseAnd = InsertNewInstBefore( - BinaryOperator::createAnd(Op0, SubOne(SFO), SI->getName()+".f"), I); + BinaryOperator::CreateAnd(Op0, SubOne(SFO), SI->getName()+".f"), I); return SelectInst::Create(SI->getOperand(0), TrueAnd, FalseAnd); } } @@ -3312,7 +3312,7 @@ Instruction *InstCombiner::visitSRem(BinaryOperator &I) { APInt Mask(APInt::getSignBit(I.getType()->getPrimitiveSizeInBits())); if (MaskedValueIsZero(Op1, Mask) && MaskedValueIsZero(Op0, Mask)) { // X srem Y -> X urem Y, iff X and Y don't have sign bit set - return BinaryOperator::createURem(Op0, Op1, I.getName()); + return BinaryOperator::CreateURem(Op0, Op1, I.getName()); } } @@ -3500,10 +3500,10 @@ Instruction *InstCombiner::OptAndOp(Instruction *Op, case Instruction::Xor: if (Op->hasOneUse()) { // (X ^ C1) & C2 --> (X & C2) ^ (C1&C2) - Instruction *And = BinaryOperator::createAnd(X, AndRHS); + Instruction *And = BinaryOperator::CreateAnd(X, AndRHS); InsertNewInstBefore(And, TheAnd); And->takeName(Op); - return BinaryOperator::createXor(And, Together); + return BinaryOperator::CreateXor(And, Together); } break; case Instruction::Or: @@ -3512,10 +3512,10 @@ Instruction *InstCombiner::OptAndOp(Instruction *Op, if (Op->hasOneUse() && Together != OpRHS) { // (X | C1) & C2 --> (X | (C1&C2)) & C2 - Instruction *Or = BinaryOperator::createOr(X, Together); + Instruction *Or = BinaryOperator::CreateOr(X, Together); InsertNewInstBefore(Or, TheAnd); Or->takeName(Op); - return BinaryOperator::createAnd(Or, AndRHS); + return BinaryOperator::CreateAnd(Or, AndRHS); } break; case Instruction::Add: @@ -3543,10 +3543,10 @@ Instruction *InstCombiner::OptAndOp(Instruction *Op, return &TheAnd; } else { // Pull the XOR out of the AND. - Instruction *NewAnd = BinaryOperator::createAnd(X, AndRHS); + Instruction *NewAnd = BinaryOperator::CreateAnd(X, AndRHS); InsertNewInstBefore(NewAnd, TheAnd); NewAnd->takeName(Op); - return BinaryOperator::createXor(NewAnd, AndRHS); + return BinaryOperator::CreateXor(NewAnd, AndRHS); } } } @@ -3605,9 +3605,9 @@ Instruction *InstCombiner::OptAndOp(Instruction *Op, // Make the argument unsigned. Value *ShVal = Op->getOperand(0); ShVal = InsertNewInstBefore( - BinaryOperator::createLShr(ShVal, OpRHS, + BinaryOperator::CreateLShr(ShVal, OpRHS, Op->getName()), TheAnd); - return BinaryOperator::createAnd(ShVal, AndRHS, TheAnd.getName()); + return BinaryOperator::CreateAnd(ShVal, AndRHS, TheAnd.getName()); } } break; @@ -3641,7 +3641,7 @@ Instruction *InstCombiner::InsertRangeTest(Value *V, Constant *Lo, Constant *Hi, // Emit V-Lo <u Hi-Lo Constant *NegLo = ConstantExpr::getNeg(Lo); - Instruction *Add = BinaryOperator::createAdd(V, NegLo, V->getName()+".off"); + Instruction *Add = BinaryOperator::CreateAdd(V, NegLo, V->getName()+".off"); InsertNewInstBefore(Add, IB); Constant *UpperBound = ConstantExpr::getAdd(NegLo, Hi); return new ICmpInst(ICmpInst::ICMP_ULT, Add, UpperBound); @@ -3661,7 +3661,7 @@ Instruction *InstCombiner::InsertRangeTest(Value *V, Constant *Lo, Constant *Hi, // Emit V-Lo >u Hi-1-Lo // Note that Hi has already had one subtracted from it, above. ConstantInt *NegLo = cast<ConstantInt>(ConstantExpr::getNeg(Lo)); - Instruction *Add = BinaryOperator::createAdd(V, NegLo, V->getName()+".off"); + Instruction *Add = BinaryOperator::CreateAdd(V, NegLo, V->getName()+".off"); InsertNewInstBefore(Add, IB); Constant *LowerBound = ConstantExpr::getAdd(NegLo, Hi); return new ICmpInst(ICmpInst::ICMP_UGT, Add, LowerBound); @@ -3736,9 +3736,9 @@ Value *InstCombiner::FoldLogicalPlusAnd(Value *LHS, Value *RHS, Instruction *New; if (isSub) - New = BinaryOperator::createSub(LHSI->getOperand(0), RHS, "fold"); + New = BinaryOperator::CreateSub(LHSI->getOperand(0), RHS, "fold"); else - New = BinaryOperator::createAdd(LHSI->getOperand(0), RHS, "fold"); + New = BinaryOperator::CreateAdd(LHSI->getOperand(0), RHS, "fold"); return InsertNewInstBefore(New, I); } @@ -3786,19 +3786,19 @@ Instruction *InstCombiner::visitAnd(BinaryOperator &I) { if (Op0I->hasOneUse()) { if (MaskedValueIsZero(Op0LHS, NotAndRHS)) { // Not masking anything out for the LHS, move to RHS. - Instruction *NewRHS = BinaryOperator::createAnd(Op0RHS, AndRHS, + Instruction *NewRHS = BinaryOperator::CreateAnd(Op0RHS, AndRHS, Op0RHS->getName()+".masked"); InsertNewInstBefore(NewRHS, I); - return BinaryOperator::create( + return BinaryOperator::Create( cast<BinaryOperator>(Op0I)->getOpcode(), Op0LHS, NewRHS); } if (!isa<Constant>(Op0RHS) && MaskedValueIsZero(Op0RHS, NotAndRHS)) { // Not masking anything out for the RHS, move to LHS. - Instruction *NewLHS = BinaryOperator::createAnd(Op0LHS, AndRHS, + Instruction *NewLHS = BinaryOperator::CreateAnd(Op0LHS, AndRHS, Op0LHS->getName()+".masked"); InsertNewInstBefore(NewLHS, I); - return BinaryOperator::create( + return BinaryOperator::Create( cast<BinaryOperator>(Op0I)->getOpcode(), NewLHS, Op0RHS); } } @@ -3809,9 +3809,9 @@ Instruction *InstCombiner::visitAnd(BinaryOperator &I) { // ((A | N) + B) & AndRHS -> (A + B) & AndRHS iff N&AndRHS == 0 // ((A ^ N) + B) & AndRHS -> (A + B) & AndRHS iff N&AndRHS == 0 if (Value *V = FoldLogicalPlusAnd(Op0LHS, Op0RHS, AndRHS, false, I)) - return BinaryOperator::createAnd(V, AndRHS); + return BinaryOperator::CreateAnd(V, AndRHS); if (Value *V = FoldLogicalPlusAnd(Op0RHS, Op0LHS, AndRHS, false, I)) - return BinaryOperator::createAnd(V, AndRHS); // Add commutes + return BinaryOperator::CreateAnd(V, AndRHS); // Add commutes break; case Instruction::Sub: @@ -3819,7 +3819,7 @@ Instruction *InstCombiner::visitAnd(BinaryOperator &I) { // ((A | N) - B) & AndRHS -> (A - B) & AndRHS iff N&AndRHS == 0 // ((A ^ N) - B) & AndRHS -> (A - B) & AndRHS iff N&AndRHS == 0 if (Value *V = FoldLogicalPlusAnd(Op0LHS, Op0RHS, AndRHS, true, I)) - return BinaryOperator::createAnd(V, AndRHS); + return BinaryOperator::CreateAnd(V, AndRHS); break; } @@ -3839,14 +3839,14 @@ Instruction *InstCombiner::visitAnd(BinaryOperator &I) { // into : and (cast X to T), trunc_or_bitcast(C1)&C2 // This will fold the two constants together, which may allow // other simplifications. - Instruction *NewCast = CastInst::createTruncOrBitCast( + Instruction *NewCast = CastInst::CreateTruncOrBitCast( CastOp->getOperand(0), I.getType(), CastOp->getName()+".shrunk"); NewCast = InsertNewInstBefore(NewCast, I); // trunc_or_bitcast(C1)&C2 Constant *C3 = ConstantExpr::getTruncOrBitCast(AndCI,I.getType()); C3 = ConstantExpr::getAnd(C3, AndRHS); - return BinaryOperator::createAnd(NewCast, C3); + return BinaryOperator::CreateAnd(NewCast, C3); } else if (CastOp->getOpcode() == Instruction::Or) { // Change: and (cast (or X, C1) to T), C2 // into : trunc(C1)&C2 iff trunc(C1)&C2 == C2 @@ -3875,10 +3875,10 @@ Instruction *InstCombiner::visitAnd(BinaryOperator &I) { // (~A & ~B) == (~(A | B)) - De Morgan's Law if (Op0NotVal && Op1NotVal && isOnlyUse(Op0) && isOnlyUse(Op1)) { - Instruction *Or = BinaryOperator::createOr(Op0NotVal, Op1NotVal, + Instruction *Or = BinaryOperator::CreateOr(Op0NotVal, Op1NotVal, I.getName()+".demorgan"); InsertNewInstBefore(Or, I); - return BinaryOperator::createNot(Or); + return BinaryOperator::CreateNot(Or); } { @@ -3890,7 +3890,7 @@ Instruction *InstCombiner::visitAnd(BinaryOperator &I) { // (A|B) & ~(A&B) -> A^B if (match(Op1, m_Not(m_And(m_Value(C), m_Value(D))))) { if ((A == C && B == D) || (A == D && B == C)) - return BinaryOperator::createXor(A, B); + return BinaryOperator::CreateXor(A, B); } } @@ -3901,7 +3901,7 @@ Instruction *InstCombiner::visitAnd(BinaryOperator &I) { // ~(A&B) & (A|B) -> A^B if (match(Op0, m_Not(m_And(m_Value(C), m_Value(D))))) { if ((A == C && B == D) || (A == D && B == C)) - return BinaryOperator::createXor(A, B); + return BinaryOperator::CreateXor(A, B); } } @@ -3923,9 +3923,9 @@ Instruction *InstCombiner::visitAnd(BinaryOperator &I) { std::swap(A, B); } if (A == Op0) { // A&(A^B) -> A & ~B - Instruction *NotB = BinaryOperator::createNot(B, "tmp"); + Instruction *NotB = BinaryOperator::CreateNot(B, "tmp"); InsertNewInstBefore(NotB, I); - return BinaryOperator::createAnd(A, NotB); + return BinaryOperator::CreateAnd(A, NotB); } } } @@ -4008,7 +4008,7 @@ Instruction *InstCombiner::visitAnd(BinaryOperator &I) { case ICmpInst::ICMP_NE: if (LHSCst == SubOne(RHSCst)){// (X != 13 & X != 14) -> X-13 >u 1 Constant *AddCST = ConstantExpr::getNeg(LHSCst); - Instruction *Add = BinaryOperator::createAdd(LHSVal, AddCST, + Instruction *Add = BinaryOperator::CreateAdd(LHSVal, AddCST, LHSVal->getName()+".off"); InsertNewInstBefore(Add, I); return new ICmpInst(ICmpInst::ICMP_UGT, Add, @@ -4101,11 +4101,11 @@ Instruction *InstCombiner::visitAnd(BinaryOperator &I) { I.getType(), TD) && ValueRequiresCast(Op1C->getOpcode(), Op1C->getOperand(0), I.getType(), TD)) { - Instruction *NewOp = BinaryOperator::createAnd(Op0C->getOperand(0), + Instruction *NewOp = BinaryOperator::CreateAnd(Op0C->getOperand(0), Op1C->getOperand(0), I.getName()); InsertNewInstBefore(NewOp, I); - return CastInst::create(Op0C->getOpcode(), NewOp, I.getType()); + return CastInst::Create(Op0C->getOpcode(), NewOp, I.getType()); } } @@ -4116,10 +4116,10 @@ Instruction *InstCombiner::visitAnd(BinaryOperator &I) { SI0->getOperand(1) == SI1->getOperand(1) && (SI0->hasOneUse() || SI1->hasOneUse())) { Instruction *NewOp = - InsertNewInstBefore(BinaryOperator::createAnd(SI0->getOperand(0), + InsertNewInstBefore(BinaryOperator::CreateAnd(SI0->getOperand(0), SI1->getOperand(0), SI0->getName()), I); - return BinaryOperator::create(SI1->getOpcode(), NewOp, + return BinaryOperator::Create(SI1->getOpcode(), NewOp, SI1->getOperand(1)); } } @@ -4291,19 +4291,19 @@ Instruction *InstCombiner::visitOr(BinaryOperator &I) { ConstantInt *C1 = 0; Value *X = 0; // (X & C1) | C2 --> (X | C2) & (C1|C2) if (match(Op0, m_And(m_Value(X), m_ConstantInt(C1))) && isOnlyUse(Op0)) { - Instruction *Or = BinaryOperator::createOr(X, RHS); + Instruction *Or = BinaryOperator::CreateOr(X, RHS); InsertNewInstBefore(Or, I); Or->takeName(Op0); - return BinaryOperator::createAnd(Or, + return BinaryOperator::CreateAnd(Or, ConstantInt::get(RHS->getValue() | C1->getValue())); } // (X ^ C1) | C2 --> (X | C2) ^ (C1&~C2) if (match(Op0, m_Xor(m_Value(X), m_ConstantInt(C1))) && isOnlyUse(Op0)) { - Instruction *Or = BinaryOperator::createOr(X, RHS); + Instruction *Or = BinaryOperator::CreateOr(X, RHS); InsertNewInstBefore(Or, I); Or->takeName(Op0); - return BinaryOperator::createXor(Or, + return BinaryOperator::CreateXor(Or, ConstantInt::get(C1->getValue() & ~RHS->getValue())); } @@ -4339,19 +4339,19 @@ Instruction *InstCombiner::visitOr(BinaryOperator &I) { // (X^C)|Y -> (X|Y)^C iff Y&C == 0 if (Op0->hasOneUse() && match(Op0, m_Xor(m_Value(A), m_ConstantInt(C1))) && MaskedValueIsZero(Op1, C1->getValue())) { - Instruction *NOr = BinaryOperator::createOr(A, Op1); + Instruction *NOr = BinaryOperator::CreateOr(A, Op1); InsertNewInstBefore(NOr, I); NOr->takeName(Op0); - return BinaryOperator::createXor(NOr, C1); + return BinaryOperator::CreateXor(NOr, C1); } // Y|(X^C) -> (X|Y)^C iff Y&C == 0 if (Op1->hasOneUse() && match(Op1, m_Xor(m_Value(A), m_ConstantInt(C1))) && MaskedValueIsZero(Op0, C1->getValue())) { - Instruction *NOr = BinaryOperator::createOr(A, Op0); + Instruction *NOr = BinaryOperator::CreateOr(A, Op0); InsertNewInstBefore(NOr, I); NOr->takeName(Op0); - return BinaryOperator::createXor(NOr, C1); + return BinaryOperator::CreateXor(NOr, C1); } // (A & C)|(B & D) @@ -4401,8 +4401,8 @@ Instruction *InstCombiner::visitOr(BinaryOperator &I) { if (V1) { Value *Or = - InsertNewInstBefore(BinaryOperator::createOr(V2, V3, "tmp"), I); - return BinaryOperator::createAnd(V1, Or); + InsertNewInstBefore(BinaryOperator::CreateOr(V2, V3, "tmp"), I); + return BinaryOperator::CreateAnd(V1, Or); } } } @@ -4414,10 +4414,10 @@ Instruction *InstCombiner::visitOr(BinaryOperator &I) { SI0->getOperand(1) == SI1->getOperand(1) && (SI0->hasOneUse() || SI1->hasOneUse())) { Instruction *NewOp = - InsertNewInstBefore(BinaryOperator::createOr(SI0->getOperand(0), + InsertNewInstBefore(BinaryOperator::CreateOr(SI0->getOperand(0), SI1->getOperand(0), SI0->getName()), I); - return BinaryOperator::create(SI1->getOpcode(), NewOp, + return BinaryOperator::Create(SI1->getOpcode(), NewOp, SI1->getOperand(1)); } } @@ -4435,9 +4435,9 @@ Instruction *InstCombiner::visitOr(BinaryOperator &I) { // (~A | ~B) == (~(A & B)) - De Morgan's Law if (A && isOnlyUse(Op0) && isOnlyUse(Op1)) { - Value *And = InsertNewInstBefore(BinaryOperator::createAnd(A, B, + Value *And = InsertNewInstBefore(BinaryOperator::CreateAnd(A, B, I.getName()+".demorgan"), I); - return BinaryOperator::createNot(And); + return BinaryOperator::CreateNot(And); } } @@ -4489,7 +4489,7 @@ Instruction *InstCombiner::visitOr(BinaryOperator &I) { case ICmpInst::ICMP_EQ: if (LHSCst == SubOne(RHSCst)) {// (X == 13 | X == 14) -> X-13 <u 2 Constant *AddCST = ConstantExpr::getNeg(LHSCst); - Instruction *Add = BinaryOperator::createAdd(LHSVal, AddCST, + Instruction *Add = BinaryOperator::CreateAdd(LHSVal, AddCST, LHSVal->getName()+".off"); InsertNewInstBefore(Add, I); AddCST = Subtract(AddOne(RHSCst), LHSCst); @@ -4608,11 +4608,11 @@ Instruction *InstCombiner::visitOr(BinaryOperator &I) { I.getType(), TD) && ValueRequiresCast(Op1C->getOpcode(), Op1C->getOperand(0), I.getType(), TD)) { - Instruction *NewOp = BinaryOperator::createOr(Op0C->getOperand(0), + Instruction *NewOp = BinaryOperator::CreateOr(Op0C->getOperand(0), Op1C->getOperand(0), I.getName()); InsertNewInstBefore(NewOp, I); - return CastInst::create(Op0C->getOpcode(), NewOp, I.getType()); + return CastInst::Create(Op0C->getOpcode(), NewOp, I.getType()); } } } @@ -4697,13 +4697,13 @@ Instruction *InstCombiner::visitXor(BinaryOperator &I) { if (dyn_castNotVal(Op0I->getOperand(1))) Op0I->swapOperands(); if (Value *Op0NotVal = dyn_castNotVal(Op0I->getOperand(0))) { Instruction *NotY = - BinaryOperator::createNot(Op0I->getOperand(1), + BinaryOperator::CreateNot(Op0I->getOperand(1), Op0I->getOperand(1)->getName()+".not"); InsertNewInstBefore(NotY, I); if (Op0I->getOpcode() == Instruction::And) - return BinaryOperator::createOr(Op0NotVal, NotY); + return BinaryOperator::CreateOr(Op0NotVal, NotY); else - return BinaryOperator::createAnd(Op0NotVal, NotY); + return BinaryOperator::CreateAnd(Op0NotVal, NotY); } } } @@ -4729,7 +4729,7 @@ Instruction *InstCombiner::visitXor(BinaryOperator &I) { Constant *NegOp0I0C = ConstantExpr::getNeg(Op0I0C); Constant *ConstantRHS = ConstantExpr::getSub(NegOp0I0C, ConstantInt::get(I.getType(), 1)); - return BinaryOperator::createAdd(Op0I->getOperand(1), ConstantRHS); + return BinaryOperator::CreateAdd(Op0I->getOperand(1), ConstantRHS); } if (ConstantInt *Op0CI = dyn_cast<ConstantInt>(Op0I->getOperand(1))) { @@ -4737,14 +4737,14 @@ Instruction *InstCombiner::visitXor(BinaryOperator &I) { // ~(X-c) --> (-c-1)-X if (RHS->isAllOnesValue()) { Constant *NegOp0CI = ConstantExpr::getNeg(Op0CI); - return BinaryOperator::createSub( + return BinaryOperator::CreateSub( ConstantExpr::getSub(NegOp0CI, ConstantInt::get(I.getType(), 1)), Op0I->getOperand(0)); } else if (RHS->getValue().isSignBit()) { // (X + C) ^ signbit -> (X + C + signbit) Constant *C = ConstantInt::get(RHS->getValue() + Op0CI->getValue()); - return BinaryOperator::createAdd(Op0I->getOperand(0), C); + return BinaryOperator::CreateAdd(Op0I->getOperand(0), C); } } else if (Op0I->getOpcode() == Instruction::Or) { @@ -4820,8 +4820,8 @@ Instruction *InstCombiner::visitXor(BinaryOperator &I) { std::swap(A, B); if (B == Op1) { // (A|B)^B == A & ~B Instruction *NotB = - InsertNewInstBefore(BinaryOperator::createNot(Op1, "tmp"), I); - return BinaryOperator::createAnd(A, NotB); + InsertNewInstBefore(BinaryOperator::CreateNot(Op1, "tmp"), I); + return BinaryOperator::CreateAnd(A, NotB); } } else if (match(Op0I, m_Xor(m_Value(A), m_Value(B)))) { if (Op1 == A) // (A^B)^A == B @@ -4834,8 +4834,8 @@ Instruction *InstCombiner::visitXor(BinaryOperator &I) { if (B == Op1 && // (B&A)^A == ~B & A !isa<ConstantInt>(Op1)) { // Canonical form is (B&C)^C Instruction *N = - InsertNewInstBefore(BinaryOperator::createNot(A, "tmp"), I); - return BinaryOperator::createAnd(N, Op1); + InsertNewInstBefore(BinaryOperator::CreateNot(A, "tmp"), I); + return BinaryOperator::CreateAnd(N, Op1); } } } @@ -4846,10 +4846,10 @@ Instruction *InstCombiner::visitXor(BinaryOperator &I) { Op0I->getOperand(1) == Op1I->getOperand(1) && (Op1I->hasOneUse() || Op1I->hasOneUse())) { Instruction *NewOp = - InsertNewInstBefore(BinaryOperator::createXor(Op0I->getOperand(0), + InsertNewInstBefore(BinaryOperator::CreateXor(Op0I->getOperand(0), Op1I->getOperand(0), Op0I->getName()), I); - return BinaryOperator::create(Op1I->getOpcode(), NewOp, + return BinaryOperator::Create(Op1I->getOpcode(), NewOp, Op1I->getOperand(1)); } @@ -4859,13 +4859,13 @@ Instruction *InstCombiner::visitXor(BinaryOperator &I) { if (match(Op0I, m_And(m_Value(A), m_Value(B))) && match(Op1I, m_Or(m_Value(C), m_Value(D)))) { if ((A == C && B == D) || (A == D && B == C)) - return BinaryOperator::createXor(A, B); + return BinaryOperator::CreateXor(A, B); } // (A | B)^(A & B) -> A ^ B if (match(Op0I, m_Or(m_Value(A), m_Value(B))) && match(Op1I, m_And(m_Value(C), m_Value(D)))) { if ((A == C && B == D) || (A == D && B == C)) - return BinaryOperator::createXor(A, B); + return BinaryOperator::CreateXor(A, B); } // (A & B)^(C & D) @@ -4885,8 +4885,8 @@ Instruction *InstCombiner::visitXor(BinaryOperator &I) { if (X) { Instruction *NewOp = - InsertNewInstBefore(BinaryOperator::createXor(Y, Z, Op0->getName()), I); - return BinaryOperator::createAnd(NewOp, X); + InsertNewInstBefore(BinaryOperator::CreateXor(Y, Z, Op0->getName()), I); + return BinaryOperator::CreateAnd(NewOp, X); } } } @@ -4907,11 +4907,11 @@ Instruction *InstCombiner::visitXor(BinaryOperator &I) { I.getType(), TD) && ValueRequiresCast(Op1C->getOpcode(), Op1C->getOperand(0), I.getType(), TD)) { - Instruction *NewOp = BinaryOperator::createXor(Op0C->getOperand(0), + Instruction *NewOp = BinaryOperator::CreateXor(Op0C->getOperand(0), Op1C->getOperand(0), I.getName()); InsertNewInstBefore(NewOp, I); - return CastInst::create(Op0C->getOpcode(), NewOp, I.getType()); + return CastInst::Create(Op0C->getOpcode(), NewOp, I.getType()); } } } @@ -4960,7 +4960,7 @@ static Value *EmitGEPOffset(User *GEP, Instruction &I, InstCombiner &IC) { Result = ConstantInt::get(RC->getValue() + APInt(IntPtrWidth, Size)); else Result = IC.InsertNewInstBefore( - BinaryOperator::createAdd(Result, + BinaryOperator::CreateAdd(Result, ConstantInt::get(IntPtrTy, Size), GEP->getName()+".offs"), I); continue; @@ -4974,7 +4974,7 @@ static Value *EmitGEPOffset(User *GEP, Instruction &I, InstCombiner &IC) { else { // Emit an add instruction. Result = IC.InsertNewInstBefore( - BinaryOperator::createAdd(Result, Scale, + BinaryOperator::CreateAdd(Result, Scale, GEP->getName()+".offs"), I); } continue; @@ -4992,7 +4992,7 @@ static Value *EmitGEPOffset(User *GEP, Instruction &I, InstCombiner &IC) { if (Constant *OpC = dyn_cast<Constant>(Op)) Op = ConstantExpr::getMul(OpC, Scale); else // We'll let instcombine(mul) convert this to a shl if possible. - Op = IC.InsertNewInstBefore(BinaryOperator::createMul(Op, Scale, + Op = IC.InsertNewInstBefore(BinaryOperator::CreateMul(Op, Scale, GEP->getName()+".idx"), I); } @@ -5001,7 +5001,7 @@ static Value *EmitGEPOffset(User *GEP, Instruction &I, InstCombiner &IC) { Result = ConstantExpr::getAdd(cast<Constant>(Op), cast<Constant>(Result)); else - Result = IC.InsertNewInstBefore(BinaryOperator::createAdd(Op, Result, + Result = IC.InsertNewInstBefore(BinaryOperator::CreateAdd(Op, Result, GEP->getName()+".offs"), I); } return Result; @@ -5106,11 +5106,11 @@ static Value *EvaluateGEPOffsetExpression(User *GEP, Instruction &I, // Okay, we can do this evaluation. Start by converting the index to intptr. const Type *IntPtrTy = TD.getIntPtrType(); if (VariableIdx->getType() != IntPtrTy) - VariableIdx = CastInst::createIntegerCast(VariableIdx, IntPtrTy, + VariableIdx = CastInst::CreateIntegerCast(VariableIdx, IntPtrTy, true /*SExt*/, VariableIdx->getNameStart(), &I); Constant *OffsetVal = ConstantInt::get(IntPtrTy, NewOffs); - return BinaryOperator::createAdd(VariableIdx, OffsetVal, "offset", &I); + return BinaryOperator::CreateAdd(VariableIdx, OffsetVal, "offset", &I); } @@ -5340,12 +5340,12 @@ Instruction *InstCombiner::visitICmpInst(ICmpInst &I) { switch (I.getPredicate()) { default: assert(0 && "Invalid icmp instruction!"); case ICmpInst::ICMP_EQ: { // icmp eq bool %A, %B -> ~(A^B) - Instruction *Xor = BinaryOperator::createXor(Op0, Op1, I.getName()+"tmp"); + Instruction *Xor = BinaryOperator::CreateXor(Op0, Op1, I.getName()+"tmp"); InsertNewInstBefore(Xor, I); - return BinaryOperator::createNot(Xor); + return BinaryOperator::CreateNot(Xor); } case ICmpInst::ICMP_NE: // icmp eq bool %A, %B -> A^B - return BinaryOperator::createXor(Op0, Op1); + return BinaryOperator::CreateXor(Op0, Op1); case ICmpInst::ICMP_UGT: case ICmpInst::ICMP_SGT: @@ -5353,9 +5353,9 @@ Instruction *InstCombiner::visitICmpInst(ICmpInst &I) { // FALL THROUGH case ICmpInst::ICMP_ULT: case ICmpInst::ICMP_SLT: { // icmp lt bool A, B -> ~X & Y - Instruction *Not = BinaryOperator::createNot(Op0, I.getName()+"tmp"); + Instruction *Not = BinaryOperator::CreateNot(Op0, I.getName()+"tmp"); InsertNewInstBefore(Not, I); - return BinaryOperator::createAnd(Not, Op1); + return BinaryOperator::CreateAnd(Not, Op1); } case ICmpInst::ICMP_UGE: case ICmpInst::ICMP_SGE: @@ -5363,9 +5363,9 @@ Instruction *InstCombiner::visitICmpInst(ICmpInst &I) { // FALL THROUGH case ICmpInst::ICMP_ULE: case ICmpInst::ICMP_SLE: { // icmp le bool %A, %B -> ~A | B - Instruction *Not = BinaryOperator::createNot(Op0, I.getName()+"tmp"); + Instruction *Not = BinaryOperator::CreateNot(Op0, I.getName()+"tmp"); InsertNewInstBefore(Not, I); - return BinaryOperator::createOr(Not, Op1); + return BinaryOperator::CreateOr(Not, Op1); } } } @@ -5697,7 +5697,7 @@ Instruction *InstCombiner::visitICmpInst(ICmpInst &I) { if (ConstantInt *C2 = dyn_cast<ConstantInt>(D)) if (Op1->hasOneUse()) { Constant *NC = ConstantInt::get(C1->getValue() ^ C2->getValue()); - Instruction *Xor = BinaryOperator::createXor(C, NC, "tmp"); + Instruction *Xor = BinaryOperator::CreateXor(C, NC, "tmp"); return new ICmpInst(I.getPredicate(), A, InsertNewInstBefore(Xor, I)); } @@ -5745,8 +5745,8 @@ Instruction *InstCombiner::visitICmpInst(ICmpInst &I) { } if (X) { // Build (X^Y) & Z - Op1 = InsertNewInstBefore(BinaryOperator::createXor(X, Y, "tmp"), I); - Op1 = InsertNewInstBefore(BinaryOperator::createAnd(Op1, Z, "tmp"), I); + Op1 = InsertNewInstBefore(BinaryOperator::CreateXor(X, Y, "tmp"), I); + Op1 = InsertNewInstBefore(BinaryOperator::CreateAnd(Op1, Z, "tmp"), I); I.setOperand(0, Op1); I.setOperand(1, Constant::getNullValue(Op1->getType())); return &I; @@ -5960,7 +5960,7 @@ Instruction *InstCombiner::visitICmpInstWithInstAndIntCst(ICmpInst &ICI, APInt NewCI = RHSV; NewCI.zext(BitWidth); Instruction *NewAnd = - BinaryOperator::createAnd(Cast->getOperand(0), + BinaryOperator::CreateAnd(Cast->getOperand(0), ConstantInt::get(NewCST),LHSI->getName()); InsertNewInstBefore(NewAnd, ICI); return new ICmpInst(ICI.getPredicate(), NewAnd, @@ -6040,18 +6040,18 @@ Instruction *InstCombiner::visitICmpInstWithInstAndIntCst(ICmpInst &ICI, // Compute C << Y. Value *NS; if (Shift->getOpcode() == Instruction::LShr) { - NS = BinaryOperator::createShl(AndCST, + NS = BinaryOperator::CreateShl(AndCST, Shift->getOperand(1), "tmp"); } else { // Insert a logical shift. - NS = BinaryOperator::createLShr(AndCST, + NS = BinaryOperator::CreateLShr(AndCST, Shift->getOperand(1), "tmp"); } InsertNewInstBefore(cast<Instruction>(NS), ICI); // Compute X & (C << Y). Instruction *NewAnd = - BinaryOperator::createAnd(Shift->getOperand(0), NS, LHSI->getName()); + BinaryOperator::CreateAnd(Shift->getOperand(0), NS, LHSI->getName()); InsertNewInstBefore(NewAnd, ICI); ICI.setOperand(0, NewAnd); @@ -6090,7 +6090,7 @@ Instruction *InstCombiner::visitICmpInstWithInstAndIntCst(ICmpInst &ICI, ConstantInt::get(APInt::getLowBitsSet(TypeBits, TypeBits-ShAmtVal)); Instruction *AndI = - BinaryOperator::createAnd(LHSI->getOperand(0), + BinaryOperator::CreateAnd(LHSI->getOperand(0), Mask, LHSI->getName()+".mask"); Value *And = InsertNewInstBefore(AndI, ICI); return new ICmpInst(ICI.getPredicate(), And, @@ -6106,7 +6106,7 @@ Instruction *InstCombiner::visitICmpInstWithInstAndIntCst(ICmpInst &ICI, Constant *Mask = ConstantInt::get(APInt(TypeBits, 1) << (TypeBits-ShAmt->getZExtValue()-1)); Instruction *AndI = - BinaryOperator::createAnd(LHSI->getOperand(0), + BinaryOperator::CreateAnd(LHSI->getOperand(0), Mask, LHSI->getName()+".mask"); Value *And = InsertNewInstBefore(AndI, ICI); @@ -6161,7 +6161,7 @@ Instruction *InstCombiner::visitICmpInstWithInstAndIntCst(ICmpInst &ICI, Constant *Mask = ConstantInt::get(Val); Instruction *AndI = - BinaryOperator::createAnd(LHSI->getOperand(0), + BinaryOperator::CreateAnd(LHSI->getOperand(0), Mask, LHSI->getName()+".mask"); Value *And = InsertNewInstBefore(AndI, ICI); return new ICmpInst(ICI.getPredicate(), And, @@ -6230,7 +6230,7 @@ Instruction *InstCombiner::visitICmpInstWithInstAndIntCst(ICmpInst &ICI, const APInt &V = cast<ConstantInt>(BO->getOperand(1))->getValue(); if (V.sgt(APInt(V.getBitWidth(), 1)) && V.isPowerOf2()) { Instruction *NewRem = - BinaryOperator::createURem(BO->getOperand(0), BO->getOperand(1), + BinaryOperator::CreateURem(BO->getOperand(0), BO->getOperand(1), BO->getName()); InsertNewInstBefore(NewRem, ICI); return new ICmpInst(ICI.getPredicate(), NewRem, @@ -6254,7 +6254,7 @@ Instruction *InstCombiner::visitICmpInstWithInstAndIntCst(ICmpInst &ICI, else if (Value *NegVal = dyn_castNegVal(BOp0)) return new ICmpInst(ICI.getPredicate(), NegVal, BOp1); else if (BO->hasOneUse()) { - Instruction *Neg = BinaryOperator::createNeg(BOp1); + Instruction *Neg = BinaryOperator::CreateNeg(BOp1); InsertNewInstBefore(Neg, ICI); Neg->takeName(BO); return new ICmpInst(ICI.getPredicate(), BOp0, Neg); @@ -6491,7 +6491,7 @@ Instruction *InstCombiner::visitICmpInstWithCastAndCast(ICmpInst &ICI) { if (Constant *CI = dyn_cast<Constant>(Result)) return ReplaceInstUsesWith(ICI, ConstantExpr::getNot(CI)); else - return BinaryOperator::createNot(Result); + return BinaryOperator::CreateNot(Result); } } @@ -6517,7 +6517,7 @@ Instruction *InstCombiner::visitAShr(BinaryOperator &I) { // See if we can turn a signed shr into an unsigned shr. if (MaskedValueIsZero(Op0, APInt::getSignBit(I.getType()->getPrimitiveSizeInBits()))) - return BinaryOperator::createLShr(Op0, I.getOperand(1)); + return BinaryOperator::CreateLShr(Op0, I.getOperand(1)); return 0; } @@ -6585,7 +6585,7 @@ Instruction *InstCombiner::FoldShiftByConstant(Value *Op0, ConstantInt *Op1, if (BinaryOperator *BO = dyn_cast<BinaryOperator>(Op0)) if (BO->getOpcode() == Instruction::Mul && isLeftShift) if (Constant *BOOp = dyn_cast<Constant>(BO->getOperand(1))) - return BinaryOperator::createMul(BO->getOperand(0), + return BinaryOperator::CreateMul(BO->getOperand(0), ConstantExpr::getShl(BOOp, Op1)); // Try to fold constant and into select arguments. @@ -6608,7 +6608,7 @@ Instruction *InstCombiner::FoldShiftByConstant(Value *Op0, ConstantInt *Op1, isa<ConstantInt>(TrOp->getOperand(1))) { // Okay, we'll do this xform. Make the shift of shift. Constant *ShAmt = ConstantExpr::getZExt(Op1, TrOp->getType()); - Instruction *NSh = BinaryOperator::create(I.getOpcode(), TrOp, ShAmt, + Instruction *NSh = BinaryOperator::Create(I.getOpcode(), TrOp, ShAmt, I.getName()); InsertNewInstBefore(NSh, I); // (shift2 (shift1 & 0x00FF), c2) @@ -6631,7 +6631,7 @@ Instruction *InstCombiner::FoldShiftByConstant(Value *Op0, ConstantInt *Op1, MaskV = MaskV.lshr(Op1->getZExtValue()); } - Instruction *And = BinaryOperator::createAnd(NSh, ConstantInt::get(MaskV), + Instruction *And = BinaryOperator::CreateAnd(NSh, ConstantInt::get(MaskV), TI->getName()); InsertNewInstBefore(And, I); // shift1 & 0x00FF @@ -6656,16 +6656,16 @@ Instruction *InstCombiner::FoldShiftByConstant(Value *Op0, ConstantInt *Op1, if (isLeftShift && Op0BO->getOperand(1)->hasOneUse() && match(Op0BO->getOperand(1), m_Shr(m_Value(V1), m_ConstantInt(CC))) && CC == Op1) { - Instruction *YS = BinaryOperator::createShl( + Instruction *YS = BinaryOperator::CreateShl( Op0BO->getOperand(0), Op1, Op0BO->getName()); InsertNewInstBefore(YS, I); // (Y << C) Instruction *X = - BinaryOperator::create(Op0BO->getOpcode(), YS, V1, + BinaryOperator::Create(Op0BO->getOpcode(), YS, V1, Op0BO->getOperand(1)->getName()); InsertNewInstBefore(X, I); // (X + (Y << C)) uint32_t Op1Val = Op1->getLimitedValue(TypeBits); - return BinaryOperator::createAnd(X, ConstantInt::get( + return BinaryOperator::CreateAnd(X, ConstantInt::get( APInt::getHighBitsSet(TypeBits, TypeBits-Op1Val))); } @@ -6676,16 +6676,16 @@ Instruction *InstCombiner::FoldShiftByConstant(Value *Op0, ConstantInt *Op1, m_And(m_Shr(m_Value(V1), m_Value(V2)),m_ConstantInt(CC))) && cast<BinaryOperator>(Op0BOOp1)->getOperand(0)->hasOneUse() && V2 == Op1) { - Instruction *YS = BinaryOperator::createShl( + Instruction *YS = BinaryOperator::CreateShl( Op0BO->getOperand(0), Op1, Op0BO->getName()); InsertNewInstBefore(YS, I); // (Y << C) Instruction *XM = - BinaryOperator::createAnd(V1, ConstantExpr::getShl(CC, Op1), + BinaryOperator::CreateAnd(V1, ConstantExpr::getShl(CC, Op1), V1->getName()+".mask"); InsertNewInstBefore(XM, I); // X & (CC << C) - return BinaryOperator::create(Op0BO->getOpcode(), YS, XM); + return BinaryOperator::Create(Op0BO->getOpcode(), YS, XM); } } @@ -6695,16 +6695,16 @@ Instruction *InstCombiner::FoldShiftByConstant(Value *Op0, ConstantInt *Op1, if (isLeftShift && Op0BO->getOperand(0)->hasOneUse() && match(Op0BO->getOperand(0), m_Shr(m_Value(V1), m_ConstantInt(CC))) && CC == Op1) { - Instruction *YS = BinaryOperator::createShl( + Instruction *YS = BinaryOperator::CreateShl( Op0BO->getOperand(1), Op1, Op0BO->getName()); InsertNewInstBefore(YS, I); // (Y << C) Instruction *X = - BinaryOperator::create(Op0BO->getOpcode(), V1, YS, + BinaryOperator::Create(Op0BO->getOpcode(), V1, YS, Op0BO->getOperand(0)->getName()); InsertNewInstBefore(X, I); // (X + (Y << C)) uint32_t Op1Val = Op1->getLimitedValue(TypeBits); - return BinaryOperator::createAnd(X, ConstantInt::get( + return BinaryOperator::CreateAnd(X, ConstantInt::get( APInt::getHighBitsSet(TypeBits, TypeBits-Op1Val))); } @@ -6715,16 +6715,16 @@ Instruction *InstCombiner::FoldShiftByConstant(Value *Op0, ConstantInt *Op1, m_ConstantInt(CC))) && V2 == Op1 && cast<BinaryOperator>(Op0BO->getOperand(0)) ->getOperand(0)->hasOneUse()) { - Instruction *YS = BinaryOperator::createShl( + Instruction *YS = BinaryOperator::CreateShl( Op0BO->getOperand(1), Op1, Op0BO->getName()); InsertNewInstBefore(YS, I); // (Y << C) Instruction *XM = - BinaryOperator::createAnd(V1, ConstantExpr::getShl(CC, Op1), + BinaryOperator::CreateAnd(V1, ConstantExpr::getShl(CC, Op1), V1->getName()+".mask"); InsertNewInstBefore(XM, I); // X & (CC << C) - return BinaryOperator::create(Op0BO->getOpcode(), XM, YS); + return BinaryOperator::Create(Op0BO->getOpcode(), XM, YS); } break; @@ -6765,11 +6765,11 @@ Instruction *InstCombiner::FoldShiftByConstant(Value *Op0, ConstantInt *Op1, Constant *NewRHS = ConstantExpr::get(I.getOpcode(), Op0C, Op1); Instruction *NewShift = - BinaryOperator::create(I.getOpcode(), Op0BO->getOperand(0), Op1); + BinaryOperator::Create(I.getOpcode(), Op0BO->getOperand(0), Op1); InsertNewInstBefore(NewShift, I); NewShift->takeName(Op0BO); - return BinaryOperator::create(Op0BO->getOpcode(), NewShift, + return BinaryOperator::Create(Op0BO->getOpcode(), NewShift, NewRHS); } } @@ -6797,21 +6797,21 @@ Instruction *InstCombiner::FoldShiftByConstant(Value *Op0, ConstantInt *Op1, // Check for (X << c1) << c2 and (X >> c1) >> c2 if (I.getOpcode() == ShiftOp->getOpcode()) { - return BinaryOperator::create(I.getOpcode(), X, + return BinaryOperator::Create(I.getOpcode(), X, ConstantInt::get(Ty, AmtSum)); } else if (ShiftOp->getOpcode() == Instruction::LShr && I.getOpcode() == Instruction::AShr) { // ((X >>u C1) >>s C2) -> (X >>u (C1+C2)) since C1 != 0. - return BinaryOperator::createLShr(X, ConstantInt::get(Ty, AmtSum)); + return BinaryOperator::CreateLShr(X, ConstantInt::get(Ty, AmtSum)); } else if (ShiftOp->getOpcode() == Instruction::AShr && I.getOpcode() == Instruction::LShr) { // ((X >>s C1) >>u C2) -> ((X >>s (C1+C2)) & mask) since C1 != 0. Instruction *Shift = - BinaryOperator::createAShr(X, ConstantInt::get(Ty, AmtSum)); + BinaryOperator::CreateAShr(X, ConstantInt::get(Ty, AmtSum)); InsertNewInstBefore(Shift, I); APInt Mask(APInt::getLowBitsSet(TypeBits, TypeBits - ShiftAmt2)); - return BinaryOperator::createAnd(Shift, ConstantInt::get(Mask)); + return BinaryOperator::CreateAnd(Shift, ConstantInt::get(Mask)); } // Okay, if we get here, one shift must be left, and the other shift must be @@ -6820,12 +6820,12 @@ Instruction *InstCombiner::FoldShiftByConstant(Value *Op0, ConstantInt *Op1, // If we have ((X >>? C) << C), turn this into X & (-1 << C). if (I.getOpcode() == Instruction::Shl) { APInt Mask(APInt::getHighBitsSet(TypeBits, TypeBits - ShiftAmt1)); - return BinaryOperator::createAnd(X, ConstantInt::get(Mask)); + return BinaryOperator::CreateAnd(X, ConstantInt::get(Mask)); } // If we have ((X << C) >>u C), turn this into X & (-1 >>u C). if (I.getOpcode() == Instruction::LShr) { APInt Mask(APInt::getLowBitsSet(TypeBits, TypeBits - ShiftAmt1)); - return BinaryOperator::createAnd(X, ConstantInt::get(Mask)); + return BinaryOperator::CreateAnd(X, ConstantInt::get(Mask)); } // We can simplify ((X << C) >>s C) into a trunc + sext. // NOTE: we could do this for any C, but that would make 'unusual' integer @@ -6857,22 +6857,22 @@ Instruction *InstCombiner::FoldShiftByConstant(Value *Op0, ConstantInt *Op1, assert(ShiftOp->getOpcode() == Instruction::LShr || ShiftOp->getOpcode() == Instruction::AShr); Instruction *Shift = - BinaryOperator::createShl(X, ConstantInt::get(Ty, ShiftDiff)); + BinaryOperator::CreateShl(X, ConstantInt::get(Ty, ShiftDiff)); InsertNewInstBefore(Shift, I); APInt Mask(APInt::getHighBitsSet(TypeBits, TypeBits - ShiftAmt2)); - return BinaryOperator::createAnd(Shift, ConstantInt::get(Mask)); + return BinaryOperator::CreateAnd(Shift, ConstantInt::get(Mask)); } // (X << C1) >>u C2 --> X >>u (C2-C1) & (-1 >> C2) if (I.getOpcode() == Instruction::LShr) { assert(ShiftOp->getOpcode() == Instruction::Shl); Instruction *Shift = - BinaryOperator::createLShr(X, ConstantInt::get(Ty, ShiftDiff)); + BinaryOperator::CreateLShr(X, ConstantInt::get(Ty, ShiftDiff)); InsertNewInstBefore(Shift, I); APInt Mask(APInt::getLowBitsSet(TypeBits, TypeBits - ShiftAmt2)); - return BinaryOperator::createAnd(Shift, ConstantInt::get(Mask)); + return BinaryOperator::CreateAnd(Shift, ConstantInt::get(Mask)); } // We can't handle (X << C1) >>s C2, it shifts arbitrary bits in. @@ -6885,23 +6885,23 @@ Instruction *InstCombiner::FoldShiftByConstant(Value *Op0, ConstantInt *Op1, assert(ShiftOp->getOpcode() == Instruction::LShr || ShiftOp->getOpcode() == Instruction::AShr); Instruction *Shift = - BinaryOperator::create(ShiftOp->getOpcode(), X, + BinaryOperator::Create(ShiftOp->getOpcode(), X, ConstantInt::get(Ty, ShiftDiff)); InsertNewInstBefore(Shift, I); APInt Mask(APInt::getHighBitsSet(TypeBits, TypeBits - ShiftAmt2)); - return BinaryOperator::createAnd(Shift, ConstantInt::get(Mask)); + return BinaryOperator::CreateAnd(Shift, ConstantInt::get(Mask)); } // (X << C1) >>u C2 --> X << (C1-C2) & (-1 >> C2) if (I.getOpcode() == Instruction::LShr) { assert(ShiftOp->getOpcode() == Instruction::Shl); Instruction *Shift = - BinaryOperator::createShl(X, ConstantInt::get(Ty, ShiftDiff)); + BinaryOperator::CreateShl(X, ConstantInt::get(Ty, ShiftDiff)); InsertNewInstBefore(Shift, I); APInt Mask(APInt::getLowBitsSet(TypeBits, TypeBits - ShiftAmt2)); - return BinaryOperator::createAnd(Shift, ConstantInt::get(Mask)); + return BinaryOperator::CreateAnd(Shift, ConstantInt::get(Mask)); } // We can't handle (X << C1) >>a C2, it shifts arbitrary bits in. @@ -7016,14 +7016,14 @@ Instruction *InstCombiner::PromoteCastOfAllocation(BitCastInst &CI, Amt = Multiply(cast<ConstantInt>(NumElements), cast<ConstantInt>(Amt)); // otherwise multiply the amount and the number of elements else if (Scale != 1) { - Instruction *Tmp = BinaryOperator::createMul(Amt, NumElements, "tmp"); + Instruction *Tmp = BinaryOperator::CreateMul(Amt, NumElements, "tmp"); Amt = InsertNewInstBefore(Tmp, AI); } } if (int Offset = (AllocElTySize*ArrayOffset)/CastElTySize) { Value *Off = ConstantInt::get(Type::Int32Ty, Offset, true); - Instruction *Tmp = BinaryOperator::createAdd(Amt, Off, "tmp"); + Instruction *Tmp = BinaryOperator::CreateAdd(Amt, Off, "tmp"); Amt = InsertNewInstBefore(Tmp, AI); } @@ -7175,7 +7175,7 @@ Value *InstCombiner::EvaluateInDifferentType(Value *V, const Type *Ty, case Instruction::Shl: { Value *LHS = EvaluateInDifferentType(I->getOperand(0), Ty, isSigned); Value *RHS = EvaluateInDifferentType(I->getOperand(1), Ty, isSigned); - Res = BinaryOperator::create((Instruction::BinaryOps)I->getOpcode(), + Res = BinaryOperator::Create((Instruction::BinaryOps)I->getOpcode(), LHS, RHS, I->getName()); break; } @@ -7189,7 +7189,7 @@ Value *InstCombiner::EvaluateInDifferentType(Value *V, const Type *Ty, return I->getOperand(0); // Otherwise, must be the same type of case, so just reinsert a new one. - Res = CastInst::create(cast<CastInst>(I)->getOpcode(), I->getOperand(0), + Res = CastInst::Create(cast<CastInst>(I)->getOpcode(), I->getOperand(0), Ty, I->getName()); break; default: @@ -7212,7 +7212,7 @@ Instruction *InstCombiner::commonCastTransforms(CastInst &CI) { isEliminableCastPair(CSrc, CI.getOpcode(), CI.getType(), TD)) { // The first cast (CSrc) is eliminable so we need to fix up or replace // the second cast (CI). CSrc will then have a good chance of being dead. - return CastInst::create(opc, CSrc->getOperand(0), CI.getType()); + return CastInst::Create(opc, CSrc->getOperand(0), CI.getType()); } } @@ -7407,11 +7407,11 @@ Instruction *InstCombiner::commonIntCastTransforms(CastInst &CI) { assert(SrcBitSize < DestBitSize && "Not a zext?"); Constant *C = ConstantInt::get(APInt::getLowBitsSet(DestBitSize, SrcBitSize)); - return BinaryOperator::createAnd(Res, C); + return BinaryOperator::CreateAnd(Res, C); } case Instruction::SExt: // We need to emit a cast to truncate, then a cast to sext. - return CastInst::create(Instruction::SExt, + return CastInst::Create(Instruction::SExt, InsertCastBefore(Instruction::Trunc, Res, Src->getType(), CI), DestTy); } @@ -7438,7 +7438,7 @@ Instruction *InstCombiner::commonIntCastTransforms(CastInst &CI) { Instruction::CastOps opcode = CI.getOpcode(); Value *Op0c = InsertOperandCastBefore(opcode, Op0, DestTy, SrcI); Value *Op1c = InsertOperandCastBefore(opcode, Op1, DestTy, SrcI); - return BinaryOperator::create( + return BinaryOperator::Create( cast<BinaryOperator>(SrcI)->getOpcode(), Op0c, Op1c); } } @@ -7449,7 +7449,7 @@ Instruction *InstCombiner::commonIntCastTransforms(CastInst &CI) { Op1 == ConstantInt::getTrue() && (!Op0->hasOneUse() || !isa<CmpInst>(Op0))) { Value *New = InsertOperandCastBefore(Instruction::ZExt, Op0, DestTy, &CI); - return BinaryOperator::createXor(New, ConstantInt::get(CI.getType(), 1)); + return BinaryOperator::CreateXor(New, ConstantInt::get(CI.getType(), 1)); } break; case Instruction::SDiv: @@ -7467,7 +7467,7 @@ Instruction *InstCombiner::commonIntCastTransforms(CastInst &CI) { Op0, DestTy, SrcI); Value *Op1c = InsertOperandCastBefore(Instruction::BitCast, Op1, DestTy, SrcI); - return BinaryOperator::create( + return BinaryOperator::Create( cast<BinaryOperator>(SrcI)->getOpcode(), Op0c, Op1c); } } @@ -7485,7 +7485,7 @@ Instruction *InstCombiner::commonIntCastTransforms(CastInst &CI) { Instruction::BitCast : Instruction::Trunc); Value *Op0c = InsertOperandCastBefore(opcode, Op0, DestTy, SrcI); Value *Op1c = InsertOperandCastBefore(opcode, Op1, DestTy, SrcI); - return BinaryOperator::createShl(Op0c, Op1c); + return BinaryOperator::CreateShl(Op0c, Op1c); } break; case Instruction::AShr: @@ -7497,7 +7497,7 @@ Instruction *InstCombiner::commonIntCastTransforms(CastInst &CI) { uint32_t ShiftAmt = cast<ConstantInt>(Op1)->getLimitedValue(SrcBitSize); if (SrcBitSize > ShiftAmt && SrcBitSize-ShiftAmt >= DestBitSize) { // Insert the new logical shift right. - return BinaryOperator::createLShr(Op0, Op1); + return BinaryOperator::CreateLShr(Op0, Op1); } } break; @@ -7535,7 +7535,7 @@ Instruction *InstCombiner::visitTrunc(TruncInst &CI) { Value *V1 = InsertCastBefore(Instruction::Trunc, SrcIOp0, Ty, CI); Value *V2 = InsertCastBefore(Instruction::Trunc, SrcI->getOperand(1), Ty, CI); - return BinaryOperator::createLShr(V1, V2); + return BinaryOperator::CreateLShr(V1, V2); } } else { // This is a variable shr. @@ -7546,9 +7546,9 @@ Instruction *InstCombiner::visitTrunc(TruncInst &CI) { Value *One = ConstantInt::get(SrcI->getType(), 1); Value *V = InsertNewInstBefore( - BinaryOperator::createShl(One, SrcI->getOperand(1), + BinaryOperator::CreateShl(One, SrcI->getOperand(1), "tmp"), CI); - V = InsertNewInstBefore(BinaryOperator::createAnd(V, + V = InsertNewInstBefore(BinaryOperator::CreateAnd(V, SrcI->getOperand(0), "tmp"), CI); Value *Zero = Constant::getNullValue(V->getType()); @@ -7581,16 +7581,16 @@ Instruction *InstCombiner::transformZExtICmp(ICmpInst *ICI, Instruction &CI, Value *In = ICI->getOperand(0); Value *Sh = ConstantInt::get(In->getType(), In->getType()->getPrimitiveSizeInBits()-1); - In = InsertNewInstBefore(BinaryOperator::createLShr(In, Sh, + In = InsertNewInstBefore(BinaryOperator::CreateLShr(In, Sh, In->getName()+".lobit"), CI); if (In->getType() != CI.getType()) - In = CastInst::createIntegerCast(In, CI.getType(), + In = CastInst::CreateIntegerCast(In, CI.getType(), false/*ZExt*/, "tmp", &CI); if (ICI->getPredicate() == ICmpInst::ICMP_SGT) { Constant *One = ConstantInt::get(In->getType(), 1); - In = InsertNewInstBefore(BinaryOperator::createXor(In, One, + In = InsertNewInstBefore(BinaryOperator::CreateXor(In, One, In->getName()+".not"), CI); } @@ -7635,21 +7635,21 @@ Instruction *InstCombiner::transformZExtICmp(ICmpInst *ICI, Instruction &CI, if (ShiftAmt) { // Perform a logical shr by shiftamt. // Insert the shift to put the result in the low bit. - In = InsertNewInstBefore(BinaryOperator::createLShr(In, + In = InsertNewInstBefore(BinaryOperator::CreateLShr(In, ConstantInt::get(In->getType(), ShiftAmt), In->getName()+".lobit"), CI); } if ((Op1CV != 0) == isNE) { // Toggle the low bit. Constant *One = ConstantInt::get(In->getType(), 1); - In = BinaryOperator::createXor(In, One, "tmp"); + In = BinaryOperator::CreateXor(In, One, "tmp"); InsertNewInstBefore(cast<Instruction>(In), CI); } if (CI.getType() == In->getType()) return ReplaceInstUsesWith(CI, In); else - return CastInst::createIntegerCast(In, CI.getType(), false/*ZExt*/); + return CastInst::CreateIntegerCast(In, CI.getType(), false/*ZExt*/); } } } @@ -7681,12 +7681,12 @@ Instruction *InstCombiner::visitZExt(ZExtInst &CI) { APInt AndValue(APInt::getLowBitsSet(SrcSize, MidSize)); Constant *AndConst = ConstantInt::get(AndValue); Instruction *And = - BinaryOperator::createAnd(CSrc->getOperand(0), AndConst); + BinaryOperator::CreateAnd(CSrc->getOperand(0), AndConst); // Unfortunately, if the type changed, we need to cast it back. if (And->getType() != CI.getType()) { And->setName(CSrc->getName()+".mask"); InsertNewInstBefore(And, CI); - And = CastInst::createIntegerCast(And, CI.getType(), false/*ZExt*/); + And = CastInst::CreateIntegerCast(And, CI.getType(), false/*ZExt*/); } return And; } @@ -7707,7 +7707,7 @@ Instruction *InstCombiner::visitZExt(ZExtInst &CI) { transformZExtICmp(RHS, CI, false))) { Value *LCast = InsertCastBefore(Instruction::ZExt, LHS, CI.getType(), CI); Value *RCast = InsertCastBefore(Instruction::ZExt, RHS, CI.getType(), CI); - return BinaryOperator::create(Instruction::Or, LCast, RCast); + return BinaryOperator::Create(Instruction::Or, LCast, RCast); } } @@ -7736,15 +7736,15 @@ Instruction *InstCombiner::visitSExt(SExtInst &CI) { Value *In = ICI->getOperand(0); Value *Sh = ConstantInt::get(In->getType(), In->getType()->getPrimitiveSizeInBits()-1); - In = InsertNewInstBefore(BinaryOperator::createAShr(In, Sh, + In = InsertNewInstBefore(BinaryOperator::CreateAShr(In, Sh, In->getName()+".lobit"), CI); if (In->getType() != CI.getType()) - In = CastInst::createIntegerCast(In, CI.getType(), + In = CastInst::CreateIntegerCast(In, CI.getType(), true/*SExt*/, "tmp", &CI); if (ICI->getPredicate() == ICmpInst::ICMP_SGT) - In = InsertNewInstBefore(BinaryOperator::createNot(In, + In = InsertNewInstBefore(BinaryOperator::CreateNot(In, In->getName()+".not"), CI); return ReplaceInstUsesWith(CI, In); @@ -7821,7 +7821,7 @@ Instruction *InstCombiner::visitFPTrunc(FPTruncInst &CI) { CI.getType(), CI); RHSTrunc = InsertCastBefore(Instruction::FPExt, RHSTrunc, CI.getType(), CI); - return BinaryOperator::create(OpI->getOpcode(), LHSTrunc, RHSTrunc); + return BinaryOperator::Create(OpI->getOpcode(), LHSTrunc, RHSTrunc); } } break; @@ -8064,7 +8064,7 @@ Instruction *InstCombiner::FoldSelectOpOp(SelectInst &SI, Instruction *TI, SelectInst *NewSI = SelectInst::Create(SI.getCondition(), TI->getOperand(0), FI->getOperand(0), SI.getName()+".v"); InsertNewInstBefore(NewSI, SI); - return CastInst::create(Instruction::CastOps(TI->getOpcode()), NewSI, + return CastInst::Create(Instruction::CastOps(TI->getOpcode()), NewSI, TI->getType()); } @@ -8108,9 +8108,9 @@ Instruction *InstCombiner::FoldSelectOpOp(SelectInst &SI, Instruction *TI, if (BinaryOperator *BO = dyn_cast<BinaryOperator>(TI)) { if (MatchIsOpZero) - return BinaryOperator::create(BO->getOpcode(), MatchOp, NewSI); + return BinaryOperator::Create(BO->getOpcode(), MatchOp, NewSI); else - return BinaryOperator::create(BO->getOpcode(), NewSI, MatchOp); + return BinaryOperator::Create(BO->getOpcode(), NewSI, MatchOp); } assert(0 && "Shouldn't get here"); return 0; @@ -8145,33 +8145,33 @@ Instruction *InstCombiner::visitSelectInst(SelectInst &SI) { if (ConstantInt *C = dyn_cast<ConstantInt>(TrueVal)) { if (C->getZExtValue()) { // Change: A = select B, true, C --> A = or B, C - return BinaryOperator::createOr(CondVal, FalseVal); + return BinaryOperator::CreateOr(CondVal, FalseVal); } else { // Change: A = select B, false, C --> A = and !B, C Value *NotCond = - InsertNewInstBefore(BinaryOperator::createNot(CondVal, + InsertNewInstBefore(BinaryOperator::CreateNot(CondVal, "not."+CondVal->getName()), SI); - return BinaryOperator::createAnd(NotCond, FalseVal); + return BinaryOperator::CreateAnd(NotCond, FalseVal); } } else if (ConstantInt *C = dyn_cast<ConstantInt>(FalseVal)) { if (C->getZExtValue() == false) { // Change: A = select B, C, false --> A = and B, C - return BinaryOperator::createAnd(CondVal, TrueVal); + return BinaryOperator::CreateAnd(CondVal, TrueVal); } else { // Change: A = select B, C, true --> A = or !B, C Value *NotCond = - InsertNewInstBefore(BinaryOperator::createNot(CondVal, + InsertNewInstBefore(BinaryOperator::CreateNot(CondVal, "not."+CondVal->getName()), SI); - return BinaryOperator::createOr(NotCond, TrueVal); + return BinaryOperator::CreateOr(NotCond, TrueVal); } } // select a, b, a -> a&b // select a, a, b -> a|b if (CondVal == TrueVal) - return BinaryOperator::createOr(CondVal, FalseVal); + return BinaryOperator::CreateOr(CondVal, FalseVal); else if (CondVal == FalseVal) - return BinaryOperator::createAnd(CondVal, TrueVal); + return BinaryOperator::CreateAnd(CondVal, TrueVal); } // Selecting between two integer constants? @@ -8179,13 +8179,13 @@ Instruction *InstCombiner::visitSelectInst(SelectInst &SI) { if (ConstantInt *FalseValC = dyn_cast<ConstantInt>(FalseVal)) { // select C, 1, 0 -> zext C to int if (FalseValC->isZero() && TrueValC->getValue() == 1) { - return CastInst::create(Instruction::ZExt, CondVal, SI.getType()); + return CastInst::Create(Instruction::ZExt, CondVal, SI.getType()); } else if (TrueValC->isZero() && FalseValC->getValue() == 1) { // select C, 0, 1 -> zext !C to int Value *NotCond = - InsertNewInstBefore(BinaryOperator::createNot(CondVal, + InsertNewInstBefore(BinaryOperator::CreateNot(CondVal, "not."+CondVal->getName()), SI); - return CastInst::create(Instruction::ZExt, NotCond, SI.getType()); + return CastInst::Create(Instruction::ZExt, NotCond, SI.getType()); } // FIXME: Turn select 0/-1 and -1/0 into sext from condition! @@ -8201,7 +8201,7 @@ Instruction *InstCombiner::visitSelectInst(SelectInst &SI) { Value *X = IC->getOperand(0); uint32_t Bits = X->getType()->getPrimitiveSizeInBits(); Constant *ShAmt = ConstantInt::get(X->getType(), Bits-1); - Instruction *SRA = BinaryOperator::create(Instruction::AShr, X, + Instruction *SRA = BinaryOperator::Create(Instruction::AShr, X, ShAmt, "ones"); InsertNewInstBefore(SRA, SI); @@ -8214,7 +8214,7 @@ Instruction *InstCombiner::visitSelectInst(SelectInst &SI) { opc = Instruction::SExt; else if (SRASize > SISize) opc = Instruction::Trunc; - return CastInst::create(opc, SRA, SI.getType()); + return CastInst::Create(opc, SRA, SI.getType()); } } @@ -8239,7 +8239,7 @@ Instruction *InstCombiner::visitSelectInst(SelectInst &SI) { ShouldNotVal ^= IC->getPredicate() == ICmpInst::ICMP_NE; Value *V = ICA; if (ShouldNotVal) - V = InsertNewInstBefore(BinaryOperator::create( + V = InsertNewInstBefore(BinaryOperator::Create( Instruction::Xor, V, ICA->getOperand(1)), SI); return ReplaceInstUsesWith(SI, V); } @@ -8344,7 +8344,7 @@ Instruction *InstCombiner::visitSelectInst(SelectInst &SI) { NegVal = ConstantExpr::getNeg(C); } else { NegVal = InsertNewInstBefore( - BinaryOperator::createNeg(SubOp->getOperand(1), "tmp"), SI); + BinaryOperator::CreateNeg(SubOp->getOperand(1), "tmp"), SI); } Value *NewTrueOp = OtherAddOp; @@ -8356,7 +8356,7 @@ Instruction *InstCombiner::visitSelectInst(SelectInst &SI) { NewFalseOp, SI.getName() + ".p"); NewSel = InsertNewInstBefore(NewSel, SI); - return BinaryOperator::createAdd(SubOp->getOperand(0), NewSel); + return BinaryOperator::CreateAdd(SubOp->getOperand(0), NewSel); } } } @@ -8384,7 +8384,7 @@ Instruction *InstCombiner::visitSelectInst(SelectInst &SI) { InsertNewInstBefore(NewSel, SI); NewSel->takeName(TVI); if (BinaryOperator *BO = dyn_cast<BinaryOperator>(TVI)) - return BinaryOperator::create(BO->getOpcode(), FalseVal, NewSel); + return BinaryOperator::Create(BO->getOpcode(), FalseVal, NewSel); else { assert(0 && "Unknown instruction!!"); } @@ -8410,7 +8410,7 @@ Instruction *InstCombiner::visitSelectInst(SelectInst &SI) { InsertNewInstBefore(NewSel, SI); NewSel->takeName(FVI); if (BinaryOperator *BO = dyn_cast<BinaryOperator>(FVI)) - return BinaryOperator::create(BO->getOpcode(), TrueVal, NewSel); + return BinaryOperator::Create(BO->getOpcode(), TrueVal, NewSel); else assert(0 && "Unknown instruction!!"); } @@ -8768,7 +8768,7 @@ Instruction *InstCombiner::visitCallInst(CallInst &CI) { i, "tmp"); InsertNewInstBefore(cast<Instruction>(Result), CI); } - return CastInst::create(Instruction::BitCast, Result, CI.getType()); + return CastInst::Create(Instruction::BitCast, Result, CI.getType()); } } break; @@ -9049,7 +9049,7 @@ bool InstCombiner::transformConstExprCastCall(CallSite CS) { } else { Instruction::CastOps opcode = CastInst::getCastOpcode(*AI, false, ParamTy, false); - CastInst *NewCast = CastInst::create(opcode, *AI, ParamTy, "tmp"); + CastInst *NewCast = CastInst::Create(opcode, *AI, ParamTy, "tmp"); Args.push_back(InsertNewInstBefore(NewCast, *Caller)); } @@ -9076,7 +9076,7 @@ bool InstCombiner::transformConstExprCastCall(CallSite CS) { // Must promote to pass through va_arg area! Instruction::CastOps opcode = CastInst::getCastOpcode(*AI, false, PTy, false); - Instruction *Cast = CastInst::create(opcode, *AI, PTy, "tmp"); + Instruction *Cast = CastInst::Create(opcode, *AI, PTy, "tmp"); InsertNewInstBefore(Cast, *Caller); Args.push_back(Cast); } else { @@ -9118,7 +9118,7 @@ bool InstCombiner::transformConstExprCastCall(CallSite CS) { if (NV->getType() != Type::VoidTy) { Instruction::CastOps opcode = CastInst::getCastOpcode(NC, false, OldRetTy, false); - NV = NC = CastInst::create(opcode, NC, OldRetTy, "tmp"); + NV = NC = CastInst::Create(opcode, NC, OldRetTy, "tmp"); // If this is an invoke instruction, we should insert it after the first // non-phi, instruction in the normal successor block. @@ -9370,9 +9370,9 @@ Instruction *InstCombiner::FoldPHIArgBinOpIntoPHI(PHINode &PN) { } if (BinaryOperator *BinOp = dyn_cast<BinaryOperator>(FirstInst)) - return BinaryOperator::create(BinOp->getOpcode(), LHSVal, RHSVal); + return BinaryOperator::Create(BinOp->getOpcode(), LHSVal, RHSVal); else if (CmpInst *CIOp = dyn_cast<CmpInst>(FirstInst)) - return CmpInst::create(CIOp->getOpcode(), CIOp->getPredicate(), LHSVal, + return CmpInst::Create(CIOp->getOpcode(), CIOp->getPredicate(), LHSVal, RHSVal); else { assert(isa<GetElementPtrInst>(FirstInst)); @@ -9515,11 +9515,11 @@ Instruction *InstCombiner::FoldPHIArgOpIntoPHI(PHINode &PN) { // Insert and return the new operation. if (CastInst* FirstCI = dyn_cast<CastInst>(FirstInst)) - return CastInst::create(FirstCI->getOpcode(), PhiVal, PN.getType()); + return CastInst::Create(FirstCI->getOpcode(), PhiVal, PN.getType()); if (BinaryOperator *BinOp = dyn_cast<BinaryOperator>(FirstInst)) - return BinaryOperator::create(BinOp->getOpcode(), PhiVal, ConstantOp); + return BinaryOperator::Create(BinOp->getOpcode(), PhiVal, ConstantOp); if (CmpInst *CIOp = dyn_cast<CmpInst>(FirstInst)) - return CmpInst::create(CIOp->getOpcode(), CIOp->getPredicate(), + return CmpInst::Create(CIOp->getOpcode(), CIOp->getPredicate(), PhiVal, ConstantOp); assert(isa<LoadInst>(FirstInst) && "Unknown operation"); @@ -9814,7 +9814,7 @@ Instruction *InstCombiner::visitGetElementPtrInst(GetElementPtrInst &GEP) { if (isa<Constant>(SO1) && isa<Constant>(GO1)) Sum = ConstantExpr::getAdd(cast<Constant>(SO1), cast<Constant>(GO1)); else { - Sum = BinaryOperator::createAdd(SO1, GO1, PtrOp->getName()+".sum"); + Sum = BinaryOperator::CreateAdd(SO1, GO1, PtrOp->getName()+".sum"); InsertNewInstBefore(cast<Instruction>(Sum), GEP); } } @@ -9945,7 +9945,7 @@ Instruction *InstCombiner::visitGetElementPtrInst(GetElementPtrInst &GEP) { if (Scale->getZExtValue() != 1) { Constant *C = ConstantExpr::getIntegerCast(Scale, NewIdx->getType(), false /*ZExt*/); - Instruction *Sc = BinaryOperator::createMul(NewIdx, C, "idxscale"); + Instruction *Sc = BinaryOperator::CreateMul(NewIdx, C, "idxscale"); NewIdx = InsertNewInstBefore(Sc, GEP); } @@ -10379,7 +10379,7 @@ static Instruction *InstCombineStoreToCast(InstCombiner &IC, StoreInst &SI) { NewCast = ConstantExpr::getCast(opcode, C, CastDstTy); else NewCast = IC.InsertNewInstBefore( - CastInst::create(opcode, SIOp0, CastDstTy, SIOp0->getName()+".c"), + CastInst::Create(opcode, SIOp0, CastDstTy, SIOp0->getName()+".c"), SI); return new StoreInst(NewCast, CastOp); } @@ -10868,7 +10868,7 @@ Instruction *InstCombiner::visitExtractElementInst(ExtractElementInst &EI) { EI.getName()+".rhs"); InsertNewInstBefore(newEI0, EI); InsertNewInstBefore(newEI1, EI); - return BinaryOperator::create(BO->getOpcode(), newEI0, newEI1); + return BinaryOperator::Create(BO->getOpcode(), newEI0, newEI1); } } else if (isa<LoadInst>(I)) { unsigned AS = diff --git a/lib/Transforms/Scalar/LoopIndexSplit.cpp b/lib/Transforms/Scalar/LoopIndexSplit.cpp index 6113b24..8b55444 100644 --- a/lib/Transforms/Scalar/LoopIndexSplit.cpp +++ b/lib/Transforms/Scalar/LoopIndexSplit.cpp @@ -581,7 +581,7 @@ bool LoopIndexSplit::processOneIterationLoop(SplitInfo &SD) { ICmpInst::ICMP_SLT : ICmpInst::ICMP_ULT, SD.SplitValue, ExitValue, "lisplit", Terminator); - Instruction *NSplitCond = BinaryOperator::createAnd(C1, C2, "lisplit", + Instruction *NSplitCond = BinaryOperator::CreateAnd(C1, C2, "lisplit", Terminator); SD.SplitCondition->replaceAllUsesWith(NSplitCond); SD.SplitCondition->eraseFromParent(); @@ -769,7 +769,7 @@ void LoopIndexSplit::updateLoopBounds(ICmpInst *CI) { // if (ExitCondition->getPredicate() == ICmpInst::ICMP_SLT || ExitCondition->getPredicate() == ICmpInst::ICMP_ULT) { - Value *A = BinaryOperator::createAdd(NV, ConstantInt::get(Ty, 1, Sign), + Value *A = BinaryOperator::CreateAdd(NV, ConstantInt::get(Ty, 1, Sign), "lsplit.add", PHTerminator); Value *C = new ICmpInst(Sign ? ICmpInst::ICMP_SLT : ICmpInst::ICMP_ULT, A, UB,"lsplit,c", PHTerminator); @@ -821,7 +821,7 @@ void LoopIndexSplit::updateLoopBounds(ICmpInst *CI) { // else if (ExitCondition->getPredicate() == ICmpInst::ICMP_SLE || ExitCondition->getPredicate() == ICmpInst::ICMP_ULE) { - Value *S = BinaryOperator::createSub(NV, ConstantInt::get(Ty, 1, Sign), + Value *S = BinaryOperator::CreateSub(NV, ConstantInt::get(Ty, 1, Sign), "lsplit.add", PHTerminator); Value *C = new ICmpInst(Sign ? ICmpInst::ICMP_SLT : ICmpInst::ICMP_ULT, S, UB, "lsplit.c", PHTerminator); @@ -857,7 +857,7 @@ void LoopIndexSplit::updateLoopBounds(ICmpInst *CI) { // LOOP_BODY // { - Value *A = BinaryOperator::createAdd(NV, ConstantInt::get(Ty, 1, Sign), + Value *A = BinaryOperator::CreateAdd(NV, ConstantInt::get(Ty, 1, Sign), "lsplit.add", PHTerminator); Value *C = new ICmpInst(Sign ? ICmpInst::ICMP_SLT : ICmpInst::ICMP_ULT, A, StartValue, "lsplit.c", PHTerminator); @@ -1213,7 +1213,7 @@ void LoopIndexSplit::calculateLoopBounds(SplitInfo &SD) { // A; // for (i = max(LB, BSV); i < UB; ++i) // B; - BSV = BinaryOperator::createAdd(SD.SplitValue, + BSV = BinaryOperator::CreateAdd(SD.SplitValue, ConstantInt::get(Ty, 1, Sign), "lsplit.add", PHTerminator); AEV = BSV; @@ -1244,7 +1244,7 @@ void LoopIndexSplit::calculateLoopBounds(SplitInfo &SD) { // B; // for (i = max(LB, BSV); i < UB; ++i) // A; - BSV = BinaryOperator::createAdd(SD.SplitValue, + BSV = BinaryOperator::CreateAdd(SD.SplitValue, ConstantInt::get(Ty, 1, Sign), "lsplit.add", PHTerminator); AEV = BSV; @@ -1272,7 +1272,7 @@ void LoopIndexSplit::calculateLoopBounds(SplitInfo &SD) { // A; // for (i = max(LB, BSV); i <= UB; ++i) // B; - AEV = BinaryOperator::createSub(SD.SplitValue, + AEV = BinaryOperator::CreateSub(SD.SplitValue, ConstantInt::get(Ty, 1, Sign), "lsplit.sub", PHTerminator); break; @@ -1288,7 +1288,7 @@ void LoopIndexSplit::calculateLoopBounds(SplitInfo &SD) { // A; // for (i = max(LB, BSV); i <= UB; ++i) // B; - BSV = BinaryOperator::createAdd(SD.SplitValue, + BSV = BinaryOperator::CreateAdd(SD.SplitValue, ConstantInt::get(Ty, 1, Sign), "lsplit.add", PHTerminator); break; @@ -1304,7 +1304,7 @@ void LoopIndexSplit::calculateLoopBounds(SplitInfo &SD) { // B; // for (i = max(LB, BSV); i <= UB; ++i) // A; - BSV = BinaryOperator::createAdd(SD.SplitValue, + BSV = BinaryOperator::CreateAdd(SD.SplitValue, ConstantInt::get(Ty, 1, Sign), "lsplit.add", PHTerminator); break; @@ -1321,7 +1321,7 @@ void LoopIndexSplit::calculateLoopBounds(SplitInfo &SD) { // B; // for (i = max(LB, BSV); i <= UB; ++i) // A; - AEV = BinaryOperator::createSub(SD.SplitValue, + AEV = BinaryOperator::CreateSub(SD.SplitValue, ConstantInt::get(Ty, 1, Sign), "lsplit.sub", PHTerminator); break; diff --git a/lib/Transforms/Scalar/MemCpyOptimizer.cpp b/lib/Transforms/Scalar/MemCpyOptimizer.cpp index 8036bf8..22a00ba 100644 --- a/lib/Transforms/Scalar/MemCpyOptimizer.cpp +++ b/lib/Transforms/Scalar/MemCpyOptimizer.cpp @@ -583,7 +583,7 @@ bool MemCpyOpt::performCallSlotOptzn(MemCpyInst *cpy, CallInst *C) { for (unsigned i = 0; i < CS.arg_size(); ++i) if (CS.getArgument(i) == cpySrc) { if (cpySrc->getType() != cpyDest->getType()) - cpyDest = CastInst::createPointerCast(cpyDest, cpySrc->getType(), + cpyDest = CastInst::CreatePointerCast(cpyDest, cpySrc->getType(), cpyDest->getName(), C); CS.setArgument(i, cpyDest); } diff --git a/lib/Transforms/Scalar/Reassociate.cpp b/lib/Transforms/Scalar/Reassociate.cpp index e2d133c..de1a3ba 100644 --- a/lib/Transforms/Scalar/Reassociate.cpp +++ b/lib/Transforms/Scalar/Reassociate.cpp @@ -194,7 +194,7 @@ static BinaryOperator *isReassociableOp(Value *V, unsigned Opcode) { static Instruction *LowerNegateToMultiply(Instruction *Neg) { Constant *Cst = ConstantInt::getAllOnesValue(Neg->getType()); - Instruction *Res = BinaryOperator::createMul(Neg->getOperand(1), Cst, "",Neg); + Instruction *Res = BinaryOperator::CreateMul(Neg->getOperand(1), Cst, "",Neg); Res->takeName(Neg); Neg->replaceAllUsesWith(Res); Neg->eraseFromParent(); @@ -389,7 +389,7 @@ static Value *NegateValue(Value *V, Instruction *BI) { // Insert a 'neg' instruction that subtracts the value from zero to get the // negation. // - return BinaryOperator::createNeg(V, V->getName() + ".neg", BI); + return BinaryOperator::CreateNeg(V, V->getName() + ".neg", BI); } /// ShouldBreakUpSubtract - Return true if we should break up this subtract of @@ -427,7 +427,7 @@ static Instruction *BreakUpSubtract(Instruction *Sub) { // Value *NegVal = NegateValue(Sub->getOperand(1), Sub); Instruction *New = - BinaryOperator::createAdd(Sub->getOperand(0), NegVal, "", Sub); + BinaryOperator::CreateAdd(Sub->getOperand(0), NegVal, "", Sub); New->takeName(Sub); // Everyone now refers to the add instruction. @@ -451,7 +451,7 @@ static Instruction *ConvertShiftToMul(Instruction *Shl) { Constant *MulCst = ConstantInt::get(Shl->getType(), 1); MulCst = ConstantExpr::getShl(MulCst, cast<Constant>(Shl->getOperand(1))); - Instruction *Mul = BinaryOperator::createMul(Shl->getOperand(0), MulCst, + Instruction *Mul = BinaryOperator::CreateMul(Shl->getOperand(0), MulCst, "", Shl); Mul->takeName(Shl); Shl->replaceAllUsesWith(Mul); @@ -485,7 +485,7 @@ static Value *EmitAddTreeOfValues(Instruction *I, std::vector<Value*> &Ops) { Value *V1 = Ops.back(); Ops.pop_back(); Value *V2 = EmitAddTreeOfValues(I, Ops); - return BinaryOperator::createAdd(V2, V1, "tmp", I); + return BinaryOperator::CreateAdd(V2, V1, "tmp", I); } /// RemoveFactorFromExpression - If V is an expression tree that is a @@ -714,7 +714,7 @@ Value *Reassociate::OptimizeExpression(BinaryOperator *I, // this, we could otherwise run into situations where removing a factor // from an expression will drop a use of maxocc, and this can cause // RemoveFactorFromExpression on successive values to behave differently. - Instruction *DummyInst = BinaryOperator::createAdd(MaxOccVal, MaxOccVal); + Instruction *DummyInst = BinaryOperator::CreateAdd(MaxOccVal, MaxOccVal); std::vector<Value*> NewMulOps; for (unsigned i = 0, e = Ops.size(); i != e; ++i) { if (Value *V = RemoveFactorFromExpression(Ops[i].Op, MaxOccVal)) { @@ -729,7 +729,7 @@ Value *Reassociate::OptimizeExpression(BinaryOperator *I, unsigned NumAddedValues = NewMulOps.size(); Value *V = EmitAddTreeOfValues(I, NewMulOps); - Value *V2 = BinaryOperator::createMul(V, MaxOccVal, "tmp", I); + Value *V2 = BinaryOperator::CreateMul(V, MaxOccVal, "tmp", I); // Now that we have inserted V and its sole use, optimize it. This allows // us to handle cases that require multiple factoring steps, such as this: diff --git a/lib/Transforms/Scalar/Reg2Mem.cpp b/lib/Transforms/Scalar/Reg2Mem.cpp index 6d408df..ce38b08 100644 --- a/lib/Transforms/Scalar/Reg2Mem.cpp +++ b/lib/Transforms/Scalar/Reg2Mem.cpp @@ -67,7 +67,7 @@ namespace { while (isa<AllocaInst>(I)) ++I; CastInst *AllocaInsertionPoint = - CastInst::create(Instruction::BitCast, + CastInst::Create(Instruction::BitCast, Constant::getNullValue(Type::Int32Ty), Type::Int32Ty, "reg2mem alloca point", I); diff --git a/lib/Transforms/Scalar/ScalarReplAggregates.cpp b/lib/Transforms/Scalar/ScalarReplAggregates.cpp index 0cd10ef..7102b17 100644 --- a/lib/Transforms/Scalar/ScalarReplAggregates.cpp +++ b/lib/Transforms/Scalar/ScalarReplAggregates.cpp @@ -1204,11 +1204,11 @@ Value *SROA::ConvertUsesOfLoadToScalar(LoadInst *LI, AllocaInst *NewAI, // We do this to support (f.e.) loads off the end of a structure where // only some bits are used. if (ShAmt > 0 && (unsigned)ShAmt < NTy->getBitWidth()) - NV = BinaryOperator::createLShr(NV, + NV = BinaryOperator::CreateLShr(NV, ConstantInt::get(NV->getType(),ShAmt), LI->getName(), LI); else if (ShAmt < 0 && (unsigned)-ShAmt < NTy->getBitWidth()) - NV = BinaryOperator::createShl(NV, + NV = BinaryOperator::CreateShl(NV, ConstantInt::get(NV->getType(),-ShAmt), LI->getName(), LI); @@ -1308,12 +1308,12 @@ Value *SROA::ConvertUsesOfStoreToScalar(StoreInst *SI, AllocaInst *NewAI, // only some bits in the structure are set. APInt Mask(APInt::getLowBitsSet(DestWidth, SrcWidth)); if (ShAmt > 0 && (unsigned)ShAmt < DestWidth) { - SV = BinaryOperator::createShl(SV, + SV = BinaryOperator::CreateShl(SV, ConstantInt::get(SV->getType(), ShAmt), SV->getName(), SI); Mask <<= ShAmt; } else if (ShAmt < 0 && (unsigned)-ShAmt < DestWidth) { - SV = BinaryOperator::createLShr(SV, + SV = BinaryOperator::CreateLShr(SV, ConstantInt::get(SV->getType(),-ShAmt), SV->getName(), SI); Mask = Mask.lshr(ShAmt); @@ -1323,9 +1323,9 @@ Value *SROA::ConvertUsesOfStoreToScalar(StoreInst *SI, AllocaInst *NewAI, // in the new bits. if (SrcWidth != DestWidth) { assert(DestWidth > SrcWidth); - Old = BinaryOperator::createAnd(Old, ConstantInt::get(~Mask), + Old = BinaryOperator::CreateAnd(Old, ConstantInt::get(~Mask), Old->getName()+".mask", SI); - SV = BinaryOperator::createOr(Old, SV, SV->getName()+".ins", SI); + SV = BinaryOperator::CreateOr(Old, SV, SV->getName()+".ins", SI); } } return SV; diff --git a/lib/Transforms/Utils/LowerAllocations.cpp b/lib/Transforms/Utils/LowerAllocations.cpp index f65a716..4223c7f 100644 --- a/lib/Transforms/Utils/LowerAllocations.cpp +++ b/lib/Transforms/Utils/LowerAllocations.cpp @@ -131,11 +131,11 @@ bool LowerAllocations::runOnBasicBlock(BasicBlock &BB) { } else { Value *Scale = MI->getOperand(0); if (Scale->getType() != IntPtrTy) - Scale = CastInst::createIntegerCast(Scale, IntPtrTy, false /*ZExt*/, + Scale = CastInst::CreateIntegerCast(Scale, IntPtrTy, false /*ZExt*/, "", I); // Multiply it by the array size if necessary... - MallocArg = BinaryOperator::create(Instruction::Mul, Scale, + MallocArg = BinaryOperator::Create(Instruction::Mul, Scale, MallocArg, "", I); } } diff --git a/lib/Transforms/Utils/LowerSwitch.cpp b/lib/Transforms/Utils/LowerSwitch.cpp index c248478..630f97c 100644 --- a/lib/Transforms/Utils/LowerSwitch.cpp +++ b/lib/Transforms/Utils/LowerSwitch.cpp @@ -202,7 +202,7 @@ BasicBlock* LowerSwitch::newLeafBlock(CaseRange& Leaf, Value* Val, } else { // Emit V-Lo <=u Hi-Lo Constant* NegLo = ConstantExpr::getNeg(Leaf.Low); - Instruction* Add = BinaryOperator::createAdd(Val, NegLo, + Instruction* Add = BinaryOperator::CreateAdd(Val, NegLo, Val->getName()+".off", NewLeaf); Constant *UpperBound = ConstantExpr::getAdd(NegLo, Leaf.High); diff --git a/lib/Transforms/Utils/SimplifyCFG.cpp b/lib/Transforms/Utils/SimplifyCFG.cpp index 7396bb4..45d3d4e 100644 --- a/lib/Transforms/Utils/SimplifyCFG.cpp +++ b/lib/Transforms/Utils/SimplifyCFG.cpp @@ -1513,7 +1513,7 @@ bool llvm::SimplifyCFG(BasicBlock *BB) { // Invert the predecessors condition test (xor it with true), // which allows us to write this code once. Value *NewCond = - BinaryOperator::createNot(PBI->getCondition(), + BinaryOperator::CreateNot(PBI->getCondition(), PBI->getCondition()->getName()+".not", PBI); PBI->setCondition(NewCond); BasicBlock *OldTrue = PBI->getSuccessor(0); @@ -1534,7 +1534,7 @@ bool llvm::SimplifyCFG(BasicBlock *BB) { PBI->getSuccessor(0) == TrueDest ? Instruction::Or : Instruction::And; Value *NewCond = - BinaryOperator::create(Opcode, PBI->getCondition(), + BinaryOperator::Create(Opcode, PBI->getCondition(), New, "bothcond", PBI); PBI->setCondition(NewCond); if (PBI->getSuccessor(0) == BB) { @@ -1656,17 +1656,17 @@ bool llvm::SimplifyCFG(BasicBlock *BB) { // Make sure we get to CommonDest on True&True directions. Value *PBICond = PBI->getCondition(); if (PBIOp) - PBICond = BinaryOperator::createNot(PBICond, + PBICond = BinaryOperator::CreateNot(PBICond, PBICond->getName()+".not", PBI); Value *BICond = BI->getCondition(); if (BIOp) - BICond = BinaryOperator::createNot(BICond, + BICond = BinaryOperator::CreateNot(BICond, BICond->getName()+".not", PBI); // Merge the conditions. Value *Cond = - BinaryOperator::createOr(PBICond, BICond, "brmerge", PBI); + BinaryOperator::CreateOr(PBICond, BICond, "brmerge", PBI); // Modify PBI to branch on the new condition to the new dests. PBI->setCondition(Cond); diff --git a/lib/VMCore/AutoUpgrade.cpp b/lib/VMCore/AutoUpgrade.cpp index 7faff56..bed8fee 100644 --- a/lib/VMCore/AutoUpgrade.cpp +++ b/lib/VMCore/AutoUpgrade.cpp @@ -272,7 +272,7 @@ void llvm::UpgradeIntrinsicCall(CallInst *CI, Function *NewFn) { bool DestSExt = F->getParamAttrs().paramHasAttr(0, ParamAttr::SExt); // Construct an appropriate cast from the new return type to the old. - CastInst *RetCast = CastInst::create( + CastInst *RetCast = CastInst::Create( CastInst::getCastOpcode(NewCI, SrcSExt, F->getReturnType(), DestSExt), diff --git a/lib/VMCore/Instructions.cpp b/lib/VMCore/Instructions.cpp index 9fc70ce..ff3b8b5 100644 --- a/lib/VMCore/Instructions.cpp +++ b/lib/VMCore/Instructions.cpp @@ -1450,7 +1450,7 @@ void BinaryOperator::init(BinaryOps iType) { #endif } -BinaryOperator *BinaryOperator::create(BinaryOps Op, Value *S1, Value *S2, +BinaryOperator *BinaryOperator::Create(BinaryOps Op, Value *S1, Value *S2, const std::string &Name, Instruction *InsertBefore) { assert(S1->getType() == S2->getType() && @@ -1458,15 +1458,15 @@ BinaryOperator *BinaryOperator::create(BinaryOps Op, Value *S1, Value *S2, return new BinaryOperator(Op, S1, S2, S1->getType(), Name, InsertBefore); } -BinaryOperator *BinaryOperator::create(BinaryOps Op, Value *S1, Value *S2, +BinaryOperator *BinaryOperator::Create(BinaryOps Op, Value *S1, Value *S2, const std::string &Name, BasicBlock *InsertAtEnd) { - BinaryOperator *Res = create(Op, S1, S2, Name); + BinaryOperator *Res = Create(Op, S1, S2, Name); InsertAtEnd->getInstList().push_back(Res); return Res; } -BinaryOperator *BinaryOperator::createNeg(Value *Op, const std::string &Name, +BinaryOperator *BinaryOperator::CreateNeg(Value *Op, const std::string &Name, Instruction *InsertBefore) { Value *zero = ConstantExpr::getZeroValueForNegationExpr(Op->getType()); return new BinaryOperator(Instruction::Sub, @@ -1474,7 +1474,7 @@ BinaryOperator *BinaryOperator::createNeg(Value *Op, const std::string &Name, Op->getType(), Name, InsertBefore); } -BinaryOperator *BinaryOperator::createNeg(Value *Op, const std::string &Name, +BinaryOperator *BinaryOperator::CreateNeg(Value *Op, const std::string &Name, BasicBlock *InsertAtEnd) { Value *zero = ConstantExpr::getZeroValueForNegationExpr(Op->getType()); return new BinaryOperator(Instruction::Sub, @@ -1482,7 +1482,7 @@ BinaryOperator *BinaryOperator::createNeg(Value *Op, const std::string &Name, Op->getType(), Name, InsertAtEnd); } -BinaryOperator *BinaryOperator::createNot(Value *Op, const std::string &Name, +BinaryOperator *BinaryOperator::CreateNot(Value *Op, const std::string &Name, Instruction *InsertBefore) { Constant *C; if (const VectorType *PTy = dyn_cast<VectorType>(Op->getType())) { @@ -1496,7 +1496,7 @@ BinaryOperator *BinaryOperator::createNot(Value *Op, const std::string &Name, Op->getType(), Name, InsertBefore); } -BinaryOperator *BinaryOperator::createNot(Value *Op, const std::string &Name, +BinaryOperator *BinaryOperator::CreateNot(Value *Op, const std::string &Name, BasicBlock *InsertAtEnd) { Constant *AllOnes; if (const VectorType *PTy = dyn_cast<VectorType>(Op->getType())) { @@ -1801,7 +1801,7 @@ unsigned CastInst::isEliminableCastPair( return 0; } -CastInst *CastInst::create(Instruction::CastOps op, Value *S, const Type *Ty, +CastInst *CastInst::Create(Instruction::CastOps op, Value *S, const Type *Ty, const std::string &Name, Instruction *InsertBefore) { // Construct and return the appropriate CastInst subclass switch (op) { @@ -1823,7 +1823,7 @@ CastInst *CastInst::create(Instruction::CastOps op, Value *S, const Type *Ty, return 0; } -CastInst *CastInst::create(Instruction::CastOps op, Value *S, const Type *Ty, +CastInst *CastInst::Create(Instruction::CastOps op, Value *S, const Type *Ty, const std::string &Name, BasicBlock *InsertAtEnd) { // Construct and return the appropriate CastInst subclass switch (op) { @@ -1845,55 +1845,55 @@ CastInst *CastInst::create(Instruction::CastOps op, Value *S, const Type *Ty, return 0; } -CastInst *CastInst::createZExtOrBitCast(Value *S, const Type *Ty, +CastInst *CastInst::CreateZExtOrBitCast(Value *S, const Type *Ty, const std::string &Name, Instruction *InsertBefore) { if (S->getType()->getPrimitiveSizeInBits() == Ty->getPrimitiveSizeInBits()) - return create(Instruction::BitCast, S, Ty, Name, InsertBefore); - return create(Instruction::ZExt, S, Ty, Name, InsertBefore); + return Create(Instruction::BitCast, S, Ty, Name, InsertBefore); + return Create(Instruction::ZExt, S, Ty, Name, InsertBefore); } -CastInst *CastInst::createZExtOrBitCast(Value *S, const Type *Ty, +CastInst *CastInst::CreateZExtOrBitCast(Value *S, const Type *Ty, const std::string &Name, BasicBlock *InsertAtEnd) { if (S->getType()->getPrimitiveSizeInBits() == Ty->getPrimitiveSizeInBits()) - return create(Instruction::BitCast, S, Ty, Name, InsertAtEnd); - return create(Instruction::ZExt, S, Ty, Name, InsertAtEnd); + return Create(Instruction::BitCast, S, Ty, Name, InsertAtEnd); + return Create(Instruction::ZExt, S, Ty, Name, InsertAtEnd); } -CastInst *CastInst::createSExtOrBitCast(Value *S, const Type *Ty, +CastInst *CastInst::CreateSExtOrBitCast(Value *S, const Type *Ty, const std::string &Name, Instruction *InsertBefore) { if (S->getType()->getPrimitiveSizeInBits() == Ty->getPrimitiveSizeInBits()) - return create(Instruction::BitCast, S, Ty, Name, InsertBefore); - return create(Instruction::SExt, S, Ty, Name, InsertBefore); + return Create(Instruction::BitCast, S, Ty, Name, InsertBefore); + return Create(Instruction::SExt, S, Ty, Name, InsertBefore); } -CastInst *CastInst::createSExtOrBitCast(Value *S, const Type *Ty, +CastInst *CastInst::CreateSExtOrBitCast(Value *S, const Type *Ty, const std::string &Name, BasicBlock *InsertAtEnd) { if (S->getType()->getPrimitiveSizeInBits() == Ty->getPrimitiveSizeInBits()) - return create(Instruction::BitCast, S, Ty, Name, InsertAtEnd); - return create(Instruction::SExt, S, Ty, Name, InsertAtEnd); + return Create(Instruction::BitCast, S, Ty, Name, InsertAtEnd); + return Create(Instruction::SExt, S, Ty, Name, InsertAtEnd); } -CastInst *CastInst::createTruncOrBitCast(Value *S, const Type *Ty, +CastInst *CastInst::CreateTruncOrBitCast(Value *S, const Type *Ty, const std::string &Name, Instruction *InsertBefore) { if (S->getType()->getPrimitiveSizeInBits() == Ty->getPrimitiveSizeInBits()) - return create(Instruction::BitCast, S, Ty, Name, InsertBefore); - return create(Instruction::Trunc, S, Ty, Name, InsertBefore); + return Create(Instruction::BitCast, S, Ty, Name, InsertBefore); + return Create(Instruction::Trunc, S, Ty, Name, InsertBefore); } -CastInst *CastInst::createTruncOrBitCast(Value *S, const Type *Ty, +CastInst *CastInst::CreateTruncOrBitCast(Value *S, const Type *Ty, const std::string &Name, BasicBlock *InsertAtEnd) { if (S->getType()->getPrimitiveSizeInBits() == Ty->getPrimitiveSizeInBits()) - return create(Instruction::BitCast, S, Ty, Name, InsertAtEnd); - return create(Instruction::Trunc, S, Ty, Name, InsertAtEnd); + return Create(Instruction::BitCast, S, Ty, Name, InsertAtEnd); + return Create(Instruction::Trunc, S, Ty, Name, InsertAtEnd); } -CastInst *CastInst::createPointerCast(Value *S, const Type *Ty, +CastInst *CastInst::CreatePointerCast(Value *S, const Type *Ty, const std::string &Name, BasicBlock *InsertAtEnd) { assert(isa<PointerType>(S->getType()) && "Invalid cast"); @@ -1901,12 +1901,12 @@ CastInst *CastInst::createPointerCast(Value *S, const Type *Ty, "Invalid cast"); if (Ty->isInteger()) - return create(Instruction::PtrToInt, S, Ty, Name, InsertAtEnd); - return create(Instruction::BitCast, S, Ty, Name, InsertAtEnd); + return Create(Instruction::PtrToInt, S, Ty, Name, InsertAtEnd); + return Create(Instruction::BitCast, S, Ty, Name, InsertAtEnd); } /// @brief Create a BitCast or a PtrToInt cast instruction -CastInst *CastInst::createPointerCast(Value *S, const Type *Ty, +CastInst *CastInst::CreatePointerCast(Value *S, const Type *Ty, const std::string &Name, Instruction *InsertBefore) { assert(isa<PointerType>(S->getType()) && "Invalid cast"); @@ -1914,11 +1914,11 @@ CastInst *CastInst::createPointerCast(Value *S, const Type *Ty, "Invalid cast"); if (Ty->isInteger()) - return create(Instruction::PtrToInt, S, Ty, Name, InsertBefore); - return create(Instruction::BitCast, S, Ty, Name, InsertBefore); + return Create(Instruction::PtrToInt, S, Ty, Name, InsertBefore); + return Create(Instruction::BitCast, S, Ty, Name, InsertBefore); } -CastInst *CastInst::createIntegerCast(Value *C, const Type *Ty, +CastInst *CastInst::CreateIntegerCast(Value *C, const Type *Ty, bool isSigned, const std::string &Name, Instruction *InsertBefore) { assert(C->getType()->isInteger() && Ty->isInteger() && "Invalid cast"); @@ -1928,10 +1928,10 @@ CastInst *CastInst::createIntegerCast(Value *C, const Type *Ty, (SrcBits == DstBits ? Instruction::BitCast : (SrcBits > DstBits ? Instruction::Trunc : (isSigned ? Instruction::SExt : Instruction::ZExt))); - return create(opcode, C, Ty, Name, InsertBefore); + return Create(opcode, C, Ty, Name, InsertBefore); } -CastInst *CastInst::createIntegerCast(Value *C, const Type *Ty, +CastInst *CastInst::CreateIntegerCast(Value *C, const Type *Ty, bool isSigned, const std::string &Name, BasicBlock *InsertAtEnd) { assert(C->getType()->isInteger() && Ty->isInteger() && "Invalid cast"); @@ -1941,10 +1941,10 @@ CastInst *CastInst::createIntegerCast(Value *C, const Type *Ty, (SrcBits == DstBits ? Instruction::BitCast : (SrcBits > DstBits ? Instruction::Trunc : (isSigned ? Instruction::SExt : Instruction::ZExt))); - return create(opcode, C, Ty, Name, InsertAtEnd); + return Create(opcode, C, Ty, Name, InsertAtEnd); } -CastInst *CastInst::createFPCast(Value *C, const Type *Ty, +CastInst *CastInst::CreateFPCast(Value *C, const Type *Ty, const std::string &Name, Instruction *InsertBefore) { assert(C->getType()->isFloatingPoint() && Ty->isFloatingPoint() && @@ -1954,10 +1954,10 @@ CastInst *CastInst::createFPCast(Value *C, const Type *Ty, Instruction::CastOps opcode = (SrcBits == DstBits ? Instruction::BitCast : (SrcBits > DstBits ? Instruction::FPTrunc : Instruction::FPExt)); - return create(opcode, C, Ty, Name, InsertBefore); + return Create(opcode, C, Ty, Name, InsertBefore); } -CastInst *CastInst::createFPCast(Value *C, const Type *Ty, +CastInst *CastInst::CreateFPCast(Value *C, const Type *Ty, const std::string &Name, BasicBlock *InsertAtEnd) { assert(C->getType()->isFloatingPoint() && Ty->isFloatingPoint() && @@ -1967,7 +1967,7 @@ CastInst *CastInst::createFPCast(Value *C, const Type *Ty, Instruction::CastOps opcode = (SrcBits == DstBits ? Instruction::BitCast : (SrcBits > DstBits ? Instruction::FPTrunc : Instruction::FPExt)); - return create(opcode, C, Ty, Name, InsertAtEnd); + return Create(opcode, C, Ty, Name, InsertAtEnd); } // Check whether it is valid to call getCastOpcode for these types. @@ -2367,7 +2367,7 @@ CmpInst::CmpInst(const Type *ty, OtherOps op, unsigned short predicate, } CmpInst * -CmpInst::create(OtherOps Op, unsigned short predicate, Value *S1, Value *S2, +CmpInst::Create(OtherOps Op, unsigned short predicate, Value *S1, Value *S2, const std::string &Name, Instruction *InsertBefore) { if (Op == Instruction::ICmp) { return new ICmpInst(CmpInst::Predicate(predicate), S1, S2, Name, @@ -2386,7 +2386,7 @@ CmpInst::create(OtherOps Op, unsigned short predicate, Value *S1, Value *S2, } CmpInst * -CmpInst::create(OtherOps Op, unsigned short predicate, Value *S1, Value *S2, +CmpInst::Create(OtherOps Op, unsigned short predicate, Value *S1, Value *S2, const std::string &Name, BasicBlock *InsertAtEnd) { if (Op == Instruction::ICmp) { return new ICmpInst(CmpInst::Predicate(predicate), S1, S2, Name, @@ -2780,7 +2780,7 @@ GetElementPtrInst *GetElementPtrInst::clone() const { } BinaryOperator *BinaryOperator::clone() const { - return create(getOpcode(), Op<0>(), Op<1>()); + return Create(getOpcode(), Op<0>(), Op<1>()); } FCmpInst* FCmpInst::clone() const { |