mirror of
https://gcc.gnu.org/git/gcc.git
synced 2024-11-23 02:44:18 +08:00
113a6da9bf
gcc/fortran/ChangeLog: * arith.cc (gfc_reduce_unsigned): New function. (gfc_arith_error): Add ARITH_UNSIGNED_TRUNCATED and ARITH_UNSIGNED_NEGATIVE. (gfc_arith_init_1): Initialize unsigned types. (gfc_check_unsigned_range): New function. (gfc_range_check): Handle unsigned types. (gfc_arith_uminus): Likewise. (gfc_arith_plus): Likewise. (gfc_arith_minus): Likewise. (gfc_arith_times): Likewise. (gfc_arith_divide): Likewise. (gfc_compare_expr): Likewise. (eval_intrinsic): Likewise. (gfc_int2int): Also convert unsigned. (gfc_uint2uint): New function. (gfc_int2uint): New function. (gfc_uint2int): New function. (gfc_uint2real): New function. (gfc_uint2complex): New function. (gfc_real2uint): New function. (gfc_complex2uint): New function. (gfc_log2uint): New function. (gfc_uint2log): New function. * arith.h (gfc_int2uint, gfc_uint2uint, gfc_uint2int, gfc_uint2real): Add prototypes. (gfc_uint2complex, gfc_real2uint, gfc_complex2uint, gfc_log2uint): Likewise. (gfc_uint2log): Likewise. * check.cc (gfc_boz2uint): New function (type_check2): New function. (int_or_real_or_unsigned_check): New function. (less_than_bitsizekind): Adjust for unsingeds. (less_than_bitsize2): Likewise. (gfc_check_allocated): Likewise. (gfc_check_mod): Likewise. (gfc_check_bge_bgt_ble_blt): Likewise. (gfc_check_bitfcn): Likewise. (gfc_check_digits): Likewise. (gfc_check_dshift): Likewise. (gfc_check_huge): Likewise. (gfc_check_iu): New function. (gfc_check_iand_ieor_ior): Adjust for unsigneds. (gfc_check_ibits): Likewise. (gfc_check_uint): New function. (gfc_check_ishft): Adjust for unsigneds. (gfc_check_ishftc): Likewise. (gfc_check_min_max): Likewise. (gfc_check_merge_bits): Likewise. (gfc_check_selected_int_kind): Likewise. (gfc_check_shift): Likewise. (gfc_check_mvbits): Likewise. (gfc_invalid_unsigned_ops): Likewise. * decl.cc (gfc_match_decl_type_spec): Likewise. * dump-parse-tree.cc (show_expr): Likewise. * expr.cc (gfc_get_constant_expr): Likewise. (gfc_copy_expr): Likewise. (gfc_extract_int): Likewise. (numeric_type): Likewise. * gfortran.h (enum arith): Extend with ARITH_UNSIGNED_TRUNCATED and ARITH_UNSIGNED_NEGATIVE. (enum gfc_isym_id): Extend with GFC_ISYM_SU_KIND and GFC_ISYM_UINT. (gfc_check_unsigned_range): New prototype- (gfc_arith_error): Likewise. (gfc_reduce_unsigned): Likewise. (gfc_boz2uint): Likewise. (gfc_invalid_unsigned_ops): Likewise. (gfc_convert_mpz_to_unsigned): Likewise. * gfortran.texi: Add some rudimentary documentation. * intrinsic.cc (gfc_type_letter): Adjust for unsigneds. (add_functions): Add uint and adjust functions to be called. (add_conversions): Add unsigned conversions. (gfc_convert_type_warn): Adjust for unsigned. * intrinsic.h (gfc_check_iu, gfc_check_uint, gfc_check_mod, gfc_simplify_uint, gfc_simplify_selected_unsigned_kind, gfc_resolve_uint): New prototypes. * invoke.texi: Add -funsigned. * iresolve.cc (gfc_resolve_dshift): Handle unsigneds. (gfc_resolve_iand): Handle unsigneds. (gfc_resolve_ibclr): Handle unsigneds. (gfc_resolve_ibits): Handle unsigneds. (gfc_resolve_ibset): Handle unsigneds. (gfc_resolve_ieor): Handle unsigneds. (gfc_resolve_ior): Handle unsigneds. (gfc_resolve_uint): Handle unsigneds. (gfc_resolve_merge_bits): Handle unsigneds. (gfc_resolve_not): Handle unsigneds. * lang.opt: Add -funsigned. * libgfortran.h: Add BT_UNSIGNED. * match.cc (gfc_match_type_spec): Match UNSIGNED. * misc.cc (gfc_basic_typename): Add UNSIGNED. (gfc_typename): Likewise. * primary.cc (convert_unsigned): New function. (match_unsigned_constant): New function. (gfc_match_literal_constant): Handle unsigned. * resolve.cc (resolve_operator): Handle unsigned. (resolve_ordinary_assign): Likewise. * simplify.cc (convert_mpz_to_unsigned): Renamed to... (gfc_convert_mpz_to_unsigned): and adjusted. (gfc_simplify_bit_size): Adjusted for unsigned. (compare_bitwise): Likewise. (gfc_simplify_bge): Likewise. (gfc_simplify_bgt): Likewise. (gfc_simplify_ble): Likewise. (gfc_simplify_blt): Likewise. (simplify_cmplx): Likewise. (gfc_simplify_digits): Likewise. (simplify_dshift): Likewise. (gfc_simplify_huge): Likewise. (gfc_simplify_iand): Likewise. (gfc_simplify_ibclr): Likewise. (gfc_simplify_ibits): Likewise. (gfc_simplify_ibset): Likewise. (gfc_simplify_ieor): Likewise. (gfc_simplify_uint): Likewise. (gfc_simplify_ior): Likewise. (simplify_shift): Likewise. (gfc_simplify_ishftc): Likewise. (gfc_simplify_merge_bits): Likewise. (min_max_choose): Likewise. (gfc_simplify_mod): Likewise. (gfc_simplify_modulo): Likewise. (gfc_simplify_popcnt): Likewise. (gfc_simplify_range): Likewise. (gfc_simplify_selected_unsigned_kind): Likewise. (gfc_convert_constant): Likewise. * target-memory.cc (size_unsigned): New function. (gfc_element_size): Adjust for unsigned. * trans-const.h (gfc_conv_mpz_unsigned_to_tree): Add prototype. * trans-const.cc (gfc_conv_mpz_unsigned_to_tree): Handle unsigneds. (gfc_conv_constant_to_tree): Likewise. * trans-decl.cc (gfc_conv_cfi_to_gfc): Put in "not yet implemented". * trans-expr.cc (gfc_conv_gfc_desc_to_cfi_desc): Likewise. * trans-stmt.cc (gfc_trans_integer_select): Handle unsigned. (gfc_trans_select): Likewise. * trans-intrinsic.cc (gfc_conv_intrinsic_mod): Handle unsigned. (gfc_conv_intrinsic_shift): Likewise. (gfc_conv_intrinsic_function): Add GFC_ISYM_UINT. * trans-io.cc (enum iocall): Add IOCALL_X_UNSIGNED and IOCALL_X_UNSIGNED_WRITE. (gfc_build_io_library_fndecls): Add transfer_unsigned and transfer_unsigned_write. (transfer_expr): Handle unsigneds. * trans-types.cc (gfc_unsinged_kinds): New array. (gfc_unsigned_types): Likewise. (gfc_init_kinds): Handle them. (validate_unsigned): New function. (gfc_validate_kind): Use it. (gfc_build_unsigned_type): New function. (gfc_init_types): Use it. (gfc_get_unsigned_type): New function. (gfc_typenode_for_spec): Handle unsigned. * trans-types.h (gfc_get_unsigned_type): New prototype. libgfortran/ChangeLog: * gfortran.map: Add _gfortran_transfer_unsgned and _gfortran_transfer-signed. * io/io.h (set_unsigned): New prototype. (us_max): New prototype. (read_decimal_unsigned): New prototype. (write_iu): New prototype. * io/list_read.c (convert_unsigned): New function. (read_integer): Also handle unsigneds. (list_formatted_read_scalar): Handle unsigneds. (nml_read_obj): Likewise. * io/read.c (set_unsigned): New function. (us_max): New function. (read_utf8): Whitespace fixes. (read_default_char1): Whitespace fixes. (read_a_char4): Whitespace fixes. (next_char): Whiltespace fixes. (read_decimal_unsigned): New function. (read_f): Whitespace fixes. (read_x): Whitespace fixes. * io/transfer.c (transfer_unsigned): New function. (transfer_unsigned_write): New function. (require_one_of_two_types): New function. (formatted_transfer_scalar_read): Use it. (formatted_transfer_scalar_write): Also use it. * io/write.c (write_decimal_unsigned): New function. (write_iu): New function. (write_unsigned): New function. (list_formatted_write_scalar): Adjust for unsigneds. * libgfortran.h (GFC_UINTEGER_1_HUGE): Define. (GFC_UINTEGER_2_HUGE): Define. (GFC_UINTEGER_4_HUGE): Define. (GFC_UINTEGER_8_HUGE): Define. (GFC_UINTEGER_16_HUGE): Define. (HAVE_GFC_UINTEGER_1): Undefine (done by mk-kind-h.sh) (HAVE_GFC_UINTEGER_4): Likewise. * mk-kinds-h.sh: Add GFC_UINTEGER_*_HUGE. gcc/testsuite/ChangeLog: * gfortran.dg/unsigned_1.f90: New test. * gfortran.dg/unsigned_10.f90: New test. * gfortran.dg/unsigned_11.f90: New test. * gfortran.dg/unsigned_12.f90: New test. * gfortran.dg/unsigned_13.f90: New test. * gfortran.dg/unsigned_14.f90: New test. * gfortran.dg/unsigned_15.f90: New test. * gfortran.dg/unsigned_16.f90: New test. * gfortran.dg/unsigned_17.f90: New test. * gfortran.dg/unsigned_18.f90: New test. * gfortran.dg/unsigned_19.f90: New test. * gfortran.dg/unsigned_2.f90: New test. * gfortran.dg/unsigned_20.f90: New test. * gfortran.dg/unsigned_21.f90: New test. * gfortran.dg/unsigned_22.f90: New test. * gfortran.dg/unsigned_23.f90: New test. * gfortran.dg/unsigned_24.f: New test. * gfortran.dg/unsigned_3.f90: New test. * gfortran.dg/unsigned_4.f90: New test. * gfortran.dg/unsigned_5.f90: New test. * gfortran.dg/unsigned_6.f90: New test. * gfortran.dg/unsigned_7.f90: New test. * gfortran.dg/unsigned_8.f90: New test. * gfortran.dg/unsigned_9.f90: New test.
141 lines
4.0 KiB
Bash
Executable File
141 lines
4.0 KiB
Bash
Executable File
#!/bin/sh
|
|
LC_ALL=C
|
|
export LC_ALL
|
|
|
|
if test "$#" -ne 4; then
|
|
echo "Usage $0 int_kinds real_kinds compile use_iec_60559"
|
|
exit 1
|
|
fi
|
|
|
|
# Possible kinds must be listed in ascending order
|
|
possible_integer_kinds="$1"
|
|
possible_real_kinds="$2"
|
|
compile="$3"
|
|
use_iec_60559="$4"
|
|
|
|
largest=""
|
|
smallest=""
|
|
for k in $possible_integer_kinds; do
|
|
echo " integer (kind=$k) :: i" > tmp$$.f90
|
|
echo " i = 1_$k" >> tmp$$.f90
|
|
echo " end" >> tmp$$.f90
|
|
if $compile -S tmp$$.f90 > /dev/null 2>&1; then
|
|
s=`expr 8 \* $k`
|
|
largest="$k"
|
|
|
|
if [ $s -eq 128 ]; then
|
|
prefix="__"
|
|
else
|
|
prefix=""
|
|
fi
|
|
|
|
if [ "$smallest" = "" ]; then
|
|
smallest="$k"
|
|
fi
|
|
|
|
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}"
|
|
echo "#define HAVE_GFC_INTEGER_${k}"
|
|
echo "#define HAVE_GFC_UINTEGER_${k}"
|
|
echo ""
|
|
fi
|
|
rm -f tmp$$.*
|
|
done
|
|
|
|
echo "#define GFC_INTEGER_LARGEST GFC_INTEGER_${largest}"
|
|
echo "#define GFC_UINTEGER_LARGEST GFC_UINTEGER_${largest}"
|
|
echo "#define GFC_DEFAULT_CHAR ${smallest}"
|
|
echo ""
|
|
|
|
|
|
# Get the kind value for long double, so we may disambiguate it
|
|
# 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 *//'`
|
|
rm -f tmq$$.*
|
|
|
|
|
|
for k in $possible_real_kinds; do
|
|
echo " real (kind=$k) :: x" > tmp$$.f90
|
|
echo " x = 1.0_$k" >> tmp$$.f90
|
|
echo " end" >> tmp$$.f90
|
|
if $compile -S tmp$$.f90 > /dev/null 2>&1; then
|
|
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" ;;
|
|
# 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
|
|
|
|
# Check for the value of HUGE
|
|
echo "print *, huge(0._$k) ; end" > tmq$$.f90
|
|
huge=`$compile -S -fdump-parse-tree tmq$$.f90 | grep TRANSFER \
|
|
| 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 \
|
|
| sed 's/ *TRANSFER *//'`
|
|
rm -f tmq$$.*
|
|
|
|
# Check for the value of RADIX
|
|
echo "print *, radix(0._$k) ; end" > tmq$$.f90
|
|
radix=`$compile -S -fdump-parse-tree tmq$$.f90 | grep TRANSFER \
|
|
| sed 's/ *TRANSFER *//'`
|
|
rm -f tmq$$.*
|
|
|
|
# Output the information we've gathered
|
|
echo "typedef ${ctype} GFC_REAL_${k};"
|
|
echo "typedef ${cplxtype} GFC_COMPLEX_${k};"
|
|
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)"
|
|
else
|
|
echo "#define GFC_REAL_${k}_LITERAL(X) (X ## ${suffix})"
|
|
fi
|
|
echo "#define GFC_REAL_${k}_DIGITS ${digits}"
|
|
echo "#define GFC_REAL_${k}_RADIX ${radix}"
|
|
echo ""
|
|
fi
|
|
rm -f tmp$$.*
|
|
done
|
|
|
|
|
|
# After this, we include a header that can override some of the
|
|
# autodetected settings.
|
|
echo '#include "kinds-override.h"'
|
|
|
|
exit 0
|