Coverage Report

Created: 2025-08-26 07:00

/src/shaderc/third_party/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
7.75k
spv_ext_inst_type_t spvExtInstImportTypeGet(const char* name) {
23
  // The names are specified by the respective extension instruction
24
  // specifications.
25
7.75k
  if (!strcmp("GLSL.std.450", name)) {
26
7.66k
    return SPV_EXT_INST_TYPE_GLSL_STD_450;
27
7.66k
  }
28
94
  if (!strcmp("OpenCL.std", name)) {
29
0
    return SPV_EXT_INST_TYPE_OPENCL_STD;
30
0
  }
31
94
  if (!strcmp("SPV_AMD_shader_explicit_vertex_parameter", name)) {
32
54
    return SPV_EXT_INST_TYPE_SPV_AMD_SHADER_EXPLICIT_VERTEX_PARAMETER;
33
54
  }
34
40
  if (!strcmp("SPV_AMD_shader_trinary_minmax", name)) {
35
0
    return SPV_EXT_INST_TYPE_SPV_AMD_SHADER_TRINARY_MINMAX;
36
0
  }
37
40
  if (!strcmp("SPV_AMD_gcn_shader", name)) {
38
0
    return SPV_EXT_INST_TYPE_SPV_AMD_GCN_SHADER;
39
0
  }
40
40
  if (!strcmp("SPV_AMD_shader_ballot", name)) {
41
0
    return SPV_EXT_INST_TYPE_SPV_AMD_SHADER_BALLOT;
42
0
  }
43
40
  if (!strcmp("DebugInfo", name)) {
44
0
    return SPV_EXT_INST_TYPE_DEBUGINFO;
45
0
  }
46
40
  if (!strcmp("OpenCL.DebugInfo.100", name)) {
47
0
    return SPV_EXT_INST_TYPE_OPENCL_DEBUGINFO_100;
48
0
  }
49
40
  if (!strcmp("NonSemantic.Shader.DebugInfo.100", name)) {
50
0
    return SPV_EXT_INST_TYPE_NONSEMANTIC_SHADER_DEBUGINFO_100;
51
0
  }
52
40
  if (!strncmp("NonSemantic.ClspvReflection.", name, 28)) {
53
0
    return SPV_EXT_INST_TYPE_NONSEMANTIC_CLSPVREFLECTION;
54
0
  }
55
40
  if (!strncmp("NonSemantic.VkspReflection.", name, 27)) {
56
0
    return SPV_EXT_INST_TYPE_NONSEMANTIC_VKSPREFLECTION;
57
0
  }
58
40
  if (!strcmp("TOSA.001000.1", name)) {
59
0
    return SPV_EXT_INST_TYPE_TOSA_001000_1;
60
0
  }
61
  // ensure to add any known non-semantic extended instruction sets
62
  // above this point, and update spvExtInstIsNonSemantic()
63
40
  if (!strncmp("NonSemantic.", name, 12)) {
64
36
    return SPV_EXT_INST_TYPE_NONSEMANTIC_UNKNOWN;
65
36
  }
66
4
  return SPV_EXT_INST_TYPE_NONE;
67
40
}
68
69
5.73k
bool spvExtInstIsNonSemantic(const spv_ext_inst_type_t type) {
70
5.73k
  if (type == SPV_EXT_INST_TYPE_NONSEMANTIC_UNKNOWN ||
71
5.73k
      type == SPV_EXT_INST_TYPE_NONSEMANTIC_SHADER_DEBUGINFO_100 ||
72
5.73k
      type == SPV_EXT_INST_TYPE_NONSEMANTIC_CLSPVREFLECTION ||
73
5.73k
      type == SPV_EXT_INST_TYPE_NONSEMANTIC_VKSPREFLECTION) {
74
128
    return true;
75
128
  }
76
5.60k
  return false;
77
5.73k
}
78
79
11.3k
bool spvExtInstIsDebugInfo(const spv_ext_inst_type_t type) {
80
11.3k
  if (type == SPV_EXT_INST_TYPE_OPENCL_DEBUGINFO_100 ||
81
11.3k
      type == SPV_EXT_INST_TYPE_NONSEMANTIC_SHADER_DEBUGINFO_100 ||
82
11.3k
      type == SPV_EXT_INST_TYPE_DEBUGINFO) {
83
0
    return true;
84
0
  }
85
11.3k
  return false;
86
11.3k
}