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