Bottom byte of version header word should be 0
authorDavid Neto <dneto@google.com>
Tue, 17 Nov 2015 21:37:10 +0000 (16:37 -0500)
committerDavid Neto <dneto@google.com>
Wed, 18 Nov 2015 20:19:43 +0000 (15:19 -0500)
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

source/disassemble.cpp
source/spirv_constant.h
source/text.cpp
test/BinaryToText.cpp
test/ExtInstGLSLstd450.cpp

index 4572afa..c4b4c69 100644 (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)) {
index cbf33cc..347131c 100644 (file)
 // 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
 
index d33d773..3ebde21 100644 (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;
index 55156cc..3156d07 100644 (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);
 }
index 41b34e2..4e21f3a 100644 (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)";