Mark SPIR-V grammar files as 1.0.
authorDejan Mircevski <deki@google.com>
Thu, 7 Apr 2016 18:09:48 +0000 (14:09 -0400)
committerDavid Neto <dneto@google.com>
Mon, 18 Apr 2016 14:00:01 +0000 (10:00 -0400)
Factor the CMake generate_grammar_tables invocation into a function
parameterized on the version.

CMakeLists.txt
source/CMakeLists.txt
source/ext_inst.cpp
source/extinst-1-0.glsl.std.450.grammar.json [moved from source/extinst.glsl.std.450.grammar.json with 100% similarity]
source/extinst-1-0.opencl.std.grammar.json [moved from source/extinst.opencl.std.grammar.json with 100% similarity]
source/opcode.cpp
source/operand.cpp
source/spirv-1-0.core.grammar.json [moved from source/spirv.core.grammar.json with 100% similarity]

index bd80545..791c195 100644 (file)
@@ -137,17 +137,21 @@ add_custom_target(spirv-tools-build-version
   ${spirv-tools_SOURCE_DIR}
   COMMENT "Update build-version.inc in the Spirv-tools build directory (if necessary).")
 
-add_custom_target(spirv-tools-build-tables
-  ${PYTHON_EXECUTABLE}
-  ${CMAKE_CURRENT_SOURCE_DIR}/utils/generate_grammar_tables.py
-  --spirv-core-grammar=${spirv-tools_SOURCE_DIR}/source/spirv.core.grammar.json
-  --extinst-glsl-grammar=${spirv-tools_SOURCE_DIR}/source/extinst.glsl.std.450.grammar.json
-  --extinst-opencl-grammar=${spirv-tools_SOURCE_DIR}/source/extinst.opencl.std.grammar.json
-  --core-insts-output=${spirv-tools_BINARY_DIR}/core.insts.inc
-  --glsl-insts-output=${spirv-tools_BINARY_DIR}/glsl.std.450.insts.inc
-  --opencl-insts-output=${spirv-tools_BINARY_DIR}/opencl.std.insts.inc
-  --operand-kinds-output=${spirv-tools_BINARY_DIR}/operand.kinds.inc
-  COMMENT "Generate info tables for SPIR-V instructions and operands.")
+function(spvtools_tables VERSION)
+  add_custom_target(spirv-tools-build-tables-${VERSION}
+    ${PYTHON_EXECUTABLE}
+    ${CMAKE_CURRENT_SOURCE_DIR}/utils/generate_grammar_tables.py
+    --spirv-core-grammar=${spirv-tools_SOURCE_DIR}/source/spirv-${VERSION}.core.grammar.json
+    --extinst-glsl-grammar=${spirv-tools_SOURCE_DIR}/source/extinst-${VERSION}.glsl.std.450.grammar.json
+    --extinst-opencl-grammar=${spirv-tools_SOURCE_DIR}/source/extinst-${VERSION}.opencl.std.grammar.json
+    --core-insts-output=${spirv-tools_BINARY_DIR}/core.insts-${VERSION}.inc
+    --glsl-insts-output=${spirv-tools_BINARY_DIR}/glsl.std.450.insts-${VERSION}.inc
+    --opencl-insts-output=${spirv-tools_BINARY_DIR}/opencl.std.insts-${VERSION}.inc
+    --operand-kinds-output=${spirv-tools_BINARY_DIR}/operand.kinds-${VERSION}.inc
+    COMMENT "Generate info tables for SPIR-V-${VERSION} instructions and operands.")
+endfunction(spvtools_tables)
+
+spvtools_tables("1-0")
 
 # Defaults to OFF if the user didn't set it.
 option(SPIRV_SKIP_EXECUTABLES
index e3b14a7..d86e0fd 100644 (file)
@@ -76,7 +76,7 @@ target_include_directories(${SPIRV_TOOLS}
   PUBLIC ${spirv-tools_SOURCE_DIR}/include
   PRIVATE ${spirv-tools_BINARY_DIR}
   )
-add_dependencies(${SPIRV_TOOLS} spirv-tools-build-tables)
+add_dependencies(${SPIRV_TOOLS} spirv-tools-build-tables-1-0)
 
 install(TARGETS ${SPIRV_TOOLS}
   RUNTIME DESTINATION bin
index f612fa9..32e76fe 100644 (file)
 #include "spirv_definition.h"
 
 static const spv_ext_inst_desc_t glslStd450Entries[] = {
-#include "glsl.std.450.insts.inc"
+#include "glsl.std.450.insts-1-0.inc"
 };
 
 static const spv_ext_inst_desc_t openclEntries[] = {
-#include "opencl.std.insts.inc"
+#include "opencl.std.insts-1-0.inc"
 };
 
 spv_result_t spvExtInstTableGet(spv_ext_inst_table* pExtInstTable) {
index 518da26..e252c8a 100644 (file)
@@ -48,7 +48,7 @@ namespace {
 // TODO(dneto): Some of the macros are quite unreadable.  We could make
 // good use of constexpr functions, but some compilers don't support that yet.
 const spv_opcode_desc_t opcodeTableEntries[] = {
-#include "core.insts.inc"
+#include "core.insts-1-0.inc"
 };
 
 }  // anonymous namespace
index 5de3f43..d2998af 100644 (file)
@@ -36,7 +36,7 @@
 #define ARRAY_SIZE(A) (static_cast<uint32_t>(sizeof(A) / sizeof(A[0])))
 
 // Pull in operand info tables automatically generated from JSON grammar.
-#include "operand.kinds.inc"
+#include "operand.kinds-1-0.inc"
 
 spv_result_t spvOperandTableGet(spv_operand_table* pOperandTable) {
   if (!pOperandTable) return SPV_ERROR_INVALID_POINTER;