mirror of
https://github.com/corda/corda.git
synced 2025-01-07 13:38:47 +00:00
Merge branch 'compiler' of la.merseine.nu:p/avian-compiler into compiler
This commit is contained in:
commit
392132cb0e
@ -625,9 +625,13 @@ freeRegisterSite(Context* c, uint64_t mask = ~static_cast<uint64_t>(0))
|
||||
RegisterSite*
|
||||
fixedRegisterSite(Context* c, int low, int high = NoRegister)
|
||||
{
|
||||
uint64_t mask = static_cast<uint64_t>(1) << low;
|
||||
if (high != NoRegister) {
|
||||
mask |= static_cast<uint64_t>(1) << (high + 32);
|
||||
uint64_t mask;
|
||||
if (high == NoRegister) {
|
||||
mask = (~static_cast<uint64_t>(0) << 32)
|
||||
| (static_cast<uint64_t>(1) << low);
|
||||
} else {
|
||||
mask = (static_cast<uint64_t>(1) << (high + 32))
|
||||
| (static_cast<uint64_t>(1) << low);
|
||||
}
|
||||
|
||||
return new (c->zone->allocate(sizeof(RegisterSite)))
|
||||
@ -953,8 +957,14 @@ trySteal(Context* c, Register* r, Stack* stack)
|
||||
}
|
||||
|
||||
if (start) {
|
||||
if (DebugRegisters) {
|
||||
fprintf(stderr, "push %p\n", v);
|
||||
}
|
||||
pushNow(c, start, count);
|
||||
} else {
|
||||
if (DebugRegisters) {
|
||||
fprintf(stderr, "unable to steal %d from %p\n", r->number, v);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
||||
@ -1053,6 +1063,10 @@ replace(Context* c, Stack* stack, Register* r)
|
||||
Register* s = acquire(c, mask, stack, r->size, r->value, r->site);
|
||||
thaw(r);
|
||||
|
||||
if (DebugRegisters) {
|
||||
fprintf(stderr, "replace %d with %d\n", r->number, s->number);
|
||||
}
|
||||
|
||||
swap(c, r, s);
|
||||
|
||||
return s;
|
||||
@ -1067,8 +1081,8 @@ acquire(Context* c, uint32_t mask, Stack* stack, unsigned newSize,
|
||||
if (r->reserved) return r;
|
||||
|
||||
if (DebugRegisters) {
|
||||
fprintf(stderr, "acquire %d, value %p, site %p\n",
|
||||
r->number, newValue, newSite);
|
||||
fprintf(stderr, "acquire %d, value %p, site %p freeze count %d ref count %d used %d used exclusively %d\n",
|
||||
r->number, newValue, newSite, r->freezeCount, r->refCount, used(c, r), usedExclusively(c, r));
|
||||
}
|
||||
|
||||
if (r->refCount) {
|
||||
@ -1118,6 +1132,8 @@ validate(Context* c, uint32_t mask, Stack* stack, unsigned size,
|
||||
current->value = value;
|
||||
current->site = site;
|
||||
return current;
|
||||
} else {
|
||||
abort(c);
|
||||
}
|
||||
}
|
||||
|
||||
@ -1430,21 +1446,20 @@ class MoveEvent: public Event {
|
||||
} else {
|
||||
target = targetOrRegister(c, dst);
|
||||
cost = src->source->copyCost(c, target);
|
||||
if (type != Move) {
|
||||
++ cost;
|
||||
}
|
||||
if (cost == 0) {
|
||||
target = src->source;
|
||||
}
|
||||
}
|
||||
|
||||
nextRead(c, src);
|
||||
if (target == src->source) {
|
||||
nextRead(c, src);
|
||||
}
|
||||
|
||||
if (dst->reads) {
|
||||
addSite(c, stack, size, dst, target);
|
||||
}
|
||||
|
||||
if (cost) {
|
||||
if (cost or type != Move) {
|
||||
if (match(c, target, dstTarget->typeMask, dstTarget->registerMask)) {
|
||||
apply(c, type, size, src->source, target);
|
||||
} else {
|
||||
@ -1455,15 +1470,24 @@ class MoveEvent: public Event {
|
||||
addSite(c, stack, size, dst, tmpTarget);
|
||||
|
||||
apply(c, type, size, src->source, tmpTarget);
|
||||
apply(c, Move, max(size, BytesPerWord), tmpTarget, target);
|
||||
|
||||
removeSite(c, dst, tmpTarget);
|
||||
if (dst->reads == 0) {
|
||||
removeSite(c, dst, tmpTarget);
|
||||
|
||||
apply(c, Move, size, tmpTarget, target);
|
||||
} else {
|
||||
removeSite(c, dst, target);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (dst->reads == 0) {
|
||||
removeSite(c, dst, target);
|
||||
}
|
||||
|
||||
if (target != src->source) {
|
||||
nextRead(c, src);
|
||||
}
|
||||
}
|
||||
|
||||
BinaryOperation type;
|
||||
|
11
src/x86.cpp
11
src/x86.cpp
@ -1083,7 +1083,7 @@ multiplyRR(Context* c, unsigned size, Assembler::Register* a,
|
||||
|
||||
// mul a->low,%eax%edx
|
||||
c->code.append(0xf7);
|
||||
c->code.append(0xe8 | a->low);
|
||||
c->code.append(0xe0 | a->low);
|
||||
|
||||
addRR(c, 4, b, &bh);
|
||||
moveRR(c, 4, &axdx, b);
|
||||
@ -1101,8 +1101,6 @@ void
|
||||
multiplyCR(Context* c, unsigned size, Assembler::Constant* a,
|
||||
Assembler::Register* b)
|
||||
{
|
||||
assert(c, BytesPerWord == 8 or size == 4);
|
||||
|
||||
if (BytesPerWord == 4 and size == 8) {
|
||||
const uint32_t mask = ~((1 << rax) | (1 << rdx));
|
||||
Assembler::Register tmp(c->client->acquireTemporary(mask),
|
||||
@ -1519,9 +1517,9 @@ unsignedShiftRightRR(Context* c, unsigned size, Assembler::Register* a,
|
||||
assert(c, a->low == rcx);
|
||||
|
||||
if (BytesPerWord == 4 and size == 8) {
|
||||
// shld
|
||||
// shrd
|
||||
c->code.append(0x0f);
|
||||
c->code.append(0xa5);
|
||||
c->code.append(0xad);
|
||||
c->code.append(0xc0 | (b->high << 3) | b->low);
|
||||
|
||||
// shr
|
||||
@ -1965,7 +1963,8 @@ class MyAssembler: public Assembler {
|
||||
case ShiftRight:
|
||||
case UnsignedShiftRight: {
|
||||
*aTypeMask = (1 << RegisterOperand);
|
||||
*aRegisterMask = static_cast<uint64_t>(1) << rcx;
|
||||
*aRegisterMask = (~static_cast<uint64_t>(0) << 32)
|
||||
| (static_cast<uint64_t>(1) << rcx);
|
||||
const uint32_t mask = ~(1 << rcx);
|
||||
*bRegisterMask = (static_cast<uint64_t>(mask) << 32) | mask;
|
||||
} break;
|
||||
|
@ -125,6 +125,35 @@ public class Misc {
|
||||
expect(~a == ~5);
|
||||
}
|
||||
|
||||
{ long a = -5;
|
||||
long b = 2;
|
||||
expect(a >> b == -5L >> 2);
|
||||
expect(a >>> b == -5L >>> 2);
|
||||
expect(a << b == -5L << 2);
|
||||
expect(a * b == -5L * 2L);
|
||||
expect(a / b == -5L / 2L);
|
||||
expect(a % b == -5L % 2L);
|
||||
expect((a & b) == (-5L & 2L));
|
||||
expect((a | b) == (-5L | 2L));
|
||||
expect((a ^ b) == (-5L ^ 2L));
|
||||
expect(-a == 5L);
|
||||
expect(~a == ~-5L);
|
||||
|
||||
a = 5;
|
||||
b = 2;
|
||||
expect(a >> b == 5L >> 2);
|
||||
expect(a >>> b == 5L >>> 2);
|
||||
expect(a << b == 5L << 2);
|
||||
expect(a * b == 5L * 2L);
|
||||
expect(a / b == 5L / 2L);
|
||||
expect(a % b == 5L % 2L);
|
||||
expect((a & b) == (5L & 2L));
|
||||
expect((a | b) == (5L | 2L));
|
||||
expect((a ^ b) == (5L ^ 2L));
|
||||
expect(-a == -5L);
|
||||
expect(~a == ~5L);
|
||||
}
|
||||
|
||||
byte2 = 0;
|
||||
expect(byte2 == 0);
|
||||
|
||||
@ -174,6 +203,10 @@ public class Misc {
|
||||
{ Misc m = new Misc();
|
||||
m.toString();
|
||||
|
||||
expect(m.time == 0xffffffffffffffffL);
|
||||
long t = m.time;
|
||||
expect(t == 0xffffffffffffffffL);
|
||||
|
||||
String s = "hello";
|
||||
m.foo(s);
|
||||
m.bar(s);
|
||||
|
Loading…
Reference in New Issue
Block a user