Move types back to the 2.5 API.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@77516 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/docs/tutorial/LangImpl3.html b/docs/tutorial/LangImpl3.html
index c56b1ed..5f1072f 100644
--- a/docs/tutorial/LangImpl3.html
+++ b/docs/tutorial/LangImpl3.html
@@ -308,7 +308,7 @@
Function *PrototypeAST::Codegen() {
// Make the function type: double(double,double) etc.
std::vector<const Type*> Doubles(Args.size(), Type::DoubleTy);
- FunctionType *FT = getGlobalContext().getFunctionType(Type::DoubleTy, Doubles, false);
+ FunctionType *FT = FunctionType::get(Type::DoubleTy, Doubles, false);
Function *F = Function::Create(FT, Function::ExternalLinkage, Name, TheModule);
</pre>
@@ -1082,7 +1082,7 @@
Function *PrototypeAST::Codegen() {
// Make the function type: double(double,double) etc.
std::vector<const Type*> Doubles(Args.size(), Type::DoubleTy);
- FunctionType *FT = getGlobalContext().getFunctionType(Type::DoubleTy, Doubles, false);
+ FunctionType *FT = FunctionType::get(Type::DoubleTy, Doubles, false);
Function *F = Function::Create(FT, Function::ExternalLinkage, Name, TheModule);
diff --git a/docs/tutorial/LangImpl4.html b/docs/tutorial/LangImpl4.html
index 45002d2..5eb69d3 100644
--- a/docs/tutorial/LangImpl4.html
+++ b/docs/tutorial/LangImpl4.html
@@ -917,7 +917,7 @@
Function *PrototypeAST::Codegen() {
// Make the function type: double(double,double) etc.
std::vector<const Type*> Doubles(Args.size(), Type::DoubleTy);
- FunctionType *FT = getGlobalContext().getFunctionType(Type::DoubleTy, Doubles, false);
+ FunctionType *FT = FunctionType::get(Type::DoubleTy, Doubles, false);
Function *F = Function::Create(FT, Function::ExternalLinkage, Name, TheModule);
diff --git a/docs/tutorial/LangImpl5.html b/docs/tutorial/LangImpl5.html
index 62a0dd9..8d77d5e 100644
--- a/docs/tutorial/LangImpl5.html
+++ b/docs/tutorial/LangImpl5.html
@@ -1551,7 +1551,7 @@
Function *PrototypeAST::Codegen() {
// Make the function type: double(double,double) etc.
std::vector<const Type*> Doubles(Args.size(), Type::DoubleTy);
- FunctionType *FT = getGlobalContext().getFunctionType(Type::DoubleTy, Doubles, false);
+ FunctionType *FT = FunctionType::get(Type::DoubleTy, Doubles, false);
Function *F = Function::Create(FT, Function::ExternalLinkage, Name, TheModule);
diff --git a/docs/tutorial/LangImpl6.html b/docs/tutorial/LangImpl6.html
index 5a553b7..0f714b3 100644
--- a/docs/tutorial/LangImpl6.html
+++ b/docs/tutorial/LangImpl6.html
@@ -1576,7 +1576,7 @@
Function *PrototypeAST::Codegen() {
// Make the function type: double(double,double) etc.
std::vector<const Type*> Doubles(Args.size(), Type::DoubleTy);
- FunctionType *FT = getGlobalContext().getFunctionType(Type::DoubleTy, Doubles, false);
+ FunctionType *FT = FunctionType::get(Type::DoubleTy, Doubles, false);
Function *F = Function::Create(FT, Function::ExternalLinkage, Name, TheModule);
diff --git a/docs/tutorial/LangImpl7.html b/docs/tutorial/LangImpl7.html
index d3ebd96..844c48f 100644
--- a/docs/tutorial/LangImpl7.html
+++ b/docs/tutorial/LangImpl7.html
@@ -1911,7 +1911,7 @@
Function *PrototypeAST::Codegen() {
// Make the function type: double(double,double) etc.
std::vector<const Type*> Doubles(Args.size(), Type::DoubleTy);
- FunctionType *FT = getGlobalContext().getFunctionType(Type::DoubleTy, Doubles, false);
+ FunctionType *FT = FunctionType::get(Type::DoubleTy, Doubles, false);
Function *F = Function::Create(FT, Function::ExternalLinkage, Name, TheModule);
diff --git a/examples/BrainF/BrainF.cpp b/examples/BrainF/BrainF.cpp
index e47365b..e161556 100644
--- a/examples/BrainF/BrainF.cpp
+++ b/examples/BrainF/BrainF.cpp
@@ -138,7 +138,7 @@
//declare i32 @puts(i8 *)
Function *puts_func = cast<Function>(module->
getOrInsertFunction("puts", IntegerType::Int32Ty,
- C.getPointerTypeUnqual(IntegerType::Int8Ty), NULL));
+ PointerType::getUnqual(IntegerType::Int8Ty), NULL));
//brainf.aberror:
aberrorbb = BasicBlock::Create(label, brainf_func);
@@ -284,7 +284,7 @@
// Make part of PHI instruction now, wait until end of loop to finish
PHINode *phi_0 =
- PHINode::Create(C.getPointerTypeUnqual(IntegerType::Int8Ty),
+ PHINode::Create(PointerType::getUnqual(IntegerType::Int8Ty),
headreg, testbb);
phi_0->reserveOperandSpace(2);
phi_0->addIncoming(curhead, bb_0);
@@ -440,7 +440,7 @@
//%head.%d = phi i8 *[%head.%d, %main.%d]
PHINode *phi_1 = builder->
- CreatePHI(C.getPointerTypeUnqual(IntegerType::Int8Ty), headreg);
+ CreatePHI(PointerType::getUnqual(IntegerType::Int8Ty), headreg);
phi_1->reserveOperandSpace(1);
phi_1->addIncoming(head_0, testbb);
curhead = phi_1;
diff --git a/examples/Kaleidoscope/toy.cpp b/examples/Kaleidoscope/toy.cpp
index 6f7f0ee..004c7b7 100644
--- a/examples/Kaleidoscope/toy.cpp
+++ b/examples/Kaleidoscope/toy.cpp
@@ -909,8 +909,7 @@
Function *PrototypeAST::Codegen() {
// Make the function type: double(double,double) etc.
std::vector<const Type*> Doubles(Args.size(), Type::DoubleTy);
- FunctionType *FT =
- getGlobalContext().getFunctionType(Type::DoubleTy, Doubles, false);
+ FunctionType *FT = FunctionType::get(Type::DoubleTy, Doubles, false);
Function *F = Function::Create(FT, Function::ExternalLinkage, Name, TheModule);
diff --git a/examples/ModuleMaker/ModuleMaker.cpp b/examples/ModuleMaker/ModuleMaker.cpp
index 1baa8c9..fc487af 100644
--- a/examples/ModuleMaker/ModuleMaker.cpp
+++ b/examples/ModuleMaker/ModuleMaker.cpp
@@ -31,7 +31,7 @@
// Create the main function: first create the type 'int ()'
FunctionType *FT =
- Context.getFunctionType(Type::Int32Ty, /*not vararg*/false);
+ FunctionType::get(Type::Int32Ty, /*not vararg*/false);
// By passing a module as the last parameter to the Function constructor,
// it automatically gets appended to the Module.
diff --git a/include/llvm/CodeGen/ValueTypes.h b/include/llvm/CodeGen/ValueTypes.h
index 57ca285..5069f9e 100644
--- a/include/llvm/CodeGen/ValueTypes.h
+++ b/include/llvm/CodeGen/ValueTypes.h
@@ -477,7 +477,7 @@
/// getTypeForMVT - This method returns an LLVM type corresponding to the
/// specified MVT. For integer types, this returns an unsigned type. Note
/// that this will abort for types that cannot be represented.
- const Type *getTypeForMVT(LLVMContext &Context) const;
+ const Type *getTypeForMVT() const;
/// getMVT - Return the value type corresponding to the specified type.
/// This returns all pointers as iPTR. If HandleUnknown is true, unknown
diff --git a/include/llvm/InstrTypes.h b/include/llvm/InstrTypes.h
index 43fe664..ddb6ad3 100644
--- a/include/llvm/InstrTypes.h
+++ b/include/llvm/InstrTypes.h
@@ -667,6 +667,14 @@
static inline bool classof(const Value *V) {
return isa<Instruction>(V) && classof(cast<Instruction>(V));
}
+
+ /// @brief Create a result type for fcmp/icmp
+ static const Type* makeCmpResultType(const Type* opnd_type) {
+ if (const VectorType* vt = dyn_cast<const VectorType>(opnd_type)) {
+ return VectorType::get(Type::Int1Ty, vt->getNumElements());
+ }
+ return Type::Int1Ty;
+ }
};
diff --git a/include/llvm/Instructions.h b/include/llvm/Instructions.h
index 2b53fac..ad5a4a9 100644
--- a/include/llvm/Instructions.h
+++ b/include/llvm/Instructions.h
@@ -645,7 +645,7 @@
Value *LHS, ///< The left-hand-side of the expression
Value *RHS, ///< The right-hand-side of the expression
const Twine &NameStr = "" ///< Name of the instruction
- ) : CmpInst(InsertBefore->getContext().makeCmpResultType(LHS->getType()),
+ ) : CmpInst(makeCmpResultType(LHS->getType()),
Instruction::ICmp, pred, LHS, RHS, NameStr,
InsertBefore) {
assert(pred >= CmpInst::FIRST_ICMP_PREDICATE &&
@@ -666,7 +666,7 @@
Value *LHS, ///< The left-hand-side of the expression
Value *RHS, ///< The right-hand-side of the expression
const Twine &NameStr = "" ///< Name of the instruction
- ) : CmpInst(InsertAtEnd.getContext().makeCmpResultType(LHS->getType()),
+ ) : CmpInst(makeCmpResultType(LHS->getType()),
Instruction::ICmp, pred, LHS, RHS, NameStr,
&InsertAtEnd) {
assert(pred >= CmpInst::FIRST_ICMP_PREDICATE &&
@@ -687,7 +687,7 @@
Value *LHS, ///< The left-hand-side of the expression
Value *RHS, ///< The right-hand-side of the expression
const Twine &NameStr = "" ///< Name of the instruction
- ) : CmpInst(Context.makeCmpResultType(LHS->getType()),
+ ) : CmpInst(makeCmpResultType(LHS->getType()),
Instruction::ICmp, pred, LHS, RHS, NameStr) {
assert(pred >= CmpInst::FIRST_ICMP_PREDICATE &&
pred <= CmpInst::LAST_ICMP_PREDICATE &&
@@ -820,7 +820,7 @@
Value *LHS, ///< The left-hand-side of the expression
Value *RHS, ///< The right-hand-side of the expression
const Twine &NameStr = "" ///< Name of the instruction
- ) : CmpInst(InsertBefore->getContext().makeCmpResultType(LHS->getType()),
+ ) : CmpInst(makeCmpResultType(LHS->getType()),
Instruction::FCmp, pred, LHS, RHS, NameStr,
InsertBefore) {
assert(pred <= FCmpInst::LAST_FCMP_PREDICATE &&
@@ -839,7 +839,7 @@
Value *LHS, ///< The left-hand-side of the expression
Value *RHS, ///< The right-hand-side of the expression
const Twine &NameStr = "" ///< Name of the instruction
- ) : CmpInst(InsertAtEnd.getContext().makeCmpResultType(LHS->getType()),
+ ) : CmpInst(makeCmpResultType(LHS->getType()),
Instruction::FCmp, pred, LHS, RHS, NameStr,
&InsertAtEnd) {
assert(pred <= FCmpInst::LAST_FCMP_PREDICATE &&
@@ -858,7 +858,7 @@
Value *LHS, ///< The left-hand-side of the expression
Value *RHS, ///< The right-hand-side of the expression
const Twine &NameStr = "" ///< Name of the instruction
- ) : CmpInst(Context.makeCmpResultType(LHS->getType()),
+ ) : CmpInst(makeCmpResultType(LHS->getType()),
Instruction::FCmp, pred, LHS, RHS, NameStr) {
assert(pred <= FCmpInst::LAST_FCMP_PREDICATE &&
"Invalid FCmp predicate value");
@@ -910,7 +910,6 @@
static inline bool classof(const Value *V) {
return isa<Instruction>(V) && classof(cast<Instruction>(V));
}
-
};
//===----------------------------------------------------------------------===//
diff --git a/include/llvm/LLVMContext.h b/include/llvm/LLVMContext.h
index 8c3e2ef..00a6581 100644
--- a/include/llvm/LLVMContext.h
+++ b/include/llvm/LLVMContext.h
@@ -91,40 +91,6 @@
// MDString accessors
MDString* getMDString(const StringRef &Str);
- // FunctionType accessors
- FunctionType* getFunctionType(const Type* Result, bool isVarArg);
- FunctionType* getFunctionType(const Type* Result,
- const std::vector<const Type*>& Params,
- bool isVarArg);
-
- // IntegerType accessors
- const IntegerType* getIntegerType(unsigned NumBits);
-
- // OpaqueType accessors
- OpaqueType* getOpaqueType();
-
- // StructType accessors
- StructType* getStructType(bool isPacked=false);
- StructType* getStructType(const std::vector<const Type*>& Params,
- bool isPacked = false);
- StructType* getStructType(const Type* type, ...);
-
- // ArrayType accessors
- ArrayType* getArrayType(const Type* ElementType, uint64_t NumElements);
-
- // PointerType accessors
- PointerType* getPointerType(const Type* ElementType, unsigned AddressSpace);
- PointerType* getPointerTypeUnqual(const Type* ElementType);
-
- // VectorType accessors
- VectorType* getVectorType(const Type* ElementType, unsigned NumElements);
- VectorType* getVectorTypeInteger(const VectorType* VTy);
- VectorType* getVectorTypeExtendedElement(const VectorType* VTy);
- VectorType* getVectorTypeTruncatedElement(const VectorType* VTy);
-
- // Other helpers
- /// @brief Create a result type for fcmp/icmp
- const Type* makeCmpResultType(const Type* opnd_type);
// Methods for erasing constants
void erase(MDString *M);
diff --git a/include/llvm/Support/TypeBuilder.h b/include/llvm/Support/TypeBuilder.h
index 5ea7f9e..1f85f1d 100644
--- a/include/llvm/Support/TypeBuilder.h
+++ b/include/llvm/Support/TypeBuilder.h
@@ -107,7 +107,7 @@
public:
static const PointerType *get(LLVMContext &Context) {
static const PointerType *const result =
- Context.getPointerTypeUnqual(TypeBuilder<T,cross>::get(Context));
+ PointerType::getUnqual(TypeBuilder<T,cross>::get(Context));
return result;
}
};
@@ -120,7 +120,7 @@
public:
static const ArrayType *get(LLVMContext &Context) {
static const ArrayType *const result =
- Context.getArrayType(TypeBuilder<T, cross>::get(Context), N);
+ ArrayType::get(TypeBuilder<T, cross>::get(Context), N);
return result;
}
};
@@ -129,7 +129,7 @@
public:
static const ArrayType *get(LLVMContext &Context) {
static const ArrayType *const result =
- Context.getArrayType(TypeBuilder<T, cross>::get(Context), 0);
+ ArrayType::get(TypeBuilder<T, cross>::get(Context), 0);
return result;
}
};
@@ -161,7 +161,7 @@
public: \
static const IntegerType *get(LLVMContext &Context) { \
static const IntegerType *const result = \
- Context.getIntegerType(sizeof(T) * CHAR_BIT); \
+ IntegerType::get(sizeof(T) * CHAR_BIT); \
return result; \
} \
}; \
@@ -191,7 +191,7 @@
class TypeBuilder<types::i<num_bits>, cross> {
public:
static const IntegerType *get(LLVMContext &Context) {
- static const IntegerType *const result = Context.getIntegerType(num_bits);
+ static const IntegerType *const result = IntegerType::get(num_bits);
return result;
}
};
@@ -254,7 +254,7 @@
private:
static const FunctionType *create(LLVMContext &Context) {
- return Context.getFunctionType(TypeBuilder<R, cross>::get(Context), false);
+ return FunctionType::get(TypeBuilder<R, cross>::get(Context), false);
}
};
template<typename R, typename A1, bool cross> class TypeBuilder<R(A1), cross> {
@@ -269,7 +269,7 @@
std::vector<const Type*> params;
params.reserve(1);
params.push_back(TypeBuilder<A1, cross>::get(Context));
- return Context.getFunctionType(TypeBuilder<R, cross>::get(Context),
+ return FunctionType::get(TypeBuilder<R, cross>::get(Context),
params, false);
}
};
@@ -287,7 +287,7 @@
params.reserve(2);
params.push_back(TypeBuilder<A1, cross>::get(Context));
params.push_back(TypeBuilder<A2, cross>::get(Context));
- return Context.getFunctionType(TypeBuilder<R, cross>::get(Context),
+ return FunctionType::get(TypeBuilder<R, cross>::get(Context),
params, false);
}
};
@@ -306,7 +306,7 @@
params.push_back(TypeBuilder<A1, cross>::get(Context));
params.push_back(TypeBuilder<A2, cross>::get(Context));
params.push_back(TypeBuilder<A3, cross>::get(Context));
- return Context.getFunctionType(TypeBuilder<R, cross>::get(Context),
+ return FunctionType::get(TypeBuilder<R, cross>::get(Context),
params, false);
}
};
@@ -328,7 +328,7 @@
params.push_back(TypeBuilder<A2, cross>::get(Context));
params.push_back(TypeBuilder<A3, cross>::get(Context));
params.push_back(TypeBuilder<A4, cross>::get(Context));
- return Context.getFunctionType(TypeBuilder<R, cross>::get(Context),
+ return FunctionType::get(TypeBuilder<R, cross>::get(Context),
params, false);
}
};
@@ -351,7 +351,7 @@
params.push_back(TypeBuilder<A3, cross>::get(Context));
params.push_back(TypeBuilder<A4, cross>::get(Context));
params.push_back(TypeBuilder<A5, cross>::get(Context));
- return Context.getFunctionType(TypeBuilder<R, cross>::get(Context),
+ return FunctionType::get(TypeBuilder<R, cross>::get(Context),
params, false);
}
};
@@ -365,7 +365,7 @@
private:
static const FunctionType *create(LLVMContext &Context) {
- return Context.getFunctionType(TypeBuilder<R, cross>::get(Context), true);
+ return FunctionType::get(TypeBuilder<R, cross>::get(Context), true);
}
};
template<typename R, typename A1, bool cross>
@@ -381,8 +381,7 @@
std::vector<const Type*> params;
params.reserve(1);
params.push_back(TypeBuilder<A1, cross>::get(Context));
- return Context.getFunctionType(TypeBuilder<R, cross>::get(Context),
- params, true);
+ return FunctionType::get(TypeBuilder<R, cross>::get(Context), params, true);
}
};
template<typename R, typename A1, typename A2, bool cross>
@@ -399,7 +398,7 @@
params.reserve(2);
params.push_back(TypeBuilder<A1, cross>::get(Context));
params.push_back(TypeBuilder<A2, cross>::get(Context));
- return Context.getFunctionType(TypeBuilder<R, cross>::get(Context),
+ return FunctionType::get(TypeBuilder<R, cross>::get(Context),
params, true);
}
};
@@ -418,7 +417,7 @@
params.push_back(TypeBuilder<A1, cross>::get(Context));
params.push_back(TypeBuilder<A2, cross>::get(Context));
params.push_back(TypeBuilder<A3, cross>::get(Context));
- return Context.getFunctionType(TypeBuilder<R, cross>::get(Context),
+ return FunctionType::get(TypeBuilder<R, cross>::get(Context),
params, true);
}
};
@@ -440,7 +439,7 @@
params.push_back(TypeBuilder<A2, cross>::get(Context));
params.push_back(TypeBuilder<A3, cross>::get(Context));
params.push_back(TypeBuilder<A4, cross>::get(Context));
- return Context.getFunctionType(TypeBuilder<R, cross>::get(Context),
+ return FunctionType::get(TypeBuilder<R, cross>::get(Context),
params, true);
}
};
@@ -463,7 +462,7 @@
params.push_back(TypeBuilder<A3, cross>::get(Context));
params.push_back(TypeBuilder<A4, cross>::get(Context));
params.push_back(TypeBuilder<A5, cross>::get(Context));
- return Context.getFunctionType(TypeBuilder<R, cross>::get(Context),
+ return FunctionType::get(TypeBuilder<R, cross>::get(Context),
params, true);
}
};
diff --git a/lib/Analysis/ConstantFolding.cpp b/lib/Analysis/ConstantFolding.cpp
index 1f034e9..126f850 100644
--- a/lib/Analysis/ConstantFolding.cpp
+++ b/lib/Analysis/ConstantFolding.cpp
@@ -184,8 +184,8 @@
if (DstEltTy->isFloatingPoint()) {
// Fold to an vector of integers with same size as our FP type.
unsigned FPWidth = DstEltTy->getPrimitiveSizeInBits();
- const Type *DestIVTy = Context.getVectorType(
- Context.getIntegerType(FPWidth), NumDstElt);
+ const Type *DestIVTy = VectorType::get(
+ IntegerType::get(FPWidth), NumDstElt);
// Recursively handle this integer conversion, if possible.
C = FoldBitCast(C, DestIVTy, TD, Context);
if (!C) return 0;
@@ -198,8 +198,8 @@
// it to integer first.
if (SrcEltTy->isFloatingPoint()) {
unsigned FPWidth = SrcEltTy->getPrimitiveSizeInBits();
- const Type *SrcIVTy = Context.getVectorType(
- Context.getIntegerType(FPWidth), NumSrcElt);
+ const Type *SrcIVTy = VectorType::get(
+ IntegerType::get(FPWidth), NumSrcElt);
// Ask VMCore to do the conversion now that #elts line up.
C = ConstantExpr::getBitCast(C, SrcIVTy);
CV = dyn_cast<ConstantVector>(C);
diff --git a/lib/Analysis/DebugInfo.cpp b/lib/Analysis/DebugInfo.cpp
index 3db7ff9..7ff1de6 100644
--- a/lib/Analysis/DebugInfo.cpp
+++ b/lib/Analysis/DebugInfo.cpp
@@ -470,7 +470,7 @@
: M(m), VMContext(M.getContext()), StopPointFn(0), FuncStartFn(0),
RegionStartFn(0), RegionEndFn(0),
DeclareFn(0) {
- EmptyStructPtr = VMContext.getPointerTypeUnqual(VMContext.getStructType());
+ EmptyStructPtr = PointerType::getUnqual(StructType::get());
}
/// getCastToEmpty - Return this descriptor as a Constant* with type '{}*'.
@@ -493,7 +493,7 @@
// Return Constant if previously defined.
if (Slot) return Slot;
- const PointerType *DestTy = VMContext.getPointerTypeUnqual(Type::Int8Ty);
+ const PointerType *DestTy = PointerType::getUnqual(Type::Int8Ty);
// If empty string then use a i8* null instead.
if (String.empty())
@@ -522,7 +522,7 @@
for (unsigned i = 0; i != NumTys; ++i)
Elts.push_back(getCastToEmpty(Tys[i]));
- Constant *Init = ConstantArray::get(VMContext.getArrayType(EmptyStructPtr,
+ Constant *Init = ConstantArray::get(ArrayType::get(EmptyStructPtr,
Elts.size()),
Elts.data(), Elts.size());
// If we already have this array, just return the uniqued version.
@@ -1075,7 +1075,7 @@
const Type *Ty = M->getTypeByName("llvm.dbg.global_variable.type");
if (!Ty) return 0;
- Ty = Context.getPointerType(Ty, 0);
+ Ty = PointerType::get(Ty, 0);
Value *Val = V->stripPointerCasts();
for (Value::use_iterator I = Val->use_begin(), E = Val->use_end();
diff --git a/lib/Analysis/LoopVR.cpp b/lib/Analysis/LoopVR.cpp
index ccd5400..8ffac63 100644
--- a/lib/Analysis/LoopVR.cpp
+++ b/lib/Analysis/LoopVR.cpp
@@ -75,8 +75,8 @@
ConstantRange X = getRange(Mul->getOperand(0), T, SE);
if (X.isFullSet()) return FullSet;
- const IntegerType *Ty = Context.getIntegerType(X.getBitWidth());
- const IntegerType *ExTy = Context.getIntegerType(X.getBitWidth() *
+ const IntegerType *Ty = IntegerType::get(X.getBitWidth());
+ const IntegerType *ExTy = IntegerType::get(X.getBitWidth() *
Mul->getNumOperands());
ConstantRange XExt = X.zeroExtend(ExTy->getBitWidth());
diff --git a/lib/Analysis/ScalarEvolution.cpp b/lib/Analysis/ScalarEvolution.cpp
index 3bf5e70..8c4d191 100644
--- a/lib/Analysis/ScalarEvolution.cpp
+++ b/lib/Analysis/ScalarEvolution.cpp
@@ -4670,7 +4670,7 @@
// Check Add for unsigned overflow.
// TODO: More sophisticated things could be done here.
- const Type *WideTy = getContext().getIntegerType(getTypeSizeInBits(Ty) + 1);
+ const Type *WideTy = IntegerType::get(getTypeSizeInBits(Ty) + 1);
const SCEV *EDiff = getZeroExtendExpr(Diff, WideTy);
const SCEV *ERoundUp = getZeroExtendExpr(RoundUp, WideTy);
const SCEV *OperandExtendedAdd = getAddExpr(EDiff, ERoundUp);
diff --git a/lib/AsmParser/LLLexer.cpp b/lib/AsmParser/LLLexer.cpp
index 4a7e123..a6e6344 100644
--- a/lib/AsmParser/LLLexer.cpp
+++ b/lib/AsmParser/LLLexer.cpp
@@ -471,7 +471,7 @@
Error("bitwidth for integer type out of range!");
return lltok::Error;
}
- TyVal = Context.getIntegerType(NumBits);
+ TyVal = IntegerType::get(NumBits);
return lltok::Type;
}
diff --git a/lib/AsmParser/LLParser.cpp b/lib/AsmParser/LLParser.cpp
index 8b3b832..359a733 100644
--- a/lib/AsmParser/LLParser.cpp
+++ b/lib/AsmParser/LLParser.cpp
@@ -1104,7 +1104,7 @@
break;
case lltok::kw_opaque:
// TypeRec ::= 'opaque'
- Result = Context.getOpaqueType();
+ Result = OpaqueType::get();
Lex.Lex();
break;
case lltok::lbrace:
@@ -1134,7 +1134,7 @@
if (const Type *T = M->getTypeByName(Lex.getStrVal())) {
Result = T;
} else {
- Result = Context.getOpaqueType();
+ Result = OpaqueType::get();
ForwardRefTypes.insert(std::make_pair(Lex.getStrVal(),
std::make_pair(Result,
Lex.getLoc())));
@@ -1153,7 +1153,7 @@
if (I != ForwardRefTypeIDs.end())
Result = I->second.first;
else {
- Result = Context.getOpaqueType();
+ Result = OpaqueType::get();
ForwardRefTypeIDs.insert(std::make_pair(Lex.getUIntVal(),
std::make_pair(Result,
Lex.getLoc())));
@@ -1166,7 +1166,7 @@
Lex.Lex();
unsigned Val;
if (ParseUInt32(Val)) return true;
- OpaqueType *OT = Context.getOpaqueType(); //Use temporary placeholder.
+ OpaqueType *OT = OpaqueType::get(); //Use temporary placeholder.
UpRefs.push_back(UpRefRecord(Lex.getLoc(), Val, OT));
Result = OT;
break;
@@ -1187,7 +1187,7 @@
return TokError("pointers to void are invalid; use i8* instead");
if (!PointerType::isValidElementType(Result.get()))
return TokError("pointer to this type is invalid");
- Result = HandleUpRefs(Context.getPointerTypeUnqual(Result.get()));
+ Result = HandleUpRefs(PointerType::getUnqual(Result.get()));
Lex.Lex();
break;
@@ -1204,7 +1204,7 @@
ParseToken(lltok::star, "expected '*' in address space"))
return true;
- Result = HandleUpRefs(Context.getPointerType(Result.get(), AddrSpace));
+ Result = HandleUpRefs(PointerType::get(Result.get(), AddrSpace));
break;
}
@@ -1365,7 +1365,7 @@
for (unsigned i = 0, e = ArgList.size(); i != e; ++i)
ArgListTy.push_back(ArgList[i].Type);
- Result = HandleUpRefs(Context.getFunctionType(Result.get(),
+ Result = HandleUpRefs(FunctionType::get(Result.get(),
ArgListTy, isVarArg));
return false;
}
@@ -1381,7 +1381,7 @@
Lex.Lex(); // Consume the '{'
if (EatIfPresent(lltok::rbrace)) {
- Result = Context.getStructType(Packed);
+ Result = StructType::get(Packed);
return false;
}
@@ -1413,7 +1413,7 @@
std::vector<const Type*> ParamsListTy;
for (unsigned i = 0, e = ParamsList.size(); i != e; ++i)
ParamsListTy.push_back(ParamsList[i].get());
- Result = HandleUpRefs(Context.getStructType(ParamsListTy, Packed));
+ Result = HandleUpRefs(StructType::get(ParamsListTy, Packed));
return false;
}
@@ -1452,11 +1452,11 @@
return Error(SizeLoc, "size too large for vector");
if (!VectorType::isValidElementType(EltTy))
return Error(TypeLoc, "vector element type must be fp or integer");
- Result = Context.getVectorType(EltTy, unsigned(Size));
+ Result = VectorType::get(EltTy, unsigned(Size));
} else {
if (!ArrayType::isValidElementType(EltTy))
return Error(TypeLoc, "invalid array element type");
- Result = HandleUpRefs(Context.getArrayType(EltTy, Size));
+ Result = HandleUpRefs(ArrayType::get(EltTy, Size));
}
return false;
}
@@ -1836,7 +1836,7 @@
return Error(FirstEltLoc, "invalid array element type: " +
Elts[0]->getType()->getDescription());
- ArrayType *ATy = Context.getArrayType(Elts[0]->getType(), Elts.size());
+ ArrayType *ATy = ArrayType::get(Elts[0]->getType(), Elts.size());
// Verify all elements are correct type!
for (unsigned i = 0, e = Elts.size(); i != e; ++i) {
@@ -2417,8 +2417,8 @@
return Error(RetTypeLoc, "functions with 'sret' argument must return void");
const FunctionType *FT =
- Context.getFunctionType(RetType, ParamTypeList, isVarArg);
- const PointerType *PFT = Context.getPointerTypeUnqual(FT);
+ FunctionType::get(RetType, ParamTypeList, isVarArg);
+ const PointerType *PFT = PointerType::getUnqual(FT);
Fn = 0;
if (!FunctionName.empty()) {
@@ -2902,8 +2902,8 @@
if (!FunctionType::isValidReturnType(RetType))
return Error(RetTypeLoc, "Invalid result type for LLVM function");
- Ty = Context.getFunctionType(RetType, ParamTypes, false);
- PFTy = Context.getPointerTypeUnqual(Ty);
+ Ty = FunctionType::get(RetType, ParamTypes, false);
+ PFTy = PointerType::getUnqual(Ty);
}
// Look up the callee.
@@ -3242,8 +3242,8 @@
if (!FunctionType::isValidReturnType(RetType))
return Error(RetTypeLoc, "Invalid result type for LLVM function");
- Ty = Context.getFunctionType(RetType, ParamTypes, false);
- PFTy = Context.getPointerTypeUnqual(Ty);
+ Ty = FunctionType::get(RetType, ParamTypes, false);
+ PFTy = PointerType::getUnqual(Ty);
}
// Look up the callee.
diff --git a/lib/Bitcode/Reader/BitcodeReader.cpp b/lib/Bitcode/Reader/BitcodeReader.cpp
index 2b22404..1e6f5b6 100644
--- a/lib/Bitcode/Reader/BitcodeReader.cpp
+++ b/lib/Bitcode/Reader/BitcodeReader.cpp
@@ -322,7 +322,7 @@
// The type table allows forward references. Push as many Opaque types as
// needed to get up to ID.
while (TypeList.size() <= ID)
- TypeList.push_back(Context.getOpaqueType());
+ TypeList.push_back(OpaqueType::get());
return TypeList.back().get();
}
@@ -512,7 +512,7 @@
if (Record.size() < 1)
return Error("Invalid Integer type record");
- ResultTy = Context.getIntegerType(Record[0]);
+ ResultTy = IntegerType::get(Record[0]);
break;
case bitc::TYPE_CODE_POINTER: { // POINTER: [pointee type] or
// [pointee type, address space]
@@ -521,7 +521,7 @@
unsigned AddressSpace = 0;
if (Record.size() == 2)
AddressSpace = Record[1];
- ResultTy = Context.getPointerType(getTypeByID(Record[0], true),
+ ResultTy = PointerType::get(getTypeByID(Record[0], true),
AddressSpace);
break;
}
@@ -534,7 +534,7 @@
for (unsigned i = 3, e = Record.size(); i != e; ++i)
ArgTys.push_back(getTypeByID(Record[i], true));
- ResultTy = Context.getFunctionType(getTypeByID(Record[2], true), ArgTys,
+ ResultTy = FunctionType::get(getTypeByID(Record[2], true), ArgTys,
Record[0]);
break;
}
@@ -544,24 +544,24 @@
std::vector<const Type*> EltTys;
for (unsigned i = 1, e = Record.size(); i != e; ++i)
EltTys.push_back(getTypeByID(Record[i], true));
- ResultTy = Context.getStructType(EltTys, Record[0]);
+ ResultTy = StructType::get(EltTys, Record[0]);
break;
}
case bitc::TYPE_CODE_ARRAY: // ARRAY: [numelts, eltty]
if (Record.size() < 2)
return Error("Invalid ARRAY type record");
- ResultTy = Context.getArrayType(getTypeByID(Record[1], true), Record[0]);
+ ResultTy = ArrayType::get(getTypeByID(Record[1], true), Record[0]);
break;
case bitc::TYPE_CODE_VECTOR: // VECTOR: [numelts, eltty]
if (Record.size() < 2)
return Error("Invalid VECTOR type record");
- ResultTy = Context.getVectorType(getTypeByID(Record[1], true), Record[0]);
+ ResultTy = VectorType::get(getTypeByID(Record[1], true), Record[0]);
break;
}
if (NumRecords == TypeList.size()) {
// If this is a new type slot, just append it.
- TypeList.push_back(ResultTy ? ResultTy : Context.getOpaqueType());
+ TypeList.push_back(ResultTy ? ResultTy : OpaqueType::get());
++NumRecords;
} else if (ResultTy == 0) {
// Otherwise, this was forward referenced, so an opaque type was created,
@@ -1046,7 +1046,7 @@
return Error("Invalid CE_SHUFFLEVEC record");
Constant *Op0 = ValueList.getConstantFwdRef(Record[0], OpTy);
Constant *Op1 = ValueList.getConstantFwdRef(Record[1], OpTy);
- const Type *ShufTy = Context.getVectorType(Type::Int32Ty,
+ const Type *ShufTy = VectorType::get(Type::Int32Ty,
OpTy->getNumElements());
Constant *Op2 = ValueList.getConstantFwdRef(Record[2], ShufTy);
V = ConstantExpr::getShuffleVector(Op0, Op1, Op2);
@@ -1059,7 +1059,7 @@
return Error("Invalid CE_SHUFVEC_EX record");
Constant *Op0 = ValueList.getConstantFwdRef(Record[1], OpTy);
Constant *Op1 = ValueList.getConstantFwdRef(Record[2], OpTy);
- const Type *ShufTy = Context.getVectorType(Type::Int32Ty,
+ const Type *ShufTy = VectorType::get(Type::Int32Ty,
RTy->getNumElements());
Constant *Op2 = ValueList.getConstantFwdRef(Record[3], ShufTy);
V = ConstantExpr::getShuffleVector(Op0, Op1, Op2);
@@ -1940,7 +1940,7 @@
Value *Val, *Ptr;
if (getValueTypePair(Record, OpNum, NextValueNo, Val) ||
getValue(Record, OpNum,
- Context.getPointerTypeUnqual(Val->getType()), Ptr)||
+ PointerType::getUnqual(Val->getType()), Ptr)||
OpNum+2 != Record.size())
return Error("Invalid STORE record");
diff --git a/lib/CodeGen/DwarfEHPrepare.cpp b/lib/CodeGen/DwarfEHPrepare.cpp
index 43760af..5bfb328 100644
--- a/lib/CodeGen/DwarfEHPrepare.cpp
+++ b/lib/CodeGen/DwarfEHPrepare.cpp
@@ -354,8 +354,7 @@
// Create the temporary if we didn't already.
if (!ExceptionValueVar) {
- ExceptionValueVar = new AllocaInst(
- BB->getContext().getPointerTypeUnqual(Type::Int8Ty),
+ ExceptionValueVar = new AllocaInst(PointerType::getUnqual(Type::Int8Ty),
"eh.value", F->begin()->begin());
++NumStackTempsIntroduced;
}
diff --git a/lib/CodeGen/SelectionDAG/DAGCombiner.cpp b/lib/CodeGen/SelectionDAG/DAGCombiner.cpp
index aacd9e8..0796f22 100644
--- a/lib/CodeGen/SelectionDAG/DAGCombiner.cpp
+++ b/lib/CodeGen/SelectionDAG/DAGCombiner.cpp
@@ -3664,7 +3664,7 @@
TLI.isConsecutiveLoad(LD2, LD1, LD1VT.getSizeInBits()/8, 1, MFI)) {
unsigned Align = LD1->getAlignment();
unsigned NewAlign = TLI.getTargetData()->
- getABITypeAlignment(VT.getTypeForMVT(*DAG.getContext()));
+ getABITypeAlignment(VT.getTypeForMVT());
if (NewAlign <= Align &&
(!LegalOperations || TLI.isOperationLegal(ISD::LOAD, VT)))
@@ -3722,7 +3722,7 @@
(!LegalOperations || TLI.isOperationLegal(ISD::LOAD, VT))) {
LoadSDNode *LN0 = cast<LoadSDNode>(N0);
unsigned Align = TLI.getTargetData()->
- getABITypeAlignment(VT.getTypeForMVT(*DAG.getContext()));
+ getABITypeAlignment(VT.getTypeForMVT());
unsigned OrigAlign = LN0->getAlignment();
if (Align <= OrigAlign) {
@@ -4993,8 +4993,7 @@
unsigned NewAlign = MinAlign(LD->getAlignment(), PtrOff);
if (NewAlign <
- TLI.getTargetData()->getABITypeAlignment(NewVT.getTypeForMVT(
- *DAG.getContext())))
+ TLI.getTargetData()->getABITypeAlignment(NewVT.getTypeForMVT()))
return SDValue();
SDValue NewPtr = DAG.getNode(ISD::ADD, LD->getDebugLoc(),
@@ -5049,7 +5048,7 @@
unsigned OrigAlign = ST->getAlignment();
MVT SVT = Value.getOperand(0).getValueType();
unsigned Align = TLI.getTargetData()->
- getABITypeAlignment(SVT.getTypeForMVT(*DAG.getContext()));
+ getABITypeAlignment(SVT.getTypeForMVT());
if (Align <= OrigAlign &&
((!LegalOperations && !ST->isVolatile()) ||
TLI.isOperationLegalOrCustom(ISD::STORE, SVT)))
@@ -5329,8 +5328,7 @@
// Check the resultant load doesn't need a higher alignment than the
// original load.
unsigned NewAlign =
- TLI.getTargetData()->getABITypeAlignment(LVT.getTypeForMVT(
- *DAG.getContext()));
+ TLI.getTargetData()->getABITypeAlignment(LVT.getTypeForMVT());
if (NewAlign > Align || !TLI.isOperationLegalOrCustom(ISD::LOAD, LVT))
return SDValue();
@@ -5812,8 +5810,7 @@
const TargetData &TD = *TLI.getTargetData();
// Create a ConstantArray of the two constants.
- Constant *CA = ConstantArray::get(
- DAG.getContext()->getArrayType(FPTy, 2), Elts, 2);
+ Constant *CA = ConstantArray::get(ArrayType::get(FPTy, 2), Elts, 2);
SDValue CPIdx = DAG.getConstantPool(CA, TLI.getPointerTy(),
TD.getPrefTypeAlignment(FPTy));
unsigned Alignment = cast<ConstantPoolSDNode>(CPIdx)->getAlignment();
diff --git a/lib/CodeGen/SelectionDAG/LegalizeDAG.cpp b/lib/CodeGen/SelectionDAG/LegalizeDAG.cpp
index e4b71b1..7293144 100644
--- a/lib/CodeGen/SelectionDAG/LegalizeDAG.cpp
+++ b/lib/CodeGen/SelectionDAG/LegalizeDAG.cpp
@@ -361,7 +361,7 @@
// smaller type.
TLI.isLoadExtLegal(ISD::EXTLOAD, SVT) &&
TLI.ShouldShrinkFPConstant(OrigVT)) {
- const Type *SType = SVT.getTypeForMVT(*DAG.getContext());
+ const Type *SType = SVT.getTypeForMVT();
LLVMC = cast<ConstantFP>(ConstantExpr::getFPTrunc(LLVMC, SType));
VT = SVT;
Extend = true;
@@ -1107,11 +1107,10 @@
// expand it.
if (!TLI.allowsUnalignedMemoryAccesses()) {
unsigned ABIAlignment = TLI.getTargetData()->
- getABITypeAlignment(LD->getMemoryVT().getTypeForMVT(
- *DAG.getContext()));
+ getABITypeAlignment(LD->getMemoryVT().getTypeForMVT());
if (LD->getAlignment() < ABIAlignment){
- Result = ExpandUnalignedLoad(cast<LoadSDNode>(Result.getNode()), DAG,
- TLI);
+ Result = ExpandUnalignedLoad(cast<LoadSDNode>(Result.getNode()),
+ DAG, TLI);
Tmp3 = Result.getOperand(0);
Tmp4 = Result.getOperand(1);
Tmp3 = LegalizeOp(Tmp3);
@@ -1291,11 +1290,10 @@
// expand it.
if (!TLI.allowsUnalignedMemoryAccesses()) {
unsigned ABIAlignment = TLI.getTargetData()->
- getABITypeAlignment(LD->getMemoryVT().getTypeForMVT(
- *DAG.getContext()));
+ getABITypeAlignment(LD->getMemoryVT().getTypeForMVT());
if (LD->getAlignment() < ABIAlignment){
- Result = ExpandUnalignedLoad(cast<LoadSDNode>(Result.getNode()), DAG,
- TLI);
+ Result = ExpandUnalignedLoad(cast<LoadSDNode>(Result.getNode()),
+ DAG, TLI);
Tmp1 = Result.getOperand(0);
Tmp2 = Result.getOperand(1);
Tmp1 = LegalizeOp(Tmp1);
@@ -1370,8 +1368,7 @@
// expand it.
if (!TLI.allowsUnalignedMemoryAccesses()) {
unsigned ABIAlignment = TLI.getTargetData()->
- getABITypeAlignment(ST->getMemoryVT().getTypeForMVT(
- *DAG.getContext()));
+ getABITypeAlignment(ST->getMemoryVT().getTypeForMVT());
if (ST->getAlignment() < ABIAlignment)
Result = ExpandUnalignedStore(cast<StoreSDNode>(Result.getNode()), DAG,
TLI);
@@ -1470,8 +1467,7 @@
// expand it.
if (!TLI.allowsUnalignedMemoryAccesses()) {
unsigned ABIAlignment = TLI.getTargetData()->
- getABITypeAlignment(ST->getMemoryVT().getTypeForMVT(
- *DAG.getContext()));
+ getABITypeAlignment(ST->getMemoryVT().getTypeForMVT());
if (ST->getAlignment() < ABIAlignment)
Result = ExpandUnalignedStore(cast<StoreSDNode>(Result.getNode()), DAG,
TLI);
@@ -1737,7 +1733,7 @@
// Create the stack frame object.
unsigned SrcAlign =
TLI.getTargetData()->getPrefTypeAlignment(SrcOp.getValueType().
- getTypeForMVT(*DAG.getContext()));
+ getTypeForMVT());
SDValue FIPtr = DAG.CreateStackTemporary(SlotVT, SrcAlign);
FrameIndexSDNode *StackPtrFI = cast<FrameIndexSDNode>(FIPtr);
@@ -1748,8 +1744,7 @@
unsigned SlotSize = SlotVT.getSizeInBits();
unsigned DestSize = DestVT.getSizeInBits();
unsigned DestAlign =
- TLI.getTargetData()->getPrefTypeAlignment(DestVT.getTypeForMVT(
- *DAG.getContext()));
+ TLI.getTargetData()->getPrefTypeAlignment(DestVT.getTypeForMVT());
// Emit a store to the stack slot. Use a truncstore if the input value is
// later than DestVT.
@@ -1844,7 +1839,7 @@
CV.push_back(const_cast<ConstantInt *>(V->getConstantIntValue()));
} else {
assert(Node->getOperand(i).getOpcode() == ISD::UNDEF);
- const Type *OpNTy = OpVT.getTypeForMVT(*DAG.getContext());
+ const Type *OpNTy = OpVT.getTypeForMVT();
CV.push_back(Context->getUndef(OpNTy));
}
}
@@ -1898,7 +1893,7 @@
TargetLowering::ArgListEntry Entry;
for (unsigned i = 0, e = Node->getNumOperands(); i != e; ++i) {
MVT ArgVT = Node->getOperand(i).getValueType();
- const Type *ArgTy = ArgVT.getTypeForMVT(*DAG.getContext());
+ const Type *ArgTy = ArgVT.getTypeForMVT();
Entry.Node = Node->getOperand(i); Entry.Ty = ArgTy;
Entry.isSExt = isSigned;
Entry.isZExt = !isSigned;
@@ -1908,7 +1903,7 @@
TLI.getPointerTy());
// Splice the libcall in wherever FindInputOutputChains tells us to.
- const Type *RetTy = Node->getValueType(0).getTypeForMVT(*DAG.getContext());
+ const Type *RetTy = Node->getValueType(0).getTypeForMVT();
std::pair<SDValue, SDValue> CallInfo =
TLI.LowerCallTo(InChain, RetTy, isSigned, !isSigned, false, false,
0, CallingConv::C, false, Callee, Args, DAG,
@@ -2397,8 +2392,7 @@
// Increment the pointer, VAList, to the next vaarg
Tmp3 = DAG.getNode(ISD::ADD, dl, TLI.getPointerTy(), VAList,
DAG.getConstant(TLI.getTargetData()->
- getTypeAllocSize(VT.getTypeForMVT(
- *DAG.getContext())),
+ getTypeAllocSize(VT.getTypeForMVT()),
TLI.getPointerTy()));
// Store the incremented VAList to the legalized pointer
Tmp3 = DAG.getStore(VAList.getValue(1), dl, Tmp3, Tmp2, V, 0);
diff --git a/lib/CodeGen/SelectionDAG/LegalizeTypes.cpp b/lib/CodeGen/SelectionDAG/LegalizeTypes.cpp
index 1f05e8d..c80b34d 100644
--- a/lib/CodeGen/SelectionDAG/LegalizeTypes.cpp
+++ b/lib/CodeGen/SelectionDAG/LegalizeTypes.cpp
@@ -1009,7 +1009,7 @@
TargetLowering::ArgListEntry Entry;
for (unsigned i = 0; i != NumOps; ++i) {
Entry.Node = Ops[i];
- Entry.Ty = Entry.Node.getValueType().getTypeForMVT(*DAG.getContext());
+ Entry.Ty = Entry.Node.getValueType().getTypeForMVT();
Entry.isSExt = isSigned;
Entry.isZExt = !isSigned;
Args.push_back(Entry);
@@ -1017,7 +1017,7 @@
SDValue Callee = DAG.getExternalSymbol(TLI.getLibcallName(LC),
TLI.getPointerTy());
- const Type *RetTy = RetVT.getTypeForMVT(*DAG.getContext());
+ const Type *RetTy = RetVT.getTypeForMVT();
std::pair<SDValue,SDValue> CallInfo =
TLI.LowerCallTo(DAG.getEntryNode(), RetTy, isSigned, !isSigned, false,
false, 0, CallingConv::C, false, Callee, Args, DAG, dl);
diff --git a/lib/CodeGen/SelectionDAG/LegalizeTypesGeneric.cpp b/lib/CodeGen/SelectionDAG/LegalizeTypesGeneric.cpp
index 49ea022..0803426 100644
--- a/lib/CodeGen/SelectionDAG/LegalizeTypesGeneric.cpp
+++ b/lib/CodeGen/SelectionDAG/LegalizeTypesGeneric.cpp
@@ -115,8 +115,7 @@
// Create the stack frame object. Make sure it is aligned for both
// the source and expanded destination types.
unsigned Alignment =
- TLI.getTargetData()->getPrefTypeAlignment(NOutVT.getTypeForMVT(
- *DAG.getContext()));
+ TLI.getTargetData()->getPrefTypeAlignment(NOutVT.getTypeForMVT());
SDValue StackPtr = DAG.CreateStackTemporary(InVT, Alignment);
int SPFI = cast<FrameIndexSDNode>(StackPtr.getNode())->getIndex();
const Value *SV = PseudoSourceValue::getFixedStack(SPFI);
diff --git a/lib/CodeGen/SelectionDAG/LegalizeVectorTypes.cpp b/lib/CodeGen/SelectionDAG/LegalizeVectorTypes.cpp
index fe26609..9ec0846 100644
--- a/lib/CodeGen/SelectionDAG/LegalizeVectorTypes.cpp
+++ b/lib/CodeGen/SelectionDAG/LegalizeVectorTypes.cpp
@@ -667,8 +667,7 @@
// so use a truncating store.
SDValue EltPtr = GetVectorElementPointer(StackPtr, EltVT, Idx);
unsigned Alignment =
- TLI.getTargetData()->getPrefTypeAlignment(VecVT.getTypeForMVT(
- *DAG.getContext()));
+ TLI.getTargetData()->getPrefTypeAlignment(VecVT.getTypeForMVT());
Store = DAG.getTruncStore(Store, dl, Elt, EltPtr, NULL, 0, EltVT);
// Load the Lo part from the stack slot.
diff --git a/lib/CodeGen/SelectionDAG/SelectionDAG.cpp b/lib/CodeGen/SelectionDAG/SelectionDAG.cpp
index a839824..eca726a 100644
--- a/lib/CodeGen/SelectionDAG/SelectionDAG.cpp
+++ b/lib/CodeGen/SelectionDAG/SelectionDAG.cpp
@@ -798,7 +798,7 @@
unsigned SelectionDAG::getMVTAlignment(MVT VT) const {
const Type *Ty = VT == MVT::iPTR ?
PointerType::get(Type::Int8Ty, 0) :
- VT.getTypeForMVT(*Context);
+ VT.getTypeForMVT();
return TLI.getTargetData()->getABITypeAlignment(Ty);
}
@@ -1389,7 +1389,7 @@
SDValue SelectionDAG::CreateStackTemporary(MVT VT, unsigned minAlign) {
MachineFrameInfo *FrameInfo = getMachineFunction().getFrameInfo();
unsigned ByteSize = VT.getStoreSizeInBits()/8;
- const Type *Ty = VT.getTypeForMVT(*Context);
+ const Type *Ty = VT.getTypeForMVT();
unsigned StackAlign =
std::max((unsigned)TLI.getTargetData()->getPrefTypeAlignment(Ty), minAlign);
@@ -1402,8 +1402,8 @@
SDValue SelectionDAG::CreateStackTemporary(MVT VT1, MVT VT2) {
unsigned Bytes = std::max(VT1.getStoreSizeInBits(),
VT2.getStoreSizeInBits())/8;
- const Type *Ty1 = VT1.getTypeForMVT(*Context);
- const Type *Ty2 = VT2.getTypeForMVT(*Context);
+ const Type *Ty1 = VT1.getTypeForMVT();
+ const Type *Ty2 = VT2.getTypeForMVT();
const TargetData *TD = TLI.getTargetData();
unsigned Align = std::max(TD->getPrefTypeAlignment(Ty1),
TD->getPrefTypeAlignment(Ty2));
@@ -3104,8 +3104,7 @@
MVT VT = TLI.getOptimalMemOpType(Size, Align, isSrcConst, isSrcStr, DAG);
if (VT != MVT::iAny) {
unsigned NewAlign = (unsigned)
- TLI.getTargetData()->getABITypeAlignment(VT.getTypeForMVT(
- *DAG.getContext()));
+ TLI.getTargetData()->getABITypeAlignment(VT.getTypeForMVT());
// If source is a string constant, this will require an unaligned load.
if (NewAlign > Align && (isSrcConst || AllowUnalign)) {
if (Dst.getOpcode() != ISD::FrameIndex) {
diff --git a/lib/CodeGen/SelectionDAG/SelectionDAGBuild.cpp b/lib/CodeGen/SelectionDAG/SelectionDAGBuild.cpp
index 7134938..0eda58a 100644
--- a/lib/CodeGen/SelectionDAG/SelectionDAGBuild.cpp
+++ b/lib/CodeGen/SelectionDAG/SelectionDAGBuild.cpp
@@ -5516,7 +5516,7 @@
for (unsigned Value = 0, NumValues = ValueVTs.size();
Value != NumValues; ++Value) {
MVT VT = ValueVTs[Value];
- const Type *ArgTy = VT.getTypeForMVT(*DAG.getContext());
+ const Type *ArgTy = VT.getTypeForMVT();
ISD::ArgFlagsTy Flags;
unsigned OriginalAlignment =
getTargetData()->getABITypeAlignment(ArgTy);
@@ -5647,7 +5647,7 @@
for (unsigned Value = 0, NumValues = ValueVTs.size();
Value != NumValues; ++Value) {
MVT VT = ValueVTs[Value];
- const Type *ArgTy = VT.getTypeForMVT(*DAG.getContext());
+ const Type *ArgTy = VT.getTypeForMVT();
SDValue Op = SDValue(Args[i].Node.getNode(),
Args[i].Node.getResNo() + Value);
ISD::ArgFlagsTy Flags;
diff --git a/lib/CodeGen/ShadowStackGC.cpp b/lib/CodeGen/ShadowStackGC.cpp
index 08d6720..b412532 100644
--- a/lib/CodeGen/ShadowStackGC.cpp
+++ b/lib/CodeGen/ShadowStackGC.cpp
@@ -188,8 +188,6 @@
Constant *ShadowStackGC::GetFrameMap(Function &F) {
// doInitialization creates the abstract type of this value.
- LLVMContext &Context = F.getContext();
-
Type *VoidPtr = PointerType::getUnqual(Type::Int8Ty);
// Truncate the ShadowStackDescriptor if some metadata is null.
@@ -209,7 +207,7 @@
Constant *DescriptorElts[] = {
ConstantStruct::get(BaseElts, 2),
- ConstantArray::get(Context.getArrayType(VoidPtr, NumMeta),
+ ConstantArray::get(ArrayType::get(VoidPtr, NumMeta),
Metadata.begin(), NumMeta)
};
diff --git a/lib/ExecutionEngine/JIT/JIT.cpp b/lib/ExecutionEngine/JIT/JIT.cpp
index 9f60954..b932c8c 100644
--- a/lib/ExecutionEngine/JIT/JIT.cpp
+++ b/lib/ExecutionEngine/JIT/JIT.cpp
@@ -368,7 +368,6 @@
GenericValue JIT::runFunction(Function *F,
const std::vector<GenericValue> &ArgValues) {
assert(F && "Function *F was null at entry to run()");
- LLVMContext &Context = F->getContext();
void *FPtr = getPointerToFunction(F);
assert(FPtr && "Pointer to fn's code was null after getPointerToFunction");
@@ -470,7 +469,7 @@
// arguments. Make this function and return.
// First, create the function.
- FunctionType *STy=Context.getFunctionType(RetTy, false);
+ FunctionType *STy=FunctionType::get(RetTy, false);
Function *Stub = Function::Create(STy, Function::InternalLinkage, "",
F->getParent());
diff --git a/lib/Linker/LinkModules.cpp b/lib/Linker/LinkModules.cpp
index 75da6bf..4d9b061 100644
--- a/lib/Linker/LinkModules.cpp
+++ b/lib/Linker/LinkModules.cpp
@@ -1148,7 +1148,7 @@
"Appending variables with different section name need to be linked!");
unsigned NewSize = T1->getNumElements() + T2->getNumElements();
- ArrayType *NewType = Context.getArrayType(T1->getElementType(),
+ ArrayType *NewType = ArrayType::get(T1->getElementType(),
NewSize);
G1->setName(""); // Clear G1's name in case of a conflict!
diff --git a/lib/Target/CellSPU/SPUISelLowering.cpp b/lib/Target/CellSPU/SPUISelLowering.cpp
index 50ba00f..ce7ba72 100644
--- a/lib/Target/CellSPU/SPUISelLowering.cpp
+++ b/lib/Target/CellSPU/SPUISelLowering.cpp
@@ -101,7 +101,7 @@
TargetLowering::ArgListEntry Entry;
for (unsigned i = 0, e = Op.getNumOperands(); i != e; ++i) {
MVT ArgVT = Op.getOperand(i).getValueType();
- const Type *ArgTy = ArgVT.getTypeForMVT(*DAG.getContext());
+ const Type *ArgTy = ArgVT.getTypeForMVT();
Entry.Node = Op.getOperand(i);
Entry.Ty = ArgTy;
Entry.isSExt = isSigned;
@@ -112,8 +112,7 @@
TLI.getPointerTy());
// Splice the libcall in wherever FindInputOutputChains tells us to.
- const Type *RetTy =
- Op.getNode()->getValueType(0).getTypeForMVT(*DAG.getContext());
+ const Type *RetTy = Op.getNode()->getValueType(0).getTypeForMVT();
std::pair<SDValue, SDValue> CallInfo =
TLI.LowerCallTo(InChain, RetTy, isSigned, !isSigned, false, false,
0, CallingConv::C, false, Callee, Args, DAG,
diff --git a/lib/Target/PIC16/PIC16ISelLowering.cpp b/lib/Target/PIC16/PIC16ISelLowering.cpp
index f194dc8..7dc96d1 100644
--- a/lib/Target/PIC16/PIC16ISelLowering.cpp
+++ b/lib/Target/PIC16/PIC16ISelLowering.cpp
@@ -372,14 +372,14 @@
TargetLowering::ArgListEntry Entry;
for (unsigned i = 0; i != NumOps; ++i) {
Entry.Node = Ops[i];
- Entry.Ty = Entry.Node.getValueType().getTypeForMVT(*DAG.getContext());
+ Entry.Ty = Entry.Node.getValueType().getTypeForMVT();
Entry.isSExt = isSigned;
Entry.isZExt = !isSigned;
Args.push_back(Entry);
}
SDValue Callee = DAG.getExternalSymbol(getPIC16LibcallName(Call), MVT::i8);
- const Type *RetTy = RetVT.getTypeForMVT(*DAG.getContext());
+ const Type *RetTy = RetVT.getTypeForMVT();
std::pair<SDValue,SDValue> CallInfo =
LowerCallTo(DAG.getEntryNode(), RetTy, isSigned, !isSigned, false,
false, 0, CallingConv::C, false, Callee, Args, DAG, dl);
diff --git a/lib/Target/PowerPC/PPCISelLowering.cpp b/lib/Target/PowerPC/PPCISelLowering.cpp
index df71838..bfe0f6f 100644
--- a/lib/Target/PowerPC/PPCISelLowering.cpp
+++ b/lib/Target/PowerPC/PPCISelLowering.cpp
@@ -1291,7 +1291,7 @@
// Lower to a call to __trampoline_setup(Trmp, TrampSize, FPtr, ctx_reg)
std::pair<SDValue, SDValue> CallResult =
- LowerCallTo(Chain, Op.getValueType().getTypeForMVT(*DAG.getContext()),
+ LowerCallTo(Chain, Op.getValueType().getTypeForMVT(),
false, false, false, false, 0, CallingConv::C, false,
DAG.getExternalSymbol("__trampoline_setup", PtrVT),
Args, DAG, dl);
diff --git a/lib/Target/XCore/XCoreISelLowering.cpp b/lib/Target/XCore/XCoreISelLowering.cpp
index eaab849..7873463 100644
--- a/lib/Target/XCore/XCoreISelLowering.cpp
+++ b/lib/Target/XCore/XCoreISelLowering.cpp
@@ -380,7 +380,7 @@
return SDValue();
}
unsigned ABIAlignment = getTargetData()->
- getABITypeAlignment(LD->getMemoryVT().getTypeForMVT(*DAG.getContext()));
+ getABITypeAlignment(LD->getMemoryVT().getTypeForMVT());
// Leave aligned load alone.
if (LD->getAlignment() >= ABIAlignment) {
return SDValue();
@@ -475,7 +475,7 @@
return SDValue();
}
unsigned ABIAlignment = getTargetData()->
- getABITypeAlignment(ST->getMemoryVT().getTypeForMVT(*DAG.getContext()));
+ getABITypeAlignment(ST->getMemoryVT().getTypeForMVT());
// Leave aligned store alone.
if (ST->getAlignment() >= ABIAlignment) {
return SDValue();
@@ -1077,7 +1077,7 @@
break;
}
unsigned ABIAlignment = getTargetData()->
- getABITypeAlignment(ST->getMemoryVT().getTypeForMVT(*DAG.getContext()));
+ getABITypeAlignment(ST->getMemoryVT().getTypeForMVT());
unsigned Alignment = ST->getAlignment();
if (Alignment >= ABIAlignment) {
break;
diff --git a/lib/Transforms/IPO/ArgumentPromotion.cpp b/lib/Transforms/IPO/ArgumentPromotion.cpp
index cb5787b..5cf3a9b 100644
--- a/lib/Transforms/IPO/ArgumentPromotion.cpp
+++ b/lib/Transforms/IPO/ArgumentPromotion.cpp
@@ -588,7 +588,7 @@
}
// Construct the new function type using the new arguments.
- FunctionType *NFTy = Context.getFunctionType(RetTy, Params, FTy->isVarArg());
+ FunctionType *NFTy = FunctionType::get(RetTy, Params, FTy->isVarArg());
// Create the new function body and insert it into the module...
Function *NF = Function::Create(NFTy, F->getLinkage(), F->getName());
diff --git a/lib/Transforms/IPO/DeadArgumentElimination.cpp b/lib/Transforms/IPO/DeadArgumentElimination.cpp
index 6321048..0b7e9d9 100644
--- a/lib/Transforms/IPO/DeadArgumentElimination.cpp
+++ b/lib/Transforms/IPO/DeadArgumentElimination.cpp
@@ -197,10 +197,9 @@
// Start by computing a new prototype for the function, which is the same as
// the old function, but doesn't have isVarArg set.
const FunctionType *FTy = Fn.getFunctionType();
- LLVMContext &Context = FTy->getContext();
std::vector<const Type*> Params(FTy->param_begin(), FTy->param_end());
- FunctionType *NFTy = Context.getFunctionType(FTy->getReturnType(),
+ FunctionType *NFTy = FunctionType::get(FTy->getReturnType(),
Params, false);
unsigned NumArgs = Params.size();
@@ -641,7 +640,7 @@
// something and {} into void.
// Make the new struct packed if we used to return a packed struct
// already.
- NRetTy = Context.getStructType(RetTypes, STy->isPacked());
+ NRetTy = StructType::get(RetTypes, STy->isPacked());
else if (RetTypes.size() == 1)
// One return type? Just a simple value then, but only if we didn't use to
// return a struct with that simple value before.
@@ -709,7 +708,7 @@
}
// Create the new function type based on the recomputed parameters.
- FunctionType *NFTy = Context.getFunctionType(NRetTy, Params,
+ FunctionType *NFTy = FunctionType::get(NRetTy, Params,
FTy->isVarArg());
// No change?
diff --git a/lib/Transforms/IPO/ExtractGV.cpp b/lib/Transforms/IPO/ExtractGV.cpp
index 9c28fdb..dfbad61 100644
--- a/lib/Transforms/IPO/ExtractGV.cpp
+++ b/lib/Transforms/IPO/ExtractGV.cpp
@@ -103,13 +103,13 @@
// by putting them in the used array
{
std::vector<Constant *> AUGs;
- const Type *SBP= Context.getPointerTypeUnqual(Type::Int8Ty);
+ const Type *SBP= PointerType::getUnqual(Type::Int8Ty);
for (std::vector<GlobalValue*>::iterator GI = Named.begin(),
GE = Named.end(); GI != GE; ++GI) {
(*GI)->setLinkage(GlobalValue::ExternalLinkage);
AUGs.push_back(ConstantExpr::getBitCast(*GI, SBP));
}
- ArrayType *AT = Context.getArrayType(SBP, AUGs.size());
+ ArrayType *AT = ArrayType::get(SBP, AUGs.size());
Constant *Init = ConstantArray::get(AT, AUGs);
GlobalValue *gv = new GlobalVariable(M, AT, false,
GlobalValue::AppendingLinkage,
diff --git a/lib/Transforms/IPO/GlobalOpt.cpp b/lib/Transforms/IPO/GlobalOpt.cpp
index 5be3239..61e4316 100644
--- a/lib/Transforms/IPO/GlobalOpt.cpp
+++ b/lib/Transforms/IPO/GlobalOpt.cpp
@@ -826,7 +826,7 @@
if (NElements->getZExtValue() != 1) {
// If we have an array allocation, transform it to a single element
// allocation to make the code below simpler.
- Type *NewTy = Context.getArrayType(MI->getAllocatedType(),
+ Type *NewTy = ArrayType::get(MI->getAllocatedType(),
NElements->getZExtValue());
MallocInst *NewMI =
new MallocInst(NewTy, Context.getNullValue(Type::Int32Ty),
@@ -1161,7 +1161,7 @@
cast<StructType>(cast<PointerType>(PN->getType())->getElementType());
Result =
- PHINode::Create(Context.getPointerTypeUnqual(ST->getElementType(FieldNo)),
+ PHINode::Create(PointerType::getUnqual(ST->getElementType(FieldNo)),
PN->getName()+".f"+utostr(FieldNo), PN);
PHIsToRewrite.push_back(std::make_pair(PN, FieldNo));
} else {
@@ -1282,7 +1282,7 @@
for (unsigned FieldNo = 0, e = STy->getNumElements(); FieldNo != e;++FieldNo){
const Type *FieldTy = STy->getElementType(FieldNo);
- const Type *PFieldTy = Context.getPointerTypeUnqual(FieldTy);
+ const Type *PFieldTy = PointerType::getUnqual(FieldTy);
GlobalVariable *NGV =
new GlobalVariable(*GV->getParent(),
@@ -1957,8 +1957,8 @@
if (Ctors[i]) {
CSVals[1] = Ctors[i];
} else {
- const Type *FTy = Context.getFunctionType(Type::VoidTy, false);
- const PointerType *PFTy = Context.getPointerTypeUnqual(FTy);
+ const Type *FTy = FunctionType::get(Type::VoidTy, false);
+ const PointerType *PFTy = PointerType::getUnqual(FTy);
CSVals[1] = Context.getNullValue(PFTy);
CSVals[0] = ConstantInt::get(Type::Int32Ty, 2147483647);
}
diff --git a/lib/Transforms/IPO/LowerSetJmp.cpp b/lib/Transforms/IPO/LowerSetJmp.cpp
index 980123a..d2837a3 100644
--- a/lib/Transforms/IPO/LowerSetJmp.cpp
+++ b/lib/Transforms/IPO/LowerSetJmp.cpp
@@ -201,9 +201,8 @@
// This function is always successful, unless it isn't.
bool LowerSetJmp::doInitialization(Module& M)
{
- LLVMContext &Context = M.getContext();
- const Type *SBPTy = Context.getPointerTypeUnqual(Type::Int8Ty);
- const Type *SBPPTy = Context.getPointerTypeUnqual(SBPTy);
+ const Type *SBPTy = PointerType::getUnqual(Type::Int8Ty);
+ const Type *SBPPTy = PointerType::getUnqual(SBPTy);
// N.B. See llvm/runtime/GCCLibraries/libexception/SJLJ-Exception.h for
// a description of the following library functions.
@@ -259,7 +258,7 @@
// throwing the exception for us.
void LowerSetJmp::TransformLongJmpCall(CallInst* Inst)
{
- const Type* SBPTy = Inst->getContext().getPointerTypeUnqual(Type::Int8Ty);
+ const Type* SBPTy = PointerType::getUnqual(Type::Int8Ty);
// Create the call to "__llvm_sjljeh_throw_longjmp". This takes the
// same parameters as "longjmp", except that the buffer is cast to a
@@ -312,7 +311,7 @@
assert(Inst && "Couldn't find even ONE instruction in entry block!");
// Fill in the alloca and call to initialize the SJ map.
- const Type *SBPTy = Func->getContext().getPointerTypeUnqual(Type::Int8Ty);
+ const Type *SBPTy = PointerType::getUnqual(Type::Int8Ty);
AllocaInst* Map = new AllocaInst(SBPTy, 0, "SJMap", Inst);
CallInst::Create(InitSJMap, Map, "", Inst);
return SJMap[Func] = Map;
@@ -378,7 +377,7 @@
Function* Func = ABlock->getParent();
// Add this setjmp to the setjmp map.
- const Type* SBPTy = Inst->getContext().getPointerTypeUnqual(Type::Int8Ty);
+ const Type* SBPTy = PointerType::getUnqual(Type::Int8Ty);
CastInst* BufPtr =
new BitCastInst(Inst->getOperand(1), SBPTy, "SBJmpBuf", Inst);
std::vector<Value*> Args =
diff --git a/lib/Transforms/IPO/RaiseAllocations.cpp b/lib/Transforms/IPO/RaiseAllocations.cpp
index 3c9178e..943d3cf 100644
--- a/lib/Transforms/IPO/RaiseAllocations.cpp
+++ b/lib/Transforms/IPO/RaiseAllocations.cpp
@@ -70,8 +70,6 @@
// function into the appropriate instruction.
//
void RaiseAllocations::doInitialization(Module &M) {
- LLVMContext &Context = M.getContext();
-
// Get Malloc and free prototypes if they exist!
MallocFunc = M.getFunction("malloc");
if (MallocFunc) {
@@ -79,7 +77,7 @@
// Get the expected prototype for malloc
const FunctionType *Malloc1Type =
- Context.getFunctionType(Context.getPointerTypeUnqual(Type::Int8Ty),
+ FunctionType::get(PointerType::getUnqual(Type::Int8Ty),
std::vector<const Type*>(1, Type::Int64Ty), false);
// Chck to see if we got the expected malloc
@@ -87,14 +85,14 @@
// Check to see if the prototype is wrong, giving us i8*(i32) * malloc
// This handles the common declaration of: 'void *malloc(unsigned);'
const FunctionType *Malloc2Type =
- Context.getFunctionType(Context.getPointerTypeUnqual(Type::Int8Ty),
+ FunctionType::get(PointerType::getUnqual(Type::Int8Ty),
std::vector<const Type*>(1, Type::Int32Ty), false);
if (TyWeHave != Malloc2Type) {
// Check to see if the prototype is missing, giving us
// i8*(...) * malloc
// This handles the common declaration of: 'void *malloc();'
const FunctionType *Malloc3Type =
- Context.getFunctionType(Context.getPointerTypeUnqual(Type::Int8Ty),
+ FunctionType::get(PointerType::getUnqual(Type::Int8Ty),
true);
if (TyWeHave != Malloc3Type)
// Give up
@@ -108,21 +106,21 @@
const FunctionType* TyWeHave = FreeFunc->getFunctionType();
// Get the expected prototype for void free(i8*)
- const FunctionType *Free1Type = Context.getFunctionType(Type::VoidTy,
- std::vector<const Type*>(1, Context.getPointerTypeUnqual(Type::Int8Ty)),
+ const FunctionType *Free1Type = FunctionType::get(Type::VoidTy,
+ std::vector<const Type*>(1, PointerType::getUnqual(Type::Int8Ty)),
false);
if (TyWeHave != Free1Type) {
// Check to see if the prototype was forgotten, giving us
// void (...) * free
// This handles the common forward declaration of: 'void free();'
- const FunctionType* Free2Type = Context.getFunctionType(Type::VoidTy,
+ const FunctionType* Free2Type = FunctionType::get(Type::VoidTy,
true);
if (TyWeHave != Free2Type) {
// One last try, check to see if we can find free as
// int (...)* free. This handles the case where NOTHING was declared.
- const FunctionType* Free3Type = Context.getFunctionType(Type::Int32Ty,
+ const FunctionType* Free3Type = FunctionType::get(Type::Int32Ty,
true);
if (TyWeHave != Free3Type) {
@@ -224,7 +222,7 @@
Value *Source = *CS.arg_begin();
if (!isa<PointerType>(Source->getType()))
Source = new IntToPtrInst(Source,
- Context.getPointerTypeUnqual(Type::Int8Ty),
+ PointerType::getUnqual(Type::Int8Ty),
"FreePtrCast", I);
new FreeInst(Source, I);
diff --git a/lib/Transforms/IPO/StructRetPromotion.cpp b/lib/Transforms/IPO/StructRetPromotion.cpp
index 8d6671d..a241359 100644
--- a/lib/Transforms/IPO/StructRetPromotion.cpp
+++ b/lib/Transforms/IPO/StructRetPromotion.cpp
@@ -232,8 +232,7 @@
AttributesVec.push_back(AttributeWithIndex::get(~0, attrs));
- FunctionType *NFTy =
- F->getContext().getFunctionType(STy, Params, FTy->isVarArg());
+ FunctionType *NFTy = FunctionType::get(STy, Params, FTy->isVarArg());
Function *NF = Function::Create(NFTy, F->getLinkage());
NF->takeName(F);
NF->copyAttributesFrom(F);
diff --git a/lib/Transforms/Instrumentation/BlockProfiling.cpp b/lib/Transforms/Instrumentation/BlockProfiling.cpp
index 065bd11..700260d 100644
--- a/lib/Transforms/Instrumentation/BlockProfiling.cpp
+++ b/lib/Transforms/Instrumentation/BlockProfiling.cpp
@@ -63,7 +63,7 @@
if (!I->isDeclaration())
++NumFunctions;
- const Type *ATy = M.getContext().getArrayType(Type::Int32Ty, NumFunctions);
+ const Type *ATy = ArrayType::get(Type::Int32Ty, NumFunctions);
GlobalVariable *Counters =
new GlobalVariable(M, ATy, false, GlobalValue::InternalLinkage,
M.getContext().getNullValue(ATy), "FuncProfCounters");
@@ -108,7 +108,7 @@
for (Module::iterator I = M.begin(), E = M.end(); I != E; ++I)
NumBlocks += I->size();
- const Type *ATy = M.getContext().getArrayType(Type::Int32Ty, NumBlocks);
+ const Type *ATy = ArrayType::get(Type::Int32Ty, NumBlocks);
GlobalVariable *Counters =
new GlobalVariable(M, ATy, false, GlobalValue::InternalLinkage,
M.getContext().getNullValue(ATy), "BlockProfCounters");
diff --git a/lib/Transforms/Instrumentation/EdgeProfiling.cpp b/lib/Transforms/Instrumentation/EdgeProfiling.cpp
index d1aa370..b900945 100644
--- a/lib/Transforms/Instrumentation/EdgeProfiling.cpp
+++ b/lib/Transforms/Instrumentation/EdgeProfiling.cpp
@@ -64,7 +64,7 @@
NumEdges += BB->getTerminator()->getNumSuccessors();
}
- const Type *ATy = M.getContext().getArrayType(Type::Int32Ty, NumEdges);
+ const Type *ATy = ArrayType::get(Type::Int32Ty, NumEdges);
GlobalVariable *Counters =
new GlobalVariable(M, ATy, false, GlobalValue::InternalLinkage,
M.getContext().getNullValue(ATy), "EdgeProfCounters");
diff --git a/lib/Transforms/Instrumentation/ProfilingUtils.cpp b/lib/Transforms/Instrumentation/ProfilingUtils.cpp
index 70ce86a..d5752b7 100644
--- a/lib/Transforms/Instrumentation/ProfilingUtils.cpp
+++ b/lib/Transforms/Instrumentation/ProfilingUtils.cpp
@@ -25,8 +25,8 @@
GlobalValue *Array) {
LLVMContext &Context = MainFn->getContext();
const Type *ArgVTy =
- Context.getPointerTypeUnqual(Context.getPointerTypeUnqual(Type::Int8Ty));
- const PointerType *UIntPtr = Context.getPointerTypeUnqual(Type::Int32Ty);
+ PointerType::getUnqual(PointerType::getUnqual(Type::Int8Ty));
+ const PointerType *UIntPtr = PointerType::getUnqual(Type::Int32Ty);
Module &M = *MainFn->getParent();
Constant *InitFn = M.getOrInsertFunction(FnName, Type::Int32Ty, Type::Int32Ty,
ArgVTy, UIntPtr, Type::Int32Ty,
diff --git a/lib/Transforms/Scalar/InstructionCombining.cpp b/lib/Transforms/Scalar/InstructionCombining.cpp
index 63dddae..554591a 100644
--- a/lib/Transforms/Scalar/InstructionCombining.cpp
+++ b/lib/Transforms/Scalar/InstructionCombining.cpp
@@ -7681,7 +7681,7 @@
case 32 :
case 64 :
case 128:
- SExtType = Context->getIntegerType(Ty->getBitWidth() - ShiftAmt1);
+ SExtType = IntegerType::get(Ty->getBitWidth() - ShiftAmt1);
break;
default: break;
}
@@ -9697,7 +9697,7 @@
// Use an integer load+store unless we can find something better.
Type *NewPtrTy =
- Context->getPointerTypeUnqual(Context->getIntegerType(Size<<3));
+ PointerType::getUnqual(IntegerType::get(Size<<3));
// Memcpy forces the use of i8* for the source and destination. That means
// that if you're using memcpy to move one double around, you'll get a cast
@@ -9726,7 +9726,7 @@
}
if (SrcETy->isSingleValueType())
- NewPtrTy = Context->getPointerTypeUnqual(SrcETy);
+ NewPtrTy = PointerType::getUnqual(SrcETy);
}
}
@@ -9768,10 +9768,10 @@
// memset(s,c,n) -> store s, c (for n=1,2,4,8)
if (Len <= 8 && isPowerOf2_32((uint32_t)Len)) {
- const Type *ITy = Context->getIntegerType(Len*8); // n=1 -> i8.
+ const Type *ITy = IntegerType::get(Len*8); // n=1 -> i8.
Value *Dest = MI->getDest();
- Dest = InsertBitCastBefore(Dest, Context->getPointerTypeUnqual(ITy), *MI);
+ Dest = InsertBitCastBefore(Dest, PointerType::getUnqual(ITy), *MI);
// Alignment 0 is identity for alignment 1 for memset, but not store.
if (Alignment == 0) Alignment = 1;
@@ -9875,7 +9875,7 @@
// Turn X86 loadups -> load if the pointer is known aligned.
if (GetOrEnforceKnownAlignment(II->getOperand(1), 16) >= 16) {
Value *Ptr = InsertBitCastBefore(II->getOperand(1),
- Context->getPointerTypeUnqual(II->getType()),
+ PointerType::getUnqual(II->getType()),
CI);
return new LoadInst(Ptr);
}
@@ -9885,7 +9885,7 @@
// Turn stvx -> store if the pointer is known aligned.
if (GetOrEnforceKnownAlignment(II->getOperand(2), 16) >= 16) {
const Type *OpPtrTy =
- Context->getPointerTypeUnqual(II->getOperand(1)->getType());
+ PointerType::getUnqual(II->getOperand(1)->getType());
Value *Ptr = InsertBitCastBefore(II->getOperand(2), OpPtrTy, CI);
return new StoreInst(II->getOperand(1), Ptr);
}
@@ -9896,7 +9896,7 @@
// Turn X86 storeu -> store if the pointer is known aligned.
if (GetOrEnforceKnownAlignment(II->getOperand(1), 16) >= 16) {
const Type *OpPtrTy =
- Context->getPointerTypeUnqual(II->getOperand(2)->getType());
+ PointerType::getUnqual(II->getOperand(2)->getType());
Value *Ptr = InsertBitCastBefore(II->getOperand(1), OpPtrTy, CI);
return new StoreInst(II->getOperand(2), Ptr);
}
@@ -10062,7 +10062,7 @@
// If the call and callee calling conventions don't match, this call must
// be unreachable, as the call is undefined.
new StoreInst(Context->getTrue(),
- Context->getUndef(Context->getPointerTypeUnqual(Type::Int1Ty)),
+ Context->getUndef(PointerType::getUnqual(Type::Int1Ty)),
OldCall);
if (!OldCall->use_empty())
OldCall->replaceAllUsesWith(Context->getUndef(OldCall->getType()));
@@ -10076,7 +10076,7 @@
// undef so that we know that this code is not reachable, despite the fact
// that we can't modify the CFG here.
new StoreInst(Context->getTrue(),
- Context->getUndef(Context->getPointerTypeUnqual(Type::Int1Ty)),
+ Context->getUndef(PointerType::getUnqual(Type::Int1Ty)),
CS.getInstruction());
if (!CS.getInstruction()->use_empty())
@@ -10457,13 +10457,12 @@
// Replace the trampoline call with a direct call. Let the generic
// code sort out any function type mismatches.
- FunctionType *NewFTy =
- Context->getFunctionType(FTy->getReturnType(), NewTypes,
+ FunctionType *NewFTy = FunctionType::get(FTy->getReturnType(), NewTypes,
FTy->isVarArg());
Constant *NewCallee =
- NestF->getType() == Context->getPointerTypeUnqual(NewFTy) ?
+ NestF->getType() == PointerType::getUnqual(NewFTy) ?
NestF : ConstantExpr::getBitCast(NestF,
- Context->getPointerTypeUnqual(NewFTy));
+ PointerType::getUnqual(NewFTy));
const AttrListPtr &NewPAL = AttrListPtr::get(NewAttrs.begin(),
NewAttrs.end());
@@ -11367,7 +11366,7 @@
if (AI.isArrayAllocation()) { // Check C != 1
if (const ConstantInt *C = dyn_cast<ConstantInt>(AI.getArraySize())) {
const Type *NewTy =
- Context->getArrayType(AI.getAllocatedType(), C->getZExtValue());
+ ArrayType::get(AI.getAllocatedType(), C->getZExtValue());
AllocationInst *New = 0;
// Create and insert the replacement instruction...
@@ -11427,7 +11426,7 @@
if (isa<UndefValue>(Op)) {
// Insert a new store to null because we cannot modify the CFG here.
new StoreInst(Context->getTrue(),
- Context->getUndef(Context->getPointerTypeUnqual(Type::Int1Ty)), &FI);
+ Context->getUndef(PointerType::getUnqual(Type::Int1Ty)), &FI);
return EraseInstFromFunction(FI);
}
@@ -11734,7 +11733,7 @@
}
}
- SrcTy = Context->getPointerType(SrcPTy, SrcTy->getAddressSpace());
+ SrcTy = PointerType::get(SrcPTy, SrcTy->getAddressSpace());
}
if (!SrcPTy->isInteger() && !isa<PointerType>(SrcPTy))
@@ -12456,7 +12455,7 @@
unsigned AS =
cast<PointerType>(I->getOperand(0)->getType())->getAddressSpace();
Value *Ptr = InsertBitCastBefore(I->getOperand(0),
- Context->getPointerType(EI.getType(), AS),EI);
+ PointerType::get(EI.getType(), AS),EI);
GetElementPtrInst *GEP =
GetElementPtrInst::Create(Ptr, EI.getOperand(1), I->getName()+".gep");
cast<GEPOperator>(GEP)->setIsInBounds(true);
diff --git a/lib/Transforms/Scalar/LoopStrengthReduce.cpp b/lib/Transforms/Scalar/LoopStrengthReduce.cpp
index 9fd0fdf..619e1f1 100644
--- a/lib/Transforms/Scalar/LoopStrengthReduce.cpp
+++ b/lib/Transforms/Scalar/LoopStrengthReduce.cpp
@@ -1947,7 +1947,7 @@
NewCmpTy = NewCmpLHS->getType();
NewTyBits = SE->getTypeSizeInBits(NewCmpTy);
- const Type *NewCmpIntTy = Context.getIntegerType(NewTyBits);
+ const Type *NewCmpIntTy = IntegerType::get(NewTyBits);
if (RequiresTypeConversion(NewCmpTy, CmpTy)) {
// Check if it is possible to rewrite it using
// an iv / stride of a smaller integer type.
diff --git a/lib/Transforms/Scalar/MemCpyOptimizer.cpp b/lib/Transforms/Scalar/MemCpyOptimizer.cpp
index afbed37..224a136 100644
--- a/lib/Transforms/Scalar/MemCpyOptimizer.cpp
+++ b/lib/Transforms/Scalar/MemCpyOptimizer.cpp
@@ -352,7 +352,6 @@
TargetData &TD = getAnalysis<TargetData>();
AliasAnalysis &AA = getAnalysis<AliasAnalysis>();
- LLVMContext &Context = SI->getContext();
Module *M = SI->getParent()->getParent()->getParent();
// Okay, so we now have a single store that can be splatable. Scan to find
@@ -441,7 +440,7 @@
StartPtr = Range.StartPtr;
// Cast the start ptr to be i8* as memset requires.
- const Type *i8Ptr = Context.getPointerTypeUnqual(Type::Int8Ty);
+ const Type *i8Ptr = PointerType::getUnqual(Type::Int8Ty);
if (StartPtr->getType() != i8Ptr)
StartPtr = new BitCastInst(StartPtr, i8Ptr, StartPtr->getName(),
InsertPt);
diff --git a/lib/Transforms/Scalar/ScalarReplAggregates.cpp b/lib/Transforms/Scalar/ScalarReplAggregates.cpp
index 7ca2c5e..73dd23c 100644
--- a/lib/Transforms/Scalar/ScalarReplAggregates.cpp
+++ b/lib/Transforms/Scalar/ScalarReplAggregates.cpp
@@ -307,7 +307,7 @@
DOUT << "CONVERT TO SCALAR INTEGER: " << *AI << "\n";
// Create and insert the integer alloca.
- const Type *NewTy = F.getContext().getIntegerType(AllocaSize*8);
+ const Type *NewTy = IntegerType::get(AllocaSize*8);
NewAI = new AllocaInst(NewTy, 0, "", AI->getParent()->begin());
ConvertUsesToScalar(AI, NewAI, 0);
}
@@ -900,7 +900,6 @@
SmallVector<AllocaInst*, 32> &NewElts){
// Extract each element out of the integer according to its structure offset
// and store the element value to the individual alloca.
- LLVMContext &Context = SI->getContext();
Value *SrcVal = SI->getOperand(0);
const Type *AllocaEltTy = AI->getType()->getElementType();
uint64_t AllocaSizeBits = TD->getTypeAllocSizeInBits(AllocaEltTy);
@@ -914,7 +913,7 @@
// Handle tail padding by extending the operand
if (TD->getTypeSizeInBits(SrcVal->getType()) != AllocaSizeBits)
SrcVal = new ZExtInst(SrcVal,
- Context.getIntegerType(AllocaSizeBits), "", SI);
+ IntegerType::get(AllocaSizeBits), "", SI);
DOUT << "PROMOTING STORE TO WHOLE ALLOCA: " << *AI << *SI;
@@ -946,7 +945,7 @@
if (FieldSizeBits != AllocaSizeBits)
EltVal = new TruncInst(EltVal,
- Context.getIntegerType(FieldSizeBits), "", SI);
+ IntegerType::get(FieldSizeBits), "", SI);
Value *DestField = NewElts[i];
if (EltVal->getType() == FieldTy) {
// Storing to an integer field of this size, just do it.
@@ -956,7 +955,7 @@
} else {
// Otherwise, bitcast the dest pointer (for aggregates).
DestField = new BitCastInst(DestField,
- Context.getPointerTypeUnqual(EltVal->getType()),
+ PointerType::getUnqual(EltVal->getType()),
"", SI);
}
new StoreInst(EltVal, DestField, SI);
@@ -989,7 +988,7 @@
// Truncate down to an integer of the right size.
if (ElementSizeBits != AllocaSizeBits)
EltVal = new TruncInst(EltVal,
- Context.getIntegerType(ElementSizeBits),"",SI);
+ IntegerType::get(ElementSizeBits),"",SI);
Value *DestField = NewElts[i];
if (EltVal->getType() == ArrayEltTy) {
// Storing to an integer field of this size, just do it.
@@ -999,7 +998,7 @@
} else {
// Otherwise, bitcast the dest pointer (for aggregates).
DestField = new BitCastInst(DestField,
- Context.getPointerTypeUnqual(EltVal->getType()),
+ PointerType::getUnqual(EltVal->getType()),
"", SI);
}
new StoreInst(EltVal, DestField, SI);
@@ -1046,7 +1045,7 @@
LLVMContext &Context = LI->getContext();
Value *ResultVal =
- Context.getNullValue(Context.getIntegerType(AllocaSizeBits));
+ Context.getNullValue(IntegerType::get(AllocaSizeBits));
for (unsigned i = 0, e = NewElts.size(); i != e; ++i) {
// Load the value from the alloca. If the NewElt is an aggregate, cast
@@ -1059,11 +1058,11 @@
// Ignore zero sized fields like {}, they obviously contain no data.
if (FieldSizeBits == 0) continue;
- const IntegerType *FieldIntTy = Context.getIntegerType(FieldSizeBits);
+ const IntegerType *FieldIntTy = IntegerType::get(FieldSizeBits);
if (!isa<IntegerType>(FieldTy) && !FieldTy->isFloatingPoint() &&
!isa<VectorType>(FieldTy))
SrcField = new BitCastInst(SrcField,
- Context.getPointerTypeUnqual(FieldIntTy),
+ PointerType::getUnqual(FieldIntTy),
"", LI);
SrcField = new LoadInst(SrcField, "sroa.load.elt", LI);
@@ -1297,7 +1296,7 @@
cast<VectorType>(VecTy)->getElementType()
->getPrimitiveSizeInBits()/8 == EltSize)) {
if (VecTy == 0)
- VecTy = In->getContext().getVectorType(In, AllocaSize/EltSize);
+ VecTy = VectorType::get(In, AllocaSize/EltSize);
return;
}
}
@@ -1623,10 +1622,10 @@
unsigned LIBitWidth = TD->getTypeSizeInBits(ToType);
if (LIBitWidth < NTy->getBitWidth())
FromVal =
- Builder.CreateTrunc(FromVal, Context.getIntegerType(LIBitWidth), "tmp");
+ Builder.CreateTrunc(FromVal, IntegerType::get(LIBitWidth), "tmp");
else if (LIBitWidth > NTy->getBitWidth())
FromVal =
- Builder.CreateZExt(FromVal, Context.getIntegerType(LIBitWidth), "tmp");
+ Builder.CreateZExt(FromVal, IntegerType::get(LIBitWidth), "tmp");
// If the result is an integer, this is a trunc or bitcast.
if (isa<IntegerType>(ToType)) {
@@ -1711,7 +1710,7 @@
unsigned SrcStoreWidth = TD->getTypeStoreSizeInBits(SV->getType());
unsigned DestStoreWidth = TD->getTypeStoreSizeInBits(AllocaType);
if (SV->getType()->isFloatingPoint() || isa<VectorType>(SV->getType()))
- SV = Builder.CreateBitCast(SV, Context.getIntegerType(SrcWidth), "tmp");
+ SV = Builder.CreateBitCast(SV, IntegerType::get(SrcWidth), "tmp");
else if (isa<PointerType>(SV->getType()))
SV = Builder.CreatePtrToInt(SV, TD->getIntPtrType(), "tmp");
diff --git a/lib/Transforms/Scalar/SimplifyLibCalls.cpp b/lib/Transforms/Scalar/SimplifyLibCalls.cpp
index c421ee2..04bc39b 100644
--- a/lib/Transforms/Scalar/SimplifyLibCalls.cpp
+++ b/lib/Transforms/Scalar/SimplifyLibCalls.cpp
@@ -126,7 +126,7 @@
/// CastToCStr - Return V if it is an i8*, otherwise cast it to i8*.
Value *LibCallOptimization::CastToCStr(Value *V, IRBuilder<> &B) {
return
- B.CreateBitCast(V, Context->getPointerTypeUnqual(Type::Int8Ty), "cstr");
+ B.CreateBitCast(V, PointerType::getUnqual(Type::Int8Ty), "cstr");
}
/// EmitStrLen - Emit a call to the strlen function to the builder, for the
@@ -140,7 +140,7 @@
Constant *StrLen =M->getOrInsertFunction("strlen", AttrListPtr::get(AWI, 2),
TD->getIntPtrType(),
- Context->getPointerTypeUnqual(Type::Int8Ty),
+ PointerType::getUnqual(Type::Int8Ty),
NULL);
CallInst *CI = B.CreateCall(StrLen, CastToCStr(Ptr, B), "strlen");
if (const Function *F = dyn_cast<Function>(StrLen->stripPointerCasts()))
@@ -171,8 +171,8 @@
AWI = AttributeWithIndex::get(~0u, Attribute::ReadOnly | Attribute::NoUnwind);
Value *MemChr = M->getOrInsertFunction("memchr", AttrListPtr::get(&AWI, 1),
- Context->getPointerTypeUnqual(Type::Int8Ty),
- Context->getPointerTypeUnqual(Type::Int8Ty),
+ PointerType::getUnqual(Type::Int8Ty),
+ PointerType::getUnqual(Type::Int8Ty),
Type::Int32Ty, TD->getIntPtrType(),
NULL);
CallInst *CI = B.CreateCall3(MemChr, CastToCStr(Ptr, B), Val, Len, "memchr");
@@ -195,8 +195,8 @@
Value *MemCmp = M->getOrInsertFunction("memcmp", AttrListPtr::get(AWI, 3),
Type::Int32Ty,
- Context->getPointerTypeUnqual(Type::Int8Ty),
- Context->getPointerTypeUnqual(Type::Int8Ty),
+ PointerType::getUnqual(Type::Int8Ty),
+ PointerType::getUnqual(Type::Int8Ty),
TD->getIntPtrType(), NULL);
CallInst *CI = B.CreateCall3(MemCmp, CastToCStr(Ptr1, B), CastToCStr(Ptr2, B),
Len, "memcmp");
@@ -274,7 +274,7 @@
Value *PutS = M->getOrInsertFunction("puts", AttrListPtr::get(AWI, 2),
Type::Int32Ty,
- Context->getPointerTypeUnqual(Type::Int8Ty),
+ PointerType::getUnqual(Type::Int8Ty),
NULL);
CallInst *CI = B.CreateCall(PutS, CastToCStr(Str, B), "puts");
if (const Function *F = dyn_cast<Function>(PutS->stripPointerCasts()))
@@ -314,11 +314,11 @@
Constant *F;
if (isa<PointerType>(File->getType()))
F = M->getOrInsertFunction("fputs", AttrListPtr::get(AWI, 3), Type::Int32Ty,
- Context->getPointerTypeUnqual(Type::Int8Ty),
+ PointerType::getUnqual(Type::Int8Ty),
File->getType(), NULL);
else
F = M->getOrInsertFunction("fputs", Type::Int32Ty,
- Context->getPointerTypeUnqual(Type::Int8Ty),
+ PointerType::getUnqual(Type::Int8Ty),
File->getType(), NULL);
CallInst *CI = B.CreateCall2(F, CastToCStr(Str, B), File, "fputs");
@@ -339,12 +339,12 @@
if (isa<PointerType>(File->getType()))
F = M->getOrInsertFunction("fwrite", AttrListPtr::get(AWI, 3),
TD->getIntPtrType(),
- Context->getPointerTypeUnqual(Type::Int8Ty),
+ PointerType::getUnqual(Type::Int8Ty),
TD->getIntPtrType(), TD->getIntPtrType(),
File->getType(), NULL);
else
F = M->getOrInsertFunction("fwrite", TD->getIntPtrType(),
- Context->getPointerTypeUnqual(Type::Int8Ty),
+ PointerType::getUnqual(Type::Int8Ty),
TD->getIntPtrType(), TD->getIntPtrType(),
File->getType(), NULL);
CallInst *CI = B.CreateCall4(F, CastToCStr(Ptr, B), Size,
@@ -555,7 +555,7 @@
// Verify the "strcat" function prototype.
const FunctionType *FT = Callee->getFunctionType();
if (FT->getNumParams() != 2 ||
- FT->getReturnType() != Context->getPointerTypeUnqual(Type::Int8Ty) ||
+ FT->getReturnType() != PointerType::getUnqual(Type::Int8Ty) ||
FT->getParamType(0) != FT->getReturnType() ||
FT->getParamType(1) != FT->getReturnType())
return 0;
@@ -602,7 +602,7 @@
// Verify the "strncat" function prototype.
const FunctionType *FT = Callee->getFunctionType();
if (FT->getNumParams() != 3 ||
- FT->getReturnType() != Context->getPointerTypeUnqual(Type::Int8Ty) ||
+ FT->getReturnType() != PointerType::getUnqual(Type::Int8Ty) ||
FT->getParamType(0) != FT->getReturnType() ||
FT->getParamType(1) != FT->getReturnType() ||
!isa<IntegerType>(FT->getParamType(2)))
@@ -647,7 +647,7 @@
// Verify the "strchr" function prototype.
const FunctionType *FT = Callee->getFunctionType();
if (FT->getNumParams() != 2 ||
- FT->getReturnType() != Context->getPointerTypeUnqual(Type::Int8Ty) ||
+ FT->getReturnType() != PointerType::getUnqual(Type::Int8Ty) ||
FT->getParamType(0) != FT->getReturnType())
return 0;
@@ -701,7 +701,7 @@
const FunctionType *FT = Callee->getFunctionType();
if (FT->getNumParams() != 2 || FT->getReturnType() != Type::Int32Ty ||
FT->getParamType(0) != FT->getParamType(1) ||
- FT->getParamType(0) != Context->getPointerTypeUnqual(Type::Int8Ty))
+ FT->getParamType(0) != PointerType::getUnqual(Type::Int8Ty))
return 0;
Value *Str1P = CI->getOperand(1), *Str2P = CI->getOperand(2);
@@ -745,7 +745,7 @@
const FunctionType *FT = Callee->getFunctionType();
if (FT->getNumParams() != 3 || FT->getReturnType() != Type::Int32Ty ||
FT->getParamType(0) != FT->getParamType(1) ||
- FT->getParamType(0) != Context->getPointerTypeUnqual(Type::Int8Ty) ||
+ FT->getParamType(0) != PointerType::getUnqual(Type::Int8Ty) ||
!isa<IntegerType>(FT->getParamType(2)))
return 0;
@@ -791,7 +791,7 @@
const FunctionType *FT = Callee->getFunctionType();
if (FT->getNumParams() != 2 || FT->getReturnType() != FT->getParamType(0) ||
FT->getParamType(0) != FT->getParamType(1) ||
- FT->getParamType(0) != Context->getPointerTypeUnqual(Type::Int8Ty))
+ FT->getParamType(0) != PointerType::getUnqual(Type::Int8Ty))
return 0;
Value *Dst = CI->getOperand(1), *Src = CI->getOperand(2);
@@ -818,7 +818,7 @@
const FunctionType *FT = Callee->getFunctionType();
if (FT->getNumParams() != 3 || FT->getReturnType() != FT->getParamType(0) ||
FT->getParamType(0) != FT->getParamType(1) ||
- FT->getParamType(0) != Context->getPointerTypeUnqual(Type::Int8Ty) ||
+ FT->getParamType(0) != PointerType::getUnqual(Type::Int8Ty) ||
!isa<IntegerType>(FT->getParamType(2)))
return 0;
@@ -863,7 +863,7 @@
virtual Value *CallOptimizer(Function *Callee, CallInst *CI, IRBuilder<> &B) {
const FunctionType *FT = Callee->getFunctionType();
if (FT->getNumParams() != 1 ||
- FT->getParamType(0) != Context->getPointerTypeUnqual(Type::Int8Ty) ||
+ FT->getParamType(0) != PointerType::getUnqual(Type::Int8Ty) ||
!isa<IntegerType>(FT->getReturnType()))
return 0;
@@ -937,7 +937,7 @@
// memcmp(S1,S2,2) != 0 -> (*(short*)LHS ^ *(short*)RHS) != 0
// memcmp(S1,S2,4) != 0 -> (*(int*)LHS ^ *(int*)RHS) != 0
if ((Len == 2 || Len == 4) && IsOnlyUsedInZeroEqualityComparison(CI)) {
- const Type *PTy = Context->getPointerTypeUnqual(Len == 2 ?
+ const Type *PTy = PointerType::getUnqual(Len == 2 ?
Type::Int16Ty : Type::Int32Ty);
LHS = B.CreateBitCast(LHS, PTy, "tmp");
RHS = B.CreateBitCast(RHS, PTy, "tmp");
diff --git a/lib/Transforms/Utils/CloneFunction.cpp b/lib/Transforms/Utils/CloneFunction.cpp
index dae39b7..7b8a8a4 100644
--- a/lib/Transforms/Utils/CloneFunction.cpp
+++ b/lib/Transforms/Utils/CloneFunction.cpp
@@ -151,8 +151,7 @@
ArgTypes.push_back(I->getType());
// Create a new function type...
- FunctionType *FTy =
- F->getContext().getFunctionType(F->getFunctionType()->getReturnType(),
+ FunctionType *FTy = FunctionType::get(F->getFunctionType()->getReturnType(),
ArgTypes, F->getFunctionType()->isVarArg());
// Create the new function...
diff --git a/lib/Transforms/Utils/CodeExtractor.cpp b/lib/Transforms/Utils/CodeExtractor.cpp
index ab10baa..d897c2a 100644
--- a/lib/Transforms/Utils/CodeExtractor.cpp
+++ b/lib/Transforms/Utils/CodeExtractor.cpp
@@ -266,8 +266,7 @@
if (AggregateArgs)
paramTy.push_back((*I)->getType());
else
- paramTy.push_back(
- header->getContext().getPointerTypeUnqual((*I)->getType()));
+ paramTy.push_back(PointerType::getUnqual((*I)->getType()));
}
DOUT << "Function type: " << *RetTy << " f(";
@@ -278,12 +277,12 @@
if (AggregateArgs && (inputs.size() + outputs.size() > 0)) {
PointerType *StructPtr =
- Context.getPointerTypeUnqual(Context.getStructType(paramTy));
+ PointerType::getUnqual(StructType::get(paramTy));
paramTy.clear();
paramTy.push_back(StructPtr);
}
const FunctionType *funcType =
- Context.getFunctionType(RetTy, paramTy, false);
+ FunctionType::get(RetTy, paramTy, false);
// Create the new function
Function *newFunction = Function::Create(funcType,
@@ -387,7 +386,7 @@
ArgTypes.push_back((*v)->getType());
// Allocate a struct at the beginning of this function
- Type *StructArgTy = Context.getStructType(ArgTypes);
+ Type *StructArgTy = StructType::get(ArgTypes);
Struct =
new AllocaInst(StructArgTy, 0, "structArg",
codeReplacer->getParent()->begin()->begin());
diff --git a/lib/Transforms/Utils/InlineFunction.cpp b/lib/Transforms/Utils/InlineFunction.cpp
index cdde678..43b996af 100644
--- a/lib/Transforms/Utils/InlineFunction.cpp
+++ b/lib/Transforms/Utils/InlineFunction.cpp
@@ -304,7 +304,7 @@
if (CalledFunc->paramHasAttr(ArgNo+1, Attribute::ByVal) &&
!CalledFunc->onlyReadsMemory()) {
const Type *AggTy = cast<PointerType>(I->getType())->getElementType();
- const Type *VoidPtrTy = Context.getPointerTypeUnqual(Type::Int8Ty);
+ const Type *VoidPtrTy = PointerType::getUnqual(Type::Int8Ty);
// Create the alloca. If we have TargetData, use nice alignment.
unsigned Align = 1;
diff --git a/lib/Transforms/Utils/LowerAllocations.cpp b/lib/Transforms/Utils/LowerAllocations.cpp
index 522166d..305897c 100644
--- a/lib/Transforms/Utils/LowerAllocations.cpp
+++ b/lib/Transforms/Utils/LowerAllocations.cpp
@@ -87,10 +87,10 @@
// This function is always successful.
//
bool LowerAllocations::doInitialization(Module &M) {
- const Type *BPTy = M.getContext().getPointerTypeUnqual(Type::Int8Ty);
+ const Type *BPTy = PointerType::getUnqual(Type::Int8Ty);
// Prototype malloc as "char* malloc(...)", because we don't know in
// doInitialization whether size_t is int or long.
- FunctionType *FT = M.getContext().getFunctionType(BPTy, true);
+ FunctionType *FT = FunctionType::get(BPTy, true);
MallocFunc = M.getOrInsertFunction("malloc", FT);
FreeFunc = M.getOrInsertFunction("free" , Type::VoidTy, BPTy, (Type *)0);
return true;
@@ -166,7 +166,7 @@
} else if (FreeInst *FI = dyn_cast<FreeInst>(I)) {
Value *PtrCast =
new BitCastInst(FI->getOperand(0),
- Context.getPointerTypeUnqual(Type::Int8Ty), "", I);
+ PointerType::getUnqual(Type::Int8Ty), "", I);
// Insert a call to the free function...
CallInst::Create(FreeFunc, PtrCast, "", I)->setTailCall();
diff --git a/lib/Transforms/Utils/LowerInvoke.cpp b/lib/Transforms/Utils/LowerInvoke.cpp
index b880734..a9d218c 100644
--- a/lib/Transforms/Utils/LowerInvoke.cpp
+++ b/lib/Transforms/Utils/LowerInvoke.cpp
@@ -117,26 +117,26 @@
bool LowerInvoke::doInitialization(Module &M) {
LLVMContext &Context = M.getContext();
- const Type *VoidPtrTy = Context.getPointerTypeUnqual(Type::Int8Ty);
+ const Type *VoidPtrTy = PointerType::getUnqual(Type::Int8Ty);
AbortMessage = 0;
if (ExpensiveEHSupport) {
// Insert a type for the linked list of jump buffers.
unsigned JBSize = TLI ? TLI->getJumpBufSize() : 0;
JBSize = JBSize ? JBSize : 200;
- const Type *JmpBufTy = Context.getArrayType(VoidPtrTy, JBSize);
+ const Type *JmpBufTy = ArrayType::get(VoidPtrTy, JBSize);
{ // The type is recursive, so use a type holder.
std::vector<const Type*> Elements;
Elements.push_back(JmpBufTy);
- OpaqueType *OT = Context.getOpaqueType();
- Elements.push_back(Context.getPointerTypeUnqual(OT));
- PATypeHolder JBLType(Context.getStructType(Elements));
+ OpaqueType *OT = OpaqueType::get();
+ Elements.push_back(PointerType::getUnqual(OT));
+ PATypeHolder JBLType(StructType::get(Elements));
OT->refineAbstractTypeTo(JBLType.get()); // Complete the cycle.
JBLinkTy = JBLType.get();
M.addTypeName("llvm.sjljeh.jmpbufty", JBLinkTy);
}
- const Type *PtrJBList = Context.getPointerTypeUnqual(JBLinkTy);
+ const Type *PtrJBList = PointerType::getUnqual(JBLinkTy);
// Now that we've done that, insert the jmpbuf list head global, unless it
// already exists.
diff --git a/lib/VMCore/AutoUpgrade.cpp b/lib/VMCore/AutoUpgrade.cpp
index fc86e54..81d143a 100644
--- a/lib/VMCore/AutoUpgrade.cpp
+++ b/lib/VMCore/AutoUpgrade.cpp
@@ -27,8 +27,6 @@
static bool UpgradeIntrinsicFunction1(Function *F, Function *&NewFn) {
assert(F && "Illegal to upgrade a non-existent Function.");
- LLVMContext &Context = F->getContext();
-
// Get the Function's name.
const std::string& Name = F->getName();
@@ -167,7 +165,7 @@
Name.compare(13,4,"psrl", 4) == 0) && Name[17] != 'i') {
const llvm::Type *VT =
- Context.getVectorType(Context.getIntegerType(64), 1);
+ VectorType::get(IntegerType::get(64), 1);
// We don't have to do anything if the parameter already has
// the correct type.
@@ -268,7 +266,7 @@
if (isLoadH || isLoadL) {
Value *Op1 = Context.getUndef(Op0->getType());
Value *Addr = new BitCastInst(CI->getOperand(2),
- Context.getPointerTypeUnqual(Type::DoubleTy),
+ PointerType::getUnqual(Type::DoubleTy),
"upgraded.", CI);
Value *Load = new LoadInst(Addr, "upgraded.", false, 8, CI);
Value *Idx = ConstantInt::get(Type::Int32Ty, 0);
diff --git a/lib/VMCore/ConstantFold.cpp b/lib/VMCore/ConstantFold.cpp
index 440fb88..ab00160 100644
--- a/lib/VMCore/ConstantFold.cpp
+++ b/lib/VMCore/ConstantFold.cpp
@@ -1373,7 +1373,7 @@
const Constant *C2) {
const Type *ResultTy;
if (const VectorType *VT = dyn_cast<VectorType>(C1->getType()))
- ResultTy = Context.getVectorType(Type::Int1Ty, VT->getNumElements());
+ ResultTy = VectorType::get(Type::Int1Ty, VT->getNumElements());
else
ResultTy = Type::Int1Ty;
@@ -1677,7 +1677,7 @@
(Value **)Idxs,
(Value **)Idxs+NumIdx);
assert(Ty != 0 && "Invalid indices for GEP!");
- return Context.getUndef(Context.getPointerType(Ty, Ptr->getAddressSpace()));
+ return Context.getUndef(PointerType::get(Ty, Ptr->getAddressSpace()));
}
Constant *Idx0 = Idxs[0];
@@ -1695,7 +1695,7 @@
(Value**)Idxs+NumIdx);
assert(Ty != 0 && "Invalid indices for GEP!");
return Context.getConstantPointerNull(
- Context.getPointerType(Ty,Ptr->getAddressSpace()));
+ PointerType::get(Ty,Ptr->getAddressSpace()));
}
}
diff --git a/lib/VMCore/Constants.cpp b/lib/VMCore/Constants.cpp
index 6746882..1ff596f 100644
--- a/lib/VMCore/Constants.cpp
+++ b/lib/VMCore/Constants.cpp
@@ -178,7 +178,7 @@
// invariant which generates an assertion.
ConstantInt *ConstantInt::get(LLVMContext &Context, const APInt& V) {
// Get the corresponding integer type for the bit width of the value.
- const IntegerType *ITy = Context.getIntegerType(V.getBitWidth());
+ const IntegerType *ITy = IntegerType::get(V.getBitWidth());
// get an existing value or the insertion position
DenseMapAPIntKeyInfo::KeyTy Key(V, ITy);
diff --git a/lib/VMCore/Core.cpp b/lib/VMCore/Core.cpp
index bf5a6a1..59aeb87 100644
--- a/lib/VMCore/Core.cpp
+++ b/lib/VMCore/Core.cpp
@@ -162,7 +162,7 @@
LLVMTypeRef LLVMInt64Type(void) { return (LLVMTypeRef) Type::Int64Ty; }
LLVMTypeRef LLVMIntType(unsigned NumBits) {
- return wrap(getGlobalContext().getIntegerType(NumBits));
+ return wrap(IntegerType::get(NumBits));
}
unsigned LLVMGetIntTypeWidth(LLVMTypeRef IntegerTy) {
@@ -186,8 +186,7 @@
for (LLVMTypeRef *I = ParamTypes, *E = ParamTypes + ParamCount; I != E; ++I)
Tys.push_back(unwrap(*I));
- return wrap(getGlobalContext().getFunctionType(unwrap(ReturnType), Tys,
- IsVarArg != 0));
+ return wrap(FunctionType::get(unwrap(ReturnType), Tys, IsVarArg != 0));
}
int LLVMIsFunctionVarArg(LLVMTypeRef FunctionTy) {
@@ -218,7 +217,7 @@
*E = ElementTypes + ElementCount; I != E; ++I)
Tys.push_back(unwrap(*I));
- return wrap(getGlobalContext().getStructType(Tys, Packed != 0));
+ return wrap(StructType::get(Tys, Packed != 0));
}
unsigned LLVMCountStructElementTypes(LLVMTypeRef StructTy) {
@@ -239,18 +238,15 @@
/*--.. Operations on array, pointer, and vector types (sequence types) .....--*/
LLVMTypeRef LLVMArrayType(LLVMTypeRef ElementType, unsigned ElementCount) {
- return wrap(getGlobalContext().getArrayType(unwrap(ElementType),
- ElementCount));
+ return wrap(ArrayType::get(unwrap(ElementType), ElementCount));
}
LLVMTypeRef LLVMPointerType(LLVMTypeRef ElementType, unsigned AddressSpace) {
- return wrap(getGlobalContext().getPointerType(unwrap(ElementType),
- AddressSpace));
+ return wrap(PointerType::get(unwrap(ElementType), AddressSpace));
}
LLVMTypeRef LLVMVectorType(LLVMTypeRef ElementType, unsigned ElementCount) {
- return wrap(getGlobalContext().getVectorType(unwrap(ElementType),
- ElementCount));
+ return wrap(VectorType::get(unwrap(ElementType), ElementCount));
}
LLVMTypeRef LLVMGetElementType(LLVMTypeRef Ty) {
@@ -275,7 +271,7 @@
LLVMTypeRef LLVMLabelType(void) { return (LLVMTypeRef) Type::LabelTy; }
LLVMTypeRef LLVMOpaqueType(void) {
- return wrap(getGlobalContext().getOpaqueType());
+ return wrap(OpaqueType::get());
}
/*--.. Operations on type handles ..........................................--*/
@@ -408,8 +404,7 @@
LLVMValueRef LLVMConstArray(LLVMTypeRef ElementTy,
LLVMValueRef *ConstantVals, unsigned Length) {
- return wrap(ConstantArray::get(
- getGlobalContext().getArrayType(unwrap(ElementTy), Length),
+ return wrap(ConstantArray::get(ArrayType::get(unwrap(ElementTy), Length),
unwrap<Constant>(ConstantVals, Length),
Length));
}
diff --git a/lib/VMCore/Function.cpp b/lib/VMCore/Function.cpp
index cdf2dd0..9fc3000 100644
--- a/lib/VMCore/Function.cpp
+++ b/lib/VMCore/Function.cpp
@@ -346,7 +346,7 @@
#include "llvm/Intrinsics.gen"
#undef GET_INTRINSIC_GENERATOR
- return Context.getFunctionType(ResultTy, ArgTys, IsVarArg);
+ return FunctionType::get(ResultTy, ArgTys, IsVarArg);
}
bool Intrinsic::isOverloaded(ID id) {
diff --git a/lib/VMCore/Globals.cpp b/lib/VMCore/Globals.cpp
index e01dedd..d18a201 100644
--- a/lib/VMCore/Globals.cpp
+++ b/lib/VMCore/Globals.cpp
@@ -98,7 +98,7 @@
bool constant, LinkageTypes Link,
Constant *InitVal, const Twine &Name,
bool ThreadLocal, unsigned AddressSpace)
- : GlobalValue(Context.getPointerType(Ty, AddressSpace),
+ : GlobalValue(PointerType::get(Ty, AddressSpace),
Value::GlobalVariableVal,
OperandTraits<GlobalVariable>::op_begin(this),
InitVal != 0, Link, Name),
@@ -117,7 +117,7 @@
const Twine &Name,
GlobalVariable *Before, bool ThreadLocal,
unsigned AddressSpace)
- : GlobalValue(M.getContext().getPointerType(Ty, AddressSpace),
+ : GlobalValue(PointerType::get(Ty, AddressSpace),
Value::GlobalVariableVal,
OperandTraits<GlobalVariable>::op_begin(this),
InitVal != 0, Link, Name),
diff --git a/lib/VMCore/Instructions.cpp b/lib/VMCore/Instructions.cpp
index 0b24241..08b4396 100644
--- a/lib/VMCore/Instructions.cpp
+++ b/lib/VMCore/Instructions.cpp
@@ -716,7 +716,7 @@
AllocationInst::AllocationInst(const Type *Ty, Value *ArraySize, unsigned iTy,
unsigned Align, const Twine &Name,
Instruction *InsertBefore)
- : UnaryInstruction(Ty->getContext().getPointerTypeUnqual(Ty), iTy,
+ : UnaryInstruction(PointerType::getUnqual(Ty), iTy,
getAISize(Ty->getContext(), ArraySize), InsertBefore) {
setAlignment(Align);
assert(Ty != Type::VoidTy && "Cannot allocate void!");
@@ -726,7 +726,7 @@
AllocationInst::AllocationInst(const Type *Ty, Value *ArraySize, unsigned iTy,
unsigned Align, const Twine &Name,
BasicBlock *InsertAtEnd)
- : UnaryInstruction(Ty->getContext().getPointerTypeUnqual(Ty), iTy,
+ : UnaryInstruction(PointerType::getUnqual(Ty), iTy,
getAISize(Ty->getContext(), ArraySize), InsertAtEnd) {
setAlignment(Align);
assert(Ty != Type::VoidTy && "Cannot allocate void!");
@@ -1046,7 +1046,7 @@
GetElementPtrInst::GetElementPtrInst(Value *Ptr, Value *Idx,
const Twine &Name, Instruction *InBe)
- : Instruction(Ptr->getType()->getContext().getPointerType(
+ : Instruction(PointerType::get(
checkType(getIndexedType(Ptr->getType(),Idx)), retrieveAddrSpace(Ptr)),
GetElementPtr,
OperandTraits<GetElementPtrInst>::op_end(this) - 2,
@@ -1056,7 +1056,7 @@
GetElementPtrInst::GetElementPtrInst(Value *Ptr, Value *Idx,
const Twine &Name, BasicBlock *IAE)
- : Instruction(Ptr->getType()->getContext().getPointerType(
+ : Instruction(PointerType::get(
checkType(getIndexedType(Ptr->getType(),Idx)),
retrieveAddrSpace(Ptr)),
GetElementPtr,
@@ -1270,8 +1270,7 @@
ShuffleVectorInst::ShuffleVectorInst(Value *V1, Value *V2, Value *Mask,
const Twine &Name,
Instruction *InsertBefore)
-: Instruction(V1->getType()->getContext().getVectorType(
- cast<VectorType>(V1->getType())->getElementType(),
+: Instruction(VectorType::get(cast<VectorType>(V1->getType())->getElementType(),
cast<VectorType>(Mask->getType())->getNumElements()),
ShuffleVector,
OperandTraits<ShuffleVectorInst>::op_begin(this),
diff --git a/lib/VMCore/LLVMContext.cpp b/lib/VMCore/LLVMContext.cpp
index e38986e..8bd45b2 100644
--- a/lib/VMCore/LLVMContext.cpp
+++ b/lib/VMCore/LLVMContext.cpp
@@ -113,89 +113,6 @@
return pImpl->getMDString(Str.data(), Str.size());
}
-// FunctionType accessors
-FunctionType* LLVMContext::getFunctionType(const Type* Result, bool isVarArg) {
- return FunctionType::get(Result, isVarArg);
-}
-
-FunctionType* LLVMContext::getFunctionType(const Type* Result,
- const std::vector<const Type*>& Params,
- bool isVarArg) {
- return FunctionType::get(Result, Params, isVarArg);
-}
-
-// IntegerType accessors
-const IntegerType* LLVMContext::getIntegerType(unsigned NumBits) {
- return IntegerType::get(NumBits);
-}
-
-// OpaqueType accessors
-OpaqueType* LLVMContext::getOpaqueType() {
- return OpaqueType::get();
-}
-
-// StructType accessors
-StructType* LLVMContext::getStructType(bool isPacked) {
- return StructType::get(isPacked);
-}
-
-StructType* LLVMContext::getStructType(const std::vector<const Type*>& Params,
- bool isPacked) {
- return StructType::get(Params, isPacked);
-}
-
-StructType *LLVMContext::getStructType(const Type *type, ...) {
- va_list ap;
- std::vector<const llvm::Type*> StructFields;
- va_start(ap, type);
- while (type) {
- StructFields.push_back(type);
- type = va_arg(ap, llvm::Type*);
- }
- return StructType::get(StructFields);
-}
-
-// ArrayType accessors
-ArrayType* LLVMContext::getArrayType(const Type* ElementType,
- uint64_t NumElements) {
- return ArrayType::get(ElementType, NumElements);
-}
-
-// PointerType accessors
-PointerType* LLVMContext::getPointerType(const Type* ElementType,
- unsigned AddressSpace) {
- return PointerType::get(ElementType, AddressSpace);
-}
-
-PointerType* LLVMContext::getPointerTypeUnqual(const Type* ElementType) {
- return PointerType::getUnqual(ElementType);
-}
-
-// VectorType accessors
-VectorType* LLVMContext::getVectorType(const Type* ElementType,
- unsigned NumElements) {
- return VectorType::get(ElementType, NumElements);
-}
-
-VectorType* LLVMContext::getVectorTypeInteger(const VectorType* VTy) {
- return VectorType::getInteger(VTy);
-}
-
-VectorType* LLVMContext::getVectorTypeExtendedElement(const VectorType* VTy) {
- return VectorType::getExtendedElementVectorType(VTy);
-}
-
-VectorType* LLVMContext::getVectorTypeTruncatedElement(const VectorType* VTy) {
- return VectorType::getTruncatedElementVectorType(VTy);
-}
-
-const Type* LLVMContext::makeCmpResultType(const Type* opnd_type) {
- if (const VectorType* vt = dyn_cast<const VectorType>(opnd_type)) {
- return getVectorType(Type::Int1Ty, vt->getNumElements());
- }
- return Type::Int1Ty;
-}
-
void LLVMContext::erase(MDString *M) {
pImpl->erase(M);
}
diff --git a/lib/VMCore/Module.cpp b/lib/VMCore/Module.cpp
index 2ef16d0..87d4b05 100644
--- a/lib/VMCore/Module.cpp
+++ b/lib/VMCore/Module.cpp
@@ -153,8 +153,8 @@
// If the function exists but has the wrong type, return a bitcast to the
// right type.
- if (F->getType() != Context.getPointerTypeUnqual(Ty))
- return ConstantExpr::getBitCast(F, Context.getPointerTypeUnqual(Ty));
+ if (F->getType() != PointerType::getUnqual(Ty))
+ return ConstantExpr::getBitCast(F, PointerType::getUnqual(Ty));
// Otherwise, we just found the existing function or a prototype.
return F;
@@ -203,7 +203,7 @@
// Build the function type and chain to the other getOrInsertFunction...
return getOrInsertFunction(Name,
- Context.getFunctionType(RetTy, ArgTys, false),
+ FunctionType::get(RetTy, ArgTys, false),
AttributeList);
}
@@ -221,7 +221,7 @@
// Build the function type and chain to the other getOrInsertFunction...
return getOrInsertFunction(Name,
- Context.getFunctionType(RetTy, ArgTys, false),
+ FunctionType::get(RetTy, ArgTys, false),
AttrListPtr::get((AttributeWithIndex *)0, 0));
}
@@ -271,8 +271,8 @@
// If the variable exists but has the wrong type, return a bitcast to the
// right type.
- if (GV->getType() != Context.getPointerTypeUnqual(Ty))
- return ConstantExpr::getBitCast(GV, Context.getPointerTypeUnqual(Ty));
+ if (GV->getType() != PointerType::getUnqual(Ty))
+ return ConstantExpr::getBitCast(GV, PointerType::getUnqual(Ty));
// Otherwise, we just found the existing function or a prototype.
return GV;
diff --git a/lib/VMCore/ValueTypes.cpp b/lib/VMCore/ValueTypes.cpp
index 5badffc..2446596 100644
--- a/lib/VMCore/ValueTypes.cpp
+++ b/lib/VMCore/ValueTypes.cpp
@@ -21,16 +21,14 @@
MVT MVT::getExtendedIntegerVT(unsigned BitWidth) {
MVT VT;
- VT.LLVMTy = getGlobalContext().getIntegerType(BitWidth);
+ VT.LLVMTy = IntegerType::get(BitWidth);
assert(VT.isExtended() && "Type is not extended!");
return VT;
}
MVT MVT::getExtendedVectorVT(MVT VT, unsigned NumElements) {
MVT ResultVT;
- ResultVT.LLVMTy = getGlobalContext().getVectorType(
- VT.getTypeForMVT(getGlobalContext()),
- NumElements);
+ ResultVT.LLVMTy = VectorType::get(VT.getTypeForMVT(), NumElements);
assert(ResultVT.isExtended() && "Type is not extended!");
return ResultVT;
}
@@ -133,7 +131,7 @@
/// getTypeForMVT - This method returns an LLVM type corresponding to the
/// specified MVT. For integer types, this returns an unsigned type. Note
/// that this will abort for types that cannot be represented.
-const Type *MVT::getTypeForMVT(LLVMContext &Context) const {
+const Type *MVT::getTypeForMVT() const {
switch (V) {
default:
assert(isExtended() && "Type is not extended!");
@@ -144,32 +142,32 @@
case MVT::i16: return Type::Int16Ty;
case MVT::i32: return Type::Int32Ty;
case MVT::i64: return Type::Int64Ty;
- case MVT::i128: return Context.getIntegerType(128);
+ case MVT::i128: return IntegerType::get(128);
case MVT::f32: return Type::FloatTy;
case MVT::f64: return Type::DoubleTy;
case MVT::f80: return Type::X86_FP80Ty;
case MVT::f128: return Type::FP128Ty;
case MVT::ppcf128: return Type::PPC_FP128Ty;
- case MVT::v2i8: return Context.getVectorType(Type::Int8Ty, 2);
- case MVT::v4i8: return Context.getVectorType(Type::Int8Ty, 4);
- case MVT::v8i8: return Context.getVectorType(Type::Int8Ty, 8);
- case MVT::v16i8: return Context.getVectorType(Type::Int8Ty, 16);
- case MVT::v32i8: return Context.getVectorType(Type::Int8Ty, 32);
- case MVT::v2i16: return Context.getVectorType(Type::Int16Ty, 2);
- case MVT::v4i16: return Context.getVectorType(Type::Int16Ty, 4);
- case MVT::v8i16: return Context.getVectorType(Type::Int16Ty, 8);
- case MVT::v16i16: return Context.getVectorType(Type::Int16Ty, 16);
- case MVT::v2i32: return Context.getVectorType(Type::Int32Ty, 2);
- case MVT::v4i32: return Context.getVectorType(Type::Int32Ty, 4);
- case MVT::v8i32: return Context.getVectorType(Type::Int32Ty, 8);
- case MVT::v1i64: return Context.getVectorType(Type::Int64Ty, 1);
- case MVT::v2i64: return Context.getVectorType(Type::Int64Ty, 2);
- case MVT::v4i64: return Context.getVectorType(Type::Int64Ty, 4);
- case MVT::v2f32: return Context.getVectorType(Type::FloatTy, 2);
- case MVT::v4f32: return Context.getVectorType(Type::FloatTy, 4);
- case MVT::v8f32: return Context.getVectorType(Type::FloatTy, 8);
- case MVT::v2f64: return Context.getVectorType(Type::DoubleTy, 2);
- case MVT::v4f64: return Context.getVectorType(Type::DoubleTy, 4);
+ case MVT::v2i8: return VectorType::get(Type::Int8Ty, 2);
+ case MVT::v4i8: return VectorType::get(Type::Int8Ty, 4);
+ case MVT::v8i8: return VectorType::get(Type::Int8Ty, 8);
+ case MVT::v16i8: return VectorType::get(Type::Int8Ty, 16);
+ case MVT::v32i8: return VectorType::get(Type::Int8Ty, 32);
+ case MVT::v2i16: return VectorType::get(Type::Int16Ty, 2);
+ case MVT::v4i16: return VectorType::get(Type::Int16Ty, 4);
+ case MVT::v8i16: return VectorType::get(Type::Int16Ty, 8);
+ case MVT::v16i16: return VectorType::get(Type::Int16Ty, 16);
+ case MVT::v2i32: return VectorType::get(Type::Int32Ty, 2);
+ case MVT::v4i32: return VectorType::get(Type::Int32Ty, 4);
+ case MVT::v8i32: return VectorType::get(Type::Int32Ty, 8);
+ case MVT::v1i64: return VectorType::get(Type::Int64Ty, 1);
+ case MVT::v2i64: return VectorType::get(Type::Int64Ty, 2);
+ case MVT::v4i64: return VectorType::get(Type::Int64Ty, 4);
+ case MVT::v2f32: return VectorType::get(Type::FloatTy, 2);
+ case MVT::v4f32: return VectorType::get(Type::FloatTy, 4);
+ case MVT::v8f32: return VectorType::get(Type::FloatTy, 8);
+ case MVT::v2f64: return VectorType::get(Type::DoubleTy, 2);
+ case MVT::v4f64: return VectorType::get(Type::DoubleTy, 4);
}
}
diff --git a/lib/VMCore/Verifier.cpp b/lib/VMCore/Verifier.cpp
index 6d179d0..407a80b 100644
--- a/lib/VMCore/Verifier.cpp
+++ b/lib/VMCore/Verifier.cpp
@@ -1490,7 +1490,6 @@
bool Verifier::PerformTypeCheck(Intrinsic::ID ID, Function *F, const Type *Ty,
int VT, unsigned ArgNo, std::string &Suffix) {
const FunctionType *FTy = F->getFunctionType();
- LLVMContext &Context = FTy->getContext();
unsigned NumElts = 0;
const Type *EltTy = Ty;
@@ -1620,7 +1619,7 @@
"vector elements!", F);
return false;
}
- } else if (MVT((MVT::SimpleValueType)VT).getTypeForMVT(Context) != EltTy) {
+ } else if (MVT((MVT::SimpleValueType)VT).getTypeForMVT() != EltTy) {
CheckFailed(IntrinsicParam(ArgNo, NumRets) + " is wrong!", F);
return false;
} else if (EltTy != Ty) {
diff --git a/tools/bugpoint/ExtractFunction.cpp b/tools/bugpoint/ExtractFunction.cpp
index c2159de..ea40caa 100644
--- a/tools/bugpoint/ExtractFunction.cpp
+++ b/tools/bugpoint/ExtractFunction.cpp
@@ -181,7 +181,6 @@
/// as a constant array.
static Constant *GetTorInit(std::vector<std::pair<Function*, int> > &TorList) {
assert(!TorList.empty() && "Don't create empty tor list!");
- LLVMContext &Context = TorList[0].first->getContext();
std::vector<Constant*> ArrayElts;
for (unsigned i = 0, e = TorList.size(); i != e; ++i) {
std::vector<Constant*> Elts;
@@ -189,7 +188,7 @@
Elts.push_back(TorList[i].first);
ArrayElts.push_back(ConstantStruct::get(Elts));
}
- return ConstantArray::get(Context.getArrayType(ArrayElts[0]->getType(),
+ return ConstantArray::get(ArrayType::get(ArrayElts[0]->getType(),
ArrayElts.size()),
ArrayElts);
}
diff --git a/tools/bugpoint/Miscompilation.cpp b/tools/bugpoint/Miscompilation.cpp
index 74eaaa8..c021418 100644
--- a/tools/bugpoint/Miscompilation.cpp
+++ b/tools/bugpoint/Miscompilation.cpp
@@ -701,8 +701,8 @@
// Prototype: void *getPointerToNamedFunction(const char* Name)
Constant *resolverFunc =
Safe->getOrInsertFunction("getPointerToNamedFunction",
- Context.getPointerTypeUnqual(Type::Int8Ty),
- Context.getPointerTypeUnqual(Type::Int8Ty), (Type *)0);
+ PointerType::getUnqual(Type::Int8Ty),
+ PointerType::getUnqual(Type::Int8Ty), (Type *)0);
// Use the function we just added to get addresses of functions we need.
for (Module::iterator F = Safe->begin(), E = Safe->end(); F != E; ++F) {
@@ -765,7 +765,7 @@
// Cast the result from the resolver to correctly-typed function.
CastInst *CastedResolver =
new BitCastInst(Resolver,
- Context.getPointerTypeUnqual(F->getFunctionType()),
+ PointerType::getUnqual(F->getFunctionType()),
"resolverCast", LookupBB);
// Save the value in our cache.
diff --git a/unittests/ExecutionEngine/JIT/JITTest.cpp b/unittests/ExecutionEngine/JIT/JITTest.cpp
index 129f21f..abfe931 100644
--- a/unittests/ExecutionEngine/JIT/JITTest.cpp
+++ b/unittests/ExecutionEngine/JIT/JITTest.cpp
@@ -31,8 +31,7 @@
Function *makeReturnGlobal(std::string Name, GlobalVariable *G, Module *M) {
std::vector<const Type*> params;
- const FunctionType *FTy =
- getGlobalContext().getFunctionType(G->getType()->getElementType(),
+ const FunctionType *FTy = FunctionType::get(G->getType()->getElementType(),
params, false);
Function *F = Function::Create(FTy, GlobalValue::ExternalLinkage, Name, M);
BasicBlock *Entry = BasicBlock::Create("entry", F);
diff --git a/unittests/Support/TypeBuilderTest.cpp b/unittests/Support/TypeBuilderTest.cpp
index 8c5369b..e6c7c95 100644
--- a/unittests/Support/TypeBuilderTest.cpp
+++ b/unittests/Support/TypeBuilderTest.cpp
@@ -171,7 +171,7 @@
st.push_back(TypeBuilder<int, cross>::get(Context));
st.push_back(TypeBuilder<int*, cross>::get(Context));
st.push_back(TypeBuilder<void*[], cross>::get(Context));
- static const StructType *const result = Context.getStructType(st);
+ static const StructType *const result = StructType::get(st);
return result;
}
@@ -194,7 +194,7 @@
st.push_back(TypeBuilder<types::i<32>, cross>::get(Context));
st.push_back(TypeBuilder<types::i<32>*, cross>::get(Context));
st.push_back(TypeBuilder<types::i<8>*[], cross>::get(Context));
- static const StructType *const result = Context.getStructType(st);
+ static const StructType *const result = StructType::get(st);
return result;
}
diff --git a/utils/TableGen/CallingConvEmitter.cpp b/utils/TableGen/CallingConvEmitter.cpp
index 82e13dd..a14be0b 100644
--- a/utils/TableGen/CallingConvEmitter.cpp
+++ b/utils/TableGen/CallingConvEmitter.cpp
@@ -163,12 +163,12 @@
O << Size << ", ";
else
O << "\n" << IndentStr << " State.getTarget().getTargetData()"
- "->getTypeAllocSize(LocVT.getTypeForMVT(State.getContext())), ";
+ "->getTypeAllocSize(LocVT.getTypeForMVT()), ";
if (Align)
O << Align;
else
O << "\n" << IndentStr << " State.getTarget().getTargetData()"
- "->getABITypeAlignment(LocVT.getTypeForMVT(State.getContext()))";
+ "->getABITypeAlignment(LocVT.getTypeForMVT())";
O << ");\n" << IndentStr
<< "State.addLoc(CCValAssign::getMem(ValNo, ValVT, Offset"
<< Counter << ", LocVT, LocInfo));\n";