ifdef HAVE_INT128
[m6w6/ext-psi] / src / calc / bin.h
index 3e9e4a0872d777195b9fe3ac9c807499498578da..ab79f21206cdb9783b9bba512ea31826cd854ee3 100644 (file)
@@ -65,6 +65,20 @@ static inline token_t psi_calc_bin_lshift(token_t t1, impl_val *v1, token_t t2,
                i1.u64 = v1->u64;
                break;
 
+#if HAVE_INT128
+       case PSI_T_INT128:
+               i1.u64 = v1->i128;
+               break;
+
+#endif
+
+#if HAVE_UINT128
+       case PSI_T_UINT128:
+               i1.u64 = v1->u128;
+               break;
+
+#endif
+
        case PSI_T_FLOAT:
                i1.u64 = v1->fval;
                break;
@@ -110,6 +124,18 @@ static inline token_t psi_calc_bin_lshift(token_t t1, impl_val *v1, token_t t2,
        case PSI_T_UINT64:
                i2.u64 = v2->u64;
                break;
+#if HAVE_INT128
+       case PSI_T_INT128:
+               i2.u64 = v2->i128;
+               break;
+#endif
+
+#if HAVE_UINT128
+       case PSI_T_UINT128:
+               i2.u64 = v2->u128;
+               break;
+#endif
+
        case PSI_T_FLOAT:
                i2.u64 = v2->fval;
                break;
@@ -168,6 +194,20 @@ static inline token_t psi_calc_bin_rshift(token_t t1, impl_val *v1, token_t t2,
                i1.u64 = v1->u64;
                break;
 
+#if HAVE_INT128
+       case PSI_T_INT128:
+               i1.u64 = v1->i128;
+               break;
+
+#endif
+
+#if HAVE_UINT128
+       case PSI_T_UINT128:
+               i1.u64 = v1->u128;
+               break;
+
+#endif
+
        case PSI_T_FLOAT:
                i1.u64 = v1->fval;
                break;
@@ -213,6 +253,18 @@ static inline token_t psi_calc_bin_rshift(token_t t1, impl_val *v1, token_t t2,
        case PSI_T_UINT64:
                i2.u64 = v2->u64;
                break;
+#if HAVE_INT128
+       case PSI_T_INT128:
+               i2.u64 = v2->i128;
+               break;
+#endif
+
+#if HAVE_UINT128
+       case PSI_T_UINT128:
+               i2.u64 = v2->u128;
+               break;
+#endif
+
        case PSI_T_FLOAT:
                i2.u64 = v2->fval;
                break;
@@ -271,6 +323,20 @@ static inline token_t psi_calc_bin_and(token_t t1, impl_val *v1, token_t t2, imp
                i1.u64 = v1->u64;
                break;
 
+#if HAVE_INT128
+       case PSI_T_INT128:
+               i1.u64 = v1->i128;
+               break;
+
+#endif
+
+#if HAVE_UINT128
+       case PSI_T_UINT128:
+               i1.u64 = v1->u128;
+               break;
+
+#endif
+
        case PSI_T_FLOAT:
                i1.u64 = v1->fval;
                break;
@@ -316,6 +382,18 @@ static inline token_t psi_calc_bin_and(token_t t1, impl_val *v1, token_t t2, imp
        case PSI_T_UINT64:
                i2.u64 = v2->u64;
                break;
+#if HAVE_INT128
+       case PSI_T_INT128:
+               i2.u64 = v2->i128;
+               break;
+#endif
+
+#if HAVE_UINT128
+       case PSI_T_UINT128:
+               i2.u64 = v2->u128;
+               break;
+#endif
+
        case PSI_T_FLOAT:
                i2.u64 = v2->fval;
                break;
@@ -374,6 +452,20 @@ static inline token_t psi_calc_bin_xor(token_t t1, impl_val *v1, token_t t2, imp
                i1.u64 = v1->u64;
                break;
 
+#if HAVE_INT128
+       case PSI_T_INT128:
+               i1.u64 = v1->i128;
+               break;
+
+#endif
+
+#if HAVE_UINT128
+       case PSI_T_UINT128:
+               i1.u64 = v1->u128;
+               break;
+
+#endif
+
        case PSI_T_FLOAT:
                i1.u64 = v1->fval;
                break;
@@ -419,6 +511,18 @@ static inline token_t psi_calc_bin_xor(token_t t1, impl_val *v1, token_t t2, imp
        case PSI_T_UINT64:
                i2.u64 = v2->u64;
                break;
+#if HAVE_INT128
+       case PSI_T_INT128:
+               i2.u64 = v2->i128;
+               break;
+#endif
+
+#if HAVE_UINT128
+       case PSI_T_UINT128:
+               i2.u64 = v2->u128;
+               break;
+#endif
+
        case PSI_T_FLOAT:
                i2.u64 = v2->fval;
                break;
@@ -477,6 +581,20 @@ static inline token_t psi_calc_bin_or(token_t t1, impl_val *v1, token_t t2, impl
                i1.u64 = v1->u64;
                break;
 
+#if HAVE_INT128
+       case PSI_T_INT128:
+               i1.u64 = v1->i128;
+               break;
+
+#endif
+
+#if HAVE_UINT128
+       case PSI_T_UINT128:
+               i1.u64 = v1->u128;
+               break;
+
+#endif
+
        case PSI_T_FLOAT:
                i1.u64 = v1->fval;
                break;
@@ -522,80 +640,28 @@ static inline token_t psi_calc_bin_or(token_t t1, impl_val *v1, token_t t2, impl
        case PSI_T_UINT64:
                i2.u64 = v2->u64;
                break;
-       case PSI_T_FLOAT:
-               i2.u64 = v2->fval;
-               break;
-       case PSI_T_DOUBLE:
-               i2.u64 = v2->dval;
-               break;
-#if HAVE_LONG_DOUBLE
-       case PSI_T_LONG_DOUBLE:
-               i2.u64 = v2->ldval;
+#if HAVE_INT128
+       case PSI_T_INT128:
+               i2.u64 = v2->i128;
                break;
 #endif
 
-       default:
-               assert(0);
-               break;
-       }
-
-       res->u64 = i1.u64 | i2.u64;
-       return PSI_T_UINT64;
-}
-
-static inline token_t psi_calc_bin_not(token_t t1, impl_val *v1, token_t t2, impl_val *v2, impl_val *res)
-{
-       impl_val i1;
-
-       (void) t2;
-       (void) v2;
-
-       switch (t1) {
-       case PSI_T_INT8:
-               i1.u64 = v1->i8;
-               break;
-
-       case PSI_T_UINT8:
-               i1.u64 = v1->u8;
-               break;
-
-       case PSI_T_INT16:
-               i1.u64 = v1->i16;
-               break;
-
-       case PSI_T_UINT16:
-               i1.u64 = v1->u16;
-               break;
-
-       case PSI_T_INT32:
-               i1.u64 = v1->i32;
-               break;
-
-       case PSI_T_UINT32:
-               i1.u64 = v1->u32;
-               break;
-
-       case PSI_T_INT64:
-               i1.u64 = v1->i64;
-               break;
-
-       case PSI_T_UINT64:
-               i1.u64 = v1->u64;
+#if HAVE_UINT128
+       case PSI_T_UINT128:
+               i2.u64 = v2->u128;
                break;
+#endif
 
        case PSI_T_FLOAT:
-               i1.u64 = v1->fval;
+               i2.u64 = v2->fval;
                break;
-
        case PSI_T_DOUBLE:
-               i1.u64 = v1->dval;
+               i2.u64 = v2->dval;
                break;
-
 #if HAVE_LONG_DOUBLE
        case PSI_T_LONG_DOUBLE:
-               i1.u64 = v1->ldval;
+               i2.u64 = v2->ldval;
                break;
-
 #endif
 
        default:
@@ -603,6 +669,6 @@ static inline token_t psi_calc_bin_not(token_t t1, impl_val *v1, token_t t2, imp
                break;
        }
 
-       res->u64 = ~i1.u64;
+       res->u64 = i1.u64 | i2.u64;
        return PSI_T_UINT64;
-}
\ No newline at end of file
+}