Commit graph

2134 commits

Author SHA1 Message Date
Paul Thomas
94fa9f4d27 Fortran: Implement the F2018 reduce intrinsic [PR85836]
2025-03-21  Paul Thomas  <pault@gcc.gnu.org>

gcc/fortran
	PR fortran/85836
	* check.cc (get_ul_from_cst_cl): New function used in
	check_operation.
	(check_operation): New function used in check_reduce and
	check_co_reduce.
	(gfc_check_co_reduce): Use it.
	(gfc_check_reduce): New function.
	(gfc_check_rename): Add prototype for intrinsic with 6 arguments.
	* gfortran.h : Add isym id for reduce and prototype for f6.
	* intrinsic.cc (do_check): Add another argument expression and use
	it in the call to the six argument specific check.
	(add_sym_6): New function.
	(add_functions): Add the discription of the reduce intrinsic and
	add it to the intrinsic list.
	* intrinsic.h : Add prototypes for gfc_check_reduce and
	gfc_resolve_reduce.
	* iresolve.cc (generate_reduce_op_wrapper): Generate a wrapper
	subroutine for the 'operation' function to enable the library
	implementation to be type agnostic and use pointer arithmetic
	throughout.
	(gfc_resolve_reduce): New function.
	* trans-expr.cc (gfc_conv_procedure_call): Add flag for scalar
	reduce. Generate a return variable 'sr' for scalar reduce, pass its
	address to the library function and return it as the scalar result.
	* trans-intrinsic.cc (gfc_conv_intrinsic_function): Array valued
	reduce is called in same way as reshape. Fall through for call to
	the scalar version.

gcc/testsuite/
	PR fortran/85836
	* gfortran.dg/reduce_1.f90: New test
	* gfortran.dg/reduce_2.f90: New test

libgfortran/
	PR libfortran/85836
	* Makefile.am : Add reduce.c
	* Makefile.in : Regenerated
	* gfortran.map : Add _gfortran_reduce, _gfortran_reduce_scalar,
	_gfortran_reduce_c and _gfortran_reduce_scalar_c to the list.
	* intrinsics/reduce.c (reduce, reduce_scalar, reduce_c,
	reduce_scalar_c): New functions and prototypes
2025-03-21 16:20:21 +00:00
GCC Administrator
d880cb4620 Daily bump. 2025-02-28 00:16:37 +00:00
Thomas Schwinge
bac2d8a246 nvptx: Build libgfortran with '-mfake-ptx-alloca' [PR107635]
As of recent commit 8bf0ee8d62
"Fortran: Add transfer_between_remotes [PR107635]", we've got 'alloca' usage
in 'libgfortran/caf/single.c:_gfortran_caf_transfer_between_remotes', and
the libgfortran target library fails to build for legacy configurations where
PTX 'alloca' is not available:

    ../../../../source-gcc/libgfortran/caf/single.c: In function ‘_gfortran_caf_transfer_between_remotes’:
    ../../../../source-gcc/libgfortran/caf/single.c:675:23: sorry, unimplemented: dynamic stack allocation not supported
      675 |       transfer_desc = __builtin_alloca (desc_size);
          |                       ^~~~~~~~~~~~~~~~~~~~~~~~~~~~
    ../../../../source-gcc/libgfortran/caf/single.c:680:20: sorry, unimplemented: dynamic stack allocation not supported
      680 |     transfer_ptr = __builtin_alloca (*opt_dst_charlen * src_size);
          |                    ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    make[6]: *** [Makefile:4675: caf/single.lo] Error 1

With '-mfake-ptx-alloca', libgfortran again succeeds to build, and compared
to before, we've got only a small number of regressions due to nvptx 'ld'
complaining about 'unresolved symbol __GCC_nvptx__PTX_alloca_not_supported':

    [-PASS:-]{+FAIL:+} gfortran.dg/coarray/codimension_2.f90 -fcoarray=lib  -O2  -lcaf_single (test for excess errors)

    [-PASS:-]{+FAIL:+} gfortran.dg/coarray/event_4.f08 -fcoarray=lib  -O2  -lcaf_single (test for excess errors)
    [-PASS:-]{+UNRESOLVED:+} gfortran.dg/coarray/event_4.f08 -fcoarray=lib  -O2  -lcaf_single [-execution test-]{+compilation failed to produce executable+}

    [-PASS:-]{+FAIL:+} gfortran.dg/coarray/fail_image_2.f08 -fcoarray=lib  -O2  -lcaf_single (test for excess errors)
    [-PASS:-]{+UNRESOLVED:+} gfortran.dg/coarray/fail_image_2.f08 -fcoarray=lib  -O2  -lcaf_single [-execution test-]{+compilation failed to produce executable+}

    [-PASS:-]{+FAIL:+} gfortran.dg/coarray/proc_pointer_assign_1.f90 -fcoarray=lib  -O2  -lcaf_single (test for excess errors)
    [-PASS:-]{+UNRESOLVED:+} gfortran.dg/coarray/proc_pointer_assign_1.f90 -fcoarray=lib  -O2  -lcaf_single [-execution test-]{+compilation failed to produce executable+}

    [-PASS:-]{+FAIL:+} gfortran.dg/coarray_43.f90   -O  (test for excess errors)

That's acceptable for such legacy PTX configurations.

	PR target/107635
	libgfortran/
	* config/t-nvptx: New.
	* configure.host [nvptx] (tmake_file): Add it.
2025-02-27 21:48:15 +01:00
GCC Administrator
4de2d2f80e Daily bump. 2025-02-22 00:17:38 +00:00
Andre Vehreschild
08bdc2ac98 Fortran: Fix build on solaris [PR107635]
libgfortran/ChangeLog:

	PR fortran/107635
	* caf/single.c: Replace alloca with __builtin_alloca.
2025-02-21 09:13:50 +01:00
GCC Administrator
fe4811fd19 Daily bump. 2025-02-21 00:17:36 +00:00
Andre Vehreschild
d324467544 Fortran: Remove deprecated coarray routines [PR107635]
gcc/fortran/ChangeLog:

	PR fortran/107635

	* gfortran.texi: Remove deprecated functions from documentation.
	* trans-decl.cc (gfc_build_builtin_function_decls): Remove
	decprecated function decls.
	* trans-intrinsic.cc (gfc_conv_intrinsic_exponent): Remove
	deprecated/no longer needed routines.
	* trans.h: Remove unused decls.

libgfortran/ChangeLog:

	* caf/libcaf.h (_gfortran_caf_get): Removed because deprecated.
	(_gfortran_caf_send): Same.
	(_gfortran_caf_sendget): Same.
	(_gfortran_caf_send_by_ref): Same.
	* caf/single.c (assign_char4_from_char1): Same.
	(assign_char1_from_char4): Same.
	(convert_type): Same.
	(defined): Same.
	(_gfortran_caf_get): Same.
	(_gfortran_caf_send): Same.
	(_gfortran_caf_sendget): Same.
	(copy_data): Same.
	(get_for_ref): Same.
	(_gfortran_caf_get_by_ref): Same.
	(send_by_ref): Same.
	(_gfortran_caf_send_by_ref): Same.
	(_gfortran_caf_sendget_by_ref): Same.
2025-02-20 10:34:35 +01:00
Andre Vehreschild
8bf0ee8d62 Fortran: Add transfer_between_remotes [PR107635]
Add the last missing coarray data manipulation routine using remote
accessors.

gcc/fortran/ChangeLog:

	PR fortran/107635

	* coarray.cc (rewrite_caf_send): Rewrite to
	transfer_between_remotes when both sides of the assignment have
	a coarray.
	(coindexed_code_callback): Prevent duplicate rewrite.
	* gfortran.texi: Add documentation for transfer_between_remotes.
	* intrinsic.cc (add_subroutines): Add intrinsic symbol for
	caf_sendget to allow easy rewrite to transfer_between_remotes.
	* trans-decl.cc (gfc_build_builtin_function_decls): Add
	prototype for transfer_between_remotes.
	* trans-intrinsic.cc (conv_caf_vector_subscript_elem): Mark as
	deprecated.
	(conv_caf_vector_subscript): Same.
	(compute_component_offset): Same.
	(conv_expr_ref_to_caf_ref): Same.
	(conv_stat_and_team): Extract stat and team from expr.
	(gfc_conv_intrinsic_caf_get): Use conv_stat_and_team.
	(conv_caf_send_to_remote): Same.
	(has_ref_after_cafref): Mark as deprecated.
	(conv_caf_sendget): Translate to transfer_between_remotes.
	* trans.h: Add prototype for transfer_between_remotes.

libgfortran/ChangeLog:

	* caf/libcaf.h: Add prototype for transfer_between_remotes.
	* caf/single.c: Implement transfer_between_remotes.

gcc/testsuite/ChangeLog:

	* gfortran.dg/coarray_lib_comm_1.f90: Fix up scan_trees.
2025-02-20 10:33:54 +01:00
Andre Vehreschild
69eb02682b Fortran: Add send_to_remote [PR107635]
Refactor to use send_to_remote instead of the slow send_by_ref.

gcc/fortran/ChangeLog:

	PR fortran/107635

	* coarray.cc (move_coarray_ref): Move the coarray reference out
	of the given one.  Especially when there is a regular array ref.
	(fixup_comp_refs): Move components refs to a derived type where
	the codim has been removed, aka a new type.
	(split_expr_at_caf_ref): Correctly split the reference chain.
	(remove_caf_ref): Simplify.
	(create_get_callback): Fix some deficiencies.
	(create_allocated_callback): Adapt to new signature of split.
	(create_send_callback): New function.
	(rewrite_caf_send): Rewrite a call to caf_send to
	caf_send_to_remote.
	(coindexed_code_callback): Treat caf_send and caf_sendget
	correctly.
	* gfortran.h (enum gfc_isym_id): Add SENDGET-isym.
	* gfortran.texi: Add documentation for send_to_remote.
	* resolve.cc (gfc_resolve_code): No longer generate send_by_ref
	when allocatable coarray (component) is on the lhs.
	* trans-decl.cc (gfc_build_builtin_function_decls): Add
	caf_send_to_remote decl.
	* trans-intrinsic.cc (conv_caf_func_index): Ensure the static
	variables created are not in a block-scope.
	(conv_caf_send_to_remote): Translate caf_send_to_remote calls.
	(conv_caf_send): Renamed to conv_caf_sendget.
	(conv_caf_sendget): Renamed from conv_caf_send.
	(gfc_conv_intrinsic_subroutine): Branch correctly for
	conv_caf_send and sendget.
	* trans.h: Correct decl.

libgfortran/ChangeLog:

	* caf/libcaf.h: Add/Correct prototypes for caf_get_from_remote,
	caf_send_to_remote.
	* caf/single.c (struct accessor_hash_t): Rename accessor_t to
	getter_t.
	(_gfortran_caf_register_accessor): Use new name of getter_t.
	(_gfortran_caf_send_to_remote): New function for sending data to
	coarray on a remote image.

gcc/testsuite/ChangeLog:

	* gfortran.dg/coarray/send_char_array_1.f90: Extend test to
	catch more cases.
	* gfortran.dg/coarray_42.f90: Invert tests use, because no
	longer a send is needed when local memory in a coarray is
	allocated.
2025-02-20 10:33:05 +01:00
Andre Vehreschild
1584725264 Fortran: Add caf_is_present_on_remote. [PR107635]
Replace caf_is_present by caf_is_present_on_remote which is using a
dedicated callback for each object to test on the remote image.

gcc/fortran/ChangeLog:

	PR fortran/107635

	* coarray.cc (create_allocated_callback): Add creating remote
	side procedure for checking allocation status of coarray.
	(rewrite_caf_allocated): Rewrite ALLOCATED on coarray to use caf
	routine.
	(coindexed_expr_callback): Exempt caf_is_present_on_remote from
	being rewritten again.
	* gfortran.h (enum gfc_isym_id): Add caf_is_present_on_remote
	id.
	* gfortran.texi: Add documentation for caf_is_present_on_remote.
	* intrinsic.cc (add_functions): Add caf_is_present_on_remote
	symbol.
	* trans-decl.cc (gfc_build_builtin_function_decls): Define
	interface of caf_is_present_on_remote.
	* trans-intrinsic.cc (gfc_conv_intrinsic_caf_is_present_remote):
	Translate caf_is_present_on_remote.
	(trans_caf_is_present): Remove.
	(caf_this_image_ref): Remove.
	(gfc_conv_allocated): Take out coarray treatment, because that
	is rewritten to caf_is_present_on_remote now.
	(gfc_conv_intrinsic_function): Handle caf_is_present_on_remote
	calls.
	* trans.h: Add symbol for caf_is_present_on_remote and remove
	old one.

libgfortran/ChangeLog:

	* caf/libcaf.h (_gfortran_caf_is_present_on_remote): Add new
	function.
	(_gfortran_caf_is_present): Remove deprecated one.
	* caf/single.c (struct accessor_hash_t): Add function ptr access
	for remote side call.
	(_gfortran_caf_is_present_on_remote): Added.
	(_gfortran_caf_is_present): Removed.

gcc/testsuite/ChangeLog:

	* gfortran.dg/coarray/coarray_allocated.f90: Adapt to new method
	of checking on remote image.
	* gfortran.dg/coarray_lib_alloc_4.f90: Same.
2025-02-20 10:32:21 +01:00
Andre Vehreschild
abbfeb2ecb Fortran: Allow to use non-pure/non-elemental functions in coarray indexes [PR107635]
Extract calls to non-pure or non-elemental functions from index
expressions on a coarray.

gcc/fortran/ChangeLog:

	PR fortran/107635

	* coarray.cc (get_arrayspec_from_expr): Treat array result of
	function calls correctly.
	(remove_coarray_from_derived_type): Prevent memory loss.
	(add_caf_get_from_remote): Correct locus.
	(find_comp): New function to find or create a new component in a
	derived type.
	(check_add_new_comp_handle_array): Handle allocatable arrays or
	non-pure/non-elemental functions in indexes of coarrays.
	(check_add_new_component): Use above function.
	(create_get_parameter_type): Rename to
	create_caf_add_data_parameter_type.
	(create_caf_add_data_parameter_type): Renaming of variable and
	make the additional data a coarray.
	(remove_caf_ref): Factor out to reuse in other caf-functions.
	(create_get_callback): Use function factored out, set locus
	correctly and ensure a kind is set for parameters.
	(add_caf_get_intrinsic): Rename to add_caf_get_from_remote and
	rename some variables.
	(coindexed_expr_callback): Skip over function created by the
	rewriter.
	(coindexed_code_callback): Filter some intrinsics not to
	process.
	(gfc_coarray_rewrite): Rewrite also contained functions.
	* trans-intrinsic.cc (gfc_conv_intrinsic_caf_get): Reflect
	changed order on caf_get_from_remote ().

libgfortran/ChangeLog:

	* caf/libcaf.h (_gfortran_caf_register_accessor): Reflect
	changed parameter order.
	* caf/single.c (struct accessor_hash_t): Same.
	(_gfortran_caf_register_accessor): Call accessor using a token
	for accessing arrays with a descriptor on the source side.

gcc/testsuite/ChangeLog:

	* gfortran.dg/coarray_lib_comm_1.f90: Adapt scan expression.
	* gfortran.dg/coarray/get_with_fn_parameter.f90: New test.
	* gfortran.dg/coarray/get_with_scalar_fn.f90: New test.
2025-02-20 10:31:40 +01:00
Andre Vehreschild
b114312bba Fortran: Prepare for more caf-rework. [PR107635]
Factor out generation of code to get remote function index and to
create the additional data structure.  Rename caf_get_by_ct to
caf_get_from_remote.

gcc/fortran/ChangeLog:

	PR fortran/107635

	* gfortran.texi: Rename caf_get_by_ct to caf_get_from_remote.
	* trans-decl.cc (gfc_build_builtin_function_decls): Rename
	intrinsic.
	* trans-intrinsic.cc (conv_caf_func_index): Factor out
	functionality to be reused by other caf-functions.
	(conv_caf_add_call_data): Same.
	(gfc_conv_intrinsic_caf_get): Use functions factored out.
	* trans.h: Rename intrinsic symbol.

libgfortran/ChangeLog:

	* caf/libcaf.h (_gfortran_caf_get_by_ref): Remove from ABI.
	This function is replaced by caf_get_from_remote ().
	(_gfortran_caf_get_remote_function_index): Use better name.
	* caf/single.c (_gfortran_caf_finalize): Free internal data.
	(_gfortran_caf_get_by_ref): Remove from public interface, but
	keep it, because it is still used by sendget ().

gcc/testsuite/ChangeLog:

	* gfortran.dg/coarray_lib_comm_1.f90: Adapt to renamed ABI
	function.
	* gfortran.dg/coarray_stat_function.f90: Same.
	* gfortran.dg/coindexed_1.f90: Same.
2025-02-20 10:31:02 +01:00
Andre Vehreschild
90ba8291c3 Fortran: Move caf_get-rewrite to coarray.cc [PR107635]
Add a rewriter to keep all expression tree that is not optimization
together.  At the moment this is just a move from resolve.cc, but will
be extended to handle more cases where rewriting the expression tree may
be easier.  The first use case is to extract accessors for coarray
remote image data access.

gcc/fortran/ChangeLog:

	PR fortran/107635
	* Make-lang.in: Add coarray.cc.
	* coarray.cc: New file.
	* gfortran.h (gfc_coarray_rewrite): New procedure.
	* parse.cc (rewrite_expr_tree): Add entrypoint for rewriting
	expression trees.
	* resolve.cc (gfc_resolve_ref): Remove caf_lhs handling.
	(get_arrayspec_from_expr): Moved to rewrite.cc.
	(remove_coarray_from_derived_type): Same.
	(convert_coarray_class_to_derived_type): Same.
	(split_expr_at_caf_ref): Same.
	(check_add_new_component): Same.
	(create_get_parameter_type): Same.
	(create_get_callback): Same.
	(add_caf_get_intrinsic): Same.
	(resolve_variable): Remove caf_lhs handling.

libgfortran/ChangeLog:

	* caf/single.c (_gfortran_caf_finalize): Free memory preventing
	leaks.
	(_gfortran_caf_get_by_ct): Fix constness.
	* caf/libcaf.h (_gfortran_caf_register_accessor): Fix constness.
2025-02-20 10:19:46 +01:00
GCC Administrator
5378627142 Daily bump. 2025-02-07 00:18:53 +00:00
Jerry DeLisle
cfed99751c Fortran: Fix handling of the X edit descriptor.
This patch is a partial fix of handling of X edit descriptors
when combined with certain T edit descriptors.

	PR libfortran/114618

libgfortran/ChangeLog:

	* io/transfer.c (formatted_transfer_scalar_write): Change name
	of vriable 'pos' to 'tab_pos' to improve clarity. Add new
	variable next_pos when calculating the maximum position.
	Update the calculation of pending spaces.

gcc/testsuite/ChangeLog:

	* gfortran.dg/pr114618.f90: New test.
2025-02-06 09:43:26 -08:00
GCC Administrator
432f988f0c Daily bump. 2025-02-05 00:18:28 +00:00
Thomas Koenig
c2a0ee5886 Add modular exponentiation for UNSIGNED.
gcc/fortran/ChangeLog:

	* arith.cc (arith_power): Handle modular arithmetic for
	BT_UNSIGNED.
	(eval_intrinsic):  Error for unsigned exponentiation with
	-pedantic.
	* expr.cc (gfc_type_convert_binary): Use type of first
	argument for unsigned exponentiation.
	* gfortran.texi: Mention arithmetic exponentiation.
	* resolve.cc (resolve_operator): Allow unsigned exponentiation.
	* trans-decl.cc (gfc_build_intrinsic_function_decls): Build
	declarations for unsigned exponentiation.
	* trans-expr.cc (gfc_conv_cst_uint_power): New function.
	(gfc_conv_power_op): Call it.  Handle unsigned exponentiation.
	* trans.h (gfor_fndecl_unsigned_pow_list):  Add declaration.

libgfortran/ChangeLog:

	* Makefile.am: Add files for unsigned exponentiation.
	* Makefile.in: Regenerate.
	* gfortran.map: Add functions for unsigned exponentiation.
	* generated/pow_m16_m1.c: New file.
	* generated/pow_m16_m16.c: New file.
	* generated/pow_m16_m2.c: New file.
	* generated/pow_m16_m4.c: New file.
	* generated/pow_m16_m8.c: New file.
	* generated/pow_m1_m1.c: New file.
	* generated/pow_m1_m16.c: New file.
	* generated/pow_m1_m2.c: New file.
	* generated/pow_m1_m4.c: New file.
	* generated/pow_m1_m8.c: New file.
	* generated/pow_m2_m1.c: New file.
	* generated/pow_m2_m16.c: New file.
	* generated/pow_m2_m2.c: New file.
	* generated/pow_m2_m4.c: New file.
	* generated/pow_m2_m8.c: New file.
	* generated/pow_m4_m1.c: New file.
	* generated/pow_m4_m16.c: New file.
	* generated/pow_m4_m2.c: New file.
	* generated/pow_m4_m4.c: New file.
	* generated/pow_m4_m8.c: New file.
	* generated/pow_m8_m1.c: New file.
	* generated/pow_m8_m16.c: New file.
	* generated/pow_m8_m2.c: New file.
	* generated/pow_m8_m4.c: New file.
	* generated/pow_m8_m8.c: New file.
	* m4/powu.m4: New file.

gcc/testsuite/ChangeLog:

	* gfortran.dg/unsigned_15.f90: Adjust error messages.
	* gfortran.dg/unsigned_43.f90: New test.
	* gfortran.dg/unsigned_44.f90: New test.
2025-02-04 08:56:19 +01:00
GCC Administrator
3fafd9cb40 Daily bump. 2025-01-25 00:17:46 +00:00
Jerry DeLisle
4daf088123 Fortran: Fix UTF-8 output with A edit descriptor.
This adjusts the source len for the case where the user has
	specified a field width with the A descriptor.

	PR libfortran/118571

libgfortran/ChangeLog:

	* io/write.c (write_utf8_char4): Adjust the src_len to the
	format width w_len when greater than zero.

gcc/testsuite/ChangeLog:

	* gfortran.dg/utf8_3.f03: New test.
2025-01-24 09:05:56 -08:00
GCC Administrator
43a15cecba Daily bump. 2025-01-18 00:17:42 +00:00
Harald Anlauf
ca2681d45a libfortran: G formatting for UNSIGNED [PR118536]
PR libfortran/118536

libgfortran/ChangeLog:

	* io/transfer.c (formatted_transfer_scalar_write): Handle UNSIGNED
	in G formatting.

gcc/testsuite/ChangeLog:

	* gfortran.dg/unsigned_write_2.f90: New test.
2025-01-17 22:38:41 +01:00
GCC Administrator
29da6a6424 Daily bump. 2025-01-17 00:20:08 +00:00
Harald Anlauf
99bcce0d89 libfortran: fix conversion of UNSIGNED(kind=16) to decimal in output [PR118406]
PR libfortran/118406

libgfortran/ChangeLog:

	* runtime/string.c (gfc_itoa): Handle unsigned integers larger than
	(10^19 * 2^64).

gcc/testsuite/ChangeLog:

	* gfortran.dg/unsigned_write.f90: New test.
2025-01-16 20:43:16 +01:00
Jakub Jelinek
6441eb6dc0 Update copyright years. 2025-01-02 11:59:57 +01:00
Jakub Jelinek
2c08aca65a Rotate ChangeLog files.
Rotate ChangeLog files for ChangeLogs with yearly cadence.
Also remove empty lines before Form Feed line.
2025-01-02 11:06:31 +01:00
GCC Administrator
4a8af01be0 Daily bump. 2024-12-24 00:17:55 +00:00
Hans-Peter Nilsson
a5b1f3e14a libgfortran: Fix build for targets with int32_t=long int
Without this, after r15-6415-g586477d67bf2e3, you'll see,
for targets where int32_t is a typedef of long int (beware
of artificially broken lines):

/x/gcc/libgfortran/caf/single.c: In function '_gfortran_caf_get_by_ct':
/x/gcc/libgfortran/caf/single.c:2943:56: error: passing argument 2 of '\
(accessor_hash_table + (sizetype)((unsigned int)getter_index * 12))->ac\
cessor' from incompatible pointer type [-Wincompatible-pointer-types]
 2943 |   accessor_hash_table[getter_index].accessor (dst_ptr, &free_bu\
ffer, src_ptr,
      |                                                        ^~~~~~~~\
~~~~
      |                                                        |
      |                                                        int *
/x/gcc/libgfortran/caf/single.c:2943:56: note: expected 'int32_t *' {ak\
a 'long int *'} but argument is of type 'int *'

libgfortran:
	* caf/single.c (_gfortran_caf_get_by_ct): Correct type of free_buffer
	to int32_t.
2024-12-24 01:13:02 +01:00
GCC Administrator
946ebec154 Daily bump. 2024-12-23 00:16:26 +00:00
Andre Vehreschild
586477d67b Fortran: Replace getting of coarray data with accessor-based version. [PR107635]
Getting coarray data from remote images was slow, inefficient and did
not work for object files that where not compiled with coarray support
for derived types with allocatable/pointer components.  The old approach
emulated accessing data through a whole structure ref, which was error
prone for corner cases.  Furthermore was did it have a runtime
complexity of O(N), where N is the number of allocatable/pointer
components and descriptors involved.  Each of those needed communication
twice.  The new approach creates a routine for each access into a
coarray object putting all required operations there.  Looking a
tree-dump one will see those small routines.  But this time it is just
compiled fortran with all the knowledge of the compiler of bounds and so
on.  New paradigms will be available out of the box.  Furthermore is the
complexity of the communication reduced to be O(1).  E.g. the mpi
implementation sends one message for the parameters of the access and
one message back with the results without caring about the number of
allocatable/pointer/descriptor components in the access.

Identification of access routines is done be adding them to a hash map,
where the hash is the same on all images.  Translating the hash to an
index, which is the same on all images again, allows for fast calls of
the access routines.  Resolving the hash to an index is cached at
runtime, preventing additional hash map lookups.  A hashmap was use
because not all processor OS combinations may use the same address for
the access routine.

gcc/fortran/ChangeLog:

	PR fortran/107635

	* gfortran.h (gfc_add_caf_accessor): New function.
	* gfortran.texi: Document new API routines.
	* resolve.cc (get_arrayspec_from_expr): Synthesize the arrayspec
	resulting from an expression, i.e. not only the rank, but also
	the bounds.
	(remove_coarray_from_derived_type): Remove coarray ref from a
	derived type to access it in access routine.
	(convert_coarray_class_to_derived_type): Same but for classes.
	The result is a derived type.
	(split_expr_at_caf_ref): Split an expression at the coarray
	reference to move the reference after the coarray ref into the
	access routine.
	(check_add_new_component): Helper to add variables as
	components to derived type transfered to the access routine.
	(create_get_parameter_type): Create the derived type to transfer
	addressing data to the access routine.
	(create_get_callback): Create the access routine.
	(add_caf_get_intrinsic): Use access routine instead of old
	caf_get.
	* trans-decl.cc (gfc_build_builtin_function_decls): Register new
	API routines.
	(gfc_create_module_variable): Use renamed flag.
	(gfc_emit_parameter_debug_info):
	(struct caf_accessor): Linked list of hash-access routine pairs.
	(gfc_add_caf_accessor): Add a hash-access routine pair to above
	linked list.
	(create_caf_accessor_register): Add all registered hash-access
	routine pairs to the current caf_init.
	(generate_coarray_init): Use routine above.
	(gfc_generate_module_vars): Use renamed flag.
	(generate_local_decl): Same.
	(gfc_generate_function_code): Same.
	(gfc_process_block_locals): Same.
	* trans-intrinsic.cc (conv_shape_to_cst): Build the product of a
	shape.
	(gfc_conv_intrinsic_caf_get): Create call to access routine.
	(conv_caf_send): Adapt to caf_get using less arguments.
	(gfc_conv_intrinsic_function): Same.
	* trans.cc (gfc_trans_force_lval): Helper to ensure that an
	expression can be used as an lvalue-ref.
	* trans.h (gfc_trans_force_lval): See above.

libgfortran/ChangeLog:

	* caf/libcaf.h (_gfortran_caf_register_accessor): New function
	to register access routines at runtime.
	(_gfortran_caf_register_accessors_finish): New function to
	finish registration of access routine and sort hash map.
	(_gfortran_caf_get_remote_function_index): New function to
	convert an hash to an index.
	(_gfortran_caf_get_by_ct): New function to get data from a
	remote image using the access routine given by an index.
	* caf/single.c (struct accessor_hash_t): Hashmap type.
	(_gfortran_caf_send): Fixed formatting.
	(_gfortran_caf_register_accessor): Register a hash accessor
	routine.
	(hash_compare): Compare two hashes for sort() and bsearch().
	(_gfortran_caf_register_accessors_finish): Sort the hashmap to
	allow bsearch()'s quick lookup.
	(_gfortran_caf_get_remote_function_index): Map a hash to an
	index.
	(_gfortran_caf_get_by_ct): Get data from a remote image using
	the index provided by get_remote_function_index().

gcc/testsuite/ChangeLog:

	* gfortran.dg/coarray_atomic_5.f90: Adapted to look for
	get_by_ct.
	* gfortran.dg/coarray_lib_comm_1.f90: Same.
	* gfortran.dg/coarray_stat_function.f90: Same.
2024-12-22 16:28:47 +01:00
GCC Administrator
2a95e00abf Daily bump. 2024-12-21 00:19:33 +00:00
Andre Vehreschild
a25cc26884 Fortran: Fix caf_stop_numeric and reporting exceptions from caf [PR57598]
Caf_stop_numeric always exited with code 0, which is wrong.  It shall
behave like regular stop.  Add reporting exceptions to caf's stop
handlers.  For this the existing library routine had to be exported.

libgfortran/ChangeLog:

	PR fortran/57598

	* caf/single.c (_gfortran_caf_stop_numeric): Report exceptions
	on stop. And fix send_by_ref.
	(_gfortran_caf_stop_str): Same.
	(_gfortran_caf_error_stop_str): Same.
	(_gfortran_caf_error_stop): Same.
	* gfortran.map: Add report_exception for export.
	* libgfortran.h (report_exception): Add to internal export.
	* runtime/stop.c (report_exception): Same.
2024-12-20 07:55:24 +01:00
GCC Administrator
d5b3d9ed34 Daily bump. 2024-12-11 00:19:28 +00:00
Jerry DeLisle
cf406a6c79 Fortran: Fix READ with padding in BLANK ZERO mode.
PR fortran/117819

libgfortran/ChangeLog:

	* io/read.c (read_decimal): If the read value is short of the
	specified width and pad mode is PAD yes, check for BLANK ZERO
	and adjust the value accordingly.
	(read_decimal_unsigned): Likewise.
	(read_radix): Likewise.

gcc/testsuite/ChangeLog:

	* gfortran.dg/pr117819.f90: New test.
2024-12-10 09:28:25 -08:00
GCC Administrator
739ce47f70 Daily bump. 2024-12-05 00:19:47 +00:00
Jerry DeLisle
7a92ba7668 Fortran: Fix B64.0 formatted write output.
PR fortran/117820

libgfortran/ChangeLog:

	* io/write.c (write_b): Add test for zero needed by write_boz.

gcc/testsuite/ChangeLog:

	* gfortran.dg/pr117820.f90: New test.
2024-12-03 20:57:59 -08:00
GCC Administrator
a095d720ac Daily bump. 2024-11-24 00:18:09 +00:00
Jerry DeLisle
fd118f4c54 Fortran: Reject missing comma in format.
Standards require rejecting formats where descriptors
	are not separated by commas. This change allows this
	the missing comma to be accepted only with
	-std=legacy.

	PR fortran/88052

libgfortran/ChangeLog:

	* io/format.c (parse_format_list): Reject missing comma in
	format strings by default or if -std=f95 or higher. This is
	a runtime error.

gcc/testsuite/ChangeLog:

	* gfortran.dg/comma_format_extension_4.f: Add missing comma.
	* gfortran.dg/dollar_edit_descriptor_2.f: Likewise.
	* gfortran.dg/fmt_error_9.f: Likewise.
	* gfortran.dg/fmt_g0_5.f08: Likewise.
	* gfortran.dg/fmt_t_2.f90: Likewise.
	* gfortran.dg/pr88052.f90: New test.
2024-11-23 09:45:36 -08:00
GCC Administrator
14870c1f86 Daily bump. 2024-10-08 00:19:04 +00:00
Thomas Koenig
c0002a675a Implement MAXLOC and MINLOC for unsigned.
gcc/fortran/ChangeLog:

	* check.cc (gfc_check_minloc_maxloc): Handle BT_UNSIGNED.
	* trans-intrinsic.cc (gfc_conv_intrinsic_minmaxloc): Likewise.
	* gfortran.texi: Document MAXLOC and MINLOC for UNSIGNED.

libgfortran/ChangeLog:

	* Makefile.am: Add files for unsigned MINLOC and MAXLOC.
	* Makefile.in: Regenerated.
	* gfortran.map: Add files for unsigned MINLOC and MAXLOC.
	* generated/maxloc0_16_m1.c: New file.
	* generated/maxloc0_16_m16.c: New file.
	* generated/maxloc0_16_m2.c: New file.
	* generated/maxloc0_16_m4.c: New file.
	* generated/maxloc0_16_m8.c: New file.
	* generated/maxloc0_4_m1.c: New file.
	* generated/maxloc0_4_m16.c: New file.
	* generated/maxloc0_4_m2.c: New file.
	* generated/maxloc0_4_m4.c: New file.
	* generated/maxloc0_4_m8.c: New file.
	* generated/maxloc0_8_m1.c: New file.
	* generated/maxloc0_8_m16.c: New file.
	* generated/maxloc0_8_m2.c: New file.
	* generated/maxloc0_8_m4.c: New file.
	* generated/maxloc0_8_m8.c: New file.
	* generated/maxloc1_16_m1.c: New file.
	* generated/maxloc1_16_m2.c: New file.
	* generated/maxloc1_16_m4.c: New file.
	* generated/maxloc1_16_m8.c: New file.
	* generated/maxloc1_4_m1.c: New file.
	* generated/maxloc1_4_m16.c: New file.
	* generated/maxloc1_4_m2.c: New file.
	* generated/maxloc1_4_m4.c: New file.
	* generated/maxloc1_4_m8.c: New file.
	* generated/maxloc1_8_m1.c: New file.
	* generated/maxloc1_8_m16.c: New file.
	* generated/maxloc1_8_m2.c: New file.
	* generated/maxloc1_8_m4.c: New file.
	* generated/maxloc1_8_m8.c: New file.
	* generated/minloc0_16_m1.c: New file.
	* generated/minloc0_16_m16.c: New file.
	* generated/minloc0_16_m2.c: New file.
	* generated/minloc0_16_m4.c: New file.
	* generated/minloc0_16_m8.c: New file.
	* generated/minloc0_4_m1.c: New file.
	* generated/minloc0_4_m16.c: New file.
	* generated/minloc0_4_m2.c: New file.
	* generated/minloc0_4_m4.c: New file.
	* generated/minloc0_4_m8.c: New file.
	* generated/minloc0_8_m1.c: New file.
	* generated/minloc0_8_m16.c: New file.
	* generated/minloc0_8_m2.c: New file.
	* generated/minloc0_8_m4.c: New file.
	* generated/minloc0_8_m8.c: New file.
	* generated/minloc1_16_m1.c: New file.
	* generated/minloc1_16_m16.c: New file.
	* generated/minloc1_16_m2.c: New file.
	* generated/minloc1_16_m4.c: New file.
	* generated/minloc1_16_m8.c: New file.
	* generated/minloc1_4_m1.c: New file.
	* generated/minloc1_4_m16.c: New file.
	* generated/minloc1_4_m2.c: New file.
	* generated/minloc1_4_m4.c: New file.
	* generated/minloc1_4_m8.c: New file.
	* generated/minloc1_8_m1.c: New file.
	* generated/minloc1_8_m16.c: New file.
	* generated/minloc1_8_m2.c: New file.
	* generated/minloc1_8_m4.c: New file.
	* generated/minloc1_8_m8.c: New file.

gcc/testsuite/ChangeLog:

	* gfortran.dg/unsigned_35.f90: New test.
2024-10-07 20:40:44 +02:00
GCC Administrator
60f1feded2 Daily bump. 2024-10-02 00:17:48 +00:00
Thomas Koenig
9dd9a06940 Implement MAXVAL and MINVAL for UNSIGNED.
gcc/fortran/ChangeLog:

	* check.cc (int_or_real_or_char_or_unsigned_check_f2003): New function.
	(gfc_check_minval_maxval): Use it.
	* trans-intrinsic.cc (gfc_conv_intrinsic_minmaxval): Handle
	initial values for UNSIGNED.
	* gfortran.texi: Document MINVAL and MAXVAL for unsigned.

libgfortran/ChangeLog:

	* Makefile.am: Add minval and maxval files.
	* Makefile.in: Regenerated.
	* gfortran.map: Add new functions.
	* generated/maxval_m1.c: New file.
	* generated/maxval_m16.c: New file.
	* generated/maxval_m2.c: New file.
	* generated/maxval_m4.c: New file.
	* generated/maxval_m8.c: New file.
	* generated/minval_m1.c: New file.
	* generated/minval_m16.c: New file.
	* generated/minval_m2.c: New file.
	* generated/minval_m4.c: New file.
	* generated/minval_m8.c: New file.

gcc/testsuite/ChangeLog:

	* gfortran.dg/unsigned_34.f90: New test.
2024-10-01 18:42:37 +02:00
GCC Administrator
2d8392c4e7 Daily bump. 2024-09-25 00:18:47 +00:00
Thomas Koenig
291e20e860 Add random numbers and fix some bugs.
This patch adds random number support for UNSIGNED, plus fixes
two bugs, with array I/O where the type used to be set to BT_INTEGER,
and for division with the divisor being a constant.

gcc/fortran/ChangeLog:

	* check.cc (gfc_check_random_number): Adjust for unsigned.
	* iresolve.cc (gfc_resolve_random_number): Handle unsigned.
	* trans-expr.cc (gfc_conv_expr_op): Handle BT_UNSIGNED for divide.
	* trans-types.cc (gfc_get_dtype_rank_type): Handle BT_UNSIGNED.
	* gfortran.texi: Add RANDOM_NUMBER for UNSIGNED.

libgfortran/ChangeLog:

	* gfortran.map: Add _gfortran_random_m1, _gfortran_random_m2,
	_gfortran_random_m4, _gfortran_random_m8 and _gfortran_random_m16.
	* intrinsics/random.c (random_m1): New function.
	(random_m2): New function.
	(random_m4): New function.
	(random_m8): New function.
	(random_m16): New function.
	(arandom_m1): New function.
	(arandom_m2): New function.
	(arandom_m4): New function.
	(arandom_m8): New funciton.
	(arandom_m16): New function.

gcc/testsuite/ChangeLog:

	* gfortran.dg/unsigned_30.f90: New test.
2024-09-24 22:57:42 +02:00
Thomas Koenig
5e918a4db9 Implement SUM and PRODUCT for unsigned.
gcc/fortran/ChangeLog:

	* gfortran.texi: Document SUM and PRODUCT.
	* iresolve.cc (resolve_transformational): New argument,
	use_integer, to translate calls to unsigned to calls to
	integer.
	(gfc_resolve_product): Use it
	(gfc_resolve_sum): Use it.
	* simplify.cc (init_result_expr): Handle BT_UNSIGNED.

libgfortran/ChangeLog:

	* generated/product_c10.c: Regenerated.
	* generated/product_c16.c: Regenerated.
	* generated/product_c17.c: Regenerated.
	* generated/product_c4.c: Regenerated.
	* generated/product_c8.c: Regenerated.
	* generated/product_i1.c: Regenerated.
	* generated/product_i16.c: Regenerated.
	* generated/product_i2.c: Regenerated.
	* generated/product_i4.c: Regenerated.
	* generated/product_i8.c: Regenarated.
	* generated/product_r10.c: Regenerated.
	* generated/product_r16.c: Regenerated.
	* generated/product_r17.c: Regenerated.
	* generated/product_r4.c: Regenerated.
	* generated/product_r8.c: Regenarated.
	* generated/sum_c10.c: Regenerated.
	* generated/sum_c16.c: Regenerated.
	* generated/sum_c17.c: Regenerated.
	* generated/sum_c4.c: Regenerated.
	* generated/sum_c8.c: Regenerated.
	* generated/sum_i1.c: Regenerated.
	* generated/sum_i16.c: Regenerated.
	* generated/sum_i2.c: Regenerated.
	* generated/sum_i4.c: Regenerated.
	* generated/sum_i8.c: Regenerated.
	* generated/sum_r10.c: Regenerated.
	* generated/sum_r16.c: Regenerated.
	* generated/sum_r17.c: Regenerated.
	* generated/sum_r4.c: Regenerated.
	* generated/sum_r8.c: Regenerated.
	* m4/ifunction.m4: Whitespace fix.
	* m4/product.m4: If type is integer, change to unsigned.
	* m4/sum.m4: Likewise.
2024-09-24 21:59:10 +02:00
Thomas Koenig
5d98fe096b Implement MATMUL and DOT_PRODUCT for unsigned.
gcc/fortran/ChangeLog:

	* arith.cc (gfc_arith_uminus): Fix warning.
	(gfc_arith_minus): Correctly truncate unsigneds.
	* check.cc (gfc_check_dot_product): Handle unsigned arguments.
	(gfc_check_matmul): Likewise.
	* expr.cc (gfc_get_unsigned_expr): New function.
	* gfortran.h (gfc_get_unsigned_expr): Add prototype.
	* iresolve.cc (gfc_resolve_matmul): If using UNSIGNED, use the
	signed integer version.
	* gfortran.texi: Document MATMUL and DOT_PRODUCT for unsigned.
	* simplify.cc (compute_dot_product): Handle unsigneds.

libgfortran/ChangeLog:

	* m4/iparm.m4: Add UNSIGED if type is m.
	* m4/matmul.m4: If type is GFC_INTEGER, use GFC_UINTEGER instead.
	Whitespace fixes.
	* m4/matmul_internal.m4: Whitespace fixes.

	* generated/matmul_c10.c: Regenerated.
	* generated/matmul_c16.c: Regenerated.
	* generated/matmul_c17.c: Regenerated.
	* generated/matmul_c4.c: Regenerated.
	* generated/matmul_c8.c: Regeneraated.
	* generated/matmul_i1.c: Regenerated.
	* generated/matmul_i16.c: Regenerated.
	* generated/matmul_i2.c: Regenerated.
	* generated/matmul_i4.c: Regenerated.
	* generated/matmul_i8.c: Regenerated.
	* generated/matmul_r10.c: Regenerated.
	* generated/matmul_r16.c: Regenerated.
	* generated/matmul_r17.c: Regenerated.
	* generated/matmul_r4.c: Regenerated.
	* generated/matmul_r8.c: Regenerated.
	* libgfortran.h: Add array types for unsiged.

gcc/testsuite/ChangeLog:

	* gfortran.dg/unsigned_25.f90: New test.
	* gfortran.dg/unsigned_26.f90: New test.
2024-09-24 21:51:42 +02:00
GCC Administrator
bfb9105ffb Daily bump. 2024-09-08 00:17:46 +00:00
Thomas Koenig
113a6da9bf Implement first part of unsigned integers for Fortran.
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.
2024-09-07 17:12:17 +02:00
GCC Administrator
964c9c247c Daily bump. 2024-08-21 00:19:34 +00:00
Andre Vehreschild
35f5601280 Fortran: Fix [Coarray] ICE in conv_caf_send, at fortran/trans-intrinsic.c:1950 [PR84246]
Fix ICE caused by converted expression already being pointer by checking
for its type.  Lift rewrite to caf_send completely into resolve and
prevent more temporary arrays.

	PR fortran/84246

gcc/fortran/ChangeLog:

	* resolve.cc (caf_possible_reallocate): Detect arrays that may
	be reallocated by caf_send.
	(resolve_ordinary_assign): More reliably detect assignments
	where a rewrite to caf_send is needed.
	* trans-expr.cc (gfc_trans_assignment_1): Remove rewrite to
	caf_send, because this is done by resolve now.
	* trans-intrinsic.cc (conv_caf_send): Prevent unneeded temporary
	arrays.

libgfortran/ChangeLog:

	* caf/single.c (send_by_ref): Created array's lbound is now 1
	and the offset set correctly.

gcc/testsuite/ChangeLog:

	* gfortran.dg/coarray_allocate_7.f08: Adapt to array being
	allocate by caf_send.
2024-08-20 09:32:09 +02:00
GCC Administrator
f11bc08844 Daily bump. 2024-08-19 00:18:24 +00:00