]> git.ipfire.org Git - thirdparty/gcc.git/blobdiff - libgfortran/mk-kinds-h.sh
Add missing config/i386/zn4zn5.md file
[thirdparty/gcc.git] / libgfortran / mk-kinds-h.sh
index f4244f006d53b3501deb97a093c07cdb667d875b..0e0ec195875a8aa952fbfef265960d32d81ecad1 100755 (executable)
@@ -2,8 +2,8 @@
 LC_ALL=C
 export LC_ALL
 
-if test "$#" -ne 3; then
-  echo "Usage $0 int_kinds real_kinds compile"
+if test "$#" -ne 4; then
+  echo "Usage $0 int_kinds real_kinds compile use_iec_60559"
   exit 1
 fi
 
@@ -11,6 +11,7 @@ fi
 possible_integer_kinds="$1"
 possible_real_kinds="$2"
 compile="$3"
+use_iec_60559="$4"
 
 largest=""
 smallest=""
@@ -35,8 +36,8 @@ for k in $possible_integer_kinds; do
     echo "typedef ${prefix}int${s}_t GFC_INTEGER_${k};"
     echo "typedef ${prefix}uint${s}_t GFC_UINTEGER_${k};"
     echo "typedef GFC_INTEGER_${k} GFC_LOGICAL_${k};"
-    echo "#define HAVE_GFC_LOGICAL_${k} 1"
-    echo "#define HAVE_GFC_INTEGER_${k} 1"
+    echo "#define HAVE_GFC_LOGICAL_${k}"
+    echo "#define HAVE_GFC_INTEGER_${k}"
     echo ""
   fi
   rm -f tmp$$.*
@@ -49,7 +50,7 @@ echo ""
 
 
 # Get the kind value for long double, so we may disambiguate it
-# from __float128.
+# from _Float128.
 echo "use iso_c_binding; print *, c_long_double ; end" > tmq$$.f90
 long_double_kind=`$compile -S -fdump-parse-tree tmq$$.f90 | grep TRANSFER \
                        | sed 's/ *TRANSFER *//'`
@@ -64,15 +65,24 @@ for k in $possible_real_kinds; do
     case $k in
       4) ctype="float" ; cplxtype="complex float" ; suffix="f" ;;
       8) ctype="double" ; cplxtype="complex double" ; suffix="" ;;
+      # If we have a REAL(KIND=10), it is always long double
       10) ctype="long double" ; cplxtype="complex long double" ; suffix="l" ;;
-      16) if [ $long_double_kind -eq 10 ]; then
-           ctype="__float128"
-           cplxtype="_Complex float __attribute__((mode(TC)))"
-           suffix="q"
+      # If we have a REAL(KIND=16), it is either long double or _Float128
+      16) if [ $long_double_kind -ne 16 ]; then
+           ctype="_Float128"
+           cplxtype="_Complex _Float128"
+           echo "#define GFC_REAL_16_IS_FLOAT128"
+           if [ x$use_iec_60559 = xyes ]; then
+             suffix="f128"
+             echo "#define GFC_REAL_16_USE_IEC_60559"
+           else
+             suffix="q"
+           fi
          else
            ctype="long double"
            cplxtype="complex long double"
            suffix="l"
+           echo "#define GFC_REAL_16_IS_LONG_DOUBLE"
          fi ;;
       *) echo "$0: Unknown type" >&2 ; exit 1 ;;
     esac
@@ -83,6 +93,12 @@ for k in $possible_real_kinds; do
                | sed 's/ *TRANSFER *//' | sed 's/_.*//'`
     rm -f tmq$$.*
 
+    # Check for the value of TINY
+    echo "print *, tiny(0._$k) ; end" > tmq$$.f90
+    tiny=`$compile -S -fdump-parse-tree tmq$$.f90 | grep TRANSFER \
+               | sed 's/ *TRANSFER *//' | sed 's/_.*//'`
+    rm -f tmq$$.*
+
     # Check for the value of DIGITS
     echo "print *, digits(0._$k) ; end" > tmq$$.f90
     digits=`$compile -S -fdump-parse-tree tmq$$.f90 | grep TRANSFER \
@@ -98,9 +114,10 @@ for k in $possible_real_kinds; do
     # Output the information we've gathered
     echo "typedef ${ctype} GFC_REAL_${k};"
     echo "typedef ${cplxtype} GFC_COMPLEX_${k};"
-    echo "#define HAVE_GFC_REAL_${k} 1"
-    echo "#define HAVE_GFC_COMPLEX_${k} 1"
+    echo "#define HAVE_GFC_REAL_${k}"
+    echo "#define HAVE_GFC_COMPLEX_${k}"
     echo "#define GFC_REAL_${k}_HUGE ${huge}${suffix}"
+    echo "#define GFC_REAL_${k}_TINY ${tiny}${suffix}"
     echo "#define GFC_REAL_${k}_LITERAL_SUFFIX ${suffix}"
     if [ "x$suffix" = "x" ]; then
       echo "#define GFC_REAL_${k}_LITERAL(X) (X)"
@@ -114,23 +131,6 @@ for k in $possible_real_kinds; do
   rm -f tmp$$.*
 done
 
-# For ISO_Fortran_binding.h
-for k in "C_LONG_DOUBLE" "C_FLOAT128" "C_INT128_T"; do
-  fname="tmp$$.val"
-  echo "use iso_c_binding, only: $k; end" > tmp$$.f90
-  if $compile -S -fdump-parse-tree tmp$$.f90 > "$fname"; then
-    kind=`grep "value:" "$fname" |grep value: | sed -e 's/.*value: *//'`
-    if [ "x$kind" = "x" ]; then
-      echo "ERROR: Failed to extract kind for $k" 1>&2
-      exit 1
-    fi
-    echo "#define GFC_${k}_KIND ${kind}"
-  else
-    echo "ERROR: Failed to extract kind for $k" 1>&2
-    exit 1
-  fi
-  rm -f tmp$$.*
-done
 
 # After this, we include a header that can override some of the
 # autodetected settings.