Added address space qualifier to intrinsic PointerType arguments.
authorPete Cooper <peter_cooper@apple.com>
Mon, 21 May 2012 23:21:28 +0000 (23:21 +0000)
committerPete Cooper <peter_cooper@apple.com>
Mon, 21 May 2012 23:21:28 +0000 (23:21 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@157218 91177308-0d34-0410-b5e6-96231b3b80d8

include/llvm/Intrinsics.td
lib/VMCore/Function.cpp
utils/TableGen/IntrinsicEmitter.cpp

index 58b178f25afc83e7f81e657f2606b78ca4168ab0..599d5bb2e202d2a400a278c835969ac59189ca06 100644 (file)
@@ -63,11 +63,15 @@ class LLVMType<ValueType vt> {
   ValueType VT = vt;
 }
 
-class LLVMPointerType<LLVMType elty>
+class LLVMQualPointerType<LLVMType elty, int addrspace>
   : LLVMType<iPTR>{
   LLVMType ElTy = elty;
+  int AddrSpace = addrspace;
 }
 
+class LLVMPointerType<LLVMType elty>
+  : LLVMQualPointerType<elty, 0>;
+
 class LLVMAnyPointerType<LLVMType elty>
   : LLVMType<iPTRAny>{
   LLVMType ElTy = elty;
index 5a2a56637e6b8643fb04cc9ea7ee73cdd16d0bd0..6339c6791d4d35ddd40d24612e943b3344debd5d 100644 (file)
@@ -388,8 +388,11 @@ static Type *DecodeFixedType(unsigned &NextElt, ArrayRef<unsigned char> 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: {
index c6acddf9dd2c78e6100e416cd4378d472975b122..a595b1edd76ce4c5d4976175383a006f1724b8f7 100644 (file)
@@ -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);
   }