I want to compare two pieces of low-level code, each in its own file. The format is AT&T-Assembly-style: For me, it's two CUDA PTX files, but this question applies also for the output of gcc -S
or clang -S
. For the sake of discussion assume that they're two implementations of the same function.
Now, I can of course diff
the files textually. The problem is that the register assignments are different. The programs could be completely the same, just with different register names; or a small difference in one line may change the register assignments everywhere (e.g. reduce everything by 1 since an extra register is not used).
I don't mind extra instructions or comments etc. - those are handled just fine by textual diff tools.
My question: What can I do in order to hide those register differences everywhere, for a more "structural" comparison? Should I try some "canonicalization" with a pre-diff'ing parsing script (and if so, which/how)? Can I maybe avail myself of an assembler which takes my code, or a compiler which produces my code, to help me with this?