block_merge_util.h 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  1. // Copyright (c) 2017 The Khronos Group Inc.
  2. // Copyright (c) 2017 Valve Corporation
  3. // Copyright (c) 2017 LunarG Inc.
  4. // Copyright (c) 2019 Google LLC
  5. //
  6. // Licensed under the Apache License, Version 2.0 (the "License");
  7. // you may not use this file except in compliance with the License.
  8. // You may obtain a copy of the License at
  9. //
  10. // http://www.apache.org/licenses/LICENSE-2.0
  11. //
  12. // Unless required by applicable law or agreed to in writing, software
  13. // distributed under the License is distributed on an "AS IS" BASIS,
  14. // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  15. // See the License for the specific language governing permissions and
  16. // limitations under the License.
  17. #ifndef SOURCE_OPT_BLOCK_MERGE_UTIL_H_
  18. #define SOURCE_OPT_BLOCK_MERGE_UTIL_H_
  19. #include "source/opt/ir_context.h"
  20. namespace spvtools {
  21. namespace opt {
  22. // Provides functions for determining when it is safe to merge blocks, and for
  23. // actually merging blocks, for use by various analyses and passes.
  24. namespace blockmergeutil {
  25. // Returns true if and only if |block| has exactly one successor and merging
  26. // this successor into |block| has no impact on the semantics or validity of the
  27. // SPIR-V module.
  28. bool CanMergeWithSuccessor(IRContext* context, BasicBlock* block);
  29. // Requires that |bi| has a successor that can be safely merged into |bi|, and
  30. // performs the merge.
  31. void MergeWithSuccessor(IRContext* context, Function* func,
  32. Function::iterator bi);
  33. } // namespace blockmergeutil
  34. } // namespace opt
  35. } // namespace spvtools
  36. #endif // SOURCE_OPT_BLOCK_MERGE_UTIL_H_