offloadstuff.c 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384
  1. /* Specialized bits of code needed for the offloading tables.
  2. Copyright (C) 2014-2022 Free Software Foundation, Inc.
  3. This file is part of GCC.
  4. GCC is free software; you can redistribute it and/or modify it under
  5. the terms of the GNU General Public License as published by the Free
  6. Software Foundation; either version 3, or (at your option) any later
  7. version.
  8. GCC is distributed in the hope that it will be useful, but WITHOUT ANY
  9. WARRANTY; without even the implied warranty of MERCHANTABILITY or
  10. FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
  11. for more details.
  12. Under Section 7 of GPL version 3, you are granted additional
  13. permissions described in the GCC Runtime Library Exception, version
  14. 3.1, as published by the Free Software Foundation.
  15. You should have received a copy of the GNU General Public License and
  16. a copy of the GCC Runtime Library Exception along with this program;
  17. see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
  18. <http://www.gnu.org/licenses/>. */
  19. /* Target machine header files require this define. */
  20. #define IN_LIBGCC2
  21. /* FIXME: Including auto-host is incorrect, but until we have
  22. identified the set of defines that need to go into auto-target.h,
  23. this will have to do. */
  24. #include "auto-host.h"
  25. #undef caddr_t
  26. #undef pid_t
  27. #undef rlim_t
  28. #undef ssize_t
  29. #undef vfork
  30. #include "tconfig.h"
  31. #include "tsystem.h"
  32. #include "coretypes.h"
  33. #include "tm.h"
  34. #include "libgcc_tm.h"
  35. #if defined(HAVE_GAS_HIDDEN) && ENABLE_OFFLOADING == 1
  36. #define OFFLOAD_FUNC_TABLE_SECTION_NAME ".gnu.offload_funcs"
  37. #define OFFLOAD_VAR_TABLE_SECTION_NAME ".gnu.offload_vars"
  38. #ifdef CRT_BEGIN
  39. const void *const __offload_func_table[0]
  40. __attribute__ ((__used__, visibility ("hidden"),
  41. section (OFFLOAD_FUNC_TABLE_SECTION_NAME))) = { };
  42. const void *const __offload_var_table[0]
  43. __attribute__ ((__used__, visibility ("hidden"),
  44. section (OFFLOAD_VAR_TABLE_SECTION_NAME))) = { };
  45. #elif defined CRT_END
  46. const void *const __offload_funcs_end[0]
  47. __attribute__ ((__used__, visibility ("hidden"),
  48. section (OFFLOAD_FUNC_TABLE_SECTION_NAME))) = { };
  49. const void *const __offload_vars_end[0]
  50. __attribute__ ((__used__, visibility ("hidden"),
  51. section (OFFLOAD_VAR_TABLE_SECTION_NAME))) = { };
  52. #elif defined CRT_TABLE
  53. extern const void *const __offload_func_table[];
  54. extern const void *const __offload_var_table[];
  55. extern const void *const __offload_funcs_end[];
  56. extern const void *const __offload_vars_end[];
  57. const void *const __OFFLOAD_TABLE__[]
  58. __attribute__ ((__visibility__ ("hidden"))) =
  59. {
  60. &__offload_func_table, &__offload_funcs_end,
  61. &__offload_var_table, &__offload_vars_end
  62. };
  63. #else /* ! CRT_BEGIN && ! CRT_END && ! CRT_TABLE */
  64. #error "One of CRT_BEGIN, CRT_END or CRT_TABLE must be defined."
  65. #endif
  66. #endif