// Copyright (c) 2017 The Khronos Group Inc. // Copyright (c) 2017 Valve Corporation // Copyright (c) 2017 LunarG Inc. // Copyright (c) 2019 Google LLC // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. // You may obtain a copy of the License at // // http://www.apache.org/licenses/LICENSE-2.0 // // Unless required by applicable law or agreed to in writing, software // distributed under the License is distributed on an "AS IS" BASIS, // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. // See the License for the specific language governing permissions and // limitations under the License. #include "block_merge_util.h" namespace spvtools { namespace opt { namespace blockmergeutil { namespace { // Returns true if |block| contains a merge instruction. bool IsHeader(BasicBlock* block) { … } // Returns true if |id| contains a merge instruction. bool IsHeader(IRContext* context, uint32_t id) { … } // Returns true if |id| is the merge target of a merge instruction. bool IsMerge(IRContext* context, uint32_t id) { … } // Returns true if |block| is the merge target of a merge instruction. bool IsMerge(IRContext* context, BasicBlock* block) { … } // Returns true if |id| is the continue target of a merge instruction. bool IsContinue(IRContext* context, uint32_t id) { … } // Removes any OpPhi instructions in |block|, which should have exactly one // predecessor, replacing uses of OpPhi ids with the ids associated with the // predecessor. void EliminateOpPhiInstructions(IRContext* context, BasicBlock* block) { … } } // Anonymous namespace bool CanMergeWithSuccessor(IRContext* context, BasicBlock* block) { … } void MergeWithSuccessor(IRContext* context, Function* func, Function::iterator bi) { … } } // namespace blockmergeutil } // namespace opt } // namespace spvtools