[PATCH 21/79] [Backport to 15][DebugInfo] Add an option for NonSemantic.Shader.DebugI...
authorDmitry Sidorov <dmitry.sidorov@intel.com>
Wed, 1 Mar 2023 18:23:49 +0000 (19:23 +0100)
committerAndreas Beckmann <anbe@debian.org>
Thu, 14 Mar 2024 19:01:08 +0000 (20:01 +0100)
Under this option this extended instruction set will be implemented
Spec:
https://github.com/KhronosGroup/SPIRV-Registry/blob/main/nonsemantic/NonSemantic.Shader.DebugInfo.100.asciidoc

TODO: to rename NonSemantic.Kernel.DebugInfo.100 to
NonSemantic.Shader.DebugInfo.200 when the name is stable

Signed-off-by: Sidorov, Dmitry <dmitry.sidorov@intel.com>
Gbp-Pq: Name 0021-Backport-to-15-DebugInfo-Add-an-option-for-NonSemant.patch

include/LLVMSPIRVOpts.h
lib/SPIRV/SPIRVToLLVMDbgTran.cpp
lib/SPIRV/SPIRVToLLVMDbgTran.h
lib/SPIRV/libSPIRV/SPIRVEnum.h
lib/SPIRV/libSPIRV/SPIRVFunction.cpp
lib/SPIRV/libSPIRV/SPIRVInstruction.h
lib/SPIRV/libSPIRV/SPIRVModule.cpp
lib/SPIRV/libSPIRV/SPIRVModule.h
tools/llvm-spirv/llvm-spirv.cpp

index 8c14037774fcf58ee2a942eebd96b32c747de1f3..e821a1fadf7735980111eb23cdf03c9c5e4a6bdb 100644 (file)
@@ -83,6 +83,7 @@ enum class FPContractMode : uint32_t { On, Off, Fast };
 enum class DebugInfoEIS : uint32_t {
   SPIRV_Debug,
   OpenCL_DebugInfo_100,
+  NonSemantic_Shader_DebugInfo_100,
   NonSemantic_Kernel_DebugInfo_100
 };
 
index e2d4e9ad30ca8d1bc66fb215edd94da146a32dff..2178582fc3ad49a2243278a4d730d7f9006a8b40 100644 (file)
@@ -92,6 +92,8 @@ SPIRVExtInst *SPIRVToLLVMDbgTran::getDbgInst(const SPIRVId Id) {
     SPIRVExtInst *EI = static_cast<SPIRVExtInst *>(E);
     if (EI->getExtSetKind() == SPIRV::SPIRVEIS_Debug ||
         EI->getExtSetKind() == SPIRV::SPIRVEIS_OpenCL_DebugInfo_100 ||
+        EI->getExtSetKind() ==
+            SPIRV::SPIRVEIS_NonSemantic_Shader_DebugInfo_100 ||
         EI->getExtSetKind() == SPIRV::SPIRVEIS_NonSemantic_Kernel_DebugInfo_100)
       return EI;
   }
index 3a0f78d45363e03cfa36ea4b9d8286c4cb8bc752..68a8351c0aac904fd83fa13bb5d3a7ca4254ecfa 100644 (file)
@@ -71,6 +71,8 @@ public:
   T *transDebugInst(const SPIRVExtInst *DebugInst) {
     assert((DebugInst->getExtSetKind() == SPIRVEIS_Debug ||
             DebugInst->getExtSetKind() == SPIRVEIS_OpenCL_DebugInfo_100 ||
+            DebugInst->getExtSetKind() ==
+                SPIRVEIS_NonSemantic_Shader_DebugInfo_100 ||
             DebugInst->getExtSetKind() ==
                 SPIRVEIS_NonSemantic_Kernel_DebugInfo_100) &&
            "Unexpected extended instruction set");
index 4e4cbf8248906ad95357b61391778bda90dc2892..9bb59b6ed5e7326b26f73fc0808928c05ab11500 100644 (file)
@@ -78,6 +78,7 @@ enum SPIRVExtInstSetKind {
   SPIRVEIS_OpenCL,
   SPIRVEIS_Debug,
   SPIRVEIS_OpenCL_DebugInfo_100,
+  SPIRVEIS_NonSemantic_Shader_DebugInfo_100,
   SPIRVEIS_NonSemantic_Kernel_DebugInfo_100,
   SPIRVEIS_Count,
 };
@@ -130,6 +131,8 @@ template <> inline void SPIRVMap<SPIRVExtInstSetKind, std::string>::init() {
   add(SPIRVEIS_OpenCL, "OpenCL.std");
   add(SPIRVEIS_Debug, "SPIRV.debug");
   add(SPIRVEIS_OpenCL_DebugInfo_100, "OpenCL.DebugInfo.100");
+  add(SPIRVEIS_NonSemantic_Shader_DebugInfo_100,
+      "NonSemantic.Shader.DebugInfo.100");
   add(SPIRVEIS_NonSemantic_Kernel_DebugInfo_100,
       "NonSemantic.Kernel.DebugInfo.100");
 }
index c91a6506937360f6b9840c4311f72cd0b07908db..64aa40f6dc0f2339e08930185b3c748ebbe775e3 100644 (file)
@@ -162,12 +162,16 @@ bool SPIRVFunction::decodeBB(SPIRVDecoder &Decoder) {
     } else {
       if (Inst->isExtInst(SPIRVEIS_Debug, SPIRVDebug::Scope) ||
           Inst->isExtInst(SPIRVEIS_OpenCL_DebugInfo_100, SPIRVDebug::Scope) ||
+          Inst->isExtInst(SPIRVEIS_NonSemantic_Shader_DebugInfo_100,
+                          SPIRVDebug::Scope) ||
           Inst->isExtInst(SPIRVEIS_NonSemantic_Kernel_DebugInfo_100,
                           SPIRVDebug::Scope)) {
         DebugScope = Inst;
       } else if (Inst->isExtInst(SPIRVEIS_Debug, SPIRVDebug::NoScope) ||
                  Inst->isExtInst(SPIRVEIS_OpenCL_DebugInfo_100,
                                  SPIRVDebug::NoScope) ||
+                 Inst->isExtInst(SPIRVEIS_NonSemantic_Shader_DebugInfo_100,
+                                 SPIRVDebug::NoScope) ||
                  Inst->isExtInst(SPIRVEIS_NonSemantic_Kernel_DebugInfo_100,
                                  SPIRVDebug::NoScope)) {
         DebugScope = nullptr;
index 69a12ca614f6105d48b99756c9ef4bfe6c8730af..568885fb9bbc6a7bb5551c1c9abc22bc5ce95938 100644 (file)
@@ -1762,6 +1762,7 @@ public:
     ExtSetKind = Module->getBuiltinSet(ExtSetId);
     assert((ExtSetKind == SPIRVEIS_OpenCL || ExtSetKind == SPIRVEIS_Debug ||
             ExtSetKind == SPIRVEIS_OpenCL_DebugInfo_100 ||
+            ExtSetKind == SPIRVEIS_NonSemantic_Shader_DebugInfo_100 ||
             ExtSetKind == SPIRVEIS_NonSemantic_Kernel_DebugInfo_100) &&
            "not supported");
   }
@@ -1773,6 +1774,7 @@ public:
       break;
     case SPIRVEIS_Debug:
     case SPIRVEIS_OpenCL_DebugInfo_100:
+    case SPIRVEIS_NonSemantic_Shader_DebugInfo_100:
     case SPIRVEIS_NonSemantic_Kernel_DebugInfo_100:
       getEncoder(O) << ExtOpDebug;
       break;
@@ -1791,6 +1793,7 @@ public:
       break;
     case SPIRVEIS_Debug:
     case SPIRVEIS_OpenCL_DebugInfo_100:
+    case SPIRVEIS_NonSemantic_Shader_DebugInfo_100:
     case SPIRVEIS_NonSemantic_Kernel_DebugInfo_100:
       getDecoder(I) >> ExtOpDebug;
       break;
index cc64266b62151062a4b3ebd5d22fd8b8eb89603b..5cbc2a80268d14019487e4c5842eac48feaabd82 100644 (file)
@@ -643,6 +643,7 @@ void SPIRVModuleImpl::layoutEntry(SPIRVEntry *E) {
     SPIRVExtInst *EI = static_cast<SPIRVExtInst *>(E);
     if ((EI->getExtSetKind() == SPIRVEIS_Debug ||
          EI->getExtSetKind() == SPIRVEIS_OpenCL_DebugInfo_100 ||
+         EI->getExtSetKind() == SPIRVEIS_NonSemantic_Shader_DebugInfo_100 ||
          EI->getExtSetKind() == SPIRVEIS_NonSemantic_Kernel_DebugInfo_100) &&
         EI->getExtOp() != SPIRVDebug::Declare &&
         EI->getExtOp() != SPIRVDebug::Value &&
index 2ec832c0adfacbc25f265bf7bf3d335180eb2fc5..bd462aa4d8a7fc071c523e2f5923b0ae08082834 100644 (file)
@@ -528,6 +528,8 @@ public:
       return SPIRVEIS_Debug;
     case DebugInfoEIS::OpenCL_DebugInfo_100:
       return SPIRVEIS_OpenCL_DebugInfo_100;
+    case DebugInfoEIS::NonSemantic_Shader_DebugInfo_100:
+      return SPIRVEIS_NonSemantic_Shader_DebugInfo_100;
     case DebugInfoEIS::NonSemantic_Kernel_DebugInfo_100:
       return SPIRVEIS_NonSemantic_Kernel_DebugInfo_100;
     }
index 60254ac47a21c1d51ae3ef178d3e00eb3c797023..8cb62b6a58d47c85a877e5b6751219e167c74204 100644 (file)
@@ -226,6 +226,13 @@ static cl::opt<SPIRV::DebugInfoEIS> DebugEIS(
                    "Emit debug info compliant with the OpenCL.DebugInfo.100 "
                    "extended instruction set. This version of SPIR-V debug "
                    "info format is compatible with the SPIRV-Tools"),
+        clEnumValN(
+            SPIRV::DebugInfoEIS::NonSemantic_Shader_DebugInfo_100,
+            "nonsemantic-shader-100",
+            "Emit debug info compliant with the "
+            "NonSemantic.Shader.DebugInfo.100 extended instruction set. This "
+            "version of SPIR-V debug info format is compatible with the rules "
+            "regarding non-semantic instruction sets."),
         clEnumValN(
             SPIRV::DebugInfoEIS::NonSemantic_Kernel_DebugInfo_100,
             "nonsemantic-kernel-100",