2016-09-25 François Dumont <fdumont@gcc.gnu.org>
[official-gcc.git] / gcc / c-family / c-pragma.h
blob6d9cb086ea3217b2ac21ad31d61bb415e74ef638
1 /* Pragma related interfaces.
2 Copyright (C) 1995-2016 Free Software Foundation, Inc.
4 This file is part of GCC.
6 GCC is free software; you can redistribute it and/or modify it under
7 the terms of the GNU General Public License as published by the Free
8 Software Foundation; either version 3, or (at your option) any later
9 version.
11 GCC is distributed in the hope that it will be useful, but WITHOUT ANY
12 WARRANTY; without even the implied warranty of MERCHANTABILITY or
13 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
14 for more details.
16 You should have received a copy of the GNU General Public License
17 along with GCC; see the file COPYING3. If not see
18 <http://www.gnu.org/licenses/>. */
20 #ifndef GCC_C_PRAGMA_H
21 #define GCC_C_PRAGMA_H
23 #include "cpplib.h" /* For enum cpp_ttype. */
25 /* Pragma identifiers built in to the front end parsers. Identifiers
26 for ancillary handlers will follow these. */
27 enum pragma_kind {
28 PRAGMA_NONE = 0,
30 PRAGMA_OACC_ATOMIC,
31 PRAGMA_OACC_CACHE,
32 PRAGMA_OACC_DATA,
33 PRAGMA_OACC_DECLARE,
34 PRAGMA_OACC_ENTER_DATA,
35 PRAGMA_OACC_EXIT_DATA,
36 PRAGMA_OACC_HOST_DATA,
37 PRAGMA_OACC_KERNELS,
38 PRAGMA_OACC_LOOP,
39 PRAGMA_OACC_PARALLEL,
40 PRAGMA_OACC_ROUTINE,
41 PRAGMA_OACC_UPDATE,
42 PRAGMA_OACC_WAIT,
44 PRAGMA_OMP_ATOMIC,
45 PRAGMA_OMP_BARRIER,
46 PRAGMA_OMP_CANCEL,
47 PRAGMA_OMP_CANCELLATION_POINT,
48 PRAGMA_OMP_CRITICAL,
49 PRAGMA_OMP_DECLARE,
50 PRAGMA_OMP_DISTRIBUTE,
51 PRAGMA_OMP_END_DECLARE_TARGET,
52 PRAGMA_OMP_FLUSH,
53 PRAGMA_OMP_FOR,
54 PRAGMA_OMP_MASTER,
55 PRAGMA_OMP_ORDERED,
56 PRAGMA_OMP_PARALLEL,
57 PRAGMA_OMP_SECTION,
58 PRAGMA_OMP_SECTIONS,
59 PRAGMA_OMP_SIMD,
60 PRAGMA_OMP_SINGLE,
61 PRAGMA_OMP_TARGET,
62 PRAGMA_OMP_TASK,
63 PRAGMA_OMP_TASKGROUP,
64 PRAGMA_OMP_TASKLOOP,
65 PRAGMA_OMP_TASKWAIT,
66 PRAGMA_OMP_TASKYIELD,
67 PRAGMA_OMP_THREADPRIVATE,
68 PRAGMA_OMP_TEAMS,
70 /* Top level clause to handle all Cilk Plus pragma simd clauses. */
71 PRAGMA_CILK_SIMD,
73 /* This pragma handles setting of grainsize for a _Cilk_for. */
74 PRAGMA_CILK_GRAINSIZE,
76 PRAGMA_GCC_PCH_PREPROCESS,
77 PRAGMA_IVDEP,
79 PRAGMA_FIRST_EXTERNAL
83 /* All clauses defined by OpenACC 2.0, and OpenMP 2.5, 3.0, 3.1, 4.0 and 4.5.
84 Used internally by both C and C++ parsers. */
85 enum pragma_omp_clause {
86 PRAGMA_OMP_CLAUSE_NONE = 0,
88 PRAGMA_OMP_CLAUSE_ALIGNED,
89 PRAGMA_OMP_CLAUSE_COLLAPSE,
90 PRAGMA_OMP_CLAUSE_COPYIN,
91 PRAGMA_OMP_CLAUSE_COPYPRIVATE,
92 PRAGMA_OMP_CLAUSE_DEFAULT,
93 PRAGMA_OMP_CLAUSE_DEFAULTMAP,
94 PRAGMA_OMP_CLAUSE_DEPEND,
95 PRAGMA_OMP_CLAUSE_DEVICE,
96 PRAGMA_OMP_CLAUSE_DIST_SCHEDULE,
97 PRAGMA_OMP_CLAUSE_FINAL,
98 PRAGMA_OMP_CLAUSE_FIRSTPRIVATE,
99 PRAGMA_OMP_CLAUSE_FOR,
100 PRAGMA_OMP_CLAUSE_FROM,
101 PRAGMA_OMP_CLAUSE_GRAINSIZE,
102 PRAGMA_OMP_CLAUSE_HINT,
103 PRAGMA_OMP_CLAUSE_IF,
104 PRAGMA_OMP_CLAUSE_INBRANCH,
105 PRAGMA_OMP_CLAUSE_IS_DEVICE_PTR,
106 PRAGMA_OMP_CLAUSE_LASTPRIVATE,
107 PRAGMA_OMP_CLAUSE_LINEAR,
108 PRAGMA_OMP_CLAUSE_LINK,
109 PRAGMA_OMP_CLAUSE_MAP,
110 PRAGMA_OMP_CLAUSE_MERGEABLE,
111 PRAGMA_OMP_CLAUSE_NOGROUP,
112 PRAGMA_OMP_CLAUSE_NOTINBRANCH,
113 PRAGMA_OMP_CLAUSE_NOWAIT,
114 PRAGMA_OMP_CLAUSE_NUM_TASKS,
115 PRAGMA_OMP_CLAUSE_NUM_TEAMS,
116 PRAGMA_OMP_CLAUSE_NUM_THREADS,
117 PRAGMA_OMP_CLAUSE_ORDERED,
118 PRAGMA_OMP_CLAUSE_PARALLEL,
119 PRAGMA_OMP_CLAUSE_PRIORITY,
120 PRAGMA_OMP_CLAUSE_PRIVATE,
121 PRAGMA_OMP_CLAUSE_PROC_BIND,
122 PRAGMA_OMP_CLAUSE_REDUCTION,
123 PRAGMA_OMP_CLAUSE_SAFELEN,
124 PRAGMA_OMP_CLAUSE_SCHEDULE,
125 PRAGMA_OMP_CLAUSE_SECTIONS,
126 PRAGMA_OMP_CLAUSE_SHARED,
127 PRAGMA_OMP_CLAUSE_SIMD,
128 PRAGMA_OMP_CLAUSE_SIMDLEN,
129 PRAGMA_OMP_CLAUSE_TASKGROUP,
130 PRAGMA_OMP_CLAUSE_THREAD_LIMIT,
131 PRAGMA_OMP_CLAUSE_THREADS,
132 PRAGMA_OMP_CLAUSE_TO,
133 PRAGMA_OMP_CLAUSE_UNIFORM,
134 PRAGMA_OMP_CLAUSE_UNTIED,
135 PRAGMA_OMP_CLAUSE_USE_DEVICE_PTR,
137 /* Clauses for Cilk Plus SIMD-enabled function. */
138 PRAGMA_CILK_CLAUSE_NOMASK,
139 PRAGMA_CILK_CLAUSE_MASK,
140 PRAGMA_CILK_CLAUSE_VECTORLENGTH,
141 PRAGMA_CILK_CLAUSE_NONE = PRAGMA_OMP_CLAUSE_NONE,
142 PRAGMA_CILK_CLAUSE_LINEAR = PRAGMA_OMP_CLAUSE_LINEAR,
143 PRAGMA_CILK_CLAUSE_PRIVATE = PRAGMA_OMP_CLAUSE_PRIVATE,
144 PRAGMA_CILK_CLAUSE_FIRSTPRIVATE = PRAGMA_OMP_CLAUSE_FIRSTPRIVATE,
145 PRAGMA_CILK_CLAUSE_LASTPRIVATE = PRAGMA_OMP_CLAUSE_LASTPRIVATE,
146 PRAGMA_CILK_CLAUSE_REDUCTION = PRAGMA_OMP_CLAUSE_REDUCTION,
147 PRAGMA_CILK_CLAUSE_UNIFORM = PRAGMA_OMP_CLAUSE_UNIFORM,
149 /* Clauses for OpenACC. */
150 PRAGMA_OACC_CLAUSE_ASYNC = PRAGMA_CILK_CLAUSE_VECTORLENGTH + 1,
151 PRAGMA_OACC_CLAUSE_AUTO,
152 PRAGMA_OACC_CLAUSE_COPY,
153 PRAGMA_OACC_CLAUSE_COPYOUT,
154 PRAGMA_OACC_CLAUSE_CREATE,
155 PRAGMA_OACC_CLAUSE_DELETE,
156 PRAGMA_OACC_CLAUSE_DEVICEPTR,
157 PRAGMA_OACC_CLAUSE_DEVICE_RESIDENT,
158 PRAGMA_OACC_CLAUSE_GANG,
159 PRAGMA_OACC_CLAUSE_HOST,
160 PRAGMA_OACC_CLAUSE_INDEPENDENT,
161 PRAGMA_OACC_CLAUSE_NUM_GANGS,
162 PRAGMA_OACC_CLAUSE_NUM_WORKERS,
163 PRAGMA_OACC_CLAUSE_PRESENT,
164 PRAGMA_OACC_CLAUSE_PRESENT_OR_COPY,
165 PRAGMA_OACC_CLAUSE_PRESENT_OR_COPYIN,
166 PRAGMA_OACC_CLAUSE_PRESENT_OR_COPYOUT,
167 PRAGMA_OACC_CLAUSE_PRESENT_OR_CREATE,
168 PRAGMA_OACC_CLAUSE_SELF,
169 PRAGMA_OACC_CLAUSE_SEQ,
170 PRAGMA_OACC_CLAUSE_TILE,
171 PRAGMA_OACC_CLAUSE_USE_DEVICE,
172 PRAGMA_OACC_CLAUSE_VECTOR,
173 PRAGMA_OACC_CLAUSE_VECTOR_LENGTH,
174 PRAGMA_OACC_CLAUSE_WAIT,
175 PRAGMA_OACC_CLAUSE_WORKER,
176 PRAGMA_OACC_CLAUSE_COLLAPSE = PRAGMA_OMP_CLAUSE_COLLAPSE,
177 PRAGMA_OACC_CLAUSE_COPYIN = PRAGMA_OMP_CLAUSE_COPYIN,
178 PRAGMA_OACC_CLAUSE_DEVICE = PRAGMA_OMP_CLAUSE_DEVICE,
179 PRAGMA_OACC_CLAUSE_DEFAULT = PRAGMA_OMP_CLAUSE_DEFAULT,
180 PRAGMA_OACC_CLAUSE_FIRSTPRIVATE = PRAGMA_OMP_CLAUSE_FIRSTPRIVATE,
181 PRAGMA_OACC_CLAUSE_IF = PRAGMA_OMP_CLAUSE_IF,
182 PRAGMA_OACC_CLAUSE_PRIVATE = PRAGMA_OMP_CLAUSE_PRIVATE,
183 PRAGMA_OACC_CLAUSE_REDUCTION = PRAGMA_OMP_CLAUSE_REDUCTION,
184 PRAGMA_OACC_CLAUSE_LINK = PRAGMA_OMP_CLAUSE_LINK
187 extern struct cpp_reader* parse_in;
189 /* It's safe to always leave visibility pragma enabled as if
190 visibility is not supported on the host OS platform the
191 statements are ignored. */
192 extern void push_visibility (const char *, int);
193 extern bool pop_visibility (int);
195 extern void init_pragma (void);
197 /* Front-end wrappers for pragma registration. */
198 typedef void (*pragma_handler_1arg)(struct cpp_reader *);
199 /* A second pragma handler, which adds a void * argument allowing to pass extra
200 data to the handler. */
201 typedef void (*pragma_handler_2arg)(struct cpp_reader *, void *);
203 /* This union allows to abstract the different handlers. */
204 union gen_pragma_handler {
205 pragma_handler_1arg handler_1arg;
206 pragma_handler_2arg handler_2arg;
208 /* Internally used to keep the data of the handler. */
209 struct internal_pragma_handler {
210 union gen_pragma_handler handler;
211 /* Permits to know if handler is a pragma_handler_1arg (extra_data is false)
212 or a pragma_handler_2arg (extra_data is true). */
213 bool extra_data;
214 /* A data field which can be used when extra_data is true. */
215 void * data;
218 extern void c_register_pragma (const char *space, const char *name,
219 pragma_handler_1arg handler);
220 extern void c_register_pragma_with_data (const char *space, const char *name,
221 pragma_handler_2arg handler,
222 void *data);
224 extern void c_register_pragma_with_expansion (const char *space,
225 const char *name,
226 pragma_handler_1arg handler);
227 extern void c_register_pragma_with_expansion_and_data (const char *space,
228 const char *name,
229 pragma_handler_2arg handler,
230 void *data);
231 extern void c_invoke_pragma_handler (unsigned int);
233 extern void maybe_apply_pragma_weak (tree);
234 extern void maybe_apply_pending_pragma_weaks (void);
235 extern tree maybe_apply_renaming_pragma (tree, tree);
236 extern void maybe_apply_pragma_scalar_storage_order (tree);
237 extern void add_to_renaming_pragma_list (tree, tree);
239 extern enum cpp_ttype pragma_lex (tree *, location_t *loc = NULL);
241 /* Flags for use with c_lex_with_flags. The values here were picked
242 so that 0 means to translate and join strings. */
243 #define C_LEX_STRING_NO_TRANSLATE 1 /* Do not lex strings into
244 execution character set. */
245 #define C_LEX_STRING_NO_JOIN 2 /* Do not concatenate strings
246 nor translate them into execution
247 character set. */
249 /* This is not actually available to pragma parsers. It's merely a
250 convenient location to declare this function for c-lex, after
251 having enum cpp_ttype declared. */
252 extern enum cpp_ttype c_lex_with_flags (tree *, location_t *, unsigned char *,
253 int);
255 extern void c_pp_lookup_pragma (unsigned int, const char **, const char **);
257 extern GTY(()) tree pragma_extern_prefix;
259 #endif /* GCC_C_PRAGMA_H */