remove redundant size parameters to appendCombine and appendTranslate

This commit is contained in:
Joshua Warner 2014-05-03 21:02:43 -06:00 committed by Joshua Warner
parent d67820054e
commit 148d35bab5
3 changed files with 73 additions and 90 deletions

View File

@ -2668,11 +2668,8 @@ class MyCompiler: public Compiler {
appendCombine(&c, appendCombine(&c,
op, op,
a->type.size(),
static_cast<Value*>(a), static_cast<Value*>(a),
b->type.size(),
static_cast<Value*>(b), static_cast<Value*>(b),
type.size(),
result); result);
return result; return result;
} }
@ -2685,7 +2682,7 @@ class MyCompiler: public Compiler {
and isFloatValue(a))); and isFloatValue(a)));
Value* result = value(&c, a->type); Value* result = value(&c, a->type);
appendTranslate( appendTranslate(
&c, op, a->type.size(), static_cast<Value*>(a), a->type.size(), result); &c, op, static_cast<Value*>(a), result);
return result; return result;
} }
@ -2696,9 +2693,7 @@ class MyCompiler: public Compiler {
Value* result = value(&c, resType); Value* result = value(&c, resType);
appendTranslate(&c, appendTranslate(&c,
lir::Float2Float, lir::Float2Float,
a->type.size(),
static_cast<Value*>(a), static_cast<Value*>(a),
resType.size(),
result); result);
return result; return result;
} }
@ -2710,9 +2705,7 @@ class MyCompiler: public Compiler {
Value* result = value(&c, resType); Value* result = value(&c, resType);
appendTranslate(&c, appendTranslate(&c,
lir::Float2Int, lir::Float2Int,
a->type.size(),
static_cast<Value*>(a), static_cast<Value*>(a),
resType.size(),
result); result);
return result; return result;
} }
@ -2724,9 +2717,7 @@ class MyCompiler: public Compiler {
Value* result = value(&c, resType); Value* result = value(&c, resType);
appendTranslate(&c, appendTranslate(&c,
lir::Int2Float, lir::Int2Float,
a->type.size(),
static_cast<Value*>(a), static_cast<Value*>(a),
resType.size(),
result); result);
return result; return result;
} }

View File

@ -901,26 +901,26 @@ Site* getTarget(Context* c, Value* value, Value* result, const SiteMask& resultM
class CombineEvent: public Event { class CombineEvent: public Event {
public: public:
CombineEvent(Context* c, lir::TernaryOperation type, CombineEvent(Context* c, lir::TernaryOperation type,
unsigned firstSize, Value* firstValue, Value* firstValue,
unsigned secondSize, Value* secondValue, Value* secondValue,
unsigned resultSize, Value* resultValue, Value* resultValue,
const SiteMask& firstLowMask, const SiteMask& firstLowMask,
const SiteMask& firstHighMask, const SiteMask& firstHighMask,
const SiteMask& secondLowMask, const SiteMask& secondLowMask,
const SiteMask& secondHighMask): const SiteMask& secondHighMask):
Event(c), type(type), firstSize(firstSize), firstValue(firstValue), Event(c), type(type), firstValue(firstValue),
secondSize(secondSize), secondValue(secondValue), resultSize(resultSize), secondValue(secondValue),
resultValue(resultValue) resultValue(resultValue)
{ {
this->addReads(c, firstValue, firstSize, firstLowMask, firstHighMask); this->addReads(c, firstValue, firstValue->type.size(), firstLowMask, firstHighMask);
if (resultSize > vm::TargetBytesPerWord) { if (resultValue->type.size() > vm::TargetBytesPerWord) {
resultValue->grow(c); resultValue->grow(c);
} }
bool condensed = c->arch->alwaysCondensed(type); bool condensed = c->arch->alwaysCondensed(type);
this->addReads(c, secondValue, secondSize, this->addReads(c, secondValue, secondValue->type.size(),
secondLowMask, condensed ? resultValue : 0, secondLowMask, condensed ? resultValue : 0,
secondHighMask, condensed ? resultValue->nextWord : 0); secondHighMask, condensed ? resultValue->nextWord : 0);
} }
@ -941,23 +941,23 @@ 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, firstSize, firstValue); freezeSource(c, firstValue->type.size(), firstValue);
OperandMask cMask; OperandMask cMask;
c->arch->planDestination c->arch->planDestination
(type, (type,
firstSize, firstValue->type.size(),
OperandMask( OperandMask(
1 << firstValue->source->type(c), 1 << firstValue->source->type(c),
(static_cast<uint64_t>(firstValue->nextWord->source->registerMask(c)) << 32) (static_cast<uint64_t>(firstValue->nextWord->source->registerMask(c)) << 32)
| static_cast<uint64_t>(firstValue->source->registerMask(c))), | static_cast<uint64_t>(firstValue->source->registerMask(c))),
secondSize, secondValue->type.size(),
OperandMask( OperandMask(
1 << secondValue->source->type(c), 1 << secondValue->source->type(c),
(static_cast<uint64_t>(secondValue->nextWord->source->registerMask(c)) << 32) (static_cast<uint64_t>(secondValue->nextWord->source->registerMask(c)) << 32)
| static_cast<uint64_t>(secondValue->source->registerMask(c))), | static_cast<uint64_t>(secondValue->source->registerMask(c))),
resultSize, resultValue->type.size(),
cMask); cMask);
SiteMask resultLowMask = SiteMask::lowPart(cMask); SiteMask resultLowMask = SiteMask::lowPart(cMask);
@ -966,7 +966,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 Site* high
= (resultSize > lowSize = (resultValue->type.size() > lowSize
? getTarget(c, secondValue->nextWord, resultValue->nextWord, resultHighMask) ? getTarget(c, secondValue->nextWord, resultValue->nextWord, resultHighMask)
: low); : low);
@ -976,75 +976,72 @@ class CombineEvent: public Event {
// resultValue, resultValue->nextWord); // resultValue, resultValue->nextWord);
apply(c, type, apply(c, type,
firstSize, firstValue->source, firstValue->nextWord->source, firstValue->type.size(), firstValue->source, firstValue->nextWord->source,
secondSize, secondValue->source, secondValue->nextWord->source, secondValue->type.size(), secondValue->source, secondValue->nextWord->source,
resultSize, low, high); resultValue->type.size(), low, high);
thawSource(c, firstSize, firstValue); thawSource(c, firstValue->type.size(), 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 (resultSize > lowSize) { if (resultValue->type.size() > 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 (resultSize > lowSize and live(c, resultValue->nextWord)) { if (resultValue->type.size() > lowSize and live(c, resultValue->nextWord)) {
resultValue->nextWord->addSite(c, high); resultValue->nextWord->addSite(c, high);
} }
} }
} }
lir::TernaryOperation type; lir::TernaryOperation type;
unsigned firstSize;
Value* firstValue; Value* firstValue;
unsigned secondSize;
Value* secondValue; Value* secondValue;
unsigned resultSize;
Value* resultValue; Value* resultValue;
}; };
void appendCombine(Context* c, void appendCombine(Context* c,
lir::TernaryOperation op, lir::TernaryOperation op,
unsigned firstSize,
Value* firstValue, Value* firstValue,
unsigned secondSize,
Value* secondValue, Value* secondValue,
unsigned resultSize,
Value* resultValue) Value* resultValue)
{ {
assert(c, firstSize == firstValue->type.size());
assert(c, secondSize == secondValue->type.size());
assert(c, resultSize == resultValue->type.size());
bool thunk; bool thunk;
OperandMask firstMask; OperandMask firstMask;
OperandMask secondMask; OperandMask secondMask;
c->arch->planSource(op,
c->arch->planSource( firstValue->type.size(),
op, firstSize, firstMask, secondSize, secondMask, resultSize, &thunk); firstMask,
secondValue->type.size(),
secondMask,
resultValue->type.size(),
&thunk);
if (thunk) { if (thunk) {
FixedSliceStack<ir::Value*, 6> slice; FixedSliceStack<ir::Value*, 6> slice;
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, firstSize, resultSize, &threadParameter); firstValue->type.size(),
resultValue->type.size(),
&threadParameter);
unsigned stackSize = ceilingDivide(secondSize, vm::TargetBytesPerWord) unsigned stackSize = ceilingDivide(secondValue->type.size(), vm::TargetBytesPerWord)
+ ceilingDivide(firstSize, vm::TargetBytesPerWord); + ceilingDivide(firstValue->type.size(), vm::TargetBytesPerWord);
pushSlice(c, pushSlice(c,
ceilingDivide(secondSize, vm::TargetBytesPerWord), ceilingDivide(secondValue->type.size(), vm::TargetBytesPerWord),
secondValue, secondValue,
stackBase, stackBase,
slice); slice);
pushSlice(c, pushSlice(c,
ceilingDivide(firstSize, vm::TargetBytesPerWord), ceilingDivide(firstValue->type.size(), vm::TargetBytesPerWord),
firstValue, firstValue,
stackBase, stackBase,
slice); slice);
@ -1063,17 +1060,14 @@ void appendCombine(Context* c,
0, 0,
0, 0,
resultValue, resultValue,
resultSize, resultValue->type.size(),
slice); slice);
} else { } else {
append(c, append(c,
new (c->zone) CombineEvent(c, new (c->zone) CombineEvent(c,
op, op,
firstSize,
firstValue, firstValue,
secondSize,
secondValue, secondValue,
resultSize,
resultValue, resultValue,
SiteMask::lowPart(firstMask), SiteMask::lowPart(firstMask),
SiteMask::highPart(firstMask), SiteMask::highPart(firstMask),
@ -1084,20 +1078,20 @@ void appendCombine(Context* c,
class TranslateEvent: public Event { class TranslateEvent: public Event {
public: public:
TranslateEvent(Context* c, lir::BinaryOperation type, unsigned valueSize, TranslateEvent(Context* c, lir::BinaryOperation type,
Value* value, unsigned resultSize, Value* resultValue, Value* firstValue, Value* resultValue,
const SiteMask& valueLowMask, const SiteMask& valueLowMask,
const SiteMask& valueHighMask): const SiteMask& valueHighMask):
Event(c), type(type), valueSize(valueSize), resultSize(resultSize), Event(c), type(type),
value(value), resultValue(resultValue) firstValue(firstValue), resultValue(resultValue)
{ {
bool condensed = c->arch->alwaysCondensed(type); bool condensed = c->arch->alwaysCondensed(type);
if (resultSize > vm::TargetBytesPerWord) { if (resultValue->type.size() > vm::TargetBytesPerWord) {
resultValue->grow(c); resultValue->grow(c);
} }
this->addReads(c, value, valueSize, valueLowMask, condensed ? resultValue : 0, this->addReads(c, firstValue, firstValue->type.size(), valueLowMask, condensed ? resultValue : 0,
valueHighMask, condensed ? resultValue->nextWord : 0); valueHighMask, condensed ? resultValue->nextWord : 0);
} }
@ -1106,54 +1100,52 @@ class TranslateEvent: public Event {
} }
virtual void compile(Context* c) { virtual void compile(Context* c) {
assert(c, value->source->type(c) == value->nextWord->source->type(c)); assert(c, firstValue->source->type(c) == firstValue->nextWord->source->type(c));
OperandMask bMask; OperandMask bMask;
c->arch->planDestination c->arch->planDestination
(type, (type,
valueSize, firstValue->type.size(),
OperandMask( OperandMask(
1 << value->source->type(c), 1 << firstValue->source->type(c),
(static_cast<uint64_t>(value->nextWord->source->registerMask(c)) << 32) (static_cast<uint64_t>(firstValue->nextWord->source->registerMask(c)) << 32)
| static_cast<uint64_t>(value->source->registerMask(c))), | static_cast<uint64_t>(firstValue->source->registerMask(c))),
resultSize, resultValue->type.size(),
bMask); bMask);
SiteMask resultLowMask = SiteMask::lowPart(bMask); SiteMask resultLowMask = SiteMask::lowPart(bMask);
SiteMask resultHighMask = SiteMask::highPart(bMask); SiteMask resultHighMask = SiteMask::highPart(bMask);
Site* low = getTarget(c, value, resultValue, resultLowMask); Site* low = getTarget(c, firstValue, resultValue, resultLowMask);
unsigned lowSize = low->registerSize(c); unsigned lowSize = low->registerSize(c);
Site* high Site* high
= (resultSize > lowSize = (resultValue->type.size() > lowSize
? getTarget(c, value->nextWord, resultValue->nextWord, resultHighMask) ? getTarget(c, firstValue->nextWord, resultValue->nextWord, resultHighMask)
: low); : low);
apply(c, type, valueSize, value->source, value->nextWord->source, apply(c, type, firstValue->type.size(), firstValue->source, firstValue->nextWord->source,
resultSize, low, high); resultValue->type.size(), low, high);
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, value); low->thaw(c, firstValue);
if (resultSize > lowSize) { if (resultValue->type.size() > lowSize) {
high->thaw(c, value->nextWord); high->thaw(c, firstValue->nextWord);
} }
if (live(c, resultValue)) { if (live(c, resultValue)) {
resultValue->addSite(c, low); resultValue->addSite(c, low);
if (resultSize > lowSize and live(c, resultValue->nextWord)) { if (resultValue->type.size() > lowSize and live(c, resultValue->nextWord)) {
resultValue->nextWord->addSite(c, high); resultValue->nextWord->addSite(c, high);
} }
} }
} }
lir::BinaryOperation type; lir::BinaryOperation type;
unsigned valueSize; Value* firstValue;
unsigned resultSize;
Value* value;
Value* resultValue; Value* resultValue;
Read* resultRead; Read* resultRead;
SiteMask resultLowMask; SiteMask resultLowMask;
@ -1162,25 +1154,24 @@ class TranslateEvent: public Event {
void appendTranslate(Context* c, void appendTranslate(Context* c,
lir::BinaryOperation op, lir::BinaryOperation op,
unsigned firstSize,
Value* firstValue, Value* firstValue,
unsigned resultSize,
Value* resultValue) Value* resultValue)
{ {
assert(c, firstSize == firstValue->type.size()); assert(c, firstValue->type.size() == firstValue->type.size());
assert(c, resultSize == resultValue->type.size()); assert(c, resultValue->type.size() == resultValue->type.size());
bool thunk; bool thunk;
OperandMask first; OperandMask first;
c->arch->planSource(op, firstSize, first, resultSize, &thunk); c->arch->planSource(
op, firstValue->type.size(), first, resultValue->type.size(), &thunk);
if (thunk) { if (thunk) {
size_t stackBase = c->stack ? c->stack->index + 1 : 0; size_t stackBase = c->stack ? c->stack->index + 1 : 0;
FixedSliceStack<ir::Value*, 2> slice; FixedSliceStack<ir::Value*, 2> slice;
pushSlice(c, pushSlice(c,
ceilingDivide(firstSize, vm::TargetBytesPerWord), ceilingDivide(firstValue->type.size(), vm::TargetBytesPerWord),
firstValue, firstValue,
stackBase, stackBase,
slice); slice);
@ -1189,20 +1180,21 @@ void appendTranslate(Context* c,
c, c,
value(c, value(c,
ir::Type(ir::Type::Address, vm::TargetBytesPerWord), ir::Type(ir::Type::Address, vm::TargetBytesPerWord),
constantSite(c, c->client->getThunk(op, firstSize, resultSize))), constantSite(
c,
c->client->getThunk(
op, firstValue->type.size(), resultValue->type.size()))),
ir::NativeCallingConvention, ir::NativeCallingConvention,
0, 0,
0, 0,
resultValue, resultValue,
resultSize, resultValue->type.size(),
slice); slice);
} else { } else {
append(c, append(c,
new (c->zone) TranslateEvent(c, new (c->zone) TranslateEvent(c,
op, op,
firstSize,
firstValue, firstValue,
resultSize,
resultValue, resultValue,
SiteMask::lowPart(first), SiteMask::lowPart(first),
SiteMask::highPart(first))); SiteMask::highPart(first)));

View File

@ -131,13 +131,13 @@ appendMove(Context* c, lir::BinaryOperation type, unsigned srcSize,
void void
appendCombine(Context* c, lir::TernaryOperation type, appendCombine(Context* c, lir::TernaryOperation type,
unsigned firstSize, Value* first, Value* first,
unsigned secondSize, Value* second, Value* second,
unsigned resultSize, Value* result); Value* result);
void void
appendTranslate(Context* c, lir::BinaryOperation type, unsigned firstSize, appendTranslate(Context* c, lir::BinaryOperation type,
Value* first, unsigned resultSize, Value* result); Value* first, Value* result);
void void
appendOperation(Context* c, lir::Operation op); appendOperation(Context* c, lir::Operation op);