handle overlap cases in moveRR

This commit is contained in:
Joel Dice 2008-11-10 19:11:32 -07:00
parent 5fc9ad058b
commit 81d532c4f0

View File

@ -642,6 +642,18 @@ negateRR(Context* c, unsigned aSize, Assembler::Register* a,
negateR(c, aSize, a);
}
void
swapRR(Context* c, unsigned aSize UNUSED, Assembler::Register* a,
unsigned bSize UNUSED, Assembler::Register* b)
{
assert(c, aSize == bSize);
assert(c, aSize == BytesPerWord);
rex(c);
c->code.append(0x87);
c->code.append(0xc0 | (b->low << 3) | a->low);
}
void
moveRR(Context* c, unsigned aSize, Assembler::Register* a,
unsigned bSize, Assembler::Register* b)
@ -650,8 +662,17 @@ moveRR(Context* c, unsigned aSize, Assembler::Register* a,
Assembler::Register ah(a->high);
Assembler::Register bh(b->high);
moveRR(c, 4, a, 4, b);
moveRR(c, 4, &ah, 4, &bh);
if (a->high == b->low) {
if (a->low == b->high) {
swapRR(c, 4, a, 4, b);
} else {
moveRR(c, 4, &ah, 4, &bh);
moveRR(c, 4, a, 4, b);
}
} else {
moveRR(c, 4, a, 4, b);
moveRR(c, 4, &ah, 4, &bh);
}
} else {
switch (aSize) {
case 1:
@ -937,18 +958,6 @@ moveZMR(Context* c, unsigned aSize UNUSED, Assembler::Memory* a,
encode2(c, 0x0fb7, b->low, a, true);
}
void
swapRR(Context* c, unsigned aSize UNUSED, Assembler::Register* a,
unsigned bSize UNUSED, Assembler::Register* b)
{
assert(c, aSize == bSize);
assert(c, aSize == BytesPerWord);
rex(c);
c->code.append(0x87);
c->code.append(0xc0 | (b->low << 3) | a->low);
}
void
compareRR(Context* c, unsigned aSize, Assembler::Register* a,
unsigned bSize UNUSED, Assembler::Register* b)