mirror of
https://github.com/corda/corda.git
synced 2025-01-22 12:28:11 +00:00
typedef RegisterMask
This commit is contained in:
parent
a509575a86
commit
76197e1f1d
@ -12,6 +12,7 @@
|
|||||||
#define AVIAN_CODEGEN_ARCHITECTURE_H
|
#define AVIAN_CODEGEN_ARCHITECTURE_H
|
||||||
|
|
||||||
#include "ir.h"
|
#include "ir.h"
|
||||||
|
#include "registers.h"
|
||||||
|
|
||||||
namespace vm {
|
namespace vm {
|
||||||
class Zone;
|
class Zone;
|
||||||
@ -32,12 +33,12 @@ class RegisterFile;
|
|||||||
class OperandMask {
|
class OperandMask {
|
||||||
public:
|
public:
|
||||||
uint8_t typeMask;
|
uint8_t typeMask;
|
||||||
uint64_t lowRegisterMask;
|
RegisterMask lowRegisterMask;
|
||||||
uint64_t highRegisterMask;
|
RegisterMask highRegisterMask;
|
||||||
|
|
||||||
OperandMask(uint8_t typeMask,
|
OperandMask(uint8_t typeMask,
|
||||||
uint64_t lowRegisterMask,
|
RegisterMask lowRegisterMask,
|
||||||
uint64_t highRegisterMask)
|
RegisterMask highRegisterMask)
|
||||||
: typeMask(typeMask),
|
: typeMask(typeMask),
|
||||||
lowRegisterMask(lowRegisterMask),
|
lowRegisterMask(lowRegisterMask),
|
||||||
highRegisterMask(highRegisterMask)
|
highRegisterMask(highRegisterMask)
|
||||||
@ -46,18 +47,18 @@ class OperandMask {
|
|||||||
|
|
||||||
// TEMPORARY!
|
// TEMPORARY!
|
||||||
OperandMask(uint8_t typeMask,
|
OperandMask(uint8_t typeMask,
|
||||||
uint64_t registerMask)
|
RegisterMask registerMask)
|
||||||
: typeMask(typeMask),
|
: typeMask(typeMask),
|
||||||
lowRegisterMask(registerMask),
|
lowRegisterMask(registerMask),
|
||||||
highRegisterMask(registerMask >> 32)
|
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->lowRegisterMask = lowRegisterMask | (highRegisterMask << 32);
|
||||||
this->highRegisterMask = highRegisterMask;
|
this->highRegisterMask = highRegisterMask;
|
||||||
}
|
}
|
||||||
|
@ -15,6 +15,7 @@
|
|||||||
#include "avian/zone.h"
|
#include "avian/zone.h"
|
||||||
|
|
||||||
#include <avian/codegen/lir.h>
|
#include <avian/codegen/lir.h>
|
||||||
|
#include <avian/codegen/registers.h>
|
||||||
#include <avian/codegen/promise.h>
|
#include <avian/codegen/promise.h>
|
||||||
|
|
||||||
namespace avian {
|
namespace avian {
|
||||||
@ -52,7 +53,7 @@ class Assembler {
|
|||||||
public:
|
public:
|
||||||
class Client {
|
class Client {
|
||||||
public:
|
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 releaseTemporary(int r) = 0;
|
||||||
|
|
||||||
virtual void save(int r) = 0;
|
virtual void save(int r) = 0;
|
||||||
|
@ -16,16 +16,18 @@
|
|||||||
namespace avian {
|
namespace avian {
|
||||||
namespace codegen {
|
namespace codegen {
|
||||||
|
|
||||||
|
typedef uint64_t RegisterMask;
|
||||||
|
|
||||||
class BoundedRegisterMask {
|
class BoundedRegisterMask {
|
||||||
public:
|
public:
|
||||||
uint32_t mask;
|
RegisterMask mask;
|
||||||
uint8_t start;
|
uint8_t start;
|
||||||
uint8_t limit;
|
uint8_t limit;
|
||||||
|
|
||||||
static unsigned maskStart(uint32_t mask);
|
static unsigned maskStart(RegisterMask mask);
|
||||||
static unsigned maskLimit(uint32_t mask);
|
static unsigned maskLimit(RegisterMask mask);
|
||||||
|
|
||||||
inline BoundedRegisterMask(uint32_t mask)
|
inline BoundedRegisterMask(RegisterMask mask)
|
||||||
: mask(mask), start(maskStart(mask)), limit(maskLimit(mask))
|
: mask(mask), start(maskStart(mask)), limit(maskLimit(mask))
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
@ -37,7 +39,7 @@ class RegisterFile {
|
|||||||
BoundedRegisterMask generalRegisters;
|
BoundedRegisterMask generalRegisters;
|
||||||
BoundedRegisterMask floatRegisters;
|
BoundedRegisterMask floatRegisters;
|
||||||
|
|
||||||
inline RegisterFile(uint32_t generalRegisterMask, uint32_t floatRegisterMask)
|
inline RegisterFile(RegisterMask generalRegisterMask, RegisterMask floatRegisterMask)
|
||||||
: allRegisters(generalRegisterMask | floatRegisterMask),
|
: allRegisters(generalRegisterMask | floatRegisterMask),
|
||||||
generalRegisters(generalRegisterMask),
|
generalRegisters(generalRegisterMask),
|
||||||
floatRegisters(floatRegisterMask)
|
floatRegisters(floatRegisterMask)
|
||||||
|
@ -2210,7 +2210,7 @@ class Client : public Assembler::Client {
|
|||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
virtual int acquireTemporary(uint32_t mask)
|
virtual int acquireTemporary(RegisterMask mask)
|
||||||
{
|
{
|
||||||
unsigned cost;
|
unsigned cost;
|
||||||
int r = pickRegisterTarget(c, 0, mask, &cost);
|
int r = pickRegisterTarget(c, 0, mask, &cost);
|
||||||
|
@ -372,7 +372,7 @@ class CallEvent : public Event {
|
|||||||
? arguments.count
|
? arguments.count
|
||||||
: 0)
|
: 0)
|
||||||
{
|
{
|
||||||
uint32_t registerMask = c->regFile->generalRegisters.mask;
|
RegisterMask registerMask = c->regFile->generalRegisters.mask;
|
||||||
|
|
||||||
if (callingConvention == ir::CallingConvention::Native) {
|
if (callingConvention == ir::CallingConvention::Native) {
|
||||||
assertT(c, (flags & Compiler::TailJump) == 0);
|
assertT(c, (flags & Compiler::TailJump) == 0);
|
||||||
|
@ -59,7 +59,7 @@ unsigned resourceCost(Context* c,
|
|||||||
bool pickRegisterTarget(Context* c,
|
bool pickRegisterTarget(Context* c,
|
||||||
int i,
|
int i,
|
||||||
Value* v,
|
Value* v,
|
||||||
uint32_t mask,
|
RegisterMask mask,
|
||||||
int* target,
|
int* target,
|
||||||
unsigned* cost,
|
unsigned* cost,
|
||||||
CostCalculator* costCalculator)
|
CostCalculator* costCalculator)
|
||||||
@ -74,7 +74,7 @@ bool pickRegisterTarget(Context* c,
|
|||||||
SiteMask(1 << lir::RegisterOperand, 1 << i, NoFrameIndex),
|
SiteMask(1 << lir::RegisterOperand, 1 << i, NoFrameIndex),
|
||||||
costCalculator) + Target::MinimumRegisterCost;
|
costCalculator) + Target::MinimumRegisterCost;
|
||||||
|
|
||||||
if ((static_cast<uint32_t>(1) << i) == mask) {
|
if ((static_cast<RegisterMask>(1) << i) == mask) {
|
||||||
*cost = myCost;
|
*cost = myCost;
|
||||||
return true;
|
return true;
|
||||||
} else if (myCost < *cost) {
|
} else if (myCost < *cost) {
|
||||||
@ -87,7 +87,7 @@ bool pickRegisterTarget(Context* c,
|
|||||||
|
|
||||||
int pickRegisterTarget(Context* c,
|
int pickRegisterTarget(Context* c,
|
||||||
Value* v,
|
Value* v,
|
||||||
uint32_t mask,
|
RegisterMask mask,
|
||||||
unsigned* cost,
|
unsigned* cost,
|
||||||
CostCalculator* costCalculator)
|
CostCalculator* costCalculator)
|
||||||
{
|
{
|
||||||
@ -119,7 +119,7 @@ int pickRegisterTarget(Context* c,
|
|||||||
|
|
||||||
Target pickRegisterTarget(Context* c,
|
Target pickRegisterTarget(Context* c,
|
||||||
Value* v,
|
Value* v,
|
||||||
uint32_t mask,
|
RegisterMask mask,
|
||||||
CostCalculator* costCalculator)
|
CostCalculator* costCalculator)
|
||||||
{
|
{
|
||||||
unsigned cost;
|
unsigned cost;
|
||||||
@ -234,14 +234,14 @@ Target pickTarget(Context* c,
|
|||||||
|
|
||||||
Value* value = read->value;
|
Value* value = read->value;
|
||||||
|
|
||||||
uint32_t registerMask
|
RegisterMask registerMask
|
||||||
= (isFloatValue(value) ? ~0 : c->regFile->generalRegisters.mask);
|
= (isFloatValue(value) ? ~0 : c->regFile->generalRegisters.mask);
|
||||||
|
|
||||||
SiteMask mask(~0, registerMask, AnyFrameIndex);
|
SiteMask mask(~0, registerMask, AnyFrameIndex);
|
||||||
read->intersect(&mask);
|
read->intersect(&mask);
|
||||||
|
|
||||||
if (isFloatValue(value)) {
|
if (isFloatValue(value)) {
|
||||||
uint32_t floatMask = mask.registerMask & c->regFile->floatRegisters.mask;
|
RegisterMask floatMask = mask.registerMask & c->regFile->floatRegisters.mask;
|
||||||
if (floatMask) {
|
if (floatMask) {
|
||||||
mask.registerMask = floatMask;
|
mask.registerMask = floatMask;
|
||||||
}
|
}
|
||||||
@ -273,7 +273,7 @@ Target pickTarget(Context* c,
|
|||||||
if (intersectRead) {
|
if (intersectRead) {
|
||||||
if (best.cost == Target::Impossible) {
|
if (best.cost == Target::Impossible) {
|
||||||
fprintf(stderr,
|
fprintf(stderr,
|
||||||
"mask type %d reg %d frame %d\n",
|
"mask type %d reg %" LLD " frame %d\n",
|
||||||
mask.typeMask,
|
mask.typeMask,
|
||||||
mask.registerMask,
|
mask.registerMask,
|
||||||
mask.frameIndex);
|
mask.frameIndex);
|
||||||
|
@ -79,20 +79,20 @@ unsigned resourceCost(Context* c,
|
|||||||
bool pickRegisterTarget(Context* c,
|
bool pickRegisterTarget(Context* c,
|
||||||
int i,
|
int i,
|
||||||
Value* v,
|
Value* v,
|
||||||
uint32_t mask,
|
RegisterMask mask,
|
||||||
int* target,
|
int* target,
|
||||||
unsigned* cost,
|
unsigned* cost,
|
||||||
CostCalculator* costCalculator = 0);
|
CostCalculator* costCalculator = 0);
|
||||||
|
|
||||||
int pickRegisterTarget(Context* c,
|
int pickRegisterTarget(Context* c,
|
||||||
Value* v,
|
Value* v,
|
||||||
uint32_t mask,
|
RegisterMask mask,
|
||||||
unsigned* cost,
|
unsigned* cost,
|
||||||
CostCalculator* costCalculator = 0);
|
CostCalculator* costCalculator = 0);
|
||||||
|
|
||||||
Target pickRegisterTarget(Context* c,
|
Target pickRegisterTarget(Context* c,
|
||||||
Value* v,
|
Value* v,
|
||||||
uint32_t mask,
|
RegisterMask mask,
|
||||||
CostCalculator* costCalculator = 0);
|
CostCalculator* costCalculator = 0);
|
||||||
|
|
||||||
unsigned frameCost(Context* c,
|
unsigned frameCost(Context* c,
|
||||||
|
@ -217,7 +217,7 @@ Site* addressSite(Context* c, Promise* address)
|
|||||||
return new (c->zone) AddressSite(address);
|
return new (c->zone) AddressSite(address);
|
||||||
}
|
}
|
||||||
|
|
||||||
RegisterSite::RegisterSite(uint32_t mask, int number)
|
RegisterSite::RegisterSite(RegisterMask mask, int number)
|
||||||
: mask_(mask), number(number)
|
: mask_(mask), number(number)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
@ -281,7 +281,7 @@ bool RegisterSite::matchNextWord(Context* c, Site* s, unsigned)
|
|||||||
assertT(c, number != lir::NoRegister);
|
assertT(c, number != lir::NoRegister);
|
||||||
return number == rs->number;
|
return number == rs->number;
|
||||||
} else {
|
} else {
|
||||||
uint32_t mask = c->regFile->generalRegisters.mask;
|
RegisterMask mask = c->regFile->generalRegisters.mask;
|
||||||
return ((1 << number) & mask) and ((1 << rs->number) & 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)
|
Site* RegisterSite::copy(Context* c)
|
||||||
{
|
{
|
||||||
uint32_t mask;
|
RegisterMask mask;
|
||||||
|
|
||||||
if (number != lir::NoRegister) {
|
if (number != lir::NoRegister) {
|
||||||
mask = 1 << number;
|
mask = 1 << number;
|
||||||
@ -429,7 +429,7 @@ Site* registerSite(Context* c, int number)
|
|||||||
return new (c->zone) RegisterSite(1 << number, 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);
|
return new (c->zone) RegisterSite(mask, lir::NoRegister);
|
||||||
}
|
}
|
||||||
|
@ -34,8 +34,8 @@ class SiteMask {
|
|||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
SiteMask(uint8_t typeMask, uint32_t registerMask, int frameIndex)
|
SiteMask(uint8_t typeMask, RegisterMask registerMask, int frameIndex)
|
||||||
: typeMask(typeMask), registerMask(registerMask), frameIndex(frameIndex)
|
: typeMask(typeMask), registerMask(/*TODO: REMOVE CAST!!! */(uint32_t)registerMask), frameIndex(frameIndex)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -57,7 +57,7 @@ class SiteMask {
|
|||||||
}
|
}
|
||||||
|
|
||||||
uint8_t typeMask;
|
uint8_t typeMask;
|
||||||
uint32_t registerMask;
|
RegisterMask registerMask;
|
||||||
int frameIndex;
|
int frameIndex;
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -251,7 +251,7 @@ Site* addressSite(Context* c, Promise* address);
|
|||||||
|
|
||||||
class RegisterSite : public Site {
|
class RegisterSite : public Site {
|
||||||
public:
|
public:
|
||||||
RegisterSite(uint32_t mask, int number);
|
RegisterSite(RegisterMask mask, int number);
|
||||||
|
|
||||||
virtual unsigned toString(Context*, char* buffer, unsigned bufferSize);
|
virtual unsigned toString(Context*, char* buffer, unsigned bufferSize);
|
||||||
|
|
||||||
@ -295,12 +295,12 @@ class RegisterSite : public Site {
|
|||||||
|
|
||||||
virtual unsigned registerMask(Context* c UNUSED);
|
virtual unsigned registerMask(Context* c UNUSED);
|
||||||
|
|
||||||
uint32_t mask_;
|
RegisterMask mask_;
|
||||||
int number;
|
int number;
|
||||||
};
|
};
|
||||||
|
|
||||||
Site* registerSite(Context* c, 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 {
|
class MemorySite : public Site {
|
||||||
public:
|
public:
|
||||||
|
@ -13,7 +13,7 @@
|
|||||||
namespace avian {
|
namespace avian {
|
||||||
namespace codegen {
|
namespace codegen {
|
||||||
|
|
||||||
unsigned BoundedRegisterMask::maskStart(uint32_t mask)
|
unsigned BoundedRegisterMask::maskStart(RegisterMask mask)
|
||||||
{
|
{
|
||||||
for (int i = 0; i <= 31; ++i) {
|
for (int i = 0; i <= 31; ++i) {
|
||||||
if (mask & (1 << i))
|
if (mask & (1 << i))
|
||||||
@ -22,7 +22,7 @@ unsigned BoundedRegisterMask::maskStart(uint32_t mask)
|
|||||||
return 32;
|
return 32;
|
||||||
}
|
}
|
||||||
|
|
||||||
unsigned BoundedRegisterMask::maskLimit(uint32_t mask)
|
unsigned BoundedRegisterMask::maskLimit(RegisterMask mask)
|
||||||
{
|
{
|
||||||
for (int i = 31; i >= 0; --i) {
|
for (int i = 31; i >= 0; --i) {
|
||||||
if (mask & (1 << i))
|
if (mask & (1 << i))
|
||||||
|
@ -23,8 +23,8 @@ const unsigned MASK_LO8 = 0xff;
|
|||||||
|
|
||||||
const int N_GPRS = 16;
|
const int N_GPRS = 16;
|
||||||
const int N_FPRS = 16;
|
const int N_FPRS = 16;
|
||||||
const uint32_t GPR_MASK = 0xffff;
|
const RegisterMask GPR_MASK = 0xffff;
|
||||||
const uint32_t FPR_MASK = 0xffff0000;
|
const RegisterMask FPR_MASK = 0xffff0000;
|
||||||
|
|
||||||
inline bool isFpr(lir::Register* reg)
|
inline bool isFpr(lir::Register* reg)
|
||||||
{
|
{
|
||||||
|
@ -1274,7 +1274,7 @@ void multiplyCR(Context* c,
|
|||||||
assertT(c, aSize == bSize);
|
assertT(c, aSize == bSize);
|
||||||
|
|
||||||
if (vm::TargetBytesPerWord == 4 and aSize == 8) {
|
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),
|
lir::Register tmp(c->client->acquireTemporary(mask),
|
||||||
c->client->acquireTemporary(mask));
|
c->client->acquireTemporary(mask));
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user