Debian Codegraph @

gcc/c-family/c-pragma.h

raw
1 /* Pragma related interfaces.
2 Copyright (C) 1995-2025 Free Software Foundation, Inc.
3
4 This file is part of GCC.
5
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.
10
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.
15
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/>. */
19
20 #ifndef GCC_C_PRAGMA_H
21 #define GCC_C_PRAGMA_H
22
23 #include "cpplib.h" /* For enum cpp_ttype. */
24
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,
29
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_SERIAL,
42 PRAGMA_OACC_UPDATE,
43 PRAGMA_OACC_WAIT,
44
45 /* PRAGMA_OMP__START_ should be equal to the first PRAGMA_OMP_* code. */
46 PRAGMA_OMP_ALLOCATE,
47 PRAGMA_OMP__START_ = PRAGMA_OMP_ALLOCATE,
48 PRAGMA_OMP_ASSUME,
49 PRAGMA_OMP_ASSUMES,
50 PRAGMA_OMP_ATOMIC,
51 PRAGMA_OMP_BARRIER,
52 PRAGMA_OMP_BEGIN,
53 PRAGMA_OMP_CANCEL,
54 PRAGMA_OMP_CANCELLATION_POINT,
55 PRAGMA_OMP_CRITICAL,
56 PRAGMA_OMP_DECLARE,
57 PRAGMA_OMP_DEPOBJ,
58 PRAGMA_OMP_DISPATCH,
59 PRAGMA_OMP_DISTRIBUTE,
60 PRAGMA_OMP_ERROR,
61 PRAGMA_OMP_END,
62 PRAGMA_OMP_FLUSH,
63 PRAGMA_OMP_FOR,
64 PRAGMA_OMP_INTEROP,
65 PRAGMA_OMP_LOOP,
66 PRAGMA_OMP_NOTHING,
67 PRAGMA_OMP_MASKED,
68 PRAGMA_OMP_MASTER,
69 PRAGMA_OMP_METADIRECTIVE,
70 PRAGMA_OMP_ORDERED,
71 PRAGMA_OMP_PARALLEL,
72 PRAGMA_OMP_REQUIRES,
73 PRAGMA_OMP_SCAN,
74 PRAGMA_OMP_SCOPE,
75 PRAGMA_OMP_SECTION,
76 PRAGMA_OMP_SECTIONS,
77 PRAGMA_OMP_SIMD,
78 PRAGMA_OMP_SINGLE,
79 PRAGMA_OMP_TARGET,
80 PRAGMA_OMP_TASK,
81 PRAGMA_OMP_TASKGROUP,
82 PRAGMA_OMP_TASKLOOP,
83 PRAGMA_OMP_TASKWAIT,
84 PRAGMA_OMP_TASKYIELD,
85 PRAGMA_OMP_THREADPRIVATE,
86 PRAGMA_OMP_TEAMS,
87 PRAGMA_OMP_TILE,
88 PRAGMA_OMP_UNROLL,
89 /* PRAGMA_OMP__LAST_ should be equal to the last PRAGMA_OMP_* code. */
90 PRAGMA_OMP__LAST_ = PRAGMA_OMP_UNROLL,
91
92 PRAGMA_GCC_PCH_PREPROCESS,
93 PRAGMA_IVDEP,
94 PRAGMA_UNROLL,
95 PRAGMA_NOVECTOR,
96
97 PRAGMA_FIRST_EXTERNAL
98 };
99
100
101 /* All clauses defined by OpenACC 2.0, and OpenMP 2.5, 3.0, 3.1, 4.0, 4.5, 5.0,
102 5.1 and 5.2. Used internally by both C and C++ parsers. */
103 enum pragma_omp_clause {
104 PRAGMA_OMP_CLAUSE_NONE = 0,
105
106 PRAGMA_OMP_CLAUSE_AFFINITY,
107 PRAGMA_OMP_CLAUSE_ALIGNED,
108 PRAGMA_OMP_CLAUSE_ALLOCATE,
109 PRAGMA_OMP_CLAUSE_BIND,
110 PRAGMA_OMP_CLAUSE_COLLAPSE,
111 PRAGMA_OMP_CLAUSE_COPYIN,
112 PRAGMA_OMP_CLAUSE_COPYPRIVATE,
113 PRAGMA_OMP_CLAUSE_DEFAULT,
114 PRAGMA_OMP_CLAUSE_DEFAULTMAP,
115 PRAGMA_OMP_CLAUSE_DEPEND,
116 PRAGMA_OMP_CLAUSE_DESTROY,
117 PRAGMA_OMP_CLAUSE_DETACH,
118 PRAGMA_OMP_CLAUSE_DEVICE,
119 PRAGMA_OMP_CLAUSE_DEVICE_TYPE,
120 PRAGMA_OMP_CLAUSE_DIST_SCHEDULE,
121 PRAGMA_OMP_CLAUSE_DOACROSS,
122 PRAGMA_OMP_CLAUSE_ENTER,
123 PRAGMA_OMP_CLAUSE_FILTER,
124 PRAGMA_OMP_CLAUSE_FINAL,
125 PRAGMA_OMP_CLAUSE_FIRSTPRIVATE,
126 PRAGMA_OMP_CLAUSE_FOR,
127 PRAGMA_OMP_CLAUSE_FROM,
128 PRAGMA_OMP_CLAUSE_FULL,
129 PRAGMA_OMP_CLAUSE_GRAINSIZE,
130 PRAGMA_OMP_CLAUSE_HAS_DEVICE_ADDR,
131 PRAGMA_OMP_CLAUSE_HINT,
132 PRAGMA_OMP_CLAUSE_IF,
133 PRAGMA_OMP_CLAUSE_IN_REDUCTION,
134 PRAGMA_OMP_CLAUSE_INBRANCH,
135 PRAGMA_OMP_CLAUSE_INDIRECT,
136 PRAGMA_OMP_CLAUSE_INIT,
137 PRAGMA_OMP_CLAUSE_IS_DEVICE_PTR,
138 PRAGMA_OMP_CLAUSE_INTEROP,
139 PRAGMA_OMP_CLAUSE_LASTPRIVATE,
140 PRAGMA_OMP_CLAUSE_LINEAR,
141 PRAGMA_OMP_CLAUSE_LINK,
142 PRAGMA_OMP_CLAUSE_MAP,
143 PRAGMA_OMP_CLAUSE_MERGEABLE,
144 PRAGMA_OMP_CLAUSE_NOCONTEXT,
145 PRAGMA_OMP_CLAUSE_NOGROUP,
146 PRAGMA_OMP_CLAUSE_NONTEMPORAL,
147 PRAGMA_OMP_CLAUSE_NOTINBRANCH,
148 PRAGMA_OMP_CLAUSE_NOVARIANTS,
149 PRAGMA_OMP_CLAUSE_NOWAIT,
150 PRAGMA_OMP_CLAUSE_NUM_TASKS,
151 PRAGMA_OMP_CLAUSE_NUM_TEAMS,
152 PRAGMA_OMP_CLAUSE_NUM_THREADS,
153 PRAGMA_OMP_CLAUSE_ORDER,
154 PRAGMA_OMP_CLAUSE_ORDERED,
155 PRAGMA_OMP_CLAUSE_PARALLEL,
156 PRAGMA_OMP_CLAUSE_PARTIAL,
157 PRAGMA_OMP_CLAUSE_PRIORITY,
158 PRAGMA_OMP_CLAUSE_PRIVATE,
159 PRAGMA_OMP_CLAUSE_PROC_BIND,
160 PRAGMA_OMP_CLAUSE_REDUCTION,
161 PRAGMA_OMP_CLAUSE_SAFELEN,
162 PRAGMA_OMP_CLAUSE_SCHEDULE,
163 PRAGMA_OMP_CLAUSE_SECTIONS,
164 PRAGMA_OMP_CLAUSE_SHARED,
165 PRAGMA_OMP_CLAUSE_SIMD,
166 PRAGMA_OMP_CLAUSE_SIMDLEN,
167 PRAGMA_OMP_CLAUSE_TASK_REDUCTION,
168 PRAGMA_OMP_CLAUSE_TASKGROUP,
169 PRAGMA_OMP_CLAUSE_THREAD_LIMIT,
170 PRAGMA_OMP_CLAUSE_THREADS,
171 PRAGMA_OMP_CLAUSE_TO,
172 PRAGMA_OMP_CLAUSE_UNIFORM,
173 PRAGMA_OMP_CLAUSE_UNTIED,
174 PRAGMA_OMP_CLAUSE_USE,
175 PRAGMA_OMP_CLAUSE_USE_DEVICE_PTR,
176 PRAGMA_OMP_CLAUSE_USE_DEVICE_ADDR,
177
178 /* Clauses for OpenACC. */
179 PRAGMA_OACC_CLAUSE_ASYNC,
180 PRAGMA_OACC_CLAUSE_ATTACH,
181 PRAGMA_OACC_CLAUSE_AUTO,
182 PRAGMA_OACC_CLAUSE_COPY,
183 PRAGMA_OACC_CLAUSE_COPYOUT,
184 PRAGMA_OACC_CLAUSE_CREATE,
185 PRAGMA_OACC_CLAUSE_DELETE,
186 PRAGMA_OACC_CLAUSE_DEVICEPTR,
187 PRAGMA_OACC_CLAUSE_DEVICE_RESIDENT,
188 PRAGMA_OACC_CLAUSE_FINALIZE,
189 PRAGMA_OACC_CLAUSE_GANG,
190 PRAGMA_OACC_CLAUSE_HOST,
191 PRAGMA_OACC_CLAUSE_INDEPENDENT,
192 PRAGMA_OACC_CLAUSE_NO_CREATE,
193 PRAGMA_OACC_CLAUSE_NOHOST,
194 PRAGMA_OACC_CLAUSE_NUM_GANGS,
195 PRAGMA_OACC_CLAUSE_NUM_WORKERS,
196 PRAGMA_OACC_CLAUSE_PRESENT,
197 PRAGMA_OACC_CLAUSE_SELF,
198 PRAGMA_OACC_CLAUSE_SEQ,
199 PRAGMA_OACC_CLAUSE_TILE,
200 PRAGMA_OACC_CLAUSE_VECTOR,
201 PRAGMA_OACC_CLAUSE_VECTOR_LENGTH,
202 PRAGMA_OACC_CLAUSE_WAIT,
203 PRAGMA_OACC_CLAUSE_WORKER,
204 PRAGMA_OACC_CLAUSE_IF_PRESENT,
205 PRAGMA_OACC_CLAUSE_COLLAPSE = PRAGMA_OMP_CLAUSE_COLLAPSE,
206 PRAGMA_OACC_CLAUSE_COPYIN = PRAGMA_OMP_CLAUSE_COPYIN,
207 PRAGMA_OACC_CLAUSE_DEVICE = PRAGMA_OMP_CLAUSE_DEVICE,
208 PRAGMA_OACC_CLAUSE_DEFAULT = PRAGMA_OMP_CLAUSE_DEFAULT,
209 PRAGMA_OACC_CLAUSE_DETACH = PRAGMA_OMP_CLAUSE_DETACH,
210 PRAGMA_OACC_CLAUSE_FIRSTPRIVATE = PRAGMA_OMP_CLAUSE_FIRSTPRIVATE,
211 PRAGMA_OACC_CLAUSE_IF = PRAGMA_OMP_CLAUSE_IF,
212 PRAGMA_OACC_CLAUSE_PRIVATE = PRAGMA_OMP_CLAUSE_PRIVATE,
213 PRAGMA_OACC_CLAUSE_REDUCTION = PRAGMA_OMP_CLAUSE_REDUCTION,
214 PRAGMA_OACC_CLAUSE_LINK = PRAGMA_OMP_CLAUSE_LINK,
215 PRAGMA_OACC_CLAUSE_USE_DEVICE = PRAGMA_OMP_CLAUSE_USE_DEVICE_PTR
216 };
217
218 extern struct cpp_reader* parse_in;
219
220 /* It's safe to always leave visibility pragma enabled as if
221 visibility is not supported on the host OS platform the
222 statements are ignored. */
223 extern void push_visibility (const char *, int);
224 extern bool pop_visibility (int);
225
226 extern void init_pragma (void);
227
228 /* Front-end wrappers for pragma registration. */
229 typedef void (*pragma_handler_1arg)(struct cpp_reader *);
230 /* A second pragma handler, which adds a void * argument allowing to pass extra
231 data to the handler. */
232 typedef void (*pragma_handler_2arg)(struct cpp_reader *, void *);
233
234 /* This union allows to abstract the different handlers. */
235 union gen_pragma_handler {
236 pragma_handler_1arg handler_1arg;
237 pragma_handler_2arg handler_2arg;
238 };
239 /* Internally used to keep the data of the handler. */
240 struct internal_pragma_handler {
241 union gen_pragma_handler handler, early_handler;
242 /* Permits to know if handler is a pragma_handler_1arg (extra_data is false)
243 or a pragma_handler_2arg (extra_data is true). */
244 bool extra_data;
245 /* A data field which can be used when extra_data is true. */
246 void * data;
247 };
248
249 extern void c_register_pragma (const char *space, const char *name,
250 pragma_handler_1arg handler);
251 extern void c_register_pragma_with_data (const char *space, const char *name,
252 pragma_handler_2arg handler,
253 void *data);
254
255 extern void c_register_pragma_with_expansion (const char *space,
256 const char *name,
257 pragma_handler_1arg handler);
258 extern void c_register_pragma_with_expansion_and_data (const char *space,
259 const char *name,
260 pragma_handler_2arg handler,
261 void *data);
262 extern void c_invoke_pragma_handler (unsigned int);
263
264 /* Early pragma handlers run in addition to the normal ones. They can be used
265 by frontends such as C++ that may want to process some pragmas during lexing
266 before they start processing them. */
267 extern void
268 c_register_pragma_with_early_handler (const char *space, const char *name,
269 pragma_handler_1arg handler,
270 pragma_handler_1arg early_handler);
271 extern void c_invoke_early_pragma_handler (unsigned int);
272 extern void c_pp_invoke_early_pragma_handler (unsigned int);
273 extern void c_reset_target_pragmas ();
274
275 extern void maybe_apply_pragma_weak (tree);
276 extern void maybe_apply_pending_pragma_weaks (void);
277 extern tree maybe_apply_renaming_pragma (tree, tree);
278 extern void maybe_apply_pragma_scalar_storage_order (tree);
279 extern void add_to_renaming_pragma_list (tree, tree);
280
281 /* These are to be implemented in each frontend that needs them. */
282 extern enum cpp_ttype pragma_lex (tree *, location_t *loc = NULL);
283 extern void pragma_lex_discard_to_eol ();
284
285 /* Flags for use with c_lex_with_flags. The values here were picked
286 so that 0 means to translate and join strings. */
287 #define C_LEX_STRING_NO_TRANSLATE 1 /* Do not lex strings into
288 execution character set. */
289 #define C_LEX_STRING_NO_JOIN 2 /* Do not concatenate strings
290 nor translate them into execution
291 character set. */
292
293 /* This is not actually available to pragma parsers. It's merely a
294 convenient location to declare this function for c-lex, after
295 having enum cpp_ttype declared. */
296 extern enum cpp_ttype c_lex_with_flags (tree *, location_t *, unsigned char *,
297 int);
298
299 extern void c_pp_lookup_pragma (unsigned int, const char **, const char **);
300
301 extern GTY(()) tree pragma_extern_prefix;
302
303 #endif /* GCC_C_PRAGMA_H */