summaryrefslogtreecommitdiffstats
path: root/llvm/lib/VMCore/Instructions.cpp
diff options
context:
space:
mode:
authorMicah Villmow <villmow@gmail.com>2012-10-24 15:52:52 +0000
committerMicah Villmow <villmow@gmail.com>2012-10-24 15:52:52 +0000
commit12d9127833b08733090eabb2b55d1184db8da395 (patch)
tree7cd4873f9416a670b3bc2b3e92e02da1d67d1854 /llvm/lib/VMCore/Instructions.cpp
parentc6317dbf5ed134f3dc54a92848707831f8787fb2 (diff)
downloadbcm5719-llvm-12d9127833b08733090eabb2b55d1184db8da395.tar.gz
bcm5719-llvm-12d9127833b08733090eabb2b55d1184db8da395.zip
Add in support for getIntPtrType to get the pointer type based on the address space.
This checkin also adds in some tests that utilize these paths and updates some of the clients. llvm-svn: 166578
Diffstat (limited to 'llvm/lib/VMCore/Instructions.cpp')
-rw-r--r--llvm/lib/VMCore/Instructions.cpp11
1 files changed, 11 insertions, 0 deletions
diff --git a/llvm/lib/VMCore/Instructions.cpp b/llvm/lib/VMCore/Instructions.cpp
index 13c4a5d2574..e9b96d6cd22 100644
--- a/llvm/lib/VMCore/Instructions.cpp
+++ b/llvm/lib/VMCore/Instructions.cpp
@@ -2120,6 +2120,17 @@ bool CastInst::isNoopCast(Type *IntPtrTy) const {
return isNoopCast(getOpcode(), getOperand(0)->getType(), getType(), IntPtrTy);
}
+/// @brief Determine if a cast is a no-op
+bool CastInst::isNoopCast(const DataLayout &DL) const {
+ unsigned AS = 0;
+ if (getOpcode() == Instruction::PtrToInt)
+ AS = getOperand(0)->getType()->getPointerAddressSpace();
+ else if (getOpcode() == Instruction::IntToPtr)
+ AS = getType()->getPointerAddressSpace();
+ Type *IntPtrTy = DL.getIntPtrType(getContext(), AS);
+ return isNoopCast(getOpcode(), getOperand(0)->getType(), getType(), IntPtrTy);
+}
+
/// This function determines if a pair of casts can be eliminated and what
/// opcode should be used in the elimination. This assumes that there are two
/// instructions like this:
OpenPOWER on IntegriCloud