Coverage Report

Created: 2023-03-01 07:18

/src/spirv-tools/source/table.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/table.h"
16
17
#include <utility>
18
19
3.92k
spv_context spvContextCreate(spv_target_env env) {
20
3.92k
  switch (env) {
21
0
    case SPV_ENV_UNIVERSAL_1_0:
22
0
    case SPV_ENV_VULKAN_1_0:
23
0
    case SPV_ENV_UNIVERSAL_1_1:
24
0
    case SPV_ENV_OPENCL_1_2:
25
0
    case SPV_ENV_OPENCL_EMBEDDED_1_2:
26
0
    case SPV_ENV_OPENCL_2_0:
27
0
    case SPV_ENV_OPENCL_EMBEDDED_2_0:
28
0
    case SPV_ENV_OPENCL_2_1:
29
0
    case SPV_ENV_OPENCL_EMBEDDED_2_1:
30
0
    case SPV_ENV_OPENCL_2_2:
31
0
    case SPV_ENV_OPENCL_EMBEDDED_2_2:
32
0
    case SPV_ENV_OPENGL_4_0:
33
3.92k
    case SPV_ENV_OPENGL_4_1:
34
3.92k
    case SPV_ENV_OPENGL_4_2:
35
3.92k
    case SPV_ENV_OPENGL_4_3:
36
3.92k
    case SPV_ENV_OPENGL_4_5:
37
3.92k
    case SPV_ENV_UNIVERSAL_1_2:
38
3.92k
    case SPV_ENV_UNIVERSAL_1_3:
39
3.92k
    case SPV_ENV_VULKAN_1_1:
40
3.92k
    case SPV_ENV_VULKAN_1_1_SPIRV_1_4:
41
3.92k
    case SPV_ENV_UNIVERSAL_1_4:
42
3.92k
    case SPV_ENV_UNIVERSAL_1_5:
43
3.92k
    case SPV_ENV_VULKAN_1_2:
44
3.92k
    case SPV_ENV_UNIVERSAL_1_6:
45
3.92k
    case SPV_ENV_VULKAN_1_3:
46
3.92k
      break;
47
0
    default:
48
0
      return nullptr;
49
3.92k
  }
50
51
3.92k
  spv_opcode_table opcode_table;
52
3.92k
  spv_operand_table operand_table;
53
3.92k
  spv_ext_inst_table ext_inst_table;
54
55
3.92k
  spvOpcodeTableGet(&opcode_table, env);
56
3.92k
  spvOperandTableGet(&operand_table, env);
57
3.92k
  spvExtInstTableGet(&ext_inst_table, env);
58
59
3.92k
  return new spv_context_t{env, opcode_table, operand_table, ext_inst_table,
60
3.92k
                           nullptr /* a null default consumer */};
61
3.92k
}
62
63
3.92k
void spvContextDestroy(spv_context context) { delete context; }
64
65
void spvtools::SetContextMessageConsumer(spv_context context,
66
0
                                         spvtools::MessageConsumer consumer) {
67
0
  context->consumer = std::move(consumer);
68
0
}