From ba775784bbe45a72ead8aab7b34df2804e599e23 Mon Sep 17 00:00:00 2001 From: Jay Kwak <82421531+jkwak-work@users.noreply.github.com> Date: Mon, 21 Oct 2024 22:24:39 -0700 Subject: Recognize a new spirv header json grammar keyword "aliases" (#5367) * Recognize a JSON keyword "aliases" for SPIRV-header This commit will handle the new JSON keyword "aliases" in SPIRV-Header grammar files. "aliases" are used in two places: one for "opname" and another for "enumerants". This commit itself wouldn't do anything until we integrate new commits from SPIRV-Header repo. --- tools/slang-lookup-generator/lookup-generator-main.cpp | 13 +++++++++++++ 1 file changed, 13 insertions(+) (limited to 'tools') diff --git a/tools/slang-lookup-generator/lookup-generator-main.cpp b/tools/slang-lookup-generator/lookup-generator-main.cpp index b99cf0e53..5806d6397 100644 --- a/tools/slang-lookup-generator/lookup-generator-main.cpp +++ b/tools/slang-lookup-generator/lookup-generator-main.cpp @@ -38,6 +38,7 @@ static List extractOpNames(UnownedStringSlice& error, const JSONValue& v // List result = match(myJSONValue, "instructions", AsArray, "opname", AsString); const auto instKey = container.findKey(UnownedStringSlice("instructions")); const auto opnameKey = container.findKey(UnownedStringSlice("opname")); + const auto aliasesKey = container.findKey(UnownedStringSlice("aliases")); if (!instKey) { error = UnownedStringSlice("JSON parsing failed, no \"instructions\" key\n"); @@ -64,6 +65,18 @@ static List extractOpNames(UnownedStringSlice& error, const JSONValue& v return {}; } opnames.add(container.getString(opname)); + + if (aliasesKey) + { + auto aliases = container.findObjectValue(inst, aliasesKey); + if (aliases.isValid() && aliases.type == JSONValue::Type::Array) + { + for (auto& alias : container.getArray(aliases)) + { + opnames.add(container.getString(alias)); + } + } + } } return opnames; -- cgit v1.2.3