SPIRV: Add disassembly support for multiple literal strings (#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, ...
This commit is contained in:
Rex Xu 2020-09-14 11:57:09 -04:00 committed by GitHub
parent 3933d7d414
commit ac2f01f4bd
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 10 additions and 2 deletions

View File

@ -625,6 +625,9 @@ namespace spv {
break; break;
} }
case spv::OperandVariableLiteralStrings:
return nextInst;
// Execution mode might have extra literal operands. Skip them. // Execution mode might have extra literal operands. Skip them.
case spv::OperandExecutionMode: case spv::OperandExecutionMode:
return nextInst; return nextInst;

View File

@ -519,6 +519,10 @@ void SpirvStream::disassembleInstruction(Id resultId, Id /*typeId*/, Op opCode,
case OperandLiteralString: case OperandLiteralString:
numOperands -= disassembleString(); numOperands -= disassembleString();
break; break;
case OperandVariableLiteralStrings:
while (numOperands > 0)
numOperands -= disassembleString();
return;
case OperandMemoryAccess: case OperandMemoryAccess:
outputMask(OperandMemoryAccess, stream[word++]); outputMask(OperandMemoryAccess, stream[word++]);
--numOperands; --numOperands;

View File

@ -1727,7 +1727,7 @@ void Parameterize()
InstructionDesc[OpDecorateStringGOOGLE].operands.push(OperandId, "'Target'"); InstructionDesc[OpDecorateStringGOOGLE].operands.push(OperandId, "'Target'");
InstructionDesc[OpDecorateStringGOOGLE].operands.push(OperandDecoration, ""); InstructionDesc[OpDecorateStringGOOGLE].operands.push(OperandDecoration, "");
InstructionDesc[OpDecorateStringGOOGLE].operands.push(OperandLiteralString, "'Literal String'"); InstructionDesc[OpDecorateStringGOOGLE].operands.push(OperandVariableLiteralStrings, "'Literal Strings'");
InstructionDesc[OpMemberDecorate].operands.push(OperandId, "'Structure Type'"); InstructionDesc[OpMemberDecorate].operands.push(OperandId, "'Structure Type'");
InstructionDesc[OpMemberDecorate].operands.push(OperandLiteralNumber, "'Member'"); InstructionDesc[OpMemberDecorate].operands.push(OperandLiteralNumber, "'Member'");
@ -1737,7 +1737,7 @@ void Parameterize()
InstructionDesc[OpMemberDecorateStringGOOGLE].operands.push(OperandId, "'Structure Type'"); InstructionDesc[OpMemberDecorateStringGOOGLE].operands.push(OperandId, "'Structure Type'");
InstructionDesc[OpMemberDecorateStringGOOGLE].operands.push(OperandLiteralNumber, "'Member'"); InstructionDesc[OpMemberDecorateStringGOOGLE].operands.push(OperandLiteralNumber, "'Member'");
InstructionDesc[OpMemberDecorateStringGOOGLE].operands.push(OperandDecoration, ""); InstructionDesc[OpMemberDecorateStringGOOGLE].operands.push(OperandDecoration, "");
InstructionDesc[OpMemberDecorateStringGOOGLE].operands.push(OperandLiteralString, "'Literal String'"); InstructionDesc[OpMemberDecorateStringGOOGLE].operands.push(OperandVariableLiteralStrings, "'Literal Strings'");
InstructionDesc[OpGroupDecorate].operands.push(OperandId, "'Decoration Group'"); InstructionDesc[OpGroupDecorate].operands.push(OperandId, "'Decoration Group'");
InstructionDesc[OpGroupDecorate].operands.push(OperandVariableIds, "'Targets'"); InstructionDesc[OpGroupDecorate].operands.push(OperandVariableIds, "'Targets'");

View File

@ -125,6 +125,7 @@ enum OperandClass {
OperandVariableLiteralId, OperandVariableLiteralId,
OperandLiteralNumber, OperandLiteralNumber,
OperandLiteralString, OperandLiteralString,
OperandVariableLiteralStrings,
OperandSource, OperandSource,
OperandExecutionModel, OperandExecutionModel,
OperandAddressing, OperandAddressing,