Handle address spaces in TargetTransformInfo

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@189527 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Matt Arsenault
2013-08-28 22:41:57 +00:00
parent 2b884bcbce
commit f9355c80d5
2 changed files with 59 additions and 8 deletions
+15 -7
View File
@@ -269,26 +269,34 @@ struct NoTTI : ImmutablePass, TargetTransformInfo {
// Otherwise, the default basic cost is used.
return TCC_Basic;
case Instruction::IntToPtr:
case Instruction::IntToPtr: {
if (!DL)
return TCC_Basic;
// An inttoptr cast is free so long as the input is a legal integer type
// which doesn't contain values outside the range of a pointer.
if (DL && DL->isLegalInteger(OpTy->getScalarSizeInBits()) &&
OpTy->getScalarSizeInBits() <= DL->getPointerSizeInBits())
unsigned OpSize = OpTy->getScalarSizeInBits();
if (DL->isLegalInteger(OpSize) &&
OpSize <= DL->getPointerTypeSizeInBits(Ty))
return TCC_Free;
// Otherwise it's not a no-op.
return TCC_Basic;
}
case Instruction::PtrToInt: {
if (!DL)
return TCC_Basic;
case Instruction::PtrToInt:
// A ptrtoint cast is free so long as the result is large enough to store
// the pointer, and a legal integer type.
if (DL && DL->isLegalInteger(Ty->getScalarSizeInBits()) &&
Ty->getScalarSizeInBits() >= DL->getPointerSizeInBits())
unsigned DestSize = Ty->getScalarSizeInBits();
if (DL->isLegalInteger(DestSize) &&
DestSize >= DL->getPointerTypeSizeInBits(OpTy))
return TCC_Free;
// Otherwise it's not a no-op.
return TCC_Basic;
}
case Instruction::Trunc:
// trunc to a native type is free (assuming the target has compare and
// shift-right of the same width).