From 3beb2a0373101562e1a1206edc33cf64fae87b54 Mon Sep 17 00:00:00 2001 From: John Kessenich Date: Tue, 12 Mar 2019 06:22:47 -0600 Subject: Add ability to skip ranges of instructions; no impact to public headers --- tools/buildHeaders/jsonToSpirv.cpp | 18 +++++++++++++++++- tools/buildHeaders/jsonToSpirv.h | 2 +- tools/buildHeaders/main.cpp | 2 +- 3 files changed, 19 insertions(+), 3 deletions(-) (limited to 'tools') diff --git a/tools/buildHeaders/jsonToSpirv.cpp b/tools/buildHeaders/jsonToSpirv.cpp index 62b85a8..e137241 100644 --- a/tools/buildHeaders/jsonToSpirv.cpp +++ b/tools/buildHeaders/jsonToSpirv.cpp @@ -230,7 +230,21 @@ unsigned int NumberStringToBit(const std::string& str) return bit; } -void jsonToSpirv(const std::string& jsonPath) +bool ExcludeInstruction(unsigned op, bool buildingHeaders) +{ + // Some instructions in the grammar don't need to be reflected + // in the specification. + + if (buildingHeaders) + return false; + + if (op >= 5699 /* OpVmeImageINTEL */ && op <= 5816 /* OpSubgroupAvcSicGetInterRawSadsINTEL */) + return true; + + return false; +} + +void jsonToSpirv(const std::string& jsonPath, bool buildingHeaders) { // only do this once. static bool initialized = false; @@ -288,6 +302,8 @@ void jsonToSpirv(const std::string& jsonPath) const Json::Value insts = root["instructions"]; for (const auto& inst : insts) { const unsigned int opcode = inst["opcode"].asUInt(); + if (ExcludeInstruction(opcode, buildingHeaders)) + continue; const std::string name = inst["opname"].asString(); EnumCaps caps = getCaps(inst); std::string version = inst["version"].asString(); diff --git a/tools/buildHeaders/jsonToSpirv.h b/tools/buildHeaders/jsonToSpirv.h index bc63a4d..68a141d 100644 --- a/tools/buildHeaders/jsonToSpirv.h +++ b/tools/buildHeaders/jsonToSpirv.h @@ -38,7 +38,7 @@ namespace spv { std::pair ReadFile(const std::string& path); // Fill in all the parameters -void jsonToSpirv(const std::string& jsonPath); +void jsonToSpirv(const std::string& jsonPath, bool buildingHeaders); // For parameterizing operands. enum OperandClass { diff --git a/tools/buildHeaders/main.cpp b/tools/buildHeaders/main.cpp index 67d676c..7e5f7f8 100644 --- a/tools/buildHeaders/main.cpp +++ b/tools/buildHeaders/main.cpp @@ -119,7 +119,7 @@ int main(int argc, char* argv[]) return 1; } - spv::jsonToSpirv(jsonPath); + spv::jsonToSpirv(jsonPath, (Options & EOptionPrintHeader) != 0); if (Options & EOptionPrintHeader) spv::PrintHeader(Language, std::cout); -- cgit v1.2.3