summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorReid Spencer <rspencer@reidspencer.com>2006-12-05 03:25:26 +0000
committerReid Spencer <rspencer@reidspencer.com>2006-12-05 03:25:26 +0000
commitbc245a0190bc3c2188d4579c16741ff120d4bb3c (patch)
treed6ff1575fe95d0299256800651472c2b9c717673
parentc92921f93981df172e9122415794b57b655ed64b (diff)
downloadbcm5719-llvm-bc245a0190bc3c2188d4579c16741ff120d4bb3c.tar.gz
bcm5719-llvm-bc245a0190bc3c2188d4579c16741ff120d4bb3c.zip
Implement getPointerCast.
llvm-svn: 32211
-rw-r--r--llvm/lib/VMCore/Constants.cpp10
1 files changed, 10 insertions, 0 deletions
diff --git a/llvm/lib/VMCore/Constants.cpp b/llvm/lib/VMCore/Constants.cpp
index 3238ad0824a..dc3d9935d69 100644
--- a/llvm/lib/VMCore/Constants.cpp
+++ b/llvm/lib/VMCore/Constants.cpp
@@ -1552,6 +1552,16 @@ Constant *ConstantExpr::getTruncOrBitCast(Constant *C, const Type *Ty) {
return getCast(Instruction::Trunc, C, Ty);
}
+Constant *ConstantExpr::getPointerCast(Constant *S, const Type *Ty) {
+ assert(isa<PointerType>(S->getType()) && "Invalid cast");
+ assert((Ty->isIntegral() || Ty->getTypeID() == Type::PointerTyID) &&
+ "Invalid cast");
+
+ if (Ty->isIntegral())
+ return getCast(Instruction::PtrToInt, S, Ty);
+ return getCast(Instruction::BitCast, S, Ty);
+}
+
Constant *ConstantExpr::getTrunc(Constant *C, const Type *Ty) {
assert(C->getType()->isInteger() && "Trunc operand must be integer");
assert(Ty->isIntegral() && "Trunc produces only integral");
OpenPOWER on IntegriCloud