/src/shaderc/third_party/spirv-tools/source/ext_inst.cpp
Line | Count | Source |
1 | | // Copyright (c) 2015-2016 The Khronos Group Inc. |
2 | | // |
3 | | // Licensed under the Apache License, Version 2.0 (the "License"); |
4 | | // you may not use this file except in compliance with the License. |
5 | | // You may obtain a copy of the License at |
6 | | // |
7 | | // http://www.apache.org/licenses/LICENSE-2.0 |
8 | | // |
9 | | // Unless required by applicable law or agreed to in writing, software |
10 | | // distributed under the License is distributed on an "AS IS" BASIS, |
11 | | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
12 | | // See the License for the specific language governing permissions and |
13 | | // limitations under the License. |
14 | | |
15 | | #include "source/ext_inst.h" |
16 | | |
17 | | #include <cstring> |
18 | | |
19 | | // DebugInfo extended instruction set. |
20 | | // #include "DebugInfo.h" |
21 | | |
22 | 1.01k | spv_ext_inst_type_t spvExtInstImportTypeGet(const char* name) { |
23 | | // The names are specified by the respective extension instruction |
24 | | // specifications. |
25 | 1.01k | if (!strcmp("GLSL.std.450", name)) { |
26 | 986 | return SPV_EXT_INST_TYPE_GLSL_STD_450; |
27 | 986 | } |
28 | 28 | if (!strcmp("OpenCL.std", name)) { |
29 | 0 | return SPV_EXT_INST_TYPE_OPENCL_STD; |
30 | 0 | } |
31 | 28 | if (!strcmp("SPV_AMD_shader_explicit_vertex_parameter", name)) { |
32 | 28 | return SPV_EXT_INST_TYPE_SPV_AMD_SHADER_EXPLICIT_VERTEX_PARAMETER; |
33 | 28 | } |
34 | 0 | if (!strcmp("SPV_AMD_shader_trinary_minmax", name)) { |
35 | 0 | return SPV_EXT_INST_TYPE_SPV_AMD_SHADER_TRINARY_MINMAX; |
36 | 0 | } |
37 | 0 | if (!strcmp("SPV_AMD_gcn_shader", name)) { |
38 | 0 | return SPV_EXT_INST_TYPE_SPV_AMD_GCN_SHADER; |
39 | 0 | } |
40 | 0 | if (!strcmp("SPV_AMD_shader_ballot", name)) { |
41 | 0 | return SPV_EXT_INST_TYPE_SPV_AMD_SHADER_BALLOT; |
42 | 0 | } |
43 | 0 | if (!strcmp("DebugInfo", name)) { |
44 | 0 | return SPV_EXT_INST_TYPE_DEBUGINFO; |
45 | 0 | } |
46 | 0 | if (!strcmp("OpenCL.DebugInfo.100", name)) { |
47 | 0 | return SPV_EXT_INST_TYPE_OPENCL_DEBUGINFO_100; |
48 | 0 | } |
49 | | // Match any version of NonSemantic.Shader.DebugInfo. |
50 | | // Later versions are supersets that share the same instruction numbering. |
51 | 0 | if (!strncmp("NonSemantic.Shader.DebugInfo.", name, 29)) { |
52 | 0 | return SPV_EXT_INST_TYPE_NONSEMANTIC_SHADER_DEBUGINFO_100; |
53 | 0 | } |
54 | 0 | if (!strncmp("NonSemantic.ClspvReflection.", name, 28)) { |
55 | 0 | return SPV_EXT_INST_TYPE_NONSEMANTIC_CLSPVREFLECTION; |
56 | 0 | } |
57 | 0 | if (!strncmp("NonSemantic.VkspReflection.", name, 27)) { |
58 | 0 | return SPV_EXT_INST_TYPE_NONSEMANTIC_VKSPREFLECTION; |
59 | 0 | } |
60 | 0 | if (!strcmp("TOSA.001000.1", name)) { |
61 | 0 | return SPV_EXT_INST_TYPE_TOSA_001000_1; |
62 | 0 | } |
63 | 0 | if (!strcmp("Arm.MotionEngine.100", name)) { |
64 | 0 | return SPV_EXT_INST_TYPE_ARM_MOTION_ENGINE_100; |
65 | 0 | } |
66 | | // ensure to add any known non-semantic extended instruction sets |
67 | | // above this point, and update spvExtInstIsNonSemantic() |
68 | 0 | if (!strncmp("NonSemantic.", name, 12)) { |
69 | 0 | return SPV_EXT_INST_TYPE_NONSEMANTIC_UNKNOWN; |
70 | 0 | } |
71 | 0 | return SPV_EXT_INST_TYPE_NONE; |
72 | 0 | } |
73 | | |
74 | 1.49k | bool spvExtInstIsNonSemantic(const spv_ext_inst_type_t type) { |
75 | 1.49k | if (type == SPV_EXT_INST_TYPE_NONSEMANTIC_UNKNOWN || |
76 | 1.49k | type == SPV_EXT_INST_TYPE_NONSEMANTIC_SHADER_DEBUGINFO_100 || |
77 | 1.49k | type == SPV_EXT_INST_TYPE_NONSEMANTIC_CLSPVREFLECTION || |
78 | 1.49k | type == SPV_EXT_INST_TYPE_NONSEMANTIC_VKSPREFLECTION) { |
79 | 0 | return true; |
80 | 0 | } |
81 | 1.49k | return false; |
82 | 1.49k | } |
83 | | |
84 | 1.23k | bool spvExtInstIsDebugInfo(const spv_ext_inst_type_t type) { |
85 | 1.23k | if (type == SPV_EXT_INST_TYPE_OPENCL_DEBUGINFO_100 || |
86 | 1.23k | type == SPV_EXT_INST_TYPE_NONSEMANTIC_SHADER_DEBUGINFO_100 || |
87 | 1.23k | type == SPV_EXT_INST_TYPE_DEBUGINFO) { |
88 | 0 | return true; |
89 | 0 | } |
90 | 1.23k | return false; |
91 | 1.23k | } |