From 4858972dbc6f7cced7210531a4a9004ebf213d07 Mon Sep 17 00:00:00 2001 From: Joel Dice Date: Sun, 18 May 2008 09:43:31 -0600 Subject: [PATCH] support 64-bit subtracts on 32-bit systems; allow constant shift counts in MyAssembler::plan --- src/x86.cpp | 27 ++++++++++++++++++++++----- 1 file changed, 22 insertions(+), 5 deletions(-) diff --git a/src/x86.cpp b/src/x86.cpp index 343c287288..c6dccfdd09 100644 --- a/src/x86.cpp +++ b/src/x86.cpp @@ -1012,15 +1012,32 @@ subtractCR(Context* c, unsigned size, Assembler::Constant* a, } } +void +subtractBorrowRR(Context* c, unsigned size UNUSED, Assembler::Register* a, + Assembler::Register* b) +{ + assert(c, BytesPerWord == 8 or size == 4); + + if (size == 8) rex(c); + c->code.append(0x19); + c->code.append(0xc0 | (a->low << 3) | b->low); +} + void subtractRR(Context* c, unsigned size, Assembler::Register* a, Assembler::Register* b) { - assert(c, BytesPerWord == 8 or size == 4); // todo + if (BytesPerWord == 4 and size == 8) { + Assembler::Register ah(a->high); + Assembler::Register bh(b->high); - if (size == 8) rex(c); - c->code.append(0x29); - c->code.append(0xc0 | (a->low << 3) | b->low); + subtractRR(c, 4, a, b); + subtractBorrowRR(c, 4, &ah, &bh); + } else { + if (size == 8) rex(c); + c->code.append(0x29); + c->code.append(0xc0 | (a->low << 3) | b->low); + } } void @@ -1962,7 +1979,7 @@ class MyAssembler: public Assembler { case ShiftLeft: case ShiftRight: case UnsignedShiftRight: { - *aTypeMask = (1 << RegisterOperand); + *aTypeMask = (1 << RegisterOperand) | (1 << ConstantOperand); *aRegisterMask = (~static_cast(0) << 32) | (static_cast(1) << rcx); const uint32_t mask = ~(1 << rcx);