Skip to content

Commit a404529

Browse files
authored
[SPIRV] Add definitions for NonSemantic debug info (llvm#95530)
This commit adds basic types and definitions for NonSemantic.Shader.DebugInfo.100 standard for SPIRV. Full implementation of the standard will allow SPIRV backend to emit files with debug info included. Link to standard: https://github.com/KhronosGroup/SPIRV-Registry/blob/main/nonsemantic/NonSemantic.Shader.DebugInfo.100.html
1 parent 2cf1975 commit a404529

File tree

3 files changed

+70
-2
lines changed

3 files changed

+70
-2
lines changed

llvm/lib/Target/SPIRV/MCTargetDesc/SPIRVBaseInfo.cpp

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -198,6 +198,8 @@ std::string getExtInstSetName(SPIRV::InstructionSet::InstructionSet Set) {
198198
return "OpenCL.std";
199199
case SPIRV::InstructionSet::GLSL_std_450:
200200
return "GLSL.std.450";
201+
case SPIRV::InstructionSet::NonSemantic_Shader_DebugInfo_100:
202+
return "NonSemantic.Shader.DebugInfo.100";
201203
case SPIRV::InstructionSet::SPV_AMD_shader_trinary_minmax:
202204
return "SPV_AMD_shader_trinary_minmax";
203205
}
@@ -206,8 +208,9 @@ std::string getExtInstSetName(SPIRV::InstructionSet::InstructionSet Set) {
206208

207209
SPIRV::InstructionSet::InstructionSet
208210
getExtInstSetFromString(std::string SetName) {
209-
for (auto Set : {SPIRV::InstructionSet::GLSL_std_450,
210-
SPIRV::InstructionSet::OpenCL_std}) {
211+
for (auto Set :
212+
{SPIRV::InstructionSet::GLSL_std_450, SPIRV::InstructionSet::OpenCL_std,
213+
SPIRV::InstructionSet::NonSemantic_Shader_DebugInfo_100}) {
211214
if (SetName == getExtInstSetName(Set))
212215
return Set;
213216
}

llvm/lib/Target/SPIRV/MCTargetDesc/SPIRVBaseInfo.h

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -197,6 +197,11 @@ namespace GLSLExtInst {
197197
#include "SPIRVGenTables.inc"
198198
} // namespace GLSLExtInst
199199

200+
namespace NonSemanticExtInst {
201+
#define GET_NonSemanticExtInst_DECL
202+
#include "SPIRVGenTables.inc"
203+
} // namespace NonSemanticExtInst
204+
200205
namespace Opcode {
201206
#define GET_Opcode_DECL
202207
#include "SPIRVGenTables.inc"

llvm/lib/Target/SPIRV/SPIRVBuiltins.td

Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ class InstructionSet<bits<32> value> {
2626
def OpenCL_std : InstructionSet<0>;
2727
def GLSL_std_450 : InstructionSet<1>;
2828
def SPV_AMD_shader_trinary_minmax : InstructionSet<2>;
29+
def NonSemantic_Shader_DebugInfo_100 : InstructionSet<3>;
2930

3031
// Define various builtin groups
3132
def BuiltinGroup : GenericEnum {
@@ -176,6 +177,17 @@ class GLSLExtInst<string name, bits<32> value> {
176177
bits<32> Value = value;
177178
}
178179

180+
def NonSemanticExtInst : GenericEnum {
181+
let FilterClass = "NonSemanticExtInst";
182+
let NameField = "Name";
183+
let ValueField = "Value";
184+
}
185+
186+
class NonSemanticExtInst<string name, bits<32> value> {
187+
string Name = name;
188+
bits<32> Value = value;
189+
}
190+
179191
// Multiclass used to define at the same time both a demangled builtin record
180192
// and a corresponding extended builtin record.
181193
multiclass DemangledExtendedBuiltin<string name, InstructionSet set, int number> {
@@ -189,6 +201,10 @@ multiclass DemangledExtendedBuiltin<string name, InstructionSet set, int number>
189201
if !eq(set, GLSL_std_450) then {
190202
def : GLSLExtInst<name, number>;
191203
}
204+
205+
if !eq(set, NonSemantic_Shader_DebugInfo_100) then {
206+
def : NonSemanticExtInst<name, number>;
207+
}
192208
}
193209

194210
// Extended builtin records:
@@ -436,6 +452,50 @@ defm : DemangledExtendedBuiltin<"NMin", GLSL_std_450, 79>;
436452
defm : DemangledExtendedBuiltin<"NMax", GLSL_std_450, 80>;
437453
defm : DemangledExtendedBuiltin<"NClamp", GLSL_std_450, 81>;
438454

455+
defm : DemangledExtendedBuiltin<"DebugInfoNone", NonSemantic_Shader_DebugInfo_100, 0>;
456+
defm : DemangledExtendedBuiltin<"DebugCompilationUnit", NonSemantic_Shader_DebugInfo_100, 1>;
457+
defm : DemangledExtendedBuiltin<"DebugTypeBasic", NonSemantic_Shader_DebugInfo_100, 2>;
458+
defm : DemangledExtendedBuiltin<"DebugTypePointer", NonSemantic_Shader_DebugInfo_100, 3>;
459+
defm : DemangledExtendedBuiltin<"DebugTypeQualifier", NonSemantic_Shader_DebugInfo_100, 4>;
460+
defm : DemangledExtendedBuiltin<"DebugTypeArray", NonSemantic_Shader_DebugInfo_100, 5>;
461+
defm : DemangledExtendedBuiltin<"DebugTypeVector", NonSemantic_Shader_DebugInfo_100, 6>;
462+
defm : DemangledExtendedBuiltin<"DebugTypedef", NonSemantic_Shader_DebugInfo_100, 7>;
463+
defm : DemangledExtendedBuiltin<"DebugTypeFunction", NonSemantic_Shader_DebugInfo_100, 8>;
464+
defm : DemangledExtendedBuiltin<"DebugTypeEnum", NonSemantic_Shader_DebugInfo_100, 9>;
465+
defm : DemangledExtendedBuiltin<"DebugTypeComposite", NonSemantic_Shader_DebugInfo_100, 10>;
466+
defm : DemangledExtendedBuiltin<"DebugTypeMember", NonSemantic_Shader_DebugInfo_100, 11>;
467+
defm : DemangledExtendedBuiltin<"DebugTypeInheritance", NonSemantic_Shader_DebugInfo_100, 12>;
468+
defm : DemangledExtendedBuiltin<"DebugTypePtrToMember", NonSemantic_Shader_DebugInfo_100, 13>;
469+
defm : DemangledExtendedBuiltin<"DebugTypeTemplate", NonSemantic_Shader_DebugInfo_100, 14>;
470+
defm : DemangledExtendedBuiltin<"DebugTypeTemplateParameter", NonSemantic_Shader_DebugInfo_100, 15>;
471+
defm : DemangledExtendedBuiltin<"DebugTypeTemplateTemplateParameter", NonSemantic_Shader_DebugInfo_100, 16>;
472+
defm : DemangledExtendedBuiltin<"DebugTypeTemplateParameterPack", NonSemantic_Shader_DebugInfo_100, 17>;
473+
defm : DemangledExtendedBuiltin<"DebugGlobalVariable", NonSemantic_Shader_DebugInfo_100, 18>;
474+
defm : DemangledExtendedBuiltin<"DebugFunctionDeclaration", NonSemantic_Shader_DebugInfo_100, 19>;
475+
defm : DemangledExtendedBuiltin<"DebugFunction", NonSemantic_Shader_DebugInfo_100, 20>;
476+
defm : DemangledExtendedBuiltin<"DebugLexicalBlock", NonSemantic_Shader_DebugInfo_100, 21>;
477+
defm : DemangledExtendedBuiltin<"DebugLexicalBlockDiscriminator", NonSemantic_Shader_DebugInfo_100, 22>;
478+
defm : DemangledExtendedBuiltin<"DebugScope", NonSemantic_Shader_DebugInfo_100, 23>;
479+
defm : DemangledExtendedBuiltin<"DebugNoScope", NonSemantic_Shader_DebugInfo_100, 24>;
480+
defm : DemangledExtendedBuiltin<"DebugInlinedAt", NonSemantic_Shader_DebugInfo_100, 25>;
481+
defm : DemangledExtendedBuiltin<"DebugLocalVariable", NonSemantic_Shader_DebugInfo_100, 26>;
482+
defm : DemangledExtendedBuiltin<"DebugInlinedVariable", NonSemantic_Shader_DebugInfo_100, 27>;
483+
defm : DemangledExtendedBuiltin<"DebugDeclare", NonSemantic_Shader_DebugInfo_100, 28>;
484+
defm : DemangledExtendedBuiltin<"DebugValue", NonSemantic_Shader_DebugInfo_100, 29>;
485+
defm : DemangledExtendedBuiltin<"DebugOperation", NonSemantic_Shader_DebugInfo_100, 30>;
486+
defm : DemangledExtendedBuiltin<"DebugExpression", NonSemantic_Shader_DebugInfo_100, 31>;
487+
defm : DemangledExtendedBuiltin<"DebugMacroDef", NonSemantic_Shader_DebugInfo_100, 32>;
488+
defm : DemangledExtendedBuiltin<"DebugMacroUndef", NonSemantic_Shader_DebugInfo_100, 33>;
489+
defm : DemangledExtendedBuiltin<"DebugImportedEntity", NonSemantic_Shader_DebugInfo_100, 34>;
490+
defm : DemangledExtendedBuiltin<"DebugSource", NonSemantic_Shader_DebugInfo_100, 35>;
491+
defm : DemangledExtendedBuiltin<"DebugFunctionDefinition", NonSemantic_Shader_DebugInfo_100, 101>;
492+
defm : DemangledExtendedBuiltin<"DebugSourceContinued", NonSemantic_Shader_DebugInfo_100, 102>;
493+
defm : DemangledExtendedBuiltin<"DebugLine", NonSemantic_Shader_DebugInfo_100, 103>;
494+
defm : DemangledExtendedBuiltin<"DebugNoLine", NonSemantic_Shader_DebugInfo_100, 104>;
495+
defm : DemangledExtendedBuiltin<"DebugBuildIdentifier", NonSemantic_Shader_DebugInfo_100, 105>;
496+
defm : DemangledExtendedBuiltin<"DebugStoragePath", NonSemantic_Shader_DebugInfo_100, 106>;
497+
defm : DemangledExtendedBuiltin<"DebugEntryPoint", NonSemantic_Shader_DebugInfo_100, 107>;
498+
defm : DemangledExtendedBuiltin<"DebugTypeMatrix", NonSemantic_Shader_DebugInfo_100, 108>;
439499
//===----------------------------------------------------------------------===//
440500
// Class defining an native builtin record used for direct translation into a
441501
// SPIR-V instruction.

0 commit comments

Comments
 (0)