mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2025-07-25 13:24:46 +00:00
Change the interface to SCEVExpander::InsertCastOfTo to take a cast opcode
so the decision of which opcode to use is pushed upward to the caller. Adjust the callers to pass the expected opcode. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@32535 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
@@ -88,7 +88,8 @@ namespace llvm {
|
||||
|
||||
/// InsertCastOfTo - Insert a cast of V to the specified type, doing what
|
||||
/// we can to share the casts.
|
||||
static Value *InsertCastOfTo(Value *V, const Type *Ty);
|
||||
static Value *InsertCastOfTo(Instruction::CastOps opcode, Value *V,
|
||||
const Type *Ty);
|
||||
|
||||
protected:
|
||||
Value *expand(SCEV *S) {
|
||||
@@ -104,8 +105,20 @@ namespace llvm {
|
||||
|
||||
Value *expandInTy(SCEV *S, const Type *Ty) {
|
||||
Value *V = expand(S);
|
||||
if (Ty && V->getType() != Ty)
|
||||
return InsertCastOfTo(V, Ty);
|
||||
if (Ty && V->getType() != Ty) {
|
||||
if (isa<PointerType>(Ty) && V->getType()->isInteger())
|
||||
return InsertCastOfTo(Instruction::IntToPtr, V, Ty);
|
||||
else if (Ty->isInteger() && isa<PointerType>(V->getType()))
|
||||
return InsertCastOfTo(Instruction::PtrToInt, V, Ty);
|
||||
else if (Ty->getPrimitiveSizeInBits() ==
|
||||
V->getType()->getPrimitiveSizeInBits())
|
||||
return InsertCastOfTo(Instruction::BitCast, V, Ty);
|
||||
else if (Ty->getPrimitiveSizeInBits() >
|
||||
V->getType()->getPrimitiveSizeInBits())
|
||||
return InsertCastOfTo(Instruction::ZExt, V, Ty);
|
||||
else
|
||||
return InsertCastOfTo(Instruction::Trunc, V, Ty);
|
||||
}
|
||||
return V;
|
||||
}
|
||||
|
||||
@@ -119,7 +132,7 @@ namespace llvm {
|
||||
}
|
||||
|
||||
Value *visitZeroExtendExpr(SCEVZeroExtendExpr *S) {
|
||||
Value *V = expandInTy(S->getOperand(),S->getType()->getUnsignedVersion());
|
||||
Value *V = expandInTy(S->getOperand(), S->getType());
|
||||
return CastInst::createZExtOrBitCast(V, S->getType(), "tmp.", InsertPt);
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user