From 6ed7681dc0627a7d87a8cea44c0b4ac5a792f1d6 Mon Sep 17 00:00:00 2001 From: Joshua Warner Date: Wed, 30 Apr 2014 22:02:57 -0600 Subject: [PATCH] use ir::Type in f2i and friends, instead of aSize --- include/avian/codegen/compiler.h | 6 +++--- src/codegen/compiler.cpp | 20 ++++++++++++++------ src/compile.cpp | 24 ++++++++++++------------ 3 files changed, 29 insertions(+), 21 deletions(-) diff --git a/include/avian/codegen/compiler.h b/include/avian/codegen/compiler.h index c8375f49c6..c38636161d 100644 --- a/include/avian/codegen/compiler.h +++ b/include/avian/codegen/compiler.h @@ -127,9 +127,9 @@ class Compiler { virtual Operand* unaryOp(lir::BinaryOperation type, unsigned size, Operand* a) = 0; virtual void nullaryOp(lir::Operation type) = 0; - virtual Operand* f2f(unsigned aSize, ir::Type resType, Operand* a) = 0; - virtual Operand* f2i(unsigned aSize, ir::Type resType, Operand* a) = 0; - virtual Operand* i2f(unsigned aSize, ir::Type resType, Operand* a) = 0; + virtual Operand* f2f(ir::Type aType, ir::Type resType, Operand* a) = 0; + virtual Operand* f2i(ir::Type aType, ir::Type resType, Operand* a) = 0; + virtual Operand* i2f(ir::Type aType, ir::Type resType, Operand* a) = 0; virtual void compile(uintptr_t stackOverflowHandler, unsigned stackLimitOffset) = 0; diff --git a/src/codegen/compiler.cpp b/src/codegen/compiler.cpp index 496f29e2a3..d298b24c70 100644 --- a/src/codegen/compiler.cpp +++ b/src/codegen/compiler.cpp @@ -2649,42 +2649,50 @@ class MyCompiler: public Compiler { return result; } - virtual Operand* f2f(unsigned aSize, ir::Type resType, Operand* a) + virtual Operand* f2f(ir::Type aType, ir::Type resType, Operand* a) { + assert(&c, aType == static_cast(a)->type); assert(&c, isFloatValue(a)); assert(&c, resType.flavor() == ir::Type::Float); + assert(&c, aType.flavor() == ir::Type::Float); Value* result = value(&c, resType); appendTranslate(&c, lir::Float2Float, - aSize, + aType.size(), static_cast(a), resType.size(), result); return result; } - virtual Operand* f2i(unsigned aSize, ir::Type resType, Operand* a) + virtual Operand* f2i(ir::Type aType, ir::Type resType, Operand* a) { + // TODO: enable when possible + // assert(&c, aType == static_cast(a)->type); assert(&c, isFloatValue(a)); assert(&c, resType.flavor() != ir::Type::Float); + assert(&c, aType.flavor() == ir::Type::Float); Value* result = value(&c, resType); appendTranslate(&c, lir::Float2Int, - aSize, + aType.size(), static_cast(a), resType.size(), result); return result; } - virtual Operand* i2f(unsigned aSize, ir::Type resType, Operand* a) + virtual Operand* i2f(ir::Type aType, ir::Type resType, Operand* a) { + // TODO: enable when possible + // assert(&c, aType == static_cast(a)->type); assert(&c, isGeneralValue(a)); assert(&c, resType.flavor() == ir::Type::Float); + assert(&c, aType.flavor() != ir::Type::Float); Value* result = value(&c, resType); appendTranslate(&c, lir::Int2Float, - aSize, + aType.size(), static_cast(a), resType.size(), result); diff --git a/src/compile.cpp b/src/compile.cpp index 360be4a5ba..5cc52c3f56 100644 --- a/src/compile.cpp +++ b/src/compile.cpp @@ -4417,15 +4417,15 @@ compile(MyThread* t, Frame* initialFrame, unsigned initialIp, } break; case d2f: { - frame->pushInt(c->f2f(8, types.f4, frame->popLong())); + frame->pushInt(c->f2f(types.f8, types.f4, frame->popLong())); } break; case d2i: { - frame->pushInt(c->f2i(8, types.i4, frame->popLong())); + frame->pushInt(c->f2i(types.f8, types.i4, frame->popLong())); } break; case d2l: { - frame->pushLong(c->f2i(8, types.i8, frame->popLong())); + frame->pushLong(c->f2i(types.f8, types.i8, frame->popLong())); } break; case dadd: @@ -4518,15 +4518,15 @@ compile(MyThread* t, Frame* initialFrame, unsigned initialIp, break; case f2d: { - frame->pushLong(c->f2f(4, types.f8, frame->popInt())); + frame->pushLong(c->f2f(types.f4, types.f8, frame->popInt())); } break; case f2i: { - frame->pushInt(c->f2i(4, types.i4, frame->popInt())); + frame->pushInt(c->f2i(types.f4, types.i4, frame->popInt())); } break; case f2l: { - frame->pushLong(c->f2i(4, types.i8, frame->popInt())); + frame->pushLong(c->f2i(types.f4, types.i8, frame->popInt())); } break; case fadd: @@ -4706,7 +4706,7 @@ compile(MyThread* t, Frame* initialFrame, unsigned initialIp, 8, 8, c->memory( - table, types.f4, targetFieldOffset(context, field), 0, 1), + table, types.f8, targetFieldOffset(context, field), 0, 1), 8)); break; @@ -4715,7 +4715,7 @@ compile(MyThread* t, Frame* initialFrame, unsigned initialIp, 8, 8, c->memory( - table, types.i4, targetFieldOffset(context, field), 0, 1), + table, types.i8, targetFieldOffset(context, field), 0, 1), 8)); break; @@ -4828,11 +4828,11 @@ compile(MyThread* t, Frame* initialFrame, unsigned initialIp, } break; case i2d: { - frame->pushLong(c->i2f(4, types.f8, frame->popInt())); + frame->pushLong(c->i2f(types.i4, types.f8, frame->popInt())); } break; case i2f: { - frame->pushInt(c->i2f(4, types.f4, frame->popInt())); + frame->pushInt(c->i2f(types.i4, types.f4, frame->popInt())); } break; case i2l: @@ -5331,11 +5331,11 @@ compile(MyThread* t, Frame* initialFrame, unsigned initialIp, } goto start; case l2d: { - frame->pushLong(c->i2f(8, types.f8, frame->popLong())); + frame->pushLong(c->i2f(types.i8, types.f8, frame->popLong())); } break; case l2f: { - frame->pushInt(c->i2f(8, types.f4, frame->popLong())); + frame->pushInt(c->i2f(types.i8, types.f4, frame->popLong())); } break; case l2i: