aboutsummaryrefslogtreecommitdiff
path: root/libgcc/config/nvptx
AgeCommit message (Collapse)AuthorFilesLines
2024-06-06nvptx, libgcc: Stub unwinding implementationThomas Schwinge2-1/+39
Adding stub '_Unwind_Backtrace', '_Unwind_GetIPInfo' functions is necessary for linking libbacktrace, as a normal (non-'LIBGFOR_MINIMAL') configuration of libgfortran wants to do, for example. The file 'libgcc/config/nvptx/unwind-nvptx.c' is copied from 'libgcc/config/gcn/unwind-gcn.c'. libgcc/ChangeLog: * config/nvptx/t-nvptx: Add unwind-nvptx.c. * config/nvptx/unwind-nvptx.c: New file. Co-authored-by: Andrew Stubbs <ams@gcc.gnu.org>
2024-06-06nvptx offloading: Global constructor, destructor support, via nvptx-tools 'ld'Thomas Schwinge1-0/+55
This extends commit d9c90c82d900fdae95df4499bf5f0a4ecb903b53 "nvptx target: Global constructor, destructor support, via nvptx-tools 'ld'" for offloading. libgcc/ * config/nvptx/gbl-ctors.c ["mgomp"] (__do_global_ctors__entry__mgomp) (__do_global_dtors__entry__mgomp): New. [!"mgomp"] (__do_global_ctors__entry, __do_global_dtors__entry): New. libgomp/ * plugin/plugin-nvptx.c (nvptx_do_global_cdtors): New. (nvptx_close_device, GOMP_OFFLOAD_load_image) (GOMP_OFFLOAD_unload_image): Call it.
2024-05-31nvptx target: Global constructor, destructor support, via nvptx-tools 'ld'Thomas Schwinge3-1/+94
The function attributes 'constructor', 'destructor', and 'init_priority' now work, as do the C++ features making use of this. Test cases with effective target 'global_constructor' and 'init_priority' now generally work, and 'check-gcc-c++' test results greatly improve; no more "sorry, unimplemented: global constructors not supported on this target". For proper execution test results, this depends on <https://github.com/SourceryTools/nvptx-tools/commit/96f8fc59a757767b9e98157d95c21e9fef22a93b> "ld: Global constructor/destructor support". gcc/ * config/nvptx/nvptx.h: Configure global constructor, destructor support. gcc/testsuite/ * gcc.dg/no_profile_instrument_function-attr-1.c: GCC/nvptx is 'NO_DOT_IN_LABEL' but not 'NO_DOLLAR_IN_LABEL', so '$' may apper in identifiers. * lib/target-supports.exp (check_effective_target_global_constructor): Enable for nvptx. libgcc/ * config/nvptx/crt0.c (__gbl_ctors): New weak function. (__main): Invoke it. * config/nvptx/gbl-ctors.c: New. * config/nvptx/t-nvptx: Configure global constructor, destructor support.
2024-01-03Update copyright years.Jakub Jelinek5-5/+5
2023-12-23GCN, nvptx: Basic '__cxa_guard_{acquire,abort,release}' for C++ static local ↵Thomas Schwinge1-0/+3
variables support For now, for single-threaded GCN, nvptx target use only; extension for multi-threaded offloading use is to follow later. Eventually switch to libstdc++-v3/libsupc++ proper. libgcc/ * c++-minimal/README: New. * c++-minimal/guard.c: New. * config/gcn/t-amdgcn (LIB2ADD): Add it. * config/nvptx/t-nvptx (LIB2ADD): Likewise.
2023-01-16Update copyright years.Jakub Jelinek5-5/+5
2022-01-03Update copyright years.Jakub Jelinek5-5/+5
2021-01-04Update copyright years.Jakub Jelinek5-5/+5
2020-09-09[nvptx, libgcc] Fix Wbuiltin-declaration-mismatch in atomic.cTom de Vries1-4/+8
When building for target nvptx, we get this and similar warnings for libgcc: ... src/libgcc/config/nvptx/atomic.c:39:1: warning: conflicting types for \ built-in function ‘__sync_val_compare_and_swap_1’; expected \ ‘unsigned char(volatile void *, unsigned char, unsigned char)’ \ [-Wbuiltin-declaration-mismatch] ... Fix this by making sure in atomic.c that the pointers used are of type 'volatile void *'. Tested by rebuilding atomic.c. libgcc/ChangeLog: * config/nvptx/atomic.c (__SYNC_SUBWORD_COMPARE_AND_SWAP): Fix Wbuiltin-declaration-mismatch.
2020-08-13nvptx: Add support for subword compare-and-swapKwok Cheung Yeung2-1/+75
This adds support for __sync_val_compare_and_swap and __sync_bool_compare_and_swap for 1-byte and 2-byte long values, which are not natively supported on nvptx. Build and reg-tested on nvptx. Build and reg-tested libgomp on x86_64 with nvptx accelerator. 2020-07-16 Kwok Cheung Yeung <kcy@codesourcery.com> libgcc/ * config/nvptx/atomic.c: New. * config/nvptx/t-nvptx (LIB2ADD): Add atomic.c. gcc/testsuite/ * gcc.target/nvptx/ia64-sync-5.c: New. libgomp/ * testsuite/libgomp.c-c++-common/reduction-16.c: New.
2020-01-01Update copyright years.Jakub Jelinek4-4/+4
From-SVN: r279813
2019-06-18[nvptx] Fix __main missing prototype warning in crt0.cTom de Vries1-1/+3
Atm we see: ... libgcc/config/nvptx/crt0.c:36:1: warning: no previous prototype for \ ‘__main’ [-Wmissing-prototypes] ... Fix this by adding the prototype. Build and reg-tested on nvptx. Build and reg-tested on x86_64 with nvptx accelerator. 2019-06-18 Tom de Vries <tdevries@suse.de> * config/nvptx/crt0.c (__main): Declare. From-SVN: r272412
2019-01-01Update copyright years.Jakub Jelinek4-4/+4
From-SVN: r267494
2018-01-03Update copyright years.Jakub Jelinek4-4/+4
From-SVN: r256169
2017-01-01Update copyright years.Jakub Jelinek4-4/+4
From-SVN: r243994
2016-11-16nvptx backend prerequisites for OpenMP offloadingAlexander Monakov3-1/+46
gcc/ * config/nvptx/mkoffload.c (main): Check that either OpenACC or OpenMP is selected. Pass -mgomp to offload compiler in OpenMP case. * config/nvptx/nvptx-protos.h (nvptx_shuffle_kind): Move enum declaration from nvptx.c. (nvptx_gen_shuffle): Declare. (nvptx_output_set_softstack): Declare. * config/nvptx/nvptx.c (nvptx_shuffle_kind): Move to nvptx-protos.h. (need_softstack_decl): New variable. (need_unisimt_decl): New variable. (diagnose_openacc_conflict): New. Use it... (nvptx_option_override): ...here. Handle TARGET_GOMP. (nvptx_encode_section_info): Handle "shared" attribute. (write_as_kernel): Restrict to OpenACC target regions. (init_softstack_frame): New. (nvptx_init_unisimt_predicate): New. (write_omp_entry): New. Use it... (nvptx_declare_function_name): ...here to emit OpenMP target region entrypoints. Handle TARGET_SOFT_STACK. Call nvptx_init_unisimt_predicate. (nvptx_output_set_softstack): New. (nvptx_get_drap_rtx): Return %argp as the DRAP if needed. (nvptx_gen_shuffle): Export. (nvptx_output_call_insn): Handle COND_EXEC patterns. Emit instruction predicate. (nvptx_print_operand): Fix handling of instruction predicates. (nvptx_get_unisimt_master): New helper function. (nvptx_get_unisimt_predicate): Ditto. (nvptx_call_insn_is_syscall_p): Ditto. (nvptx_unisimt_handle_set): Ditto. (nvptx_reorg_uniform_simt): New. Transform code for -muniform-simt. (nvptx_reorg): Call nvptx_reorg_uniform_simt. (nvptx_handle_shared_attribute): New. Use it... (nvptx_attribute_table): ... here (new entry). (nvptx_record_offload_symbol): Handle NULL attributes. (nvptx_file_end): Handle need_softstack_decl and need_unisimt_decl. (nvptx_simt_vf): New. (TARGET_SIMT_VF): Define. * config/nvptx/nvptx.h (TARGET_CPU_CPP_BUILTINS): Define __nvptx_softstack or __nvptx_unisimt__ when -msoft-stack, or resp. -muniform-simt option is active. (STACK_SIZE_MODE): Define. (FIXED_REGISTERS): Adjust. (SOFTSTACK_SLOT_REGNUM): New. (SOFTSTACK_PREV_REGNUM): New. (REGISTER_NAMES): Adjust. (struct machine_function): New fields. * config/nvptx/nvptx.md (UNSPEC_SET_SOFTSTACK): New. (UNSPEC_VOTE_BALLOT): Ditto. (UNSPEC_LANEID): Ditto. (UNSPECV_NOUNROLL): Ditto. (atomic): New attribute. (predicable): New attribute. Generate predicated forms via define_cond_exec. (br_true): Mark as not predicable. (br_false): Ditto. (br_true_uni): Ditto. (br_false_uni): Ditto. (return): Ditto. (trap_if_true): Ditto. (trap_if_false): Ditto. (nvptx_fork): Ditto. (nvptx_forked): Ditto. (nvptx_joining): Ditto. (nvptx_join): Ditto. (nvptx_barsync): Ditto. (epilogue): Emit stack restore if TARGET_SOFT_STACK. (allocate_stack): Implement for TARGET_SOFT_STACK. Remove unused code. (allocate_stack_<mode>): Remove unused pattern. (set_softstack_insn): New pattern. (restore_stack_block): Handle for TARGET_SOFT_STACK. (nvptx_vote_ballot): New pattern. (omp_simt_lane): Ditto. (omp_simt_last_lane): Ditto. (omp_simt_ordered): Ditto. (omp_simt_vote_any): Ditto. (omp_simt_xchg_bfly): Ditto. (omp_simt_xchg_idx): Ditto. (nvptx_nounroll): Ditto. (atomic_compare_and_swap<mode>_1): Mark with atomic attribute. (atomic_exchange<mode>): Ditto. (atomic_fetch_add<mode>): Ditto. (atomic_fetch_addsf): Ditto. (atomic_fetch_<logic><mode>): Ditto. * config/nvptx/nvptx.opt: (msoft-stack): New option. (muniform-simt): Ditto. (mgomp): Ditto. * config/nvptx/t-nvptx (MULTILIB_OPTIONS): New. * doc/extend.texi (Nvidia PTX Variable Attributes): New section. * doc/invoke.texi (msoft-stack): Document. (muniform-simt): Document (mgomp): Document. * doc/tm.texi: Regenerate. * doc/tm.texi.in: (TARGET_SIMT_VF): New hook. * target.def: Define it. * target-insns.def (omp_simt_lane): New. (omp_simt_last_lane): New. (omp_simt_ordered): New. (omp_simt_vote_any): New. (omp_simt_xchg_bfly): New. (omp_simt_xchg_idx): New. libgcc/ * config/nvptx/crt0.c (__main): Setup __nvptx_stacks and __nvptx_uni. * config/nvptx/mgomp.c: New file. * config/nvptx/t-nvptx: Add mgomp.c gcc/testsuite/ * lib/target-supports.exp (check_effective_target_alloca): Use a compile test. * gcc.target/nvptx/softstack.c: New test. * gcc.target/nvptx/decl-shared.c: New test. * gcc.target/nvptx/decl-shared-init.c: New test. From-SVN: r242503
2016-05-26free.asm: Delete.Nathan Sidwell4-159/+1
* config/nvptx/free.asm: Delete. * config/nvptx/malloc.asm: Delete. * config/nvptx/realloc.c: Delete. * t-nvptx: Update. From-SVN: r236773
2016-05-25crt0.s: Delete.Nathan Sidwell3-47/+39
libgcc/ * config/nvptx/crt0.s: Delete. * config/nvptx/crt0.c: New. * t-nvptx: Update. gcc/testsuite/ * gcc.c-torture/execute/921110-1.c: Fix abort decl. add missing 2016-05-20 Nathan Sidwell <nathan@acm.org> entry From-SVN: r236702
2016-01-04Update copyright years.Jakub Jelinek5-5/+5
From-SVN: r232055
2015-11-18nvptx.c (global_lock_var): New.Nathan Sidwell2-1/+33
gcc/ * config/nvptx/nvptx.c (global_lock_var): New. (nvptx_global_lock_addr): New. (nvptx_lockless_update): Recomment and adjust for clarity. (nvptx_lockfull_update): New. (nvptx_reduction_update): New. (nvptx_goacc_reduction_fini): Call it. libgcc/ * config/nvptx/reduction.c: New. * config/nvptx/t-nvptx (LIB2ADD): Add it. libgomp/ * testsuite/libgomp.oacc-c-c++-common/reduction-cplx-flt.c: Add worker & gang cases. * testsuite/libgomp.oacc-c-c++-common/reduction-cplx-dbl.c: Likewise. From-SVN: r230545
2015-02-23[PR target/65181] nvptx libgcc: Prevent building "advanced" stuff (for ↵Thomas Schwinge1-0/+5
example, gcov support) When building GCC against a proper newlib sysroot, the libgcc build will include more than what's built in the -Dinhibit_libc configuration used when building newlib as part of the GCC build process. See the inhibit_libc logic in gcc/configure.ac. To avoid... ptxas _gcov_indirect_call_topn_profiler.o, line 101; error : Type or alignment of argument does not match formal parameter 'ptr' ptxas _gcov_indirect_call_topn_profiler.o, line 101; error : Call has wrong number of parameters ptxas _gcov_indirect_call_topn_profiler.o, line 101; error : Type or alignment of argument does not match formal parameter 'size' ptxas fatal : Ptx assembly aborted due to errors nvptx-as: ptxas returned 255 exit status make[2]: *** [_gcov_indirect_call_topn_profiler.o] Error 1 ..., "dumb down" the libgcc build: libgcc/ PR target/65181 * config/nvptx/t-nvptx (INHIBIT_LIBC_CFLAGS): Define to -Dinhibit_libc. From-SVN: r220915
2015-02-17Avoid dependence on libc headers in nvptx realloc.Joseph Myers1-3/+2
* config/nvptx/realloc.c: Include <stddef.h> instead of <stdlib.h> and <string.h>. (__nvptx_realloc): Call __builtin_memcpy instead of memcpy. From-SVN: r220764
2015-01-05Update copyright years.Jakub Jelinek4-4/+4
From-SVN: r219188
2014-11-10Add the nvptx port.Bernd Schmidt6-0/+236
* configure.ac: Handle nvptx-*-*. * configure: Regenerate. gcc/ * config/nvptx/nvptx.c: New file. * config/nvptx/nvptx.h: New file. * config/nvptx/nvptx-protos.h: New file. * config/nvptx/nvptx.md: New file. * config/nvptx/t-nvptx: New file. * config/nvptx/nvptx.opt: New file. * common/config/nvptx/nvptx-common.c: New file. * config.gcc: Handle nvptx-*-*. libgcc/ * config.host: Handle nvptx-*-*. * shared-object.mk (as-flags-$o): Define. ($(base)$(objext), $(base)_s$(objext)): Use it instead of -xassembler-with-cpp. * static-object.mk: Identical changes. * config/nvptx/t-nvptx: New file. * config/nvptx/crt0.s: New file. * config/nvptx/free.asm: New file. * config/nvptx/malloc.asm: New file. * config/nvptx/realloc.c: New file. From-SVN: r217295