From a3ccc94cf5477a61282a1262ffd7d874b0a38760 Mon Sep 17 00:00:00 2001 From: Joshua Warner Date: Fri, 5 Dec 2014 12:27:33 -0700 Subject: [PATCH] make BoundedRegisterMask a subclass of RegisterMask --- include/avian/codegen/registers.h | 7 +++---- src/codegen/compiler.cpp | 10 +++++----- src/codegen/compiler/event.cpp | 2 +- src/codegen/compiler/regalloc.cpp | 8 ++++---- src/codegen/compiler/resource.cpp | 8 ++++---- src/codegen/compiler/site.cpp | 14 +++++++------- 6 files changed, 24 insertions(+), 25 deletions(-) diff --git a/include/avian/codegen/registers.h b/include/avian/codegen/registers.h index cd3a25eaad..34b74926cb 100644 --- a/include/avian/codegen/registers.h +++ b/include/avian/codegen/registers.h @@ -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); } }; diff --git a/src/codegen/compiler.cpp b/src/codegen/compiler.cpp index 9c0a8e46f4..02a1a224e9 100644 --- a/src/codegen/compiler.cpp +++ b/src/codegen/compiler.cpp @@ -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( diff --git a/src/codegen/compiler/event.cpp b/src/codegen/compiler/event.cpp index a769899b0c..b23e4a56f6 100644 --- a/src/codegen/compiler/event.cpp +++ b/src/codegen/compiler/event.cpp @@ -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); diff --git a/src/codegen/compiler/regalloc.cpp b/src/codegen/compiler/regalloc.cpp index b16e68dfd2..26ce7b2b78 100644 --- a/src/codegen/compiler/regalloc.cpp +++ b/src/codegen/compiler/regalloc.cpp @@ -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; } diff --git a/src/codegen/compiler/resource.cpp b/src/codegen/compiler/resource.cpp index b0b7ad63c2..915da9ccff 100644 --- a/src/codegen/compiler/resource.cpp +++ b/src/codegen/compiler/resource.cpp @@ -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); } } diff --git a/src/codegen/compiler/site.cpp b/src/codegen/compiler/site.cpp index 221d2add91..ca9ba2ff97 100644 --- a/src/codegen/compiler/site.cpp +++ b/src/codegen/compiler/site.cpp @@ -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); }