use enum class in ir

This commit is contained in:
Joshua Warner 2014-07-12 11:54:19 -06:00 committed by Joshua Warner
parent 060b5c8f13
commit 1ad1fe9048
5 changed files with 44 additions and 44 deletions

View File

@ -140,7 +140,7 @@ class Compiler {
ir::Value* index, ir::Value* index,
intptr_t handler) = 0; intptr_t handler) = 0;
virtual ir::Value* truncateThenExtend(ir::SignExtendMode signExtend, virtual ir::Value* truncateThenExtend(ir::ExtendMode extendMode,
ir::Type extendType, ir::Type extendType,
ir::Type truncateType, ir::Type truncateType,
ir::Value* src) = 0; ir::Value* src) = 0;
@ -148,7 +148,7 @@ class Compiler {
virtual ir::Value* truncate(ir::Type type, ir::Value* src) = 0; virtual ir::Value* truncate(ir::Type type, ir::Value* src) = 0;
virtual void store(ir::Value* src, ir::Value* dst) = 0; virtual void store(ir::Value* src, ir::Value* dst) = 0;
virtual ir::Value* load(ir::SignExtendMode signExtend, virtual ir::Value* load(ir::ExtendMode extendMode,
ir::Value* src, ir::Value* src,
ir::Type dstType) = 0; ir::Type dstType) = 0;

View File

@ -132,9 +132,9 @@ class Type {
} }
}; };
enum SignExtendMode { SignExtend, ZeroExtend }; enum class ExtendMode { Signed, Unsigned };
enum CallingConvention { NativeCallingConvention, AvianCallingConvention }; enum class CallingConvention { Native, Avian };
class Value { class Value {
public: public:

View File

@ -2567,7 +2567,7 @@ class MyCompiler : public Compiler {
Value* result = value(&c, resultType); Value* result = value(&c, resultType);
appendCall(&c, appendCall(&c,
static_cast<Value*>(address), static_cast<Value*>(address),
ir::NativeCallingConvention, ir::CallingConvention::Native,
flags, flags,
traceHandler, traceHandler,
result, result,
@ -2586,7 +2586,7 @@ class MyCompiler : public Compiler {
Stack* b UNUSED = c.stack; Stack* b UNUSED = c.stack;
appendCall(&c, appendCall(&c,
static_cast<Value*>(address), static_cast<Value*>(address),
ir::AvianCallingConvention, ir::CallingConvention::Avian,
flags, flags,
traceHandler, traceHandler,
result, result,
@ -2741,14 +2741,14 @@ class MyCompiler : public Compiler {
return dst; return dst;
} }
virtual ir::Value* truncateThenExtend(ir::SignExtendMode signExtend, virtual ir::Value* truncateThenExtend(ir::ExtendMode extendMode,
ir::Type extendType, ir::Type extendType,
ir::Type truncateType, ir::Type truncateType,
ir::Value* src) ir::Value* src)
{ {
Value* dst = value(&c, extendType); Value* dst = value(&c, extendType);
appendMove(&c, appendMove(&c,
signExtend == ir::SignExtend ? lir::Move : lir::MoveZ, extendMode == ir::ExtendMode::Signed ? lir::Move : lir::MoveZ,
TargetBytesPerWord, TargetBytesPerWord,
truncateType.size(c.targetInfo), truncateType.size(c.targetInfo),
static_cast<Value*>(src), static_cast<Value*>(src),
@ -2772,7 +2772,7 @@ class MyCompiler : public Compiler {
static_cast<Value*>(dst)); static_cast<Value*>(dst));
} }
virtual ir::Value* load(ir::SignExtendMode signExtend, virtual ir::Value* load(ir::ExtendMode extendMode,
ir::Value* src, ir::Value* src,
ir::Type dstType) ir::Type dstType)
{ {
@ -2780,7 +2780,7 @@ class MyCompiler : public Compiler {
Value* dst = value(&c, dstType); Value* dst = value(&c, dstType);
appendMove(&c, appendMove(&c,
signExtend == ir::SignExtend ? lir::Move : lir::MoveZ, extendMode == ir::ExtendMode::Signed ? lir::Move : lir::MoveZ,
src->type.size(c.targetInfo), src->type.size(c.targetInfo),
src->type.size(c.targetInfo), src->type.size(c.targetInfo),
static_cast<Value*>(src), static_cast<Value*>(src),

View File

@ -368,13 +368,13 @@ class CallEvent : public Event {
popIndex(0), popIndex(0),
stackArgumentIndex(0), stackArgumentIndex(0),
flags(flags), flags(flags),
stackArgumentFootprint(callingConvention == ir::AvianCallingConvention stackArgumentFootprint(callingConvention == ir::CallingConvention::Avian
? arguments.count ? arguments.count
: 0) : 0)
{ {
uint32_t registerMask = c->regFile->generalRegisters.mask; uint32_t registerMask = c->regFile->generalRegisters.mask;
if (callingConvention == ir::NativeCallingConvention) { if (callingConvention == ir::CallingConvention::Native) {
assertT(c, (flags & Compiler::TailJump) == 0); assertT(c, (flags & Compiler::TailJump) == 0);
assertT(c, stackArgumentFootprint == 0); assertT(c, stackArgumentFootprint == 0);
@ -450,7 +450,7 @@ class CallEvent : public Event {
Stack* stack = stackBefore; Stack* stack = stackBefore;
if (callingConvention == ir::AvianCallingConvention) { if (callingConvention == ir::CallingConvention::Avian) {
for (size_t i = 0; i < arguments.count; i++) { for (size_t i = 0; i < arguments.count; i++) {
stack = stack->next; stack = stack->next;
} }
@ -1257,7 +1257,7 @@ void appendCombine(Context* c,
appendCall(c, appendCall(c,
value(c, ir::Type::addr(), constantSite(c, handler)), value(c, ir::Type::addr(), constantSite(c, handler)),
ir::NativeCallingConvention, ir::CallingConvention::Native,
0, 0,
0, 0,
resultValue, resultValue,
@ -1413,7 +1413,7 @@ void appendTranslate(Context* c,
op, op,
firstValue->type.size(c->targetInfo), firstValue->type.size(c->targetInfo),
resultValue->type.size(c->targetInfo)))), resultValue->type.size(c->targetInfo)))),
ir::NativeCallingConvention, ir::CallingConvention::Native,
0, 0,
0, 0,
resultValue, resultValue,
@ -1849,7 +1849,7 @@ void appendBranch(Context* c,
Value* result = value(c, ir::Type::addr()); Value* result = value(c, ir::Type::addr());
appendCall(c, appendCall(c,
value(c, ir::Type::addr(), constantSite(c, handler)), value(c, ir::Type::addr(), constantSite(c, handler)),
ir::NativeCallingConvention, ir::CallingConvention::Native,
0, 0,
0, 0,
result, result,

View File

@ -3575,7 +3575,7 @@ ir::Value* popLongAddress(Frame* frame)
{ {
return TargetBytesPerWord == 8 return TargetBytesPerWord == 8
? frame->popLarge(ir::Type::i8()) ? frame->popLarge(ir::Type::i8())
: frame->c->load(ir::SignExtend, : frame->c->load(ir::ExtendMode::Signed,
frame->popLarge(ir::Type::i8()), frame->popLarge(ir::Type::i8()),
ir::Type::iptr()); ir::Type::iptr());
} }
@ -3616,7 +3616,7 @@ bool intrinsic(MyThread* t UNUSED, Frame* frame, GcMethod* target)
ir::Value* address = popLongAddress(frame); ir::Value* address = popLongAddress(frame);
frame->pop(ir::Type::object()); frame->pop(ir::Type::object());
frame->push(ir::Type::i4(), frame->push(ir::Type::i4(),
c->load(ir::SignExtend, c->load(ir::ExtendMode::Signed,
c->memory(address, ir::Type::i1()), c->memory(address, ir::Type::i1()),
ir::Type::i4())); ir::Type::i4()));
return true; return true;
@ -3634,7 +3634,7 @@ bool intrinsic(MyThread* t UNUSED, Frame* frame, GcMethod* target)
ir::Value* address = popLongAddress(frame); ir::Value* address = popLongAddress(frame);
frame->pop(ir::Type::object()); frame->pop(ir::Type::object());
frame->push(ir::Type::i4(), frame->push(ir::Type::i4(),
c->load(ir::SignExtend, c->load(ir::ExtendMode::Signed,
c->memory(address, ir::Type::i2()), c->memory(address, ir::Type::i2()),
ir::Type::i4())); ir::Type::i4()));
return true; return true;
@ -3656,7 +3656,7 @@ bool intrinsic(MyThread* t UNUSED, Frame* frame, GcMethod* target)
ir::Type type = MATCH(target->name(), "getInt") ? ir::Type::i4() ir::Type type = MATCH(target->name(), "getInt") ? ir::Type::i4()
: ir::Type::f4(); : ir::Type::f4();
frame->push(type, frame->push(type,
c->load(ir::SignExtend, c->memory(address, type), type)); c->load(ir::ExtendMode::Signed, c->memory(address, type), type));
return true; return true;
} else if ((MATCH(target->name(), "putInt") } else if ((MATCH(target->name(), "putInt")
and MATCH(target->spec(), "(JI)V")) and MATCH(target->spec(), "(JI)V"))
@ -3678,7 +3678,7 @@ bool intrinsic(MyThread* t UNUSED, Frame* frame, GcMethod* target)
ir::Type type = MATCH(target->name(), "getLong") ? ir::Type::i8() ir::Type type = MATCH(target->name(), "getLong") ? ir::Type::i8()
: ir::Type::f8(); : ir::Type::f8();
frame->pushLarge(type, frame->pushLarge(type,
c->load(ir::SignExtend, c->memory(address, type), type)); c->load(ir::ExtendMode::Signed, c->memory(address, type), type));
return true; return true;
} else if ((MATCH(target->name(), "putLong") } else if ((MATCH(target->name(), "putLong")
and MATCH(target->spec(), "(JJ)V")) and MATCH(target->spec(), "(JJ)V"))
@ -3696,7 +3696,7 @@ bool intrinsic(MyThread* t UNUSED, Frame* frame, GcMethod* target)
ir::Value* address = popLongAddress(frame); ir::Value* address = popLongAddress(frame);
frame->pop(ir::Type::object()); frame->pop(ir::Type::object());
frame->pushLarge(ir::Type::i8(), frame->pushLarge(ir::Type::i8(),
c->load(ir::SignExtend, c->load(ir::ExtendMode::Signed,
c->memory(address, ir::Type::iptr()), c->memory(address, ir::Type::iptr()),
ir::Type::i8())); ir::Type::i8()));
return true; return true;
@ -3976,7 +3976,7 @@ loop:
frame->push( frame->push(
ir::Type::object(), ir::Type::object(),
c->load( c->load(
ir::SignExtend, ir::ExtendMode::Signed,
c->memory(array, ir::Type::object(), TargetArrayBody, index), c->memory(array, ir::Type::object(), TargetArrayBody, index),
ir::Type::object())); ir::Type::object()));
break; break;
@ -3984,7 +3984,7 @@ loop:
case faload: case faload:
frame->push( frame->push(
ir::Type::f4(), ir::Type::f4(),
c->load(ir::SignExtend, c->load(ir::ExtendMode::Signed,
c->memory(array, ir::Type::f4(), TargetArrayBody, index), c->memory(array, ir::Type::f4(), TargetArrayBody, index),
ir::Type::f4())); ir::Type::f4()));
break; break;
@ -3992,7 +3992,7 @@ loop:
case iaload: case iaload:
frame->push( frame->push(
ir::Type::i4(), ir::Type::i4(),
c->load(ir::SignExtend, c->load(ir::ExtendMode::Signed,
c->memory(array, ir::Type::i4(), TargetArrayBody, index), c->memory(array, ir::Type::i4(), TargetArrayBody, index),
ir::Type::i4())); ir::Type::i4()));
break; break;
@ -4000,7 +4000,7 @@ loop:
case baload: case baload:
frame->push( frame->push(
ir::Type::i4(), ir::Type::i4(),
c->load(ir::SignExtend, c->load(ir::ExtendMode::Signed,
c->memory(array, ir::Type::i1(), TargetArrayBody, index), c->memory(array, ir::Type::i1(), TargetArrayBody, index),
ir::Type::i4())); ir::Type::i4()));
break; break;
@ -4008,7 +4008,7 @@ loop:
case caload: case caload:
frame->push( frame->push(
ir::Type::i4(), ir::Type::i4(),
c->load(ir::ZeroExtend, c->load(ir::ExtendMode::Unsigned,
c->memory(array, ir::Type::i2(), TargetArrayBody, index), c->memory(array, ir::Type::i2(), TargetArrayBody, index),
ir::Type::i4())); ir::Type::i4()));
break; break;
@ -4016,7 +4016,7 @@ loop:
case daload: case daload:
frame->pushLarge( frame->pushLarge(
ir::Type::f8(), ir::Type::f8(),
c->load(ir::SignExtend, c->load(ir::ExtendMode::Signed,
c->memory(array, ir::Type::f8(), TargetArrayBody, index), c->memory(array, ir::Type::f8(), TargetArrayBody, index),
ir::Type::f8())); ir::Type::f8()));
break; break;
@ -4024,7 +4024,7 @@ loop:
case laload: case laload:
frame->pushLarge( frame->pushLarge(
ir::Type::i8(), ir::Type::i8(),
c->load(ir::SignExtend, c->load(ir::ExtendMode::Signed,
c->memory(array, ir::Type::i8(), TargetArrayBody, index), c->memory(array, ir::Type::i8(), TargetArrayBody, index),
ir::Type::i8())); ir::Type::i8()));
break; break;
@ -4032,7 +4032,7 @@ loop:
case saload: case saload:
frame->push( frame->push(
ir::Type::i4(), ir::Type::i4(),
c->load(ir::SignExtend, c->load(ir::ExtendMode::Signed,
c->memory(array, ir::Type::i2(), TargetArrayBody, index), c->memory(array, ir::Type::i2(), TargetArrayBody, index),
ir::Type::i4())); ir::Type::i4()));
break; break;
@ -4190,7 +4190,7 @@ loop:
case arraylength: { case arraylength: {
frame->push(ir::Type::i4(), frame->push(ir::Type::i4(),
c->load(ir::SignExtend, c->load(ir::ExtendMode::Signed,
c->memory(frame->pop(ir::Type::object()), c->memory(frame->pop(ir::Type::object()),
ir::Type::iptr(), ir::Type::iptr(),
TargetArrayLength), TargetArrayLength),
@ -4509,7 +4509,7 @@ loop:
case ByteField: case ByteField:
case BooleanField: case BooleanField:
frame->push(ir::Type::i4(), frame->push(ir::Type::i4(),
c->load(ir::SignExtend, c->load(ir::ExtendMode::Signed,
c->memory(table, c->memory(table,
ir::Type::i1(), ir::Type::i1(),
targetFieldOffset(context, field)), targetFieldOffset(context, field)),
@ -4518,7 +4518,7 @@ loop:
case CharField: case CharField:
frame->push(ir::Type::i4(), frame->push(ir::Type::i4(),
c->load(ir::ZeroExtend, c->load(ir::ExtendMode::Unsigned,
c->memory(table, c->memory(table,
ir::Type::i2(), ir::Type::i2(),
targetFieldOffset(context, field)), targetFieldOffset(context, field)),
@ -4527,7 +4527,7 @@ loop:
case ShortField: case ShortField:
frame->push(ir::Type::i4(), frame->push(ir::Type::i4(),
c->load(ir::SignExtend, c->load(ir::ExtendMode::Signed,
c->memory(table, c->memory(table,
ir::Type::i2(), ir::Type::i2(),
targetFieldOffset(context, field)), targetFieldOffset(context, field)),
@ -4536,7 +4536,7 @@ loop:
case FloatField: case FloatField:
frame->push(ir::Type::f4(), frame->push(ir::Type::f4(),
c->load(ir::SignExtend, c->load(ir::ExtendMode::Signed,
c->memory(table, c->memory(table,
ir::Type::f4(), ir::Type::f4(),
targetFieldOffset(context, field)), targetFieldOffset(context, field)),
@ -4545,7 +4545,7 @@ loop:
case IntField: case IntField:
frame->push(ir::Type::i4(), frame->push(ir::Type::i4(),
c->load(ir::SignExtend, c->load(ir::ExtendMode::Signed,
c->memory(table, c->memory(table,
ir::Type::i4(), ir::Type::i4(),
targetFieldOffset(context, field)), targetFieldOffset(context, field)),
@ -4554,7 +4554,7 @@ loop:
case DoubleField: case DoubleField:
frame->pushLarge(ir::Type::f8(), frame->pushLarge(ir::Type::f8(),
c->load(ir::SignExtend, c->load(ir::ExtendMode::Signed,
c->memory(table, c->memory(table,
ir::Type::f8(), ir::Type::f8(),
targetFieldOffset(context, field)), targetFieldOffset(context, field)),
@ -4563,7 +4563,7 @@ loop:
case LongField: case LongField:
frame->pushLarge(ir::Type::i8(), frame->pushLarge(ir::Type::i8(),
c->load(ir::SignExtend, c->load(ir::ExtendMode::Signed,
c->memory(table, c->memory(table,
ir::Type::i8(), ir::Type::i8(),
targetFieldOffset(context, field)), targetFieldOffset(context, field)),
@ -4572,7 +4572,7 @@ loop:
case ObjectField: case ObjectField:
frame->push(ir::Type::object(), frame->push(ir::Type::object(),
c->load(ir::SignExtend, c->load(ir::ExtendMode::Signed,
c->memory(table, c->memory(table,
ir::Type::object(), ir::Type::object(),
targetFieldOffset(context, field)), targetFieldOffset(context, field)),
@ -4662,7 +4662,7 @@ loop:
case i2b: { case i2b: {
frame->push(ir::Type::i4(), frame->push(ir::Type::i4(),
c->truncateThenExtend(ir::SignExtend, c->truncateThenExtend(ir::ExtendMode::Signed,
ir::Type::i4(), ir::Type::i4(),
ir::Type::i1(), ir::Type::i1(),
frame->pop(ir::Type::i4()))); frame->pop(ir::Type::i4())));
@ -4670,7 +4670,7 @@ loop:
case i2c: { case i2c: {
frame->push(ir::Type::i4(), frame->push(ir::Type::i4(),
c->truncateThenExtend(ir::ZeroExtend, c->truncateThenExtend(ir::ExtendMode::Unsigned,
ir::Type::i4(), ir::Type::i4(),
ir::Type::i2(), ir::Type::i2(),
frame->pop(ir::Type::i4()))); frame->pop(ir::Type::i4())));
@ -4688,7 +4688,7 @@ loop:
case i2l: case i2l:
frame->pushLarge(ir::Type::i8(), frame->pushLarge(ir::Type::i8(),
c->truncateThenExtend(ir::SignExtend, c->truncateThenExtend(ir::ExtendMode::Signed,
ir::Type::i8(), ir::Type::i8(),
ir::Type::i4(), ir::Type::i4(),
frame->pop(ir::Type::i4()))); frame->pop(ir::Type::i4())));
@ -4696,7 +4696,7 @@ loop:
case i2s: { case i2s: {
frame->push(ir::Type::i4(), frame->push(ir::Type::i4(),
c->truncateThenExtend(ir::SignExtend, c->truncateThenExtend(ir::ExtendMode::Signed,
ir::Type::i4(), ir::Type::i4(),
ir::Type::i2(), ir::Type::i2(),
frame->pop(ir::Type::i4()))); frame->pop(ir::Type::i4())));
@ -6113,7 +6113,7 @@ next:
0, 0,
normalizedKey); normalizedKey);
c->jmp(c->load(ir::SignExtend, c->jmp(c->load(ir::ExtendMode::Signed,
context->bootContext context->bootContext
? c->binaryOp(lir::Add, ? c->binaryOp(lir::Add,
ir::Type::iptr(), ir::Type::iptr(),