mirror of
https://github.com/corda/corda.git
synced 2025-01-05 20:54:13 +00:00
remove static references to TargetBytesPerWord in Compiler
This commit is contained in:
parent
1fb6a0bceb
commit
05d80aee8b
@ -11,6 +11,8 @@
|
|||||||
#ifndef AVIAN_CODEGEN_ARCHITECTURE_H
|
#ifndef AVIAN_CODEGEN_ARCHITECTURE_H
|
||||||
#define AVIAN_CODEGEN_ARCHITECTURE_H
|
#define AVIAN_CODEGEN_ARCHITECTURE_H
|
||||||
|
|
||||||
|
#include "ir.h"
|
||||||
|
|
||||||
namespace vm {
|
namespace vm {
|
||||||
class Zone;
|
class Zone;
|
||||||
}
|
}
|
||||||
@ -57,6 +59,8 @@ virtual int returnHigh() = 0;
|
|||||||
virtual int virtualCallTarget() = 0;
|
virtual int virtualCallTarget() = 0;
|
||||||
virtual int virtualCallIndex() = 0;
|
virtual int virtualCallIndex() = 0;
|
||||||
|
|
||||||
|
virtual ir::TargetInfo targetInfo() = 0;
|
||||||
|
|
||||||
virtual bool bigEndian() = 0;
|
virtual bool bigEndian() = 0;
|
||||||
|
|
||||||
virtual uintptr_t maximumImmediateJump() = 0;
|
virtual uintptr_t maximumImmediateJump() = 0;
|
||||||
|
@ -19,7 +19,7 @@ class TargetInfo {
|
|||||||
public:
|
public:
|
||||||
unsigned pointerSize;
|
unsigned pointerSize;
|
||||||
|
|
||||||
TargetInfo(unsigned pointerSize) : pointerSize(pointerSize)
|
explicit TargetInfo(unsigned pointerSize) : pointerSize(pointerSize)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
@ -2281,7 +2281,7 @@ class MyCompiler: public Compiler {
|
|||||||
static_cast<Value*>(base),
|
static_cast<Value*>(base),
|
||||||
displacement,
|
displacement,
|
||||||
static_cast<Value*>(index),
|
static_cast<Value*>(index),
|
||||||
index == 0 ? 1 : type.size(TargetBytesPerWord),
|
index == 0 ? 1 : type.size(c.targetInfo),
|
||||||
result);
|
result);
|
||||||
|
|
||||||
return result;
|
return result;
|
||||||
@ -2585,10 +2585,10 @@ class MyCompiler: public Compiler {
|
|||||||
Value* dst = value(&c, type);
|
Value* dst = value(&c, type);
|
||||||
appendMove(&c,
|
appendMove(&c,
|
||||||
lir::Move,
|
lir::Move,
|
||||||
src->type.size(TargetBytesPerWord),
|
src->type.size(c.targetInfo),
|
||||||
src->type.size(TargetBytesPerWord),
|
src->type.size(c.targetInfo),
|
||||||
static_cast<Value*>(src),
|
static_cast<Value*>(src),
|
||||||
type.size(TargetBytesPerWord),
|
type.size(c.targetInfo),
|
||||||
dst);
|
dst);
|
||||||
return dst;
|
return dst;
|
||||||
}
|
}
|
||||||
@ -2602,11 +2602,11 @@ class MyCompiler: public Compiler {
|
|||||||
appendMove(&c,
|
appendMove(&c,
|
||||||
signExtend == ir::SignExtend ? lir::Move : lir::MoveZ,
|
signExtend == ir::SignExtend ? lir::Move : lir::MoveZ,
|
||||||
TargetBytesPerWord,
|
TargetBytesPerWord,
|
||||||
truncateType.size(TargetBytesPerWord),
|
truncateType.size(c.targetInfo),
|
||||||
static_cast<Value*>(src),
|
static_cast<Value*>(src),
|
||||||
extendType.size(TargetBytesPerWord) < TargetBytesPerWord
|
extendType.size(c.targetInfo) < TargetBytesPerWord
|
||||||
? TargetBytesPerWord
|
? TargetBytesPerWord
|
||||||
: extendType.size(TargetBytesPerWord),
|
: extendType.size(c.targetInfo),
|
||||||
dst);
|
dst);
|
||||||
return dst;
|
return dst;
|
||||||
}
|
}
|
||||||
@ -2617,10 +2617,10 @@ class MyCompiler: public Compiler {
|
|||||||
|
|
||||||
appendMove(&c,
|
appendMove(&c,
|
||||||
lir::Move,
|
lir::Move,
|
||||||
src->type.size(TargetBytesPerWord),
|
src->type.size(c.targetInfo),
|
||||||
src->type.size(TargetBytesPerWord),
|
src->type.size(c.targetInfo),
|
||||||
static_cast<Value*>(src),
|
static_cast<Value*>(src),
|
||||||
dst->type.size(TargetBytesPerWord),
|
dst->type.size(c.targetInfo),
|
||||||
static_cast<Value*>(dst));
|
static_cast<Value*>(dst));
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -2633,12 +2633,12 @@ class MyCompiler: public Compiler {
|
|||||||
Value* dst = value(&c, dstType);
|
Value* dst = value(&c, dstType);
|
||||||
appendMove(&c,
|
appendMove(&c,
|
||||||
signExtend == ir::SignExtend ? lir::Move : lir::MoveZ,
|
signExtend == ir::SignExtend ? lir::Move : lir::MoveZ,
|
||||||
src->type.size(TargetBytesPerWord),
|
src->type.size(c.targetInfo),
|
||||||
src->type.size(TargetBytesPerWord),
|
src->type.size(c.targetInfo),
|
||||||
static_cast<Value*>(src),
|
static_cast<Value*>(src),
|
||||||
dstType.size(TargetBytesPerWord) < TargetBytesPerWord
|
dstType.size(c.targetInfo) < TargetBytesPerWord
|
||||||
? TargetBytesPerWord
|
? TargetBytesPerWord
|
||||||
: dstType.size(TargetBytesPerWord),
|
: dstType.size(c.targetInfo),
|
||||||
dst);
|
dst);
|
||||||
return dst;
|
return dst;
|
||||||
}
|
}
|
||||||
|
@ -17,38 +17,41 @@ namespace avian {
|
|||||||
namespace codegen {
|
namespace codegen {
|
||||||
namespace compiler {
|
namespace compiler {
|
||||||
|
|
||||||
Context::Context(vm::System* system, Assembler* assembler, vm::Zone* zone,
|
Context::Context(vm::System* system,
|
||||||
Compiler::Client* client):
|
Assembler* assembler,
|
||||||
system(system),
|
vm::Zone* zone,
|
||||||
assembler(assembler),
|
Compiler::Client* client)
|
||||||
arch(assembler->arch()),
|
: system(system),
|
||||||
zone(zone),
|
assembler(assembler),
|
||||||
client(client),
|
arch(assembler->arch()),
|
||||||
stack(0),
|
zone(zone),
|
||||||
locals(0),
|
client(client),
|
||||||
saved(0),
|
stack(0),
|
||||||
predecessor(0),
|
locals(0),
|
||||||
regFile(arch->registerFile()),
|
saved(0),
|
||||||
regAlloc(system, arch->registerFile()),
|
predecessor(0),
|
||||||
registerResources
|
regFile(arch->registerFile()),
|
||||||
(static_cast<RegisterResource*>
|
regAlloc(system, arch->registerFile()),
|
||||||
(zone->allocate(sizeof(RegisterResource) * regFile->allRegisters.limit))),
|
registerResources(static_cast<RegisterResource*>(zone->allocate(
|
||||||
frameResources(0),
|
sizeof(RegisterResource) * regFile->allRegisters.limit))),
|
||||||
acquiredResources(0),
|
frameResources(0),
|
||||||
firstConstant(0),
|
acquiredResources(0),
|
||||||
lastConstant(0),
|
firstConstant(0),
|
||||||
machineCode(0),
|
lastConstant(0),
|
||||||
firstEvent(0),
|
machineCode(0),
|
||||||
lastEvent(0),
|
firstEvent(0),
|
||||||
forkState(0),
|
lastEvent(0),
|
||||||
firstBlock(0),
|
forkState(0),
|
||||||
logicalIp(-1),
|
firstBlock(0),
|
||||||
constantCount(0),
|
logicalIp(-1),
|
||||||
parameterFootprint(0),
|
constantCount(0),
|
||||||
localFootprint(0),
|
parameterFootprint(0),
|
||||||
machineCodeSize(0),
|
localFootprint(0),
|
||||||
alignedFrameSize(0),
|
machineCodeSize(0),
|
||||||
availableGeneralRegisterCount(regFile->generalRegisters.limit - regFile->generalRegisters.start)
|
alignedFrameSize(0),
|
||||||
|
availableGeneralRegisterCount(regFile->generalRegisters.limit
|
||||||
|
- regFile->generalRegisters.start),
|
||||||
|
targetInfo(arch->targetInfo())
|
||||||
{
|
{
|
||||||
for (unsigned i = regFile->generalRegisters.start; i < regFile->generalRegisters.limit; ++i) {
|
for (unsigned i = regFile->generalRegisters.start; i < regFile->generalRegisters.limit; ++i) {
|
||||||
new (registerResources + i) RegisterResource(arch->reserved(i));
|
new (registerResources + i) RegisterResource(arch->reserved(i));
|
||||||
|
@ -125,6 +125,7 @@ class Context {
|
|||||||
unsigned machineCodeSize;
|
unsigned machineCodeSize;
|
||||||
unsigned alignedFrameSize;
|
unsigned alignedFrameSize;
|
||||||
unsigned availableGeneralRegisterCount;
|
unsigned availableGeneralRegisterCount;
|
||||||
|
ir::TargetInfo targetInfo;
|
||||||
};
|
};
|
||||||
|
|
||||||
inline Aborter* getAborter(Context* c) {
|
inline Aborter* getAborter(Context* c) {
|
||||||
|
@ -130,7 +130,7 @@ void Event::addReads(Context* c, Value* v, unsigned size,
|
|||||||
{
|
{
|
||||||
SingleRead* r = read(c, lowMask, lowSuccessor);
|
SingleRead* r = read(c, lowMask, lowSuccessor);
|
||||||
this->addRead(c, v, r);
|
this->addRead(c, v, r);
|
||||||
if (size > vm::TargetBytesPerWord) {
|
if (size > c->targetInfo.pointerSize) {
|
||||||
r->high_ = v->nextWord;
|
r->high_ = v->nextWord;
|
||||||
this->addRead(c, v->nextWord, highMask, highSuccessor);
|
this->addRead(c, v->nextWord, highMask, highSuccessor);
|
||||||
}
|
}
|
||||||
@ -269,7 +269,7 @@ void slicePush(Context* c,
|
|||||||
if (footprint > 1) {
|
if (footprint > 1) {
|
||||||
assert(c, footprint == 2);
|
assert(c, footprint == 2);
|
||||||
|
|
||||||
if (vm::TargetBytesPerWord == 4) {
|
if (c->targetInfo.pointerSize == 4) {
|
||||||
low->maybeSplit(c);
|
low->maybeSplit(c);
|
||||||
high = slicePushWord(c, low->nextWord, stackBase, slice);
|
high = slicePushWord(c, low->nextWord, stackBase, slice);
|
||||||
} else {
|
} else {
|
||||||
@ -376,9 +376,10 @@ class CallEvent: public Event {
|
|||||||
|
|
||||||
{ bool thunk;
|
{ bool thunk;
|
||||||
OperandMask op;
|
OperandMask op;
|
||||||
c->arch->plan
|
c->arch->plan((flags & Compiler::Aligned) ? lir::AlignedCall : lir::Call,
|
||||||
((flags & Compiler::Aligned) ? lir::AlignedCall : lir::Call, vm::TargetBytesPerWord,
|
c->targetInfo.pointerSize,
|
||||||
op, &thunk);
|
op,
|
||||||
|
&thunk);
|
||||||
|
|
||||||
assert(c, not thunk);
|
assert(c, not thunk);
|
||||||
|
|
||||||
@ -395,12 +396,12 @@ class CallEvent: public Event {
|
|||||||
for (int i = stackArgumentFootprint - 1; i >= 0; --i) {
|
for (int i = stackArgumentFootprint - 1; i >= 0; --i) {
|
||||||
Value* v = static_cast<Value*>(arguments[i]);
|
Value* v = static_cast<Value*>(arguments[i]);
|
||||||
|
|
||||||
if ((vm::TargetBytesPerWord == 8
|
if ((c->targetInfo.pointerSize == 8
|
||||||
&& (v == 0 || (i >= 1 && arguments[i - 1] == 0)))
|
&& (v == 0 || (i >= 1 && arguments[i - 1] == 0)))
|
||||||
|| (vm::TargetBytesPerWord == 4 && v->nextWord != v)) {
|
|| (c->targetInfo.pointerSize == 4 && v->nextWord != v)) {
|
||||||
assert(
|
assert(c,
|
||||||
c,
|
c->targetInfo.pointerSize == 8
|
||||||
vm::TargetBytesPerWord == 8 or v->nextWord == arguments[i - 1]);
|
or v->nextWord == arguments[i - 1]);
|
||||||
|
|
||||||
arguments[i] = arguments[i - 1];
|
arguments[i] = arguments[i - 1];
|
||||||
--i;
|
--i;
|
||||||
@ -553,7 +554,7 @@ class CallEvent: public Event {
|
|||||||
op = lir::Call;
|
op = lir::Call;
|
||||||
}
|
}
|
||||||
|
|
||||||
apply(c, op, vm::TargetBytesPerWord, address->source, address->source);
|
apply(c, op, c->targetInfo.pointerSize, address->source, address->source);
|
||||||
|
|
||||||
if (traceHandler) {
|
if (traceHandler) {
|
||||||
traceHandler->handleTrace(codePromise(c, c->assembler->offset(true)),
|
traceHandler->handleTrace(codePromise(c, c->assembler->offset(true)),
|
||||||
@ -576,11 +577,10 @@ class CallEvent: public Event {
|
|||||||
|
|
||||||
clean(c, this, stackBefore, localsBefore, reads, popIndex);
|
clean(c, this, stackBefore, localsBefore, reads, popIndex);
|
||||||
|
|
||||||
if (resultValue->type.size(vm::TargetBytesPerWord)
|
if (resultValue->type.size(c->targetInfo) and live(c, resultValue)) {
|
||||||
and live(c, resultValue)) {
|
|
||||||
resultValue->addSite(c, registerSite(c, c->arch->returnLow()));
|
resultValue->addSite(c, registerSite(c, c->arch->returnLow()));
|
||||||
if (resultValue->type.size(vm::TargetBytesPerWord)
|
if (resultValue->type.size(c->targetInfo) > c->targetInfo.pointerSize
|
||||||
> vm::TargetBytesPerWord and live(c, resultValue->nextWord)) {
|
and live(c, resultValue->nextWord)) {
|
||||||
resultValue->nextWord->addSite(c,
|
resultValue->nextWord->addSite(c,
|
||||||
registerSite(c, c->arch->returnHigh()));
|
registerSite(c, c->arch->returnHigh()));
|
||||||
}
|
}
|
||||||
@ -628,7 +628,7 @@ class ReturnEvent: public Event {
|
|||||||
if (value) {
|
if (value) {
|
||||||
this->addReads(c,
|
this->addReads(c,
|
||||||
value,
|
value,
|
||||||
value->type.size(vm::TargetBytesPerWord),
|
value->type.size(c->targetInfo),
|
||||||
SiteMask::fixedRegisterMask(c->arch->returnLow()),
|
SiteMask::fixedRegisterMask(c->arch->returnLow()),
|
||||||
SiteMask::fixedRegisterMask(c->arch->returnHigh()));
|
SiteMask::fixedRegisterMask(c->arch->returnHigh()));
|
||||||
}
|
}
|
||||||
@ -680,18 +680,23 @@ class MoveEvent: public Event {
|
|||||||
assert(c, srcSelectSize <= srcSize);
|
assert(c, srcSelectSize <= srcSize);
|
||||||
|
|
||||||
bool noop = srcSelectSize >= dstSize;
|
bool noop = srcSelectSize >= dstSize;
|
||||||
|
|
||||||
if (dstSize > vm::TargetBytesPerWord) {
|
if (dstSize > c->targetInfo.pointerSize) {
|
||||||
dstValue->grow(c);
|
dstValue->grow(c);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (srcSelectSize > vm::TargetBytesPerWord) {
|
if (srcSelectSize > c->targetInfo.pointerSize) {
|
||||||
srcValue->maybeSplit(c);
|
srcValue->maybeSplit(c);
|
||||||
}
|
}
|
||||||
|
|
||||||
this->addReads(c, srcValue, srcSelectSize, srcLowMask, noop ? dstValue : 0,
|
this->addReads(
|
||||||
srcHighMask,
|
c,
|
||||||
noop and dstSize > vm::TargetBytesPerWord ? dstValue->nextWord : 0);
|
srcValue,
|
||||||
|
srcSelectSize,
|
||||||
|
srcLowMask,
|
||||||
|
noop ? dstValue : 0,
|
||||||
|
srcHighMask,
|
||||||
|
noop and dstSize > c->targetInfo.pointerSize ? dstValue->nextWord : 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
virtual const char* name() {
|
virtual const char* name() {
|
||||||
@ -714,47 +719,61 @@ class MoveEvent: public Event {
|
|||||||
SiteMask dstLowMask = SiteMask::lowPart(dst);
|
SiteMask dstLowMask = SiteMask::lowPart(dst);
|
||||||
SiteMask dstHighMask = SiteMask::highPart(dst);
|
SiteMask dstHighMask = SiteMask::highPart(dst);
|
||||||
|
|
||||||
if (srcSelectSize >= vm::TargetBytesPerWord
|
if (srcSelectSize >= c->targetInfo.pointerSize
|
||||||
and dstSize >= vm::TargetBytesPerWord
|
and dstSize >= c->targetInfo.pointerSize and srcSelectSize >= dstSize) {
|
||||||
and srcSelectSize >= dstSize)
|
|
||||||
{
|
|
||||||
if (dstValue->target) {
|
if (dstValue->target) {
|
||||||
if (dstSize > vm::TargetBytesPerWord) {
|
if (dstSize > c->targetInfo.pointerSize) {
|
||||||
if (srcValue->source->registerSize(c) > vm::TargetBytesPerWord) {
|
if (srcValue->source->registerSize(c) > c->targetInfo.pointerSize) {
|
||||||
apply(c, lir::Move, srcSelectSize, srcValue->source, srcValue->source,
|
apply(c, lir::Move, srcSelectSize, srcValue->source, srcValue->source,
|
||||||
dstSize, dstValue->target, dstValue->target);
|
dstSize, dstValue->target, dstValue->target);
|
||||||
|
|
||||||
if (live(c, dstValue) == 0) {
|
if (live(c, dstValue) == 0) {
|
||||||
dstValue->removeSite(c, dstValue->target);
|
dstValue->removeSite(c, dstValue->target);
|
||||||
if (dstSize > vm::TargetBytesPerWord) {
|
if (dstSize > c->targetInfo.pointerSize) {
|
||||||
dstValue->nextWord->removeSite(c, dstValue->nextWord->target);
|
dstValue->nextWord->removeSite(c, dstValue->nextWord->target);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
srcValue->nextWord->source->freeze(c, srcValue->nextWord);
|
srcValue->nextWord->source->freeze(c, srcValue->nextWord);
|
||||||
|
|
||||||
maybeMove(c, lir::Move, vm::TargetBytesPerWord, vm::TargetBytesPerWord, srcValue,
|
maybeMove(c,
|
||||||
vm::TargetBytesPerWord, dstValue, dstLowMask);
|
lir::Move,
|
||||||
|
c->targetInfo.pointerSize,
|
||||||
|
c->targetInfo.pointerSize,
|
||||||
|
srcValue,
|
||||||
|
c->targetInfo.pointerSize,
|
||||||
|
dstValue,
|
||||||
|
dstLowMask);
|
||||||
|
|
||||||
srcValue->nextWord->source->thaw(c, srcValue->nextWord);
|
srcValue->nextWord->source->thaw(c, srcValue->nextWord);
|
||||||
|
|
||||||
maybeMove
|
maybeMove(c,
|
||||||
(c, lir::Move, vm::TargetBytesPerWord, vm::TargetBytesPerWord, srcValue->nextWord,
|
lir::Move,
|
||||||
vm::TargetBytesPerWord, dstValue->nextWord, dstHighMask);
|
c->targetInfo.pointerSize,
|
||||||
|
c->targetInfo.pointerSize,
|
||||||
|
srcValue->nextWord,
|
||||||
|
c->targetInfo.pointerSize,
|
||||||
|
dstValue->nextWord,
|
||||||
|
dstHighMask);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
maybeMove(c, lir::Move, vm::TargetBytesPerWord, vm::TargetBytesPerWord, srcValue,
|
maybeMove(c,
|
||||||
vm::TargetBytesPerWord, dstValue, dstLowMask);
|
lir::Move,
|
||||||
|
c->targetInfo.pointerSize,
|
||||||
|
c->targetInfo.pointerSize,
|
||||||
|
srcValue,
|
||||||
|
c->targetInfo.pointerSize,
|
||||||
|
dstValue,
|
||||||
|
dstLowMask);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
Site* low = pickSiteOrMove(c, srcValue, dstValue, 0, 0);
|
Site* low = pickSiteOrMove(c, srcValue, dstValue, 0, 0);
|
||||||
if (dstSize > vm::TargetBytesPerWord) {
|
if (dstSize > c->targetInfo.pointerSize) {
|
||||||
pickSiteOrMove(c, srcValue->nextWord, dstValue->nextWord, low, 1);
|
pickSiteOrMove(c, srcValue->nextWord, dstValue->nextWord, low, 1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else if (srcSelectSize <= vm::TargetBytesPerWord
|
} else if (srcSelectSize <= c->targetInfo.pointerSize
|
||||||
and dstSize <= vm::TargetBytesPerWord)
|
and dstSize <= c->targetInfo.pointerSize) {
|
||||||
{
|
|
||||||
maybeMove(c,
|
maybeMove(c,
|
||||||
op,
|
op,
|
||||||
srcSize,
|
srcSize,
|
||||||
@ -764,8 +783,8 @@ class MoveEvent: public Event {
|
|||||||
dstValue,
|
dstValue,
|
||||||
dstLowMask);
|
dstLowMask);
|
||||||
} else {
|
} else {
|
||||||
assert(c, srcSize == vm::TargetBytesPerWord);
|
assert(c, srcSize == c->targetInfo.pointerSize);
|
||||||
assert(c, srcSelectSize == vm::TargetBytesPerWord);
|
assert(c, srcSelectSize == c->targetInfo.pointerSize);
|
||||||
|
|
||||||
if (dstValue->nextWord->target or live(c, dstValue->nextWord)) {
|
if (dstValue->nextWord->target or live(c, dstValue->nextWord)) {
|
||||||
assert(c, dstLowMask.typeMask & (1 << lir::RegisterOperand));
|
assert(c, dstLowMask.typeMask & (1 << lir::RegisterOperand));
|
||||||
@ -785,8 +804,14 @@ class MoveEvent: public Event {
|
|||||||
srcb, dstb, srcValue);
|
srcb, dstb, srcValue);
|
||||||
}
|
}
|
||||||
|
|
||||||
apply(c, lir::Move, vm::TargetBytesPerWord, srcValue->source, srcValue->source,
|
apply(c,
|
||||||
vm::TargetBytesPerWord, low, low);
|
lir::Move,
|
||||||
|
c->targetInfo.pointerSize,
|
||||||
|
srcValue->source,
|
||||||
|
srcValue->source,
|
||||||
|
c->targetInfo.pointerSize,
|
||||||
|
low,
|
||||||
|
low);
|
||||||
|
|
||||||
low->thaw(c, dstValue);
|
low->thaw(c, dstValue);
|
||||||
|
|
||||||
@ -809,7 +834,14 @@ class MoveEvent: public Event {
|
|||||||
srcb, dstb, dstValue, dstValue->nextWord);
|
srcb, dstb, dstValue, dstValue->nextWord);
|
||||||
}
|
}
|
||||||
|
|
||||||
apply(c, lir::Move, vm::TargetBytesPerWord, low, low, dstSize, low, high);
|
apply(c,
|
||||||
|
lir::Move,
|
||||||
|
c->targetInfo.pointerSize,
|
||||||
|
low,
|
||||||
|
low,
|
||||||
|
dstSize,
|
||||||
|
low,
|
||||||
|
high);
|
||||||
|
|
||||||
high->thaw(c, dstValue->nextWord);
|
high->thaw(c, dstValue->nextWord);
|
||||||
|
|
||||||
@ -864,7 +896,7 @@ void
|
|||||||
freezeSource(Context* c, unsigned size, Value* v)
|
freezeSource(Context* c, unsigned size, Value* v)
|
||||||
{
|
{
|
||||||
v->source->freeze(c, v);
|
v->source->freeze(c, v);
|
||||||
if (size > vm::TargetBytesPerWord) {
|
if (size > c->targetInfo.pointerSize) {
|
||||||
v->nextWord->source->freeze(c, v->nextWord);
|
v->nextWord->source->freeze(c, v->nextWord);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -873,7 +905,7 @@ void
|
|||||||
thawSource(Context* c, unsigned size, Value* v)
|
thawSource(Context* c, unsigned size, Value* v)
|
||||||
{
|
{
|
||||||
v->source->thaw(c, v);
|
v->source->thaw(c, v);
|
||||||
if (size > vm::TargetBytesPerWord) {
|
if (size > c->targetInfo.pointerSize) {
|
||||||
v->nextWord->source->thaw(c, v->nextWord);
|
v->nextWord->source->thaw(c, v->nextWord);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -948,12 +980,11 @@ class CombineEvent: public Event {
|
|||||||
{
|
{
|
||||||
this->addReads(c,
|
this->addReads(c,
|
||||||
firstValue,
|
firstValue,
|
||||||
firstValue->type.size(vm::TargetBytesPerWord),
|
firstValue->type.size(c->targetInfo),
|
||||||
firstLowMask,
|
firstLowMask,
|
||||||
firstHighMask);
|
firstHighMask);
|
||||||
|
|
||||||
if (resultValue->type.size(vm::TargetBytesPerWord)
|
if (resultValue->type.size(c->targetInfo) > c->targetInfo.pointerSize) {
|
||||||
> vm::TargetBytesPerWord) {
|
|
||||||
resultValue->grow(c);
|
resultValue->grow(c);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -961,7 +992,7 @@ class CombineEvent: public Event {
|
|||||||
|
|
||||||
this->addReads(c,
|
this->addReads(c,
|
||||||
secondValue,
|
secondValue,
|
||||||
secondValue->type.size(vm::TargetBytesPerWord),
|
secondValue->type.size(c->targetInfo),
|
||||||
secondLowMask,
|
secondLowMask,
|
||||||
condensed ? resultValue : 0,
|
condensed ? resultValue : 0,
|
||||||
secondHighMask,
|
secondHighMask,
|
||||||
@ -984,27 +1015,27 @@ class CombineEvent: public Event {
|
|||||||
|
|
||||||
assert(c, secondValue->source->type(c) == secondValue->nextWord->source->type(c));
|
assert(c, secondValue->source->type(c) == secondValue->nextWord->source->type(c));
|
||||||
|
|
||||||
freezeSource(c, firstValue->type.size(vm::TargetBytesPerWord), firstValue);
|
freezeSource(c, firstValue->type.size(c->targetInfo), firstValue);
|
||||||
|
|
||||||
OperandMask cMask;
|
OperandMask cMask;
|
||||||
|
|
||||||
c->arch->planDestination(
|
c->arch->planDestination(
|
||||||
op,
|
op,
|
||||||
firstValue->type.size(vm::TargetBytesPerWord),
|
firstValue->type.size(c->targetInfo),
|
||||||
OperandMask(
|
OperandMask(
|
||||||
1 << firstValue->source->type(c),
|
1 << firstValue->source->type(c),
|
||||||
(static_cast<uint64_t>(
|
(static_cast<uint64_t>(
|
||||||
firstValue->nextWord->source->registerMask(c))
|
firstValue->nextWord->source->registerMask(c))
|
||||||
<< 32)
|
<< 32)
|
||||||
| static_cast<uint64_t>(firstValue->source->registerMask(c))),
|
| static_cast<uint64_t>(firstValue->source->registerMask(c))),
|
||||||
secondValue->type.size(vm::TargetBytesPerWord),
|
secondValue->type.size(c->targetInfo),
|
||||||
OperandMask(
|
OperandMask(
|
||||||
1 << secondValue->source->type(c),
|
1 << secondValue->source->type(c),
|
||||||
(static_cast<uint64_t>(
|
(static_cast<uint64_t>(
|
||||||
secondValue->nextWord->source->registerMask(c))
|
secondValue->nextWord->source->registerMask(c))
|
||||||
<< 32)
|
<< 32)
|
||||||
| static_cast<uint64_t>(secondValue->source->registerMask(c))),
|
| static_cast<uint64_t>(secondValue->source->registerMask(c))),
|
||||||
resultValue->type.size(vm::TargetBytesPerWord),
|
resultValue->type.size(c->targetInfo),
|
||||||
cMask);
|
cMask);
|
||||||
|
|
||||||
SiteMask resultLowMask = SiteMask::lowPart(cMask);
|
SiteMask resultLowMask = SiteMask::lowPart(cMask);
|
||||||
@ -1012,7 +1043,7 @@ class CombineEvent: public Event {
|
|||||||
|
|
||||||
Site* low = getTarget(c, secondValue, resultValue, resultLowMask);
|
Site* low = getTarget(c, secondValue, resultValue, resultLowMask);
|
||||||
unsigned lowSize = low->registerSize(c);
|
unsigned lowSize = low->registerSize(c);
|
||||||
Site* high = (resultValue->type.size(vm::TargetBytesPerWord) > lowSize
|
Site* high = (resultValue->type.size(c->targetInfo) > lowSize
|
||||||
? getTarget(c,
|
? getTarget(c,
|
||||||
secondValue->nextWord,
|
secondValue->nextWord,
|
||||||
resultValue->nextWord,
|
resultValue->nextWord,
|
||||||
@ -1026,30 +1057,30 @@ class CombineEvent: public Event {
|
|||||||
|
|
||||||
apply(c,
|
apply(c,
|
||||||
op,
|
op,
|
||||||
firstValue->type.size(vm::TargetBytesPerWord),
|
firstValue->type.size(c->targetInfo),
|
||||||
firstValue->source,
|
firstValue->source,
|
||||||
firstValue->nextWord->source,
|
firstValue->nextWord->source,
|
||||||
secondValue->type.size(vm::TargetBytesPerWord),
|
secondValue->type.size(c->targetInfo),
|
||||||
secondValue->source,
|
secondValue->source,
|
||||||
secondValue->nextWord->source,
|
secondValue->nextWord->source,
|
||||||
resultValue->type.size(vm::TargetBytesPerWord),
|
resultValue->type.size(c->targetInfo),
|
||||||
low,
|
low,
|
||||||
high);
|
high);
|
||||||
|
|
||||||
thawSource(c, firstValue->type.size(vm::TargetBytesPerWord), firstValue);
|
thawSource(c, firstValue->type.size(c->targetInfo), firstValue);
|
||||||
|
|
||||||
for (Read* r = reads; r; r = r->eventNext) {
|
for (Read* r = reads; r; r = r->eventNext) {
|
||||||
popRead(c, this, r->value);
|
popRead(c, this, r->value);
|
||||||
}
|
}
|
||||||
|
|
||||||
low->thaw(c, secondValue);
|
low->thaw(c, secondValue);
|
||||||
if (resultValue->type.size(vm::TargetBytesPerWord) > lowSize) {
|
if (resultValue->type.size(c->targetInfo) > lowSize) {
|
||||||
high->thaw(c, secondValue->nextWord);
|
high->thaw(c, secondValue->nextWord);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (live(c, resultValue)) {
|
if (live(c, resultValue)) {
|
||||||
resultValue->addSite(c, low);
|
resultValue->addSite(c, low);
|
||||||
if (resultValue->type.size(vm::TargetBytesPerWord) > lowSize
|
if (resultValue->type.size(c->targetInfo) > lowSize
|
||||||
and live(c, resultValue->nextWord)) {
|
and live(c, resultValue->nextWord)) {
|
||||||
resultValue->nextWord->addSite(c, high);
|
resultValue->nextWord->addSite(c, high);
|
||||||
}
|
}
|
||||||
@ -1072,11 +1103,11 @@ void appendCombine(Context* c,
|
|||||||
OperandMask firstMask;
|
OperandMask firstMask;
|
||||||
OperandMask secondMask;
|
OperandMask secondMask;
|
||||||
c->arch->planSource(op,
|
c->arch->planSource(op,
|
||||||
firstValue->type.size(vm::TargetBytesPerWord),
|
firstValue->type.size(c->targetInfo),
|
||||||
firstMask,
|
firstMask,
|
||||||
secondValue->type.size(vm::TargetBytesPerWord),
|
secondValue->type.size(c->targetInfo),
|
||||||
secondMask,
|
secondMask,
|
||||||
resultValue->type.size(vm::TargetBytesPerWord),
|
resultValue->type.size(c->targetInfo),
|
||||||
&thunk);
|
&thunk);
|
||||||
|
|
||||||
if (thunk) {
|
if (thunk) {
|
||||||
@ -1087,25 +1118,24 @@ void appendCombine(Context* c,
|
|||||||
bool threadParameter;
|
bool threadParameter;
|
||||||
intptr_t handler
|
intptr_t handler
|
||||||
= c->client->getThunk(op,
|
= c->client->getThunk(op,
|
||||||
firstValue->type.size(vm::TargetBytesPerWord),
|
firstValue->type.size(c->targetInfo),
|
||||||
resultValue->type.size(vm::TargetBytesPerWord),
|
resultValue->type.size(c->targetInfo),
|
||||||
&threadParameter);
|
&threadParameter);
|
||||||
|
|
||||||
unsigned stackSize
|
unsigned stackSize = ceilingDivide(secondValue->type.size(c->targetInfo),
|
||||||
= ceilingDivide(secondValue->type.size(vm::TargetBytesPerWord),
|
c->targetInfo.pointerSize)
|
||||||
vm::TargetBytesPerWord)
|
+ ceilingDivide(firstValue->type.size(c->targetInfo),
|
||||||
+ ceilingDivide(firstValue->type.size(vm::TargetBytesPerWord),
|
c->targetInfo.pointerSize);
|
||||||
vm::TargetBytesPerWord);
|
|
||||||
|
|
||||||
slicePush(c,
|
slicePush(c,
|
||||||
ceilingDivide(secondValue->type.size(vm::TargetBytesPerWord),
|
ceilingDivide(secondValue->type.size(c->targetInfo),
|
||||||
vm::TargetBytesPerWord),
|
c->targetInfo.pointerSize),
|
||||||
secondValue,
|
secondValue,
|
||||||
stackBase,
|
stackBase,
|
||||||
slice);
|
slice);
|
||||||
slicePush(c,
|
slicePush(c,
|
||||||
ceilingDivide(firstValue->type.size(vm::TargetBytesPerWord),
|
ceilingDivide(firstValue->type.size(c->targetInfo),
|
||||||
vm::TargetBytesPerWord),
|
c->targetInfo.pointerSize),
|
||||||
firstValue,
|
firstValue,
|
||||||
stackBase,
|
stackBase,
|
||||||
slice);
|
slice);
|
||||||
@ -1149,14 +1179,13 @@ class TranslateEvent: public Event {
|
|||||||
{
|
{
|
||||||
bool condensed = c->arch->alwaysCondensed(op);
|
bool condensed = c->arch->alwaysCondensed(op);
|
||||||
|
|
||||||
if (resultValue->type.size(vm::TargetBytesPerWord)
|
if (resultValue->type.size(c->targetInfo) > c->targetInfo.pointerSize) {
|
||||||
> vm::TargetBytesPerWord) {
|
|
||||||
resultValue->grow(c);
|
resultValue->grow(c);
|
||||||
}
|
}
|
||||||
|
|
||||||
this->addReads(c,
|
this->addReads(c,
|
||||||
firstValue,
|
firstValue,
|
||||||
firstValue->type.size(vm::TargetBytesPerWord),
|
firstValue->type.size(c->targetInfo),
|
||||||
valueLowMask,
|
valueLowMask,
|
||||||
condensed ? resultValue : 0,
|
condensed ? resultValue : 0,
|
||||||
valueHighMask,
|
valueHighMask,
|
||||||
@ -1174,14 +1203,14 @@ class TranslateEvent: public Event {
|
|||||||
|
|
||||||
c->arch->planDestination(
|
c->arch->planDestination(
|
||||||
op,
|
op,
|
||||||
firstValue->type.size(vm::TargetBytesPerWord),
|
firstValue->type.size(c->targetInfo),
|
||||||
OperandMask(
|
OperandMask(
|
||||||
1 << firstValue->source->type(c),
|
1 << firstValue->source->type(c),
|
||||||
(static_cast<uint64_t>(
|
(static_cast<uint64_t>(
|
||||||
firstValue->nextWord->source->registerMask(c))
|
firstValue->nextWord->source->registerMask(c))
|
||||||
<< 32)
|
<< 32)
|
||||||
| static_cast<uint64_t>(firstValue->source->registerMask(c))),
|
| static_cast<uint64_t>(firstValue->source->registerMask(c))),
|
||||||
resultValue->type.size(vm::TargetBytesPerWord),
|
resultValue->type.size(c->targetInfo),
|
||||||
bMask);
|
bMask);
|
||||||
|
|
||||||
SiteMask resultLowMask = SiteMask::lowPart(bMask);
|
SiteMask resultLowMask = SiteMask::lowPart(bMask);
|
||||||
@ -1189,7 +1218,7 @@ class TranslateEvent: public Event {
|
|||||||
|
|
||||||
Site* low = getTarget(c, firstValue, resultValue, resultLowMask);
|
Site* low = getTarget(c, firstValue, resultValue, resultLowMask);
|
||||||
unsigned lowSize = low->registerSize(c);
|
unsigned lowSize = low->registerSize(c);
|
||||||
Site* high = (resultValue->type.size(vm::TargetBytesPerWord) > lowSize
|
Site* high = (resultValue->type.size(c->targetInfo) > lowSize
|
||||||
? getTarget(c,
|
? getTarget(c,
|
||||||
firstValue->nextWord,
|
firstValue->nextWord,
|
||||||
resultValue->nextWord,
|
resultValue->nextWord,
|
||||||
@ -1198,10 +1227,10 @@ class TranslateEvent: public Event {
|
|||||||
|
|
||||||
apply(c,
|
apply(c,
|
||||||
op,
|
op,
|
||||||
firstValue->type.size(vm::TargetBytesPerWord),
|
firstValue->type.size(c->targetInfo),
|
||||||
firstValue->source,
|
firstValue->source,
|
||||||
firstValue->nextWord->source,
|
firstValue->nextWord->source,
|
||||||
resultValue->type.size(vm::TargetBytesPerWord),
|
resultValue->type.size(c->targetInfo),
|
||||||
low,
|
low,
|
||||||
high);
|
high);
|
||||||
|
|
||||||
@ -1210,13 +1239,13 @@ class TranslateEvent: public Event {
|
|||||||
}
|
}
|
||||||
|
|
||||||
low->thaw(c, firstValue);
|
low->thaw(c, firstValue);
|
||||||
if (resultValue->type.size(vm::TargetBytesPerWord) > lowSize) {
|
if (resultValue->type.size(c->targetInfo) > lowSize) {
|
||||||
high->thaw(c, firstValue->nextWord);
|
high->thaw(c, firstValue->nextWord);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (live(c, resultValue)) {
|
if (live(c, resultValue)) {
|
||||||
resultValue->addSite(c, low);
|
resultValue->addSite(c, low);
|
||||||
if (resultValue->type.size(vm::TargetBytesPerWord) > lowSize
|
if (resultValue->type.size(c->targetInfo) > lowSize
|
||||||
and live(c, resultValue->nextWord)) {
|
and live(c, resultValue->nextWord)) {
|
||||||
resultValue->nextWord->addSite(c, high);
|
resultValue->nextWord->addSite(c, high);
|
||||||
}
|
}
|
||||||
@ -1237,19 +1266,19 @@ void appendTranslate(Context* c,
|
|||||||
Value* resultValue)
|
Value* resultValue)
|
||||||
{
|
{
|
||||||
assert(c,
|
assert(c,
|
||||||
firstValue->type.size(vm::TargetBytesPerWord)
|
firstValue->type.size(c->targetInfo)
|
||||||
== firstValue->type.size(vm::TargetBytesPerWord));
|
== firstValue->type.size(c->targetInfo));
|
||||||
assert(c,
|
assert(c,
|
||||||
resultValue->type.size(vm::TargetBytesPerWord)
|
resultValue->type.size(c->targetInfo)
|
||||||
== resultValue->type.size(vm::TargetBytesPerWord));
|
== resultValue->type.size(c->targetInfo));
|
||||||
|
|
||||||
bool thunk;
|
bool thunk;
|
||||||
OperandMask first;
|
OperandMask first;
|
||||||
|
|
||||||
c->arch->planSource(op,
|
c->arch->planSource(op,
|
||||||
firstValue->type.size(vm::TargetBytesPerWord),
|
firstValue->type.size(c->targetInfo),
|
||||||
first,
|
first,
|
||||||
resultValue->type.size(vm::TargetBytesPerWord),
|
resultValue->type.size(c->targetInfo),
|
||||||
&thunk);
|
&thunk);
|
||||||
|
|
||||||
if (thunk) {
|
if (thunk) {
|
||||||
@ -1257,8 +1286,8 @@ void appendTranslate(Context* c,
|
|||||||
FixedSliceStack<ir::Value*, 2> slice;
|
FixedSliceStack<ir::Value*, 2> slice;
|
||||||
|
|
||||||
slicePush(c,
|
slicePush(c,
|
||||||
ceilingDivide(firstValue->type.size(vm::TargetBytesPerWord),
|
ceilingDivide(firstValue->type.size(c->targetInfo),
|
||||||
vm::TargetBytesPerWord),
|
c->targetInfo.pointerSize),
|
||||||
firstValue,
|
firstValue,
|
||||||
stackBase,
|
stackBase,
|
||||||
slice);
|
slice);
|
||||||
@ -1266,12 +1295,11 @@ void appendTranslate(Context* c,
|
|||||||
appendCall(c,
|
appendCall(c,
|
||||||
value(c,
|
value(c,
|
||||||
ir::Type::addr(),
|
ir::Type::addr(),
|
||||||
constantSite(
|
constantSite(c,
|
||||||
c,
|
c->client->getThunk(
|
||||||
c->client->getThunk(
|
op,
|
||||||
op,
|
firstValue->type.size(c->targetInfo),
|
||||||
firstValue->type.size(vm::TargetBytesPerWord),
|
resultValue->type.size(c->targetInfo)))),
|
||||||
resultValue->type.size(vm::TargetBytesPerWord)))),
|
|
||||||
ir::NativeCallingConvention,
|
ir::NativeCallingConvention,
|
||||||
0,
|
0,
|
||||||
0,
|
0,
|
||||||
@ -1374,7 +1402,7 @@ class MemoryEvent: public Event {
|
|||||||
|
|
||||||
popRead(c, this, base);
|
popRead(c, this, base);
|
||||||
if (index) {
|
if (index) {
|
||||||
if (vm::TargetBytesPerWord == 8 and indexRegister != lir::NoRegister) {
|
if (c->targetInfo.pointerSize == 8 and indexRegister != lir::NoRegister) {
|
||||||
apply(c, lir::Move, 4, index->source, index->source,
|
apply(c, lir::Move, 4, index->source, index->source,
|
||||||
8, index->source, index->source);
|
8, index->source, index->source);
|
||||||
}
|
}
|
||||||
@ -1544,22 +1572,22 @@ class BranchEvent: public Event {
|
|||||||
{
|
{
|
||||||
this->addReads(c,
|
this->addReads(c,
|
||||||
firstValue,
|
firstValue,
|
||||||
firstValue->type.size(vm::TargetBytesPerWord),
|
firstValue->type.size(c->targetInfo),
|
||||||
firstLowMask,
|
firstLowMask,
|
||||||
firstHighMask);
|
firstHighMask);
|
||||||
this->addReads(c,
|
this->addReads(c,
|
||||||
secondValue,
|
secondValue,
|
||||||
firstValue->type.size(vm::TargetBytesPerWord),
|
firstValue->type.size(c->targetInfo),
|
||||||
secondLowMask,
|
secondLowMask,
|
||||||
secondHighMask);
|
secondHighMask);
|
||||||
|
|
||||||
OperandMask dstMask;
|
OperandMask dstMask;
|
||||||
c->arch->planDestination(op,
|
c->arch->planDestination(op,
|
||||||
firstValue->type.size(vm::TargetBytesPerWord),
|
firstValue->type.size(c->targetInfo),
|
||||||
OperandMask(0, 0),
|
OperandMask(0, 0),
|
||||||
firstValue->type.size(vm::TargetBytesPerWord),
|
firstValue->type.size(c->targetInfo),
|
||||||
OperandMask(0, 0),
|
OperandMask(0, 0),
|
||||||
vm::TargetBytesPerWord,
|
c->targetInfo.pointerSize,
|
||||||
dstMask);
|
dstMask);
|
||||||
|
|
||||||
this->addRead(c, addressValue, SiteMask::lowPart(dstMask));
|
this->addRead(c, addressValue, SiteMask::lowPart(dstMask));
|
||||||
@ -1582,8 +1610,7 @@ class BranchEvent: public Event {
|
|||||||
int64_t firstConstVal = firstConstant->value->value();
|
int64_t firstConstVal = firstConstant->value->value();
|
||||||
int64_t secondConstVal = secondConstant->value->value();
|
int64_t secondConstVal = secondConstant->value->value();
|
||||||
|
|
||||||
if (firstValue->type.size(vm::TargetBytesPerWord)
|
if (firstValue->type.size(c->targetInfo) > c->targetInfo.pointerSize) {
|
||||||
> vm::TargetBytesPerWord) {
|
|
||||||
firstConstVal |= findConstantSite
|
firstConstVal |= findConstantSite
|
||||||
(c, firstValue->nextWord)->value->value() << 32;
|
(c, firstValue->nextWord)->value->value() << 32;
|
||||||
secondConstVal |= findConstantSite
|
secondConstVal |= findConstantSite
|
||||||
@ -1592,35 +1619,35 @@ class BranchEvent: public Event {
|
|||||||
|
|
||||||
if (shouldJump(c,
|
if (shouldJump(c,
|
||||||
op,
|
op,
|
||||||
firstValue->type.size(vm::TargetBytesPerWord),
|
firstValue->type.size(c->targetInfo),
|
||||||
firstConstVal,
|
firstConstVal,
|
||||||
secondConstVal)) {
|
secondConstVal)) {
|
||||||
apply(c, lir::Jump, vm::TargetBytesPerWord, addressValue->source, addressValue->source);
|
apply(c,
|
||||||
|
lir::Jump,
|
||||||
|
c->targetInfo.pointerSize,
|
||||||
|
addressValue->source,
|
||||||
|
addressValue->source);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
freezeSource(
|
freezeSource(c, firstValue->type.size(c->targetInfo), firstValue);
|
||||||
c, firstValue->type.size(vm::TargetBytesPerWord), firstValue);
|
freezeSource(c, firstValue->type.size(c->targetInfo), secondValue);
|
||||||
freezeSource(
|
freezeSource(c, c->targetInfo.pointerSize, addressValue);
|
||||||
c, firstValue->type.size(vm::TargetBytesPerWord), secondValue);
|
|
||||||
freezeSource(c, vm::TargetBytesPerWord, addressValue);
|
|
||||||
|
|
||||||
apply(c,
|
apply(c,
|
||||||
op,
|
op,
|
||||||
firstValue->type.size(vm::TargetBytesPerWord),
|
firstValue->type.size(c->targetInfo),
|
||||||
firstValue->source,
|
firstValue->source,
|
||||||
firstValue->nextWord->source,
|
firstValue->nextWord->source,
|
||||||
firstValue->type.size(vm::TargetBytesPerWord),
|
firstValue->type.size(c->targetInfo),
|
||||||
secondValue->source,
|
secondValue->source,
|
||||||
secondValue->nextWord->source,
|
secondValue->nextWord->source,
|
||||||
vm::TargetBytesPerWord,
|
c->targetInfo.pointerSize,
|
||||||
addressValue->source,
|
addressValue->source,
|
||||||
addressValue->source);
|
addressValue->source);
|
||||||
|
|
||||||
thawSource(c, vm::TargetBytesPerWord, addressValue);
|
thawSource(c, c->targetInfo.pointerSize, addressValue);
|
||||||
thawSource(
|
thawSource(c, firstValue->type.size(c->targetInfo), secondValue);
|
||||||
c, firstValue->type.size(vm::TargetBytesPerWord), secondValue);
|
thawSource(c, firstValue->type.size(c->targetInfo), firstValue);
|
||||||
thawSource(
|
|
||||||
c, firstValue->type.size(vm::TargetBytesPerWord), firstValue);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1648,11 +1675,11 @@ void appendBranch(Context* c,
|
|||||||
OperandMask secondMask;
|
OperandMask secondMask;
|
||||||
|
|
||||||
c->arch->planSource(op,
|
c->arch->planSource(op,
|
||||||
firstValue->type.size(vm::TargetBytesPerWord),
|
firstValue->type.size(c->targetInfo),
|
||||||
firstMask,
|
firstMask,
|
||||||
firstValue->type.size(vm::TargetBytesPerWord),
|
firstValue->type.size(c->targetInfo),
|
||||||
secondMask,
|
secondMask,
|
||||||
vm::TargetBytesPerWord,
|
c->targetInfo.pointerSize,
|
||||||
&thunk);
|
&thunk);
|
||||||
|
|
||||||
if (thunk) {
|
if (thunk) {
|
||||||
@ -1661,23 +1688,22 @@ void appendBranch(Context* c,
|
|||||||
size_t stackBase = c->stack ? c->stack->index + 1 : 0;
|
size_t stackBase = c->stack ? c->stack->index + 1 : 0;
|
||||||
|
|
||||||
bool threadParameter;
|
bool threadParameter;
|
||||||
intptr_t handler
|
intptr_t handler = c->client->getThunk(op,
|
||||||
= c->client->getThunk(op,
|
firstValue->type.size(c->targetInfo),
|
||||||
firstValue->type.size(vm::TargetBytesPerWord),
|
firstValue->type.size(c->targetInfo),
|
||||||
firstValue->type.size(vm::TargetBytesPerWord),
|
&threadParameter);
|
||||||
&threadParameter);
|
|
||||||
|
|
||||||
assert(c, not threadParameter);
|
assert(c, not threadParameter);
|
||||||
|
|
||||||
slicePush(c,
|
slicePush(c,
|
||||||
ceilingDivide(firstValue->type.size(vm::TargetBytesPerWord),
|
ceilingDivide(firstValue->type.size(c->targetInfo),
|
||||||
vm::TargetBytesPerWord),
|
c->targetInfo.pointerSize),
|
||||||
secondValue,
|
secondValue,
|
||||||
stackBase,
|
stackBase,
|
||||||
slice);
|
slice);
|
||||||
slicePush(c,
|
slicePush(c,
|
||||||
ceilingDivide(firstValue->type.size(vm::TargetBytesPerWord),
|
ceilingDivide(firstValue->type.size(c->targetInfo),
|
||||||
vm::TargetBytesPerWord),
|
c->targetInfo.pointerSize),
|
||||||
firstValue,
|
firstValue,
|
||||||
stackBase,
|
stackBase,
|
||||||
slice);
|
slice);
|
||||||
@ -1758,7 +1784,7 @@ class JumpEvent: public Event {
|
|||||||
{
|
{
|
||||||
bool thunk;
|
bool thunk;
|
||||||
OperandMask mask;
|
OperandMask mask;
|
||||||
c->arch->plan(op, vm::TargetBytesPerWord, mask, &thunk);
|
c->arch->plan(op, c->targetInfo.pointerSize, mask, &thunk);
|
||||||
|
|
||||||
assert(c, not thunk);
|
assert(c, not thunk);
|
||||||
|
|
||||||
@ -1771,7 +1797,7 @@ class JumpEvent: public Event {
|
|||||||
|
|
||||||
virtual void compile(Context* c) {
|
virtual void compile(Context* c) {
|
||||||
if (not this->isUnreachable()) {
|
if (not this->isUnreachable()) {
|
||||||
apply(c, op, vm::TargetBytesPerWord, address->source, address->source);
|
apply(c, op, c->targetInfo.pointerSize, address->source, address->source);
|
||||||
}
|
}
|
||||||
|
|
||||||
for (Read* r = reads; r; r = r->eventNext) {
|
for (Read* r = reads; r; r = r->eventNext) {
|
||||||
@ -1832,17 +1858,26 @@ class BoundsCheckEvent: public Event {
|
|||||||
if (constant->value->value() < 0) {
|
if (constant->value->value() < 0) {
|
||||||
lir::Constant handlerConstant(resolvedPromise(c, handler));
|
lir::Constant handlerConstant(resolvedPromise(c, handler));
|
||||||
a->apply(lir::Call,
|
a->apply(lir::Call,
|
||||||
OperandInfo(vm::TargetBytesPerWord, lir::ConstantOperand, &handlerConstant));
|
OperandInfo(c->targetInfo.pointerSize,
|
||||||
|
lir::ConstantOperand,
|
||||||
|
&handlerConstant));
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
outOfBoundsPromise = compiler::codePromise(c, static_cast<Promise*>(0));
|
outOfBoundsPromise = compiler::codePromise(c, static_cast<Promise*>(0));
|
||||||
|
|
||||||
ConstantSite zero(resolvedPromise(c, 0));
|
ConstantSite zero(resolvedPromise(c, 0));
|
||||||
ConstantSite oob(outOfBoundsPromise);
|
ConstantSite oob(outOfBoundsPromise);
|
||||||
apply(c, lir::JumpIfLess,
|
apply(c,
|
||||||
4, &zero, &zero,
|
lir::JumpIfLess,
|
||||||
4, index->source, index->source,
|
4,
|
||||||
vm::TargetBytesPerWord, &oob, &oob);
|
&zero,
|
||||||
|
&zero,
|
||||||
|
4,
|
||||||
|
index->source,
|
||||||
|
index->source,
|
||||||
|
c->targetInfo.pointerSize,
|
||||||
|
&oob,
|
||||||
|
&oob);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (constant == 0 or constant->value->value() >= 0) {
|
if (constant == 0 or constant->value->value() >= 0) {
|
||||||
@ -1853,15 +1888,22 @@ class BoundsCheckEvent: public Event {
|
|||||||
|
|
||||||
CodePromise* nextPromise = compiler::codePromise(c, static_cast<Promise*>(0));
|
CodePromise* nextPromise = compiler::codePromise(c, static_cast<Promise*>(0));
|
||||||
|
|
||||||
freezeSource(c, vm::TargetBytesPerWord, index);
|
freezeSource(c, c->targetInfo.pointerSize, index);
|
||||||
|
|
||||||
ConstantSite next(nextPromise);
|
ConstantSite next(nextPromise);
|
||||||
apply(c, lir::JumpIfGreater,
|
apply(c,
|
||||||
4, index->source,
|
lir::JumpIfGreater,
|
||||||
index->source, 4, &length,
|
4,
|
||||||
&length, vm::TargetBytesPerWord, &next, &next);
|
index->source,
|
||||||
|
index->source,
|
||||||
|
4,
|
||||||
|
&length,
|
||||||
|
&length,
|
||||||
|
c->targetInfo.pointerSize,
|
||||||
|
&next,
|
||||||
|
&next);
|
||||||
|
|
||||||
thawSource(c, vm::TargetBytesPerWord, index);
|
thawSource(c, c->targetInfo.pointerSize, index);
|
||||||
|
|
||||||
if (constant == 0) {
|
if (constant == 0) {
|
||||||
outOfBoundsPromise->offset = a->offset();
|
outOfBoundsPromise->offset = a->offset();
|
||||||
@ -1869,7 +1911,9 @@ class BoundsCheckEvent: public Event {
|
|||||||
|
|
||||||
lir::Constant handlerConstant(resolvedPromise(c, handler));
|
lir::Constant handlerConstant(resolvedPromise(c, handler));
|
||||||
a->apply(lir::Call,
|
a->apply(lir::Call,
|
||||||
OperandInfo(vm::TargetBytesPerWord, lir::ConstantOperand, &handlerConstant));
|
OperandInfo(c->targetInfo.pointerSize,
|
||||||
|
lir::ConstantOperand,
|
||||||
|
&handlerConstant));
|
||||||
|
|
||||||
nextPromise->offset = a->offset();
|
nextPromise->offset = a->offset();
|
||||||
}
|
}
|
||||||
|
@ -45,16 +45,18 @@ int frameIndex(Context* c, int localIndex) {
|
|||||||
unsigned frameIndexToOffset(Context* c, unsigned frameIndex) {
|
unsigned frameIndexToOffset(Context* c, unsigned frameIndex) {
|
||||||
assert(c, frameIndex < totalFrameSize(c));
|
assert(c, frameIndex < totalFrameSize(c));
|
||||||
|
|
||||||
return (frameIndex + c->arch->frameFooterSize()) * vm::TargetBytesPerWord;
|
return (frameIndex + c->arch->frameFooterSize()) * c->targetInfo.pointerSize;
|
||||||
}
|
}
|
||||||
|
|
||||||
unsigned offsetToFrameIndex(Context* c, unsigned offset) {
|
unsigned offsetToFrameIndex(Context* c, unsigned offset) {
|
||||||
assert(c, static_cast<int>
|
assert(c,
|
||||||
((offset / vm::TargetBytesPerWord) - c->arch->frameFooterSize()) >= 0);
|
static_cast<int>((offset / c->targetInfo.pointerSize)
|
||||||
assert(c, ((offset / vm::TargetBytesPerWord) - c->arch->frameFooterSize())
|
- c->arch->frameFooterSize()) >= 0);
|
||||||
|
assert(c,
|
||||||
|
((offset / c->targetInfo.pointerSize) - c->arch->frameFooterSize())
|
||||||
< totalFrameSize(c));
|
< totalFrameSize(c));
|
||||||
|
|
||||||
return (offset / vm::TargetBytesPerWord) - c->arch->frameFooterSize();
|
return (offset / c->targetInfo.pointerSize) - c->arch->frameFooterSize();
|
||||||
}
|
}
|
||||||
|
|
||||||
unsigned frameBase(Context* c) {
|
unsigned frameBase(Context* c) {
|
||||||
|
@ -90,9 +90,10 @@ class PoolPromise: public Promise {
|
|||||||
|
|
||||||
virtual int64_t value() {
|
virtual int64_t value() {
|
||||||
if (resolved()) {
|
if (resolved()) {
|
||||||
return reinterpret_cast<int64_t>
|
return reinterpret_cast<int64_t>(
|
||||||
(c->machineCode + vm::pad(c->machineCodeSize, vm::TargetBytesPerWord)
|
c->machineCode
|
||||||
+ (key * vm::TargetBytesPerWord));
|
+ vm::pad(c->machineCodeSize, c->targetInfo.pointerSize)
|
||||||
|
+ (key * c->targetInfo.pointerSize));
|
||||||
}
|
}
|
||||||
|
|
||||||
abort(c);
|
abort(c);
|
||||||
|
@ -52,7 +52,7 @@ SiteIterator::SiteIterator(Context* c, Value* v, bool includeBuddies,
|
|||||||
Site** SiteIterator::findNext(Site** p) {
|
Site** SiteIterator::findNext(Site** p) {
|
||||||
while (true) {
|
while (true) {
|
||||||
if (*p) {
|
if (*p) {
|
||||||
if (pass == 0 or (*p)->registerSize(c) > vm::TargetBytesPerWord) {
|
if (pass == 0 or (*p)->registerSize(c) > c->targetInfo.pointerSize) {
|
||||||
return p;
|
return p;
|
||||||
} else {
|
} else {
|
||||||
p = &((*p)->next);
|
p = &((*p)->next);
|
||||||
@ -103,14 +103,11 @@ void SiteIterator::remove(Context* c) {
|
|||||||
previous = 0;
|
previous = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
unsigned Site::registerSize(Context* c)
|
||||||
|
{
|
||||||
unsigned Site::registerSize(Context*) {
|
return c->targetInfo.pointerSize;
|
||||||
return vm::TargetBytesPerWord;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
Site* constantSite(Context* c, Promise* value) {
|
Site* constantSite(Context* c, Promise* value) {
|
||||||
return new(c->zone) ConstantSite(value);
|
return new(c->zone) ConstantSite(value);
|
||||||
}
|
}
|
||||||
@ -250,7 +247,7 @@ bool RegisterSite::matchNextWord(Context* c, Site* s, unsigned) {
|
|||||||
|
|
||||||
RegisterSite* rs = static_cast<RegisterSite*>(s);
|
RegisterSite* rs = static_cast<RegisterSite*>(s);
|
||||||
unsigned size = rs->registerSize(c);
|
unsigned size = rs->registerSize(c);
|
||||||
if (size > vm::TargetBytesPerWord) {
|
if (size > c->targetInfo.pointerSize) {
|
||||||
assert(c, number != lir::NoRegister);
|
assert(c, number != lir::NoRegister);
|
||||||
return number == rs->number;
|
return number == rs->number;
|
||||||
} else {
|
} else {
|
||||||
@ -352,7 +349,7 @@ SiteMask RegisterSite::mask(Context* c UNUSED) {
|
|||||||
SiteMask RegisterSite::nextWordMask(Context* c, unsigned) {
|
SiteMask RegisterSite::nextWordMask(Context* c, unsigned) {
|
||||||
assert(c, number != lir::NoRegister);
|
assert(c, number != lir::NoRegister);
|
||||||
|
|
||||||
if (registerSize(c) > vm::TargetBytesPerWord) {
|
if (registerSize(c) > c->targetInfo.pointerSize) {
|
||||||
return SiteMask
|
return SiteMask
|
||||||
(1 << lir::RegisterOperand, number, NoFrameIndex);
|
(1 << lir::RegisterOperand, number, NoFrameIndex);
|
||||||
} else {
|
} else {
|
||||||
@ -367,7 +364,7 @@ unsigned RegisterSite::registerSize(Context* c) {
|
|||||||
if ((1 << number) & c->regFile->floatRegisters.mask) {
|
if ((1 << number) & c->regFile->floatRegisters.mask) {
|
||||||
return c->arch->floatRegisterSize();
|
return c->arch->floatRegisterSize();
|
||||||
} else {
|
} else {
|
||||||
return vm::TargetBytesPerWord;
|
return c->targetInfo.pointerSize;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -469,12 +466,15 @@ bool MemorySite::matchNextWord(Context* c, Site* s, unsigned index) {
|
|||||||
if (s->type(c) == lir::MemoryOperand) {
|
if (s->type(c) == lir::MemoryOperand) {
|
||||||
MemorySite* ms = static_cast<MemorySite*>(s);
|
MemorySite* ms = static_cast<MemorySite*>(s);
|
||||||
return ms->base == this->base
|
return ms->base == this->base
|
||||||
and ((index == 1 and ms->offset == static_cast<int>
|
and ((index == 1
|
||||||
(this->offset + vm::TargetBytesPerWord))
|
and ms->offset
|
||||||
or (index == 0 and this->offset == static_cast<int>
|
== static_cast<int>(this->offset
|
||||||
(ms->offset + vm::TargetBytesPerWord)))
|
+ c->targetInfo.pointerSize))
|
||||||
and ms->index == this->index
|
or (index == 0
|
||||||
and ms->scale == this->scale;
|
and this->offset
|
||||||
|
== static_cast<int>(ms->offset
|
||||||
|
+ c->targetInfo.pointerSize)))
|
||||||
|
and ms->index == this->index and ms->scale == this->scale;
|
||||||
} else {
|
} else {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@ -551,10 +551,11 @@ void MemorySite::asAssemblerOperand(Context* c UNUSED, Site* high UNUSED,
|
|||||||
lir::Operand* result)
|
lir::Operand* result)
|
||||||
{
|
{
|
||||||
// todo: endianness?
|
// todo: endianness?
|
||||||
assert(c, high == this
|
assert(c,
|
||||||
|
high == this
|
||||||
or (static_cast<MemorySite*>(high)->base == base
|
or (static_cast<MemorySite*>(high)->base == base
|
||||||
and static_cast<MemorySite*>(high)->offset
|
and static_cast<MemorySite*>(high)->offset
|
||||||
== static_cast<int>(offset + vm::TargetBytesPerWord)
|
== static_cast<int>(offset + c->targetInfo.pointerSize)
|
||||||
and static_cast<MemorySite*>(high)->index == index
|
and static_cast<MemorySite*>(high)->index == index
|
||||||
and static_cast<MemorySite*>(high)->scale == scale));
|
and static_cast<MemorySite*>(high)->scale == scale));
|
||||||
|
|
||||||
@ -569,7 +570,8 @@ Site* MemorySite::copy(Context* c) {
|
|||||||
|
|
||||||
Site* MemorySite::copyHalf(Context* c, bool add) {
|
Site* MemorySite::copyHalf(Context* c, bool add) {
|
||||||
if (add) {
|
if (add) {
|
||||||
return memorySite(c, base, offset + vm::TargetBytesPerWord, index, scale);
|
return memorySite(
|
||||||
|
c, base, offset + c->targetInfo.pointerSize, index, scale);
|
||||||
} else {
|
} else {
|
||||||
return copy(c);
|
return copy(c);
|
||||||
}
|
}
|
||||||
@ -584,10 +586,13 @@ Site* MemorySite::copyHigh(Context* c) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
Site* MemorySite::makeNextWord(Context* c, unsigned index) {
|
Site* MemorySite::makeNextWord(Context* c, unsigned index) {
|
||||||
return memorySite
|
return memorySite(c,
|
||||||
(c, base, offset + ((index == 1) xor c->arch->bigEndian()
|
base,
|
||||||
? vm::TargetBytesPerWord : -vm::TargetBytesPerWord),
|
offset + ((index == 1) xor c->arch->bigEndian()
|
||||||
this->index, scale);
|
? c->targetInfo.pointerSize
|
||||||
|
: -c->targetInfo.pointerSize),
|
||||||
|
this->index,
|
||||||
|
scale);
|
||||||
}
|
}
|
||||||
|
|
||||||
SiteMask MemorySite::mask(Context* c) {
|
SiteMask MemorySite::mask(Context* c) {
|
||||||
|
@ -115,7 +115,8 @@ bool Value::uniqueSite(Context* c, Site* s) {
|
|||||||
if (it.hasMore()) {
|
if (it.hasMore()) {
|
||||||
// the site is not this word's only site, but if the site is
|
// the site is not this word's only site, but if the site is
|
||||||
// shared with the next word, it may be that word's only site
|
// shared with the next word, it may be that word's only site
|
||||||
if (this->nextWord != this and s->registerSize(c) > vm::TargetBytesPerWord) {
|
if (this->nextWord != this
|
||||||
|
and s->registerSize(c) > c->targetInfo.pointerSize) {
|
||||||
SiteIterator nit(c, this->nextWord);
|
SiteIterator nit(c, this->nextWord);
|
||||||
Site* p = nit.next();
|
Site* p = nit.next();
|
||||||
if (nit.hasMore()) {
|
if (nit.hasMore()) {
|
||||||
|
@ -180,6 +180,11 @@ class MyArchitecture: public Architecture {
|
|||||||
return 3;
|
return 3;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
virtual ir::TargetInfo targetInfo()
|
||||||
|
{
|
||||||
|
return ir::TargetInfo(TargetBytesPerWord);
|
||||||
|
}
|
||||||
|
|
||||||
virtual bool bigEndian() {
|
virtual bool bigEndian() {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
@ -204,6 +204,11 @@ class MyArchitecture: public Architecture {
|
|||||||
return rdx;
|
return rdx;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
virtual ir::TargetInfo targetInfo()
|
||||||
|
{
|
||||||
|
return ir::TargetInfo(TargetBytesPerWord);
|
||||||
|
}
|
||||||
|
|
||||||
virtual bool bigEndian() {
|
virtual bool bigEndian() {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
@ -446,12 +446,6 @@ int printInstruction(uint8_t* code, unsigned& ip, const char* prefix)
|
|||||||
fprintf(
|
fprintf(
|
||||||
stderr, "lookupswitch default: %d pairCount: %d", default_, pairCount);
|
stderr, "lookupswitch default: %d pairCount: %d", default_, pairCount);
|
||||||
|
|
||||||
bool good = true;
|
|
||||||
if (pairCount >= 1000) {
|
|
||||||
pairCount = 1;
|
|
||||||
good = false;
|
|
||||||
}
|
|
||||||
|
|
||||||
for (int i = 0; i < pairCount; i++) {
|
for (int i = 0; i < pairCount; i++) {
|
||||||
int32_t k = read32(code, ip);
|
int32_t k = read32(code, ip);
|
||||||
int32_t d = read32(code, ip) + startIp;
|
int32_t d = read32(code, ip) + startIp;
|
||||||
@ -459,8 +453,6 @@ int printInstruction(uint8_t* code, unsigned& ip, const char* prefix)
|
|||||||
}
|
}
|
||||||
fprintf(stderr, "\n");
|
fprintf(stderr, "\n");
|
||||||
fflush(stderr);
|
fflush(stderr);
|
||||||
if (!good)
|
|
||||||
asm("int3");
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user