mirror of
https://github.com/corda/corda.git
synced 2025-01-06 05:04:20 +00:00
move TranslateEvent out of compiler.cpp
This commit is contained in:
parent
8a61b38a01
commit
70f9209a6e
@ -1595,119 +1595,6 @@ register_(Context* c, int number)
|
||||
return value(c, type, s, s);
|
||||
}
|
||||
|
||||
class TranslateEvent: public Event {
|
||||
public:
|
||||
TranslateEvent(Context* c, lir::BinaryOperation type, unsigned valueSize,
|
||||
Value* value, unsigned resultSize, Value* result,
|
||||
const SiteMask& valueLowMask,
|
||||
const SiteMask& valueHighMask):
|
||||
Event(c), type(type), valueSize(valueSize), resultSize(resultSize),
|
||||
value(value), result(result)
|
||||
{
|
||||
bool condensed = c->arch->alwaysCondensed(type);
|
||||
|
||||
if (resultSize > TargetBytesPerWord) {
|
||||
result->grow(c);
|
||||
}
|
||||
|
||||
this->addReads(c, value, valueSize, valueLowMask, condensed ? result : 0,
|
||||
valueHighMask, condensed ? result->nextWord : 0);
|
||||
}
|
||||
|
||||
virtual const char* name() {
|
||||
return "TranslateEvent";
|
||||
}
|
||||
|
||||
virtual void compile(Context* c) {
|
||||
assert(c, value->source->type(c) == value->nextWord->source->type(c));
|
||||
|
||||
uint8_t bTypeMask;
|
||||
uint64_t bRegisterMask;
|
||||
|
||||
c->arch->planDestination
|
||||
(type,
|
||||
valueSize,
|
||||
1 << value->source->type(c),
|
||||
(static_cast<uint64_t>(value->nextWord->source->registerMask(c)) << 32)
|
||||
| static_cast<uint64_t>(value->source->registerMask(c)),
|
||||
resultSize,
|
||||
&bTypeMask,
|
||||
&bRegisterMask);
|
||||
|
||||
SiteMask resultLowMask(bTypeMask, bRegisterMask, AnyFrameIndex);
|
||||
SiteMask resultHighMask(bTypeMask, bRegisterMask >> 32, AnyFrameIndex);
|
||||
|
||||
Site* low = getTarget(c, value, result, resultLowMask);
|
||||
unsigned lowSize = low->registerSize(c);
|
||||
Site* high
|
||||
= (resultSize > lowSize
|
||||
? getTarget(c, value->nextWord, result->nextWord, resultHighMask)
|
||||
: low);
|
||||
|
||||
apply(c, type, valueSize, value->source, value->nextWord->source,
|
||||
resultSize, low, high);
|
||||
|
||||
for (Read* r = reads; r; r = r->eventNext) {
|
||||
popRead(c, this, r->value);
|
||||
}
|
||||
|
||||
low->thaw(c, value);
|
||||
if (resultSize > lowSize) {
|
||||
high->thaw(c, value->nextWord);
|
||||
}
|
||||
|
||||
if (live(c, result)) {
|
||||
result->addSite(c, low);
|
||||
if (resultSize > lowSize and live(c, result->nextWord)) {
|
||||
result->nextWord->addSite(c, high);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
lir::BinaryOperation type;
|
||||
unsigned valueSize;
|
||||
unsigned resultSize;
|
||||
Value* value;
|
||||
Value* result;
|
||||
Read* resultRead;
|
||||
SiteMask resultLowMask;
|
||||
SiteMask resultHighMask;
|
||||
};
|
||||
|
||||
void
|
||||
appendTranslate(Context* c, lir::BinaryOperation type, unsigned firstSize,
|
||||
Value* first, unsigned resultSize, Value* result)
|
||||
{
|
||||
bool thunk;
|
||||
uint8_t firstTypeMask;
|
||||
uint64_t firstRegisterMask;
|
||||
|
||||
c->arch->planSource(type, firstSize, &firstTypeMask, &firstRegisterMask,
|
||||
resultSize, &thunk);
|
||||
|
||||
if (thunk) {
|
||||
Stack* oldStack = c->stack;
|
||||
|
||||
compiler::push(c, ceilingDivide(firstSize, TargetBytesPerWord), first);
|
||||
|
||||
Stack* argumentStack = c->stack;
|
||||
c->stack = oldStack;
|
||||
|
||||
appendCall
|
||||
(c, value
|
||||
(c, lir::ValueGeneral, constantSite
|
||||
(c, c->client->getThunk(type, firstSize, resultSize))),
|
||||
0, 0, result, resultSize, argumentStack,
|
||||
ceilingDivide(firstSize, TargetBytesPerWord), 0);
|
||||
} else {
|
||||
append(c, new(c->zone)
|
||||
TranslateEvent
|
||||
(c, type, firstSize, first, resultSize, result,
|
||||
SiteMask(firstTypeMask, firstRegisterMask, AnyFrameIndex),
|
||||
SiteMask(firstTypeMask, firstRegisterMask >> 32, AnyFrameIndex)));
|
||||
}
|
||||
}
|
||||
|
||||
class OperationEvent: public Event {
|
||||
public:
|
||||
OperationEvent(Context* c, lir::Operation op):
|
||||
|
@ -932,6 +932,119 @@ appendCombine(Context* c, lir::TernaryOperation type,
|
||||
}
|
||||
}
|
||||
|
||||
class TranslateEvent: public Event {
|
||||
public:
|
||||
TranslateEvent(Context* c, lir::BinaryOperation type, unsigned valueSize,
|
||||
Value* value, unsigned resultSize, Value* result,
|
||||
const SiteMask& valueLowMask,
|
||||
const SiteMask& valueHighMask):
|
||||
Event(c), type(type), valueSize(valueSize), resultSize(resultSize),
|
||||
value(value), result(result)
|
||||
{
|
||||
bool condensed = c->arch->alwaysCondensed(type);
|
||||
|
||||
if (resultSize > vm::TargetBytesPerWord) {
|
||||
result->grow(c);
|
||||
}
|
||||
|
||||
this->addReads(c, value, valueSize, valueLowMask, condensed ? result : 0,
|
||||
valueHighMask, condensed ? result->nextWord : 0);
|
||||
}
|
||||
|
||||
virtual const char* name() {
|
||||
return "TranslateEvent";
|
||||
}
|
||||
|
||||
virtual void compile(Context* c) {
|
||||
assert(c, value->source->type(c) == value->nextWord->source->type(c));
|
||||
|
||||
uint8_t bTypeMask;
|
||||
uint64_t bRegisterMask;
|
||||
|
||||
c->arch->planDestination
|
||||
(type,
|
||||
valueSize,
|
||||
1 << value->source->type(c),
|
||||
(static_cast<uint64_t>(value->nextWord->source->registerMask(c)) << 32)
|
||||
| static_cast<uint64_t>(value->source->registerMask(c)),
|
||||
resultSize,
|
||||
&bTypeMask,
|
||||
&bRegisterMask);
|
||||
|
||||
SiteMask resultLowMask(bTypeMask, bRegisterMask, AnyFrameIndex);
|
||||
SiteMask resultHighMask(bTypeMask, bRegisterMask >> 32, AnyFrameIndex);
|
||||
|
||||
Site* low = getTarget(c, value, result, resultLowMask);
|
||||
unsigned lowSize = low->registerSize(c);
|
||||
Site* high
|
||||
= (resultSize > lowSize
|
||||
? getTarget(c, value->nextWord, result->nextWord, resultHighMask)
|
||||
: low);
|
||||
|
||||
apply(c, type, valueSize, value->source, value->nextWord->source,
|
||||
resultSize, low, high);
|
||||
|
||||
for (Read* r = reads; r; r = r->eventNext) {
|
||||
popRead(c, this, r->value);
|
||||
}
|
||||
|
||||
low->thaw(c, value);
|
||||
if (resultSize > lowSize) {
|
||||
high->thaw(c, value->nextWord);
|
||||
}
|
||||
|
||||
if (live(c, result)) {
|
||||
result->addSite(c, low);
|
||||
if (resultSize > lowSize and live(c, result->nextWord)) {
|
||||
result->nextWord->addSite(c, high);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
lir::BinaryOperation type;
|
||||
unsigned valueSize;
|
||||
unsigned resultSize;
|
||||
Value* value;
|
||||
Value* result;
|
||||
Read* resultRead;
|
||||
SiteMask resultLowMask;
|
||||
SiteMask resultHighMask;
|
||||
};
|
||||
|
||||
void
|
||||
appendTranslate(Context* c, lir::BinaryOperation type, unsigned firstSize,
|
||||
Value* first, unsigned resultSize, Value* result)
|
||||
{
|
||||
bool thunk;
|
||||
uint8_t firstTypeMask;
|
||||
uint64_t firstRegisterMask;
|
||||
|
||||
c->arch->planSource(type, firstSize, &firstTypeMask, &firstRegisterMask,
|
||||
resultSize, &thunk);
|
||||
|
||||
if (thunk) {
|
||||
Stack* oldStack = c->stack;
|
||||
|
||||
compiler::push(c, vm::ceilingDivide(firstSize, vm::TargetBytesPerWord), first);
|
||||
|
||||
Stack* argumentStack = c->stack;
|
||||
c->stack = oldStack;
|
||||
|
||||
appendCall
|
||||
(c, value
|
||||
(c, lir::ValueGeneral, constantSite
|
||||
(c, c->client->getThunk(type, firstSize, resultSize))),
|
||||
0, 0, result, resultSize, argumentStack,
|
||||
vm::ceilingDivide(firstSize, vm::TargetBytesPerWord), 0);
|
||||
} else {
|
||||
append(c, new(c->zone)
|
||||
TranslateEvent
|
||||
(c, type, firstSize, first, resultSize, result,
|
||||
SiteMask(firstTypeMask, firstRegisterMask, AnyFrameIndex),
|
||||
SiteMask(firstTypeMask, firstRegisterMask >> 32, AnyFrameIndex)));
|
||||
}
|
||||
}
|
||||
|
||||
} // namespace compiler
|
||||
} // namespace codegen
|
||||
} // namespace avian
|
||||
|
@ -128,6 +128,10 @@ appendCombine(Context* c, lir::TernaryOperation type,
|
||||
unsigned secondSize, Value* second,
|
||||
unsigned resultSize, Value* result);
|
||||
|
||||
void
|
||||
appendTranslate(Context* c, lir::BinaryOperation type, unsigned firstSize,
|
||||
Value* first, unsigned resultSize, Value* result);
|
||||
|
||||
} // namespace compiler
|
||||
} // namespace codegen
|
||||
} // namespace avian
|
||||
|
Loading…
Reference in New Issue
Block a user