Skip to content

Commit

Permalink
added native double round(double) function
Browse files Browse the repository at this point in the history
  • Loading branch information
mmaulwurff authored and madame-rachelle committed Jun 7, 2019
1 parent d5cb48b commit fc701c8
Show file tree
Hide file tree
Showing 6 changed files with 10 additions and 0 deletions.
2 changes: 2 additions & 0 deletions src/scripting/backend/codegen.cpp
Expand Up @@ -82,6 +82,8 @@ static const FLOP FxFlops[] =
{ NAME_CosH, FLOP_COSH, [](double v) { return g_cosh(v); } },
{ NAME_SinH, FLOP_SINH, [](double v) { return g_sinh(v); } },
{ NAME_TanH, FLOP_TANH, [](double v) { return g_tanh(v); } },

{ NAME_Round, FLOP_ROUND, [](double v) { return round(v); } },
};


Expand Down
2 changes: 2 additions & 0 deletions src/scripting/backend/vmdisasm.cpp
Expand Up @@ -181,6 +181,8 @@ static const char *const FlopNames[] =
"cosh",
"sinh",
"tanh",

"round",
};

static int print_reg(FILE *out, int col, int arg, int mode, int immshift, const VMScriptFunction *func);
Expand Down
1 change: 1 addition & 0 deletions src/scripting/vm/jit_math.cpp
Expand Up @@ -985,6 +985,7 @@ void JitCompiler::EmitFLOP()
case FLOP_COSH: func = g_cosh; break;
case FLOP_SINH: func = g_sinh; break;
case FLOP_TANH: func = g_tanh; break;
case FLOP_ROUND: func = round; break;
}

auto result = newResultXmmSd();
Expand Down
2 changes: 2 additions & 0 deletions src/scripting/vm/vmexec.h
Expand Up @@ -1741,6 +1741,8 @@ static double DoFLOP(int flop, double v)
case FLOP_COSH: return g_cosh(v);
case FLOP_SINH: return g_sinh(v);
case FLOP_TANH: return g_tanh(v);

case FLOP_ROUND: return round(v);
}
assert(0);
return 0;
Expand Down
2 changes: 2 additions & 0 deletions src/scripting/vm/vmintern.h
Expand Up @@ -101,6 +101,8 @@ enum
FLOP_COSH,
FLOP_SINH,
FLOP_TANH,

FLOP_ROUND,
};

// Cast operations
Expand Down
1 change: 1 addition & 0 deletions src/utility/namedef.h
Expand Up @@ -363,6 +363,7 @@ xx(Tan)
xx(CosH)
xx(SinH)
xx(TanH)
xx(Round)
xx(ATan2)
xx(VectorAngle)
xx(New)
Expand Down

0 comments on commit fc701c8

Please sign in to comment.