1
0
mirror of https://github.com/RPCS3/llvm-mirror.git synced 2024-11-24 19:52:54 +01:00

Implement getPointerCast.

llvm-svn: 32211
This commit is contained in:
Reid Spencer 2006-12-05 03:25:26 +00:00
parent 6da381c3d5
commit c5727bf642

View File

@ -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");