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-2023 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
28/* Flags for an OpenACC loop. */
29
30enum oacc_loop_flags {
31 OLF_SEQ = 1u << 0, /* Explicitly sequential */
32 OLF_AUTO = 1u << 1, /* Compiler chooses axes. */
33 OLF_INDEPENDENT = 1u << 2, /* Iterations are known independent. */
34 OLF_GANG_STATIC = 1u << 3, /* Gang partitioning is static (has op). */
35 OLF_TILE = 1u << 4, /* Tiled loop. */
36 OLF_REDUCTION = 1u << 5, /* Reduction loop. */
37
38 /* Explicitly specified loop axes. */
39 OLF_DIM_BASE = 6,
40 OLF_DIM_GANG = 1u << (OLF_DIM_BASE + GOMP_DIM_GANG),
41 OLF_DIM_WORKER = 1u << (OLF_DIM_BASE + GOMP_DIM_WORKER),
42 OLF_DIM_VECTOR = 1u << (OLF_DIM_BASE + GOMP_DIM_VECTOR),
43
44 OLF_MAX = OLF_DIM_BASE + GOMP_DIM_MAX
45};
46
47/* A structure holding the elements of:
48 for (V = N1; V cond N2; V += STEP) [...]
49 or for non-rectangular loops:
50 for (V = M1 * W + N1; V cond M2 * W + N2; V += STEP;
51 where W is V of the OUTER-th loop (e.g. for OUTER 1 it is the
52 the index of the immediately surrounding loop).
53 NON_RECT_REFERENCED is true for loops referenced by loops
54 with non-NULL M1 or M2. */
55
56struct omp_for_data_loop
57{
58 tree v, n1, n2, step, m1, m2;
59 enum tree_code cond_code;
60 int outer;
61 bool non_rect_referenced;
62};
63
64/* A structure describing the main elements of a parallel loop. */
65
66struct omp_for_data
67{
68 struct omp_for_data_loop loop;
69 tree chunk_size;
70 gomp_for *for_stmt;
71 tree pre, iter_type;
72 tree tiling; /* Tiling values (if non null). */
73 int collapse; /* Collapsed loops, 1 for a non-collapsed loop. */
74 int ordered;
75 int first_nonrect, last_nonrect;
76 bool have_nowait, have_ordered, simd_schedule, have_reductemp;
77 bool have_pointer_condtemp, have_scantemp, have_nonctrl_scantemp;
78 bool non_rect;
79 int lastprivate_conditional;
80 unsigned char sched_modifiers;
81 enum omp_clause_schedule_kind sched_kind;
82 struct omp_for_data_loop *loops;
83 /* The following are relevant only for non-rectangular loops
84 where only a single loop depends on an outer loop iterator. */
85 tree first_inner_iterations; /* Number of iterations of the inner
86 loop with the first outer iterator
87 (or adjn1, if that is non-NULL). */
88 tree factor; /* (m2 - m1) * outer_step / inner_step. */
89 /* Adjusted n1 of the outer loop in such loop nests (if needed). */
90 tree adjn1;
91};
92
93#define OACC_FN_ATTRIB "oacc function"
94
95extern tree omp_find_clause (tree clauses, enum omp_clause_code kind);
96extern bool omp_is_allocatable_or_ptr (tree decl);
97extern tree omp_check_optional_argument (tree decl, bool for_present_check);
98extern bool omp_mappable_type (tree type);
99extern bool omp_privatize_by_reference (tree decl);
100extern void omp_adjust_for_condition (location_t loc, enum tree_code *cond_code,
101 tree *n2, tree v, tree step);
102extern tree omp_get_for_step_from_incr (location_t loc, tree incr);
103extern void omp_extract_for_data (gomp_for *for_stmt, struct omp_for_data *fd,
104 struct omp_for_data_loop *loops);
105extern gimple *omp_build_barrier (tree lhs);
106extern tree find_combined_omp_for (tree *, int *, void *);
107extern poly_uint64 omp_max_vf (void);
108extern int omp_max_simt_vf (void);
109extern int omp_constructor_traits_to_codes (tree, enum tree_code *);
110extern tree omp_check_context_selector (location_t loc, tree ctx);
111extern void omp_mark_declare_variant (location_t loc, tree variant,
112 tree construct);
113extern int omp_context_selector_matches (tree);
114extern int omp_context_selector_set_compare (const char *, tree, tree);
115extern tree omp_get_context_selector (tree, const char *, const char *);
116extern tree omp_resolve_declare_variant (tree);
117extern tree oacc_launch_pack (unsigned code, tree device, unsigned op);
118extern tree oacc_replace_fn_attrib_attr (tree attribs, tree dims);
119extern void oacc_replace_fn_attrib (tree fn, tree dims);
120extern void oacc_set_fn_attrib (tree fn, tree clauses, vec<tree> *args);
121extern int oacc_verify_routine_clauses (tree, tree *, location_t,
122 const char *);
123extern tree oacc_build_routine_dims (tree clauses);
124extern tree oacc_get_fn_attrib (tree fn);
125extern bool offloading_function_p (tree fn);
126extern int oacc_get_fn_dim_size (tree fn, int axis);
127extern int oacc_get_ifn_dim_arg (const gimple *stmt);
128
129enum omp_requires {
130 OMP_REQUIRES_ATOMIC_DEFAULT_MEM_ORDER = 0xf,
131 OMP_REQUIRES_UNIFIED_ADDRESS = GOMP_REQUIRES_UNIFIED_ADDRESS,
132 OMP_REQUIRES_UNIFIED_SHARED_MEMORY = GOMP_REQUIRES_UNIFIED_SHARED_MEMORY,
133 OMP_REQUIRES_DYNAMIC_ALLOCATORS = 0x40,
134 OMP_REQUIRES_REVERSE_OFFLOAD = GOMP_REQUIRES_REVERSE_OFFLOAD,
135 OMP_REQUIRES_ATOMIC_DEFAULT_MEM_ORDER_USED = 0x100,
136 OMP_REQUIRES_TARGET_USED = GOMP_REQUIRES_TARGET_USED,
137};
138
139extern GTY(()) enum omp_requires omp_requires_mask;
140
141inline dump_flags_t
142get_openacc_privatization_dump_flags ()
143{
144 dump_flags_t l_dump_flags = MSG_NOTE;
145
146 /* For '--param=openacc-privatization=quiet', diagnostics only go to dump
147 files. */
148 if (param_openacc_privatization == OPENACC_PRIVATIZATION_QUIET)
149 l_dump_flags |= MSG_PRIORITY_INTERNALS;
150
151 return l_dump_flags;
152}
153
154extern tree omp_build_component_ref (tree obj, tree field);
155
156#endif /* GCC_OMP_GENERAL_H */
157

source code of gcc/omp-general.h