Signed-off-by: Arthur HUILLET <[email protected]>
---
 include/jit/expression.h      |    6 ++++++
 include/vm/system.h           |   10 ++++++++++
 jit/arithmetic-bc.c           |    8 ++++----
 jit/tree-printer.c            |    4 ++++
 test/jit/arithmetic-bc-test.c |    8 ++++----
 5 files changed, 28 insertions(+), 8 deletions(-)

diff --git a/include/jit/expression.h b/include/jit/expression.h
index beeabbe..d18aebd 100644
--- a/include/jit/expression.h
+++ b/include/jit/expression.h
@@ -74,6 +74,12 @@ enum binary_operator {
        OP_GE,
        OP_GT,
        OP_LE,
+
+       OP_FADD,
+       OP_FSUB,
+       OP_FMUL,
+       OP_FDIV,
+
        BINOP_LAST,     /* Not a real operator. Keep this last. */
 };
 
diff --git a/include/vm/system.h b/include/vm/system.h
index a6d756c..f215118 100644
--- a/include/vm/system.h
+++ b/include/vm/system.h
@@ -43,4 +43,14 @@ static inline float uint32_to_float(uint32_t value)
        return a.fv;
 }
 
+static inline int float_to_uint32(float value)
+{
+       union {
+               uint32_t        iv;
+               float           val;
+       } a;
+       a.val = value;
+       return a.iv;
+}
+
 #endif
diff --git a/jit/arithmetic-bc.c b/jit/arithmetic-bc.c
index 94052b9..e07a3d1 100644
--- a/jit/arithmetic-bc.c
+++ b/jit/arithmetic-bc.c
@@ -45,7 +45,7 @@ int convert_ladd(struct parse_context *ctx)
 
 int convert_fadd(struct parse_context *ctx)
 {
-       return convert_binop(ctx, J_FLOAT, OP_ADD);
+       return convert_binop(ctx, J_FLOAT, OP_FADD);
 }
 
 int convert_dadd(struct parse_context *ctx)
@@ -65,7 +65,7 @@ int convert_lsub(struct parse_context *ctx)
 
 int convert_fsub(struct parse_context *ctx)
 {
-       return convert_binop(ctx, J_FLOAT, OP_SUB);
+       return convert_binop(ctx, J_FLOAT, OP_FSUB);
 }
 
 int convert_dsub(struct parse_context *ctx)
@@ -85,7 +85,7 @@ int convert_lmul(struct parse_context *ctx)
 
 int convert_fmul(struct parse_context *ctx)
 {
-       return convert_binop(ctx, J_FLOAT, OP_MUL);
+       return convert_binop(ctx, J_FLOAT, OP_FMUL);
 }
 
 int convert_dmul(struct parse_context *ctx)
@@ -105,7 +105,7 @@ int convert_ldiv(struct parse_context *ctx)
 
 int convert_fdiv(struct parse_context *ctx)
 {
-       return convert_binop(ctx, J_FLOAT, OP_DIV);
+       return convert_binop(ctx, J_FLOAT, OP_FDIV);
 }
 
 int convert_ddiv(struct parse_context *ctx)
diff --git a/jit/tree-printer.c b/jit/tree-printer.c
index b2944bd..c1a5852 100644
--- a/jit/tree-printer.c
+++ b/jit/tree-printer.c
@@ -397,6 +397,10 @@ static const char *op_names[] = {
        [OP_DIV_64] = "div64",
        [OP_REM] = "rem",
        [OP_REM_64] = "rem64",
+       [OP_FADD] = "fadd",
+       [OP_FSUB] = "fsub",
+       [OP_FMUL] = "fmul",
+       [OP_FDIV] = "fdiv",
        [OP_SHL] = "shl",
        [OP_SHL_64] = "shl64",
        [OP_SHR] = "shr",
diff --git a/test/jit/arithmetic-bc-test.c b/test/jit/arithmetic-bc-test.c
index 337fbf3..98feabe 100644
--- a/test/jit/arithmetic-bc-test.c
+++ b/test/jit/arithmetic-bc-test.c
@@ -64,7 +64,7 @@ void test_convert_add(void)
 {
        assert_convert_binop(J_INT, OP_ADD, OPC_IADD);
        assert_convert_binop(J_LONG, OP_ADD, OPC_LADD);
-       assert_convert_binop(J_FLOAT, OP_ADD, OPC_FADD);
+       assert_convert_binop(J_FLOAT, OP_FADD, OPC_FADD);
        assert_convert_binop(J_DOUBLE, OP_ADD, OPC_DADD);
 }
 
@@ -72,7 +72,7 @@ void test_convert_sub(void)
 {
        assert_convert_binop(J_INT, OP_SUB, OPC_ISUB);
        assert_convert_binop(J_LONG, OP_SUB, OPC_LSUB);
-       assert_convert_binop(J_FLOAT, OP_SUB, OPC_FSUB);
+       assert_convert_binop(J_FLOAT, OP_FSUB, OPC_FSUB);
        assert_convert_binop(J_DOUBLE, OP_SUB, OPC_DSUB);
 }
 
@@ -80,7 +80,7 @@ void test_convert_mul(void)
 {
        assert_convert_binop(J_INT, OP_MUL, OPC_IMUL);
        assert_convert_binop(J_LONG, OP_MUL_64, OPC_LMUL);
-       assert_convert_binop(J_FLOAT, OP_MUL, OPC_FMUL);
+       assert_convert_binop(J_FLOAT, OP_FMUL, OPC_FMUL);
        assert_convert_binop(J_DOUBLE, OP_MUL, OPC_DMUL);
 }
 
@@ -88,7 +88,7 @@ void test_convert_div(void)
 {
        assert_convert_binop(J_INT, OP_DIV, OPC_IDIV);
        assert_convert_binop(J_LONG, OP_DIV_64, OPC_LDIV);
-       assert_convert_binop(J_FLOAT, OP_DIV, OPC_FDIV);
+       assert_convert_binop(J_FLOAT, OP_FDIV, OPC_FDIV);
        assert_convert_binop(J_DOUBLE, OP_DIV, OPC_DDIV);
 }
 
-- 
1.6.3.2



------------------------------------------------------------------------------
_______________________________________________
Jatovm-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/jatovm-devel

Reply via email to