Refactor include of latest spir-v header versions
authorAndrey Tuganov <andreyt@google.com>
Wed, 13 Dec 2017 22:55:00 +0000 (17:55 -0500)
committerDavid Neto <dneto@google.com>
Thu, 14 Dec 2017 16:18:20 +0000 (11:18 -0500)
32 files changed:
Android.mk
source/CMakeLists.txt
source/assembly_grammar.h
source/comp/markv_codec.cpp
source/comp/markv_model.h
source/enum_set.h
source/ext_inst.cpp
source/instruction.h
source/latest_version_glsl_std_450_header.h [new file with mode: 0644]
source/latest_version_opencl_std_header.h [new file with mode: 0644]
source/latest_version_spirv_header.h [new file with mode: 0644]
source/opcode.h
source/opt/aggressive_dead_code_elim_pass.cpp
source/opt/instruction.h
source/opt/instruction_list.h
source/opt/ir_context.cpp
source/opt/local_single_store_elim_pass.cpp
source/opt/reflect.h
source/opt/types.h
source/spirv_constant.h
source/spirv_definition.h
source/table.h
source/val/basic_block.h
source/val/decoration.h
source/val/function.h
source/val/validation_state.h
test/binary_parse_test.cpp
test/ext_inst.glsl_test.cpp
test/ext_inst.opencl_test.cpp
test/stats/stats_analyzer_test.cpp
test/text_to_binary.extension_test.cpp
test/val/val_state_test.cpp

index f9baa6a..3129e53 100644 (file)
@@ -108,12 +108,12 @@ SPVTOOLS_OPT_SRC_FILES := \
 SPV_CORE10_GRAMMAR=$(SPVHEADERS_LOCAL_PATH)/include/spirv/1.0/spirv.core.grammar.json
 SPV_CORE11_GRAMMAR=$(SPVHEADERS_LOCAL_PATH)/include/spirv/1.1/spirv.core.grammar.json
 SPV_CORE12_GRAMMAR=$(SPVHEADERS_LOCAL_PATH)/include/spirv/1.2/spirv.core.grammar.json
-SPV_GLSL_GRAMMAR=$(SPVHEADERS_LOCAL_PATH)/include/spirv/1.0/extinst.glsl.std.450.grammar.json
-SPV_OPENCL_GRAMMAR=$(SPVHEADERS_LOCAL_PATH)/include/spirv/1.0/extinst.opencl.std.100.grammar.json
+SPV_GLSL_GRAMMAR=$(SPVHEADERS_LOCAL_PATH)/include/spirv/1.2/extinst.glsl.std.450.grammar.json
+SPV_OPENCL_GRAMMAR=$(SPVHEADERS_LOCAL_PATH)/include/spirv/1.2/extinst.opencl.std.100.grammar.json
 
 define gen_spvtools_grammar_tables
 $(call generate-file-dir,$(1)/core.insts-1.0.inc)
-$(1)/core.insts-1.0.inc $(1)/operand.kinds-1.0.inc $(1)/glsl.std.450.insts-1.0.inc $(1)/opencl.std.insts-1.0.inc: \
+$(1)/core.insts-1.0.inc $(1)/operand.kinds-1.0.inc $(1)/glsl.std.450.insts.inc $(1)/opencl.std.insts.inc: \
         $(LOCAL_PATH)/utils/generate_grammar_tables.py \
         $(SPV_CORE10_GRAMMAR) \
         $(SPV_GLSL_GRAMMAR) \
@@ -123,8 +123,8 @@ $(1)/core.insts-1.0.inc $(1)/operand.kinds-1.0.inc $(1)/glsl.std.450.insts-1.0.i
                                --extinst-glsl-grammar=$(SPV_GLSL_GRAMMAR) \
                                --extinst-opencl-grammar=$(SPV_OPENCL_GRAMMAR) \
                                --core-insts-output=$(1)/core.insts-1.0.inc \
-                               --glsl-insts-output=$(1)/glsl.std.450.insts-1.0.inc \
-                               --opencl-insts-output=$(1)/opencl.std.insts-1.0.inc \
+                               --glsl-insts-output=$(1)/glsl.std.450.insts.inc \
+                               --opencl-insts-output=$(1)/opencl.std.insts.inc \
                                --operand-kinds-output=$(1)/operand.kinds-1.0.inc
                @echo "[$(TARGET_ARCH_ABI)] Grammar v1.0   : instructions & operands <= grammar JSON files"
 $(1)/core.insts-1.1.inc $(1)/operand.kinds-1.1.inc: \
@@ -145,7 +145,7 @@ $(1)/core.insts-1.2.inc $(1)/operand.kinds-1.2.inc: \
                @echo "[$(TARGET_ARCH_ABI)] Grammar v1.2   : instructions & operands <= grammar JSON files"
 $(LOCAL_PATH)/source/opcode.cpp: $(1)/core.insts-1.0.inc $(1)/core.insts-1.1.inc $(1)/core.insts-1.2.inc
 $(LOCAL_PATH)/source/operand.cpp: $(1)/operand.kinds-1.0.inc $(1)/operand.kinds-1.1.inc $(1)/operand.kinds-1.2.inc
-$(LOCAL_PATH)/source/ext_inst.cpp: $(1)/glsl.std.450.insts-1.0.inc $(1)/opencl.std.insts-1.0.inc
+$(LOCAL_PATH)/source/ext_inst.cpp: $(1)/glsl.std.450.insts.inc $(1)/opencl.std.insts.inc
 endef
 $(eval $(call gen_spvtools_grammar_tables,$(SPVTOOLS_OUT_PATH)))
 
index 87819d5..9f4d3eb 100644 (file)
@@ -70,7 +70,7 @@ endmacro(spvtools_vimsyntax)
 macro(spvtools_glsl_tables VERSION)
   set(CORE_GRAMMAR_JSON_FILE "${SPIRV_HEADER_INCLUDE_DIR}/spirv/${VERSION}/spirv.core.grammar.json")
   set(GLSL_GRAMMAR_JSON_FILE "${SPIRV_HEADER_INCLUDE_DIR}/spirv/${VERSION}/extinst.glsl.std.450.grammar.json")
-  set(GRAMMAR_INC_FILE "${spirv-tools_BINARY_DIR}/glsl.std.450.insts-${VERSION}.inc")
+  set(GRAMMAR_INC_FILE "${spirv-tools_BINARY_DIR}/glsl.std.450.insts.inc")
   add_custom_command(OUTPUT ${GRAMMAR_INC_FILE}
     COMMAND ${PYTHON_EXECUTABLE} ${GRAMMAR_PROCESSING_SCRIPT}
       --spirv-core-grammar=${CORE_GRAMMAR_JSON_FILE}
@@ -84,7 +84,7 @@ endmacro(spvtools_glsl_tables)
 macro(spvtools_opencl_tables VERSION)
   set(CORE_GRAMMAR_JSON_FILE "${SPIRV_HEADER_INCLUDE_DIR}/spirv/${VERSION}/spirv.core.grammar.json")
   set(OPENCL_GRAMMAR_JSON_FILE "${SPIRV_HEADER_INCLUDE_DIR}/spirv/${VERSION}/extinst.opencl.std.100.grammar.json")
-  set(GRAMMAR_INC_FILE "${spirv-tools_BINARY_DIR}/opencl.std.insts-${VERSION}.inc")
+  set(GRAMMAR_INC_FILE "${spirv-tools_BINARY_DIR}/opencl.std.insts.inc")
   add_custom_command(OUTPUT ${GRAMMAR_INC_FILE}
     COMMAND ${PYTHON_EXECUTABLE} ${GRAMMAR_PROCESSING_SCRIPT}
       --spirv-core-grammar=${CORE_GRAMMAR_JSON_FILE}
@@ -113,8 +113,8 @@ spvtools_core_tables("1.0")
 spvtools_core_tables("1.1")
 spvtools_core_tables("1.2")
 spvtools_enum_string_mapping("1.2")
-spvtools_opencl_tables("1.0")
-spvtools_glsl_tables("1.0")
+spvtools_opencl_tables("1.2")
+spvtools_glsl_tables("1.2")
 spvtools_vendor_tables("spv-amd-shader-explicit-vertex-parameter")
 spvtools_vendor_tables("spv-amd-shader-trinary-minmax")
 spvtools_vendor_tables("spv-amd-gcn-shader")
@@ -210,6 +210,9 @@ set(SPIRV_SOURCES
   ${CMAKE_CURRENT_SOURCE_DIR}/extensions.h
   ${CMAKE_CURRENT_SOURCE_DIR}/id_descriptor.h
   ${CMAKE_CURRENT_SOURCE_DIR}/instruction.h
+  ${CMAKE_CURRENT_SOURCE_DIR}/latest_version_glsl_std_450_header.h
+  ${CMAKE_CURRENT_SOURCE_DIR}/latest_version_opencl_std_header.h
+  ${CMAKE_CURRENT_SOURCE_DIR}/latest_version_spirv_header.h
   ${CMAKE_CURRENT_SOURCE_DIR}/macro.h
   ${CMAKE_CURRENT_SOURCE_DIR}/name_mapper.h
   ${CMAKE_CURRENT_SOURCE_DIR}/opcode.h
index bfbfe76..e37c457 100644 (file)
@@ -15,9 +15,9 @@
 #ifndef LIBSPIRV_ASSEMBLY_GRAMMAR_H_
 #define LIBSPIRV_ASSEMBLY_GRAMMAR_H_
 
+#include "latest_version_spirv_header.h"
 #include "operand.h"
 #include "spirv-tools/libspirv.h"
-#include "spirv/1.2/spirv.h"
 #include "table.h"
 
 namespace libspirv {
index dec4d73..ff1c582 100644 (file)
@@ -34,9 +34,9 @@
 #include <unordered_set>
 #include <vector>
 
-#include "spirv/1.2/GLSL.std.450.h"
-#include "spirv/1.2/OpenCL.std.h"
-#include "spirv/1.2/spirv.h"
+#include "latest_version_glsl_std_450_header.h"
+#include "latest_version_opencl_std_header.h"
+#include "latest_version_spirv_header.h"
 
 #include "binary.h"
 #include "diagnostic.h"
index 630942c..606396e 100644 (file)
@@ -19,8 +19,8 @@
 #include <unordered_set>
 #include <vector>
 
+#include "latest_version_spirv_header.h"
 #include "spirv-tools/libspirv.h"
-#include "spirv/1.2/spirv.h"
 #include "util/huffman_codec.h"
 
 namespace spvtools {
index b956b49..75a49f0 100644 (file)
@@ -21,7 +21,7 @@
 #include <set>
 #include <utility>
 
-#include "spirv/1.2/spirv.h"
+#include "latest_version_spirv_header.h"
 
 namespace libspirv {
 
index fc8a486..fa2c9b6 100644 (file)
 #include <cassert>
 #include <cstring>
 
-#include "spirv/1.0/GLSL.std.450.h"
-#include "spirv/1.0/OpenCL.std.h"
+#include "latest_version_glsl_std_450_header.h"
+#include "latest_version_opencl_std_header.h"
 #include "spirv_definition.h"
 
 #include "macro.h"
 
-#include "glsl.std.450.insts-1.0.inc"  // defines glsl_entries
-#include "opencl.std.insts-1.0.inc"    // defines opencl_entries
+#include "glsl.std.450.insts.inc"  // defines glsl_entries
+#include "opencl.std.insts.inc"    // defines opencl_entries
 
 #include "spv-amd-gcn-shader.insts.inc"
 #include "spv-amd-shader-ballot.insts.inc"
index 2afa6d4..884276d 100644 (file)
@@ -18,8 +18,8 @@
 #include <cstdint>
 #include <vector>
 
+#include "latest_version_spirv_header.h"
 #include "spirv-tools/libspirv.h"
-#include "spirv/1.2/spirv.h"
 
 // Describes an instruction.
 struct spv_instruction_t {
diff --git a/source/latest_version_glsl_std_450_header.h b/source/latest_version_glsl_std_450_header.h
new file mode 100644 (file)
index 0000000..3fbddb8
--- /dev/null
@@ -0,0 +1,20 @@
+// Copyright (c) 2017 Google Inc.
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+//     http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
+#ifndef LIBSPIRV_LATEST_VERSION_GLSL_STD_450_HEADER_H_
+#define LIBSPIRV_LATEST_VERSION_GLSL_STD_450_HEADER_H_
+
+#include "spirv/1.2/GLSL.std.450.h"
+
+#endif  // LIBSPIRV_LATEST_VERSION_GLSL_STD_450_HEADER_H_
diff --git a/source/latest_version_opencl_std_header.h b/source/latest_version_opencl_std_header.h
new file mode 100644 (file)
index 0000000..aa68f08
--- /dev/null
@@ -0,0 +1,20 @@
+// Copyright (c) 2017 Google Inc.
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+//     http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
+#ifndef LIBSPIRV_LATEST_VERSION_OPENCL_STD_HEADER_H_
+#define LIBSPIRV_LATEST_VERSION_OPENCL_STD_HEADER_H_
+
+#include "spirv/1.2/OpenCL.std.h"
+
+#endif  // LIBSPIRV_LATEST_VERSION_OPENCL_STD_HEADER_H_
diff --git a/source/latest_version_spirv_header.h b/source/latest_version_spirv_header.h
new file mode 100644 (file)
index 0000000..ea9f45c
--- /dev/null
@@ -0,0 +1,20 @@
+// Copyright (c) 2017 Google Inc.
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+//     http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
+#ifndef LIBSPIRV_LATEST_VERSION_SPIRV_HEADER_H_
+#define LIBSPIRV_LATEST_VERSION_SPIRV_HEADER_H_
+
+#include "spirv/1.2/spirv.h"
+
+#endif  // LIBSPIRV_LATEST_VERSION_SPIRV_HEADER_H_
index 3ba99df..25c8de9 100644 (file)
@@ -16,8 +16,8 @@
 #define LIBSPIRV_OPCODE_H_
 
 #include "instruction.h"
+#include "latest_version_spirv_header.h"
 #include "spirv-tools/libspirv.h"
-#include "spirv/1.2/spirv.h"
 #include "table.h"
 
 // Returns the name of a registered SPIR-V generator as a null-terminated
index 512cdd7..b9b5486 100644 (file)
@@ -18,7 +18,7 @@
 
 #include "cfa.h"
 #include "iterator.h"
-#include "spirv/1.0/GLSL.std.450.h"
+#include "latest_version_glsl_std_450_header.h"
 
 #include <stack>
 
index 1bd1344..3ddf741 100644 (file)
@@ -24,8 +24,8 @@
 #include "operand.h"
 #include "util/ilist_node.h"
 
+#include "latest_version_spirv_header.h"
 #include "spirv-tools/libspirv.h"
-#include "spirv/1.2/spirv.h"
 
 namespace spvtools {
 namespace ir {
index 2b7b931..182317f 100644 (file)
@@ -25,8 +25,8 @@
 #include "operand.h"
 #include "util/ilist.h"
 
+#include "latest_version_spirv_header.h"
 #include "spirv-tools/libspirv.h"
-#include "spirv/1.2/spirv.h"
 
 namespace spvtools {
 namespace ir {
@@ -104,11 +104,10 @@ class InstructionList : public utils::IntrusiveList<Instruction> {
 
   // Runs the given function |f| on the instructions in the list and optionally
   // on the preceding debug line instructions.
-  inline void ForEachInst(
-      const std::function<void(Instruction*)>& f,
-      bool run_on_debug_line_insts) {
+  inline void ForEachInst(const std::function<void(Instruction*)>& f,
+                          bool run_on_debug_line_insts) {
     auto next = begin();
-    for( auto i = next; i != end(); i = next ) {
+    for (auto i = next; i != end(); i = next) {
       ++next;
       i->ForEachInst(f, run_on_debug_line_insts);
     }
index 9f68db7..c899591 100644 (file)
@@ -13,9 +13,9 @@
 // limitations under the License.
 
 #include "ir_context.h"
+#include "latest_version_glsl_std_450_header.h"
 #include "log.h"
 #include "mem_pass.h"
-#include "spirv/1.0/GLSL.std.450.h"
 
 #include <cstring>
 
index 139f53c..cb40ba0 100644 (file)
@@ -18,7 +18,7 @@
 
 #include "cfa.h"
 #include "iterator.h"
-#include "spirv/1.0/GLSL.std.450.h"
+#include "latest_version_glsl_std_450_header.h"
 
 namespace spvtools {
 namespace opt {
index ce5c331..c5fd653 100644 (file)
@@ -15,7 +15,7 @@
 #ifndef LIBSPIRV_OPT_REFLECT_H_
 #define LIBSPIRV_OPT_REFLECT_H_
 
-#include "spirv/1.2/spirv.h"
+#include "latest_version_spirv_header.h"
 
 namespace spvtools {
 namespace ir {
index b6b62c5..f1c8e3e 100644 (file)
@@ -21,8 +21,8 @@
 #include <unordered_map>
 #include <vector>
 
+#include "latest_version_spirv_header.h"
 #include "spirv-tools/libspirv.h"
-#include "spirv/1.2/spirv.h"
 
 namespace spvtools {
 namespace opt {
index c70ade1..92ccd15 100644 (file)
@@ -15,8 +15,8 @@
 #ifndef LIBSPIRV_SPIRV_CONSTANT_H_
 #define LIBSPIRV_SPIRV_CONSTANT_H_
 
+#include "latest_version_spirv_header.h"
 #include "spirv-tools/libspirv.h"
-#include "spirv/1.2/spirv.h"
 
 // Version number macros.
 
index b82bda1..9e22108 100644 (file)
@@ -17,7 +17,7 @@
 
 #include <cstdint>
 
-#include "spirv/1.2/spirv.h"
+#include "latest_version_spirv_header.h"
 
 #define spvIsInBitfield(value, bitfield) ((value) == ((value)&bitfield))
 
index 1422db4..dc185e2 100644 (file)
@@ -15,7 +15,7 @@
 #ifndef LIBSPIRV_TABLE_H_
 #define LIBSPIRV_TABLE_H_
 
-#include "spirv/1.2/spirv.h"
+#include "latest_version_spirv_header.h"
 
 #include "extensions.h"
 #include "message.h"
index f42d624..c2a5bb8 100644 (file)
@@ -15,7 +15,7 @@
 #ifndef LIBSPIRV_VAL_BASICBLOCK_H_
 #define LIBSPIRV_VAL_BASICBLOCK_H_
 
-#include "spirv/1.2/spirv.h"
+#include "latest_version_spirv_header.h"
 
 #include <cstdint>
 
index e6e85ea..b1d894a 100644 (file)
@@ -19,7 +19,7 @@
 #include <unordered_map>
 #include <vector>
 
-#include "spirv/1.2/spirv.h"
+#include "latest_version_spirv_header.h"
 
 namespace libspirv {
 
index eb23201..f6afb71 100644 (file)
@@ -23,8 +23,8 @@
 #include <unordered_set>
 #include <vector>
 
+#include "latest_version_spirv_header.h"
 #include "spirv-tools/libspirv.h"
-#include "spirv/1.2/spirv.h"
 #include "val/basic_block.h"
 #include "val/construct.h"
 
index 6005605..986d759 100644 (file)
@@ -26,8 +26,8 @@
 #include "decoration.h"
 #include "diagnostic.h"
 #include "enum_set.h"
+#include "latest_version_spirv_header.h"
 #include "spirv-tools/libspirv.h"
-#include "spirv/1.2/spirv.h"
 #include "spirv_definition.h"
 #include "val/function.h"
 #include "val/instruction.h"
index c979751..bb1d6ff 100644 (file)
@@ -17,9 +17,9 @@
 #include <vector>
 
 #include "gmock/gmock.h"
+#include "latest_version_opencl_std_header.h"
 #include "source/message.h"
 #include "source/table.h"
-#include "spirv/1.0/OpenCL.std.h"
 #include "test_fixture.h"
 #include "unit_spirv.h"
 
index e1da2f9..5e569ea 100644 (file)
@@ -15,7 +15,7 @@
 #include <algorithm>
 #include <vector>
 
-#include "spirv/1.0/GLSL.std.450.h"
+#include "latest_version_glsl_std_450_header.h"
 #include "unit_spirv.h"
 
 namespace {
index af739f6..6829e3c 100644 (file)
@@ -15,7 +15,7 @@
 #include "unit_spirv.h"
 
 #include <gmock/gmock.h>
-#include "spirv/1.0/OpenCL.std.h"
+#include "latest_version_opencl_std_header.h"
 #include "test_fixture.h"
 
 namespace {
index 6667969..9608af8 100644 (file)
@@ -17,7 +17,7 @@
 #include <sstream>
 #include <string>
 
-#include "spirv/1.1/spirv.h"
+#include "latest_version_spirv_header.h"
 #include "test_fixture.h"
 #include "tools/stats/stats_analyzer.h"
 
index e2a5101..032c38e 100644 (file)
@@ -18,8 +18,8 @@
 #include "unit_spirv.h"
 
 #include "gmock/gmock.h"
-#include "spirv/1.0/GLSL.std.450.h"
-#include "spirv/1.0/OpenCL.std.h"
+#include "latest_version_glsl_std_450_header.h"
+#include "latest_version_opencl_std_header.h"
 #include "test_fixture.h"
 
 namespace {
index ea09cf9..c63a0c5 100644 (file)
@@ -18,7 +18,7 @@
 #include <vector>
 
 #include "gtest/gtest.h"
-#include "spirv/1.1/spirv.h"
+#include "latest_version_spirv_header.h"
 
 #include "enum_set.h"
 #include "extensions.h"