mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2025-07-25 13:24:46 +00:00
Fix ptr vector inconsistency in CreatePointerCast
One form would accept a vector of pointers, and the other did not. Make both accept vectors of pointers, and add an assertion for the number of elements. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@187464 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
@@ -2415,22 +2415,30 @@ CastInst *CastInst::CreateTruncOrBitCast(Value *S, Type *Ty,
|
||||
CastInst *CastInst::CreatePointerCast(Value *S, Type *Ty,
|
||||
const Twine &Name,
|
||||
BasicBlock *InsertAtEnd) {
|
||||
assert(S->getType()->isPointerTy() && "Invalid cast");
|
||||
assert((Ty->isIntegerTy() || Ty->isPointerTy()) &&
|
||||
assert(S->getType()->isPtrOrPtrVectorTy() && "Invalid cast");
|
||||
assert((Ty->isIntOrIntVectorTy() || Ty->isPtrOrPtrVectorTy()) &&
|
||||
"Invalid cast");
|
||||
assert(Ty->isVectorTy() == S->getType()->isVectorTy() && "Invalid cast");
|
||||
assert(!Ty->isVectorTy() ||
|
||||
Ty->getVectorNumElements() == S->getType()->getVectorNumElements() &&
|
||||
"Invalid cast");
|
||||
|
||||
if (Ty->isIntegerTy())
|
||||
if (Ty->isIntOrIntVectorTy())
|
||||
return Create(Instruction::PtrToInt, S, Ty, Name, InsertAtEnd);
|
||||
return Create(Instruction::BitCast, S, Ty, Name, InsertAtEnd);
|
||||
}
|
||||
|
||||
/// @brief Create a BitCast or a PtrToInt cast instruction
|
||||
CastInst *CastInst::CreatePointerCast(Value *S, Type *Ty,
|
||||
const Twine &Name,
|
||||
CastInst *CastInst::CreatePointerCast(Value *S, Type *Ty,
|
||||
const Twine &Name,
|
||||
Instruction *InsertBefore) {
|
||||
assert(S->getType()->isPtrOrPtrVectorTy() && "Invalid cast");
|
||||
assert((Ty->isIntOrIntVectorTy() || Ty->isPtrOrPtrVectorTy()) &&
|
||||
"Invalid cast");
|
||||
assert(Ty->isVectorTy() == S->getType()->isVectorTy() && "Invalid cast");
|
||||
assert(!Ty->isVectorTy() ||
|
||||
Ty->getVectorNumElements() == S->getType()->getVectorNumElements() &&
|
||||
"Invalid cast");
|
||||
|
||||
if (Ty->isIntOrIntVectorTy())
|
||||
return Create(Instruction::PtrToInt, S, Ty, Name, InsertBefore);
|
||||
|
Reference in New Issue
Block a user