GCC Middle and Back End API Reference
omp-general.h
Go to the documentation of this file.
1/* General types and functions that are uselful for processing of OpenMP,
2 OpenACC and similar directivers at various stages of compilation.
3
4 Copyright (C) 2005-2024 Free Software Foundation, Inc.
5
6This file is part of GCC.
7
8GCC is free software; you can redistribute it and/or modify it under
9the terms of the GNU General Public License as published by the Free
10Software Foundation; either version 3, or (at your option) any later
11version.
12
13GCC is distributed in the hope that it will be useful, but WITHOUT ANY
14WARRANTY; without even the implied warranty of MERCHANTABILITY or
15FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
16for more details.
17
18You should have received a copy of the GNU General Public License
19along with GCC; see the file COPYING3. If not see
20<http://www.gnu.org/licenses/>. */
21
22#ifndef GCC_OMP_GENERAL_H
23#define GCC_OMP_GENERAL_H
24
25#include "gomp-constants.h"
26#include "omp-api.h"
27#include "omp-selectors.h"
28
29/* Flags for an OpenACC loop. */
30
32 OLF_SEQ = 1u << 0, /* Explicitly sequential */
33 OLF_AUTO = 1u << 1, /* Compiler chooses axes. */
34 OLF_INDEPENDENT = 1u << 2, /* Iterations are known independent. */
35 OLF_GANG_STATIC = 1u << 3, /* Gang partitioning is static (has op). */
36 OLF_TILE = 1u << 4, /* Tiled loop. */
37 OLF_REDUCTION = 1u << 5, /* Reduction loop. */
38
39 /* Explicitly specified loop axes. */
41 OLF_DIM_GANG = 1u << (OLF_DIM_BASE + GOMP_DIM_GANG),
42 OLF_DIM_WORKER = 1u << (OLF_DIM_BASE + GOMP_DIM_WORKER),
43 OLF_DIM_VECTOR = 1u << (OLF_DIM_BASE + GOMP_DIM_VECTOR),
44
45 OLF_MAX = OLF_DIM_BASE + GOMP_DIM_MAX
46};
47
48/* A structure holding the elements of:
49 for (V = N1; V cond N2; V += STEP) [...]
50 or for non-rectangular loops:
51 for (V = M1 * W + N1; V cond M2 * W + N2; V += STEP;
52 where W is V of the OUTER-th loop (e.g. for OUTER 1 it is the
53 the index of the immediately surrounding loop).
54 NON_RECT_REFERENCED is true for loops referenced by loops
55 with non-NULL M1 or M2. */
56
64
65/* A structure describing the main elements of a parallel loop. */
66
68{
73 tree tiling; /* Tiling values (if non null). */
74 int collapse; /* Collapsed loops, 1 for a non-collapsed loop. */
81 unsigned char sched_modifiers;
84 /* The following are relevant only for non-rectangular loops
85 where only a single loop depends on an outer loop iterator. */
86 tree first_inner_iterations; /* Number of iterations of the inner
87 loop with the first outer iterator
88 (or adjn1, if that is non-NULL). */
89 tree factor; /* (m2 - m1) * outer_step / inner_step. */
90 /* Adjusted n1 of the outer loop in such loop nests (if needed). */
92};
93
94#define OACC_FN_ATTRIB "oacc function"
95
96/* Accessors for OMP context selectors, used by variant directives.
97 These are represented internally by a multilevel TREE_LIST structure, but
98 these accessors should be used to avoid confusion. The grammar is:
99
100 context-set-selector-specification:
101 trait-set-selector [, trait-set-selector [, ...]]
102 trait-set-selector:
103 trait-set-selector-name = { trait-selector [, trait-selector [, ... ]] }
104 trait-selector:
105 trait-selector-name [ ( [trait-score: ]
106 trait-property [, trait-property [, ...]] ) ]
107
108 trait-properties can variously be identifiers, strings, clauses, or
109 expressions.
110
111 All the lists are chained via TREE_CHAIN. If a score is present, it is
112 internally tacked on to the properties with a TREE_PURPOSE of
113 OMP_TS_SCORE_NODE. */
114
115#define OMP_TS_SCORE_NODE integer_minus_one_node
116#define OMP_TP_NAMELIST_NODE integer_one_node
117
118#define OMP_TSS_ID(NODE) \
119 TREE_PURPOSE (NODE)
120#define OMP_TSS_TRAIT_SELECTORS(NODE) \
121 TREE_VALUE (NODE)
122#define OMP_TS_ID(NODE) \
123 TREE_PURPOSE (NODE)
124#define OMP_TS_SCORE(NODE) \
125 ((TREE_VALUE (NODE) \
126 && TREE_CODE (TREE_VALUE (NODE)) == TREE_LIST \
127 && TREE_PURPOSE (TREE_VALUE (NODE)) == OMP_TS_SCORE_NODE) \
128 ? TREE_VALUE (TREE_VALUE (NODE)) : NULL_TREE)
129#define OMP_TS_PROPERTIES(NODE) \
130 ((TREE_VALUE (NODE) \
131 && TREE_CODE (TREE_VALUE (NODE)) == TREE_LIST \
132 && TREE_PURPOSE (TREE_VALUE (NODE)) == OMP_TS_SCORE_NODE) \
133 ? TREE_CHAIN (TREE_VALUE (NODE)) : TREE_VALUE (NODE))
134#define OMP_TP_NAME(NODE) \
135 TREE_PURPOSE (NODE)
136#define OMP_TP_VALUE(NODE) \
137 TREE_VALUE (NODE)
138
139#define OMP_TSS_CODE(t) \
140 ((enum omp_tss_code) TREE_INT_CST_LOW (OMP_TSS_ID (t)))
141#define OMP_TSS_NAME(t) \
142 (omp_tss_map[OMP_TSS_CODE (t)])
143
144#define OMP_TS_CODE(t) \
145 ((enum omp_ts_code) TREE_INT_CST_LOW (OMP_TS_ID (t)))
146#define OMP_TS_NAME(t) \
147 (omp_ts_map[OMP_TS_CODE (t)].name)
148
152
153extern tree omp_find_clause (tree clauses, enum omp_clause_code kind);
155extern tree omp_check_optional_argument (tree decl, bool for_present_check);
156extern bool omp_mappable_type (tree type);
158extern void omp_adjust_for_condition (location_t loc, enum tree_code *cond_code,
159 tree *n2, tree v, tree step);
160extern tree omp_get_for_step_from_incr (location_t loc, tree incr);
161extern void omp_extract_for_data (gomp_for *for_stmt, struct omp_for_data *fd,
162 struct omp_for_data_loop *loops);
163extern gimple *omp_build_barrier (tree lhs);
164extern tree find_combined_omp_for (tree *, int *, void *);
165extern poly_uint64 omp_max_vf (void);
166extern int omp_max_simt_vf (void);
167extern const char *omp_context_name_list_prop (tree);
168extern void omp_construct_traits_to_codes (tree, int, enum tree_code *);
169extern tree omp_check_context_selector (location_t loc, tree ctx);
170extern void omp_mark_declare_variant (location_t loc, tree variant,
171 tree construct);
175 enum omp_ts_code);
178extern tree oacc_launch_pack (unsigned code, tree device, unsigned op);
179extern tree oacc_replace_fn_attrib_attr (tree attribs, tree dims);
180extern void oacc_replace_fn_attrib (tree fn, tree dims);
181extern void oacc_set_fn_attrib (tree fn, tree clauses, vec<tree> *args);
182extern int oacc_verify_routine_clauses (tree, tree *, location_t,
183 const char *);
184extern tree oacc_build_routine_dims (tree clauses);
185extern tree oacc_get_fn_attrib (tree fn);
186extern bool offloading_function_p (tree fn);
187extern int oacc_get_fn_dim_size (tree fn, int axis);
188extern int oacc_get_ifn_dim_arg (const gimple *stmt);
189
192 OMP_REQUIRES_UNIFIED_ADDRESS = GOMP_REQUIRES_UNIFIED_ADDRESS,
193 OMP_REQUIRES_UNIFIED_SHARED_MEMORY = GOMP_REQUIRES_UNIFIED_SHARED_MEMORY,
195 OMP_REQUIRES_REVERSE_OFFLOAD = GOMP_REQUIRES_REVERSE_OFFLOAD,
197 OMP_REQUIRES_TARGET_USED = GOMP_REQUIRES_TARGET_USED,
198};
199
200extern GTY(()) enum omp_requires omp_requires_mask;
201
202inline dump_flags_t
204{
205 dump_flags_t l_dump_flags = MSG_NOTE;
206
207 /* For '--param=openacc-privatization=quiet', diagnostics only go to dump
208 files. */
209 if (param_openacc_privatization == OPENACC_PRIVATIZATION_QUIET)
210 l_dump_flags |= MSG_PRIORITY_INTERNALS;
211
212 return l_dump_flags;
213}
214
215extern tree omp_build_component_ref (tree obj, tree field);
216
217namespace omp_addr_tokenizer {
218
219/* These are the ways of accessing a variable that have special-case handling
220 in the middle end (gimplify, omp-lower, etc.). */
221
222/* These are the kinds of access that an ACCESS_METHOD token can represent. */
223
235
236/* These are the kinds that a STRUCTURE_BASE or ARRAY_BASE (except
237 BASE_COMPONENT_EXPR) can represent. */
238
239enum structure_base_kinds
240{
245
246/* The coarse type for an address token. These can have subtypes for
247 ARRAY_BASE or STRUCTURE_BASE (structure_base_kinds) or ACCESS_METHOD
248 (access_method_kinds). */
249
257
258/* The struct that forms a single token of an address expression as parsed by
259 omp_parse_expr. These are typically held in a vec after parsing. */
260
276
277extern bool omp_access_chain_p (vec<omp_addr_token *> &, unsigned);
279
280}
281
283
285
287extern void omp_maybe_apply_loop_xforms (tree *, tree);
288
289#endif /* GCC_OMP_GENERAL_H */
Definition cfgloop.h:120
#define GTY(x)
Definition coretypes.h:41
union tree_node * tree
Definition coretypes.h:97
@ MSG_PRIORITY_INTERNALS
Definition dumpfile.h:181
@ MSG_NOTE
Definition dumpfile.h:159
enum dump_flag dump_flags_t
Definition dumpfile.h:209
@ OPENACC_PRIVATIZATION_QUIET
Definition flag-types.h:516
tree_code
Definition genmatch.cc:347
Definition omp-general.cc:3381
structure_base_kinds
Definition omp-general.h:240
@ BASE_ARBITRARY_EXPR
Definition omp-general.h:243
@ BASE_COMPONENT_EXPR
Definition omp-general.h:242
@ BASE_DECL
Definition omp-general.h:241
access_method_kinds
Definition omp-general.h:225
@ ACCESS_REF_TO_POINTER
Definition omp-general.h:229
@ ACCESS_POINTER_OFFSET
Definition omp-general.h:230
@ ACCESS_DIRECT
Definition omp-general.h:226
@ ACCESS_INDEXED_REF_TO_ARRAY
Definition omp-general.h:233
@ ACCESS_REF_TO_POINTER_OFFSET
Definition omp-general.h:231
@ ACCESS_POINTER
Definition omp-general.h:228
@ ACCESS_REF
Definition omp-general.h:227
@ ACCESS_INDEXED_ARRAY
Definition omp-general.h:232
bool omp_access_chain_p(vec< omp_addr_token * > &addr_tokens, unsigned i)
Definition omp-general.cc:3682
tree omp_accessed_addr(vec< omp_addr_token * > &addr_tokens, unsigned i, tree expr)
Definition omp-general.cc:3694
token_type
Definition omp-general.h:251
@ STRUCTURE_BASE
Definition omp-general.h:253
@ ARRAY_BASE
Definition omp-general.h:252
@ COMPONENT_SELECTOR
Definition omp-general.h:254
@ ACCESS_METHOD
Definition omp-general.h:255
tree omp_find_clause(tree clauses, enum omp_clause_code kind)
Definition omp-general.cc:52
tree omp_build_component_ref(tree obj, tree field)
Definition omp-general.cc:3237
enum omp_requires omp_requires_mask
Definition omp-general.cc:48
gimple * omp_build_barrier(tree lhs)
Definition omp-general.cc:923
bool omp_is_allocatable_or_ptr(tree decl)
Definition omp-general.cc:64
void omp_mark_declare_variant(location_t loc, tree variant, tree construct)
Definition omp-general.cc:1389
tree oacc_build_routine_dims(tree clauses)
Definition omp-general.cc:3153
tree omp_resolve_declare_variant(tree)
Definition omp-general.cc:2492
tree oacc_replace_fn_attrib_attr(tree attribs, tree dims)
Definition omp-general.cc:2916
bool omp_privatize_by_reference(tree decl)
Definition omp-general.cc:98
tree omp_check_context_selector(location_t loc, tree ctx)
Definition omp-general.cc:1283
int oacc_get_fn_dim_size(tree fn, int axis)
Definition omp-general.cc:3203
omp_addr_tokenizer::omp_addr_token omp_addr_token
Definition omp-general.h:282
tree omp_loop_number_of_iterations(tree, int, tree *=NULL)
Definition omp-general.cc:3807
tree make_trait_set_selector(enum omp_tss_code, tree, tree)
Definition omp-general.cc:1421
bool omp_mappable_type(tree type)
Definition omp-general.cc:86
tree make_trait_property(tree, tree, tree)
Definition omp-general.cc:1441
void omp_extract_for_data(gomp_for *for_stmt, struct omp_for_data *fd, struct omp_for_data_loop *loops)
Definition omp-general.cc:206
void oacc_replace_fn_attrib(tree fn, tree dims)
Definition omp-general.cc:2930
void omp_maybe_apply_loop_xforms(tree *, tree)
Definition omp-general.cc:4120
tree omp_check_optional_argument(tree decl, bool for_present_check)
Definition omp-general.cc:78
tree find_combined_omp_for(tree *, int *, void *)
Definition omp-general.cc:940
int oacc_get_ifn_dim_arg(const gimple *stmt)
Definition omp-general.cc:3222
tree omp_get_context_selector_list(tree, enum omp_tss_code)
Definition omp-general.cc:2175
int omp_context_selector_set_compare(enum omp_tss_code, tree, tree)
Definition omp-general.cc:2007
poly_uint64 omp_max_vf(void)
Definition omp-general.cc:991
tree make_trait_selector(enum omp_ts_code, tree, tree, tree)
Definition omp-general.cc:1428
oacc_loop_flags
Definition omp-general.h:31
@ OLF_AUTO
Definition omp-general.h:33
@ OLF_DIM_VECTOR
Definition omp-general.h:43
@ OLF_DIM_GANG
Definition omp-general.h:41
@ OLF_REDUCTION
Definition omp-general.h:37
@ OLF_SEQ
Definition omp-general.h:32
@ OLF_TILE
Definition omp-general.h:36
@ OLF_GANG_STATIC
Definition omp-general.h:35
@ OLF_MAX
Definition omp-general.h:45
@ OLF_DIM_BASE
Definition omp-general.h:40
@ OLF_INDEPENDENT
Definition omp-general.h:34
@ OLF_DIM_WORKER
Definition omp-general.h:42
int omp_max_simt_vf(void)
Definition omp-general.cc:1023
tree oacc_launch_pack(unsigned code, tree device, unsigned op)
Definition omp-general.cc:2882
dump_flags_t get_openacc_privatization_dump_flags()
Definition omp-general.h:203
omp_requires
Definition omp-general.h:190
@ OMP_REQUIRES_REVERSE_OFFLOAD
Definition omp-general.h:195
@ OMP_REQUIRES_DYNAMIC_ALLOCATORS
Definition omp-general.h:194
@ OMP_REQUIRES_UNIFIED_ADDRESS
Definition omp-general.h:192
@ OMP_REQUIRES_ATOMIC_DEFAULT_MEM_ORDER_USED
Definition omp-general.h:196
@ OMP_REQUIRES_UNIFIED_SHARED_MEMORY
Definition omp-general.h:193
@ OMP_REQUIRES_TARGET_USED
Definition omp-general.h:197
@ OMP_REQUIRES_ATOMIC_DEFAULT_MEM_ORDER
Definition omp-general.h:191
void omp_construct_traits_to_codes(tree, int, enum tree_code *)
Definition omp-general.cc:1043
int oacc_verify_routine_clauses(tree, tree *, location_t, const char *)
Definition omp-general.cc:2990
tree omp_get_context_selector(tree, enum omp_tss_code, enum omp_ts_code)
Definition omp-general.cc:2162
void oacc_set_fn_attrib(tree fn, tree clauses, vec< tree > *args)
Definition omp-general.cc:2941
tree omp_get_for_step_from_incr(location_t loc, tree incr)
Definition omp-general.cc:181
int omp_context_selector_matches(tree)
Definition omp-general.cc:1453
void omp_adjust_for_condition(location_t loc, enum tree_code *cond_code, tree *n2, tree v, tree step)
Definition omp-general.cc:107
const char * omp_context_name_list_prop(tree)
Definition omp-general.cc:1258
bool offloading_function_p(tree fn)
Definition omp-general.cc:3191
tree oacc_get_fn_attrib(tree fn)
Definition omp-general.cc:3183
bool omp_parse_expr(vec< omp_addr_token * > &, tree)
Definition omp-general.cc:3705
omp_tss_code
Definition omp-selectors.h:28
omp_ts_code
Definition omp-selectors.h:39
Definition genautomata.cc:499
Definition gimple.h:225
Definition gimple.h:606
Definition cfgloop.h:324
Definition omp-general.h:262
union omp_addr_tokenizer::omp_addr_token::@51 u
tree expr
Definition omp-general.h:264
structure_base_kinds structure_base_kind
Definition omp-general.h:269
enum token_type type
Definition omp-general.h:263
access_method_kinds access_kind
Definition omp-general.h:268
Definition omp-general.h:58
tree n1
Definition omp-general.h:59
tree m2
Definition omp-general.h:59
tree v
Definition omp-general.h:59
tree m1
Definition omp-general.h:59
enum tree_code cond_code
Definition omp-general.h:60
tree step
Definition omp-general.h:59
tree n2
Definition omp-general.h:59
int outer
Definition omp-general.h:61
bool non_rect_referenced
Definition omp-general.h:62
Definition omp-general.h:68
bool have_pointer_condtemp
Definition omp-general.h:78
int collapse
Definition omp-general.h:74
bool non_rect
Definition omp-general.h:79
int lastprivate_conditional
Definition omp-general.h:80
gomp_for * for_stmt
Definition omp-general.h:71
bool simd_schedule
Definition omp-general.h:77
int last_nonrect
Definition omp-general.h:76
bool have_nonctrl_scantemp
Definition omp-general.h:78
tree chunk_size
Definition omp-general.h:70
struct omp_for_data_loop * loops
Definition omp-general.h:83
tree first_inner_iterations
Definition omp-general.h:86
int first_nonrect
Definition omp-general.h:76
bool have_nowait
Definition omp-general.h:77
int ordered
Definition omp-general.h:75
bool have_reductemp
Definition omp-general.h:77
tree tiling
Definition omp-general.h:73
tree pre
Definition omp-general.h:72
bool have_ordered
Definition omp-general.h:77
bool have_scantemp
Definition omp-general.h:78
tree adjn1
Definition omp-general.h:91
tree factor
Definition omp-general.h:89
tree iter_type
Definition omp-general.h:72
enum omp_clause_schedule_kind sched_kind
Definition omp-general.h:82
unsigned char sched_modifiers
Definition omp-general.h:81
Definition gengtype.h:252
Definition vec.h:450
#define NULL
Definition system.h:50
omp_clause_code
Definition tree-core.h:245
omp_clause_schedule_kind
Definition tree-core.h:555