typedef RegisterMask

This commit is contained in:
Joshua Warner 2014-12-04 15:26:47 -07:00
parent a509575a86
commit 76197e1f1d
12 changed files with 44 additions and 40 deletions

View File

@ -12,6 +12,7 @@
#define AVIAN_CODEGEN_ARCHITECTURE_H
#include "ir.h"
#include "registers.h"
namespace vm {
class Zone;
@ -32,12 +33,12 @@ class RegisterFile;
class OperandMask {
public:
uint8_t typeMask;
uint64_t lowRegisterMask;
uint64_t highRegisterMask;
RegisterMask lowRegisterMask;
RegisterMask highRegisterMask;
OperandMask(uint8_t typeMask,
uint64_t lowRegisterMask,
uint64_t highRegisterMask)
RegisterMask lowRegisterMask,
RegisterMask highRegisterMask)
: typeMask(typeMask),
lowRegisterMask(lowRegisterMask),
highRegisterMask(highRegisterMask)
@ -46,18 +47,18 @@ class OperandMask {
// TEMPORARY!
OperandMask(uint8_t typeMask,
uint64_t registerMask)
RegisterMask registerMask)
: typeMask(typeMask),
lowRegisterMask(registerMask),
highRegisterMask(registerMask >> 32)
{
}
OperandMask() : typeMask(~0), lowRegisterMask(~static_cast<uint64_t>(0)), highRegisterMask(~static_cast<uint64_t>(0))
OperandMask() : typeMask(~0), lowRegisterMask(~static_cast<RegisterMask>(0)), highRegisterMask(~static_cast<RegisterMask>(0))
{
}
void setLowHighRegisterMasks(uint64_t lowRegisterMask, uint64_t highRegisterMask) {
void setLowHighRegisterMasks(RegisterMask lowRegisterMask, RegisterMask highRegisterMask) {
this->lowRegisterMask = lowRegisterMask | (highRegisterMask << 32);
this->highRegisterMask = highRegisterMask;
}

View File

@ -15,6 +15,7 @@
#include "avian/zone.h"
#include <avian/codegen/lir.h>
#include <avian/codegen/registers.h>
#include <avian/codegen/promise.h>
namespace avian {
@ -52,7 +53,7 @@ class Assembler {
public:
class Client {
public:
virtual int acquireTemporary(uint32_t mask = ~static_cast<uint32_t>(0)) = 0;
virtual int acquireTemporary(RegisterMask mask = ~static_cast<RegisterMask>(0)) = 0;
virtual void releaseTemporary(int r) = 0;
virtual void save(int r) = 0;

View File

@ -16,16 +16,18 @@
namespace avian {
namespace codegen {
typedef uint64_t RegisterMask;
class BoundedRegisterMask {
public:
uint32_t mask;
RegisterMask mask;
uint8_t start;
uint8_t limit;
static unsigned maskStart(uint32_t mask);
static unsigned maskLimit(uint32_t mask);
static unsigned maskStart(RegisterMask mask);
static unsigned maskLimit(RegisterMask mask);
inline BoundedRegisterMask(uint32_t mask)
inline BoundedRegisterMask(RegisterMask mask)
: mask(mask), start(maskStart(mask)), limit(maskLimit(mask))
{
}
@ -37,7 +39,7 @@ class RegisterFile {
BoundedRegisterMask generalRegisters;
BoundedRegisterMask floatRegisters;
inline RegisterFile(uint32_t generalRegisterMask, uint32_t floatRegisterMask)
inline RegisterFile(RegisterMask generalRegisterMask, RegisterMask floatRegisterMask)
: allRegisters(generalRegisterMask | floatRegisterMask),
generalRegisters(generalRegisterMask),
floatRegisters(floatRegisterMask)

View File

@ -2210,7 +2210,7 @@ class Client : public Assembler::Client {
{
}
virtual int acquireTemporary(uint32_t mask)
virtual int acquireTemporary(RegisterMask mask)
{
unsigned cost;
int r = pickRegisterTarget(c, 0, mask, &cost);

View File

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

View File

@ -59,7 +59,7 @@ unsigned resourceCost(Context* c,
bool pickRegisterTarget(Context* c,
int i,
Value* v,
uint32_t mask,
RegisterMask mask,
int* target,
unsigned* cost,
CostCalculator* costCalculator)
@ -74,7 +74,7 @@ bool pickRegisterTarget(Context* c,
SiteMask(1 << lir::RegisterOperand, 1 << i, NoFrameIndex),
costCalculator) + Target::MinimumRegisterCost;
if ((static_cast<uint32_t>(1) << i) == mask) {
if ((static_cast<RegisterMask>(1) << i) == mask) {
*cost = myCost;
return true;
} else if (myCost < *cost) {
@ -87,7 +87,7 @@ bool pickRegisterTarget(Context* c,
int pickRegisterTarget(Context* c,
Value* v,
uint32_t mask,
RegisterMask mask,
unsigned* cost,
CostCalculator* costCalculator)
{
@ -119,7 +119,7 @@ int pickRegisterTarget(Context* c,
Target pickRegisterTarget(Context* c,
Value* v,
uint32_t mask,
RegisterMask mask,
CostCalculator* costCalculator)
{
unsigned cost;
@ -234,14 +234,14 @@ Target pickTarget(Context* c,
Value* value = read->value;
uint32_t registerMask
RegisterMask registerMask
= (isFloatValue(value) ? ~0 : c->regFile->generalRegisters.mask);
SiteMask mask(~0, registerMask, AnyFrameIndex);
read->intersect(&mask);
if (isFloatValue(value)) {
uint32_t floatMask = mask.registerMask & c->regFile->floatRegisters.mask;
RegisterMask floatMask = mask.registerMask & c->regFile->floatRegisters.mask;
if (floatMask) {
mask.registerMask = floatMask;
}
@ -273,7 +273,7 @@ Target pickTarget(Context* c,
if (intersectRead) {
if (best.cost == Target::Impossible) {
fprintf(stderr,
"mask type %d reg %d frame %d\n",
"mask type %d reg %" LLD " frame %d\n",
mask.typeMask,
mask.registerMask,
mask.frameIndex);

View File

@ -79,20 +79,20 @@ unsigned resourceCost(Context* c,
bool pickRegisterTarget(Context* c,
int i,
Value* v,
uint32_t mask,
RegisterMask mask,
int* target,
unsigned* cost,
CostCalculator* costCalculator = 0);
int pickRegisterTarget(Context* c,
Value* v,
uint32_t mask,
RegisterMask mask,
unsigned* cost,
CostCalculator* costCalculator = 0);
Target pickRegisterTarget(Context* c,
Value* v,
uint32_t mask,
RegisterMask mask,
CostCalculator* costCalculator = 0);
unsigned frameCost(Context* c,

View File

@ -217,7 +217,7 @@ Site* addressSite(Context* c, Promise* address)
return new (c->zone) AddressSite(address);
}
RegisterSite::RegisterSite(uint32_t mask, int number)
RegisterSite::RegisterSite(RegisterMask mask, int number)
: mask_(mask), number(number)
{
}
@ -281,7 +281,7 @@ bool RegisterSite::matchNextWord(Context* c, Site* s, unsigned)
assertT(c, number != lir::NoRegister);
return number == rs->number;
} else {
uint32_t mask = c->regFile->generalRegisters.mask;
RegisterMask mask = c->regFile->generalRegisters.mask;
return ((1 << number) & mask) and ((1 << rs->number) & mask);
}
}
@ -354,7 +354,7 @@ void RegisterSite::asAssemblerOperand(Context* c UNUSED,
Site* RegisterSite::copy(Context* c)
{
uint32_t mask;
RegisterMask mask;
if (number != lir::NoRegister) {
mask = 1 << number;
@ -429,7 +429,7 @@ Site* registerSite(Context* c, int number)
return new (c->zone) RegisterSite(1 << number, number);
}
Site* freeRegisterSite(Context* c, uint32_t mask)
Site* freeRegisterSite(Context* c, RegisterMask mask)
{
return new (c->zone) RegisterSite(mask, lir::NoRegister);
}

View File

@ -34,8 +34,8 @@ class SiteMask {
{
}
SiteMask(uint8_t typeMask, uint32_t registerMask, int frameIndex)
: typeMask(typeMask), registerMask(registerMask), frameIndex(frameIndex)
SiteMask(uint8_t typeMask, RegisterMask registerMask, int frameIndex)
: typeMask(typeMask), registerMask(/*TODO: REMOVE CAST!!! */(uint32_t)registerMask), frameIndex(frameIndex)
{
}
@ -57,7 +57,7 @@ class SiteMask {
}
uint8_t typeMask;
uint32_t registerMask;
RegisterMask registerMask;
int frameIndex;
};
@ -251,7 +251,7 @@ Site* addressSite(Context* c, Promise* address);
class RegisterSite : public Site {
public:
RegisterSite(uint32_t mask, int number);
RegisterSite(RegisterMask mask, int number);
virtual unsigned toString(Context*, char* buffer, unsigned bufferSize);
@ -295,12 +295,12 @@ class RegisterSite : public Site {
virtual unsigned registerMask(Context* c UNUSED);
uint32_t mask_;
RegisterMask mask_;
int number;
};
Site* registerSite(Context* c, int number);
Site* freeRegisterSite(Context* c, uint32_t mask);
Site* freeRegisterSite(Context* c, RegisterMask mask);
class MemorySite : public Site {
public:

View File

@ -13,7 +13,7 @@
namespace avian {
namespace codegen {
unsigned BoundedRegisterMask::maskStart(uint32_t mask)
unsigned BoundedRegisterMask::maskStart(RegisterMask mask)
{
for (int i = 0; i <= 31; ++i) {
if (mask & (1 << i))
@ -22,7 +22,7 @@ unsigned BoundedRegisterMask::maskStart(uint32_t mask)
return 32;
}
unsigned BoundedRegisterMask::maskLimit(uint32_t mask)
unsigned BoundedRegisterMask::maskLimit(RegisterMask mask)
{
for (int i = 31; i >= 0; --i) {
if (mask & (1 << i))

View File

@ -23,8 +23,8 @@ const unsigned MASK_LO8 = 0xff;
const int N_GPRS = 16;
const int N_FPRS = 16;
const uint32_t GPR_MASK = 0xffff;
const uint32_t FPR_MASK = 0xffff0000;
const RegisterMask GPR_MASK = 0xffff;
const RegisterMask FPR_MASK = 0xffff0000;
inline bool isFpr(lir::Register* reg)
{

View File

@ -1274,7 +1274,7 @@ void multiplyCR(Context* c,
assertT(c, aSize == bSize);
if (vm::TargetBytesPerWord == 4 and aSize == 8) {
const uint32_t mask = GeneralRegisterMask & ~((1 << rax) | (1 << rdx));
const RegisterMask mask = GeneralRegisterMask & ~((1 << rax) | (1 << rdx));
lir::Register tmp(c->client->acquireTemporary(mask),
c->client->acquireTemporary(mask));