diff --git a/include/llvm/Intrinsics.td b/include/llvm/Intrinsics.td index 58b178f25af..599d5bb2e20 100644 --- a/include/llvm/Intrinsics.td +++ b/include/llvm/Intrinsics.td @@ -63,11 +63,15 @@ class LLVMType { ValueType VT = vt; } -class LLVMPointerType +class LLVMQualPointerType : LLVMType{ LLVMType ElTy = elty; + int AddrSpace = addrspace; } +class LLVMPointerType + : LLVMQualPointerType; + class LLVMAnyPointerType : LLVMType{ LLVMType ElTy = elty; diff --git a/lib/VMCore/Function.cpp b/lib/VMCore/Function.cpp index 5a2a56637e6..6339c6791d4 100644 --- a/lib/VMCore/Function.cpp +++ b/lib/VMCore/Function.cpp @@ -388,8 +388,11 @@ static Type *DecodeFixedType(unsigned &NextElt, ArrayRef Infos, return VectorType::get(DecodeFixedType(NextElt, Infos, Tys, Context), 16); case IIT_V32: return VectorType::get(DecodeFixedType(NextElt, Infos, Tys, Context), 32); - case IIT_PTR: - return PointerType::getUnqual(DecodeFixedType(NextElt, Infos, Tys,Context)); + case IIT_PTR: { + unsigned AddrSpace = Infos[NextElt++]; + Type *PtrTy = DecodeFixedType(NextElt, Infos, Tys,Context); + return PointerType::get(PtrTy, AddrSpace); + } case IIT_ARG: case IIT_EXTEND_VEC_ARG: case IIT_TRUNC_VEC_ARG: { diff --git a/utils/TableGen/IntrinsicEmitter.cpp b/utils/TableGen/IntrinsicEmitter.cpp index c6acddf9dd2..a595b1edd76 100644 --- a/utils/TableGen/IntrinsicEmitter.cpp +++ b/utils/TableGen/IntrinsicEmitter.cpp @@ -413,6 +413,12 @@ static void EncodeFixedType(Record *R, unsigned &NextArgNo, if (VT == MVT::iPTR) { Sig.push_back(IIT_PTR); + unsigned AddrSpace = 0; + if (R->isSubClassOf("LLVMQualPointerType")) { + AddrSpace = R->getValueAsInt("AddrSpace"); + assert(AddrSpace < 256 && "Address space exceeds 255"); + } + Sig.push_back(AddrSpace); return EncodeFixedType(R->getValueAsDef("ElTy"), NextArgNo, Sig); }