2
0

composite.h 1.8 KB

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