more bugfixes

This commit is contained in:
Joel Dice 2008-09-23 18:01:42 -06:00
parent d4938115ef
commit f2bf152eba
3 changed files with 115 additions and 89 deletions

View File

@ -1856,7 +1856,7 @@ compile(MyThread* t, Frame* initialFrame, unsigned ip, bool exceptionHandler)
int index = 0; int index = 0;
if ((methodFlags(t, context->method) & ACC_STATIC) == 0) { if ((methodFlags(t, context->method) & ACC_STATIC) == 0) {
c->initParameter(1, index++); c->initParameter(BytesPerWord, index++);
} }
for (MethodSpecIterator it for (MethodSpecIterator it
@ -1867,12 +1867,12 @@ compile(MyThread* t, Frame* initialFrame, unsigned ip, bool exceptionHandler)
switch (*it.next()) { switch (*it.next()) {
case 'J': case 'J':
case 'D': case 'D':
c->initParameter(2, index); c->initParameter(2 * BytesPerWord, index);
index += 2; index += 2;
break; break;
default: default:
c->initParameter(1, index++); c->initParameter(BytesPerWord, index++);
break; break;
} }
} }

View File

@ -67,6 +67,12 @@ class Cell {
void* value; void* value;
}; };
class Local {
public:
Value* value;
unsigned size;
};
class Site { class Site {
public: public:
Site(): next(0) { } Site(): next(0) { }
@ -79,7 +85,7 @@ class Site {
virtual bool match(Context*, uint8_t, uint64_t, int) = 0; virtual bool match(Context*, uint8_t, uint64_t, int) = 0;
virtual void acquire(Context*, Stack*, Value**, unsigned, Value*) { } virtual void acquire(Context*, Stack*, Local*, unsigned, Value*) { }
virtual void release(Context*) { } virtual void release(Context*) { }
@ -115,7 +121,7 @@ class MultiReadPair {
class MyState: public Compiler::State { class MyState: public Compiler::State {
public: public:
MyState(Stack* stack, Value** locals, Event* predecessor, MyState(Stack* stack, Local* locals, Event* predecessor,
unsigned logicalIp): unsigned logicalIp):
stack(stack), stack(stack),
locals(locals), locals(locals),
@ -125,7 +131,7 @@ class MyState: public Compiler::State {
{ } { }
Stack* stack; Stack* stack;
Value** locals; Local* locals;
Event* predecessor; Event* predecessor;
unsigned logicalIp; unsigned logicalIp;
unsigned readCount; unsigned readCount;
@ -134,7 +140,7 @@ class MyState: public Compiler::State {
class LogicalInstruction { class LogicalInstruction {
public: public:
LogicalInstruction(int index, Stack* stack, Value** locals): LogicalInstruction(int index, Stack* stack, Local* locals):
firstEvent(0), lastEvent(0), immediatePredecessor(0), stack(stack), firstEvent(0), lastEvent(0), immediatePredecessor(0), stack(stack),
locals(locals), machineOffset(0), index(index) locals(locals), machineOffset(0), index(index)
{ } { }
@ -143,7 +149,7 @@ class LogicalInstruction {
Event* lastEvent; Event* lastEvent;
LogicalInstruction* immediatePredecessor; LogicalInstruction* immediatePredecessor;
Stack* stack; Stack* stack;
Value** locals; Local* locals;
Promise* machineOffset; Promise* machineOffset;
int index; int index;
}; };
@ -175,8 +181,8 @@ class ConstantPoolNode {
class Read { class Read {
public: public:
Read(): Read(unsigned size):
value(0), event(0), eventNext(0) value(0), event(0), eventNext(0), size(size)
{ } { }
virtual ~Read() { } virtual ~Read() { }
@ -190,8 +196,6 @@ class Read {
virtual bool valid() = 0; virtual bool valid() = 0;
virtual unsigned size(Context* c) = 0;
virtual void append(Context* c, Read* r) = 0; virtual void append(Context* c, Read* r) = 0;
virtual Read* next(Context* c) = 0; virtual Read* next(Context* c) = 0;
@ -199,6 +203,7 @@ class Read {
Value* value; Value* value;
Event* event; Event* event;
Read* eventNext; Read* eventNext;
unsigned size;
}; };
int int
@ -280,7 +285,7 @@ class Context {
Zone* zone; Zone* zone;
Compiler::Client* client; Compiler::Client* client;
Stack* stack; Stack* stack;
Value** locals; Local* locals;
Event* predecessor; Event* predecessor;
LogicalInstruction** logicalCode; LogicalInstruction** logicalCode;
Register** registers; Register** registers;
@ -483,7 +488,7 @@ class Event {
Event* next; Event* next;
Stack* stack; Stack* stack;
Value** locals; Local* locals;
CodePromise* promises; CodePromise* promises;
Read* reads; Read* reads;
Site** junctionSites; Site** junctionSites;
@ -538,7 +543,7 @@ findSite(Context*, Value* v, Site* site)
} }
void void
addSite(Context* c, Stack* stack, Value** locals, unsigned size, Value* v, addSite(Context* c, Stack* stack, Local* locals, unsigned size, Value* v,
Site* s) Site* s)
{ {
if (not findSite(c, v, s)) { if (not findSite(c, v, s)) {
@ -703,14 +708,14 @@ thaw(Register* r)
} }
Register* Register*
acquire(Context* c, uint32_t mask, Stack* stack, Value** locals, acquire(Context* c, uint32_t mask, Stack* stack, Local* locals,
unsigned newSize, Value* newValue, RegisterSite* newSite); unsigned newSize, Value* newValue, RegisterSite* newSite);
void void
release(Context* c, Register* r); release(Context* c, Register* r);
Register* Register*
validate(Context* c, uint32_t mask, Stack* stack, Value** locals, validate(Context* c, uint32_t mask, Stack* stack, Local* locals,
unsigned size, Value* value, RegisterSite* site, Register* current); unsigned size, Value* value, RegisterSite* site, Register* current);
class RegisterSite: public Site { class RegisterSite: public Site {
@ -757,7 +762,7 @@ class RegisterSite: public Site {
} }
} }
virtual void acquire(Context* c, Stack* stack, Value** locals, unsigned size, virtual void acquire(Context* c, Stack* stack, Local* locals, unsigned size,
Value* v) Value* v)
{ {
low = ::validate(c, mask, stack, locals, size, v, this, low); low = ::validate(c, mask, stack, locals, size, v, this, low);
@ -907,7 +912,7 @@ class MemorySite: public Site {
} }
} }
virtual void acquire(Context* c, Stack*, Value**, unsigned, Value*) { virtual void acquire(Context* c, Stack*, Local*, unsigned, Value*) {
base = increment(c, value.base); base = increment(c, value.base);
if (value.index != NoRegister) { if (value.index != NoRegister) {
index = increment(c, value.index); index = increment(c, value.index);
@ -1003,7 +1008,7 @@ allocateSite(Context* c, uint8_t typeMask, uint64_t registerMask,
} else if (frameIndex >= 0) { } else if (frameIndex >= 0) {
return frameSite(c, frameIndex); return frameSite(c, frameIndex);
} else { } else {
abort(c); return 0;
} }
} }
@ -1011,7 +1016,7 @@ class SingleRead: public Read {
public: public:
SingleRead(unsigned size, uint8_t typeMask, uint64_t registerMask, SingleRead(unsigned size, uint8_t typeMask, uint64_t registerMask,
int frameIndex): int frameIndex):
next_(0), size_(size), typeMask(typeMask), registerMask(registerMask), Read(size), next_(0), typeMask(typeMask), registerMask(registerMask),
frameIndex(frameIndex) frameIndex(frameIndex)
{ } { }
@ -1036,10 +1041,6 @@ class SingleRead: public Read {
return true; return true;
} }
virtual unsigned size(Context*) {
return size_;
}
virtual void append(Context* c, Read* r) { virtual void append(Context* c, Read* r) {
assert(c, next_ == 0); assert(c, next_ == 0);
next_ = r; next_ = r;
@ -1050,7 +1051,6 @@ class SingleRead: public Read {
} }
Read* next_; Read* next_;
unsigned size_;
uint8_t typeMask; uint8_t typeMask;
uint64_t registerMask; uint64_t registerMask;
int frameIndex; int frameIndex;
@ -1095,8 +1095,9 @@ fixedRegisterRead(Context* c, unsigned size, int low, int high = NoRegister)
class MultiRead: public Read { class MultiRead: public Read {
public: public:
MultiRead(): MultiRead(unsigned size):
reads(0), lastRead(0), firstTarget(0), lastTarget(0), visited(false) Read(size), reads(0), lastRead(0), firstTarget(0), lastTarget(0),
visited(false)
{ } { }
virtual Site* pickSite(Context* c, Value* value) { virtual Site* pickSite(Context* c, Value* value) {
@ -1156,10 +1157,6 @@ class MultiRead: public Read {
return result; return result;
} }
virtual unsigned size(Context* c) {
return static_cast<Read*>(reads->value)->size(c);
}
virtual void append(Context* c, Read* r) { virtual void append(Context* c, Read* r) {
Cell* cell = cons(c, r, 0); Cell* cell = cons(c, r, 0);
if (lastRead == 0) { if (lastRead == 0) {
@ -1200,15 +1197,15 @@ class MultiRead: public Read {
}; };
MultiRead* MultiRead*
multiRead(Context* c) multiRead(Context* c, unsigned size)
{ {
return new (c->zone->allocate(sizeof(MultiRead))) MultiRead(); return new (c->zone->allocate(sizeof(MultiRead))) MultiRead(size);
} }
class StubRead: public Read { class StubRead: public Read {
public: public:
StubRead(): StubRead(unsigned size):
read(0), visited(false) Read(size), read(0), visited(false)
{ } { }
virtual Site* pickSite(Context* c, Value* value) { virtual Site* pickSite(Context* c, Value* value) {
@ -1249,10 +1246,6 @@ class StubRead: public Read {
return true; return true;
} }
virtual unsigned size(Context* c) {
return read->size(c);
}
virtual void append(Context*, Read* r) { virtual void append(Context*, Read* r) {
read = r; read = r;
} }
@ -1266,9 +1259,9 @@ class StubRead: public Read {
}; };
StubRead* StubRead*
stubRead(Context* c) stubRead(Context* c, unsigned size)
{ {
return new (c->zone->allocate(sizeof(StubRead))) StubRead(); return new (c->zone->allocate(sizeof(StubRead))) StubRead(size);
} }
Site* Site*
@ -1300,7 +1293,7 @@ pick(Context* c, Site* sites, Site* target = 0, unsigned* cost = 0)
} }
bool bool
trySteal(Context* c, Register* r, Stack* stack, Value** locals) trySteal(Context* c, Register* r, Stack* stack, Local* locals)
{ {
assert(c, r->refCount == 0); assert(c, r->refCount == 0);
@ -1315,7 +1308,7 @@ trySteal(Context* c, Register* r, Stack* stack, Value** locals)
if (v->sites->next == 0) { if (v->sites->next == 0) {
Site* saveSite = 0; Site* saveSite = 0;
for (unsigned i = 0; i < c->localFootprint; ++i) { for (unsigned i = 0; i < c->localFootprint; ++i) {
if (locals[i] == v) { if (locals[i].value == v) {
saveSite = frameSite(c, i); saveSite = frameSite(c, i);
break; break;
} }
@ -1340,8 +1333,8 @@ trySteal(Context* c, Register* r, Stack* stack, Value** locals)
} }
if (saveSite) { if (saveSite) {
apply(c, Move, r->size, r->site, r->size, saveSite);
addSite(c, 0, 0, r->size, v, saveSite); addSite(c, 0, 0, r->size, v, saveSite);
apply(c, Move, r->size, r->site, r->size, saveSite);
} else { } else {
if (DebugRegisters) { if (DebugRegisters) {
fprintf(stderr, "unable to steal %d from %p\n", r->number, v); fprintf(stderr, "unable to steal %d from %p\n", r->number, v);
@ -1437,7 +1430,7 @@ swap(Context* c, Register* a, Register* b)
} }
Register* Register*
replace(Context* c, Stack* stack, Value** locals, Register* r) replace(Context* c, Stack* stack, Local* locals, Register* r)
{ {
uint32_t mask = (r->freezeCount? r->site->mask : ~0); uint32_t mask = (r->freezeCount? r->site->mask : ~0);
@ -1455,7 +1448,7 @@ replace(Context* c, Stack* stack, Value** locals, Register* r)
} }
Register* Register*
acquire(Context* c, uint32_t mask, Stack* stack, Value** locals, acquire(Context* c, uint32_t mask, Stack* stack, Local* locals,
unsigned newSize, Value* newValue, RegisterSite* newSite) unsigned newSize, Value* newValue, RegisterSite* newSite)
{ {
Register* r = pickRegister(c, mask); Register* r = pickRegister(c, mask);
@ -1503,7 +1496,7 @@ release(Context*, Register* r)
} }
Register* Register*
validate(Context* c, uint32_t mask, Stack* stack, Value** locals, validate(Context* c, uint32_t mask, Stack* stack, Local* locals,
unsigned size, Value* value, RegisterSite* site, Register* current) unsigned size, Value* value, RegisterSite* site, Register* current)
{ {
if (current and (mask & (1 << current->number))) { if (current and (mask & (1 << current->number))) {
@ -1615,10 +1608,10 @@ clean(Context* c, Value* v)
} }
void void
clean(Context* c, Stack* stack, Value** locals, Read* reads) clean(Context* c, Stack* stack, Local* locals, Read* reads)
{ {
for (unsigned i = 0; i < c->localFootprint; ++i) { for (unsigned i = 0; i < c->localFootprint; ++i) {
if (locals[i]) clean(c, locals[i]); if (locals[i].value) clean(c, locals[i].value);
} }
for (Stack* s = stack; s; s = s->next) { for (Stack* s = stack; s; s = s->next) {
@ -1951,7 +1944,7 @@ appendCompare(Context* c, unsigned size, Value* first, Value* second)
} }
void void
preserve(Context* c, Stack* stack, Value** locals, unsigned size, Value* v, preserve(Context* c, Stack* stack, Local* locals, unsigned size, Value* v,
Site* s, Read* read) Site* s, Read* read)
{ {
assert(c, v->sites == s); assert(c, v->sites == s);
@ -1962,7 +1955,7 @@ preserve(Context* c, Stack* stack, Value** locals, unsigned size, Value* v,
} }
void void
maybePreserve(Context* c, Stack* stack, Value** locals, unsigned size, maybePreserve(Context* c, Stack* stack, Local* locals, unsigned size,
Value* v, Site* s) Value* v, Site* s)
{ {
if (valid(v->reads->next(c)) and v->sites->next == 0) { if (valid(v->reads->next(c)) and v->sites->next == 0) {
@ -2455,7 +2448,7 @@ appendDummy(Context* c)
} }
Site* Site*
readSource(Context* c, Stack* stack, Value** locals, Read* r) readSource(Context* c, Stack* stack, Local* locals, Read* r)
{ {
if (r->value->sites == 0) { if (r->value->sites == 0) {
return 0; return 0;
@ -2471,8 +2464,8 @@ readSource(Context* c, Stack* stack, Value** locals, Read* r)
site = pick(c, r->value->sites, target, &copyCost); site = pick(c, r->value->sites, target, &copyCost);
assert(c, copyCost); assert(c, copyCost);
addSite(c, stack, locals, r->size(c), r->value, target); addSite(c, stack, locals, r->size, r->value, target);
apply(c, Move, r->size(c), site, r->size(c), target); apply(c, Move, r->size, site, r->size, target);
return target; return target;
} }
} }
@ -2482,7 +2475,9 @@ pickJunctionSite(Context* c, Value* v, Read* r)
{ {
Site* s = r->pickSite(c, v); Site* s = r->pickSite(c, v);
if (s) return s; if (s) return s;
return r->allocateSite(c); s = r->allocateSite(c);
if (s) return s;
return freeRegisterSite(c, ~0);
} }
unsigned unsigned
@ -2510,8 +2505,8 @@ resolveJunctionSite(Context* c, Event* e, Event* successor, Value* v,
unsigned copyCost; unsigned copyCost;
Site* site = pick(c, v->sites, target, &copyCost); Site* site = pick(c, v->sites, target, &copyCost);
if (copyCost) { if (copyCost) {
addSite(c, successor->stack, successor->locals, r->size(c), v, target); addSite(c, successor->stack, successor->locals, r->size, v, target);
apply(c, Move, r->size(c), site, r->size(c), target); apply(c, Move, r->size, site, r->size, target);
} }
if (original == 0) { if (original == 0) {
@ -2573,9 +2568,9 @@ populateSiteTables(Context* c, Event* e)
if (e->junctionSites) { if (e->junctionSites) {
for (unsigned i = 0; i < c->localFootprint; ++i) { for (unsigned i = 0; i < c->localFootprint; ++i) {
if (successor->locals[i]) { if (successor->locals[i].value) {
frozenSiteIndex = resolveJunctionSite frozenSiteIndex = resolveJunctionSite
(c, e, successor, successor->locals[i], i, frozenSites, (c, e, successor, successor->locals[i].value, i, frozenSites,
frozenSiteIndex); frozenSiteIndex);
} }
} }
@ -2602,8 +2597,8 @@ populateSiteTables(Context* c, Event* e)
memset(savedSites, 0, size); memset(savedSites, 0, size);
for (unsigned i = 0; i < c->localFootprint; ++i) { for (unsigned i = 0; i < c->localFootprint; ++i) {
if (successor->locals[i]) { if (successor->locals[i].value) {
savedSites[i] = successor->locals[i]->sites; savedSites[i] = successor->locals[i].value->sites;
} }
} }
@ -2626,11 +2621,11 @@ void
setSites(Context* c, Event* e, Site** sites) setSites(Context* c, Event* e, Site** sites)
{ {
for (unsigned i = 0; i < c->localFootprint; ++i) { for (unsigned i = 0; i < c->localFootprint; ++i) {
Value* v = e->locals[i]; Value* v = e->locals[i].value;
if (v) { if (v) {
clearSites(c, v); clearSites(c, v);
if (live(v)) { if (live(v)) {
addSite(c, 0, 0, v->reads->size(c), v, sites[i]); addSite(c, 0, 0, v->reads->size, v, sites[i]);
} }
} }
} }
@ -2641,7 +2636,7 @@ setSites(Context* c, Event* e, Site** sites)
Value* v = stack->value; Value* v = stack->value;
clearSites(c, v); clearSites(c, v);
if (live(v)) { if (live(v)) {
addSite(c, 0, 0, v->reads->size(c), v, sites[i]); addSite(c, 0, 0, v->reads->size, v, sites[i]);
} }
i -= stack->size; i -= stack->size;
} }
@ -2669,7 +2664,7 @@ populateSources(Context* c, Event* e)
} }
void void
addStubRead(Context* c, Value* v, StubReadPair** reads) addStubRead(Context* c, Value* v, unsigned size, StubReadPair** reads)
{ {
if (v) { if (v) {
StubRead* r; StubRead* r;
@ -2678,7 +2673,7 @@ addStubRead(Context* c, Value* v, StubReadPair** reads)
} else { } else {
v->visited = true; v->visited = true;
r = stubRead(c); r = stubRead(c, size);
addRead(c, 0, v, r); addRead(c, 0, v, r);
} }
@ -2697,11 +2692,12 @@ populateJunctionReads(Context* c, Event* e)
e->junctionReads = reads; e->junctionReads = reads;
for (unsigned i = 0; i < c->localFootprint; ++i) { for (unsigned i = 0; i < c->localFootprint; ++i) {
addStubRead(c, c->locals[i], &reads); Local* local = c->locals + i;
addStubRead(c, local->value, local->size, &reads);
} }
for (Stack* s = c->stack; s; s = s->next) { for (Stack* s = c->stack; s; s = s->next) {
addStubRead(c, s->value, &reads); addStubRead(c, s->value, s->size * BytesPerWord, &reads);
} }
for (StubReadPair* r = e->junctionReads; r < reads; ++r) { for (StubReadPair* r = e->junctionReads; r < reads; ++r) {
@ -2721,8 +2717,8 @@ updateJunctionReads(Context* c, Event* e, Event* successor)
StubReadPair* reads = e->junctionReads; StubReadPair* reads = e->junctionReads;
for (unsigned i = 0; i < c->localFootprint; ++i) { for (unsigned i = 0; i < c->localFootprint; ++i) {
if (successor->locals[i]) { if (successor->locals[i].value) {
updateStubRead(c, reads++, successor->locals[i]->reads); updateStubRead(c, reads++, successor->locals[i].value->reads);
} }
} }
@ -2867,12 +2863,13 @@ allocateTargets(Context* c, MyState* state)
} }
void void
addMultiRead(Context* c, Value* v, MyState* state, unsigned* count) addMultiRead(Context* c, Value* v, unsigned size, MyState* state,
unsigned* count)
{ {
if (v and not v->visited) { if (v and not v->visited) {
v->visited = true; v->visited = true;
MultiRead* r = multiRead(c); MultiRead* r = multiRead(c, size);
addRead(c, 0, v, r); addRead(c, 0, v, r);
MultiReadPair* p = state->reads + ((*count)++); MultiReadPair* p = state->reads + ((*count)++);
@ -2895,11 +2892,14 @@ saveState(Context* c)
unsigned count = 0; unsigned count = 0;
for (unsigned i = 0; i < c->localFootprint; ++i) { for (unsigned i = 0; i < c->localFootprint; ++i) {
addMultiRead(c, c->locals[i], state, &count); if (c->locals[i].value) {
Local* local = c->locals + i;
addMultiRead(c, local->value, local->size, state, &count);
}
} }
for (Stack* s = c->stack; s; s = s->next) { for (Stack* s = c->stack; s; s = s->next) {
addMultiRead(c, s->value, state, &count); addMultiRead(c, s->value, s->size * BytesPerWord, state, &count);
} }
for (unsigned i = 0; i < count; ++i) { for (unsigned i = 0; i < count; ++i) {
@ -2990,10 +2990,10 @@ class MyCompiler: public Compiler {
(c.zone->allocate(sizeof(LogicalInstruction*) * logicalCodeLength)); (c.zone->allocate(sizeof(LogicalInstruction*) * logicalCodeLength));
memset(c.logicalCode, 0, sizeof(LogicalInstruction*) * logicalCodeLength); memset(c.logicalCode, 0, sizeof(LogicalInstruction*) * logicalCodeLength);
c.locals = static_cast<Value**> c.locals = static_cast<Local*>
(c.zone->allocate(sizeof(Value*) * localFootprint)); (c.zone->allocate(sizeof(Local) * localFootprint));
memset(c.locals, 0, sizeof(Value*) * localFootprint); memset(c.locals, 0, sizeof(Local) * localFootprint);
} }
virtual void visitLogicalIp(unsigned logicalIp) { virtual void visitLogicalIp(unsigned logicalIp) {
@ -3210,28 +3210,39 @@ class MyCompiler: public Compiler {
virtual void initParameter(unsigned size, unsigned index) { virtual void initParameter(unsigned size, unsigned index) {
assert(&c, index < c.parameterFootprint); assert(&c, index < c.parameterFootprint);
fprintf(stderr, "init parameter %d size %d\n", index, size); //fprintf(stderr, "init parameter of size %d at %d\n", size, index);
Value* v = value(&c); Value* v = value(&c);
appendParameter(&c, v, size, index); appendParameter(&c, v, size, index);
c.locals[index] = v;
Local* local = c.locals + index;
local->value = v;
local->size = size;
} }
virtual void storeLocal(unsigned, Operand* src, unsigned index) { virtual void storeLocal(unsigned size, Operand* src, unsigned index) {
//fprintf(stderr, "store local of size %d at %d\n", size, index);
assert(&c, index < c.localFootprint); assert(&c, index < c.localFootprint);
unsigned size = sizeof(Value*) * c.localFootprint; unsigned footprint = sizeof(Local) * c.localFootprint;
Value** newLocals = static_cast<Value**>(c.zone->allocate(size)); Local* newLocals = static_cast<Local*>(c.zone->allocate(footprint));
memcpy(newLocals, c.locals, size); memcpy(newLocals, c.locals, footprint);
c.locals = newLocals; c.locals = newLocals;
c.locals[index] = static_cast<Value*>(src); Local* local = c.locals + index;
local->value = static_cast<Value*>(src);
local->size = size;
} }
virtual Operand* loadLocal(unsigned, unsigned index) { virtual Operand* loadLocal(unsigned size UNUSED, unsigned index) {
assert(&c, index < c.localFootprint); //fprintf(stderr, "load local of size %d at %d\n", size, index);
assert(&c, c.locals[index]);
return c.locals[index]; assert(&c, index < c.localFootprint);
assert(&c, c.locals[index].value);
assert(&c, pad(c.locals[index].size) == pad(size));
return c.locals[index].value;
} }
virtual void checkBounds(Operand* object, unsigned lengthOffset, virtual void checkBounds(Operand* object, unsigned lengthOffset,

View File

@ -867,6 +867,18 @@ moveCM(Context* c, unsigned aSize UNUSED, Assembler::Constant* 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 void
compareRR(Context* c, unsigned aSize, Assembler::Register* a, compareRR(Context* c, unsigned aSize, Assembler::Register* a,
unsigned bSize UNUSED, Assembler::Register* b) unsigned bSize UNUSED, Assembler::Register* b)
@ -1224,9 +1236,12 @@ populateTables(ArchitectureContext* c)
bo[index(Move, A, R)] = CAST2(moveAR); bo[index(Move, A, R)] = CAST2(moveAR);
bo[index(Move, M, M)] = CAST2(moveMM); bo[index(Move, M, M)] = CAST2(moveMM);
bo[index(Swap, R, R)] = CAST2(swapRR);
bo[index(Compare, R, R)] = CAST2(compareRR); bo[index(Compare, R, R)] = CAST2(compareRR);
bo[index(Compare, C, R)] = CAST2(compareCR); bo[index(Compare, C, R)] = CAST2(compareCR);
bo[index(Add, R, R)] = CAST2(addRR);
bo[index(Add, C, R)] = CAST2(addCR); bo[index(Add, C, R)] = CAST2(addCR);
bo[index(Subtract, C, R)] = CAST2(subtractCR); bo[index(Subtract, C, R)] = CAST2(subtractCR);