Coverage Report

Created: 2025-10-13 06:58

next uncovered line (L), next uncovered region (R), next uncovered branch (B)
/src/shaderc/third_party/spirv-tools/source/opt/composite.cpp
Line
Count
Source
1
// Copyright (c) 2018 The Khronos Group Inc.
2
// Copyright (c) 2018 Valve Corporation
3
// Copyright (c) 2018 LunarG Inc.
4
//
5
// Licensed under the Apache License, Version 2.0 (the "License");
6
// you may not use this file except in compliance with the License.
7
// You may obtain a copy of the License at
8
//
9
//     http://www.apache.org/licenses/LICENSE-2.0
10
//
11
// Unless required by applicable law or agreed to in writing, software
12
// distributed under the License is distributed on an "AS IS" BASIS,
13
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14
// See the License for the specific language governing permissions and
15
// limitations under the License.
16
17
#include "source/opt/composite.h"
18
19
#include <vector>
20
21
#include "source/opt/ir_context.h"
22
#include "source/opt/iterator.h"
23
#include "spirv/1.2/GLSL.std.450.h"
24
25
namespace spvtools {
26
namespace opt {
27
28
bool ExtInsMatch(const std::vector<uint32_t>& extIndices,
29
1.52k
                 const Instruction* insInst, const uint32_t extOffset) {
30
1.52k
  uint32_t numIndices = static_cast<uint32_t>(extIndices.size()) - extOffset;
31
1.52k
  if (numIndices != insInst->NumInOperands() - 2) return false;
32
1.95k
  for (uint32_t i = 0; i < numIndices; ++i)
33
1.52k
    if (extIndices[i + extOffset] != insInst->GetSingleWordInOperand(i + 2))
34
1.08k
      return false;
35
432
  return true;
36
1.52k
}
37
38
bool ExtInsConflict(const std::vector<uint32_t>& extIndices,
39
1.08k
                    const Instruction* insInst, const uint32_t extOffset) {
40
1.08k
  if (extIndices.size() - extOffset == insInst->NumInOperands() - 2)
41
1.08k
    return false;
42
0
  uint32_t extNumIndices = static_cast<uint32_t>(extIndices.size()) - extOffset;
43
0
  uint32_t insNumIndices = insInst->NumInOperands() - 2;
44
0
  uint32_t numIndices = std::min(extNumIndices, insNumIndices);
45
0
  for (uint32_t i = 0; i < numIndices; ++i)
46
0
    if (extIndices[i + extOffset] != insInst->GetSingleWordInOperand(i + 2))
47
0
      return false;
48
0
  return true;
49
0
}
50
51
}  // namespace opt
52
}  // namespace spvtools