use ir::Type in place of lir::ValueType in Value

This commit is contained in:
Joshua Warner 2014-04-30 19:50:32 -06:00 committed by Joshua Warner
parent 855534b152
commit 587b1e3eda
5 changed files with 49 additions and 26 deletions

View File

@ -821,7 +821,7 @@ maybeMove(Context* c, lir::BinaryOperation type, unsigned srcSize,
c->arch->planSource(type, dstSize, src, dstSize, &thunk);
if (srcValue->type == lir::ValueGeneral) {
if (isGeneralValue(srcValue)) {
src.registerMask &= c->regFile->generalRegisters.mask;
}
@ -1506,8 +1506,8 @@ resolveOriginalSites(Context* c, Event* e, SiteRecordList* frozen,
fprintf(stderr, "freeze original %s for %p local %d frame %d\n",
buffer, v, el.localIndex, el.frameIndex(c));
}
Value dummy(0, 0, lir::ValueGeneral);
Value dummy(0, 0, ir::Type(ir::Type::Integer, TargetBytesPerWord));
dummy.addSite(c, s);
dummy.removeSite(c, s);
freeze(c, frozen, s, 0);
@ -2536,8 +2536,7 @@ class MyCompiler: public Compiler {
for (int i = 0; i < static_cast<int>(c.localFootprint); ++i) {
Local* local = e->locals() + i;
if (local->value) {
initLocal
(1, i, local->value->type == lir::ValueGeneral ? IntegerType : FloatType);
initLocal(1, i, isGeneralValue(local->value) ? IntegerType : FloatType);
}
}
@ -2633,8 +2632,9 @@ class MyCompiler: public Compiler {
virtual Operand* f2f(unsigned aSize, ir::Type resType, Operand* a)
{
assert(&c, static_cast<Value*>(a)->type == lir::ValueFloat);
Value* result = value(&c, lir::ValueFloat);
assert(&c, isFloatValue(a));
assert(&c, resType.flavor() == ir::Type::Float);
Value* result = value(&c, resType);
appendTranslate(&c,
lir::Float2Float,
aSize,
@ -2646,8 +2646,9 @@ class MyCompiler: public Compiler {
virtual Operand* f2i(unsigned aSize, ir::Type resType, Operand* a)
{
assert(&c, static_cast<Value*>(a)->type == lir::ValueFloat);
Value* result = value(&c, lir::ValueGeneral);
assert(&c, isFloatValue(a));
assert(&c, resType.flavor() != ir::Type::Float);
Value* result = value(&c, resType);
appendTranslate(&c,
lir::Float2Int,
aSize,
@ -2659,8 +2660,9 @@ class MyCompiler: public Compiler {
virtual Operand* i2f(unsigned aSize, ir::Type resType, Operand* a)
{
assert(&c, static_cast<Value*>(a)->type == lir::ValueGeneral);
Value* result = value(&c, lir::ValueFloat);
assert(&c, isGeneralValue(a));
assert(&c, resType.flavor() == ir::Type::Float);
Value* result = value(&c, resType);
appendTranslate(&c,
lir::Int2Float,
aSize,

View File

@ -215,12 +215,12 @@ pickTarget(Context* c, Read* read, bool intersectRead,
Value* value = read->value;
uint32_t registerMask
= (value->type == lir::ValueFloat ? ~0 : c->regFile->generalRegisters.mask);
= (isFloatValue(value) ? ~0 : c->regFile->generalRegisters.mask);
SiteMask mask(~0, registerMask, AnyFrameIndex);
read->intersect(&mask);
if (value->type == lir::ValueFloat) {
if (isFloatValue(value)) {
uint32_t floatMask = mask.registerMask & c->regFile->floatRegisters.mask;
if (floatMask) {
mask.registerMask = floatMask;

View File

@ -17,9 +17,17 @@ namespace avian {
namespace codegen {
namespace compiler {
Value::Value(Site* site, Site* target, lir::ValueType type):
reads(0), lastRead(0), sites(site), source(0), target(target), buddy(this),
nextWord(this), home(NoFrameIndex), type(type), wordIndex(0)
Value::Value(Site* site, Site* target, ir::Type type)
: reads(0),
lastRead(0),
sites(site),
source(0),
target(target),
buddy(this),
nextWord(this),
home(NoFrameIndex),
wordIndex(0),
type(type)
{ }
bool Value::findSite(Site* site) {
@ -156,6 +164,16 @@ bool Value::hasBuddy(Context* c, Value* b) {
Value* value(Context* c, lir::ValueType type, Site* site, Site* target) {
return value(
c,
ir::Type(type == lir::ValueGeneral ? ir::Type::Integer : ir::Type::Float,
vm::TargetBytesPerWord),
site,
target);
}
Value* value(Context* c, ir::Type type, Site* site, Site* target)
{
return new(c->zone) Value(site, target, type);
}

View File

@ -36,10 +36,10 @@ class Value: public Compiler::Operand {
Value* buddy;
Value* nextWord;
int16_t home;
lir::ValueType type;
uint8_t wordIndex;
ir::Type type;
Value(Site* site, Site* target, lir::ValueType type);
Value(Site* site, Site* target, ir::Type type);
bool findSite(Site* site);
@ -67,15 +67,18 @@ class Value: public Compiler::Operand {
};
inline bool isGeneralValue(Compiler::Operand* a) {
return static_cast<Value*>(a)->type == lir::ValueGeneral;
inline bool isFloatValue(Compiler::Operand* a)
{
return static_cast<Value*>(a)->type.flavor() == ir::Type::Float;
}
inline bool isFloatValue(Compiler::Operand* a) {
return static_cast<Value*>(a)->type == lir::ValueFloat;
inline bool isGeneralValue(Compiler::Operand* a)
{
return !isFloatValue(a);
}
Value* value(Context* c, lir::ValueType type, Site* site = 0, Site* target = 0);
Value* value(Context* c, ir::Type type, Site* site = 0, Site* target = 0);
} // namespace compiler
} // namespace codegen

View File

@ -4380,11 +4380,11 @@ compile(MyThread* t, Frame* initialFrame, unsigned initialIp,
} break;
case d2i: {
frame->pushInt(c->f2i(8, types.f4, frame->popLong()));
frame->pushInt(c->f2i(8, types.i4, frame->popLong()));
} break;
case d2l: {
frame->pushLong(c->f2i(8, types.f8, frame->popLong()));
frame->pushLong(c->f2i(8, types.i8, frame->popLong()));
} break;
case dadd:
@ -4473,11 +4473,11 @@ compile(MyThread* t, Frame* initialFrame, unsigned initialIp,
} break;
case f2i: {
frame->pushInt(c->f2i(4, types.f4, frame->popInt()));
frame->pushInt(c->f2i(4, types.i4, frame->popInt()));
} break;
case f2l: {
frame->pushLong(c->f2i(4, types.f8, frame->popInt()));
frame->pushLong(c->f2i(4, types.i8, frame->popInt()));
} break;
case fadd: