diff.h 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  1. // Copyright (c) 2022 Google LLC.
  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_DIFF_DIFF_H_
  15. #define SOURCE_DIFF_DIFF_H_
  16. #include "source/opt/ir_context.h"
  17. namespace spvtools {
  18. namespace diff {
  19. struct Options {
  20. bool ignore_set_binding = false;
  21. bool ignore_location = false;
  22. bool indent = false;
  23. bool no_header = false;
  24. bool color_output = false;
  25. bool dump_id_map = false;
  26. };
  27. // Given two SPIR-V modules, this function outputs the textual diff of their
  28. // assembly in `out`. The diff is *semantic*, so that the ordering of certain
  29. // instructions wouldn't matter.
  30. //
  31. // The output is a disassembly of src, with diff(1)-style + and - lines that
  32. // show how the src is changed into dst. To make this disassembly
  33. // self-consistent, the ids that are output are all in the space of the src
  34. // module; e.g. any + lines (showing instructions from the dst module) have
  35. // their ids mapped to the matched instruction in the src module (or a new id
  36. // allocated in the src module if unmatched).
  37. spv_result_t Diff(opt::IRContext* src, opt::IRContext* dst, std::ostream& out,
  38. Options options);
  39. } // namespace diff
  40. } // namespace spvtools
  41. #endif // SOURCE_DIFF_DIFF_H_