diff options
author | Micah Villmow <villmow@gmail.com> | 2012-10-15 16:24:29 +0000 |
---|---|---|
committer | Micah Villmow <villmow@gmail.com> | 2012-10-15 16:24:29 +0000 |
commit | 2c39b15073db81d93bb629303915b7d7e5d088dc (patch) | |
tree | 966e03c76191ad625cf466ea6ccf1238ddc23ed7 /include/llvm/Instructions.h | |
parent | f35c62bf025411393c7df0803851010cc0e597ba (diff) | |
download | external_llvm-2c39b15073db81d93bb629303915b7d7e5d088dc.tar.gz external_llvm-2c39b15073db81d93bb629303915b7d7e5d088dc.tar.bz2 external_llvm-2c39b15073db81d93bb629303915b7d7e5d088dc.zip |
Resubmit the changes to llvm core to update the functions to support different pointer sizes on a per address space basis.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@165941 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'include/llvm/Instructions.h')
-rw-r--r-- | include/llvm/Instructions.h | 32 |
1 files changed, 29 insertions, 3 deletions
diff --git a/include/llvm/Instructions.h b/include/llvm/Instructions.h index dba852fc84..458bd6ddb6 100644 --- a/include/llvm/Instructions.h +++ b/include/llvm/Instructions.h @@ -348,7 +348,16 @@ public: static unsigned getPointerOperandIndex() { return 1U; } unsigned getPointerAddressSpace() const { - return cast<PointerType>(getPointerOperand()->getType())->getAddressSpace(); + if (getPointerOperand()->getType()->isPointerTy()) + return cast<PointerType>(getPointerOperand()->getType()) + ->getAddressSpace(); + if (getPointerOperand()->getType()->isVectorTy() + && cast<VectorType>(getPointerOperand()->getType())->isPointerTy()) + return cast<PointerType>(cast<VectorType>( + getPointerOperand()->getType())->getElementType()) + ->getAddressSpace(); + llvm_unreachable("Only a vector of pointers or pointers can be used!"); + return 0; } // Methods for support type inquiry through isa, cast, and dyn_cast: @@ -3618,7 +3627,15 @@ public: /// @brief return the address space of the pointer. unsigned getAddressSpace() const { - return cast<PointerType>(getType())->getAddressSpace(); + if (getType()->isPointerTy()) + return cast<PointerType>(getType())->getAddressSpace(); + if (getType()->isVectorTy() && + cast<VectorType>(getType())->getElementType()->isPointerTy()) + return cast<PointerType>( + cast<VectorType>(getType())->getElementType()) + ->getAddressSpace(); + llvm_unreachable("Must be a pointer or a vector of pointers."); + return 0; } // Methods for support type inquiry through isa, cast, and dyn_cast: @@ -3659,7 +3676,16 @@ public: /// @brief return the address space of the pointer. unsigned getPointerAddressSpace() const { - return cast<PointerType>(getOperand(0)->getType())->getAddressSpace(); + Type *Ty = getOperand(0)->getType(); + if (Ty->isPointerTy()) + return cast<PointerType>(Ty)->getAddressSpace(); + if (Ty->isVectorTy() + && cast<VectorType>(Ty)->getElementType()->isPointerTy()) + return cast<PointerType>( + cast<VectorType>(Ty)->getElementType()) + ->getAddressSpace(); + llvm_unreachable("Must be a pointer or a vector of pointers."); + return 0; } // Methods for support type inquiry through isa, cast, and dyn_cast: |