dotgnu-pnet-commits
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[dotgnu-pnet-commits] libjit ChangeLog jit/jit-insn.c


From: Aleksey Demakov
Subject: [dotgnu-pnet-commits] libjit ChangeLog jit/jit-insn.c
Date: Sun, 20 Apr 2008 20:24:58 +0000

CVSROOT:        /sources/dotgnu-pnet
Module name:    libjit
Changes by:     Aleksey Demakov <avd>   08/04/20 20:24:58

Modified files:
        .              : ChangeLog 
        jit            : jit-insn.c 

Log message:
        code cleanup wrt unnecessary common_binary() use

CVSWeb URLs:
http://cvs.savannah.gnu.org/viewcvs/libjit/ChangeLog?cvsroot=dotgnu-pnet&r1=1.364&r2=1.365
http://cvs.savannah.gnu.org/viewcvs/libjit/jit/jit-insn.c?cvsroot=dotgnu-pnet&r1=1.60&r2=1.61

Patches:
Index: ChangeLog
===================================================================
RCS file: /sources/dotgnu-pnet/libjit/ChangeLog,v
retrieving revision 1.364
retrieving revision 1.365
diff -u -b -r1.364 -r1.365
--- ChangeLog   20 Apr 2008 10:44:02 -0000      1.364
+++ ChangeLog   20 Apr 2008 20:24:57 -0000      1.365
@@ -12,6 +12,14 @@
        * jit/jit-rules-x86.ins: fix the sign opcode for longs (based on
        a patch from Klaus) and slightly modify it for ints.
 
+       * jit/jit-insn.c: some code cleanup:
+       (jit_insn_neg, jit_insn_abs, jit_insn_sign): for these unary ops
+       replace common_binary() with more basic function calls that should
+       suffice.
+       (jit_insn_is_nan, jit_insn_is_finite, jit_insn_is_inf): return
+       false for non-floating point values and do not use common_binary()
+       as well.
+
 2008-04-19  Klaus Treichel  <address@hidden>
 
        * jit/jit-insn.c (jit_insn_sign): the dest value of the sign insn

Index: jit/jit-insn.c
===================================================================
RCS file: /sources/dotgnu-pnet/libjit/jit/jit-insn.c,v
retrieving revision 1.60
retrieving revision 1.61
diff -u -b -r1.60 -r1.61
--- jit/jit-insn.c      19 Apr 2008 13:48:50 -0000      1.60
+++ jit/jit-insn.c      20 Apr 2008 20:24:58 -0000      1.61
@@ -836,56 +836,46 @@
 }
 
 /*
- * Apply a unary test operator, after coercing the
- * argument to an appropriate type.
+ * Apply a unary test to a floating point value.
  */
-static jit_value_t apply_test
-               (jit_function_t func, const jit_opcode_descr *descr,
-                jit_value_t value1, int float_only)
+static jit_value_t
+test_float_value(jit_function_t func, const jit_opcode_descr *descr, 
jit_value_t value1)
 {
        int oper;
-       jit_type_t result_type;
+       jit_type_t type;
+
+       /* Bail out if the parameters are invalid */
        if(!value1)
        {
                return 0;
        }
-       result_type = common_binary(value1->type, value1->type, 0, float_only);
-       if(result_type == jit_type_int)
-       {
-               oper = descr->ioper;
-       }
-       else if(result_type == jit_type_uint)
-       {
-               oper = descr->iuoper;
-       }
-       else if(result_type == jit_type_long)
-       {
-               oper = descr->loper;
-       }
-       else if(result_type == jit_type_ulong)
-       {
-               oper = descr->luoper;
-       }
-       else if(result_type == jit_type_float32)
+
+       type = jit_type_normalize(value1->type);
+       if(type == jit_type_float32)
        {
                oper = descr->foper;
        }
-       else if(result_type == jit_type_float64)
+       else if(type == jit_type_float64)
        {
                oper = descr->doper;
        }
-       else
+       else if(type == jit_type_nfloat)
        {
                oper = descr->nfoper;
        }
-       value1 = jit_insn_convert(func, value1, result_type, 0);
+       else
+       {
+               /* if the value is not a float then the result is false */
+               return jit_value_create_nint_constant(func, jit_type_int, 0);
+       }
+
        if(_jit_opcode_is_supported(oper))
        {
                return apply_unary(func, oper, value1, jit_type_int);
        }
        else
        {
-               return apply_intrinsic(func, descr, value1, 0, result_type);
+               return apply_intrinsic(func, descr, value1, 0, type);
        }
 }
 
@@ -2195,11 +2185,14 @@
        };
        int oper;
        jit_type_t result_type;
+
+       /* Bail out if the parameters are invalid */
        if(!value1)
        {
                return 0;
        }
-       result_type = common_binary(value1->type, value1->type, 0, 0);
+
+       result_type = jit_type_promote_int(jit_type_normalize(value1->type));
        if(result_type == jit_type_int)
        {
                oper = neg_descr.ioper;
@@ -2230,6 +2223,7 @@
        {
                oper = neg_descr.nfoper;
        }
+
        value1 = jit_insn_convert(func, value1, result_type, 0);
        if(_jit_opcode_is_supported(oper))
        {
@@ -3270,7 +3264,7 @@
                jit_intrinsic(jit_float64_is_nan, descr_i_d),
                jit_intrinsic(jit_nfloat_is_nan, descr_i_D)
        };
-       return apply_test(func, &is_nan_descr, value1, 1);
+       return test_float_value(func, &is_nan_descr, value1);
 }
 
 jit_value_t jit_insn_is_finite(jit_function_t func, jit_value_t value1)
@@ -3288,7 +3282,7 @@
                jit_intrinsic(jit_float64_is_finite, descr_i_d),
                jit_intrinsic(jit_nfloat_is_finite, descr_i_D)
        };
-       return apply_test(func, &is_finite_descr, value1, 1);
+       return test_float_value(func, &is_finite_descr, value1);
 }
 
 jit_value_t jit_insn_is_inf(jit_function_t func, jit_value_t value1)
@@ -3306,7 +3300,7 @@
                jit_intrinsic(jit_float64_is_inf, descr_i_d),
                jit_intrinsic(jit_nfloat_is_inf, descr_i_D)
        };
-       return apply_test(func, &is_inf_descr, value1, 1);
+       return test_float_value(func, &is_inf_descr, value1);
 }
 
 /*@
@@ -3325,11 +3319,14 @@
        const char *name;
        jit_type_t result_type;
        const jit_intrinsic_descr_t *descr;
+
+       /* Bail out if the parameters are invalid */
        if(!value1)
        {
                return 0;
        }
-       result_type = common_binary(value1->type, value1->type, 0, 0);
+
+       result_type = jit_type_promote_int(jit_type_normalize(value1->type));
        if(result_type == jit_type_int)
        {
                oper = JIT_OP_IABS;
@@ -3379,6 +3376,7 @@
                name = "jit_nfloat_abs";
                descr = &descr_D_D;
        }
+
        value1 = jit_insn_convert(func, value1, result_type, 0);
        if(!oper)
        {
@@ -3447,11 +3445,14 @@
        const char *name;
        jit_type_t result_type;
        const jit_intrinsic_descr_t *descr;
+
+       /* Bail out if the parameters are invalid */
        if(!value1)
        {
                return 0;
        }
-       result_type = common_binary(value1->type, value1->type, 0, 0);
+
+       result_type = jit_type_promote_int(jit_type_normalize(value1->type));
        if(result_type == jit_type_int)
        {
                oper = JIT_OP_ISIGN;
@@ -3499,6 +3500,7 @@
                name = "jit_nfloat_sign";
                descr = &descr_i_D;
        }
+
        value1 = jit_insn_convert(func, value1, result_type, 0);
        if(_jit_opcode_is_supported(oper))
        {




reply via email to

[Prev in Thread] Current Thread [Next in Thread]