Skip to content

Commit ac2f01f

Browse files
authored
SPIRV: Add disassembly support for multiple literal strings (KhronosGroup#2397)
According to the extension SPV_GOOGLE_decorate_string, OpDecorateString (or OpMemberDecorateString) ought to be capable of supporting multiple literal strings. Each literal strings are padded with null terminator to make word alignment. The layout is: Inst | Target | Decoration | Literal String, Literal String, ...
1 parent 3933d7d commit ac2f01f

File tree

4 files changed

+10
-2
lines changed

4 files changed

+10
-2
lines changed

SPIRV/SPVRemapper.cpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -625,6 +625,9 @@ namespace spv {
625625
break;
626626
}
627627

628+
case spv::OperandVariableLiteralStrings:
629+
return nextInst;
630+
628631
// Execution mode might have extra literal operands. Skip them.
629632
case spv::OperandExecutionMode:
630633
return nextInst;

SPIRV/disassemble.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -519,6 +519,10 @@ void SpirvStream::disassembleInstruction(Id resultId, Id /*typeId*/, Op opCode,
519519
case OperandLiteralString:
520520
numOperands -= disassembleString();
521521
break;
522+
case OperandVariableLiteralStrings:
523+
while (numOperands > 0)
524+
numOperands -= disassembleString();
525+
return;
522526
case OperandMemoryAccess:
523527
outputMask(OperandMemoryAccess, stream[word++]);
524528
--numOperands;

SPIRV/doc.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1727,7 +1727,7 @@ void Parameterize()
17271727

17281728
InstructionDesc[OpDecorateStringGOOGLE].operands.push(OperandId, "'Target'");
17291729
InstructionDesc[OpDecorateStringGOOGLE].operands.push(OperandDecoration, "");
1730-
InstructionDesc[OpDecorateStringGOOGLE].operands.push(OperandLiteralString, "'Literal String'");
1730+
InstructionDesc[OpDecorateStringGOOGLE].operands.push(OperandVariableLiteralStrings, "'Literal Strings'");
17311731

17321732
InstructionDesc[OpMemberDecorate].operands.push(OperandId, "'Structure Type'");
17331733
InstructionDesc[OpMemberDecorate].operands.push(OperandLiteralNumber, "'Member'");
@@ -1737,7 +1737,7 @@ void Parameterize()
17371737
InstructionDesc[OpMemberDecorateStringGOOGLE].operands.push(OperandId, "'Structure Type'");
17381738
InstructionDesc[OpMemberDecorateStringGOOGLE].operands.push(OperandLiteralNumber, "'Member'");
17391739
InstructionDesc[OpMemberDecorateStringGOOGLE].operands.push(OperandDecoration, "");
1740-
InstructionDesc[OpMemberDecorateStringGOOGLE].operands.push(OperandLiteralString, "'Literal String'");
1740+
InstructionDesc[OpMemberDecorateStringGOOGLE].operands.push(OperandVariableLiteralStrings, "'Literal Strings'");
17411741

17421742
InstructionDesc[OpGroupDecorate].operands.push(OperandId, "'Decoration Group'");
17431743
InstructionDesc[OpGroupDecorate].operands.push(OperandVariableIds, "'Targets'");

SPIRV/doc.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -125,6 +125,7 @@ enum OperandClass {
125125
OperandVariableLiteralId,
126126
OperandLiteralNumber,
127127
OperandLiteralString,
128+
OperandVariableLiteralStrings,
128129
OperandSource,
129130
OperandExecutionModel,
130131
OperandAddressing,

0 commit comments

Comments
 (0)