c-pragma.h 7.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236
  1. /* Pragma related interfaces.
  2. Copyright (C) 1995-2015 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. typedef enum pragma_kind {
  21. PRAGMA_NONE = 0,
  22. PRAGMA_OACC_CACHE,
  23. PRAGMA_OACC_DATA,
  24. PRAGMA_OACC_ENTER_DATA,
  25. PRAGMA_OACC_EXIT_DATA,
  26. PRAGMA_OACC_KERNELS,
  27. PRAGMA_OACC_LOOP,
  28. PRAGMA_OACC_PARALLEL,
  29. PRAGMA_OACC_UPDATE,
  30. PRAGMA_OACC_WAIT,
  31. PRAGMA_OMP_ATOMIC,
  32. PRAGMA_OMP_BARRIER,
  33. PRAGMA_OMP_CANCEL,
  34. PRAGMA_OMP_CANCELLATION_POINT,
  35. PRAGMA_OMP_CRITICAL,
  36. PRAGMA_OMP_DECLARE_REDUCTION,
  37. PRAGMA_OMP_DISTRIBUTE,
  38. PRAGMA_OMP_END_DECLARE_TARGET,
  39. PRAGMA_OMP_FLUSH,
  40. PRAGMA_OMP_FOR,
  41. PRAGMA_OMP_MASTER,
  42. PRAGMA_OMP_ORDERED,
  43. PRAGMA_OMP_PARALLEL,
  44. PRAGMA_OMP_SECTION,
  45. PRAGMA_OMP_SECTIONS,
  46. PRAGMA_OMP_SIMD,
  47. PRAGMA_OMP_SINGLE,
  48. PRAGMA_OMP_TARGET,
  49. PRAGMA_OMP_TASK,
  50. PRAGMA_OMP_TASKGROUP,
  51. PRAGMA_OMP_TASKWAIT,
  52. PRAGMA_OMP_TASKYIELD,
  53. PRAGMA_OMP_THREADPRIVATE,
  54. PRAGMA_OMP_TEAMS,
  55. /* Top level clause to handle all Cilk Plus pragma simd clauses. */
  56. PRAGMA_CILK_SIMD,
  57. /* This pragma handles setting of grainsize for a _Cilk_for. */
  58. PRAGMA_CILK_GRAINSIZE,
  59. PRAGMA_GCC_PCH_PREPROCESS,
  60. PRAGMA_IVDEP,
  61. PRAGMA_FIRST_EXTERNAL
  62. } pragma_kind;
  63. /* All clauses defined by OpenACC 2.0, and OpenMP 2.5, 3.0, 3.1, and 4.0.
  64. Used internally by both C and C++ parsers. */
  65. typedef enum pragma_omp_clause {
  66. PRAGMA_OMP_CLAUSE_NONE = 0,
  67. PRAGMA_OMP_CLAUSE_ALIGNED,
  68. PRAGMA_OMP_CLAUSE_COLLAPSE,
  69. PRAGMA_OMP_CLAUSE_COPYIN,
  70. PRAGMA_OMP_CLAUSE_COPYPRIVATE,
  71. PRAGMA_OMP_CLAUSE_DEFAULT,
  72. PRAGMA_OMP_CLAUSE_DEPEND,
  73. PRAGMA_OMP_CLAUSE_DEVICE,
  74. PRAGMA_OMP_CLAUSE_DIST_SCHEDULE,
  75. PRAGMA_OMP_CLAUSE_FINAL,
  76. PRAGMA_OMP_CLAUSE_FIRSTPRIVATE,
  77. PRAGMA_OMP_CLAUSE_FOR,
  78. PRAGMA_OMP_CLAUSE_FROM,
  79. PRAGMA_OMP_CLAUSE_IF,
  80. PRAGMA_OMP_CLAUSE_INBRANCH,
  81. PRAGMA_OMP_CLAUSE_LASTPRIVATE,
  82. PRAGMA_OMP_CLAUSE_LINEAR,
  83. PRAGMA_OMP_CLAUSE_MAP,
  84. PRAGMA_OMP_CLAUSE_MERGEABLE,
  85. PRAGMA_OMP_CLAUSE_NOTINBRANCH,
  86. PRAGMA_OMP_CLAUSE_NOWAIT,
  87. PRAGMA_OMP_CLAUSE_NUM_TEAMS,
  88. PRAGMA_OMP_CLAUSE_NUM_THREADS,
  89. PRAGMA_OMP_CLAUSE_ORDERED,
  90. PRAGMA_OMP_CLAUSE_PARALLEL,
  91. PRAGMA_OMP_CLAUSE_PRIVATE,
  92. PRAGMA_OMP_CLAUSE_PROC_BIND,
  93. PRAGMA_OMP_CLAUSE_REDUCTION,
  94. PRAGMA_OMP_CLAUSE_SAFELEN,
  95. PRAGMA_OMP_CLAUSE_SCHEDULE,
  96. PRAGMA_OMP_CLAUSE_SECTIONS,
  97. PRAGMA_OMP_CLAUSE_SHARED,
  98. PRAGMA_OMP_CLAUSE_SIMDLEN,
  99. PRAGMA_OMP_CLAUSE_TASKGROUP,
  100. PRAGMA_OMP_CLAUSE_THREAD_LIMIT,
  101. PRAGMA_OMP_CLAUSE_TO,
  102. PRAGMA_OMP_CLAUSE_UNIFORM,
  103. PRAGMA_OMP_CLAUSE_UNTIED,
  104. /* Clauses for Cilk Plus SIMD-enabled function. */
  105. PRAGMA_CILK_CLAUSE_NOMASK,
  106. PRAGMA_CILK_CLAUSE_MASK,
  107. PRAGMA_CILK_CLAUSE_VECTORLENGTH,
  108. PRAGMA_CILK_CLAUSE_NONE = PRAGMA_OMP_CLAUSE_NONE,
  109. PRAGMA_CILK_CLAUSE_LINEAR = PRAGMA_OMP_CLAUSE_LINEAR,
  110. PRAGMA_CILK_CLAUSE_PRIVATE = PRAGMA_OMP_CLAUSE_PRIVATE,
  111. PRAGMA_CILK_CLAUSE_FIRSTPRIVATE = PRAGMA_OMP_CLAUSE_FIRSTPRIVATE,
  112. PRAGMA_CILK_CLAUSE_LASTPRIVATE = PRAGMA_OMP_CLAUSE_LASTPRIVATE,
  113. PRAGMA_CILK_CLAUSE_REDUCTION = PRAGMA_OMP_CLAUSE_REDUCTION,
  114. PRAGMA_CILK_CLAUSE_UNIFORM = PRAGMA_OMP_CLAUSE_UNIFORM,
  115. /* Clauses for OpenACC. */
  116. PRAGMA_OACC_CLAUSE_ASYNC = PRAGMA_CILK_CLAUSE_VECTORLENGTH + 1,
  117. PRAGMA_OACC_CLAUSE_AUTO,
  118. PRAGMA_OACC_CLAUSE_COPY,
  119. PRAGMA_OACC_CLAUSE_COPYOUT,
  120. PRAGMA_OACC_CLAUSE_CREATE,
  121. PRAGMA_OACC_CLAUSE_DELETE,
  122. PRAGMA_OACC_CLAUSE_DEVICEPTR,
  123. PRAGMA_OACC_CLAUSE_GANG,
  124. PRAGMA_OACC_CLAUSE_HOST,
  125. PRAGMA_OACC_CLAUSE_NUM_GANGS,
  126. PRAGMA_OACC_CLAUSE_NUM_WORKERS,
  127. PRAGMA_OACC_CLAUSE_PRESENT,
  128. PRAGMA_OACC_CLAUSE_PRESENT_OR_COPY,
  129. PRAGMA_OACC_CLAUSE_PRESENT_OR_COPYIN,
  130. PRAGMA_OACC_CLAUSE_PRESENT_OR_COPYOUT,
  131. PRAGMA_OACC_CLAUSE_PRESENT_OR_CREATE,
  132. PRAGMA_OACC_CLAUSE_SELF,
  133. PRAGMA_OACC_CLAUSE_SEQ,
  134. PRAGMA_OACC_CLAUSE_VECTOR,
  135. PRAGMA_OACC_CLAUSE_VECTOR_LENGTH,
  136. PRAGMA_OACC_CLAUSE_WAIT,
  137. PRAGMA_OACC_CLAUSE_WORKER,
  138. PRAGMA_OACC_CLAUSE_COLLAPSE = PRAGMA_OMP_CLAUSE_COLLAPSE,
  139. PRAGMA_OACC_CLAUSE_COPYIN = PRAGMA_OMP_CLAUSE_COPYIN,
  140. PRAGMA_OACC_CLAUSE_DEVICE = PRAGMA_OMP_CLAUSE_DEVICE,
  141. PRAGMA_OACC_CLAUSE_FIRSTPRIVATE = PRAGMA_OMP_CLAUSE_FIRSTPRIVATE,
  142. PRAGMA_OACC_CLAUSE_IF = PRAGMA_OMP_CLAUSE_IF,
  143. PRAGMA_OACC_CLAUSE_PRIVATE = PRAGMA_OMP_CLAUSE_PRIVATE,
  144. PRAGMA_OACC_CLAUSE_REDUCTION = PRAGMA_OMP_CLAUSE_REDUCTION
  145. } pragma_omp_clause;
  146. extern struct cpp_reader* parse_in;
  147. /* It's safe to always leave visibility pragma enabled as if
  148. visibility is not supported on the host OS platform the
  149. statements are ignored. */
  150. extern void push_visibility (const char *, int);
  151. extern bool pop_visibility (int);
  152. extern void init_pragma (void);
  153. /* Front-end wrappers for pragma registration. */
  154. typedef void (*pragma_handler_1arg)(struct cpp_reader *);
  155. /* A second pragma handler, which adds a void * argument allowing to pass extra
  156. data to the handler. */
  157. typedef void (*pragma_handler_2arg)(struct cpp_reader *, void *);
  158. /* This union allows to abstract the different handlers. */
  159. union gen_pragma_handler {
  160. pragma_handler_1arg handler_1arg;
  161. pragma_handler_2arg handler_2arg;
  162. };
  163. /* Internally used to keep the data of the handler. */
  164. struct internal_pragma_handler_d {
  165. union gen_pragma_handler handler;
  166. /* Permits to know if handler is a pragma_handler_1arg (extra_data is false)
  167. or a pragma_handler_2arg (extra_data is true). */
  168. bool extra_data;
  169. /* A data field which can be used when extra_data is true. */
  170. void * data;
  171. };
  172. typedef struct internal_pragma_handler_d internal_pragma_handler;
  173. extern void c_register_pragma (const char *space, const char *name,
  174. pragma_handler_1arg handler);
  175. extern void c_register_pragma_with_data (const char *space, const char *name,
  176. pragma_handler_2arg handler,
  177. void *data);
  178. extern void c_register_pragma_with_expansion (const char *space,
  179. const char *name,
  180. pragma_handler_1arg handler);
  181. extern void c_register_pragma_with_expansion_and_data (const char *space,
  182. const char *name,
  183. pragma_handler_2arg handler,
  184. void *data);
  185. extern void c_invoke_pragma_handler (unsigned int);
  186. extern void maybe_apply_pragma_weak (tree);
  187. extern void maybe_apply_pending_pragma_weaks (void);
  188. extern tree maybe_apply_renaming_pragma (tree, tree);
  189. extern void add_to_renaming_pragma_list (tree, tree);
  190. extern enum cpp_ttype pragma_lex (tree *);
  191. /* Flags for use with c_lex_with_flags. The values here were picked
  192. so that 0 means to translate and join strings. */
  193. #define C_LEX_STRING_NO_TRANSLATE 1 /* Do not lex strings into
  194. execution character set. */
  195. #define C_LEX_STRING_NO_JOIN 2 /* Do not concatenate strings
  196. nor translate them into execution
  197. character set. */
  198. /* This is not actually available to pragma parsers. It's merely a
  199. convenient location to declare this function for c-lex, after
  200. having enum cpp_ttype declared. */
  201. extern enum cpp_ttype c_lex_with_flags (tree *, location_t *, unsigned char *,
  202. int);
  203. extern void c_pp_lookup_pragma (unsigned int, const char **, const char **);
  204. extern GTY(()) tree pragma_extern_prefix;
  205. #endif /* GCC_C_PRAGMA_H */