implement swapRR

This commit is contained in:
Joel Dice 2008-05-14 17:33:55 -06:00
parent 04f4ad4f58
commit 8434abaa0e

View File

@ -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);