xref: /netbsd-src/external/gpl3/gcc/dist/libgcc/offloadstuff.c (revision b1e838363e3c6fc78a55519254d99869742dd33c)
14d5abbe8Smrg /* Specialized bits of code needed for the offloading tables.
2*b1e83836Smrg    Copyright (C) 2014-2022 Free Software Foundation, Inc.
34d5abbe8Smrg 
44d5abbe8Smrg This file is part of GCC.
54d5abbe8Smrg 
64d5abbe8Smrg GCC is free software; you can redistribute it and/or modify it under
74d5abbe8Smrg the terms of the GNU General Public License as published by the Free
84d5abbe8Smrg Software Foundation; either version 3, or (at your option) any later
94d5abbe8Smrg version.
104d5abbe8Smrg 
114d5abbe8Smrg GCC is distributed in the hope that it will be useful, but WITHOUT ANY
124d5abbe8Smrg WARRANTY; without even the implied warranty of MERCHANTABILITY or
134d5abbe8Smrg FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
144d5abbe8Smrg for more details.
154d5abbe8Smrg 
164d5abbe8Smrg Under Section 7 of GPL version 3, you are granted additional
174d5abbe8Smrg permissions described in the GCC Runtime Library Exception, version
184d5abbe8Smrg 3.1, as published by the Free Software Foundation.
194d5abbe8Smrg 
204d5abbe8Smrg You should have received a copy of the GNU General Public License and
214d5abbe8Smrg a copy of the GCC Runtime Library Exception along with this program;
224d5abbe8Smrg see the files COPYING3 and COPYING.RUNTIME respectively.  If not, see
234d5abbe8Smrg <http://www.gnu.org/licenses/>.  */
244d5abbe8Smrg 
254d5abbe8Smrg /* Target machine header files require this define. */
264d5abbe8Smrg #define IN_LIBGCC2
274d5abbe8Smrg 
284d5abbe8Smrg /* FIXME: Including auto-host is incorrect, but until we have
294d5abbe8Smrg    identified the set of defines that need to go into auto-target.h,
304d5abbe8Smrg    this will have to do.  */
314d5abbe8Smrg #include "auto-host.h"
324d5abbe8Smrg #undef caddr_t
334d5abbe8Smrg #undef pid_t
344d5abbe8Smrg #undef rlim_t
354d5abbe8Smrg #undef ssize_t
364d5abbe8Smrg #undef vfork
374d5abbe8Smrg #include "tconfig.h"
384d5abbe8Smrg #include "tsystem.h"
394d5abbe8Smrg #include "coretypes.h"
404d5abbe8Smrg #include "tm.h"
414d5abbe8Smrg #include "libgcc_tm.h"
424d5abbe8Smrg 
43f9a78e0eSmrg #if defined(HAVE_GAS_HIDDEN) && ENABLE_OFFLOADING == 1
44f9a78e0eSmrg 
454d5abbe8Smrg #define OFFLOAD_FUNC_TABLE_SECTION_NAME ".gnu.offload_funcs"
464d5abbe8Smrg #define OFFLOAD_VAR_TABLE_SECTION_NAME ".gnu.offload_vars"
474d5abbe8Smrg 
484d5abbe8Smrg #ifdef CRT_BEGIN
494d5abbe8Smrg 
50f9a78e0eSmrg const void *const __offload_func_table[0]
514d5abbe8Smrg   __attribute__ ((__used__, visibility ("hidden"),
524d5abbe8Smrg 		  section (OFFLOAD_FUNC_TABLE_SECTION_NAME))) = { };
53f9a78e0eSmrg const void *const __offload_var_table[0]
544d5abbe8Smrg   __attribute__ ((__used__, visibility ("hidden"),
554d5abbe8Smrg 		  section (OFFLOAD_VAR_TABLE_SECTION_NAME))) = { };
564d5abbe8Smrg 
574d5abbe8Smrg #elif defined CRT_END
584d5abbe8Smrg 
59f9a78e0eSmrg const void *const __offload_funcs_end[0]
604d5abbe8Smrg   __attribute__ ((__used__, visibility ("hidden"),
614d5abbe8Smrg 		  section (OFFLOAD_FUNC_TABLE_SECTION_NAME))) = { };
62f9a78e0eSmrg const void *const __offload_vars_end[0]
634d5abbe8Smrg   __attribute__ ((__used__, visibility ("hidden"),
644d5abbe8Smrg 		  section (OFFLOAD_VAR_TABLE_SECTION_NAME))) = { };
654d5abbe8Smrg 
66f9a78e0eSmrg #elif defined CRT_TABLE
674d5abbe8Smrg 
68f9a78e0eSmrg extern const void *const __offload_func_table[];
69f9a78e0eSmrg extern const void *const __offload_var_table[];
70f9a78e0eSmrg extern const void *const __offload_funcs_end[];
71f9a78e0eSmrg extern const void *const __offload_vars_end[];
72f9a78e0eSmrg 
73f9a78e0eSmrg const void *const __OFFLOAD_TABLE__[]
744d5abbe8Smrg   __attribute__ ((__visibility__ ("hidden"))) =
754d5abbe8Smrg {
764d5abbe8Smrg   &__offload_func_table, &__offload_funcs_end,
774d5abbe8Smrg   &__offload_var_table, &__offload_vars_end
784d5abbe8Smrg };
79f9a78e0eSmrg 
80f9a78e0eSmrg #else /* ! CRT_BEGIN && ! CRT_END && ! CRT_TABLE  */
81f9a78e0eSmrg #error "One of CRT_BEGIN, CRT_END or CRT_TABLE must be defined."
824d5abbe8Smrg #endif
834d5abbe8Smrg 
844d5abbe8Smrg #endif
85