aboutsummaryrefslogtreecommitdiffstats
path: root/lib/VMCore
diff options
context:
space:
mode:
authorOwen Anderson <resistor@mac.com>2009-07-29 18:55:55 +0000
committerOwen Anderson <resistor@mac.com>2009-07-29 18:55:55 +0000
commitbaf3c404409d5e47b13984a7f95bfbd6d1f2e79e (patch)
treec06618ee06936e7f5a1dc3c30b313ee49d5eb09b /lib/VMCore
parent26ef510d5d20b89c637d13e2d9169c0458de775c (diff)
downloadexternal_llvm-baf3c404409d5e47b13984a7f95bfbd6d1f2e79e.zip
external_llvm-baf3c404409d5e47b13984a7f95bfbd6d1f2e79e.tar.gz
external_llvm-baf3c404409d5e47b13984a7f95bfbd6d1f2e79e.tar.bz2
Move ConstantExpr to 2.5 API.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@77494 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/VMCore')
-rw-r--r--lib/VMCore/ConstantFold.cpp88
-rw-r--r--lib/VMCore/Constants.cpp121
-rw-r--r--lib/VMCore/Core.cpp80
-rw-r--r--lib/VMCore/LLVMContext.cpp264
-rw-r--r--lib/VMCore/LLVMContextImpl.h1
-rw-r--r--lib/VMCore/Module.cpp4
6 files changed, 207 insertions, 351 deletions
diff --git a/lib/VMCore/ConstantFold.cpp b/lib/VMCore/ConstantFold.cpp
index 2fdf08d..440fb88 100644
--- a/lib/VMCore/ConstantFold.cpp
+++ b/lib/VMCore/ConstantFold.cpp
@@ -61,7 +61,7 @@ static Constant *BitCastConstantVector(LLVMContext &Context, ConstantVector *CV,
std::vector<Constant*> Result;
const Type *DstEltTy = DstTy->getElementType();
for (unsigned i = 0; i != NumElts; ++i)
- Result.push_back(Context.getConstantExprBitCast(CV->getOperand(i),
+ Result.push_back(ConstantExpr::getBitCast(CV->getOperand(i),
DstEltTy));
return ConstantVector::get(Result);
}
@@ -121,7 +121,7 @@ static Constant *FoldBitCast(LLVMContext &Context,
}
if (ElTy == DPTy->getElementType())
- return Context.getConstantExprGetElementPtr(V, &IdxList[0],
+ return ConstantExpr::getGetElementPtr(V, &IdxList[0],
IdxList.size());
}
@@ -144,7 +144,7 @@ static Constant *FoldBitCast(LLVMContext &Context,
// This allows for other simplifications (although some of them
// can only be handled by Analysis/ConstantFolding.cpp).
if (isa<ConstantInt>(V) || isa<ConstantFP>(V))
- return Context.getConstantExprBitCast(
+ return ConstantExpr::getBitCast(
ConstantVector::get(&V, 1), DestPTy);
}
@@ -199,7 +199,7 @@ Constant *llvm::ConstantFoldCastInstruction(LLVMContext &Context,
if (CE->isCast()) {
// Try hard to fold cast of cast because they are often eliminable.
if (unsigned newOpc = foldConstantCastPair(opc, CE, DestTy))
- return Context.getConstantExprCast(newOpc, CE->getOperand(0), DestTy);
+ return ConstantExpr::getCast(newOpc, CE->getOperand(0), DestTy);
} else if (CE->getOpcode() == Instruction::GetElementPtr) {
// If all of the indexes in the GEP are null values, there is no pointer
// adjustment going on. We might as well cast the source pointer.
@@ -211,7 +211,7 @@ Constant *llvm::ConstantFoldCastInstruction(LLVMContext &Context,
}
if (isAllNull)
// This is casting one pointer type to another, always BitCast
- return Context.getConstantExprPointerCast(CE->getOperand(0), DestTy);
+ return ConstantExpr::getPointerCast(CE->getOperand(0), DestTy);
}
}
@@ -226,7 +226,7 @@ Constant *llvm::ConstantFoldCastInstruction(LLVMContext &Context,
const VectorType *DestVecTy = cast<VectorType>(DestTy);
const Type *DstEltTy = DestVecTy->getElementType();
for (unsigned i = 0, e = CV->getType()->getNumElements(); i != e; ++i)
- res.push_back(Context.getConstantExprCast(opc,
+ res.push_back(ConstantExpr::getCast(opc,
CV->getOperand(i), DstEltTy));
return ConstantVector::get(DestVecTy, res);
}
@@ -705,7 +705,7 @@ Constant *llvm::ConstantFoldBinaryInstruction(LLVMContext &Context,
// ashr (zext C to Ty), C2 -> lshr (zext C, CSA), C2
if (const ConstantExpr *CE1 = dyn_cast<ConstantExpr>(C1))
if (CE1->getOpcode() == Instruction::ZExt) // Top bits known zero.
- return Context.getConstantExprLShr(const_cast<Constant*>(C1),
+ return ConstantExpr::getLShr(const_cast<Constant*>(C1),
const_cast<Constant*>(C2));
break;
}
@@ -826,7 +826,7 @@ Constant *llvm::ConstantFoldBinaryInstruction(LLVMContext &Context,
for (unsigned i = 0, e = VTy->getNumElements(); i != e; ++i) {
C1 = CP1 ? CP1->getOperand(i) : Context.getNullValue(EltTy);
C2 = CP2 ? CP2->getOperand(i) : Context.getNullValue(EltTy);
- Res.push_back(Context.getConstantExprAdd(const_cast<Constant*>(C1),
+ Res.push_back(ConstantExpr::getAdd(const_cast<Constant*>(C1),
const_cast<Constant*>(C2)));
}
return ConstantVector::get(Res);
@@ -834,7 +834,7 @@ Constant *llvm::ConstantFoldBinaryInstruction(LLVMContext &Context,
for (unsigned i = 0, e = VTy->getNumElements(); i != e; ++i) {
C1 = CP1 ? CP1->getOperand(i) : Context.getNullValue(EltTy);
C2 = CP2 ? CP2->getOperand(i) : Context.getNullValue(EltTy);
- Res.push_back(Context.getConstantExprFAdd(const_cast<Constant*>(C1),
+ Res.push_back(ConstantExpr::getFAdd(const_cast<Constant*>(C1),
const_cast<Constant*>(C2)));
}
return ConstantVector::get(Res);
@@ -842,7 +842,7 @@ Constant *llvm::ConstantFoldBinaryInstruction(LLVMContext &Context,
for (unsigned i = 0, e = VTy->getNumElements(); i != e; ++i) {
C1 = CP1 ? CP1->getOperand(i) : Context.getNullValue(EltTy);
C2 = CP2 ? CP2->getOperand(i) : Context.getNullValue(EltTy);
- Res.push_back(Context.getConstantExprSub(const_cast<Constant*>(C1),
+ Res.push_back(ConstantExpr::getSub(const_cast<Constant*>(C1),
const_cast<Constant*>(C2)));
}
return ConstantVector::get(Res);
@@ -850,7 +850,7 @@ Constant *llvm::ConstantFoldBinaryInstruction(LLVMContext &Context,
for (unsigned i = 0, e = VTy->getNumElements(); i != e; ++i) {
C1 = CP1 ? CP1->getOperand(i) : Context.getNullValue(EltTy);
C2 = CP2 ? CP2->getOperand(i) : Context.getNullValue(EltTy);
- Res.push_back(Context.getConstantExprFSub(const_cast<Constant*>(C1),
+ Res.push_back(ConstantExpr::getFSub(const_cast<Constant*>(C1),
const_cast<Constant*>(C2)));
}
return ConstantVector::get(Res);
@@ -858,7 +858,7 @@ Constant *llvm::ConstantFoldBinaryInstruction(LLVMContext &Context,
for (unsigned i = 0, e = VTy->getNumElements(); i != e; ++i) {
C1 = CP1 ? CP1->getOperand(i) : Context.getNullValue(EltTy);
C2 = CP2 ? CP2->getOperand(i) : Context.getNullValue(EltTy);
- Res.push_back(Context.getConstantExprMul(const_cast<Constant*>(C1),
+ Res.push_back(ConstantExpr::getMul(const_cast<Constant*>(C1),
const_cast<Constant*>(C2)));
}
return ConstantVector::get(Res);
@@ -866,7 +866,7 @@ Constant *llvm::ConstantFoldBinaryInstruction(LLVMContext &Context,
for (unsigned i = 0, e = VTy->getNumElements(); i != e; ++i) {
C1 = CP1 ? CP1->getOperand(i) : Context.getNullValue(EltTy);
C2 = CP2 ? CP2->getOperand(i) : Context.getNullValue(EltTy);
- Res.push_back(Context.getConstantExprFMul(const_cast<Constant*>(C1),
+ Res.push_back(ConstantExpr::getFMul(const_cast<Constant*>(C1),
const_cast<Constant*>(C2)));
}
return ConstantVector::get(Res);
@@ -874,7 +874,7 @@ Constant *llvm::ConstantFoldBinaryInstruction(LLVMContext &Context,
for (unsigned i = 0, e = VTy->getNumElements(); i != e; ++i) {
C1 = CP1 ? CP1->getOperand(i) : Context.getNullValue(EltTy);
C2 = CP2 ? CP2->getOperand(i) : Context.getNullValue(EltTy);
- Res.push_back(Context.getConstantExprUDiv(const_cast<Constant*>(C1),
+ Res.push_back(ConstantExpr::getUDiv(const_cast<Constant*>(C1),
const_cast<Constant*>(C2)));
}
return ConstantVector::get(Res);
@@ -882,7 +882,7 @@ Constant *llvm::ConstantFoldBinaryInstruction(LLVMContext &Context,
for (unsigned i = 0, e = VTy->getNumElements(); i != e; ++i) {
C1 = CP1 ? CP1->getOperand(i) : Context.getNullValue(EltTy);
C2 = CP2 ? CP2->getOperand(i) : Context.getNullValue(EltTy);
- Res.push_back(Context.getConstantExprSDiv(const_cast<Constant*>(C1),
+ Res.push_back(ConstantExpr::getSDiv(const_cast<Constant*>(C1),
const_cast<Constant*>(C2)));
}
return ConstantVector::get(Res);
@@ -890,7 +890,7 @@ Constant *llvm::ConstantFoldBinaryInstruction(LLVMContext &Context,
for (unsigned i = 0, e = VTy->getNumElements(); i != e; ++i) {
C1 = CP1 ? CP1->getOperand(i) : Context.getNullValue(EltTy);
C2 = CP2 ? CP2->getOperand(i) : Context.getNullValue(EltTy);
- Res.push_back(Context.getConstantExprFDiv(const_cast<Constant*>(C1),
+ Res.push_back(ConstantExpr::getFDiv(const_cast<Constant*>(C1),
const_cast<Constant*>(C2)));
}
return ConstantVector::get(Res);
@@ -898,7 +898,7 @@ Constant *llvm::ConstantFoldBinaryInstruction(LLVMContext &Context,
for (unsigned i = 0, e = VTy->getNumElements(); i != e; ++i) {
C1 = CP1 ? CP1->getOperand(i) : Context.getNullValue(EltTy);
C2 = CP2 ? CP2->getOperand(i) : Context.getNullValue(EltTy);
- Res.push_back(Context.getConstantExprURem(const_cast<Constant*>(C1),
+ Res.push_back(ConstantExpr::getURem(const_cast<Constant*>(C1),
const_cast<Constant*>(C2)));
}
return ConstantVector::get(Res);
@@ -906,7 +906,7 @@ Constant *llvm::ConstantFoldBinaryInstruction(LLVMContext &Context,
for (unsigned i = 0, e = VTy->getNumElements(); i != e; ++i) {
C1 = CP1 ? CP1->getOperand(i) : Context.getNullValue(EltTy);
C2 = CP2 ? CP2->getOperand(i) : Context.getNullValue(EltTy);
- Res.push_back(Context.getConstantExprSRem(const_cast<Constant*>(C1),
+ Res.push_back(ConstantExpr::getSRem(const_cast<Constant*>(C1),
const_cast<Constant*>(C2)));
}
return ConstantVector::get(Res);
@@ -914,7 +914,7 @@ Constant *llvm::ConstantFoldBinaryInstruction(LLVMContext &Context,
for (unsigned i = 0, e = VTy->getNumElements(); i != e; ++i) {
C1 = CP1 ? CP1->getOperand(i) : Context.getNullValue(EltTy);
C2 = CP2 ? CP2->getOperand(i) : Context.getNullValue(EltTy);
- Res.push_back(Context.getConstantExprFRem(const_cast<Constant*>(C1),
+ Res.push_back(ConstantExpr::getFRem(const_cast<Constant*>(C1),
const_cast<Constant*>(C2)));
}
return ConstantVector::get(Res);
@@ -922,7 +922,7 @@ Constant *llvm::ConstantFoldBinaryInstruction(LLVMContext &Context,
for (unsigned i = 0, e = VTy->getNumElements(); i != e; ++i) {
C1 = CP1 ? CP1->getOperand(i) : Context.getNullValue(EltTy);
C2 = CP2 ? CP2->getOperand(i) : Context.getNullValue(EltTy);
- Res.push_back(Context.getConstantExprAnd(const_cast<Constant*>(C1),
+ Res.push_back(ConstantExpr::getAnd(const_cast<Constant*>(C1),
const_cast<Constant*>(C2)));
}
return ConstantVector::get(Res);
@@ -930,7 +930,7 @@ Constant *llvm::ConstantFoldBinaryInstruction(LLVMContext &Context,
for (unsigned i = 0, e = VTy->getNumElements(); i != e; ++i) {
C1 = CP1 ? CP1->getOperand(i) : Context.getNullValue(EltTy);
C2 = CP2 ? CP2->getOperand(i) : Context.getNullValue(EltTy);
- Res.push_back(Context.getConstantExprOr(const_cast<Constant*>(C1),
+ Res.push_back(ConstantExpr::getOr(const_cast<Constant*>(C1),
const_cast<Constant*>(C2)));
}
return ConstantVector::get(Res);
@@ -938,7 +938,7 @@ Constant *llvm::ConstantFoldBinaryInstruction(LLVMContext &Context,
for (unsigned i = 0, e = VTy->getNumElements(); i != e; ++i) {
C1 = CP1 ? CP1->getOperand(i) : Context.getNullValue(EltTy);
C2 = CP2 ? CP2->getOperand(i) : Context.getNullValue(EltTy);
- Res.push_back(Context.getConstantExprXor(const_cast<Constant*>(C1),
+ Res.push_back(ConstantExpr::getXor(const_cast<Constant*>(C1),
const_cast<Constant*>(C2)));
}
return ConstantVector::get(Res);
@@ -946,7 +946,7 @@ Constant *llvm::ConstantFoldBinaryInstruction(LLVMContext &Context,
for (unsigned i = 0, e = VTy->getNumElements(); i != e; ++i) {
C1 = CP1 ? CP1->getOperand(i) : Context.getNullValue(EltTy);
C2 = CP2 ? CP2->getOperand(i) : Context.getNullValue(EltTy);
- Res.push_back(Context.getConstantExprLShr(const_cast<Constant*>(C1),
+ Res.push_back(ConstantExpr::getLShr(const_cast<Constant*>(C1),
const_cast<Constant*>(C2)));
}
return ConstantVector::get(Res);
@@ -954,7 +954,7 @@ Constant *llvm::ConstantFoldBinaryInstruction(LLVMContext &Context,
for (unsigned i = 0, e = VTy->getNumElements(); i != e; ++i) {
C1 = CP1 ? CP1->getOperand(i) : Context.getNullValue(EltTy);
C2 = CP2 ? CP2->getOperand(i) : Context.getNullValue(EltTy);
- Res.push_back(Context.getConstantExprAShr(const_cast<Constant*>(C1),
+ Res.push_back(ConstantExpr::getAShr(const_cast<Constant*>(C1),
const_cast<Constant*>(C2)));
}
return ConstantVector::get(Res);
@@ -962,7 +962,7 @@ Constant *llvm::ConstantFoldBinaryInstruction(LLVMContext &Context,
for (unsigned i = 0, e = VTy->getNumElements(); i != e; ++i) {
C1 = CP1 ? CP1->getOperand(i) : Context.getNullValue(EltTy);
C2 = CP2 ? CP2->getOperand(i) : Context.getNullValue(EltTy);
- Res.push_back(Context.getConstantExprShl(const_cast<Constant*>(C1),
+ Res.push_back(ConstantExpr::getShl(const_cast<Constant*>(C1),
const_cast<Constant*>(C2)));
}
return ConstantVector::get(Res);
@@ -1044,10 +1044,10 @@ static int IdxCompare(LLVMContext &Context, Constant *C1, Constant *C2,
// Ok, we have two differing integer indices. Sign extend them to be the same
// type. Long is always big enough, so we use it.
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);
if (C1 == C2) return 0; // They are equal
@@ -1096,15 +1096,15 @@ static FCmpInst::Predicate evaluateFCmpRelation(LLVMContext &Context,
Constant *C1 = const_cast<Constant*>(V1);
Constant *C2 = const_cast<Constant*>(V2);
R = dyn_cast<ConstantInt>(
- Context.getConstantExprFCmp(FCmpInst::FCMP_OEQ, C1, C2));
+ ConstantExpr::getFCmp(FCmpInst::FCMP_OEQ, C1, C2));
if (R && !R->isZero())
return FCmpInst::FCMP_OEQ;
R = dyn_cast<ConstantInt>(
- Context.getConstantExprFCmp(FCmpInst::FCMP_OLT, C1, C2));
+ ConstantExpr::getFCmp(FCmpInst::FCMP_OLT, C1, C2));
if (R && !R->isZero())
return FCmpInst::FCMP_OLT;
R = dyn_cast<ConstantInt>(
- Context.getConstantExprFCmp(FCmpInst::FCMP_OGT, C1, C2));
+ ConstantExpr::getFCmp(FCmpInst::FCMP_OGT, C1, C2));
if (R && !R->isZero())
return FCmpInst::FCMP_OGT;
@@ -1164,15 +1164,15 @@ static ICmpInst::Predicate evaluateICmpRelation(LLVMContext &Context,
Constant *C1 = const_cast<Constant*>(V1);
Constant *C2 = const_cast<Constant*>(V2);
ICmpInst::Predicate pred = ICmpInst::ICMP_EQ;
- R = dyn_cast<ConstantInt>(Context.getConstantExprICmp(pred, C1, C2));
+ R = dyn_cast<ConstantInt>(ConstantExpr::getICmp(pred, C1, C2));
if (R && !R->isZero())
return pred;
pred = isSigned ? ICmpInst::ICMP_SLT : ICmpInst::ICMP_ULT;
- R = dyn_cast<ConstantInt>(Context.getConstantExprICmp(pred, C1, C2));
+ R = dyn_cast<ConstantInt>(ConstantExpr::getICmp(pred, C1, C2));
if (R && !R->isZero())
return pred;
pred = isSigned ? ICmpInst::ICMP_SGT : ICmpInst::ICMP_UGT;
- R = dyn_cast<ConstantInt>(Context.getConstantExprICmp(pred, C1, C2));
+ R = dyn_cast<ConstantInt>(ConstantExpr::getICmp(pred, C1, C2));
if (R && !R->isZero())
return pred;
@@ -1494,7 +1494,7 @@ Constant *llvm::ConstantFoldCompareInstruction(LLVMContext &Context,
for (unsigned i = 0, e = C1Elts.size(); i != e; ++i) {
// Compare the elements, producing an i1 result or constant expr.
ResElts.push_back(
- Context.getConstantExprCompare(pred, C1Elts[i], C2Elts[i]));
+ ConstantExpr::getCompare(pred, C1Elts[i], C2Elts[i]));
}
return ConstantVector::get(&ResElts[0], ResElts.size());
}
@@ -1724,19 +1724,19 @@ Constant *llvm::ConstantFoldGetElementPtr(LLVMContext &Context,
const Type *IdxTy = Combined->getType();
if (IdxTy != Idx0->getType()) {
Constant *C1 =
- Context.getConstantExprSExtOrBitCast(Idx0, Type::Int64Ty);
- Constant *C2 = Context.getConstantExprSExtOrBitCast(Combined,
+ ConstantExpr::getSExtOrBitCast(Idx0, Type::Int64Ty);
+ Constant *C2 = ConstantExpr::getSExtOrBitCast(Combined,
Type::Int64Ty);
- Combined = Context.getConstantExpr(Instruction::Add, C1, C2);
+ Combined = ConstantExpr::get(Instruction::Add, C1, C2);
} else {
Combined =
- Context.getConstantExpr(Instruction::Add, Idx0, Combined);
+ ConstantExpr::get(Instruction::Add, Idx0, Combined);
}
}
NewIndices.push_back(Combined);
NewIndices.insert(NewIndices.end(), Idxs+1, Idxs+NumIdx);
- return Context.getConstantExprGetElementPtr(CE->getOperand(0),
+ return ConstantExpr::getGetElementPtr(CE->getOperand(0),
&NewIndices[0],
NewIndices.size());
}
@@ -1754,7 +1754,7 @@ Constant *llvm::ConstantFoldGetElementPtr(LLVMContext &Context,
if (const ArrayType *CAT =
dyn_cast<ArrayType>(cast<PointerType>(C->getType())->getElementType()))
if (CAT->getElementType() == SAT->getElementType())
- return Context.getConstantExprGetElementPtr(
+ return ConstantExpr::getGetElementPtr(
(Constant*)CE->getOperand(0), Idxs, NumIdx);
}
@@ -1770,13 +1770,13 @@ Constant *llvm::ConstantFoldGetElementPtr(LLVMContext &Context,
// Convert the smaller integer to the larger type.
if (Offset->getType()->getPrimitiveSizeInBits() <
Base->getType()->getPrimitiveSizeInBits())
- Offset = Context.getConstantExprSExt(Offset, Base->getType());
+ Offset = ConstantExpr::getSExt(Offset, Base->getType());
else if (Base->getType()->getPrimitiveSizeInBits() <
Offset->getType()->getPrimitiveSizeInBits())
- Base = Context.getConstantExprZExt(Base, Offset->getType());
+ Base = ConstantExpr::getZExt(Base, Offset->getType());
- Base = Context.getConstantExprAdd(Base, Offset);
- return Context.getConstantExprIntToPtr(Base, CE->getType());
+ Base = ConstantExpr::getAdd(Base, Offset);
+ return ConstantExpr::getIntToPtr(Base, CE->getType());
}
}
return 0;
diff --git a/lib/VMCore/Constants.cpp b/lib/VMCore/Constants.cpp
index 92b76b9..6746882 100644
--- a/lib/VMCore/Constants.cpp
+++ b/lib/VMCore/Constants.cpp
@@ -1719,6 +1719,29 @@ Constant *ConstantExpr::get(unsigned Opcode, Constant *C1, Constant *C2) {
return getTy(C1->getType(), Opcode, C1, C2);
}
+Constant* ConstantExpr::getSizeOf(const Type* Ty) {
+ // sizeof is implemented as: (i64) gep (Ty*)null, 1
+ // Note that a non-inbounds gep is used, as null isn't within any object.
+ LLVMContext &Context = Ty->getContext();
+ Constant *GEPIdx = ConstantInt::get(Type::Int32Ty, 1);
+ Constant *GEP = getGetElementPtr(
+ Context.getNullValue(PointerType::getUnqual(Ty)), &GEPIdx, 1);
+ return getCast(Instruction::PtrToInt, GEP, Type::Int64Ty);
+}
+
+Constant* ConstantExpr::getAlignOf(const Type* Ty) {
+ LLVMContext &Context = Ty->getContext();
+ // alignof is implemented as: (i64) gep ({i8,Ty}*)null, 0, 1
+ const Type *AligningTy = StructType::get(Type::Int8Ty, Ty, NULL);
+ Constant *NullPtr = Context.getNullValue(AligningTy->getPointerTo());
+ Constant *Zero = ConstantInt::get(Type::Int32Ty, 0);
+ Constant *One = ConstantInt::get(Type::Int32Ty, 1);
+ Constant *Indices[2] = { Zero, One };
+ Constant *GEP = getGetElementPtr(NullPtr, Indices, 2);
+ return getCast(Instruction::PtrToInt, GEP, Type::Int32Ty);
+}
+
+
Constant *ConstantExpr::getCompare(unsigned short pred,
Constant *C1, Constant *C2) {
assert(C1->getType() == C2->getType() && "Op types should be identical!");
@@ -1955,6 +1978,104 @@ Constant *ConstantExpr::getExtractValue(Constant *Agg,
return getExtractValueTy(ReqTy, Agg, IdxList, NumIdx);
}
+Constant* ConstantExpr::getNeg(Constant* C) {
+ // API compatibility: Adjust integer opcodes to floating-point opcodes.
+ if (C->getType()->isFPOrFPVector())
+ return getFNeg(C);
+ assert(C->getType()->isIntOrIntVector() &&
+ "Cannot NEG a nonintegral value!");
+ return get(Instruction::Sub,
+ ConstantFP::getZeroValueForNegation(C->getType()),
+ C);
+}
+
+Constant* ConstantExpr::getFNeg(Constant* C) {
+ assert(C->getType()->isFPOrFPVector() &&
+ "Cannot FNEG a non-floating-point value!");
+ return get(Instruction::FSub,
+ ConstantFP::getZeroValueForNegation(C->getType()),
+ C);
+}
+
+Constant* ConstantExpr::getNot(Constant* C) {
+ assert(C->getType()->isIntOrIntVector() &&
+ "Cannot NOT a nonintegral value!");
+ LLVMContext &Context = C->getType()->getContext();
+ return get(Instruction::Xor, C, Context.getAllOnesValue(C->getType()));
+}
+
+Constant* ConstantExpr::getAdd(Constant* C1, Constant* C2) {
+ return get(Instruction::Add, C1, C2);
+}
+
+Constant* ConstantExpr::getFAdd(Constant* C1, Constant* C2) {
+ return get(Instruction::FAdd, C1, C2);
+}
+
+Constant* ConstantExpr::getSub(Constant* C1, Constant* C2) {
+ return get(Instruction::Sub, C1, C2);
+}
+
+Constant* ConstantExpr::getFSub(Constant* C1, Constant* C2) {
+ return get(Instruction::FSub, C1, C2);
+}
+
+Constant* ConstantExpr::getMul(Constant* C1, Constant* C2) {
+ return get(Instruction::Mul, C1, C2);
+}
+
+Constant* ConstantExpr::getFMul(Constant* C1, Constant* C2) {
+ return get(Instruction::FMul, C1, C2);
+}
+
+Constant* ConstantExpr::getUDiv(Constant* C1, Constant* C2) {
+ return get(Instruction::UDiv, C1, C2);
+}
+
+Constant* ConstantExpr::getSDiv(Constant* C1, Constant* C2) {
+ return get(Instruction::SDiv, C1, C2);
+}
+
+Constant* ConstantExpr::getFDiv(Constant* C1, Constant* C2) {
+ return get(Instruction::FDiv, C1, C2);
+}
+
+Constant* ConstantExpr::getURem(Constant* C1, Constant* C2) {
+ return get(Instruction::URem, C1, C2);
+}
+
+Constant* ConstantExpr::getSRem(Constant* C1, Constant* C2) {
+ return get(Instruction::SRem, C1, C2);
+}
+
+Constant* ConstantExpr::getFRem(Constant* C1, Constant* C2) {
+ return get(Instruction::FRem, C1, C2);
+}
+
+Constant* ConstantExpr::getAnd(Constant* C1, Constant* C2) {
+ return get(Instruction::And, C1, C2);
+}
+
+Constant* ConstantExpr::getOr(Constant* C1, Constant* C2) {
+ return get(Instruction::Or, C1, C2);
+}
+
+Constant* ConstantExpr::getXor(Constant* C1, Constant* C2) {
+ return get(Instruction::Xor, C1, C2);
+}
+
+Constant* ConstantExpr::getShl(Constant* C1, Constant* C2) {
+ return get(Instruction::Shl, C1, C2);
+}
+
+Constant* ConstantExpr::getLShr(Constant* C1, Constant* C2) {
+ return get(Instruction::LShr, C1, C2);
+}
+
+Constant* ConstantExpr::getAShr(Constant* C1, Constant* C2) {
+ return get(Instruction::AShr, C1, C2);
+}
+
// destroyConstant - Remove the constant from the constant table...
//
void ConstantExpr::destroyConstant() {
diff --git a/lib/VMCore/Core.cpp b/lib/VMCore/Core.cpp
index d1e6fb2..bf5a6a1 100644
--- a/lib/VMCore/Core.cpp
+++ b/lib/VMCore/Core.cpp
@@ -428,130 +428,130 @@ LLVMValueRef LLVMConstVector(LLVMValueRef *ScalarConstantVals, unsigned Size) {
/*--.. Constant expressions ................................................--*/
LLVMValueRef LLVMAlignOf(LLVMTypeRef Ty) {
- return wrap(getGlobalContext().getConstantExprAlignOf(unwrap(Ty)));
+ return wrap(ConstantExpr::getAlignOf(unwrap(Ty)));
}
LLVMValueRef LLVMSizeOf(LLVMTypeRef Ty) {
- return wrap(getGlobalContext().getConstantExprSizeOf(unwrap(Ty)));
+ return wrap(ConstantExpr::getSizeOf(unwrap(Ty)));
}
LLVMValueRef LLVMConstNeg(LLVMValueRef ConstantVal) {
- return wrap(getGlobalContext().getConstantExprNeg(
+ return wrap(ConstantExpr::getNeg(
unwrap<Constant>(ConstantVal)));
}
LLVMValueRef LLVMConstNot(LLVMValueRef ConstantVal) {
- return wrap(getGlobalContext().getConstantExprNot(
+ return wrap(ConstantExpr::getNot(
unwrap<Constant>(ConstantVal)));
}
LLVMValueRef LLVMConstAdd(LLVMValueRef LHSConstant, LLVMValueRef RHSConstant) {
- return wrap(getGlobalContext().getConstantExprAdd(
+ return wrap(ConstantExpr::getAdd(
unwrap<Constant>(LHSConstant),
unwrap<Constant>(RHSConstant)));
}
LLVMValueRef LLVMConstSub(LLVMValueRef LHSConstant, LLVMValueRef RHSConstant) {
- return wrap(getGlobalContext().getConstantExprSub(
+ return wrap(ConstantExpr::getSub(
unwrap<Constant>(LHSConstant),
unwrap<Constant>(RHSConstant)));
}
LLVMValueRef LLVMConstMul(LLVMValueRef LHSConstant, LLVMValueRef RHSConstant) {
- return wrap(getGlobalContext().getConstantExprMul(
+ return wrap(ConstantExpr::getMul(
unwrap<Constant>(LHSConstant),
unwrap<Constant>(RHSConstant)));
}
LLVMValueRef LLVMConstUDiv(LLVMValueRef LHSConstant, LLVMValueRef RHSConstant) {
- return wrap(getGlobalContext().getConstantExprUDiv(
+ return wrap(ConstantExpr::getUDiv(
unwrap<Constant>(LHSConstant),
unwrap<Constant>(RHSConstant)));
}
LLVMValueRef LLVMConstSDiv(LLVMValueRef LHSConstant, LLVMValueRef RHSConstant) {
- return wrap(getGlobalContext().getConstantExprSDiv(
+ return wrap(ConstantExpr::getSDiv(
unwrap<Constant>(LHSConstant),
unwrap<Constant>(RHSConstant)));
}
LLVMValueRef LLVMConstFDiv(LLVMValueRef LHSConstant, LLVMValueRef RHSConstant) {
- return wrap(getGlobalContext().getConstantExprFDiv(
+ return wrap(ConstantExpr::getFDiv(
unwrap<Constant>(LHSConstant),
unwrap<Constant>(RHSConstant)));
}
LLVMValueRef LLVMConstURem(LLVMValueRef LHSConstant, LLVMValueRef RHSConstant) {
- return wrap(getGlobalContext().getConstantExprURem(
+ return wrap(ConstantExpr::getURem(
unwrap<Constant>(LHSConstant),
unwrap<Constant>(RHSConstant)));
}
LLVMValueRef LLVMConstSRem(LLVMValueRef LHSConstant, LLVMValueRef RHSConstant) {
- return wrap(getGlobalContext().getConstantExprSRem(
+ return wrap(ConstantExpr::getSRem(
unwrap<Constant>(LHSConstant),
unwrap<Constant>(RHSConstant)));
}
LLVMValueRef LLVMConstFRem(LLVMValueRef LHSConstant, LLVMValueRef RHSConstant) {
- return wrap(getGlobalContext().getConstantExprFRem(
+ return wrap(ConstantExpr::getFRem(
unwrap<Constant>(LHSConstant),
unwrap<Constant>(RHSConstant)));
}
LLVMValueRef LLVMConstAnd(LLVMValueRef LHSConstant, LLVMValueRef RHSConstant) {
- return wrap(getGlobalContext().getConstantExprAnd(
+ return wrap(ConstantExpr::getAnd(
unwrap<Constant>(LHSConstant),
unwrap<Constant>(RHSConstant)));
}
LLVMValueRef LLVMConstOr(LLVMValueRef LHSConstant, LLVMValueRef RHSConstant) {
- return wrap(getGlobalContext().getConstantExprOr(
+ return wrap(ConstantExpr::getOr(
unwrap<Constant>(LHSConstant),
unwrap<Constant>(RHSConstant)));
}
LLVMValueRef LLVMConstXor(LLVMValueRef LHSConstant, LLVMValueRef RHSConstant) {
- return wrap(getGlobalContext().getConstantExprXor(
+ return wrap(ConstantExpr::getXor(
unwrap<Constant>(LHSConstant),
unwrap<Constant>(RHSConstant)));
}
LLVMValueRef LLVMConstICmp(LLVMIntPredicate Predicate,
LLVMValueRef LHSConstant, LLVMValueRef RHSConstant) {
- return wrap(getGlobalContext().getConstantExprICmp(Predicate,
+ return wrap(ConstantExpr::getICmp(Predicate,
unwrap<Constant>(LHSConstant),
unwrap<Constant>(RHSConstant)));
}
LLVMValueRef LLVMConstFCmp(LLVMRealPredicate Predicate,
LLVMValueRef LHSConstant, LLVMValueRef RHSConstant) {
- return wrap(getGlobalContext().getConstantExprFCmp(Predicate,
+ return wrap(ConstantExpr::getFCmp(Predicate,
unwrap<Constant>(LHSConstant),
unwrap<Constant>(RHSConstant)));
}
LLVMValueRef LLVMConstShl(LLVMValueRef LHSConstant, LLVMValueRef RHSConstant) {
- return wrap(getGlobalContext().getConstantExprShl(
+ return wrap(ConstantExpr::getShl(
unwrap<Constant>(LHSConstant),
unwrap<Constant>(RHSConstant)));
}
LLVMValueRef LLVMConstLShr(LLVMValueRef LHSConstant, LLVMValueRef RHSConstant) {
- return wrap(getGlobalContext().getConstantExprLShr(
+ return wrap(ConstantExpr::getLShr(
unwrap<Constant>(LHSConstant),
unwrap<Constant>(RHSConstant)));
}
LLVMValueRef LLVMConstAShr(LLVMValueRef LHSConstant, LLVMValueRef RHSConstant) {
- return wrap(getGlobalContext().getConstantExprAShr(
+ return wrap(ConstantExpr::getAShr(
unwrap<Constant>(LHSConstant),
unwrap<Constant>(RHSConstant)));
}
LLVMValueRef LLVMConstGEP(LLVMValueRef ConstantVal,
LLVMValueRef *ConstantIndices, unsigned NumIndices) {
- return wrap(getGlobalContext().getConstantExprGetElementPtr(
+ return wrap(ConstantExpr::getGetElementPtr(
unwrap<Constant>(ConstantVal),
unwrap<Constant>(ConstantIndices,
NumIndices),
@@ -559,71 +559,71 @@ LLVMValueRef LLVMConstGEP(LLVMValueRef ConstantVal,
}
LLVMValueRef LLVMConstTrunc(LLVMValueRef ConstantVal, LLVMTypeRef ToType) {
- return wrap(getGlobalContext().getConstantExprTrunc(
+ return wrap(ConstantExpr::getTrunc(
unwrap<Constant>(ConstantVal),
unwrap(ToType)));
}
LLVMValueRef LLVMConstSExt(LLVMValueRef ConstantVal, LLVMTypeRef ToType) {
- return wrap(getGlobalContext().getConstantExprSExt(
+ return wrap(ConstantExpr::getSExt(
unwrap<Constant>(ConstantVal),
unwrap(ToType)));
}
LLVMValueRef LLVMConstZExt(LLVMValueRef ConstantVal, LLVMTypeRef ToType) {
- return wrap(getGlobalContext().getConstantExprZExt(
+ return wrap(ConstantExpr::getZExt(
unwrap<Constant>(ConstantVal),
unwrap(ToType)));
}
LLVMValueRef LLVMConstFPTrunc(LLVMValueRef ConstantVal, LLVMTypeRef ToType) {
- return wrap(getGlobalContext().getConstantExprFPTrunc(
+ return wrap(ConstantExpr::getFPTrunc(
unwrap<Constant>(ConstantVal),
unwrap(ToType)));
}
LLVMValueRef LLVMConstFPExt(LLVMValueRef ConstantVal, LLVMTypeRef ToType) {
- return wrap(getGlobalContext().getConstantExprFPExtend(
+ return wrap(ConstantExpr::getFPExtend(
unwrap<Constant>(ConstantVal),
unwrap(ToType)));
}
LLVMValueRef LLVMConstUIToFP(LLVMValueRef ConstantVal, LLVMTypeRef ToType) {
- return wrap(getGlobalContext().getConstantExprUIToFP(
+ return wrap(ConstantExpr::getUIToFP(
unwrap<Constant>(ConstantVal),
unwrap(ToType)));
}
LLVMValueRef LLVMConstSIToFP(LLVMValueRef ConstantVal, LLVMTypeRef ToType) {
- return wrap(getGlobalContext().getConstantExprSIToFP(unwrap<Constant>(ConstantVal),
+ return wrap(ConstantExpr::getSIToFP(unwrap<Constant>(ConstantVal),
unwrap(ToType)));
}
LLVMValueRef LLVMConstFPToUI(LLVMValueRef ConstantVal, LLVMTypeRef ToType) {
- return wrap(getGlobalContext().getConstantExprFPToUI(unwrap<Constant>(ConstantVal),
+ return wrap(ConstantExpr::getFPToUI(unwrap<Constant>(ConstantVal),
unwrap(ToType)));
}
LLVMValueRef LLVMConstFPToSI(LLVMValueRef ConstantVal, LLVMTypeRef ToType) {
- return wrap(getGlobalContext().getConstantExprFPToSI(
+ return wrap(ConstantExpr::getFPToSI(
unwrap<Constant>(ConstantVal),
unwrap(ToType)));
}
LLVMValueRef LLVMConstPtrToInt(LLVMValueRef ConstantVal, LLVMTypeRef ToType) {
- return wrap(getGlobalContext().getConstantExprPtrToInt(
+ return wrap(ConstantExpr::getPtrToInt(
unwrap<Constant>(ConstantVal),
unwrap(ToType)));
}
LLVMValueRef LLVMConstIntToPtr(LLVMValueRef ConstantVal, LLVMTypeRef ToType) {
- return wrap(getGlobalContext().getConstantExprIntToPtr(
+ return wrap(ConstantExpr::getIntToPtr(
unwrap<Constant>(ConstantVal),
unwrap(ToType)));
}
LLVMValueRef LLVMConstBitCast(LLVMValueRef ConstantVal, LLVMTypeRef ToType) {
- return wrap(getGlobalContext().getConstantExprBitCast(
+ return wrap(ConstantExpr::getBitCast(
unwrap<Constant>(ConstantVal),
unwrap(ToType)));
}
@@ -631,7 +631,7 @@ LLVMValueRef LLVMConstBitCast(LLVMValueRef ConstantVal, LLVMTypeRef ToType) {
LLVMValueRef LLVMConstSelect(LLVMValueRef ConstantCondition,
LLVMValueRef ConstantIfTrue,
LLVMValueRef ConstantIfFalse) {
- return wrap(getGlobalContext().getConstantExprSelect(
+ return wrap(ConstantExpr::getSelect(
unwrap<Constant>(ConstantCondition),
unwrap<Constant>(ConstantIfTrue),
unwrap<Constant>(ConstantIfFalse)));
@@ -639,7 +639,7 @@ LLVMValueRef LLVMConstSelect(LLVMValueRef ConstantCondition,
LLVMValueRef LLVMConstExtractElement(LLVMValueRef VectorConstant,
LLVMValueRef IndexConstant) {
- return wrap(getGlobalContext().getConstantExprExtractElement(
+ return wrap(ConstantExpr::getExtractElement(
unwrap<Constant>(VectorConstant),
unwrap<Constant>(IndexConstant)));
}
@@ -647,7 +647,7 @@ LLVMValueRef LLVMConstExtractElement(LLVMValueRef VectorConstant,
LLVMValueRef LLVMConstInsertElement(LLVMValueRef VectorConstant,
LLVMValueRef ElementValueConstant,
LLVMValueRef IndexConstant) {
- return wrap(getGlobalContext().getConstantExprInsertElement(
+ return wrap(ConstantExpr::getInsertElement(
unwrap<Constant>(VectorConstant),
unwrap<Constant>(ElementValueConstant),
unwrap<Constant>(IndexConstant)));
@@ -656,7 +656,7 @@ LLVMValueRef LLVMConstInsertElement(LLVMValueRef VectorConstant,
LLVMValueRef LLVMConstShuffleVector(LLVMValueRef VectorAConstant,
LLVMValueRef VectorBConstant,
LLVMValueRef MaskConstant) {
- return wrap(getGlobalContext().getConstantExprShuffleVector(
+ return wrap(ConstantExpr::getShuffleVector(
unwrap<Constant>(VectorAConstant),
unwrap<Constant>(VectorBConstant),
unwrap<Constant>(MaskConstant)));
@@ -664,7 +664,7 @@ LLVMValueRef LLVMConstShuffleVector(LLVMValueRef VectorAConstant,
LLVMValueRef LLVMConstExtractValue(LLVMValueRef AggConstant, unsigned *IdxList,
unsigned NumIdx) {
- return wrap(getGlobalContext().getConstantExprExtractValue(
+ return wrap(ConstantExpr::getExtractValue(
unwrap<Constant>(AggConstant),
IdxList, NumIdx));
}
@@ -672,7 +672,7 @@ LLVMValueRef LLVMConstExtractValue(LLVMValueRef AggConstant, unsigned *IdxList,
LLVMValueRef LLVMConstInsertValue(LLVMValueRef AggConstant,
LLVMValueRef ElementValueConstant,
unsigned *IdxList, unsigned NumIdx) {
- return wrap(getGlobalContext().getConstantExprInsertValue(
+ return wrap(ConstantExpr::getInsertValue(
unwrap<Constant>(AggConstant),
unwrap<Constant>(ElementValueConstant),
IdxList, NumIdx));
diff --git a/lib/VMCore/LLVMContext.cpp b/lib/VMCore/LLVMContext.cpp
index 30343dc..e38986e 100644
--- a/lib/VMCore/LLVMContext.cpp
+++ b/lib/VMCore/LLVMContext.cpp
@@ -103,270 +103,6 @@ ConstantAggregateZero* LLVMContext::getConstantAggregateZero(const Type* Ty) {
return pImpl->getConstantAggregateZero(Ty);
}
-// ConstantExpr accessors.
-Constant* LLVMContext::getConstantExpr(unsigned Opcode, Constant* C1,
- Constant* C2) {
- return ConstantExpr::get(Opcode, C1, C2);
-}
-
-Constant* LLVMContext::getConstantExprTrunc(Constant* C, const Type* Ty) {
- return ConstantExpr::getTrunc(C, Ty);
-}
-
-Constant* LLVMContext::getConstantExprSExt(Constant* C, const Type* Ty) {
- return ConstantExpr::getSExt(C, Ty);
-}
-
-Constant* LLVMContext::getConstantExprZExt(Constant* C, const Type* Ty) {
- return ConstantExpr::getZExt(C, Ty);
-}
-
-Constant* LLVMContext::getConstantExprFPTrunc(Constant* C, const Type* Ty) {
- return ConstantExpr::getFPTrunc(C, Ty);
-}
-
-Constant* LLVMContext::getConstantExprFPExtend(Constant* C, const Type* Ty) {
- return ConstantExpr::getFPExtend(C, Ty);
-}
-
-Constant* LLVMContext::getConstantExprUIToFP(Constant* C, const Type* Ty) {
- return ConstantExpr::getUIToFP(C, Ty);
-}
-
-Constant* LLVMContext::getConstantExprSIToFP(Constant* C, const Type* Ty) {
- return ConstantExpr::getSIToFP(C, Ty);
-}
-
-Constant* LLVMContext::getConstantExprFPToUI(Constant* C, const Type* Ty) {
- return ConstantExpr::getFPToUI(C, Ty);
-}
-
-Constant* LLVMContext::getConstantExprFPToSI(Constant* C, const Type* Ty) {
- return ConstantExpr::getFPToSI(C, Ty);
-}
-
-Constant* LLVMContext::getConstantExprPtrToInt(Constant* C, const Type* Ty) {
- return ConstantExpr::getPtrToInt(C, Ty);
-}
-
-Constant* LLVMContext::getConstantExprIntToPtr(Constant* C, const Type* Ty) {
- return ConstantExpr::getIntToPtr(C, Ty);
-}
-
-Constant* LLVMContext::getConstantExprBitCast(Constant* C, const Type* Ty) {
- return ConstantExpr::getBitCast(C, Ty);
-}
-
-Constant* LLVMContext::getConstantExprCast(unsigned ops, Constant* C,
- const Type* Ty) {
- return ConstantExpr::getCast(ops, C, Ty);
-}
-
-Constant* LLVMContext::getConstantExprZExtOrBitCast(Constant* C,
- const Type* Ty) {
- return ConstantExpr::getZExtOrBitCast(C, Ty);
-}
-
-Constant* LLVMContext::getConstantExprSExtOrBitCast(Constant* C,
- const Type* Ty) {
- return ConstantExpr::getSExtOrBitCast(C, Ty);
-}
-
-Constant* LLVMContext::getConstantExprTruncOrBitCast(Constant* C,
- const Type* Ty) {
- return ConstantExpr::getTruncOrBitCast(C, Ty);
-}
-
-Constant* LLVMContext::getConstantExprPointerCast(Constant* C, const Type* Ty) {
- return ConstantExpr::getPointerCast(C, Ty);
-}
-
-Constant* LLVMContext::getConstantExprIntegerCast(Constant* C, const Type* Ty,
- bool isSigned) {
- return ConstantExpr::getIntegerCast(C, Ty, isSigned);
-}
-
-Constant* LLVMContext::getConstantExprFPCast(Constant* C, const Type* Ty) {
- return ConstantExpr::getFPCast(C, Ty);
-}
-
-Constant* LLVMContext::getConstantExprSelect(Constant* C, Constant* V1,
- Constant* V2) {
- return ConstantExpr::getSelect(C, V1, V2);
-}
-
-Constant* LLVMContext::getConstantExprAlignOf(const Type* Ty) {
- // alignof is implemented as: (i64) gep ({i8,Ty}*)null, 0, 1
- const Type *AligningTy = getStructType(Type::Int8Ty, Ty, NULL);
- Constant *NullPtr = getNullValue(AligningTy->getPointerTo());
- Constant *Zero = ConstantInt::get(Type::Int32Ty, 0);
- Constant *One = ConstantInt::get(Type::Int32Ty, 1);
- Constant *Indices[2] = { Zero, One };
- Constant *GEP = getConstantExprGetElementPtr(NullPtr, Indices, 2);
- return getConstantExprCast(Instruction::PtrToInt, GEP, Type::Int32Ty);
-}
-
-Constant* LLVMContext::getConstantExprCompare(unsigned short pred,
- Constant* C1, Constant* C2) {
- return ConstantExpr::getCompare(pred, C1, C2);
-}
-
-Constant* LLVMContext::getConstantExprNeg(Constant* C) {
- // API compatibility: Adjust integer opcodes to floating-point opcodes.
- if (C->getType()->isFPOrFPVector())
- return getConstantExprFNeg(C);
- assert(C->getType()->isIntOrIntVector() &&
- "Cannot NEG a nonintegral value!");
- return getConstantExpr(Instruction::Sub,
- ConstantFP::getZeroValueForNegation(C->getType()),
- C);
-}
-
-Constant* LLVMContext::getConstantExprFNeg(Constant* C) {
- assert(C->getType()->isFPOrFPVector() &&
- "Cannot FNEG a non-floating-point value!");
- return getConstantExpr(Instruction::FSub,
- ConstantFP::getZeroValueForNegation(C->getType()),
- C);
-}
-
-Constant* LLVMContext::getConstantExprNot(Constant* C) {
- assert(C->getType()->isIntOrIntVector() &&
- "Cannot NOT a nonintegral value!");
- return getConstantExpr(Instruction::Xor, C, getAllOnesValue(C->getType()));
-}
-
-Constant* LLVMContext::getConstantExprAdd(Constant* C1, Constant* C2) {
- return getConstantExpr(Instruction::Add, C1, C2);
-}
-
-Constant* LLVMContext::getConstantExprFAdd(Constant* C1, Constant* C2) {
- return getConstantExpr(Instruction::FAdd, C1, C2);
-}
-
-Constant* LLVMContext::getConstantExprSub(Constant* C1, Constant* C2) {
- return getConstantExpr(Instruction::Sub, C1, C2);
-}
-
-Constant* LLVMContext::getConstantExprFSub(Constant* C1, Constant* C2) {
- return getConstantExpr(Instruction::FSub, C1, C2);
-}
-
-Constant* LLVMContext::getConstantExprMul(Constant* C1, Constant* C2) {
- return getConstantExpr(Instruction::Mul, C1, C2);
-}
-
-Constant* LLVMContext::getConstantExprFMul(Constant* C1, Constant* C2) {
- return getConstantExpr(Instruction::FMul, C1, C2);
-}
-
-Constant* LLVMContext::getConstantExprUDiv(Constant* C1, Constant* C2) {
- return getConstantExpr(Instruction::UDiv, C1, C2);
-}
-
-Constant* LLVMContext::getConstantExprSDiv(Constant* C1, Constant* C2) {
- return getConstantExpr(Instruction::SDiv, C1, C2);
-}
-
-Constant* LLVMContext::getConstantExprFDiv(Constant* C1, Constant* C2) {
- return getConstantExpr(Instruction::FDiv, C1, C2);
-}
-
-Constant* LLVMContext::getConstantExprURem(Constant* C1, Constant* C2) {
- return getConstantExpr(Instruction::URem, C1, C2);
-}
-
-Constant* LLVMContext::getConstantExprSRem(Constant* C1, Constant* C2) {
- return getConstantExpr(Instruction::SRem, C1, C2);
-}
-
-Constant* LLVMContext::getConstantExprFRem(Constant* C1, Constant* C2) {
- return getConstantExpr(Instruction::FRem, C1, C2);
-}
-
-Constant* LLVMContext::getConstantExprAnd(Constant* C1, Constant* C2) {
- return getConstantExpr(Instruction::And, C1, C2);
-}
-
-Constant* LLVMContext::getConstantExprOr(Constant* C1, Constant* C2) {
- return getConstantExpr(Instruction::Or, C1, C2);
-}
-
-Constant* LLVMContext::getConstantExprXor(Constant* C1, Constant* C2) {
- return getConstantExpr(Instruction::Xor, C1, C2);
-}
-
-Constant* LLVMContext::getConstantExprICmp(unsigned short pred, Constant* LHS,
- Constant* RHS) {
- return ConstantExpr::getICmp(pred, LHS, RHS);
-}
-
-Constant* LLVMContext::getConstantExprFCmp(unsigned short pred, Constant* LHS,
- Constant* RHS) {
- return ConstantExpr::getFCmp(pred, LHS, RHS);
-}
-
-Constant* LLVMContext::getConstantExprShl(Constant* C1, Constant* C2) {
- return getConstantExpr(Instruction::Shl, C1, C2);
-}
-
-Constant* LLVMContext::getConstantExprLShr(Constant* C1, Constant* C2) {
- return getConstantExpr(Instruction::LShr, C1, C2);
-}
-
-Constant* LLVMContext::getConstantExprAShr(Constant* C1, Constant* C2) {
- return getConstantExpr(Instruction::AShr, C1, C2);
-}
-
-Constant* LLVMContext::getConstantExprGetElementPtr(Constant* C,
- Constant* const* IdxList,
- unsigned NumIdx) {
- return ConstantExpr::getGetElementPtr(C, IdxList, NumIdx);
-}
-
-Constant* LLVMContext::getConstantExprGetElementPtr(Constant* C,
- Value* const* IdxList,
- unsigned NumIdx) {
- return ConstantExpr::getGetElementPtr(C, IdxList, NumIdx);
-}
-
-Constant* LLVMContext::getConstantExprExtractElement(Constant* Vec,
- Constant* Idx) {
- return ConstantExpr::getExtractElement(Vec, Idx);
-}
-
-Constant* LLVMContext::getConstantExprInsertElement(Constant* Vec,
- Constant* Elt,
- Constant* Idx) {
- return ConstantExpr::getInsertElement(Vec, Elt, Idx);
-}
-
-Constant* LLVMContext::getConstantExprShuffleVector(Constant* V1, Constant* V2,
- Constant* Mask) {
- return ConstantExpr::getShuffleVector(V1, V2, Mask);
-}
-
-Constant* LLVMContext::getConstantExprExtractValue(Constant* Agg,
- const unsigned* IdxList,
- unsigned NumIdx) {
- return ConstantExpr::getExtractValue(Agg, IdxList, NumIdx);
-}
-
-Constant* LLVMContext::getConstantExprInsertValue(Constant* Agg, Constant* Val,
- const unsigned* IdxList,
- unsigned NumIdx) {
- return ConstantExpr::getInsertValue(Agg, Val, IdxList, NumIdx);
-}
-
-Constant* LLVMContext::getConstantExprSizeOf(const Type* Ty) {
- // sizeof is implemented as: (i64) gep (Ty*)null, 1
- // Note that a non-inbounds gep is used, as null isn't within any object.
- Constant *GEPIdx = ConstantInt::get(Type::Int32Ty, 1);
- Constant *GEP = getConstantExprGetElementPtr(
- getNullValue(getPointerTypeUnqual(Ty)), &GEPIdx, 1);
- return getConstantExprCast(Instruction::PtrToInt, GEP, Type::Int64Ty);
-}
-
// MDNode accessors
MDNode* LLVMContext::getMDNode(Value* const* Vals, unsigned NumVals) {
return pImpl->getMDNode(Vals, NumVals);
diff --git a/lib/VMCore/LLVMContextImpl.h b/lib/VMCore/LLVMContextImpl.h
index ebcb8a4..c092603 100644
--- a/lib/VMCore/LLVMContextImpl.h
+++ b/lib/VMCore/LLVMContextImpl.h
@@ -487,7 +487,6 @@ public:
void erase(MDString *M);
void erase(MDNode *M);
void erase(ConstantAggregateZero *Z);
- void erase(ConstantVector *V);
};
}
diff --git a/lib/VMCore/Module.cpp b/lib/VMCore/Module.cpp
index c9d599e..2ef16d0 100644
--- a/lib/VMCore/Module.cpp
+++ b/lib/VMCore/Module.cpp
@@ -154,7 +154,7 @@ Constant *Module::getOrInsertFunction(const StringRef &Name,
// If the function exists but has the wrong type, return a bitcast to the
// right type.
if (F->getType() != Context.getPointerTypeUnqual(Ty))
- return Context.getConstantExprBitCast(F, Context.getPointerTypeUnqual(Ty));
+ return ConstantExpr::getBitCast(F, Context.getPointerTypeUnqual(Ty));
// Otherwise, we just found the existing function or a prototype.
return F;
@@ -272,7 +272,7 @@ Constant *Module::getOrInsertGlobal(const StringRef &Name, const Type *Ty) {
// If the variable exists but has the wrong type, return a bitcast to the
// right type.
if (GV->getType() != Context.getPointerTypeUnqual(Ty))
- return Context.getConstantExprBitCast(GV, Context.getPointerTypeUnqual(Ty));
+ return ConstantExpr::getBitCast(GV, Context.getPointerTypeUnqual(Ty));
// Otherwise, we just found the existing function or a prototype.
return GV;