https://gcc.gnu.org/g:43e4aeda30546a0767c0fda6e940d7275375dd30
commit 43e4aeda30546a0767c0fda6e940d7275375dd30 Author: Paul-Antoine Arras <par...@baylibre.com> Date: Thu Jan 23 22:58:17 2025 +0100 OpenMP: dispatch + adjust_args tree data structures and front-end interfaces This patch introduces the OMP_DISPATCH tree node, as well as two new clauses `nocontext` and `novariants`. It defines/exposes interfaces that will be used in subsequent patches that add front-end and middle-end support, but nothing generates these nodes yet. gcc/ChangeLog: * builtin-types.def (BT_FN_PTR_CONST_PTR_INT): New. * omp-selectors.h (enum omp_ts_code): Add OMP_TRAIT_CONSTRUCT_DISPATCH. * tree-core.h (enum omp_clause_code): Add OMP_CLAUSE_NOVARIANTS and OMP_CLAUSE_NOCONTEXT. * tree-pretty-print.cc (dump_omp_clause): Handle OMP_CLAUSE_NOVARIANTS and OMP_CLAUSE_NOCONTEXT. (dump_generic_node): Handle OMP_DISPATCH. * tree.cc (omp_clause_num_ops): Add OMP_CLAUSE_NOVARIANTS and OMP_CLAUSE_NOCONTEXT. (omp_clause_code_name): Add "novariants" and "nocontext". * tree.def (OMP_DISPATCH): New. * tree.h (OMP_DISPATCH_BODY): New macro. (OMP_DISPATCH_CLAUSES): New macro. (OMP_CLAUSE_NOVARIANTS_EXPR): New macro. (OMP_CLAUSE_NOCONTEXT_EXPR): New macro. gcc/fortran/ChangeLog: * types.def (BT_FN_PTR_CONST_PTR_INT): Declare. (cherry picked from commit 0e15f1df4ae86cf8542cee6c15ad11b85f968f2e) Diff: --- gcc/ChangeLog.omp | 21 +++++++++++++++++++++ gcc/builtin-types.def | 1 + gcc/fortran/ChangeLog.omp | 7 +++++++ gcc/fortran/types.def | 1 + gcc/omp-selectors.h | 1 + gcc/tree-core.h | 6 ++++++ gcc/tree-pretty-print.cc | 21 +++++++++++++++++++++ gcc/tree.cc | 4 ++++ gcc/tree.def | 5 +++++ gcc/tree.h | 7 +++++++ 10 files changed, 74 insertions(+) diff --git a/gcc/ChangeLog.omp b/gcc/ChangeLog.omp index 89fc9a7dc336..00f7ca13f442 100644 --- a/gcc/ChangeLog.omp +++ b/gcc/ChangeLog.omp @@ -1,3 +1,24 @@ +2025-01-23 Paul-Antoine Arras <par...@baylibre.com> + + Backported from master: + 2024-11-20 Paul-Antoine Arras <par...@baylibre.com> + + * builtin-types.def (BT_FN_PTR_CONST_PTR_INT): New. + * omp-selectors.h (enum omp_ts_code): Add OMP_TRAIT_CONSTRUCT_DISPATCH. + * tree-core.h (enum omp_clause_code): Add OMP_CLAUSE_NOVARIANTS and + OMP_CLAUSE_NOCONTEXT. + * tree-pretty-print.cc (dump_omp_clause): Handle OMP_CLAUSE_NOVARIANTS + and OMP_CLAUSE_NOCONTEXT. + (dump_generic_node): Handle OMP_DISPATCH. + * tree.cc (omp_clause_num_ops): Add OMP_CLAUSE_NOVARIANTS and + OMP_CLAUSE_NOCONTEXT. + (omp_clause_code_name): Add "novariants" and "nocontext". + * tree.def (OMP_DISPATCH): New. + * tree.h (OMP_DISPATCH_BODY): New macro. + (OMP_DISPATCH_CLAUSES): New macro. + (OMP_CLAUSE_NOVARIANTS_EXPR): New macro. + (OMP_CLAUSE_NOCONTEXT_EXPR): New macro. + 2025-01-23 Tobias Burnus <tbur...@baylibre.com> Backported from master: diff --git a/gcc/builtin-types.def b/gcc/builtin-types.def index 28b6da21dc1b..d31b15f0aa9d 100644 --- a/gcc/builtin-types.def +++ b/gcc/builtin-types.def @@ -678,6 +678,7 @@ DEF_FUNCTION_TYPE_2 (BT_FN_INT_FEXCEPT_T_PTR_INT, BT_INT, BT_FEXCEPT_T_PTR, DEF_FUNCTION_TYPE_2 (BT_FN_INT_CONST_FEXCEPT_T_PTR_INT, BT_INT, BT_CONST_FEXCEPT_T_PTR, BT_INT) DEF_FUNCTION_TYPE_2 (BT_FN_PTR_CONST_PTR_UINT8, BT_PTR, BT_CONST_PTR, BT_UINT8) +DEF_FUNCTION_TYPE_2 (BT_FN_PTR_CONST_PTR_INT, BT_PTR, BT_CONST_PTR, BT_INT) DEF_POINTER_TYPE (BT_PTR_FN_VOID_PTR_PTR, BT_FN_VOID_PTR_PTR) diff --git a/gcc/fortran/ChangeLog.omp b/gcc/fortran/ChangeLog.omp index 9e1893e7dc01..5a99b7d37f07 100644 --- a/gcc/fortran/ChangeLog.omp +++ b/gcc/fortran/ChangeLog.omp @@ -1,3 +1,10 @@ +2025-01-23 Paul-Antoine Arras <par...@baylibre.com> + + Backported from master: + 2024-11-20 Paul-Antoine Arras <par...@baylibre.com> + + * types.def (BT_FN_PTR_CONST_PTR_INT): Declare. + 2025-01-23 Tobias Burnus <tbur...@baylibre.com> Backported from master: diff --git a/gcc/fortran/types.def b/gcc/fortran/types.def index 0e3ea057272f..ff6b98b6b00f 100644 --- a/gcc/fortran/types.def +++ b/gcc/fortran/types.def @@ -121,6 +121,7 @@ DEF_FUNCTION_TYPE_2 (BT_FN_BOOL_INT_BOOL, BT_BOOL, BT_INT, BT_BOOL) DEF_FUNCTION_TYPE_2 (BT_FN_VOID_PTR_PTRMODE, BT_VOID, BT_PTR, BT_PTRMODE) DEF_FUNCTION_TYPE_2 (BT_FN_VOID_CONST_PTR_SIZE, BT_VOID, BT_CONST_PTR, BT_SIZE) +DEF_FUNCTION_TYPE_2 (BT_FN_PTR_CONST_PTR_INT, BT_PTR, BT_CONST_PTR, BT_INT) DEF_POINTER_TYPE (BT_PTR_FN_VOID_PTR_PTR, BT_FN_VOID_PTR_PTR) diff --git a/gcc/omp-selectors.h b/gcc/omp-selectors.h index c61808ec0ad1..ef3ce9a449ae 100644 --- a/gcc/omp-selectors.h +++ b/gcc/omp-selectors.h @@ -55,6 +55,7 @@ enum omp_ts_code { OMP_TRAIT_CONSTRUCT_PARALLEL, OMP_TRAIT_CONSTRUCT_FOR, OMP_TRAIT_CONSTRUCT_SIMD, + OMP_TRAIT_CONSTRUCT_DISPATCH, OMP_TRAIT_LAST, OMP_TRAIT_INVALID = -1 }; diff --git a/gcc/tree-core.h b/gcc/tree-core.h index def059b1aad0..d205722cff3d 100644 --- a/gcc/tree-core.h +++ b/gcc/tree-core.h @@ -577,6 +577,12 @@ enum omp_clause_code { /* OpenMP clause: uses_allocators. */ OMP_CLAUSE_USES_ALLOCATORS, + + /* OpenMP clause: novariants (scalar-expression). */ + OMP_CLAUSE_NOVARIANTS, + + /* OpenMP clause: nocontext (scalar-expression). */ + OMP_CLAUSE_NOCONTEXT, }; #undef DEFTREESTRUCT diff --git a/gcc/tree-pretty-print.cc b/gcc/tree-pretty-print.cc index bc4847a6b8fd..d994faead42c 100644 --- a/gcc/tree-pretty-print.cc +++ b/gcc/tree-pretty-print.cc @@ -506,6 +506,22 @@ dump_omp_clause (pretty_printer *pp, tree clause, int spc, dump_flags_t flags) case OMP_CLAUSE_EXCLUSIVE: name = "exclusive"; goto print_remap; + case OMP_CLAUSE_NOVARIANTS: + pp_string (pp, "novariants"); + pp_left_paren (pp); + gcc_assert (OMP_CLAUSE_NOVARIANTS_EXPR (clause)); + dump_generic_node (pp, OMP_CLAUSE_NOVARIANTS_EXPR (clause), spc, flags, + false); + pp_right_paren (pp); + break; + case OMP_CLAUSE_NOCONTEXT: + pp_string (pp, "nocontext"); + pp_left_paren (pp); + gcc_assert (OMP_CLAUSE_NOCONTEXT_EXPR (clause)); + dump_generic_node (pp, OMP_CLAUSE_NOCONTEXT_EXPR (clause), spc, flags, + false); + pp_right_paren (pp); + break; case OMP_CLAUSE__LOOPTEMP_: name = "_looptemp_"; goto print_remap; @@ -4057,6 +4073,11 @@ dump_generic_node (pretty_printer *pp, tree node, int spc, dump_flags_t flags, dump_omp_clauses (pp, OMP_SECTIONS_CLAUSES (node), spc, flags); goto dump_omp_body; + case OMP_DISPATCH: + pp_string (pp, "#pragma omp dispatch"); + dump_omp_clauses (pp, OMP_DISPATCH_CLAUSES (node), spc, flags); + goto dump_omp_body; + case OMP_SECTION: pp_string (pp, "#pragma omp section"); goto dump_omp_body; diff --git a/gcc/tree.cc b/gcc/tree.cc index b0fcced07cf2..6d3124d1f3ac 100644 --- a/gcc/tree.cc +++ b/gcc/tree.cc @@ -334,6 +334,8 @@ unsigned const char omp_clause_num_ops[] = 0, /* OMP_CLAUSE_FINALIZE */ 0, /* OMP_CLAUSE_NOHOST */ 3, /* OMP_CLAUSE_USES_ALLOCATORS */ + 1, /* OMP_CLAUSE_NOVARIANTS */ + 1, /* OMP_CLAUSE_NOCONTEXT */ }; const char * const omp_clause_code_name[] = @@ -433,6 +435,8 @@ const char * const omp_clause_code_name[] = "finalize", "nohost", "uses_allocators", + "novariants", + "nocontext", }; /* Unless specific to OpenACC, we tend to internally maintain OpenMP-centric diff --git a/gcc/tree.def b/gcc/tree.def index 81b96c714e73..6c2bf6a5479d 100644 --- a/gcc/tree.def +++ b/gcc/tree.def @@ -1298,6 +1298,11 @@ DEFTREECODE (OMP_MASKED, "omp_masked", tcc_statement, 2) Operand 1: OMP_SCAN_CLAUSES: List of clauses. */ DEFTREECODE (OMP_SCAN, "omp_scan", tcc_statement, 2) +/* OpenMP - #pragma omp dispatch [clause1 ... clauseN] + Operand 0: OMP_DISPATCH_BODY: Expression statement including a target call. + Operand 1: OMP_DISPATCH_CLAUSES: List of clauses. */ +DEFTREECODE (OMP_DISPATCH, "omp_dispatch", tcc_statement, 2) + /* OpenMP - #pragma omp section Operand 0: OMP_SECTION_BODY: Section body. */ DEFTREECODE (OMP_SECTION, "omp_section", tcc_statement, 1) diff --git a/gcc/tree.h b/gcc/tree.h index 53b1aed44357..812b08a6a113 100644 --- a/gcc/tree.h +++ b/gcc/tree.h @@ -1613,6 +1613,9 @@ class auto_suppress_location_wrappers #define OMP_SCAN_BODY(NODE) TREE_OPERAND (OMP_SCAN_CHECK (NODE), 0) #define OMP_SCAN_CLAUSES(NODE) TREE_OPERAND (OMP_SCAN_CHECK (NODE), 1) +#define OMP_DISPATCH_BODY(NODE) TREE_OPERAND (OMP_DISPATCH_CHECK (NODE), 0) +#define OMP_DISPATCH_CLAUSES(NODE) TREE_OPERAND (OMP_DISPATCH_CHECK (NODE), 1) + #define OMP_CLAUSE_SIZE(NODE) \ OMP_CLAUSE_OPERAND (OMP_CLAUSE_RANGE_CHECK (OMP_CLAUSE_CHECK (NODE), \ OMP_CLAUSE_FROM, \ @@ -1760,6 +1763,10 @@ class auto_suppress_location_wrappers OMP_CLAUSE_OPERAND (OMP_CLAUSE_SUBCODE_CHECK (NODE, OMP_CLAUSE_PARTIAL), 0) #define OMP_CLAUSE_SIZES_LIST(NODE) \ OMP_CLAUSE_OPERAND (OMP_CLAUSE_SUBCODE_CHECK (NODE, OMP_CLAUSE_SIZES), 0) +#define OMP_CLAUSE_NOVARIANTS_EXPR(NODE) \ + OMP_CLAUSE_OPERAND (OMP_CLAUSE_SUBCODE_CHECK (NODE, OMP_CLAUSE_NOVARIANTS), 0) +#define OMP_CLAUSE_NOCONTEXT_EXPR(NODE) \ + OMP_CLAUSE_OPERAND (OMP_CLAUSE_SUBCODE_CHECK (NODE, OMP_CLAUSE_NOCONTEXT), 0) #define OMP_CLAUSE_GRAINSIZE_EXPR(NODE) \ OMP_CLAUSE_OPERAND (OMP_CLAUSE_SUBCODE_CHECK (NODE, OMP_CLAUSE_GRAINSIZE),0)