Coverage Report

Created: 2026-06-30 06:51

next uncovered line (L), next uncovered region (R), next uncovered branch (B)
/src/spirv-tools/source/opt/legalize_multidim_array_pass.h
Line
Count
Source
1
// Copyright (c) 2026 Google LLC
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
#ifndef SOURCE_OPT_LEGALIZE_MULTIDIM_ARRAY_PASS_H_
16
#define SOURCE_OPT_LEGALIZE_MULTIDIM_ARRAY_PASS_H_
17
18
#include "source/opt/pass.h"
19
20
namespace spvtools {
21
namespace opt {
22
23
// Pass to legalize multidimensional arrays of resources for Vulkan.
24
// It transforms multidimensional arrays into single-dimensional ones.
25
class LegalizeMultidimArrayPass : public Pass {
26
 public:
27
9.45k
  const char* name() const override { return "legalize-multidim-array"; }
28
  Status Process() override;
29
30
 private:
31
  // Returns true if |var| is a multidimensional array of resources.
32
  bool IsMultidimArrayOfResources(Instruction* var);
33
34
  // Flattens the multidimensional array type of |var| and returns the new type
35
  // id.
36
  uint32_t FlattenArrayType(Instruction* var);
37
38
  // Rewrites all access chains that use |var|.
39
  bool RewriteAccessChains(Instruction* var, uint32_t old_ptr_type_id);
40
41
  // Returns true if all uses of |var| can be legalized.
42
  bool CanLegalize(Instruction* var);
43
44
  // Recursively checks if the uses of |inst| can be legalized.
45
  bool CheckUse(Instruction* inst, uint32_t max_depth);
46
47
  // Returns the dimensions of the array type |type_id|.
48
  void GetArrayDimensions(uint32_t type_id, std::vector<uint32_t>* dims,
49
                          uint32_t* element_type_id);
50
};
51
52
}  // namespace opt
53
}  // namespace spvtools
54
55
#endif  // SOURCE_OPT_LEGALIZE_MULTIDIM_ARRAY_PASS_H_