diff --git a/include/LLVMSPIRVOpts.h b/include/LLVMSPIRVOpts.h index 24e24df92d..930f38445b 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 6250a36149..49a5f5bb28 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 391e562222..16edb78e70 100644 --- a/lib/SPIRV/SPIRVToLLVMDbgTran.h +++ b/lib/SPIRV/SPIRVToLLVMDbgTran.h @@ -71,6 +71,8 @@ class SPIRVToLLVMDbgTran { 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 54f7ee35f1..0f03e25088 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 c91a650693..64aa40f6dc 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 46a4862f86..74bffd677d 100644 --- a/lib/SPIRV/libSPIRV/SPIRVInstruction.h +++ b/lib/SPIRV/libSPIRV/SPIRVInstruction.h @@ -1762,6 +1762,7 @@ class SPIRVExtInst : public SPIRVFunctionCallGeneric { 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 @@ class SPIRVExtInst : public SPIRVFunctionCallGeneric { 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 @@ class SPIRVExtInst : public SPIRVFunctionCallGeneric { 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 c8387b45f8..477b7d708e 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 2ec832c0ad..bd462aa4d8 100644 --- a/lib/SPIRV/libSPIRV/SPIRVModule.h +++ b/lib/SPIRV/libSPIRV/SPIRVModule.h @@ -528,6 +528,8 @@ class SPIRVModule { 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 75b7b55f3f..6beaaaaf35 100644 --- a/tools/llvm-spirv/llvm-spirv.cpp +++ b/tools/llvm-spirv/llvm-spirv.cpp @@ -229,6 +229,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",