diff options
| author | Reid Spencer <rspencer@reidspencer.com> | 2006-12-05 03:25:26 +0000 |
|---|---|---|
| committer | Reid Spencer <rspencer@reidspencer.com> | 2006-12-05 03:25:26 +0000 |
| commit | c0459fb7f52ca1bcba977f3e72abc050af078aee (patch) | |
| tree | 848605aff54609517b47b88a003f716758343238 /lib | |
| parent | 4d7bd8fe6fd21fa307dbc1fd6f7274fa3cf19c18 (diff) | |
Implement getPointerCast.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@32211 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib')
| -rw-r--r-- | lib/VMCore/Constants.cpp | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/lib/VMCore/Constants.cpp b/lib/VMCore/Constants.cpp index 3238ad0824..dc3d9935d6 100644 --- a/lib/VMCore/Constants.cpp +++ b/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"); |
