Rename float opcodes.

This commit is contained in:
David Anderson 2014-12-14 18:57:22 -08:00
parent ce55dc6961
commit 7eae305da6
3 changed files with 62 additions and 66 deletions

View File

@ -235,24 +235,24 @@ namespace sp {
_(STRADJUST_PRI, "stradjust.pri") \ _(STRADJUST_PRI, "stradjust.pri") \
_(UNGEN_STKADJUST,"stackadjust") \ _(UNGEN_STKADJUST,"stackadjust") \
_(ENDPROC, "endproc") \ _(ENDPROC, "endproc") \
_(FABS, "fabs") \ _(ABS_F32, "abs.f32") \
_(FLOAT, "float") \ _(CVT_I32_TO_F32, "cvt.i32.f32") \
_(FLOATADD, "float.add") \ _(ADD_F32, "add.f32") \
_(FLOATSUB, "float.sub") \ _(SUB_F32, "sub.f32") \
_(FLOATMUL, "float.mul") \ _(MUL_F32, "mul.f32") \
_(FLOATDIV, "float.div") \ _(DIV_F32, "div.f32") \
_(RND_TO_NEAREST, "round") \ _(RND_F32_TO_NEAREST, "round.f32") \
_(RND_TO_FLOOR, "floor") \ _(RND_F32_TO_FLOOR, "floor.f32") \
_(RND_TO_CEIL, "ceil") \ _(RND_F32_TO_CEIL, "ceil.f32") \
_(RND_TO_ZERO, "rndtozero") \ _(RND_F32_TO_ZERO, "rndtozero.f32") \
_(FLOATCMP, "float.cmp") \ _(CMP_F32, "cmp.f32") \
_(FLOAT_GT, "float.gt") \ _(GT_F32, "gt.f32") \
_(FLOAT_GE, "float.ge") \ _(GE_F32, "ge.f32") \
_(FLOAT_LT, "float.lt") \ _(LT_F32, "lt.f32") \
_(FLOAT_LE, "float.le") \ _(LE_F32, "le.f32") \
_(FLOAT_NE, "float.ne") \ _(NE_F32, "ne.f32") \
_(FLOAT_EQ, "float.eq") \ _(EQ_F32, "eq.f32") \
_(FLOAT_NOT, "float.not") _(NOT_F32, "not.f32")
enum OPCODE { enum OPCODE {
#define _(op, text) OP_##op, #define _(op, text) OP_##op,

View File

@ -82,24 +82,24 @@ struct NativeMapping {
}; };
static const NativeMapping sNativeMap[] = { static const NativeMapping sNativeMap[] = {
{ "FloatAbs", OP_FABS }, { "FloatAbs", OP_ABS_F32 },
{ "FloatAdd", OP_FLOATADD }, { "FloatAdd", OP_ADD_F32 },
{ "FloatSub", OP_FLOATSUB }, { "FloatSub", OP_SUB_F32 },
{ "FloatMul", OP_FLOATMUL }, { "FloatMul", OP_MUL_F32 },
{ "FloatDiv", OP_FLOATDIV }, { "FloatDiv", OP_DIV_F32 },
{ "float", OP_FLOAT }, { "float", OP_CVT_I32_TO_F32 },
{ "FloatCompare", OP_FLOATCMP }, { "FloatCompare", OP_CMP_F32 },
{ "RoundToCeil", OP_RND_TO_CEIL }, { "RoundToCeil", OP_RND_F32_TO_CEIL },
{ "RoundToZero", OP_RND_TO_ZERO }, { "RoundToZero", OP_RND_F32_TO_ZERO },
{ "RoundToFloor", OP_RND_TO_FLOOR }, { "RoundToFloor", OP_RND_F32_TO_FLOOR },
{ "RoundToNearest", OP_RND_TO_NEAREST }, { "RoundToNearest", OP_RND_F32_TO_NEAREST },
{ "__FLOAT_GT__", OP_FLOAT_GT }, { "__FLOAT_GT__", OP_GT_F32 },
{ "__FLOAT_GE__", OP_FLOAT_GE }, { "__FLOAT_GE__", OP_GE_F32 },
{ "__FLOAT_LT__", OP_FLOAT_LT }, { "__FLOAT_LT__", OP_LT_F32 },
{ "__FLOAT_LE__", OP_FLOAT_LE }, { "__FLOAT_LE__", OP_LE_F32 },
{ "__FLOAT_EQ__", OP_FLOAT_EQ }, { "__FLOAT_EQ__", OP_EQ_F32 },
{ "__FLOAT_NE__", OP_FLOAT_NE }, { "__FLOAT_NE__", OP_NE_F32 },
{ "__FLOAT_NOT__", OP_FLOAT_NOT }, { "__FLOAT_NOT__", OP_NOT_F32 },
{ NULL, 0 }, { NULL, 0 },
}; };

View File

@ -43,10 +43,6 @@
using namespace sp; using namespace sp;
using namespace Knight; using namespace Knight;
#if defined USE_UNGEN_OPCODES
#include "ungen_opcodes.h"
#endif
#define __ masm. #define __ masm.
JITX86 g_Jit; JITX86 g_Jit;
@ -977,13 +973,13 @@ Compiler::emitOp(OPCODE op)
__ sarl(pri, 2); __ sarl(pri, 2);
break; break;
case OP_FABS: case OP_ABS_F32:
__ movl(pri, Operand(stk, 0)); __ movl(pri, Operand(stk, 0));
__ andl(pri, 0x7fffffff); __ andl(pri, 0x7fffffff);
__ addl(stk, 4); __ addl(stk, 4);
break; break;
case OP_FLOAT: case OP_CVT_I32_TO_F32:
if (MacroAssemblerX86::Features().sse2) { if (MacroAssemblerX86::Features().sse2) {
__ cvtsi2ss(xmm0, Operand(edi, 0)); __ cvtsi2ss(xmm0, Operand(edi, 0));
__ movd(pri, xmm0); __ movd(pri, xmm0);
@ -996,32 +992,32 @@ Compiler::emitOp(OPCODE op)
__ addl(stk, 4); __ addl(stk, 4);
break; break;
case OP_FLOATADD: case OP_ADD_F32:
case OP_FLOATSUB: case OP_SUB_F32:
case OP_FLOATMUL: case OP_MUL_F32:
case OP_FLOATDIV: case OP_DIV_F32:
if (MacroAssemblerX86::Features().sse2) { if (MacroAssemblerX86::Features().sse2) {
__ movss(xmm0, Operand(stk, 0)); __ movss(xmm0, Operand(stk, 0));
if (op == OP_FLOATADD) if (op == OP_ADD_F32)
__ addss(xmm0, Operand(stk, 4)); __ addss(xmm0, Operand(stk, 4));
else if (op == OP_FLOATSUB) else if (op == OP_SUB_F32)
__ subss(xmm0, Operand(stk, 4)); __ subss(xmm0, Operand(stk, 4));
else if (op == OP_FLOATMUL) else if (op == OP_MUL_F32)
__ mulss(xmm0, Operand(stk, 4)); __ mulss(xmm0, Operand(stk, 4));
else if (op == OP_FLOATDIV) else if (op == OP_DIV_F32)
__ divss(xmm0, Operand(stk, 4)); __ divss(xmm0, Operand(stk, 4));
__ movd(pri, xmm0); __ movd(pri, xmm0);
} else { } else {
__ subl(esp, 4); __ subl(esp, 4);
__ fld32(Operand(stk, 0)); __ fld32(Operand(stk, 0));
if (op == OP_FLOATADD) if (op == OP_ADD_F32)
__ fadd32(Operand(stk, 4)); __ fadd32(Operand(stk, 4));
else if (op == OP_FLOATSUB) else if (op == OP_SUB_F32)
__ fsub32(Operand(stk, 4)); __ fsub32(Operand(stk, 4));
else if (op == OP_FLOATMUL) else if (op == OP_MUL_F32)
__ fmul32(Operand(stk, 4)); __ fmul32(Operand(stk, 4));
else if (op == OP_FLOATDIV) else if (op == OP_DIV_F32)
__ fdiv32(Operand(stk, 4)); __ fdiv32(Operand(stk, 4));
__ fstp32(Operand(esp, 0)); __ fstp32(Operand(esp, 0));
@ -1030,7 +1026,7 @@ Compiler::emitOp(OPCODE op)
__ addl(stk, 8); __ addl(stk, 8);
break; break;
case OP_RND_TO_NEAREST: case OP_RND_F32_TO_NEAREST:
{ {
if (MacroAssemblerX86::Features().sse) { if (MacroAssemblerX86::Features().sse) {
// Assume no one is touching MXCSR. // Assume no one is touching MXCSR.
@ -1050,7 +1046,7 @@ Compiler::emitOp(OPCODE op)
break; break;
} }
case OP_RND_TO_CEIL: case OP_RND_F32_TO_CEIL:
{ {
static float kRoundToCeil = -0.5f; static float kRoundToCeil = -0.5f;
// From http://wurstcaptures.untergrund.net/assembler_tricks.html#fastfloorf // From http://wurstcaptures.untergrund.net/assembler_tricks.html#fastfloorf
@ -1066,7 +1062,7 @@ Compiler::emitOp(OPCODE op)
break; break;
} }
case OP_RND_TO_ZERO: case OP_RND_F32_TO_ZERO:
if (MacroAssemblerX86::Features().sse) { if (MacroAssemblerX86::Features().sse) {
__ cvttss2si(pri, Operand(stk, 0)); __ cvttss2si(pri, Operand(stk, 0));
} else { } else {
@ -1083,7 +1079,7 @@ Compiler::emitOp(OPCODE op)
__ addl(stk, 4); __ addl(stk, 4);
break; break;
case OP_RND_TO_FLOOR: case OP_RND_F32_TO_FLOOR:
__ fld32(Operand(stk, 0)); __ fld32(Operand(stk, 0));
__ subl(esp, 8); __ subl(esp, 8);
__ fstcw(Operand(esp, 4)); __ fstcw(Operand(esp, 4));
@ -1100,7 +1096,7 @@ Compiler::emitOp(OPCODE op)
// compiled code it should not be used or generated. // compiled code it should not be used or generated.
// //
// Note that the checks here are inverted: the test is |rhs OP lhs|. // Note that the checks here are inverted: the test is |rhs OP lhs|.
case OP_FLOATCMP: case OP_CMP_F32:
{ {
Label bl, ab, done; Label bl, ab, done;
if (MacroAssemblerX86::Features().sse) { if (MacroAssemblerX86::Features().sse) {
@ -1126,31 +1122,31 @@ Compiler::emitOp(OPCODE op)
break; break;
} }
case OP_FLOAT_GT: case OP_GT_F32:
emitFloatCmp(above); emitFloatCmp(above);
break; break;
case OP_FLOAT_GE: case OP_GE_F32:
emitFloatCmp(above_equal); emitFloatCmp(above_equal);
break; break;
case OP_FLOAT_LE: case OP_LE_F32:
emitFloatCmp(below_equal); emitFloatCmp(below_equal);
break; break;
case OP_FLOAT_LT: case OP_LT_F32:
emitFloatCmp(below); emitFloatCmp(below);
break; break;
case OP_FLOAT_EQ: case OP_EQ_F32:
emitFloatCmp(equal); emitFloatCmp(equal);
break; break;
case OP_FLOAT_NE: case OP_NE_F32:
emitFloatCmp(not_equal); emitFloatCmp(not_equal);
break; break;
case OP_FLOAT_NOT: case OP_NOT_F32:
{ {
if (MacroAssemblerX86::Features().sse) { if (MacroAssemblerX86::Features().sse) {
__ xorps(xmm0, xmm0); __ xorps(xmm0, xmm0);