]>
git.ipfire.org Git - thirdparty/gcc.git/blob - libgfortran/mk-kinds-h.sh
5 if test "$#" -ne 3; then
6 echo "Usage $0 int_kinds real_kinds compile"
10 # Possible kinds must be listed in ascending order
11 possible_integer_kinds
="$1"
12 possible_real_kinds
="$2"
17 for k
in $possible_integer_kinds; do
18 echo " integer (kind=$k) :: i" > tmp$$.f90
19 echo " i = 1_$k" >> tmp$$.f90
20 echo " end" >> tmp$$.f90
21 if $compile -S tmp$$.f90
> /dev
/null
2>&1; then
25 if [ $s -eq 128 ]; then
31 if [ "$smallest" = "" ]; then
35 echo "typedef ${prefix}int${s}_t GFC_INTEGER_${k};"
36 echo "typedef ${prefix}uint${s}_t GFC_UINTEGER_${k};"
37 echo "typedef GFC_INTEGER_${k} GFC_LOGICAL_${k};"
38 echo "#define HAVE_GFC_LOGICAL_${k}"
39 echo "#define HAVE_GFC_INTEGER_${k}"
45 echo "#define GFC_INTEGER_LARGEST GFC_INTEGER_${largest}"
46 echo "#define GFC_UINTEGER_LARGEST GFC_UINTEGER_${largest}"
47 echo "#define GFC_DEFAULT_CHAR ${smallest}"
51 # Get the kind value for long double, so we may disambiguate it
53 echo "use iso_c_binding; print *, c_long_double ; end" > tmq$$.f90
54 long_double_kind
=`$compile -S -fdump-parse-tree tmq$$.f90 | grep TRANSFER \
55 | sed 's/ *TRANSFER *//'`
59 for k
in $possible_real_kinds; do
60 echo " real (kind=$k) :: x" > tmp$$.f90
61 echo " x = 1.0_$k" >> tmp$$.f90
62 echo " end" >> tmp$$.f90
63 if $compile -S tmp$$.f90
> /dev
/null
2>&1; then
65 4) ctype
="float" ; cplxtype
="complex float" ; suffix
="f" ;;
66 8) ctype
="double" ; cplxtype
="complex double" ; suffix
="" ;;
67 # If we have a REAL(KIND=10), it is always long double
68 10) ctype
="long double" ; cplxtype
="complex long double" ; suffix
="l" ;;
69 # If we have a REAL(KIND=16), it is either long double or __float128
70 16) if [ $long_double_kind -ne 16 ]; then
72 cplxtype
="_Complex float __attribute__((mode(TC)))"
74 echo "#define GFC_REAL_16_IS_FLOAT128"
77 cplxtype
="complex long double"
79 echo "#define GFC_REAL_16_IS_LONG_DOUBLE"
81 *) echo "$0: Unknown type" >&2 ; exit 1 ;;
84 # Check for the value of HUGE
85 echo "print *, huge(0._$k) ; end" > tmq$$.f90
86 huge
=`$compile -S -fdump-parse-tree tmq$$.f90 | grep TRANSFER \
87 | sed 's/ *TRANSFER *//' | sed 's/_.*//'`
90 # Check for the value of TINY
91 echo "print *, tiny(0._$k) ; end" > tmq$$.f90
92 tiny
=`$compile -S -fdump-parse-tree tmq$$.f90 | grep TRANSFER \
93 | sed 's/ *TRANSFER *//' | sed 's/_.*//'`
96 # Check for the value of DIGITS
97 echo "print *, digits(0._$k) ; end" > tmq$$.f90
98 digits
=`$compile -S -fdump-parse-tree tmq$$.f90 | grep TRANSFER \
99 | sed 's/ *TRANSFER *//'`
102 # Check for the value of RADIX
103 echo "print *, radix(0._$k) ; end" > tmq$$.f90
104 radix
=`$compile -S -fdump-parse-tree tmq$$.f90 | grep TRANSFER \
105 | sed 's/ *TRANSFER *//'`
108 # Output the information we've gathered
109 echo "typedef ${ctype} GFC_REAL_${k};"
110 echo "typedef ${cplxtype} GFC_COMPLEX_${k};"
111 echo "#define HAVE_GFC_REAL_${k}"
112 echo "#define HAVE_GFC_COMPLEX_${k}"
113 echo "#define GFC_REAL_${k}_HUGE ${huge}${suffix}"
114 echo "#define GFC_REAL_${k}_TINY ${tiny}${suffix}"
115 echo "#define GFC_REAL_${k}_LITERAL_SUFFIX ${suffix}"
116 if [ "x$suffix" = "x" ]; then
117 echo "#define GFC_REAL_${k}_LITERAL(X) (X)"
119 echo "#define GFC_REAL_${k}_LITERAL(X) (X ## ${suffix})"
121 echo "#define GFC_REAL_${k}_DIGITS ${digits}"
122 echo "#define GFC_REAL_${k}_RADIX ${radix}"
129 # After this, we include a header that can override some of the
130 # autodetected settings.
131 echo '#include "kinds-override.h"'