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#ifndef SOURCE_OPT_COMPOSITE_H_
18#define SOURCE_OPT_COMPOSITE_H_
19
20#include <algorithm>
21#include <map>
22#include <unordered_map>
23#include <unordered_set>
24#include <utility>
25#include <vector>
26
27#include "source/opt/basic_block.h"
28#include "source/opt/def_use_manager.h"
29#include "source/opt/ir_context.h"
30#include "source/opt/module.h"
31
32namespace spvtools {
33namespace opt {
34
35// Return true if the extract indices in |extIndices| starting at |extOffset|
36// match indices of insert |insInst|.
37bool ExtInsMatch(const std::vector<uint32_t>& extIndices,
38 const Instruction* insInst, const uint32_t extOffset);
39
40// Return true if indices in |extIndices| starting at |extOffset| and
41// indices of insert |insInst| conflict, specifically, if the insert
42// changes bits specified by the extract, but changes either more bits
43// or less bits than the extract specifies, meaning the exact value being
44// inserted cannot be used to replace the extract.
45bool ExtInsConflict(const std::vector<uint32_t>& extIndices,
46 const Instruction* insInst, const uint32_t extOffset);
47
48} // namespace opt
49} // namespace spvtools
50
51#endif // SOURCE_OPT_COMPOSITE_H_
52