From 8434abaa0e1a911cb44437034bb085d42383e721 Mon Sep 17 00:00:00 2001 From: Joel Dice Date: Wed, 14 May 2008 17:33:55 -0600 Subject: [PATCH] implement swapRR --- src/x86.cpp | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) diff --git a/src/x86.cpp b/src/x86.cpp index a1c28c0dbc..6ecd286005 100644 --- a/src/x86.cpp +++ b/src/x86.cpp @@ -580,15 +580,6 @@ void xorRR(Context* c, unsigned size, Assembler::Register* a, Assembler::Register* b); -void -swap(Context* c, Assembler::Register* a, Assembler::Register* b) -{ - // todo: use xchg instead - xorRR(c, 4, a, b); - xorRR(c, 4, b, b); - xorRR(c, 4, a, b); -} - void negateR(Context* c, unsigned size, Assembler::Register* a) { @@ -908,6 +899,14 @@ moveZRR(Context* c, unsigned size, Assembler::Register* a, } } +void +swapRR(Context* c, unsigned, Assembler::Register* a, Assembler::Register* b) +{ + rex(c); + c->code.append(0x87); + c->code.append(0xc0 | (b->low << 3) | a->low); +} + void addCM(Context* c, unsigned size UNUSED, Assembler::Constant* a, Assembler::Memory* b) @@ -1762,6 +1761,8 @@ populateTables() BinaryOperations[INDEX2(MoveZ, Memory, Register)] = CAST2(moveZMR); BinaryOperations[INDEX2(MoveZ, Register, Register)] = CAST2(moveZRR); + BinaryOperations[INDEX2(Swap, Register, Register)] = CAST2(swapRR); + BinaryOperations[INDEX2(Add, Constant, Register)] = CAST2(addCR); BinaryOperations[INDEX2(Add, Register, Register)] = CAST2(addRR); BinaryOperations[INDEX2(Add, Register, Memory)] = CAST2(addRM);