mirror of
https://github.com/corda/corda.git
synced 2025-02-10 21:01:27 +00:00
Nine tests (including float and integer calculations) are now passing.
This commit is contained in:
parent
56b59cef5c
commit
b6a839950f
107
src/arm.cpp
107
src/arm.cpp
@ -157,6 +157,7 @@ inline bool isInt24(intptr_t v) { return v == (v & 0xffffff); }
|
|||||||
inline bool isInt32(intptr_t v) { return v == static_cast<int32_t>(v); }
|
inline bool isInt32(intptr_t v) { return v == static_cast<int32_t>(v); }
|
||||||
inline int carry16(intptr_t v) { return static_cast<int16_t>(v) < 0 ? 1 : 0; }
|
inline int carry16(intptr_t v) { return static_cast<int16_t>(v) < 0 ? 1 : 0; }
|
||||||
|
|
||||||
|
inline bool isOfWidth(long long i, int size) { return static_cast<unsigned long long>(i) >> size == 0; }
|
||||||
inline bool isOfWidth(int i, int size) { return static_cast<unsigned>(i) >> size == 0; }
|
inline bool isOfWidth(int i, int size) { return static_cast<unsigned>(i) >> size == 0; }
|
||||||
|
|
||||||
const unsigned FrameFooterSize = 2;
|
const unsigned FrameFooterSize = 2;
|
||||||
@ -751,26 +752,6 @@ void addR(Context* con, unsigned size, Assembler::Register* a, Assembler::Regist
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void addC(Context* con, unsigned size, Assembler::Constant* a, Assembler::Register* b, Assembler::Register* t) {
|
|
||||||
assert(con, size == BytesPerWord);
|
|
||||||
|
|
||||||
int32_t i = getValue(a);
|
|
||||||
if (i) {
|
|
||||||
emit(con, addi(t->low, b->low, lo8(i)));
|
|
||||||
if (!isOfWidth(i, 8)) {
|
|
||||||
emit(con, addi(t->low, b->low, hi8(i), 12));
|
|
||||||
if (!isOfWidth(i, 16)) {
|
|
||||||
emit(con, addi(t->low, b->low, lo8(hi16(i)), 8));
|
|
||||||
if (!isOfWidth(i, 24)) {
|
|
||||||
emit(con, addi(t->low, b->low, hi8(hi16(i)), 4));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
moveRR(con, size, b, size, t);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void subR(Context* con, unsigned size, Assembler::Register* a, Assembler::Register* b, Assembler::Register* t) {
|
void subR(Context* con, unsigned size, Assembler::Register* a, Assembler::Register* b, Assembler::Register* t) {
|
||||||
if (size == 8) {
|
if (size == 8) {
|
||||||
emit(con, SETS(rsb(t->low, a->low, b->low)));
|
emit(con, SETS(rsb(t->low, a->low, b->low)));
|
||||||
@ -780,14 +761,6 @@ void subR(Context* con, unsigned size, Assembler::Register* a, Assembler::Regist
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void subC(Context* c, unsigned size, Assembler::Constant* a, Assembler::Register* b, Assembler::Register* t) {
|
|
||||||
assert(c, size == BytesPerWord);
|
|
||||||
|
|
||||||
ResolvedPromise promise(- a->value->value());
|
|
||||||
Assembler::Constant constant(&promise);
|
|
||||||
addC(c, size, &constant, b, t);
|
|
||||||
}
|
|
||||||
|
|
||||||
void multiplyR(Context* con, unsigned size, Assembler::Register* a, Assembler::Register* b, Assembler::Register* t) {
|
void multiplyR(Context* con, unsigned size, Assembler::Register* a, Assembler::Register* b, Assembler::Register* t) {
|
||||||
if (size == 8) {
|
if (size == 8) {
|
||||||
emit(con, mul(t->high, a->low, b->high));
|
emit(con, mul(t->high, a->low, b->high));
|
||||||
@ -835,8 +808,10 @@ normalize(Context* c, int offset, int index, unsigned scale,
|
|||||||
ResolvedPromise offsetPromise(offset);
|
ResolvedPromise offsetPromise(offset);
|
||||||
Assembler::Constant offsetConstant(&offsetPromise);
|
Assembler::Constant offsetConstant(&offsetPromise);
|
||||||
|
|
||||||
addC(c, BytesPerWord, &offsetConstant,
|
Assembler::Register tmp(c->client->acquireTemporary());
|
||||||
&untranslatedIndex, &normalizedIndex);
|
moveCR(c, BytesPerWord, &offsetConstant, BytesPerWord, &tmp);
|
||||||
|
addR(c, BytesPerWord, &tmp, &untranslatedIndex, &normalizedIndex);
|
||||||
|
c->client->releaseTemporary(tmp.low);
|
||||||
}
|
}
|
||||||
|
|
||||||
return normalizedIndex.low;
|
return normalizedIndex.low;
|
||||||
@ -1035,23 +1010,6 @@ andR(Context* c, unsigned size, Assembler::Register* a,
|
|||||||
emit(c, and_(dst->low, a->low, b->low));
|
emit(c, and_(dst->low, a->low, b->low));
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
|
||||||
andC(Context* con, unsigned size, Assembler::Constant* a,
|
|
||||||
Assembler::Register* b, Assembler::Register* dst)
|
|
||||||
{
|
|
||||||
assert(con, size == BytesPerWord);
|
|
||||||
|
|
||||||
int32_t i = getValue(a);
|
|
||||||
if (i) {
|
|
||||||
Assembler::Register tmp(con->client->acquireTemporary());
|
|
||||||
moveCR(con, size, a, size, &tmp);
|
|
||||||
andR(con, size, &tmp, b, dst);
|
|
||||||
con->client->releaseTemporary(tmp.low);
|
|
||||||
} else {
|
|
||||||
emit(con, mov(dst->low, 0));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void
|
void
|
||||||
orR(Context* c, unsigned size, Assembler::Register* a,
|
orR(Context* c, unsigned size, Assembler::Register* a,
|
||||||
Assembler::Register* b, Assembler::Register* dst)
|
Assembler::Register* b, Assembler::Register* dst)
|
||||||
@ -1060,29 +1018,6 @@ orR(Context* c, unsigned size, Assembler::Register* a,
|
|||||||
emit(c, orr(dst->low, a->low, b->low));
|
emit(c, orr(dst->low, a->low, b->low));
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
|
||||||
orC(Context* con, unsigned size, Assembler::Constant* a,
|
|
||||||
Assembler::Register* b, Assembler::Register* dst)
|
|
||||||
{
|
|
||||||
assert(con, size == BytesPerWord);
|
|
||||||
|
|
||||||
int32_t i = getValue(a);
|
|
||||||
if (i) {
|
|
||||||
emit(con, orri(dst->low, b->low, lo8(i)));
|
|
||||||
if (!isOfWidth(i, 8)) {
|
|
||||||
emit(con, orri(dst->low, b->low, hi8(i), 12));
|
|
||||||
if (!isOfWidth(i, 16)) {
|
|
||||||
emit(con, orri(dst->low, b->low, lo8(hi16(i)), 8));
|
|
||||||
if (!isOfWidth(i, 24)) {
|
|
||||||
emit(con, orri(dst->low, b->low, hi8(hi16(i)), 4));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
moveRR(con, size, b, size, dst);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void
|
void
|
||||||
xorR(Context* con, unsigned size, Assembler::Register* a,
|
xorR(Context* con, unsigned size, Assembler::Register* a,
|
||||||
Assembler::Register* b, Assembler::Register* dst)
|
Assembler::Register* b, Assembler::Register* dst)
|
||||||
@ -1091,21 +1026,6 @@ xorR(Context* con, unsigned size, Assembler::Register* a,
|
|||||||
emit(con, eor(dst->low, a->low, b->low));
|
emit(con, eor(dst->low, a->low, b->low));
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
|
||||||
xorC(Context* con, unsigned size, Assembler::Constant* a,
|
|
||||||
Assembler::Register* b, Assembler::Register* dst)
|
|
||||||
{
|
|
||||||
assert(con, size == BytesPerWord);
|
|
||||||
|
|
||||||
int32_t i = getValue(a);
|
|
||||||
if (i) {
|
|
||||||
Assembler::Register tmp(con->client->acquireTemporary());
|
|
||||||
moveCR(con, size, a, size, &tmp);
|
|
||||||
xorR(con, size, &tmp, b, dst);
|
|
||||||
con->client->releaseTemporary(tmp.low);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void
|
void
|
||||||
moveAR2(Context* c, unsigned srcSize, Assembler::Address* src,
|
moveAR2(Context* c, unsigned srcSize, Assembler::Address* src,
|
||||||
unsigned dstSize, Assembler::Register* dst, unsigned promiseOffset)
|
unsigned dstSize, Assembler::Register* dst, unsigned promiseOffset)
|
||||||
@ -1143,7 +1063,7 @@ compareCR(Context* c, unsigned aSize, Assembler::Constant* a,
|
|||||||
{
|
{
|
||||||
assert(c, aSize == 4 and bSize == 4);
|
assert(c, aSize == 4 and bSize == 4);
|
||||||
|
|
||||||
if (a->value->resolved() and isInt16(a->value->value())) {
|
if (a->value->resolved() and isOfWidth(a->value->value(), 8)) {
|
||||||
emit(c, cmpi(b->low, a->value->value()));
|
emit(c, cmpi(b->low, a->value->value()));
|
||||||
} else {
|
} else {
|
||||||
Assembler::Register tmp(c->client->acquireTemporary());
|
Assembler::Register tmp(c->client->acquireTemporary());
|
||||||
@ -1538,10 +1458,8 @@ populateTables(ArchitectureContext* c)
|
|||||||
bo[index(c, Negate, R, R)] = CAST2(negateRR);
|
bo[index(c, Negate, R, R)] = CAST2(negateRR);
|
||||||
|
|
||||||
to[index(c, Add, R)] = CAST3(addR);
|
to[index(c, Add, R)] = CAST3(addR);
|
||||||
to[index(c, Add, C)] = CAST3(addC);
|
|
||||||
|
|
||||||
to[index(c, Subtract, R)] = CAST3(subR);
|
to[index(c, Subtract, R)] = CAST3(subR);
|
||||||
to[index(c, Subtract, C)] = CAST3(subC);
|
|
||||||
|
|
||||||
to[index(c, Multiply, R)] = CAST3(multiplyR);
|
to[index(c, Multiply, R)] = CAST3(multiplyR);
|
||||||
|
|
||||||
@ -1554,13 +1472,10 @@ populateTables(ArchitectureContext* c)
|
|||||||
to[index(c, UnsignedShiftRight, R)] = CAST3(unsignedShiftRightR);
|
to[index(c, UnsignedShiftRight, R)] = CAST3(unsignedShiftRightR);
|
||||||
to[index(c, UnsignedShiftRight, C)] = CAST3(unsignedShiftRightC);
|
to[index(c, UnsignedShiftRight, C)] = CAST3(unsignedShiftRightC);
|
||||||
|
|
||||||
to[index(c, And, C)] = CAST3(andC);
|
|
||||||
to[index(c, And, R)] = CAST3(andR);
|
to[index(c, And, R)] = CAST3(andR);
|
||||||
|
|
||||||
to[index(c, Or, C)] = CAST3(orC);
|
|
||||||
to[index(c, Or, R)] = CAST3(orR);
|
to[index(c, Or, R)] = CAST3(orR);
|
||||||
|
|
||||||
to[index(c, Xor, C)] = CAST3(xorC);
|
|
||||||
to[index(c, Xor, R)] = CAST3(xorR);
|
to[index(c, Xor, R)] = CAST3(xorR);
|
||||||
|
|
||||||
bro[branchIndex(c, R, R)] = CAST_BRANCH(branchRR);
|
bro[branchIndex(c, R, R)] = CAST_BRANCH(branchRR);
|
||||||
@ -1830,7 +1745,7 @@ class MyArchitecture: public Assembler::Architecture {
|
|||||||
|
|
||||||
virtual void planSource
|
virtual void planSource
|
||||||
(TernaryOperation op,
|
(TernaryOperation op,
|
||||||
unsigned aSize, uint8_t* aTypeMask, uint64_t* aRegisterMask,
|
unsigned aSize UNUSED, uint8_t* aTypeMask, uint64_t* aRegisterMask,
|
||||||
unsigned, uint8_t* bTypeMask, uint64_t* bRegisterMask,
|
unsigned, uint8_t* bTypeMask, uint64_t* bRegisterMask,
|
||||||
unsigned, bool* thunk)
|
unsigned, bool* thunk)
|
||||||
{
|
{
|
||||||
@ -1845,11 +1760,9 @@ class MyArchitecture: public Assembler::Architecture {
|
|||||||
switch (op) {
|
switch (op) {
|
||||||
case Add:
|
case Add:
|
||||||
case Subtract:
|
case Subtract:
|
||||||
if (aSize == 8) {
|
case And:
|
||||||
*aTypeMask = *bTypeMask = (1 << RegisterOperand);
|
case Or:
|
||||||
}
|
case Xor:
|
||||||
break;
|
|
||||||
|
|
||||||
case Multiply:
|
case Multiply:
|
||||||
*aTypeMask = *bTypeMask = (1 << RegisterOperand);
|
*aTypeMask = *bTypeMask = (1 << RegisterOperand);
|
||||||
break;
|
break;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user