summaryrefslogtreecommitdiffstats
path: root/tools
diff options
context:
space:
mode:
authorJay Kwak <82421531+jkwak-work@users.noreply.github.com>2024-10-21 22:24:39 -0700
committerGitHub <noreply@github.com>2024-10-21 22:24:39 -0700
commitba775784bbe45a72ead8aab7b34df2804e599e23 (patch)
tree98e733c8707de81c9c5d9b730ea7eba8115bc985 /tools
parent3e84726f45c66b477569be9e62da71956ab78e94 (diff)
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.
Diffstat (limited to 'tools')
-rw-r--r--tools/slang-lookup-generator/lookup-generator-main.cpp13
1 files changed, 13 insertions, 0 deletions
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<String> extractOpNames(UnownedStringSlice& error, const JSONValue& v
// List<String> 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<String> 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;