aboutsummaryrefslogtreecommitdiff
path: root/tools
diff options
context:
space:
mode:
Diffstat (limited to 'tools')
-rw-r--r--[-rwxr-xr-x]tools/buildHeaders/CMakeLists.txt0
-rwxr-xr-xtools/buildHeaders/bin/makeHeaders2
-rw-r--r--[-rwxr-xr-x]tools/buildHeaders/header.cpp170
-rw-r--r--[-rwxr-xr-x]tools/buildHeaders/header.h14
-rw-r--r--[-rwxr-xr-x]tools/buildHeaders/jsonToSpirv.cpp33
-rw-r--r--[-rwxr-xr-x]tools/buildHeaders/jsonToSpirv.h36
-rw-r--r--[-rwxr-xr-x]tools/buildHeaders/main.cpp20
7 files changed, 221 insertions, 54 deletions
diff --git a/tools/buildHeaders/CMakeLists.txt b/tools/buildHeaders/CMakeLists.txt
index c624151..c624151 100755..100644
--- a/tools/buildHeaders/CMakeLists.txt
+++ b/tools/buildHeaders/CMakeLists.txt
diff --git a/tools/buildHeaders/bin/makeHeaders b/tools/buildHeaders/bin/makeHeaders
index bf2c615..47d2218 100755
--- a/tools/buildHeaders/bin/makeHeaders
+++ b/tools/buildHeaders/bin/makeHeaders
@@ -2,4 +2,4 @@
cd ../../include/spirv/unified1
../../../tools/buildHeaders/build/install/bin/buildSpvHeaders -H spirv.core.grammar.json
-dos2unix spirv.*
+dos2unix spirv.* SpirV.* spv.*
diff --git a/tools/buildHeaders/header.cpp b/tools/buildHeaders/header.cpp
index b8b227f..e1e05d0 100755..100644
--- a/tools/buildHeaders/header.cpp
+++ b/tools/buildHeaders/header.cpp
@@ -1,19 +1,19 @@
-// Copyright (c) 2014-2018 The Khronos Group Inc.
-//
+// Copyright (c) 2014-2019 The Khronos Group Inc.
+//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and/or associated documentation files (the "Materials"),
// to deal in the Materials without restriction, including without limitation
// the rights to use, copy, modify, merge, publish, distribute, sublicense,
// and/or sell copies of the Materials, and to permit persons to whom the
// Materials are furnished to do so, subject to the following conditions:
-//
+//
// The above copyright notice and this permission notice shall be included in
// all copies or substantial portions of the Materials.
-//
+//
// MODIFICATIONS TO THIS FILE MAY MEAN IT NO LONGER ACCURATELY REFLECTS KHRONOS
// STANDARDS. THE UNMODIFIED, NORMATIVE VERSIONS OF KHRONOS SPECIFICATIONS AND
-// HEADER INFORMATION ARE LOCATED AT https://www.khronos.org/registry/
-//
+// HEADER INFORMATION ARE LOCATED AT https://www.khronos.org/registry/
+//
// THE MATERIALS ARE PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
@@ -42,6 +42,7 @@
#include <cctype>
#include <vector>
#include <utility>
+#include <set>
#include "jsoncpp/dist/json/json.h"
@@ -68,7 +69,7 @@ namespace {
TPrinter();
static const int DocMagicNumber = 0x07230203;
- static const int DocVersion = 0x00010300;
+ static const int DocVersion = 0x00010400;
static const int DocRevision = 1;
#define DocRevisionString "1"
static const std::string DocCopyright;
@@ -97,7 +98,8 @@ namespace {
virtual void printEpilogue(std::ostream&) const { }
virtual void printMeta(std::ostream&) const;
virtual void printTypes(std::ostream&) const { }
-
+ virtual void printHasResultType(std::ostream&) const { };
+
virtual std::string escapeComment(const std::string& s) const;
// Default printComments() uses these comment strings
@@ -107,7 +109,7 @@ namespace {
virtual std::string commentEOL(bool isLast) const { return ""; }
typedef std::pair<unsigned, std::string> valpair_t;
-
+
// for printing enum values
virtual std::string enumBeg(const std::string&, enumStyle_t) const { return ""; }
virtual std::string enumEnd(const std::string&, enumStyle_t, bool isLast = false) const {
@@ -126,7 +128,7 @@ namespace {
const char* fmt, bool isLast = false) const {
return "";
}
-
+
std::vector<valpair_t> getSortedVals(const Json::Value&) const;
virtual std::string indent(int count = 1) const {
@@ -149,7 +151,7 @@ namespace {
}
void addComment(Json::Value& node, const std::string& str);
-
+
Json::Value spvRoot; // JSON SPIR-V data
};
@@ -167,7 +169,7 @@ namespace {
}
const std::string TPrinter::DocCopyright =
- "Copyright (c) 2014-2018 The Khronos Group Inc.\n"
+ "Copyright (c) 2014-2019 The Khronos Group Inc.\n"
"\n"
"Permission is hereby granted, free of charge, to any person obtaining a copy\n"
"of this software and/or associated documentation files (the \"Materials\"),\n"
@@ -197,13 +199,16 @@ namespace {
const std::string TPrinter::DocComment2 =
"Enumeration tokens for SPIR-V, in various styles:\n"
- " C, C++, C++11, JSON, Lua, Python\n"
+ " C, C++, C++11, JSON, Lua, Python, C#, D\n"
"\n"
"- C will have tokens with a \"Spv\" prefix, e.g.: SpvSourceLanguageGLSL\n"
"- C++ will have tokens in the \"spv\" name space, e.g.: spv::SourceLanguageGLSL\n"
"- C++11 will use enum classes in the spv namespace, e.g.: spv::SourceLanguage::GLSL\n"
"- Lua will use tables, e.g.: spv.SourceLanguage.GLSL\n"
"- Python will use dictionaries, e.g.: spv['SourceLanguage']['GLSL']\n"
+ "- C# will use enum classes in the Specification class located in the \"Spv\" namespace,\n"
+ " e.g.: Spv.Specification.SourceLanguage.GLSL\n"
+ "- D will have tokens under the \"spv\" module, e.g: spv.SourceLanguage.GLSL\n"
"\n"
"Some tokens act like mask values, which can be OR'd together,\n"
"while others are mutually exclusive. The mask-like ones have\n"
@@ -290,7 +295,7 @@ namespace {
{
const int commentCount = spvRoot["spv"]["meta"]["Comment"].size();
int commentNum = 0;
-
+
for (const auto& comment : spvRoot["spv"]["meta"]["Comment"]) {
out << commentBeg();
@@ -322,7 +327,7 @@ namespace {
void TPrinter::printDefs(std::ostream& out) const
{
const Json::Value& enums = spvRoot["spv"]["enum"];
-
+
for (auto opClass = enums.begin(); opClass != enums.end(); ++opClass) {
const bool isMask = (*opClass)["Type"].asString() == "Bit";
const auto opName = (*opClass)["Name"].asString();
@@ -337,13 +342,13 @@ namespace {
out << enumFmt(opPrefix, valpair_t(0, "MaskNone"), enumNoMask);
const auto sorted = getSortedVals((*opClass)["Values"]);
-
- std::string maxEnum = maxEnumFmt(opName, valpair_t(0x7FFFFFFF, "Max"), enumHex);
+
+ std::string maxEnum = maxEnumFmt(opName, valpair_t(0x7FFFFFFF, "Max"), enumHex);
bool printMax = (style != enumMask && maxEnum.size() > 0);
for (const auto& v : sorted)
- out << enumFmt(opPrefix, v, style, !printMax && v.first == sorted.back().first);
+ out << enumFmt(opPrefix, v, style, !printMax && v.second == sorted.back().second);
if (printMax)
out << maxEnum;
@@ -361,6 +366,7 @@ namespace {
printTypes(out);
printMeta(out);
printDefs(out);
+ printHasResultType(out);
printEpilogue(out);
}
@@ -390,7 +396,7 @@ namespace {
}
return newStr;
}
-
+
std::string fmtConstInt(unsigned val, const std::string& name,
const char* fmt, bool isLast) const override {
return indent(3) + '"' + name + "\": " + fmtNum("%d", val) + (isLast ? "\n" : ",\n");
@@ -475,7 +481,7 @@ namespace {
}
virtual void printEpilogue(std::ostream& out) const override {
- out << "#endif // #ifndef spirv_" << headerGuardSuffix() << std::endl;
+ out << "#endif" << std::endl;
}
virtual void printTypes(std::ostream& out) const override {
@@ -488,9 +494,48 @@ namespace {
return std::string("static const unsigned int ") + pre() + name +
" = " + fmtNum(fmt, val) + (isLast ? ";\n\n" : ";\n");
}
-
+
virtual std::string pre() const { return ""; } // C name prefix
virtual std::string headerGuardSuffix() const = 0;
+
+ virtual std::string fmtEnumUse(const std::string& opPrefix, const std::string& name) const { return pre() + name; }
+
+ virtual void printHasResultType(std::ostream& out) const
+ {
+ const Json::Value& enums = spvRoot["spv"]["enum"];
+
+ std::set<unsigned> seenValues;
+
+ for (auto opClass = enums.begin(); opClass != enums.end(); ++opClass) {
+ const auto opName = (*opClass)["Name"].asString();
+ if (opName != "Op") {
+ continue;
+ }
+
+ out << "#ifdef SPV_ENABLE_UTILITY_CODE" << std::endl;
+ out << "inline void " << pre() << "HasResultAndType(" << pre() << opName << " opcode, bool *hasResult, bool *hasResultType) {" << std::endl;
+ out << " *hasResult = *hasResultType = false;" << std::endl;
+ out << " switch (opcode) {" << std::endl;
+ out << " default: /* unknown opcode */ break;" << std::endl;
+
+ for (auto& inst : spv::InstructionDesc) {
+
+ // Filter out duplicate enum values, which would break the switch statement.
+ // These are probably just extension enums promoted to core.
+ if (seenValues.find(inst.value) != seenValues.end()) {
+ continue;
+ }
+ seenValues.insert(inst.value);
+
+ std::string name = inst.name;
+ out << " case " << fmtEnumUse("Op", name) << ": *hasResult = " << (inst.hasResult() ? "true" : "false") << "; *hasResultType = " << (inst.hasType() ? "true" : "false") << "; break;" << std::endl;
+ }
+
+ out << " }" << std::endl;
+ out << "}" << std::endl;
+ out << "#endif /* SPV_ENABLE_UTILITY_CODE */" << std::endl << std::endl;
+ }
+ }
};
// C printer
@@ -542,19 +587,19 @@ namespace {
if (isMask) {
const auto typeName = opName + styleStr(enumMask);
-
+
out << "inline " + typeName + " operator|(" + typeName + " a, " + typeName + " b) { return " +
typeName + "(unsigned(a) | unsigned(b)); }\n";
}
}
out << "\n} // end namespace spv\n\n";
- TPrinterCBase::printEpilogue(out);
+ out << "#endif // #ifndef spirv_" << headerGuardSuffix() << std::endl;
}
std::string commentBOL() const override { return "// "; }
-
+
virtual std::string enumBeg(const std::string& s, enumStyle_t style) const override {
return std::string("enum ") + s + styleStr(style) + " {\n";
}
@@ -597,6 +642,9 @@ namespace {
return enumFmt(s, v, style, true);
}
+ // Add type prefix for scoped enum
+ virtual std::string fmtEnumUse(const std::string& opPrefix, const std::string& name) const { return opPrefix + "::" + name; }
+
std::string headerGuardSuffix() const override { return "HPP"; }
};
@@ -658,6 +706,76 @@ namespace {
}
};
+ // C# printer
+ class TPrinterCSharp final : public TPrinter {
+ private:
+ std::string commentBOL() const override { return "// "; }
+
+ void printPrologue(std::ostream& out) const override {
+ out << "namespace Spv\n{\n\n";
+ out << indent() << "public static class Specification\n";
+ out << indent() << "{\n";
+ }
+
+ void printEpilogue(std::ostream& out) const override {
+ out << indent() << "}\n";
+ out << "}\n";
+ }
+
+ std::string enumBeg(const std::string& s, enumStyle_t style) const override {
+ return indent(2) + "public enum " + s + styleStr(style) + "\n" + indent(2) + "{\n";
+ }
+
+ std::string enumEnd(const std::string& s, enumStyle_t style, bool isLast) const override {
+ return indent(2) + "}" + + (isLast ? "\n" : "\n\n");
+ }
+
+ std::string enumFmt(const std::string& s, const valpair_t& v,
+ enumStyle_t style, bool isLast) const override {
+ return indent(3) + prependIfDigit(s, v.second) + " = " + fmtStyleVal(v.first, style) + ",\n";
+ }
+
+ std::string fmtConstInt(unsigned val, const std::string& name,
+ const char* fmt, bool isLast) const override {
+ return indent(2) + std::string("public const uint ") + name +
+ " = " + fmtNum(fmt, val) + (isLast ? ";\n\n" : ";\n");
+ }
+ };
+
+ // D printer
+ class TPrinterD final : public TPrinter {
+ private:
+ std::string commentBeg() const override { return "/+\n"; }
+ std::string commentBOL() const override { return " + "; }
+ std::string commentEnd(bool isLast) const override { return " +/\n"; }
+
+ void printPrologue(std::ostream& out) const override {
+ out << "module spv;\n\n";
+ }
+
+ void printEpilogue(std::ostream& out) const override {
+ }
+
+ std::string enumBeg(const std::string& s, enumStyle_t style) const override {
+ return "enum " + s + styleStr(style) + " : uint\n{\n";
+ }
+
+ std::string enumEnd(const std::string& s, enumStyle_t style, bool isLast) const override {
+ return std::string("}\n\n");
+ }
+
+ std::string enumFmt(const std::string& s, const valpair_t& v,
+ enumStyle_t style, bool isLast) const override {
+ return indent() + prependIfDigit("_", v.second) + " = " + fmtStyleVal(v.first, style) + ",\n";
+ }
+
+ std::string fmtConstInt(unsigned val, const std::string& name,
+ const char* fmt, bool isLast) const override {
+ return std::string("enum uint ") + name +
+ " = " + fmtNum(fmt, val) + (isLast ? ";\n\n" : ";\n");
+ }
+ };
+
} // namespace
namespace spv {
@@ -672,6 +790,8 @@ namespace spv {
langInfo.push_back(std::make_pair(ELangJSON, "spirv.json"));
langInfo.push_back(std::make_pair(ELangLua, "spirv.lua"));
langInfo.push_back(std::make_pair(ELangPython, "spirv.py"));
+ langInfo.push_back(std::make_pair(ELangCSharp, "spirv.cs"));
+ langInfo.push_back(std::make_pair(ELangD, "spv.d"));
for (const auto& lang : langInfo) {
std::ofstream out(lang.second, std::ios::out);
@@ -697,6 +817,8 @@ namespace spv {
case ELangJSON: p = TPrinterPtr(new TPrinterJSON); break;
case ELangLua: p = TPrinterPtr(new TPrinterLua); break;
case ELangPython: p = TPrinterPtr(new TPrinterPython); break;
+ case ELangCSharp: p = TPrinterPtr(new TPrinterCSharp); break;
+ case ELangD: p = TPrinterPtr(new TPrinterD); break;
case ELangAll: PrintAllHeaders(); break;
default:
std::cerr << "Unknown language." << std::endl;
diff --git a/tools/buildHeaders/header.h b/tools/buildHeaders/header.h
index 5a0952d..9c34b21 100755..100644
--- a/tools/buildHeaders/header.h
+++ b/tools/buildHeaders/header.h
@@ -1,19 +1,19 @@
-// Copyright (c) 2014-2018 The Khronos Group Inc.
-//
+// Copyright (c) 2014-2019 The Khronos Group Inc.
+//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and/or associated documentation files (the "Materials"),
// to deal in the Materials without restriction, including without limitation
// the rights to use, copy, modify, merge, publish, distribute, sublicense,
// and/or sell copies of the Materials, and to permit persons to whom the
// Materials are furnished to do so, subject to the following conditions:
-//
+//
// The above copyright notice and this permission notice shall be included in
// all copies or substantial portions of the Materials.
-//
+//
// MODIFICATIONS TO THIS FILE MAY MEAN IT NO LONGER ACCURATELY REFLECTS KHRONOS
// STANDARDS. THE UNMODIFIED, NORMATIVE VERSIONS OF KHRONOS SPECIFICATIONS AND
-// HEADER INFORMATION ARE LOCATED AT https://www.khronos.org/registry/
-//
+// HEADER INFORMATION ARE LOCATED AT https://www.khronos.org/registry/
+//
// THE MATERIALS ARE PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
@@ -41,6 +41,8 @@ namespace spv {
ELangJSON, // JSON
ELangLua, // Lua
ELangPython, // Python
+ ELangCSharp, // CSharp
+ ELangD, // D
ELangAll, // print headers in all languages to files
};
diff --git a/tools/buildHeaders/jsonToSpirv.cpp b/tools/buildHeaders/jsonToSpirv.cpp
index bb32566..e6cab48 100755..100644
--- a/tools/buildHeaders/jsonToSpirv.cpp
+++ b/tools/buildHeaders/jsonToSpirv.cpp
@@ -1,4 +1,4 @@
-// Copyright (c) 2014-2018 The Khronos Group Inc.
+// Copyright (c) 2014-2019 The Khronos Group Inc.
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and/or associated documentation files (the "Materials"),
@@ -119,8 +119,7 @@ ClassOptionality ToOperandClassAndOptionality(const std::string& operandKind, co
else if (quantifier == "?")
return {OperandLiteralString, true};
else {
- assert(0 && "this case should not exist");
- return {OperandNone, false};
+ return {OperandOptionalLiteralStrings, false};
}
} else if (operandKind == "PairLiteralIntegerIdRef") {
// Used by OpSwitch in the grammar
@@ -198,7 +197,7 @@ ClassOptionality ToOperandClassAndOptionality(const std::string& operandKind, co
} else if (operandKind == "FunctionControl") {
type = OperandFunction;
} else if (operandKind == "MemoryAccess") {
- type = OperandMemoryAccess;
+ type = OperandMemoryOperands;
}
if (type == OperandNone) {
@@ -230,7 +229,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,9 +301,12 @@ 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();
+ std::string lastVersion = inst["lastVersion"].asString();
Extensions exts = getExts(inst);
OperandParameters operands;
bool defResultId = false;
@@ -306,7 +322,7 @@ void jsonToSpirv(const std::string& jsonPath)
}
InstructionDesc.emplace_back(
std::move(EnumValue(opcode, name,
- std::move(caps), std::move(version), std::move(exts),
+ std::move(caps), std::move(version), std::move(lastVersion), std::move(exts),
std::move(operands))),
defTypeId, defResultId);
}
@@ -339,6 +355,7 @@ void jsonToSpirv(const std::string& jsonPath)
continue;
EnumCaps caps(getCaps(enumerant));
std::string version = enumerant["version"].asString();
+ std::string lastVersion = enumerant["lastVersion"].asString();
Extensions exts(getExts(enumerant));
OperandParameters params;
const Json::Value& paramsJson = enumerant["parameters"];
@@ -353,7 +370,7 @@ void jsonToSpirv(const std::string& jsonPath)
}
dest->emplace_back(
value, enumerant["enumerant"].asString(),
- std::move(caps), std::move(version), std::move(exts), std::move(params));
+ std::move(caps), std::move(version), std::move(lastVersion), std::move(exts), std::move(params));
}
};
@@ -421,7 +438,7 @@ void jsonToSpirv(const std::string& jsonPath)
} else if (enumName == "Dim") {
establishOperandClass(enumName, OperandDimensionality, &DimensionalityParams, operandEnum, category);
} else if (enumName == "MemoryAccess") {
- establishOperandClass(enumName, OperandMemoryAccess, &MemoryAccessParams, operandEnum, category);
+ establishOperandClass(enumName, OperandMemoryOperands, &MemoryAccessParams, operandEnum, category);
} else if (enumName == "Scope") {
establishOperandClass(enumName, OperandScope, &ScopeParams, operandEnum, category);
} else if (enumName == "GroupOperation") {
diff --git a/tools/buildHeaders/jsonToSpirv.h b/tools/buildHeaders/jsonToSpirv.h
index 00a2f70..beec01c 100755..100644
--- a/tools/buildHeaders/jsonToSpirv.h
+++ b/tools/buildHeaders/jsonToSpirv.h
@@ -1,4 +1,4 @@
-// Copyright (c) 2014-2018 The Khronos Group Inc.
+// Copyright (c) 2014-2019 The Khronos Group Inc.
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and/or associated documentation files (the "Materials"),
@@ -38,7 +38,7 @@ namespace spv {
std::pair<bool, std::string> 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 {
@@ -47,6 +47,7 @@ enum OperandClass {
OperandVariableIds,
OperandOptionalLiteral,
OperandOptionalLiteralString,
+ OperandOptionalLiteralStrings,
OperandVariableLiterals,
OperandVariableIdLiteral,
OperandVariableLiteralId,
@@ -76,7 +77,7 @@ enum OperandClass {
OperandLoop,
OperandFunction,
OperandMemorySemantics,
- OperandMemoryAccess,
+ OperandMemoryOperands,
OperandScope,
OperandGroupOperation,
OperandKernelEnqueueFlags,
@@ -145,6 +146,12 @@ public:
assert((where != end()) && "Could not find enum in the enum list");
return *where;
}
+ // gets *all* entries for the value, including the first one
+ void gatherAliases(unsigned value, std::vector<EValue*>& aliases) {
+ std::for_each(begin(), end(), [&](EValue& e) {
+ if (value == e.value)
+ aliases.push_back(&e);});
+ }
// Returns the EValue with the given name. We assume uniqueness
// by name.
EValue& at(std::string name) {
@@ -167,9 +174,11 @@ private:
class EnumValue {
public:
EnumValue() : value(0), desc(nullptr) {}
- EnumValue(unsigned int the_value, const std::string& the_name, EnumCaps&& the_caps, const std::string& the_version,
- Extensions&& the_extensions, OperandParameters&& the_operands) :
- value(the_value), name(the_name), capabilities(std::move(the_caps)), version(std::move(the_version)),
+ EnumValue(unsigned int the_value, const std::string& the_name, EnumCaps&& the_caps,
+ const std::string& the_firstVersion, const std::string& the_lastVersion,
+ Extensions&& the_extensions, OperandParameters&& the_operands) :
+ value(the_value), name(the_name), capabilities(std::move(the_caps)),
+ firstVersion(std::move(the_firstVersion)), lastVersion(std::move(the_lastVersion)),
extensions(std::move(the_extensions)), operands(std::move(the_operands)), desc(nullptr) { }
// For ValueEnum, the value from the JSON file.
@@ -178,7 +187,8 @@ public:
unsigned value;
std::string name;
EnumCaps capabilities;
- std::string version;
+ std::string firstVersion;
+ std::string lastVersion;
// A feature only be enabled by certain extensions.
// An empty list means the feature does not require an extension.
// Normally, only Capability enums are enabled by extension. In turn,
@@ -233,10 +243,19 @@ public:
opDesc("TBD"),
opClass(0),
typePresent(has_type),
- resultPresent(has_result) {}
+ resultPresent(has_result),
+ alias(this) { }
+ InstructionValue(const InstructionValue& v)
+ {
+ *this = v;
+ alias = this;
+ }
bool hasResult() const { return resultPresent != 0; }
bool hasType() const { return typePresent != 0; }
+ void setAlias(const InstructionValue& a) { alias = &a; }
+ const InstructionValue& getAlias() const { return *alias; }
+ bool isAlias() const { return alias != this; }
const char* opDesc;
int opClass;
@@ -244,6 +263,7 @@ public:
protected:
int typePresent : 1;
int resultPresent : 1;
+ const InstructionValue* alias; // correct only after discovering the aliases; otherwise points to this
};
using InstructionValues = EnumValuesContainer<InstructionValue>;
diff --git a/tools/buildHeaders/main.cpp b/tools/buildHeaders/main.cpp
index e146b39..7e5f7f8 100755..100644
--- a/tools/buildHeaders/main.cpp
+++ b/tools/buildHeaders/main.cpp
@@ -1,19 +1,19 @@
-// Copyright (c) 2014-2018 The Khronos Group Inc.
-//
+// Copyright (c) 2014-2019 The Khronos Group Inc.
+//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and/or associated documentation files (the "Materials"),
// to deal in the Materials without restriction, including without limitation
// the rights to use, copy, modify, merge, publish, distribute, sublicense,
// and/or sell copies of the Materials, and to permit persons to whom the
// Materials are furnished to do so, subject to the following conditions:
-//
+//
// The above copyright notice and this permission notice shall be included in
// all copies or substantial portions of the Materials.
-//
+//
// MODIFICATIONS TO THIS FILE MAY MEAN IT NO LONGER ACCURATELY REFLECTS KHRONOS
// STANDARDS. THE UNMODIFIED, NORMATIVE VERSIONS OF KHRONOS SPECIFICATIONS AND
-// HEADER INFORMATION ARE LOCATED AT https://www.khronos.org/registry/
-//
+// HEADER INFORMATION ARE LOCATED AT https://www.khronos.org/registry/
+//
// THE MATERIALS ARE PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
@@ -50,6 +50,8 @@ void Usage()
" JSON - JSON format data\n"
" Lua - Lua module\n"
" Python - Python module (also accepts Py)\n"
+ " C# - C# module (also accepts CSharp)\n"
+ " D - D module\n"
" -H print header in all supported languages to files in current directory\n"
);
}
@@ -90,6 +92,10 @@ bool ProcessArguments(int argc, char* argv[])
Language = spv::ELangLua;
} else if (language == "python" || language == "py") {
Language = spv::ELangPython;
+ } else if (language == "c#" || language == "csharp") {
+ Language = spv::ELangCSharp;
+ } else if (language == "d") {
+ Language = spv::ELangD;
} else
return false;
@@ -113,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);