您最多选择25个主题 主题必须以字母或数字开头,可以包含连字符 (-),并且长度不得超过35个字符

256 行
8.2KB

  1. /* Pragma related interfaces.
  2. Copyright (C) 1995-2020 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. You should have received a copy of the GNU General Public License
  13. along with GCC; see the file COPYING3. If not see
  14. <http://www.gnu.org/licenses/>. */
  15. #ifndef GCC_C_PRAGMA_H
  16. #define GCC_C_PRAGMA_H
  17. #include "cpplib.h" /* For enum cpp_ttype. */
  18. /* Pragma identifiers built in to the front end parsers. Identifiers
  19. for ancillary handlers will follow these. */
  20. enum pragma_kind {
  21. PRAGMA_NONE = 0,
  22. PRAGMA_OACC_ATOMIC,
  23. PRAGMA_OACC_CACHE,
  24. PRAGMA_OACC_DATA,
  25. PRAGMA_OACC_DECLARE,
  26. PRAGMA_OACC_ENTER_DATA,
  27. PRAGMA_OACC_EXIT_DATA,
  28. PRAGMA_OACC_HOST_DATA,
  29. PRAGMA_OACC_KERNELS,
  30. PRAGMA_OACC_LOOP,
  31. PRAGMA_OACC_PARALLEL,
  32. PRAGMA_OACC_ROUTINE,
  33. PRAGMA_OACC_SERIAL,
  34. PRAGMA_OACC_UPDATE,
  35. PRAGMA_OACC_WAIT,
  36. PRAGMA_OMP_ATOMIC,
  37. PRAGMA_OMP_BARRIER,
  38. PRAGMA_OMP_CANCEL,
  39. PRAGMA_OMP_CANCELLATION_POINT,
  40. PRAGMA_OMP_CRITICAL,
  41. PRAGMA_OMP_DECLARE,
  42. PRAGMA_OMP_DEPOBJ,
  43. PRAGMA_OMP_DISTRIBUTE,
  44. PRAGMA_OMP_END_DECLARE_TARGET,
  45. PRAGMA_OMP_FLUSH,
  46. PRAGMA_OMP_FOR,
  47. PRAGMA_OMP_LOOP,
  48. PRAGMA_OMP_MASTER,
  49. PRAGMA_OMP_ORDERED,
  50. PRAGMA_OMP_PARALLEL,
  51. PRAGMA_OMP_REQUIRES,
  52. PRAGMA_OMP_SCAN,
  53. PRAGMA_OMP_SECTION,
  54. PRAGMA_OMP_SECTIONS,
  55. PRAGMA_OMP_SIMD,
  56. PRAGMA_OMP_SINGLE,
  57. PRAGMA_OMP_TARGET,
  58. PRAGMA_OMP_TASK,
  59. PRAGMA_OMP_TASKGROUP,
  60. PRAGMA_OMP_TASKLOOP,
  61. PRAGMA_OMP_TASKWAIT,
  62. PRAGMA_OMP_TASKYIELD,
  63. PRAGMA_OMP_THREADPRIVATE,
  64. PRAGMA_OMP_TEAMS,
  65. PRAGMA_GCC_PCH_PREPROCESS,
  66. PRAGMA_IVDEP,
  67. PRAGMA_UNROLL,
  68. PRAGMA_FIRST_EXTERNAL
  69. };
  70. /* All clauses defined by OpenACC 2.0, and OpenMP 2.5, 3.0, 3.1, 4.0, 4.5
  71. and 5.0. Used internally by both C and C++ parsers. */
  72. enum pragma_omp_clause {
  73. PRAGMA_OMP_CLAUSE_NONE = 0,
  74. PRAGMA_OMP_CLAUSE_ALIGNED,
  75. PRAGMA_OMP_CLAUSE_BIND,
  76. PRAGMA_OMP_CLAUSE_COLLAPSE,
  77. PRAGMA_OMP_CLAUSE_COPYIN,
  78. PRAGMA_OMP_CLAUSE_COPYPRIVATE,
  79. PRAGMA_OMP_CLAUSE_DEFAULT,
  80. PRAGMA_OMP_CLAUSE_DEFAULTMAP,
  81. PRAGMA_OMP_CLAUSE_DEPEND,
  82. PRAGMA_OMP_CLAUSE_DEVICE,
  83. PRAGMA_OMP_CLAUSE_DEVICE_TYPE,
  84. PRAGMA_OMP_CLAUSE_DIST_SCHEDULE,
  85. PRAGMA_OMP_CLAUSE_FINAL,
  86. PRAGMA_OMP_CLAUSE_FIRSTPRIVATE,
  87. PRAGMA_OMP_CLAUSE_FOR,
  88. PRAGMA_OMP_CLAUSE_FROM,
  89. PRAGMA_OMP_CLAUSE_GRAINSIZE,
  90. PRAGMA_OMP_CLAUSE_HINT,
  91. PRAGMA_OMP_CLAUSE_IF,
  92. PRAGMA_OMP_CLAUSE_IN_REDUCTION,
  93. PRAGMA_OMP_CLAUSE_INBRANCH,
  94. PRAGMA_OMP_CLAUSE_IS_DEVICE_PTR,
  95. PRAGMA_OMP_CLAUSE_LASTPRIVATE,
  96. PRAGMA_OMP_CLAUSE_LINEAR,
  97. PRAGMA_OMP_CLAUSE_LINK,
  98. PRAGMA_OMP_CLAUSE_MAP,
  99. PRAGMA_OMP_CLAUSE_MERGEABLE,
  100. PRAGMA_OMP_CLAUSE_NOGROUP,
  101. PRAGMA_OMP_CLAUSE_NONTEMPORAL,
  102. PRAGMA_OMP_CLAUSE_NOTINBRANCH,
  103. PRAGMA_OMP_CLAUSE_NOWAIT,
  104. PRAGMA_OMP_CLAUSE_NUM_TASKS,
  105. PRAGMA_OMP_CLAUSE_NUM_TEAMS,
  106. PRAGMA_OMP_CLAUSE_NUM_THREADS,
  107. PRAGMA_OMP_CLAUSE_ORDER,
  108. PRAGMA_OMP_CLAUSE_ORDERED,
  109. PRAGMA_OMP_CLAUSE_PARALLEL,
  110. PRAGMA_OMP_CLAUSE_PRIORITY,
  111. PRAGMA_OMP_CLAUSE_PRIVATE,
  112. PRAGMA_OMP_CLAUSE_PROC_BIND,
  113. PRAGMA_OMP_CLAUSE_REDUCTION,
  114. PRAGMA_OMP_CLAUSE_SAFELEN,
  115. PRAGMA_OMP_CLAUSE_SCHEDULE,
  116. PRAGMA_OMP_CLAUSE_SECTIONS,
  117. PRAGMA_OMP_CLAUSE_SHARED,
  118. PRAGMA_OMP_CLAUSE_SIMD,
  119. PRAGMA_OMP_CLAUSE_SIMDLEN,
  120. PRAGMA_OMP_CLAUSE_TASK_REDUCTION,
  121. PRAGMA_OMP_CLAUSE_TASKGROUP,
  122. PRAGMA_OMP_CLAUSE_THREAD_LIMIT,
  123. PRAGMA_OMP_CLAUSE_THREADS,
  124. PRAGMA_OMP_CLAUSE_TO,
  125. PRAGMA_OMP_CLAUSE_UNIFORM,
  126. PRAGMA_OMP_CLAUSE_UNTIED,
  127. PRAGMA_OMP_CLAUSE_USE_DEVICE_PTR,
  128. PRAGMA_OMP_CLAUSE_USE_DEVICE_ADDR,
  129. /* Clauses for OpenACC. */
  130. PRAGMA_OACC_CLAUSE_ASYNC,
  131. PRAGMA_OACC_CLAUSE_ATTACH,
  132. PRAGMA_OACC_CLAUSE_AUTO,
  133. PRAGMA_OACC_CLAUSE_COPY,
  134. PRAGMA_OACC_CLAUSE_COPYOUT,
  135. PRAGMA_OACC_CLAUSE_CREATE,
  136. PRAGMA_OACC_CLAUSE_DELETE,
  137. PRAGMA_OACC_CLAUSE_DETACH,
  138. PRAGMA_OACC_CLAUSE_DEVICEPTR,
  139. PRAGMA_OACC_CLAUSE_DEVICE_RESIDENT,
  140. PRAGMA_OACC_CLAUSE_FINALIZE,
  141. PRAGMA_OACC_CLAUSE_GANG,
  142. PRAGMA_OACC_CLAUSE_HOST,
  143. PRAGMA_OACC_CLAUSE_INDEPENDENT,
  144. PRAGMA_OACC_CLAUSE_NO_CREATE,
  145. PRAGMA_OACC_CLAUSE_NUM_GANGS,
  146. PRAGMA_OACC_CLAUSE_NUM_WORKERS,
  147. PRAGMA_OACC_CLAUSE_PRESENT,
  148. PRAGMA_OACC_CLAUSE_SELF,
  149. PRAGMA_OACC_CLAUSE_SEQ,
  150. PRAGMA_OACC_CLAUSE_TILE,
  151. PRAGMA_OACC_CLAUSE_VECTOR,
  152. PRAGMA_OACC_CLAUSE_VECTOR_LENGTH,
  153. PRAGMA_OACC_CLAUSE_WAIT,
  154. PRAGMA_OACC_CLAUSE_WORKER,
  155. PRAGMA_OACC_CLAUSE_IF_PRESENT,
  156. PRAGMA_OACC_CLAUSE_COLLAPSE = PRAGMA_OMP_CLAUSE_COLLAPSE,
  157. PRAGMA_OACC_CLAUSE_COPYIN = PRAGMA_OMP_CLAUSE_COPYIN,
  158. PRAGMA_OACC_CLAUSE_DEVICE = PRAGMA_OMP_CLAUSE_DEVICE,
  159. PRAGMA_OACC_CLAUSE_DEFAULT = PRAGMA_OMP_CLAUSE_DEFAULT,
  160. PRAGMA_OACC_CLAUSE_FIRSTPRIVATE = PRAGMA_OMP_CLAUSE_FIRSTPRIVATE,
  161. PRAGMA_OACC_CLAUSE_IF = PRAGMA_OMP_CLAUSE_IF,
  162. PRAGMA_OACC_CLAUSE_PRIVATE = PRAGMA_OMP_CLAUSE_PRIVATE,
  163. PRAGMA_OACC_CLAUSE_REDUCTION = PRAGMA_OMP_CLAUSE_REDUCTION,
  164. PRAGMA_OACC_CLAUSE_LINK = PRAGMA_OMP_CLAUSE_LINK,
  165. PRAGMA_OACC_CLAUSE_USE_DEVICE = PRAGMA_OMP_CLAUSE_USE_DEVICE_PTR
  166. };
  167. extern struct cpp_reader* parse_in;
  168. /* It's safe to always leave visibility pragma enabled as if
  169. visibility is not supported on the host OS platform the
  170. statements are ignored. */
  171. extern void push_visibility (const char *, int);
  172. extern bool pop_visibility (int);
  173. extern void init_pragma (void);
  174. /* Front-end wrappers for pragma registration. */
  175. typedef void (*pragma_handler_1arg)(struct cpp_reader *);
  176. /* A second pragma handler, which adds a void * argument allowing to pass extra
  177. data to the handler. */
  178. typedef void (*pragma_handler_2arg)(struct cpp_reader *, void *);
  179. /* This union allows to abstract the different handlers. */
  180. union gen_pragma_handler {
  181. pragma_handler_1arg handler_1arg;
  182. pragma_handler_2arg handler_2arg;
  183. };
  184. /* Internally used to keep the data of the handler. */
  185. struct internal_pragma_handler {
  186. union gen_pragma_handler handler;
  187. /* Permits to know if handler is a pragma_handler_1arg (extra_data is false)
  188. or a pragma_handler_2arg (extra_data is true). */
  189. bool extra_data;
  190. /* A data field which can be used when extra_data is true. */
  191. void * data;
  192. };
  193. extern void c_register_pragma (const char *space, const char *name,
  194. pragma_handler_1arg handler);
  195. extern void c_register_pragma_with_data (const char *space, const char *name,
  196. pragma_handler_2arg handler,
  197. void *data);
  198. extern void c_register_pragma_with_expansion (const char *space,
  199. const char *name,
  200. pragma_handler_1arg handler);
  201. extern void c_register_pragma_with_expansion_and_data (const char *space,
  202. const char *name,
  203. pragma_handler_2arg handler,
  204. void *data);
  205. extern void c_invoke_pragma_handler (unsigned int);
  206. extern void maybe_apply_pragma_weak (tree);
  207. extern void maybe_apply_pending_pragma_weaks (void);
  208. extern tree maybe_apply_renaming_pragma (tree, tree);
  209. extern void maybe_apply_pragma_scalar_storage_order (tree);
  210. extern void add_to_renaming_pragma_list (tree, tree);
  211. extern enum cpp_ttype pragma_lex (tree *, location_t *loc = NULL);
  212. /* Flags for use with c_lex_with_flags. The values here were picked
  213. so that 0 means to translate and join strings. */
  214. #define C_LEX_STRING_NO_TRANSLATE 1 /* Do not lex strings into
  215. execution character set. */
  216. #define C_LEX_STRING_NO_JOIN 2 /* Do not concatenate strings
  217. nor translate them into execution
  218. character set. */
  219. /* This is not actually available to pragma parsers. It's merely a
  220. convenient location to declare this function for c-lex, after
  221. having enum cpp_ttype declared. */
  222. extern enum cpp_ttype c_lex_with_flags (tree *, location_t *, unsigned char *,
  223. int);
  224. extern void c_pp_lookup_pragma (unsigned int, const char **, const char **);
  225. extern GTY(()) tree pragma_extern_prefix;
  226. #endif /* GCC_C_PRAGMA_H */