remove_duplicates_pass.h 1.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  1. // Copyright (c) 2017 Pierre Moreau
  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. #ifndef SOURCE_OPT_REMOVE_DUPLICATES_PASS_H_
  15. #define SOURCE_OPT_REMOVE_DUPLICATES_PASS_H_
  16. #include <unordered_map>
  17. #include <vector>
  18. #include "source/opt/decoration_manager.h"
  19. #include "source/opt/def_use_manager.h"
  20. #include "source/opt/ir_context.h"
  21. #include "source/opt/module.h"
  22. #include "source/opt/pass.h"
  23. namespace spvtools {
  24. namespace opt {
  25. using IdDecorationsList =
  26. std::unordered_map<uint32_t, std::vector<Instruction*>>;
  27. // See optimizer.hpp for documentation.
  28. class RemoveDuplicatesPass : public Pass {
  29. public:
  30. const char* name() const override { return "remove-duplicates"; }
  31. Status Process() override;
  32. private:
  33. // Remove duplicate capabilities from the module
  34. //
  35. // Returns true if the module was modified, false otherwise.
  36. bool RemoveDuplicateCapabilities() const;
  37. // Remove duplicate extended instruction imports from the module
  38. //
  39. // Returns true if the module was modified, false otherwise.
  40. bool RemoveDuplicatesExtInstImports() const;
  41. // Remove duplicate types from the module
  42. //
  43. // Returns true if the module was modified, false otherwise.
  44. bool RemoveDuplicateTypes() const;
  45. // Remove duplicate decorations from the module
  46. //
  47. // Returns true if the module was modified, false otherwise.
  48. bool RemoveDuplicateDecorations() const;
  49. };
  50. } // namespace opt
  51. } // namespace spvtools
  52. #endif // SOURCE_OPT_REMOVE_DUPLICATES_PASS_H_