From 3f4081d854db2d186adea4067da575eca7c7adf1 Mon Sep 17 00:00:00 2001 From: Ellie Hermaszewska Date: Tue, 12 Sep 2023 17:44:34 +0800 Subject: Correctly identify the number of operands to image sampling operands in SPIR-V (#3200) * Correctly identify the number of operands to image sampling operands in SPIR-V * Neaten imageoperands warning test * Neaten imageoperands warning test --- source/compiler-core/slang-spirv-core-grammar.cpp | 24 ++++++++++++++++------- 1 file changed, 17 insertions(+), 7 deletions(-) (limited to 'source/compiler-core') diff --git a/source/compiler-core/slang-spirv-core-grammar.cpp b/source/compiler-core/slang-spirv-core-grammar.cpp index 8140d002a..9a4a7e17f 100644 --- a/source/compiler-core/slang-spirv-core-grammar.cpp +++ b/source/compiler-core/slang-spirv-core-grammar.cpp @@ -265,7 +265,17 @@ RefPtr SPIRVCoreGrammarInfo::loadFromJSON(SourceView& sour numOperandTypes++; res->operandTypesStorage.add(*catIndex); - if(o.quantifier == "") + // The number of "ImageOperands" is dependent on the bitmask + // operand, for our purposes treat them as unbounded + if(o.quantifier == "*" || o.kind == "ImageOperands") + { + maxOperandCount = 0xffff; + } + else if(o.quantifier == "?") + { + maxOperandCount++; + } + else if(o.quantifier == "") { // This catches the case where an "?" or "*" qualified operand // appears before any unqualified operands @@ -278,13 +288,13 @@ RefPtr SPIRVCoreGrammarInfo::loadFromJSON(SourceView& sour minOperandCount++; maxOperandCount++; } - else if(o.quantifier == "?") - { - maxOperandCount++; - } - else if(o.quantifier == "*") + else { - maxOperandCount = 0xffff; + sink.diagnose( + SourceLoc{}, + MiscDiagnostics::spirvCoreGrammarJSONParseFailure, + "quantifier wasn't empty, * or ?" + ); } } -- cgit v1.2.3