swr/rast: Add debugging type support for function types.
authorGeorge Kyriazis <george.kyriazis@intel.com>
Fri, 19 Jan 2018 21:47:02 +0000 (15:47 -0600)
committerGeorge Kyriazis <george.kyriazis@intel.com>
Fri, 19 Jan 2018 22:52:38 +0000 (16:52 -0600)
Reviewed-by: Bruce Cherniak <bruce.cherniak@intel.com>
src/gallium/drivers/swr/rasterizer/jitter/JitManager.cpp
src/gallium/drivers/swr/rasterizer/jitter/JitManager.h

index a3bda616f956cb6fee02fd3397f00c380eb63e92..b0f9d2f645643fe7afd4ba498256b15d91dc0abe 100644 (file)
@@ -254,11 +254,31 @@ DIType* JitManager::GetDebugType(Type* pTy)
     case Type::ArrayTyID: return GetDebugArrayType(pTy); break;
     case Type::PointerTyID: return builder.createPointerType(GetDebugType(pTy->getPointerElementType()), 64, 64); break;
     case Type::VectorTyID: return GetDebugVectorType(pTy); break;
+    case Type::FunctionTyID: return GetDebugFunctionType(pTy); break;
     default: SWR_ASSERT(false, "Unimplemented llvm type");
     }
     return nullptr;
 }
 
+// Create a DISubroutineType from an llvm FunctionType
+DIType* JitManager::GetDebugFunctionType(Type* pTy)
+{
+    SmallVector<Metadata*, 8> ElemTypes;
+    FunctionType* pFuncTy = cast<FunctionType>(pTy);
+    DIBuilder builder(*mpCurrentModule);
+
+    // Add result type
+    ElemTypes.push_back(GetDebugType(pFuncTy->getReturnType()));
+
+    // Add arguments
+    for (auto& param : pFuncTy->params())
+    {
+        ElemTypes.push_back(GetDebugType(param));
+    }
+
+    return builder.createSubroutineType(builder.getOrCreateTypeArray(ElemTypes));
+}
+
 DIType* JitManager::GetDebugIntegerType(Type* pTy)
 {
     DIBuilder builder(*mpCurrentModule);
index fb20a36625d4a2b4bfe12f77f4ad84c4eb1ce1d4..50b9d829047b90cd64d6a5370d2d90ceda921c80 100644 (file)
@@ -175,6 +175,7 @@ struct JitManager
     llvm::DIType* GetDebugIntegerType(llvm::Type* pTy);
     llvm::DIType* GetDebugArrayType(llvm::Type* pTy);
     llvm::DIType* GetDebugVectorType(llvm::Type* pTy);
+    llvm::DIType* GetDebugFunctionType(llvm::Type* pTy);
 
     llvm::DIType* GetDebugStructType(llvm::Type* pType)
     {