make BoundedRegisterMask a subclass of RegisterMask

This commit is contained in:
Joshua Warner 2014-12-05 12:27:33 -07:00
parent 6b889b1d78
commit a3ccc94cf5
6 changed files with 24 additions and 25 deletions

View File

@ -95,9 +95,8 @@ constexpr RegisterMask Register::operator | (Register o) const {
return RegisterMask(*this) | o;
}
class BoundedRegisterMask {
class BoundedRegisterMask : public RegisterMask {
public:
RegisterMask mask;
uint8_t start;
uint8_t limit;
@ -105,7 +104,7 @@ class BoundedRegisterMask {
static unsigned maskLimit(RegisterMask mask);
inline BoundedRegisterMask(RegisterMask mask)
: mask(mask), start(maskStart(mask)), limit(maskLimit(mask))
: RegisterMask(mask), start(maskStart(mask)), limit(maskLimit(mask))
{
}
};
@ -144,7 +143,7 @@ class RegisterIterator {
int r = index;
do {
index++;
} while (index < mask.limit && !(mask.mask.contains(Register(index))));
} while (index < mask.limit && !(mask.contains(Register(index))));
return Register(r);
}
};

View File

@ -515,14 +515,14 @@ void steal(Context* c, Resource* r, Value* thief)
SiteMask generalRegisterMask(Context* c)
{
return SiteMask(1 << (unsigned)lir::Operand::Type::RegisterPair,
c->regFile->generalRegisters.mask,
c->regFile->generalRegisters,
NoFrameIndex);
}
SiteMask generalRegisterOrConstantMask(Context* c)
{
return SiteMask((1 << (unsigned)lir::Operand::Type::RegisterPair) | (1 << (unsigned)lir::Operand::Type::Constant),
c->regFile->generalRegisters.mask,
c->regFile->generalRegisters,
NoFrameIndex);
}
@ -874,7 +874,7 @@ void maybeMove(Context* c,
c->arch->planSource(op, dstSize, src, dstSize, &thunk);
if (isGeneralValue(srcValue)) {
src.lowRegisterMask &= c->regFile->generalRegisters.mask;
src.lowRegisterMask &= c->regFile->generalRegisters;
}
assertT(c, thunk == 0);
@ -1636,7 +1636,7 @@ bool resolveSourceSites(Context* c,
if (r and sites[el.localIndex] == 0) {
SiteMask mask((1 << (unsigned)lir::Operand::Type::RegisterPair) | (1 << (unsigned)lir::Operand::Type::Memory),
c->regFile->generalRegisters.mask,
c->regFile->generalRegisters,
AnyFrameIndex);
Site* s = pickSourceSite(
@ -1678,7 +1678,7 @@ void resolveTargetSites(Context* c,
if (r and sites[el.localIndex] == 0) {
SiteMask mask((1 << (unsigned)lir::Operand::Type::RegisterPair) | (1 << (unsigned)lir::Operand::Type::Memory),
c->regFile->generalRegisters.mask,
c->regFile->generalRegisters,
AnyFrameIndex);
Site* s = pickSourceSite(

View File

@ -372,7 +372,7 @@ class CallEvent : public Event {
? arguments.count
: 0)
{
RegisterMask registerMask = c->regFile->generalRegisters.mask;
RegisterMask registerMask = c->regFile->generalRegisters;
if (callingConvention == ir::CallingConvention::Native) {
assertT(c, (flags & Compiler::TailJump) == 0);

View File

@ -94,7 +94,7 @@ Register pickRegisterTarget(Context* c,
Register target = NoRegister;
*cost = Target::Impossible;
if (mask & c->regFile->generalRegisters.mask) {
if (mask & c->regFile->generalRegisters) {
for (Register i = Register(c->regFile->generalRegisters.limit - 1);
(int8_t)i >= c->regFile->generalRegisters.start;
i = Register((int8_t)i - 1)) {
@ -104,7 +104,7 @@ Register pickRegisterTarget(Context* c,
}
}
if (mask & c->regFile->floatRegisters.mask) {
if (mask & c->regFile->floatRegisters) {
for (Register i = Register(c->regFile->floatRegisters.start);
(int8_t)i < c->regFile->floatRegisters.limit;
i = Register((int8_t)i + 1)) {
@ -235,13 +235,13 @@ Target pickTarget(Context* c,
Value* value = read->value;
RegisterMask registerMask
= (isFloatValue(value) ? RegisterMask::Any : c->regFile->generalRegisters.mask);
= (isFloatValue(value) ? RegisterMask::Any : (RegisterMask)c->regFile->generalRegisters);
SiteMask mask(~0, registerMask, AnyFrameIndex);
read->intersect(&mask);
if (isFloatValue(value)) {
RegisterMask floatMask = mask.registerMask & c->regFile->floatRegisters.mask;
RegisterMask floatMask = mask.registerMask & c->regFile->floatRegisters;
if (floatMask) {
mask.registerMask = floatMask;
}

View File

@ -88,7 +88,7 @@ void RegisterResource::freeze(Context* c, Value* v)
freezeResource(c, this, v);
if (freezeCount == 1
and c->regFile->generalRegisters.mask.contains(index(c))) {
and c->regFile->generalRegisters.contains(index(c))) {
decrementAvailableGeneralRegisterCount(c);
}
}
@ -100,7 +100,7 @@ void RegisterResource::thaw(Context* c, Value* v)
thawResource(c, this, v);
if (freezeCount == 0
and c->regFile->generalRegisters.mask.contains(index(c))) {
and c->regFile->generalRegisters.contains(index(c))) {
incrementAvailableGeneralRegisterCount(c);
}
}
@ -130,7 +130,7 @@ void RegisterResource::increment(Context* c)
++this->referenceCount;
if (this->referenceCount == 1
and c->regFile->generalRegisters.mask.contains(this->index(c))) {
and c->regFile->generalRegisters.contains(this->index(c))) {
decrementAvailableGeneralRegisterCount(c);
}
}
@ -150,7 +150,7 @@ void RegisterResource::decrement(Context* c)
--this->referenceCount;
if (this->referenceCount == 0
and c->regFile->generalRegisters.mask.contains(this->index(c))) {
and c->regFile->generalRegisters.contains(this->index(c))) {
incrementAvailableGeneralRegisterCount(c);
}
}

View File

@ -281,7 +281,7 @@ bool RegisterSite::matchNextWord(Context* c, Site* s, unsigned)
assertT(c, number != NoRegister);
return number == rs->number;
} else {
RegisterMask mask = c->regFile->generalRegisters.mask;
RegisterMask mask = c->regFile->generalRegisters;
return mask.contains(number) and mask.contains(rs->number);
}
}
@ -378,9 +378,9 @@ Site* RegisterSite::copyHigh(Context* c)
Site* RegisterSite::makeNextWord(Context* c, unsigned)
{
assertT(c, number != NoRegister);
assertT(c, c->regFile->generalRegisters.mask.contains(number));
assertT(c, c->regFile->generalRegisters.contains(number));
return freeRegisterSite(c, c->regFile->generalRegisters.mask);
return freeRegisterSite(c, c->regFile->generalRegisters);
}
SiteMask RegisterSite::mask(Context* c UNUSED)
@ -396,7 +396,7 @@ SiteMask RegisterSite::nextWordMask(Context* c, unsigned)
return SiteMask(1 << (unsigned)lir::Operand::Type::RegisterPair, number, NoFrameIndex);
} else {
return SiteMask(1 << (unsigned)lir::Operand::Type::RegisterPair,
c->regFile->generalRegisters.mask,
c->regFile->generalRegisters,
NoFrameIndex);
}
}
@ -405,7 +405,7 @@ unsigned RegisterSite::registerSize(Context* c)
{
assertT(c, number != NoRegister);
if (c->regFile->floatRegisters.mask.contains(number)) {
if (c->regFile->floatRegisters.contains(number)) {
return c->arch->floatRegisterSize();
} else {
return c->targetInfo.pointerSize;
@ -423,8 +423,8 @@ Site* registerSite(Context* c, Register number)
{
assertT(c, number != NoRegister);
assertT(c,
(c->regFile->generalRegisters.mask
| c->regFile->floatRegisters.mask).contains(number));
(c->regFile->generalRegisters
| c->regFile->floatRegisters).contains(number));
return new (c->zone) RegisterSite(RegisterMask(number), number);
}