]> git.ipfire.org Git - thirdparty/gcc.git/blame - libgfortran/mk-kinds-h.sh
Add missing config/i386/zn4zn5.md file
[thirdparty/gcc.git] / libgfortran / mk-kinds-h.sh
CommitLineData
32aa3bff 1#!/bin/sh
094817b0
TB
2LC_ALL=C
3export LC_ALL
32aa3bff 4
133d0d42
JJ
5if test "$#" -ne 4; then
6 echo "Usage $0 int_kinds real_kinds compile use_iec_60559"
2e764ae1
TB
7 exit 1
8fi
32aa3bff 9
2e764ae1
TB
10# Possible kinds must be listed in ascending order
11possible_integer_kinds="$1"
12possible_real_kinds="$2"
13compile="$3"
133d0d42 14use_iec_60559="$4"
32aa3bff
FXC
15
16largest=""
6ad5cf72 17smallest=""
32aa3bff
FXC
18for k in $possible_integer_kinds; do
19 echo " integer (kind=$k) :: i" > tmp$$.f90
b554826c 20 echo " i = 1_$k" >> tmp$$.f90
32aa3bff 21 echo " end" >> tmp$$.f90
4349e292 22 if $compile -S tmp$$.f90 > /dev/null 2>&1; then
32aa3bff
FXC
23 s=`expr 8 \* $k`
24 largest="$k"
25
26 if [ $s -eq 128 ]; then
27 prefix="__"
28 else
29 prefix=""
30 fi
31
6ad5cf72
CR
32 if [ "$smallest" = "" ]; then
33 smallest="$k"
34 fi
35
32aa3bff
FXC
36 echo "typedef ${prefix}int${s}_t GFC_INTEGER_${k};"
37 echo "typedef ${prefix}uint${s}_t GFC_UINTEGER_${k};"
38 echo "typedef GFC_INTEGER_${k} GFC_LOGICAL_${k};"
13beaf9e
SL
39 echo "#define HAVE_GFC_LOGICAL_${k}"
40 echo "#define HAVE_GFC_INTEGER_${k}"
1fa6df85 41 echo ""
32aa3bff
FXC
42 fi
43 rm -f tmp$$.*
44done
45
46echo "#define GFC_INTEGER_LARGEST GFC_INTEGER_${largest}"
47echo "#define GFC_UINTEGER_LARGEST GFC_UINTEGER_${largest}"
6ad5cf72 48echo "#define GFC_DEFAULT_CHAR ${smallest}"
32aa3bff
FXC
49echo ""
50
1ec601bf
FXC
51
52# Get the kind value for long double, so we may disambiguate it
133d0d42 53# from _Float128.
1ec601bf
FXC
54echo "use iso_c_binding; print *, c_long_double ; end" > tmq$$.f90
55long_double_kind=`$compile -S -fdump-parse-tree tmq$$.f90 | grep TRANSFER \
56 | sed 's/ *TRANSFER *//'`
57rm -f tmq$$.*
58
32aa3bff 59
32aa3bff
FXC
60for k in $possible_real_kinds; do
61 echo " real (kind=$k) :: x" > tmp$$.f90
b554826c 62 echo " x = 1.0_$k" >> tmp$$.f90
32aa3bff 63 echo " end" >> tmp$$.f90
4349e292 64 if $compile -S tmp$$.f90 > /dev/null 2>&1; then
32aa3bff 65 case $k in
1ec601bf
FXC
66 4) ctype="float" ; cplxtype="complex float" ; suffix="f" ;;
67 8) ctype="double" ; cplxtype="complex double" ; suffix="" ;;
22817356 68 # If we have a REAL(KIND=10), it is always long double
1ec601bf 69 10) ctype="long double" ; cplxtype="complex long double" ; suffix="l" ;;
5097cdf9 70 # If we have a REAL(KIND=16), it is either long double or _Float128
22817356 71 16) if [ $long_double_kind -ne 16 ]; then
133d0d42
JJ
72 ctype="_Float128"
73 cplxtype="_Complex _Float128"
22817356 74 echo "#define GFC_REAL_16_IS_FLOAT128"
133d0d42
JJ
75 if [ x$use_iec_60559 = xyes ]; then
76 suffix="f128"
77 echo "#define GFC_REAL_16_USE_IEC_60559"
78 else
79 suffix="q"
80 fi
1ec601bf
FXC
81 else
82 ctype="long double"
83 cplxtype="complex long double"
84 suffix="l"
22817356 85 echo "#define GFC_REAL_16_IS_LONG_DOUBLE"
1ec601bf 86 fi ;;
32aa3bff
FXC
87 *) echo "$0: Unknown type" >&2 ; exit 1 ;;
88 esac
1fa6df85
FXC
89
90 # Check for the value of HUGE
91 echo "print *, huge(0._$k) ; end" > tmq$$.f90
4349e292 92 huge=`$compile -S -fdump-parse-tree tmq$$.f90 | grep TRANSFER \
66ec5f87 93 | sed 's/ *TRANSFER *//' | sed 's/_.*//'`
1fa6df85
FXC
94 rm -f tmq$$.*
95
90045c5d
FXC
96 # Check for the value of TINY
97 echo "print *, tiny(0._$k) ; end" > tmq$$.f90
98 tiny=`$compile -S -fdump-parse-tree tmq$$.f90 | grep TRANSFER \
99 | sed 's/ *TRANSFER *//' | sed 's/_.*//'`
100 rm -f tmq$$.*
101
1fa6df85
FXC
102 # Check for the value of DIGITS
103 echo "print *, digits(0._$k) ; end" > tmq$$.f90
4349e292 104 digits=`$compile -S -fdump-parse-tree tmq$$.f90 | grep TRANSFER \
1fa6df85
FXC
105 | sed 's/ *TRANSFER *//'`
106 rm -f tmq$$.*
107
108 # Check for the value of RADIX
109 echo "print *, radix(0._$k) ; end" > tmq$$.f90
4349e292 110 radix=`$compile -S -fdump-parse-tree tmq$$.f90 | grep TRANSFER \
1fa6df85
FXC
111 | sed 's/ *TRANSFER *//'`
112 rm -f tmq$$.*
113
114 # Output the information we've gathered
32aa3bff 115 echo "typedef ${ctype} GFC_REAL_${k};"
1ec601bf 116 echo "typedef ${cplxtype} GFC_COMPLEX_${k};"
13beaf9e
SL
117 echo "#define HAVE_GFC_REAL_${k}"
118 echo "#define HAVE_GFC_COMPLEX_${k}"
1fa6df85 119 echo "#define GFC_REAL_${k}_HUGE ${huge}${suffix}"
90045c5d 120 echo "#define GFC_REAL_${k}_TINY ${tiny}${suffix}"
a83169cd
FXC
121 echo "#define GFC_REAL_${k}_LITERAL_SUFFIX ${suffix}"
122 if [ "x$suffix" = "x" ]; then
123 echo "#define GFC_REAL_${k}_LITERAL(X) (X)"
124 else
125 echo "#define GFC_REAL_${k}_LITERAL(X) (X ## ${suffix})"
126 fi
1fa6df85
FXC
127 echo "#define GFC_REAL_${k}_DIGITS ${digits}"
128 echo "#define GFC_REAL_${k}_RADIX ${radix}"
129 echo ""
32aa3bff
FXC
130 fi
131 rm -f tmp$$.*
132done
133
1ec601bf 134
2e764ae1 135# After this, we include a header that can override some of the
1ec601bf
FXC
136# autodetected settings.
137echo '#include "kinds-override.h"'
138
32aa3bff 139exit 0