During register allocation when compiling a high level language to a low-level intermediate representation (say, GNU lightning's instruction set), it is often needed to swap the contents of two or more registers. When there is no scratch register available (for example, due to high register pressure), this can be done using the xor trick.
The x64 ISA, however, also provides the xchg instruction which performs better than three xors in a row. Other ISAs may provide similar instructions. Thus I would like to suggest to add an xchgr instruction to GNU lightning's instruction set that exchanges the contents of two registers. By default, it can be implemented with the xor trick. On specific architectures, like the x64, it can be compiled to the native xchg instruction.
Marc