/home/runner/work/DirectXShaderCompiler/DirectXShaderCompiler/external/SPIRV-Tools/source/ext_inst.cpp
Line | Count | Source (jump to first uncovered line) |
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 | 2.06k | spv_ext_inst_type_t spvExtInstImportTypeGet(const char* name) { |
23 | | // The names are specified by the respective extension instruction |
24 | | // specifications. |
25 | 2.06k | if (!strcmp("GLSL.std.450", name)) { |
26 | 924 | return SPV_EXT_INST_TYPE_GLSL_STD_450; |
27 | 924 | } |
28 | 1.14k | if (!strcmp("OpenCL.std", name)) { |
29 | 0 | return SPV_EXT_INST_TYPE_OPENCL_STD; |
30 | 0 | } |
31 | 1.14k | if (!strcmp("SPV_AMD_shader_explicit_vertex_parameter", name)) { |
32 | 0 | return SPV_EXT_INST_TYPE_SPV_AMD_SHADER_EXPLICIT_VERTEX_PARAMETER; |
33 | 0 | } |
34 | 1.14k | if (!strcmp("SPV_AMD_shader_trinary_minmax", name)) { |
35 | 10 | return SPV_EXT_INST_TYPE_SPV_AMD_SHADER_TRINARY_MINMAX; |
36 | 10 | } |
37 | 1.13k | if (!strcmp("SPV_AMD_gcn_shader", name)) { |
38 | 0 | return SPV_EXT_INST_TYPE_SPV_AMD_GCN_SHADER; |
39 | 0 | } |
40 | 1.13k | if (!strcmp("SPV_AMD_shader_ballot", name)) { |
41 | 0 | return SPV_EXT_INST_TYPE_SPV_AMD_SHADER_BALLOT; |
42 | 0 | } |
43 | 1.13k | if (!strcmp("DebugInfo", name)) { |
44 | 0 | return SPV_EXT_INST_TYPE_DEBUGINFO; |
45 | 0 | } |
46 | 1.13k | if (!strcmp("OpenCL.DebugInfo.100", name)) { |
47 | 444 | return SPV_EXT_INST_TYPE_OPENCL_DEBUGINFO_100; |
48 | 444 | } |
49 | | // Match any version of NonSemantic.Shader.DebugInfo. |
50 | | // Later versions are supersets that share the same instruction numbering. |
51 | 690 | if (!strncmp("NonSemantic.Shader.DebugInfo.", name, 29)) { |
52 | 632 | return SPV_EXT_INST_TYPE_NONSEMANTIC_SHADER_DEBUGINFO_100; |
53 | 632 | } |
54 | 58 | if (!strncmp("NonSemantic.ClspvReflection.", name, 28)) { |
55 | 0 | return SPV_EXT_INST_TYPE_NONSEMANTIC_CLSPVREFLECTION; |
56 | 0 | } |
57 | 58 | if (!strncmp("NonSemantic.VkspReflection.", name, 27)) { |
58 | 0 | return SPV_EXT_INST_TYPE_NONSEMANTIC_VKSPREFLECTION; |
59 | 0 | } |
60 | 58 | if (!strcmp("TOSA.001000.1", name)) { |
61 | 0 | return SPV_EXT_INST_TYPE_TOSA_001000_1; |
62 | 0 | } |
63 | 58 | 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 | 58 | if (!strncmp("NonSemantic.", name, 12)) { |
69 | 58 | return SPV_EXT_INST_TYPE_NONSEMANTIC_UNKNOWN; |
70 | 58 | } |
71 | 0 | return SPV_EXT_INST_TYPE_NONE; |
72 | 58 | } |
73 | | |
74 | 50.1k | bool spvExtInstIsNonSemantic(const spv_ext_inst_type_t type) { |
75 | 50.1k | if (type == SPV_EXT_INST_TYPE_NONSEMANTIC_UNKNOWN || |
76 | 50.1k | type == SPV_EXT_INST_TYPE_NONSEMANTIC_SHADER_DEBUGINFO_10049.9k || |
77 | 50.1k | type == SPV_EXT_INST_TYPE_NONSEMANTIC_CLSPVREFLECTION23.1k || |
78 | 50.1k | type == SPV_EXT_INST_TYPE_NONSEMANTIC_VKSPREFLECTION23.1k ) { |
79 | 26.9k | return true; |
80 | 26.9k | } |
81 | 23.1k | return false; |
82 | 50.1k | } |
83 | | |
84 | 30.9k | bool spvExtInstIsDebugInfo(const spv_ext_inst_type_t type) { |
85 | 30.9k | if (type == SPV_EXT_INST_TYPE_OPENCL_DEBUGINFO_100 || |
86 | 30.9k | type == SPV_EXT_INST_TYPE_NONSEMANTIC_SHADER_DEBUGINFO_10020.4k || |
87 | 30.9k | type == SPV_EXT_INST_TYPE_DEBUGINFO4.18k ) { |
88 | 26.7k | return true; |
89 | 26.7k | } |
90 | 4.18k | return false; |
91 | 30.9k | } |