Bottom byte of version header word should be 0

The assembler should always make it 0.
The disassembler should ignore it.

Remove the macro support for supplying a value for it.

Fixes https://github.com/KhronosGroup/SPIRV-Tools/issues/6
This commit is contained in:
David Neto 2015-11-17 16:37:10 -05:00
parent 01a3b9ce36
commit 8ddd4ec102
5 changed files with 7 additions and 13 deletions

View File

@ -136,8 +136,7 @@ spv_result_t Disassembler::HandleHeader(spv_endianness_t endian,
spvGeneratorStr(SPV_GENERATOR_TOOL_PART(generator));
stream_ << "; SPIR-V\n"
<< "; Version: " << SPV_SPIRV_VERSION_MAJOR_PART(version) << "."
<< SPV_SPIRV_VERSION_MINOR_PART(version) << "."
<< SPV_SPIRV_VERSION_REVISION_PART(version) << "\n"
<< SPV_SPIRV_VERSION_MINOR_PART(version) << "\n"
<< "; Generator: " << generator_tool;
// For unknown tools, print the numeric tool value.
if (0 == strcmp("Unknown", generator_tool)) {

View File

@ -32,16 +32,13 @@
// Version number macros.
// Evaluates to a well-formed version header word, given valid
// SPIR-V version major, minor, and revision numbers.
#define SPV_SPIRV_VERSION_WORD(MAJOR, MINOR, REVISION) \
((uint32_t(uint8_t(MAJOR)) << 16) | (uint32_t(uint8_t(MINOR)) << 8) | \
uint8_t(REVISION))
// SPIR-V version major and minor version numbers.
#define SPV_SPIRV_VERSION_WORD(MAJOR, MINOR) \
((uint32_t(uint8_t(MAJOR)) << 16) | (uint32_t(uint8_t(MINOR)) << 8))
// Returns the major version extracted from a version header word.
#define SPV_SPIRV_VERSION_MAJOR_PART(WORD) ((uint32_t(WORD) >> 16) & 0xff)
// Returns the minor version extracted from a version header word.
#define SPV_SPIRV_VERSION_MINOR_PART(WORD) ((uint32_t(WORD) >> 8) & 0xff)
// Returns the revision number extracted from a version header word.
#define SPV_SPIRV_VERSION_REVISION_PART(WORD) (uint32_t(WORD) & 0xff)
// Header indices

View File

@ -668,8 +668,7 @@ SetHeader(uint32_t* words, const uint32_t bound) {
words[SPV_INDEX_MAGIC_NUMBER] = SpvMagicNumber;
words[SPV_INDEX_VERSION_NUMBER] =
SPV_SPIRV_VERSION_WORD(SPV_SPIRV_VERSION_MAJOR, SPV_SPIRV_VERSION_MINOR,
SPV_SPIRV_VERSION_REVISION);
SPV_SPIRV_VERSION_WORD(SPV_SPIRV_VERSION_MAJOR, SPV_SPIRV_VERSION_MINOR);
words[SPV_INDEX_GENERATOR_NUMBER] =
SPV_GENERATOR_WORD(SPV_GENERATOR_KHRONOS_ASSEMBLER, kAssemblerVersion);
words[SPV_INDEX_BOUND] = bound;

View File

@ -408,8 +408,7 @@ TEST_F(TextToBinaryTest, VersionString) {
EXPECT_EQ(1, SPV_SPIRV_VERSION_MAJOR);
EXPECT_EQ(0, SPV_SPIRV_VERSION_MINOR);
EXPECT_EQ(2, SPV_SPIRV_VERSION_REVISION);
EXPECT_THAT(decoded_text->str, HasSubstr("Version: 1.0.2\n"))
EXPECT_THAT(decoded_text->str, HasSubstr("Version: 1.0\n"))
<< EncodeAndDecodeSuccessfully("");
spvTextDestroy(decoded_text);
}

View File

@ -66,7 +66,7 @@ OpFunctionEnd
)";
const std::string spirv_header =
R"(; SPIR-V
; Version: 1.0.2
; Version: 1.0
; Generator: Khronos SPIR-V Tools Assembler; 0
; Bound: 9
; Schema: 0)";