Mark SPIR-V grammar files as 1.0.

Factor the CMake generate_grammar_tables invocation into a function
parameterized on the version.
This commit is contained in:
Dejan Mircevski 2016-04-07 14:09:48 -04:00 committed by David Neto
parent 77d4e30eda
commit e26fdc6bd1
8 changed files with 20 additions and 16 deletions

View 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

View 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

View File

@ -33,11 +33,11 @@
#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) {

View 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

View 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;