From: Richard Henderson Date: Mon, 30 Aug 2004 21:34:37 +0000 (-0700) Subject: Makefile.am (gfor_helper_src): Split selected_kind.f90. X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=625be2863598fcaa489d1372ee825aff85ea7cec;p=gcc.git Makefile.am (gfor_helper_src): Split selected_kind.f90. * Makefile.am (gfor_helper_src): Split selected_kind.f90. (gfor_built_src): Add selected_int_kind.inc selected_real_kind.inc. (selected_int_kind.inc selected_real_kind.inc): New rules. * Makefile.in: Regenerate. * mk-sik-inc.sh, mk-srk-inc.sh: New files. * intrinsics/selected_int_kind.f90: Split from selected_kind.f90, include table of detected kinds. * intrinsics/selected_real_kind.f90: Similarly. From-SVN: r86801 --- diff --git a/libgfortran/ChangeLog b/libgfortran/ChangeLog index 097e356f3a5..48b652fc17b 100644 --- a/libgfortran/ChangeLog +++ b/libgfortran/ChangeLog @@ -1,3 +1,14 @@ +2004-08-30 Richard Henderson + + * Makefile.am (gfor_helper_src): Split selected_kind.f90. + (gfor_built_src): Add selected_int_kind.inc selected_real_kind.inc. + (selected_int_kind.inc selected_real_kind.inc): New rules. + * Makefile.in: Regenerate. + * mk-sik-inc.sh, mk-srk-inc.sh: New files. + * intrinsics/selected_int_kind.f90: Split from selected_kind.f90, + include table of detected kinds. + * intrinsics/selected_real_kind.f90: Similarly. + 2004-08-29 Steven G. Kargl Paul Brook diff --git a/libgfortran/Makefile.am b/libgfortran/Makefile.am index f07f1b554c7..91d70b8129c 100644 --- a/libgfortran/Makefile.am +++ b/libgfortran/Makefile.am @@ -59,7 +59,8 @@ intrinsics/rand.c \ intrinsics/random.c \ intrinsics/reshape_generic.c \ intrinsics/reshape_packed.c \ -intrinsics/selected_kind.f90 \ +intrinsics/selected_int_kind.f90 \ +intrinsics/selected_real_kind.f90 \ intrinsics/system_clock.c \ intrinsics/transpose_generic.c \ intrinsics/unpack_generic.c \ @@ -264,7 +265,8 @@ gfor_built_src= $(i_all_c) $(i_any_c) $(i_count_c) $(i_maxloc0_c) \ $(i_matmul_c) $(i_matmull_c) $(i_transpose_c) $(i_shape_c) $(i_eoshift1_c) \ $(i_eoshift3_c) $(i_cshift1_c) $(i_reshape_c) $(in_pack_c) $(in_unpack_c) \ $(i_exponent_c) $(i_fraction_c) $(i_nearest_c) $(i_set_exponent_c) \ - $(i_pow_c) + $(i_pow_c) \ + selected_int_kind.inc selected_real_kind.inc # We only use these if libm doesn't contain complex math functions. @@ -383,6 +385,12 @@ I_M4_DEPS=m4/iparm.m4 I_M4_DEPS0=$(I_M4_DEPS) m4/iforeach.m4 I_M4_DEPS1=$(I_M4_DEPS) m4/ifunction.m4 +selected_int_kind.inc: $(srcdir)/mk-sik-inc.sh + $(SHELL) $(srcdir)/mk-sik-inc.sh '$(F77COMPILE)' > $@ + +selected_real_kind.inc: $(srcdir)/mk-srk-inc.sh + $(SHELL) $(srcdir)/mk-srk-inc.sh '$(F77COMPILE)' > $@ + ## A 'normal' build shouldn't need to regenerate these ## so we only include them in maintainer mode diff --git a/libgfortran/Makefile.in b/libgfortran/Makefile.in index e83388dc3ab..ded21b61c7c 100644 --- a/libgfortran/Makefile.in +++ b/libgfortran/Makefile.in @@ -123,9 +123,9 @@ am__objects_33 = associated.lo abort.lo args.lo bessel.lo \ env.lo erf.lo eoshift0.lo eoshift2.lo etime.lo getXid.lo \ ishftc.lo pack_generic.lo size.lo spread_generic.lo \ string_intrinsics.lo rand.lo random.lo reshape_generic.lo \ - reshape_packed.lo selected_kind.lo system_clock.lo \ - transpose_generic.lo unpack_generic.lo in_pack_generic.lo \ - in_unpack_generic.lo normalize.lo + reshape_packed.lo selected_int_kind.lo selected_real_kind.lo \ + system_clock.lo transpose_generic.lo unpack_generic.lo \ + in_pack_generic.lo in_unpack_generic.lo normalize.lo am__objects_34 = am__objects_35 = _abs_c4.lo _abs_c8.lo _abs_i4.lo _abs_i8.lo \ _abs_r4.lo _abs_r8.lo _exp_r4.lo _exp_r8.lo _exp_c4.lo \ @@ -331,7 +331,8 @@ intrinsics/rand.c \ intrinsics/random.c \ intrinsics/reshape_generic.c \ intrinsics/reshape_packed.c \ -intrinsics/selected_kind.f90 \ +intrinsics/selected_int_kind.f90 \ +intrinsics/selected_real_kind.f90 \ intrinsics/system_clock.c \ intrinsics/transpose_generic.c \ intrinsics/unpack_generic.c \ @@ -536,7 +537,8 @@ gfor_built_src = $(i_all_c) $(i_any_c) $(i_count_c) $(i_maxloc0_c) \ $(i_matmul_c) $(i_matmull_c) $(i_transpose_c) $(i_shape_c) $(i_eoshift1_c) \ $(i_eoshift3_c) $(i_cshift1_c) $(i_reshape_c) $(in_pack_c) $(in_unpack_c) \ $(i_exponent_c) $(i_fraction_c) $(i_nearest_c) $(i_set_exponent_c) \ - $(i_pow_c) + $(i_pow_c) \ + selected_int_kind.inc selected_real_kind.inc # We only use these if libm doesn't contain complex math functions. @@ -2291,14 +2293,23 @@ hyp_c8.lo: generated/hyp_c8.c .f90.lo: $(LTF77COMPILE) -c -o $@ $< -selected_kind.o: intrinsics/selected_kind.f90 - $(F77) $(AM_FFLAGS) $(FFLAGS) -c -o selected_kind.o `test -f 'intrinsics/selected_kind.f90' || echo '$(srcdir)/'`intrinsics/selected_kind.f90 +selected_int_kind.o: intrinsics/selected_int_kind.f90 + $(F77) $(AM_FFLAGS) $(FFLAGS) -c -o selected_int_kind.o `test -f 'intrinsics/selected_int_kind.f90' || echo '$(srcdir)/'`intrinsics/selected_int_kind.f90 -selected_kind.obj: intrinsics/selected_kind.f90 - $(F77) $(AM_FFLAGS) $(FFLAGS) -c -o selected_kind.obj `if test -f 'intrinsics/selected_kind.f90'; then $(CYGPATH_W) 'intrinsics/selected_kind.f90'; else $(CYGPATH_W) '$(srcdir)/intrinsics/selected_kind.f90'; fi` +selected_int_kind.obj: intrinsics/selected_int_kind.f90 + $(F77) $(AM_FFLAGS) $(FFLAGS) -c -o selected_int_kind.obj `if test -f 'intrinsics/selected_int_kind.f90'; then $(CYGPATH_W) 'intrinsics/selected_int_kind.f90'; else $(CYGPATH_W) '$(srcdir)/intrinsics/selected_int_kind.f90'; fi` -selected_kind.lo: intrinsics/selected_kind.f90 - $(LIBTOOL) --mode=compile $(F77) $(AM_FFLAGS) $(FFLAGS) -c -o selected_kind.lo `test -f 'intrinsics/selected_kind.f90' || echo '$(srcdir)/'`intrinsics/selected_kind.f90 +selected_int_kind.lo: intrinsics/selected_int_kind.f90 + $(LIBTOOL) --mode=compile $(F77) $(AM_FFLAGS) $(FFLAGS) -c -o selected_int_kind.lo `test -f 'intrinsics/selected_int_kind.f90' || echo '$(srcdir)/'`intrinsics/selected_int_kind.f90 + +selected_real_kind.o: intrinsics/selected_real_kind.f90 + $(F77) $(AM_FFLAGS) $(FFLAGS) -c -o selected_real_kind.o `test -f 'intrinsics/selected_real_kind.f90' || echo '$(srcdir)/'`intrinsics/selected_real_kind.f90 + +selected_real_kind.obj: intrinsics/selected_real_kind.f90 + $(F77) $(AM_FFLAGS) $(FFLAGS) -c -o selected_real_kind.obj `if test -f 'intrinsics/selected_real_kind.f90'; then $(CYGPATH_W) 'intrinsics/selected_real_kind.f90'; else $(CYGPATH_W) '$(srcdir)/intrinsics/selected_real_kind.f90'; fi` + +selected_real_kind.lo: intrinsics/selected_real_kind.f90 + $(LIBTOOL) --mode=compile $(F77) $(AM_FFLAGS) $(FFLAGS) -c -o selected_real_kind.lo `test -f 'intrinsics/selected_real_kind.f90' || echo '$(srcdir)/'`intrinsics/selected_real_kind.f90 _abs_c4.o: generated/_abs_c4.f90 $(F77) $(AM_FFLAGS) $(FFLAGS) -c -o _abs_c4.o `test -f 'generated/_abs_c4.f90' || echo '$(srcdir)/'`generated/_abs_c4.f90 @@ -3170,6 +3181,12 @@ uninstall-am: uninstall-info-am uninstall-toolexeclibLTLIBRARIES uninstall-toolexeclibLTLIBRARIES +selected_int_kind.inc: $(srcdir)/mk-sik-inc.sh + $(SHELL) $(srcdir)/mk-sik-inc.sh '$(F77COMPILE)' > $@ + +selected_real_kind.inc: $(srcdir)/mk-srk-inc.sh + $(SHELL) $(srcdir)/mk-srk-inc.sh '$(F77COMPILE)' > $@ + @MAINTAINER_MODE_TRUE@$(i_all_c): m4/all.m4 $(I_M4_DEPS1) @MAINTAINER_MODE_TRUE@ m4 -Dfile=$@ -I$(srcdir)/m4 all.m4 > $@ diff --git a/libgfortran/intrinsics/selected_int_kind.f90 b/libgfortran/intrinsics/selected_int_kind.f90 new file mode 100644 index 00000000000..8d9a6bedc6b --- /dev/null +++ b/libgfortran/intrinsics/selected_int_kind.f90 @@ -0,0 +1,43 @@ +! Copyright 2003, 2004 Free Software Foundation, Inc. +! Contributed by Kejia Zhao +! +!This file is part of the GNU Fortran 95 runtime library (libgfor). +! +!GNU libgfor is free software; you can redistribute it and/or +!modify it under the terms of the GNU Lesser General Public +!License as published by the Free Software Foundation; either +!version 2.1 of the License, or (at your option) any later version. +! +!GNU libgfor is distributed in the hope that it will be useful, +!but WITHOUT ANY WARRANTY; without even the implied warranty of +!MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +!GNU Lesser General Public License for more details. +! +!You should have received a copy of the GNU Lesser General Public +!License along with libgfor; see the file COPYING. If not, +!write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, +!Boston, MA 02111-1307, USA. +! + +function selected_int_kind (r) + implicit none + integer, intent (in) :: r + integer :: selected_int_kind + integer :: i + ! Integer kind_range table + type :: int_info + integer :: kind + integer :: range + end type int_info + + include "selected_int_kind.inc" + + do i = 1, c + if (r <= int_infos (i) % range) then + selected_int_kind = int_infos (i) % kind + return + end if + end do + selected_int_kind = -1 + return +end function diff --git a/libgfortran/intrinsics/selected_kind.f90 b/libgfortran/intrinsics/selected_kind.f90 deleted file mode 100644 index 62d11c7f596..00000000000 --- a/libgfortran/intrinsics/selected_kind.f90 +++ /dev/null @@ -1,90 +0,0 @@ -! Copyright 2003 Free Software Foundation, Inc. -! Contributed by Kejia Zhao -! -!This file is part of the GNU Fortran 95 runtime library (libgfor). -! -!GNU libgfor is free software; you can redistribute it and/or -!modify it under the terms of the GNU Lesser General Public -!License as published by the Free Software Foundation; either -!version 2.1 of the License, or (at your option) any later version. -! -!GNU libgfor is distributed in the hope that it will be useful, -!but WITHOUT ANY WARRANTY; without even the implied warranty of -!MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -!GNU Lesser General Public License for more details. -! -!You should have received a copy of the GNU Lesser General Public -!License along with libgfor; see the file COPYING. If not, -!write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, -!Boston, MA 02111-1307, USA. -! - -function selected_int_kind (r) - implicit none - integer, intent (in) :: r - integer :: selected_int_kind - integer :: i - ! Integer kind_range table - integer, parameter :: c = 4 - type :: int_info - integer :: kind - integer :: range - end type int_info - type (int_info), parameter :: int_infos (c) = & - (/int_info (1, range (0_1)), & - int_info (2, range (0_2)), & - int_info (4, range (0_4)), & - int_info (8, range (0_8))/) - - do i = 1, c - if (r <= int_infos (i) % range) then - selected_int_kind = int_infos (i) % kind - return - end if - end do - selected_int_kind = -1 - return -end function - -function selected_real_kind (p, r) - implicit none - integer, optional, intent (in) :: p, r - integer :: selected_real_kind - integer :: i, p2, r2 - logical :: found_p, found_r - ! Real kind_precision_range table - integer, parameter :: c = 2 - type :: real_info - integer :: kind - integer :: precision - integer :: range - end type real_info - type (real_info) :: real_infos (c) = & - (/real_info (4, precision (0.0_4), range (0.0_4)), & - real_info (8, precision (0.0_8), range (0.0_8))/) - - selected_real_kind = 0 - p2 = 0 - r2 = 0 - found_p = .false. - found_r = .false. - - if (present (p)) p2 = p - if (present (r)) r2 = r - - ! Assumes each type has a greater precision and range than previous one. - - do i = 1, c - if (p2 <= real_infos (i) % precision) found_p = .true. - if (r2 <= real_infos (i) % range) found_r = .true. - if (found_p .and. found_r) then - selected_real_kind = real_infos (i) % kind - return - end if - end do - - if (.not. (found_p)) selected_real_kind = selected_real_kind - 1 - if (.not. (found_r)) selected_real_kind = selected_real_kind - 2 - - return -end function diff --git a/libgfortran/intrinsics/selected_real_kind.f90 b/libgfortran/intrinsics/selected_real_kind.f90 new file mode 100644 index 00000000000..df2881717cd --- /dev/null +++ b/libgfortran/intrinsics/selected_real_kind.f90 @@ -0,0 +1,61 @@ +! Copyright 2003, 2004 Free Software Foundation, Inc. +! Contributed by Kejia Zhao +! +!This file is part of the GNU Fortran 95 runtime library (libgfor). +! +!GNU libgfor is free software; you can redistribute it and/or +!modify it under the terms of the GNU Lesser General Public +!License as published by the Free Software Foundation; either +!version 2.1 of the License, or (at your option) any later version. +! +!GNU libgfor is distributed in the hope that it will be useful, +!but WITHOUT ANY WARRANTY; without even the implied warranty of +!MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +!GNU Lesser General Public License for more details. +! +!You should have received a copy of the GNU Lesser General Public +!License along with libgfor; see the file COPYING. If not, +!write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, +!Boston, MA 02111-1307, USA. +! + +function selected_real_kind (p, r) + implicit none + integer, optional, intent (in) :: p, r + integer :: selected_real_kind + integer :: i, p2, r2 + logical :: found_p, found_r + ! Real kind_precision_range table + type :: real_info + integer :: kind + integer :: precision + integer :: range + end type real_info + + include "selected_real_kind.inc" + + selected_real_kind = 0 + p2 = 0 + r2 = 0 + found_p = .false. + found_r = .false. + + if (present (p)) p2 = p + if (present (r)) r2 = r + + ! Assumes each type has a greater precision and range than previous one. + + do i = 1, c + if (p2 <= real_infos (i) % precision) found_p = .true. + if (r2 <= real_infos (i) % range) found_r = .true. + if (found_p .and. found_r) then + selected_real_kind = real_infos (i) % kind + return + end if + end do + + if (.not. (found_p)) selected_real_kind = selected_real_kind - 1 + if (.not. (found_r)) selected_real_kind = selected_real_kind - 2 + + return +end function diff --git a/libgfortran/mk-sik-inc.sh b/libgfortran/mk-sik-inc.sh new file mode 100755 index 00000000000..536eda70c88 --- /dev/null +++ b/libgfortran/mk-sik-inc.sh @@ -0,0 +1,32 @@ +#!/bin/sh + +compile="$1" +kinds="" +possible_kinds="1 2 4 8 16" +c=0 + +for k in $possible_kinds; do + echo " integer (kind=$k) :: x" > tmp$$.f90 + echo " end" >> tmp$$.f90 + if $compile -c tmp$$.f90 > /dev/null 2>&1; then + kinds="$kinds $k" + c=`expr $c + 1` + fi + rm -f tmp$$.* +done + +echo " integer, parameter :: c = $c" +echo " type (int_info), parameter :: int_infos(c) = (/ &" + +i=0 +for k in $kinds; do + echo -n " int_info ($k, range(0_$k))" + i=`expr $i + 1` + if [ $i -lt $c ]; then + echo ", &" + else + echo " /)" + fi +done + +exit 0 diff --git a/libgfortran/mk-srk-inc.sh b/libgfortran/mk-srk-inc.sh new file mode 100755 index 00000000000..47046985b00 --- /dev/null +++ b/libgfortran/mk-srk-inc.sh @@ -0,0 +1,32 @@ +#!/bin/sh + +compile="$1" +kinds="" +possible_kinds="4 8 10 16" +c=0 + +for k in $possible_kinds; do + echo " real (kind=$k) :: x" > tmp$$.f90 + echo " end" >> tmp$$.f90 + if $compile -c tmp$$.f90 > /dev/null 2>&1; then + kinds="$kinds $k" + c=`expr $c + 1` + fi + rm -f tmp$$.* +done + +echo " integer, parameter :: c = $c" +echo " type (real_info), parameter :: real_infos(c) = (/ &" + +i=0 +for k in $kinds; do + echo -n " real_info ($k, precision(0.0_$k), range(0.0_$k))" + i=`expr $i + 1` + if [ $i -lt $c ]; then + echo ", &" + else + echo " /)" + fi +done + +exit 0