use ir::Type in Compiler::initLocal

This commit is contained in:
Joshua Warner 2014-04-30 21:35:08 -06:00 committed by Joshua Warner
parent 4bfb359cdd
commit d8914a9646
4 changed files with 25 additions and 15 deletions

View File

@ -108,7 +108,7 @@ class Compiler {
virtual void return_(ir::Type type, Operand* value) = 0;
virtual void return_() = 0;
virtual void initLocal(unsigned size, unsigned index, OperandType type) = 0;
virtual void initLocal(unsigned size, unsigned index, ir::Type type) = 0;
virtual void initLocalsFromLogicalIp(unsigned logicalIp) = 0;
virtual void storeLocal(unsigned footprint, Operand* src,
unsigned index) = 0;

View File

@ -23,7 +23,13 @@ class Type {
// GC-invisible types
Integer,
Float
Float,
Address,
// Represents individual halves of two-word types
// (double/long on 32-bit systems)
// TODO: remove when possible
Half,
};
private:

View File

@ -2118,6 +2118,8 @@ unsigned typeFootprint(Context* c, ir::Type type)
case ir::Type::Integer:
return type.size() / 4;
case ir::Type::Object:
case ir::Type::Address:
case ir::Type::Half:
return 1;
default:
abort(c);
@ -2274,7 +2276,7 @@ class MyCompiler: public Compiler {
for (unsigned li = 0; li < c.localFootprint; ++li) {
Local* local = c.locals + li;
if (local->value == 0) {
initLocal(1, li, IntegerType);
initLocal(1, li, ir::Type(ir::Type::Address, TargetBytesPerWord));
}
}
}
@ -2510,11 +2512,13 @@ class MyCompiler: public Compiler {
appendReturn(&c, 0, 0);
}
virtual void initLocal(unsigned footprint, unsigned index, OperandType type)
virtual void initLocal(unsigned footprint, unsigned index, ir::Type type)
{
// TODO: enable the following assertion when possible:
// assert(&c, footprint == typeFootprint(type));
assert(&c, index + footprint <= c.localFootprint);
Value* v = value(&c, valueType(&c, type));
Value* v = value(&c, type);
if (footprint > 1) {
assert(&c, footprint == 2);
@ -2564,7 +2568,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, isGeneralValue(local->value) ? IntegerType : FloatType);
initLocal(1, i, local->value->type);
}
}

View File

@ -7153,7 +7153,7 @@ compile(MyThread* t, Context* context)
unsigned index = methodParameterFootprint(t, context->method);
if ((methodFlags(t, context->method) & ACC_STATIC) == 0) {
frame.set(--index, Frame::Object);
c->initLocal(1, index, Compiler::ObjectType);
c->initLocal(1, index, frame.types.object);
}
for (MethodSpecIterator it
@ -7165,29 +7165,29 @@ compile(MyThread* t, Context* context)
case 'L':
case '[':
frame.set(--index, Frame::Object);
c->initLocal(1, index, Compiler::ObjectType);
c->initLocal(1, index, frame.types.object);
break;
case 'J':
frame.set(--index, Frame::Long);
frame.set(--index, Frame::Long);
c->initLocal(2, index, Compiler::IntegerType);
c->initLocal(2, index, frame.types.i8);
break;
case 'D':
frame.set(--index, Frame::Long);
frame.set(--index, Frame::Long);
c->initLocal(2, index, Compiler::FloatType);
c->initLocal(2, index, frame.types.f8);
break;
case 'F':
frame.set(--index, Frame::Integer);
c->initLocal(1, index, Compiler::FloatType);
c->initLocal(1, index, frame.types.f4);
break;
default:
frame.set(--index, Frame::Integer);
c->initLocal(1, index, Compiler::IntegerType);
c->initLocal(1, index, frame.types.i4);
break;
}
}