xref: /netbsd-src/external/gpl3/gcc.old/dist/gcc/c-family/c-pragma.h (revision aef5eb5f59cdfe8314f1b5f78ac04eb144e44010)
1 /* Pragma related interfaces.
2    Copyright (C) 1995-2019 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_UPDATE,
42   PRAGMA_OACC_WAIT,
43 
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_DEPOBJ,
51   PRAGMA_OMP_DISTRIBUTE,
52   PRAGMA_OMP_END_DECLARE_TARGET,
53   PRAGMA_OMP_FLUSH,
54   PRAGMA_OMP_FOR,
55   PRAGMA_OMP_MASTER,
56   PRAGMA_OMP_ORDERED,
57   PRAGMA_OMP_PARALLEL,
58   PRAGMA_OMP_REQUIRES,
59   PRAGMA_OMP_SECTION,
60   PRAGMA_OMP_SECTIONS,
61   PRAGMA_OMP_SIMD,
62   PRAGMA_OMP_SINGLE,
63   PRAGMA_OMP_TARGET,
64   PRAGMA_OMP_TASK,
65   PRAGMA_OMP_TASKGROUP,
66   PRAGMA_OMP_TASKLOOP,
67   PRAGMA_OMP_TASKWAIT,
68   PRAGMA_OMP_TASKYIELD,
69   PRAGMA_OMP_THREADPRIVATE,
70   PRAGMA_OMP_TEAMS,
71 
72   PRAGMA_GCC_PCH_PREPROCESS,
73   PRAGMA_IVDEP,
74   PRAGMA_UNROLL,
75 
76   PRAGMA_FIRST_EXTERNAL
77 };
78 
79 
80 /* All clauses defined by OpenACC 2.0, and OpenMP 2.5, 3.0, 3.1, 4.0, 4.5
81    and 5.0.  Used internally by both C and C++ parsers.  */
82 enum pragma_omp_clause {
83   PRAGMA_OMP_CLAUSE_NONE = 0,
84 
85   PRAGMA_OMP_CLAUSE_ALIGNED,
86   PRAGMA_OMP_CLAUSE_COLLAPSE,
87   PRAGMA_OMP_CLAUSE_COPYIN,
88   PRAGMA_OMP_CLAUSE_COPYPRIVATE,
89   PRAGMA_OMP_CLAUSE_DEFAULT,
90   PRAGMA_OMP_CLAUSE_DEFAULTMAP,
91   PRAGMA_OMP_CLAUSE_DEPEND,
92   PRAGMA_OMP_CLAUSE_DEVICE,
93   PRAGMA_OMP_CLAUSE_DIST_SCHEDULE,
94   PRAGMA_OMP_CLAUSE_FINAL,
95   PRAGMA_OMP_CLAUSE_FIRSTPRIVATE,
96   PRAGMA_OMP_CLAUSE_FOR,
97   PRAGMA_OMP_CLAUSE_FROM,
98   PRAGMA_OMP_CLAUSE_GRAINSIZE,
99   PRAGMA_OMP_CLAUSE_HINT,
100   PRAGMA_OMP_CLAUSE_IF,
101   PRAGMA_OMP_CLAUSE_IN_REDUCTION,
102   PRAGMA_OMP_CLAUSE_INBRANCH,
103   PRAGMA_OMP_CLAUSE_IS_DEVICE_PTR,
104   PRAGMA_OMP_CLAUSE_LASTPRIVATE,
105   PRAGMA_OMP_CLAUSE_LINEAR,
106   PRAGMA_OMP_CLAUSE_LINK,
107   PRAGMA_OMP_CLAUSE_MAP,
108   PRAGMA_OMP_CLAUSE_MERGEABLE,
109   PRAGMA_OMP_CLAUSE_NOGROUP,
110   PRAGMA_OMP_CLAUSE_NONTEMPORAL,
111   PRAGMA_OMP_CLAUSE_NOTINBRANCH,
112   PRAGMA_OMP_CLAUSE_NOWAIT,
113   PRAGMA_OMP_CLAUSE_NUM_TASKS,
114   PRAGMA_OMP_CLAUSE_NUM_TEAMS,
115   PRAGMA_OMP_CLAUSE_NUM_THREADS,
116   PRAGMA_OMP_CLAUSE_ORDERED,
117   PRAGMA_OMP_CLAUSE_PARALLEL,
118   PRAGMA_OMP_CLAUSE_PRIORITY,
119   PRAGMA_OMP_CLAUSE_PRIVATE,
120   PRAGMA_OMP_CLAUSE_PROC_BIND,
121   PRAGMA_OMP_CLAUSE_REDUCTION,
122   PRAGMA_OMP_CLAUSE_SAFELEN,
123   PRAGMA_OMP_CLAUSE_SCHEDULE,
124   PRAGMA_OMP_CLAUSE_SECTIONS,
125   PRAGMA_OMP_CLAUSE_SHARED,
126   PRAGMA_OMP_CLAUSE_SIMD,
127   PRAGMA_OMP_CLAUSE_SIMDLEN,
128   PRAGMA_OMP_CLAUSE_TASK_REDUCTION,
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,
136 
137   /* Clauses for OpenACC.  */
138   PRAGMA_OACC_CLAUSE_ASYNC,
139   PRAGMA_OACC_CLAUSE_AUTO,
140   PRAGMA_OACC_CLAUSE_COPY,
141   PRAGMA_OACC_CLAUSE_COPYOUT,
142   PRAGMA_OACC_CLAUSE_CREATE,
143   PRAGMA_OACC_CLAUSE_DELETE,
144   PRAGMA_OACC_CLAUSE_DEVICEPTR,
145   PRAGMA_OACC_CLAUSE_DEVICE_RESIDENT,
146   PRAGMA_OACC_CLAUSE_FINALIZE,
147   PRAGMA_OACC_CLAUSE_GANG,
148   PRAGMA_OACC_CLAUSE_HOST,
149   PRAGMA_OACC_CLAUSE_INDEPENDENT,
150   PRAGMA_OACC_CLAUSE_NUM_GANGS,
151   PRAGMA_OACC_CLAUSE_NUM_WORKERS,
152   PRAGMA_OACC_CLAUSE_PRESENT,
153   PRAGMA_OACC_CLAUSE_SELF,
154   PRAGMA_OACC_CLAUSE_SEQ,
155   PRAGMA_OACC_CLAUSE_TILE,
156   PRAGMA_OACC_CLAUSE_USE_DEVICE,
157   PRAGMA_OACC_CLAUSE_VECTOR,
158   PRAGMA_OACC_CLAUSE_VECTOR_LENGTH,
159   PRAGMA_OACC_CLAUSE_WAIT,
160   PRAGMA_OACC_CLAUSE_WORKER,
161   PRAGMA_OACC_CLAUSE_IF_PRESENT,
162   PRAGMA_OACC_CLAUSE_COLLAPSE = PRAGMA_OMP_CLAUSE_COLLAPSE,
163   PRAGMA_OACC_CLAUSE_COPYIN = PRAGMA_OMP_CLAUSE_COPYIN,
164   PRAGMA_OACC_CLAUSE_DEVICE = PRAGMA_OMP_CLAUSE_DEVICE,
165   PRAGMA_OACC_CLAUSE_DEFAULT = PRAGMA_OMP_CLAUSE_DEFAULT,
166   PRAGMA_OACC_CLAUSE_FIRSTPRIVATE = PRAGMA_OMP_CLAUSE_FIRSTPRIVATE,
167   PRAGMA_OACC_CLAUSE_IF = PRAGMA_OMP_CLAUSE_IF,
168   PRAGMA_OACC_CLAUSE_PRIVATE = PRAGMA_OMP_CLAUSE_PRIVATE,
169   PRAGMA_OACC_CLAUSE_REDUCTION = PRAGMA_OMP_CLAUSE_REDUCTION,
170   PRAGMA_OACC_CLAUSE_LINK = PRAGMA_OMP_CLAUSE_LINK
171 };
172 
173 extern struct cpp_reader* parse_in;
174 
175 /* It's safe to always leave visibility pragma enabled as if
176    visibility is not supported on the host OS platform the
177    statements are ignored.  */
178 extern void push_visibility (const char *, int);
179 extern bool pop_visibility (int);
180 
181 extern void init_pragma (void);
182 
183 /* Front-end wrappers for pragma registration.  */
184 typedef void (*pragma_handler_1arg)(struct cpp_reader *);
185 /* A second pragma handler, which adds a void * argument allowing to pass extra
186    data to the handler.  */
187 typedef void (*pragma_handler_2arg)(struct cpp_reader *, void *);
188 
189 /* This union allows to abstract the different handlers.  */
190 union gen_pragma_handler {
191   pragma_handler_1arg handler_1arg;
192   pragma_handler_2arg handler_2arg;
193 };
194 /* Internally used to keep the data of the handler.  */
195 struct internal_pragma_handler {
196   union gen_pragma_handler handler;
197   /* Permits to know if handler is a pragma_handler_1arg (extra_data is false)
198      or a pragma_handler_2arg (extra_data is true).  */
199   bool extra_data;
200   /* A data field which can be used when extra_data is true.  */
201   void * data;
202 };
203 
204 extern void c_register_pragma (const char *space, const char *name,
205                                pragma_handler_1arg handler);
206 extern void c_register_pragma_with_data (const char *space, const char *name,
207                                          pragma_handler_2arg handler,
208                                          void *data);
209 
210 extern void c_register_pragma_with_expansion (const char *space,
211                                               const char *name,
212                                               pragma_handler_1arg handler);
213 extern void c_register_pragma_with_expansion_and_data (const char *space,
214                                                        const char *name,
215                                                    pragma_handler_2arg handler,
216                                                        void *data);
217 extern void c_invoke_pragma_handler (unsigned int);
218 
219 extern void maybe_apply_pragma_weak (tree);
220 extern void maybe_apply_pending_pragma_weaks (void);
221 extern tree maybe_apply_renaming_pragma (tree, tree);
222 extern void maybe_apply_pragma_scalar_storage_order (tree);
223 extern void add_to_renaming_pragma_list (tree, tree);
224 
225 extern enum cpp_ttype pragma_lex (tree *, location_t *loc = NULL);
226 
227 /* Flags for use with c_lex_with_flags.  The values here were picked
228    so that 0 means to translate and join strings.  */
229 #define C_LEX_STRING_NO_TRANSLATE 1 /* Do not lex strings into
230 				       execution character set.  */
231 #define C_LEX_STRING_NO_JOIN	  2 /* Do not concatenate strings
232 				       nor translate them into execution
233 				       character set.  */
234 
235 /* This is not actually available to pragma parsers.  It's merely a
236    convenient location to declare this function for c-lex, after
237    having enum cpp_ttype declared.  */
238 extern enum cpp_ttype c_lex_with_flags (tree *, location_t *, unsigned char *,
239 					int);
240 
241 extern void c_pp_lookup_pragma (unsigned int, const char **, const char **);
242 
243 extern GTY(()) tree pragma_extern_prefix;
244 
245 #endif /* GCC_C_PRAGMA_H */
246