Resubmit the changes to llvm core to update the functions to support different pointer sizes on a per address space basis.

llvm-svn: 165941
This commit is contained in:
Micah Villmow
2012-10-15 16:24:29 +00:00
parent ef206f19a4
commit 4bb926d91d
40 changed files with 190 additions and 109 deletions

View File

@@ -91,14 +91,16 @@ bool llvm::isInstructionFree(const Instruction *I, const DataLayout *TD) {
// which doesn't contain values outside the range of a pointer.
if (isa<IntToPtrInst>(CI) && TD &&
TD->isLegalInteger(Op->getType()->getScalarSizeInBits()) &&
Op->getType()->getScalarSizeInBits() <= TD->getPointerSizeInBits())
Op->getType()->getScalarSizeInBits() <= TD->getPointerSizeInBits(
cast<IntToPtrInst>(CI)->getAddressSpace()))
return true;
// A ptrtoint cast is free so long as the result is large enough to store
// the pointer, and a legal integer type.
if (isa<PtrToIntInst>(CI) && TD &&
TD->isLegalInteger(Op->getType()->getScalarSizeInBits()) &&
Op->getType()->getScalarSizeInBits() >= TD->getPointerSizeInBits())
Op->getType()->getScalarSizeInBits() >= TD->getPointerSizeInBits(
cast<PtrToIntInst>(CI)->getPointerAddressSpace()))
return true;
// trunc to a native type is free (assuming the target has compare and