mirror of
https://gitee.com/openharmony/third_party_spirv-headers
synced 2024-11-26 17:20:34 +00:00
Merge pull request #283 from jayrulez/beeflang
Implemented Beef language header generation
This commit is contained in:
commit
5a12186692
1878
include/spirv/unified1/spirv.bf
Normal file
1878
include/spirv/unified1/spirv.bf
Normal file
File diff suppressed because it is too large
Load Diff
@ -26,7 +26,7 @@
|
||||
// the Binary Section of the SPIR-V specification.
|
||||
|
||||
// Enumeration tokens for SPIR-V, in various styles:
|
||||
// C, C++, C++11, JSON, Lua, Python, C#, D
|
||||
// C, C++, C++11, JSON, Lua, Python, C#, D, Beef
|
||||
//
|
||||
// - C will have tokens with a "Spv" prefix, e.g.: SpvSourceLanguageGLSL
|
||||
// - C++ will have tokens in the "spv" name space, e.g.: spv::SourceLanguageGLSL
|
||||
@ -36,6 +36,8 @@
|
||||
// - C# will use enum classes in the Specification class located in the "Spv" namespace,
|
||||
// e.g.: Spv.Specification.SourceLanguage.GLSL
|
||||
// - D will have tokens under the "spv" module, e.g: spv.SourceLanguage.GLSL
|
||||
// - Beef will use enum classes in the Specification class located in the "Spv" namespace,
|
||||
// e.g.: Spv.Specification.SourceLanguage.GLSL
|
||||
//
|
||||
// Some tokens act like mask values, which can be OR'd together,
|
||||
// while others are mutually exclusive. The mask-like ones have
|
||||
|
@ -31,7 +31,7 @@
|
||||
|
||||
/*
|
||||
** Enumeration tokens for SPIR-V, in various styles:
|
||||
** C, C++, C++11, JSON, Lua, Python, C#, D
|
||||
** C, C++, C++11, JSON, Lua, Python, C#, D, Beef
|
||||
**
|
||||
** - C will have tokens with a "Spv" prefix, e.g.: SpvSourceLanguageGLSL
|
||||
** - C++ will have tokens in the "spv" name space, e.g.: spv::SourceLanguageGLSL
|
||||
@ -41,6 +41,8 @@
|
||||
** - C# will use enum classes in the Specification class located in the "Spv" namespace,
|
||||
** e.g.: Spv.Specification.SourceLanguage.GLSL
|
||||
** - D will have tokens under the "spv" module, e.g: spv.SourceLanguage.GLSL
|
||||
** - Beef will use enum classes in the Specification class located in the "Spv" namespace,
|
||||
** e.g.: Spv.Specification.SourceLanguage.GLSL
|
||||
**
|
||||
** Some tokens act like mask values, which can be OR'd together,
|
||||
** while others are mutually exclusive. The mask-like ones have
|
||||
|
@ -26,7 +26,7 @@
|
||||
// the Binary Section of the SPIR-V specification.
|
||||
|
||||
// Enumeration tokens for SPIR-V, in various styles:
|
||||
// C, C++, C++11, JSON, Lua, Python, C#, D
|
||||
// C, C++, C++11, JSON, Lua, Python, C#, D, Beef
|
||||
//
|
||||
// - C will have tokens with a "Spv" prefix, e.g.: SpvSourceLanguageGLSL
|
||||
// - C++ will have tokens in the "spv" name space, e.g.: spv::SourceLanguageGLSL
|
||||
@ -36,6 +36,8 @@
|
||||
// - C# will use enum classes in the Specification class located in the "Spv" namespace,
|
||||
// e.g.: Spv.Specification.SourceLanguage.GLSL
|
||||
// - D will have tokens under the "spv" module, e.g: spv.SourceLanguage.GLSL
|
||||
// - Beef will use enum classes in the Specification class located in the "Spv" namespace,
|
||||
// e.g.: Spv.Specification.SourceLanguage.GLSL
|
||||
//
|
||||
// Some tokens act like mask values, which can be OR'd together,
|
||||
// while others are mutually exclusive. The mask-like ones have
|
||||
|
@ -26,7 +26,7 @@
|
||||
// the Binary Section of the SPIR-V specification.
|
||||
|
||||
// Enumeration tokens for SPIR-V, in various styles:
|
||||
// C, C++, C++11, JSON, Lua, Python, C#, D
|
||||
// C, C++, C++11, JSON, Lua, Python, C#, D, Beef
|
||||
//
|
||||
// - C will have tokens with a "Spv" prefix, e.g.: SpvSourceLanguageGLSL
|
||||
// - C++ will have tokens in the "spv" name space, e.g.: spv::SourceLanguageGLSL
|
||||
@ -36,6 +36,8 @@
|
||||
// - C# will use enum classes in the Specification class located in the "Spv" namespace,
|
||||
// e.g.: Spv.Specification.SourceLanguage.GLSL
|
||||
// - D will have tokens under the "spv" module, e.g: spv.SourceLanguage.GLSL
|
||||
// - Beef will use enum classes in the Specification class located in the "Spv" namespace,
|
||||
// e.g.: Spv.Specification.SourceLanguage.GLSL
|
||||
//
|
||||
// Some tokens act like mask values, which can be OR'd together,
|
||||
// while others are mutually exclusive. The mask-like ones have
|
||||
|
@ -36,7 +36,7 @@
|
||||
],
|
||||
[
|
||||
"Enumeration tokens for SPIR-V, in various styles:",
|
||||
" C, C++, C++11, JSON, Lua, Python, C#, D",
|
||||
" C, C++, C++11, JSON, Lua, Python, C#, D, Beef",
|
||||
"",
|
||||
"- C will have tokens with a \"Spv\" prefix, e.g.: SpvSourceLanguageGLSL",
|
||||
"- C++ will have tokens in the \"spv\" name space, e.g.: spv::SourceLanguageGLSL",
|
||||
@ -46,6 +46,8 @@
|
||||
"- C# will use enum classes in the Specification class located in the \"Spv\" namespace,",
|
||||
" e.g.: Spv.Specification.SourceLanguage.GLSL",
|
||||
"- D will have tokens under the \"spv\" module, e.g: spv.SourceLanguage.GLSL",
|
||||
"- Beef will use enum classes in the Specification class located in the \"Spv\" namespace,",
|
||||
" e.g.: Spv.Specification.SourceLanguage.GLSL",
|
||||
"",
|
||||
"Some tokens act like mask values, which can be OR'd together,",
|
||||
"while others are mutually exclusive. The mask-like ones have",
|
||||
|
@ -26,7 +26,7 @@
|
||||
-- the Binary Section of the SPIR-V specification.
|
||||
|
||||
-- Enumeration tokens for SPIR-V, in various styles:
|
||||
-- C, C++, C++11, JSON, Lua, Python, C#, D
|
||||
-- C, C++, C++11, JSON, Lua, Python, C#, D, Beef
|
||||
--
|
||||
-- - C will have tokens with a "Spv" prefix, e.g.: SpvSourceLanguageGLSL
|
||||
-- - C++ will have tokens in the "spv" name space, e.g.: spv::SourceLanguageGLSL
|
||||
@ -36,6 +36,8 @@
|
||||
-- - C# will use enum classes in the Specification class located in the "Spv" namespace,
|
||||
-- e.g.: Spv.Specification.SourceLanguage.GLSL
|
||||
-- - D will have tokens under the "spv" module, e.g: spv.SourceLanguage.GLSL
|
||||
-- - Beef will use enum classes in the Specification class located in the "Spv" namespace,
|
||||
-- e.g.: Spv.Specification.SourceLanguage.GLSL
|
||||
--
|
||||
-- Some tokens act like mask values, which can be OR'd together,
|
||||
-- while others are mutually exclusive. The mask-like ones have
|
||||
|
@ -26,7 +26,7 @@
|
||||
# the Binary Section of the SPIR-V specification.
|
||||
|
||||
# Enumeration tokens for SPIR-V, in various styles:
|
||||
# C, C++, C++11, JSON, Lua, Python, C#, D
|
||||
# C, C++, C++11, JSON, Lua, Python, C#, D, Beef
|
||||
#
|
||||
# - C will have tokens with a "Spv" prefix, e.g.: SpvSourceLanguageGLSL
|
||||
# - C++ will have tokens in the "spv" name space, e.g.: spv::SourceLanguageGLSL
|
||||
@ -36,6 +36,8 @@
|
||||
# - C# will use enum classes in the Specification class located in the "Spv" namespace,
|
||||
# e.g.: Spv.Specification.SourceLanguage.GLSL
|
||||
# - D will have tokens under the "spv" module, e.g: spv.SourceLanguage.GLSL
|
||||
# - Beef will use enum classes in the Specification class located in the "Spv" namespace,
|
||||
# e.g.: Spv.Specification.SourceLanguage.GLSL
|
||||
#
|
||||
# Some tokens act like mask values, which can be OR'd together,
|
||||
# while others are mutually exclusive. The mask-like ones have
|
||||
|
@ -31,7 +31,7 @@
|
||||
|
||||
/+
|
||||
+ Enumeration tokens for SPIR-V, in various styles:
|
||||
+ C, C++, C++11, JSON, Lua, Python, C#, D
|
||||
+ C, C++, C++11, JSON, Lua, Python, C#, D, Beef
|
||||
+
|
||||
+ - C will have tokens with a "Spv" prefix, e.g.: SpvSourceLanguageGLSL
|
||||
+ - C++ will have tokens in the "spv" name space, e.g.: spv::SourceLanguageGLSL
|
||||
@ -41,6 +41,8 @@
|
||||
+ - C# will use enum classes in the Specification class located in the "Spv" namespace,
|
||||
+ e.g.: Spv.Specification.SourceLanguage.GLSL
|
||||
+ - D will have tokens under the "spv" module, e.g: spv.SourceLanguage.GLSL
|
||||
+ - Beef will use enum classes in the Specification class located in the "Spv" namespace,
|
||||
+ e.g.: Spv.Specification.SourceLanguage.GLSL
|
||||
+
|
||||
+ Some tokens act like mask values, which can be OR'd together,
|
||||
+ while others are mutually exclusive. The mask-like ones have
|
||||
|
@ -199,7 +199,7 @@ namespace {
|
||||
|
||||
const std::string TPrinter::DocComment2 =
|
||||
"Enumeration tokens for SPIR-V, in various styles:\n"
|
||||
" C, C++, C++11, JSON, Lua, Python, C#, D\n"
|
||||
" C, C++, C++11, JSON, Lua, Python, C#, D, Beef\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"
|
||||
@ -209,6 +209,8 @@ namespace {
|
||||
"- 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"
|
||||
"- Beef will use enum classes in the Specification class located in the \"Spv\" namespace,\n"
|
||||
" e.g.: Spv.Specification.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"
|
||||
@ -779,6 +781,43 @@ namespace {
|
||||
}
|
||||
};
|
||||
|
||||
// Beef printer
|
||||
class TPrinterBeef final : public TPrinter {
|
||||
private:
|
||||
std::string commentBOL() const override { return "// "; }
|
||||
|
||||
void printPrologue(std::ostream& out) const override {
|
||||
out << "namespace Spv\n{\n";
|
||||
out << indent() << "using System;\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) + "[AllowDuplicates, CRepr] 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 uint32 ") + name +
|
||||
" = " + fmtNum(fmt, val) + (isLast ? ";\n\n" : ";\n");
|
||||
}
|
||||
};
|
||||
|
||||
} // namespace
|
||||
|
||||
namespace spv {
|
||||
@ -795,6 +834,7 @@ namespace spv {
|
||||
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"));
|
||||
langInfo.push_back(std::make_pair(ELangBeef, "spirv.bf"));
|
||||
|
||||
for (const auto& lang : langInfo) {
|
||||
std::ofstream out(lang.second, std::ios::out);
|
||||
@ -822,6 +862,7 @@ namespace spv {
|
||||
case ELangPython: p = TPrinterPtr(new TPrinterPython); break;
|
||||
case ELangCSharp: p = TPrinterPtr(new TPrinterCSharp); break;
|
||||
case ELangD: p = TPrinterPtr(new TPrinterD); break;
|
||||
case ELangBeef: p = TPrinterPtr(new TPrinterBeef); break;
|
||||
case ELangAll: PrintAllHeaders(); break;
|
||||
default:
|
||||
std::cerr << "Unknown language." << std::endl;
|
||||
|
@ -43,6 +43,7 @@ namespace spv {
|
||||
ELangPython, // Python
|
||||
ELangCSharp, // CSharp
|
||||
ELangD, // D
|
||||
ELangBeef, // Beef
|
||||
|
||||
ELangAll, // print headers in all languages to files
|
||||
};
|
||||
|
@ -52,6 +52,7 @@ void Usage()
|
||||
" Python - Python module (also accepts Py)\n"
|
||||
" C# - C# module (also accepts CSharp)\n"
|
||||
" D - D module\n"
|
||||
" Beef - Beef module\n"
|
||||
" -H print header in all supported languages to files in current directory\n"
|
||||
);
|
||||
}
|
||||
@ -96,6 +97,8 @@ bool ProcessArguments(int argc, char* argv[])
|
||||
Language = spv::ELangCSharp;
|
||||
} else if (language == "d") {
|
||||
Language = spv::ELangD;
|
||||
} else if (language == "beef") {
|
||||
Language = spv::ELangBeef;
|
||||
} else
|
||||
return false;
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user