Move ConstantExpr to 2.5 API.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@77494 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/lib/Analysis/BasicAliasAnalysis.cpp b/lib/Analysis/BasicAliasAnalysis.cpp
index 9f0c138..2badd26 100644
--- a/lib/Analysis/BasicAliasAnalysis.cpp
+++ b/lib/Analysis/BasicAliasAnalysis.cpp
@@ -505,9 +505,9 @@
if (Constant *C2 = dyn_cast<Constant>(V2)) {
// Sign extend the constants to long types, if necessary
if (C1->getType() != Type::Int64Ty)
- C1 = Context.getConstantExprSExt(C1, Type::Int64Ty);
+ C1 = ConstantExpr::getSExt(C1, Type::Int64Ty);
if (C2->getType() != Type::Int64Ty)
- C2 = Context.getConstantExprSExt(C2, Type::Int64Ty);
+ C2 = ConstantExpr::getSExt(C2, Type::Int64Ty);
return C1 == C2;
}
return false;
@@ -603,9 +603,9 @@
if (G1OC->getType() != G2OC->getType()) {
// Sign extend both operands to long.
if (G1OC->getType() != Type::Int64Ty)
- G1OC = Context.getConstantExprSExt(G1OC, Type::Int64Ty);
+ G1OC = ConstantExpr::getSExt(G1OC, Type::Int64Ty);
if (G2OC->getType() != Type::Int64Ty)
- G2OC = Context.getConstantExprSExt(G2OC, Type::Int64Ty);
+ G2OC = ConstantExpr::getSExt(G2OC, Type::Int64Ty);
GEP1Ops[FirstConstantOper] = G1OC;
GEP2Ops[FirstConstantOper] = G2OC;
}
diff --git a/lib/Analysis/ConstantFolding.cpp b/lib/Analysis/ConstantFolding.cpp
index b3c8a77..1f034e9 100644
--- a/lib/Analysis/ConstantFolding.cpp
+++ b/lib/Analysis/ConstantFolding.cpp
@@ -152,7 +152,7 @@
uint64_t Offset = TD->getIndexedOffset(Ptr->getType(),
(Value**)Ops+1, NumOps-1);
Constant *C = ConstantInt::get(TD->getIntPtrType(), Offset+BasePtr);
- return Context.getConstantExprIntToPtr(C, ResultTy);
+ return ConstantExpr::getIntToPtr(C, ResultTy);
}
/// FoldBitCast - Constant fold bitcast, symbolically evaluating it with
@@ -191,7 +191,7 @@
if (!C) return 0;
// Finally, VMCore can handle this now that #elts line up.
- return Context.getConstantExprBitCast(C, DestTy);
+ return ConstantExpr::getBitCast(C, DestTy);
}
// Okay, we know the destination is integer, if the input is FP, convert
@@ -201,7 +201,7 @@
const Type *SrcIVTy = Context.getVectorType(
Context.getIntegerType(FPWidth), NumSrcElt);
// Ask VMCore to do the conversion now that #elts line up.
- C = Context.getConstantExprBitCast(C, SrcIVTy);
+ C = ConstantExpr::getBitCast(C, SrcIVTy);
CV = dyn_cast<ConstantVector>(C);
if (!CV) return 0; // If VMCore wasn't able to fold it, bail out.
}
@@ -228,15 +228,15 @@
if (!Src) return 0; // Reject constantexpr elements.
// Zero extend the element to the right size.
- Src = Context.getConstantExprZExt(Src, Elt->getType());
+ Src = ConstantExpr::getZExt(Src, Elt->getType());
// Shift it to the right place, depending on endianness.
- Src = Context.getConstantExprShl(Src,
+ Src = ConstantExpr::getShl(Src,
ConstantInt::get(Src->getType(), ShiftAmt));
ShiftAmt += isLittleEndian ? SrcBitSize : -SrcBitSize;
// Mix it in.
- Elt = Context.getConstantExprOr(Elt, Src);
+ Elt = ConstantExpr::getOr(Elt, Src);
}
Result.push_back(Elt);
}
@@ -254,12 +254,12 @@
for (unsigned j = 0; j != Ratio; ++j) {
// Shift the piece of the value into the right place, depending on
// endianness.
- Constant *Elt = Context.getConstantExprLShr(Src,
+ Constant *Elt = ConstantExpr::getLShr(Src,
ConstantInt::get(Src->getType(), ShiftAmt));
ShiftAmt += isLittleEndian ? DstBitSize : -DstBitSize;
// Truncate and remember this piece.
- Result.push_back(Context.getConstantExprTrunc(Elt, DstEltTy));
+ Result.push_back(ConstantExpr::getTrunc(Elt, DstEltTy));
}
}
}
@@ -354,7 +354,7 @@
Context))
return C;
- return Context.getConstantExpr(Opcode, Ops[0], Ops[1]);
+ return ConstantExpr::get(Opcode, Ops[0], Ops[1]);
}
switch (Opcode) {
@@ -378,13 +378,13 @@
Constant *Mask =
ConstantInt::get(Context, APInt::getLowBitsSet(InWidth,
TD->getPointerSizeInBits()));
- Input = Context.getConstantExprAnd(Input, Mask);
+ Input = ConstantExpr::getAnd(Input, Mask);
}
// Do a zext or trunc to get to the dest size.
- return Context.getConstantExprIntegerCast(Input, DestTy, false);
+ return ConstantExpr::getIntegerCast(Input, DestTy, false);
}
}
- return Context.getConstantExprCast(Opcode, Ops[0], DestTy);
+ return ConstantExpr::getCast(Opcode, Ops[0], DestTy);
case Instruction::IntToPtr:
// If the input is a ptrtoint, turn the pair into a ptr to ptr bitcast if
// the int size is >= the ptr size. This requires knowing the width of a
@@ -396,7 +396,7 @@
if (CE->getOpcode() == Instruction::PtrToInt) {
Constant *Input = CE->getOperand(0);
Constant *C = FoldBitCast(Input, DestTy, *TD, Context);
- return C ? C : Context.getConstantExprBitCast(Input, DestTy);
+ return C ? C : ConstantExpr::getBitCast(Input, DestTy);
}
// If there's a constant offset added to the integer value before
// it is casted back to a pointer, see if the expression can be
@@ -423,14 +423,14 @@
ConstantInt::get(Context, ElemIdx)
};
return
- Context.getConstantExprGetElementPtr(GV, &Index[0], 2);
+ ConstantExpr::getGetElementPtr(GV, &Index[0], 2);
}
}
}
}
}
}
- return Context.getConstantExprCast(Opcode, Ops[0], DestTy);
+ return ConstantExpr::getCast(Opcode, Ops[0], DestTy);
case Instruction::Trunc:
case Instruction::ZExt:
case Instruction::SExt:
@@ -440,25 +440,25 @@
case Instruction::SIToFP:
case Instruction::FPToUI:
case Instruction::FPToSI:
- return Context.getConstantExprCast(Opcode, Ops[0], DestTy);
+ return ConstantExpr::getCast(Opcode, Ops[0], DestTy);
case Instruction::BitCast:
if (TD)
if (Constant *C = FoldBitCast(Ops[0], DestTy, *TD, Context))
return C;
- return Context.getConstantExprBitCast(Ops[0], DestTy);
+ return ConstantExpr::getBitCast(Ops[0], DestTy);
case Instruction::Select:
- return Context.getConstantExprSelect(Ops[0], Ops[1], Ops[2]);
+ return ConstantExpr::getSelect(Ops[0], Ops[1], Ops[2]);
case Instruction::ExtractElement:
- return Context.getConstantExprExtractElement(Ops[0], Ops[1]);
+ return ConstantExpr::getExtractElement(Ops[0], Ops[1]);
case Instruction::InsertElement:
- return Context.getConstantExprInsertElement(Ops[0], Ops[1], Ops[2]);
+ return ConstantExpr::getInsertElement(Ops[0], Ops[1], Ops[2]);
case Instruction::ShuffleVector:
- return Context.getConstantExprShuffleVector(Ops[0], Ops[1], Ops[2]);
+ return ConstantExpr::getShuffleVector(Ops[0], Ops[1], Ops[2]);
case Instruction::GetElementPtr:
if (Constant *C = SymbolicallyEvaluateGEP(Ops, NumOps, DestTy, Context, TD))
return C;
- return Context.getConstantExprGetElementPtr(Ops[0], Ops+1, NumOps-1);
+ return ConstantExpr::getGetElementPtr(Ops[0], Ops+1, NumOps-1);
}
}
@@ -484,7 +484,7 @@
if (CE0->getOpcode() == Instruction::IntToPtr) {
// Convert the integer value to the right size to ensure we get the
// proper extension or truncation.
- Constant *C = Context.getConstantExprIntegerCast(CE0->getOperand(0),
+ Constant *C = ConstantExpr::getIntegerCast(CE0->getOperand(0),
IntPtrTy, false);
Constant *NewOps[] = { C, Context.getNullValue(C->getType()) };
return ConstantFoldCompareInstOperands(Predicate, NewOps, 2,
@@ -510,9 +510,9 @@
if (CE0->getOpcode() == Instruction::IntToPtr) {
// Convert the integer value to the right size to ensure we get the
// proper extension or truncation.
- Constant *C0 = Context.getConstantExprIntegerCast(CE0->getOperand(0),
+ Constant *C0 = ConstantExpr::getIntegerCast(CE0->getOperand(0),
IntPtrTy, false);
- Constant *C1 = Context.getConstantExprIntegerCast(CE1->getOperand(0),
+ Constant *C1 = ConstantExpr::getIntegerCast(CE1->getOperand(0),
IntPtrTy, false);
Constant *NewOps[] = { C0, C1 };
return ConstantFoldCompareInstOperands(Predicate, NewOps, 2,
@@ -533,7 +533,7 @@
}
}
}
- return Context.getConstantExprCompare(Predicate, Ops[0], Ops[1]);
+ return ConstantExpr::getCompare(Predicate, Ops[0], Ops[1]);
}
diff --git a/lib/Analysis/DebugInfo.cpp b/lib/Analysis/DebugInfo.cpp
index 7ecb1ad..3db7ff9 100644
--- a/lib/Analysis/DebugInfo.cpp
+++ b/lib/Analysis/DebugInfo.cpp
@@ -477,7 +477,7 @@
/// This is only valid when the descriptor is non-null.
Constant *DIFactory::getCastToEmpty(DIDescriptor D) {
if (D.isNull()) return VMContext.getNullValue(EmptyStructPtr);
- return VMContext.getConstantExprBitCast(D.getGV(), EmptyStructPtr);
+ return ConstantExpr::getBitCast(D.getGV(), EmptyStructPtr);
}
Constant *DIFactory::GetTagConstant(unsigned TAG) {
@@ -507,7 +507,7 @@
GlobalVariable::InternalLinkage,
ConstStr, ".str");
StrGV->setSection("llvm.metadata");
- return Slot = VMContext.getConstantExprBitCast(StrGV, DestTy);
+ return Slot = ConstantExpr::getBitCast(StrGV, DestTy);
}
//===----------------------------------------------------------------------===//
@@ -779,7 +779,7 @@
getCastToEmpty(Type),
ConstantInt::get(Type::Int1Ty, isLocalToUnit),
ConstantInt::get(Type::Int1Ty, isDefinition),
- VMContext.getConstantExprBitCast(Val, EmptyStructPtr)
+ ConstantExpr::getBitCast(Val, EmptyStructPtr)
};
Constant *Init = ConstantStruct::get(Elts, sizeof(Elts)/sizeof(Elts[0]));
diff --git a/lib/Analysis/ScalarEvolution.cpp b/lib/Analysis/ScalarEvolution.cpp
index 721fe93..3bf5e70 100644
--- a/lib/Analysis/ScalarEvolution.cpp
+++ b/lib/Analysis/ScalarEvolution.cpp
@@ -1694,7 +1694,7 @@
if (const SCEVConstant *LHSC = dyn_cast<SCEVConstant>(LHS)) {
Constant *LHSCV = LHSC->getValue();
Constant *RHSCV = RHSC->getValue();
- return getConstant(cast<ConstantInt>(getContext().getConstantExprUDiv(LHSCV,
+ return getConstant(cast<ConstantInt>(ConstantExpr::getUDiv(LHSCV,
RHSCV)));
}
}
@@ -2095,7 +2095,7 @@
const SCEV *ScalarEvolution::getNegativeSCEV(const SCEV *V) {
if (const SCEVConstant *VC = dyn_cast<SCEVConstant>(V))
return getConstant(
- cast<ConstantInt>(getContext().getConstantExprNeg(VC->getValue())));
+ cast<ConstantInt>(ConstantExpr::getNeg(VC->getValue())));
const Type *Ty = V->getType();
Ty = getEffectiveSCEVType(Ty);
@@ -2107,7 +2107,7 @@
const SCEV *ScalarEvolution::getNotSCEV(const SCEV *V) {
if (const SCEVConstant *VC = dyn_cast<SCEVConstant>(V))
return getConstant(
- cast<ConstantInt>(getContext().getConstantExprNot(VC->getValue())));
+ cast<ConstantInt>(ConstantExpr::getNot(VC->getValue())));
const Type *Ty = V->getType();
Ty = getEffectiveSCEVType(Ty);
@@ -4130,7 +4130,7 @@
#endif
// Pick the smallest positive root value.
if (ConstantInt *CB =
- dyn_cast<ConstantInt>(getContext().getConstantExprICmp(ICmpInst::ICMP_ULT,
+ dyn_cast<ConstantInt>(ConstantExpr::getICmp(ICmpInst::ICMP_ULT,
R1->getValue(), R2->getValue()))) {
if (CB->getZExtValue() == false)
std::swap(R1, R2); // R1 is the minimum root now.
@@ -4856,8 +4856,7 @@
if (R1) {
// Pick the smallest positive root value.
if (ConstantInt *CB =
- dyn_cast<ConstantInt>(
- SE.getContext().getConstantExprICmp(ICmpInst::ICMP_ULT,
+ dyn_cast<ConstantInt>(ConstantExpr::getICmp(ICmpInst::ICMP_ULT,
R1->getValue(), R2->getValue()))) {
if (CB->getZExtValue() == false)
std::swap(R1, R2); // R1 is the minimum root now.
diff --git a/lib/Analysis/ScalarEvolutionExpander.cpp b/lib/Analysis/ScalarEvolutionExpander.cpp
index e098ea2..b6c30fb 100644
--- a/lib/Analysis/ScalarEvolutionExpander.cpp
+++ b/lib/Analysis/ScalarEvolutionExpander.cpp
@@ -55,7 +55,7 @@
// FIXME: keep track of the cast instruction.
if (Constant *C = dyn_cast<Constant>(V))
- return getContext().getConstantExprCast(Op, C, Ty);
+ return ConstantExpr::getCast(Op, C, Ty);
if (Argument *A = dyn_cast<Argument>(V)) {
// Check to see if there is already a cast!
@@ -126,7 +126,7 @@
// Fold a binop with constant operands.
if (Constant *CLHS = dyn_cast<Constant>(LHS))
if (Constant *CRHS = dyn_cast<Constant>(RHS))
- return getContext().getConstantExpr(Opcode, CLHS, CRHS);
+ return ConstantExpr::get(Opcode, CLHS, CRHS);
// Do a quick scan to see if we have this binop nearby. If so, reuse it.
unsigned ScanLimit = 6;
@@ -327,7 +327,7 @@
// Fold a GEP with constant operands.
if (Constant *CLHS = dyn_cast<Constant>(V))
if (Constant *CRHS = dyn_cast<Constant>(Idx))
- return getContext().getConstantExprGetElementPtr(CLHS, &CRHS, 1);
+ return ConstantExpr::getGetElementPtr(CLHS, &CRHS, 1);
// Do a quick scan to see if we have this GEP nearby. If so, reuse it.
unsigned ScanLimit = 6;