diff options
author | Björn Gustavsson <[email protected]> | 2015-06-25 13:21:14 +0200 |
---|---|---|
committer | Björn Gustavsson <[email protected]> | 2015-07-03 14:34:58 +0200 |
commit | 62473daf8169a04a07409f344d938bc51a4536c3 (patch) | |
tree | 153bf43a5833103f6d368de318288aad692fcedf /erts/emulator/beam/beam_emu.c | |
parent | 3dc2bee53b4d36f41821a6ab512cf01c958c11f9 (diff) | |
download | otp-62473daf8169a04a07409f344d938bc51a4536c3.tar.gz otp-62473daf8169a04a07409f344d938bc51a4536c3.tar.bz2 otp-62473daf8169a04a07409f344d938bc51a4536c3.zip |
Introduce swap_temp/3 and swap/2
Sequences of three move instructionst that effectively swap the
contents of two registers are fairly common. We can replace them
with a swap_temp/3 instruction. The third operand is the temporary
register to be used for swapping, since the temporary register
may actually be used.
If swap_temp/3 instruction is followed by a call, the temporary
register will often (but not always) be killed by the call. If
it is killed, we can replace the swap_temp/3 instruction with a
slightly cheaper swap/2 instruction.
Diffstat (limited to 'erts/emulator/beam/beam_emu.c')
-rw-r--r-- | erts/emulator/beam/beam_emu.c | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/erts/emulator/beam/beam_emu.c b/erts/emulator/beam/beam_emu.c index 2c10e7ae7c..4e6e7aa48a 100644 --- a/erts/emulator/beam/beam_emu.c +++ b/erts/emulator/beam/beam_emu.c @@ -545,6 +545,20 @@ void** beam_ops; HTOP += 2; \ } while (0) +#define Swap(R1, R2) \ + do { \ + Eterm V = R1; \ + R1 = R2; \ + R2 = V; \ + } while (0) + +#define SwapTemp(R1, R2, Tmp) \ + do { \ + Eterm V = R1; \ + R1 = R2; \ + R2 = Tmp = V; \ + } while (0) + #define Move(Src, Dst, Store) \ do { \ Eterm term = (Src); \ |