[llvm-commits] CVS: llvm/lib/VMCore/Constants.cpp
Reid Spencer
reid at x10sys.com
Mon Dec 4 19:25:41 PST 2006
Changes in directory llvm/lib/VMCore:
Constants.cpp updated: 1.179 -> 1.180
---
Log message:
Implement getPointerCast.
---
Diffs of the changes: (+10 -0)
Constants.cpp | 10 ++++++++++
1 files changed, 10 insertions(+)
Index: llvm/lib/VMCore/Constants.cpp
diff -u llvm/lib/VMCore/Constants.cpp:1.179 llvm/lib/VMCore/Constants.cpp:1.180
--- llvm/lib/VMCore/Constants.cpp:1.179 Mon Dec 4 15:35:24 2006
+++ llvm/lib/VMCore/Constants.cpp Mon Dec 4 21:25:26 2006
@@ -1552,6 +1552,16 @@
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");
More information about the llvm-commits
mailing list