From: Dmitry Sidorov Date: Wed, 1 Mar 2023 18:23:49 +0000 (+0100) Subject: [PATCH 21/79] [Backport to 15][DebugInfo] Add an option for NonSemantic.Shader.DebugI... X-Git-Tag: archive/raspbian/15.0.0-6+rpi1^2~60 X-Git-Url: https://dgit.raspbian.org/?a=commitdiff_plain;h=a79bc2541665a19c985f2a31c858eadc97359c17;p=spirv-llvm-translator-15.git [PATCH 21/79] [Backport to 15][DebugInfo] Add an option for NonSemantic.Shader.DebugInfo.100 (#1855) 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 Gbp-Pq: Name 0021-Backport-to-15-DebugInfo-Add-an-option-for-NonSemant.patch --- diff --git a/include/LLVMSPIRVOpts.h b/include/LLVMSPIRVOpts.h index 8c14037..e821a1f 100644 --- a/include/LLVMSPIRVOpts.h +++ b/include/LLVMSPIRVOpts.h @@ -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 }; diff --git a/lib/SPIRV/SPIRVToLLVMDbgTran.cpp b/lib/SPIRV/SPIRVToLLVMDbgTran.cpp index e2d4e9a..2178582 100644 --- a/lib/SPIRV/SPIRVToLLVMDbgTran.cpp +++ b/lib/SPIRV/SPIRVToLLVMDbgTran.cpp @@ -92,6 +92,8 @@ SPIRVExtInst *SPIRVToLLVMDbgTran::getDbgInst(const SPIRVId Id) { SPIRVExtInst *EI = static_cast(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; } diff --git a/lib/SPIRV/SPIRVToLLVMDbgTran.h b/lib/SPIRV/SPIRVToLLVMDbgTran.h index 3a0f78d..68a8351 100644 --- a/lib/SPIRV/SPIRVToLLVMDbgTran.h +++ b/lib/SPIRV/SPIRVToLLVMDbgTran.h @@ -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"); diff --git a/lib/SPIRV/libSPIRV/SPIRVEnum.h b/lib/SPIRV/libSPIRV/SPIRVEnum.h index 4e4cbf8..9bb59b6 100644 --- a/lib/SPIRV/libSPIRV/SPIRVEnum.h +++ b/lib/SPIRV/libSPIRV/SPIRVEnum.h @@ -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::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"); } diff --git a/lib/SPIRV/libSPIRV/SPIRVFunction.cpp b/lib/SPIRV/libSPIRV/SPIRVFunction.cpp index c91a650..64aa40f 100644 --- a/lib/SPIRV/libSPIRV/SPIRVFunction.cpp +++ b/lib/SPIRV/libSPIRV/SPIRVFunction.cpp @@ -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; diff --git a/lib/SPIRV/libSPIRV/SPIRVInstruction.h b/lib/SPIRV/libSPIRV/SPIRVInstruction.h index 69a12ca..568885f 100644 --- a/lib/SPIRV/libSPIRV/SPIRVInstruction.h +++ b/lib/SPIRV/libSPIRV/SPIRVInstruction.h @@ -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; diff --git a/lib/SPIRV/libSPIRV/SPIRVModule.cpp b/lib/SPIRV/libSPIRV/SPIRVModule.cpp index cc64266..5cbc2a8 100644 --- a/lib/SPIRV/libSPIRV/SPIRVModule.cpp +++ b/lib/SPIRV/libSPIRV/SPIRVModule.cpp @@ -643,6 +643,7 @@ void SPIRVModuleImpl::layoutEntry(SPIRVEntry *E) { SPIRVExtInst *EI = static_cast(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 && diff --git a/lib/SPIRV/libSPIRV/SPIRVModule.h b/lib/SPIRV/libSPIRV/SPIRVModule.h index 2ec832c..bd462aa 100644 --- a/lib/SPIRV/libSPIRV/SPIRVModule.h +++ b/lib/SPIRV/libSPIRV/SPIRVModule.h @@ -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; } diff --git a/tools/llvm-spirv/llvm-spirv.cpp b/tools/llvm-spirv/llvm-spirv.cpp index 60254ac..8cb62b6 100644 --- a/tools/llvm-spirv/llvm-spirv.cpp +++ b/tools/llvm-spirv/llvm-spirv.cpp @@ -226,6 +226,13 @@ static cl::opt 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",