Skip to content

Commit

Permalink
[DebugInfo] Add an option for NonSemantic.Shader.DebugInfo.100 (#1855)
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
MrSidims authored Mar 1, 2023
1 parent 02d37bb commit a8c3ba2
Show file tree
Hide file tree
Showing 9 changed files with 25 additions and 0 deletions.
1 change: 1 addition & 0 deletions include/LLVMSPIRVOpts.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
};

Expand Down
2 changes: 2 additions & 0 deletions lib/SPIRV/SPIRVToLLVMDbgTran.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down
2 changes: 2 additions & 0 deletions lib/SPIRV/SPIRVToLLVMDbgTran.h
Original file line number Diff line number Diff line change
Expand Up @@ -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");
Expand Down
3 changes: 3 additions & 0 deletions lib/SPIRV/libSPIRV/SPIRVEnum.h
Original file line number Diff line number Diff line change
Expand Up @@ -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,
};
Expand Down Expand Up @@ -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");
}
Expand Down
4 changes: 4 additions & 0 deletions lib/SPIRV/libSPIRV/SPIRVFunction.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
3 changes: 3 additions & 0 deletions lib/SPIRV/libSPIRV/SPIRVInstruction.h
Original file line number Diff line number Diff line change
Expand Up @@ -1762,6 +1762,7 @@ class SPIRVExtInst : public SPIRVFunctionCallGeneric<OpExtInst, 5> {
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");
}
Expand All @@ -1773,6 +1774,7 @@ class SPIRVExtInst : public SPIRVFunctionCallGeneric<OpExtInst, 5> {
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;
Expand All @@ -1791,6 +1793,7 @@ class SPIRVExtInst : public SPIRVFunctionCallGeneric<OpExtInst, 5> {
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;
Expand Down
1 change: 1 addition & 0 deletions lib/SPIRV/libSPIRV/SPIRVModule.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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 &&
Expand Down
2 changes: 2 additions & 0 deletions lib/SPIRV/libSPIRV/SPIRVModule.h
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down
7 changes: 7 additions & 0 deletions tools/llvm-spirv/llvm-spirv.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -229,6 +229,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",
Expand Down

0 comments on commit a8c3ba2

Please sign in to comment.