Add support for 32-bit hppa targets in muldi3 expander
[official-gcc.git] / libgfortran / mk-kinds-h.sh
blob249619061c6a585675ebeffd7b6334b1eb7c9202
1 #!/bin/sh
2 LC_ALL=C
3 export LC_ALL
5 if test "$#" -ne 3; then
6 echo "Usage $0 int_kinds real_kinds compile"
7 exit 1
8 fi
10 # Possible kinds must be listed in ascending order
11 possible_integer_kinds="$1"
12 possible_real_kinds="$2"
13 compile="$3"
15 largest=""
16 smallest=""
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
22 s=`expr 8 \* $k`
23 largest="$k"
25 if [ $s -eq 128 ]; then
26 prefix="__"
27 else
28 prefix=""
31 if [ "$smallest" = "" ]; then
32 smallest="$k"
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}"
40 echo ""
42 rm -f tmp$$.*
43 done
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}"
48 echo ""
51 # Get the kind value for long double, so we may disambiguate it
52 # from __float128.
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 *//'`
56 rm -f tmq$$.*
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
64 case $k in
65 4) ctype="float" ; cplxtype="complex float" ; suffix="f" ;;
66 8) ctype="double" ; cplxtype="complex double" ; suffix="" ;;
67 10) ctype="long double" ; cplxtype="complex long double" ; suffix="l" ;;
68 16) if [ $long_double_kind -eq 10 ]; then
69 ctype="__float128"
70 cplxtype="_Complex float __attribute__((mode(TC)))"
71 suffix="q"
72 else
73 ctype="long double"
74 cplxtype="complex long double"
75 suffix="l"
76 fi ;;
77 *) echo "$0: Unknown type" >&2 ; exit 1 ;;
78 esac
80 # Check for the value of HUGE
81 echo "print *, huge(0._$k) ; end" > tmq$$.f90
82 huge=`$compile -S -fdump-parse-tree tmq$$.f90 | grep TRANSFER \
83 | sed 's/ *TRANSFER *//' | sed 's/_.*//'`
84 rm -f tmq$$.*
86 # Check for the value of DIGITS
87 echo "print *, digits(0._$k) ; end" > tmq$$.f90
88 digits=`$compile -S -fdump-parse-tree tmq$$.f90 | grep TRANSFER \
89 | sed 's/ *TRANSFER *//'`
90 rm -f tmq$$.*
92 # Check for the value of RADIX
93 echo "print *, radix(0._$k) ; end" > tmq$$.f90
94 radix=`$compile -S -fdump-parse-tree tmq$$.f90 | grep TRANSFER \
95 | sed 's/ *TRANSFER *//'`
96 rm -f tmq$$.*
98 # Output the information we've gathered
99 echo "typedef ${ctype} GFC_REAL_${k};"
100 echo "typedef ${cplxtype} GFC_COMPLEX_${k};"
101 echo "#define HAVE_GFC_REAL_${k}"
102 echo "#define HAVE_GFC_COMPLEX_${k}"
103 echo "#define GFC_REAL_${k}_HUGE ${huge}${suffix}"
104 echo "#define GFC_REAL_${k}_LITERAL_SUFFIX ${suffix}"
105 if [ "x$suffix" = "x" ]; then
106 echo "#define GFC_REAL_${k}_LITERAL(X) (X)"
107 else
108 echo "#define GFC_REAL_${k}_LITERAL(X) (X ## ${suffix})"
110 echo "#define GFC_REAL_${k}_DIGITS ${digits}"
111 echo "#define GFC_REAL_${k}_RADIX ${radix}"
112 echo ""
114 rm -f tmp$$.*
115 done
118 # After this, we include a header that can override some of the
119 # autodetected settings.
120 echo '#include "kinds-override.h"'
122 exit 0