do bit operations according to IEEE754 spec. Also include
         convert_double_rtp(2,4,8,16) support

Signed-off-by: rander <[email protected]>
---
 backend/src/libocl/script/ocl_convert.sh | 99 ++++++++++++++++++++++++++++++++
 1 file changed, 99 insertions(+)

diff --git a/backend/src/libocl/script/ocl_convert.sh 
b/backend/src/libocl/script/ocl_convert.sh
index 1a3f1f3..c9144c2 100755
--- a/backend/src/libocl/script/ocl_convert.sh
+++ b/backend/src/libocl/script/ocl_convert.sh
@@ -1245,6 +1245,105 @@ for vector_length in $VECTOR_LENGTHS; do
     done
 done
 
+if [ $1"a" != "-pa" ]; then
+echo '
+OVERLOADABLE double convert_double_rtp(ulong x)
+{
+       long exp;
+       long ret, ma, tmp;
+       int msbOne = 64 -clz(x);
+
+       exp = msbOne + DF_EXP_BIAS - 1;
+       ret = (exp << 52);
+       int shift = abs(53 - msbOne);
+       tmp = ret | ((x << shift) &DF_MAN_MASK);
+
+       ma = (x & ((0x1 << shift) - 1));
+       ret |= (x >> shift) &DF_MAN_MASK;
+       if(ma) ret += 1;
+
+       ret = (msbOne < 54) ? tmp:ret;
+       ret = (msbOne == 0) ? 0:ret;
+
+       return as_double(ret);
+}
+
+OVERLOADABLE double convert_double_rtz(ulong x)
+{
+       return 0;
+}
+
+OVERLOADABLE double convert_double_rtn(ulong x)
+{
+       return 0;
+}
+
+OVERLOADABLE double convert_double_rte(ulong x)
+{
+       return 0;
+}
+'
+fi
+
+TTYPES=" ulong:8"
+for vector_length in $VECTOR_LENGTHS; do
+    for ftype in $TTYPES; do
+       fbasetype=`IFS=:; set -- dummy $ftype; echo $2`
+
+           if test $vector_length -eq 1; then
+               if [ $1"a" = "-pa" ]; then
+                   echo "OVERLOADABLE double convert_double_rte($fbasetype x);"
+                   echo "OVERLOADABLE double convert_double_rtz($fbasetype x);"
+                   echo "OVERLOADABLE double convert_double_rtp($fbasetype x);"
+                   echo "OVERLOADABLE double convert_double_rtn($fbasetype x);"
+               fi
+               continue
+           fi
+
+           for rounding in $ROUNDING_MODES; do
+               fvectortype=$fbasetype$vector_length
+               tvectortype=double$vector_length
+               conv="convert_double_${rounding}"
+
+               construct="$conv(v.s0)"
+               if test $vector_length -gt 1; then
+                   construct="$construct, $conv(v.s1)"
+               fi
+               if test $vector_length -gt 2; then
+                   construct="$construct, $conv(v.s2)"
+               fi
+               if test $vector_length -gt 3; then
+                   construct="$construct, $conv(v.s3)"
+               fi
+               if test $vector_length -gt 4; then
+                   construct="$construct, $conv(v.s4)"
+                   construct="$construct, $conv(v.s5)"
+                   construct="$construct, $conv(v.s6)"
+                   construct="$construct, $conv(v.s7)"
+               fi
+               if test $vector_length -gt 8; then
+                   construct="$construct, $conv(v.s8)"
+                   construct="$construct, $conv(v.s9)"
+                   construct="$construct, $conv(v.sA)"
+                   construct="$construct, $conv(v.sB)"
+                   construct="$construct, $conv(v.sC)"
+                   construct="$construct, $conv(v.sD)"
+                   construct="$construct, $conv(v.sE)"
+                   construct="$construct, $conv(v.sF)"
+               fi
+
+               if [ $1"a" = "-pa" ]; then
+                   echo "OVERLOADABLE $tvectortype 
convert_${tvectortype}_${rounding}($fvectortype v);"
+               else
+                   echo "OVERLOADABLE $tvectortype 
convert_${tvectortype}_${rounding}($fvectortype v) {"
+                   echo "  return ($tvectortype)($construct);"
+                   echo "}"
+                   echo
+               fi
+       done
+    done
+done
+
 if [ $1"a" = "-pa" ]; then
     echo "#endif /* __OCL_CONVERT_H__ */"
 fi
-- 
2.7.4

_______________________________________________
Beignet mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/beignet

Reply via email to