OpenMP 5.0 adds support for non-rectangular loop collapses, e.g. triangular and more complex. This patch deals just with the diagnostics so that they aren't rejected immediately as before. As the spec generally requires as before that the iteration variable initializer and bound in the comparison as invariant vs. the outermost loop, and just add some exceptional forms that can violate that, we need to avoid folding the expressions until we can detect them and in order to avoid folding it later on, I chose to use a TREE_VEC in those expressions to hold the var_outer * expr1 + expr2 triplet, the patch adds pretty-printing of that, gimplification etc. and just sorry_at during omp expansion for now. The next step will be to implement the different cases of that one by one. 2020-06-16 Jakub Jelinek <jakub@redhat.com> gcc/ * tree.h (OMP_FOR_NON_RECTANGULAR): Define. * gimplify.c (gimplify_omp_for): Diagnose schedule, ordered or dist_schedule clause on non-rectangular loops. Handle gimplification of non-rectangular lb/b expressions. When changing iteration variable, adjust also non-rectangular lb/b expressions referencing that. * omp-general.h (struct omp_for_data_loop): Add m1, m2 and outer members. (struct omp_for_data): Add non_rect member. * omp-general.c (omp_extract_for_data): Handle non-rectangular loops. Fill in non_rect, m1, m2 and outer. * omp-low.c (lower_omp_for): Handle non-rectangular lb/b expressions. * omp-expand.c (expand_omp_for): Emit sorry_at for unsupported non-rectangular loop cases and assert for cases that can't be non-rectangular. * tree-pretty-print.c (dump_mem_ref): Formatting fix. (dump_omp_loop_non_rect_expr): New function. (dump_generic_node): Handle non-rectangular OpenMP loops. * tree-pretty-print.h (dump_omp_loop_non_rect_expr): Declare. * gimple-pretty-print.c (dump_gimple_omp_for): Handle non-rectangular OpenMP loops. gcc/c-family/ * c-common.h (c_omp_check_loop_iv_exprs): Add an int argument. * c-omp.c (struct c_omp_check_loop_iv_data): Add maybe_nonrect and idx members. (c_omp_is_loop_iterator): New function. (c_omp_check_loop_iv_r): Use it. Add support for silent scanning if outer loop iterator is present. Perform duplicate checking through hash_set in the function rather than expecting caller to do that. Pass NULL instead of d->ppset to walk_tree_1. (c_omp_check_nonrect_loop_iv): New function. (c_omp_check_loop_iv): Use it. Fill in new members, allow non-rectangular loop forms, diagnose multiple associated loops with the same iterator. Pass NULL instead of &pset to walk_tree_1. (c_omp_check_loop_iv_exprs): Likewise. gcc/c/ * c-parser.c (c_parser_expr_no_commas): Save, clear and restore c_in_omp_for. (c_parser_omp_for_loop): Set c_in_omp_for around some calls to avoid premature c_fully_fold. Defer explicit c_fully_fold calls to after c_finish_omp_for. * c-tree.h (c_in_omp_for): Declare. * c-typeck.c (c_in_omp_for): Define. (build_modify_expr): Avoid c_fully_fold if c_in_omp_for. (digest_init): Likewise. (build_binary_op): Likewise. gcc/cp/ * semantics.c (handle_omp_for_class_iterator): Adjust c_omp_check_loop_iv_exprs caller. (finish_omp_for): Likewise. Don't call fold_build_cleanup_point_expr before calling c_finish_omp_for and c_omp_check_loop_iv, move it after those calls. * pt.c (tsubst_omp_for_iterator): Handle non-rectangular loops. gcc/testsuite/ * c-c++-common/gomp/loop-6.c: New test. * gcc.dg/gomp/loop-1.c: Don't expect diagnostics on valid non-rectangular loops. * gcc.dg/gomp/loop-2.c: New test. * g++.dg/gomp/loop-1.C: Don't expect diagnostics on valid non-rectangular loops. * g++.dg/gomp/loop-2.C: Likewise. * g++.dg/gomp/loop-5.C: New test. * g++.dg/gomp/loop-6.C: New test.
61 lines
2.6 KiB
C
61 lines
2.6 KiB
C
/* Various declarations for language-independent pretty-print
|
|
subroutines that are only for use in the compilers proper and not
|
|
the driver or other programs.
|
|
Copyright (C) 2002-2020 Free Software Foundation, Inc.
|
|
|
|
This file is part of GCC.
|
|
|
|
GCC is free software; you can redistribute it and/or modify it under
|
|
the terms of the GNU General Public License as published by the Free
|
|
Software Foundation; either version 3, or (at your option) any later
|
|
version.
|
|
|
|
GCC is distributed in the hope that it will be useful, but WITHOUT ANY
|
|
WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
|
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
|
for more details.
|
|
|
|
You should have received a copy of the GNU General Public License
|
|
along with GCC; see the file COPYING3. If not see
|
|
<http://www.gnu.org/licenses/>. */
|
|
|
|
#ifndef GCC_TREE_PRETTY_PRINT_H
|
|
#define GCC_TREE_PRETTY_PRINT_H
|
|
|
|
#include "pretty-print.h"
|
|
|
|
#define pp_unsupported_tree(PP, T) \
|
|
pp_verbatim (PP, "%qs not supported by %s", \
|
|
get_tree_code_name (TREE_CODE (T)), __FUNCTION__)
|
|
|
|
#define pp_ti_abstract_origin(TI) ((tree *) (TI)->x_data)
|
|
|
|
|
|
extern void debug_generic_expr (tree);
|
|
extern void debug_generic_stmt (tree);
|
|
extern void debug_tree_chain (tree);
|
|
extern void print_generic_decl (FILE *, tree, dump_flags_t);
|
|
extern void print_generic_stmt (FILE *, tree, dump_flags_t = TDF_NONE);
|
|
extern void print_generic_stmt_indented (FILE *, tree, dump_flags_t, int);
|
|
extern void print_generic_expr (FILE *, tree, dump_flags_t = TDF_NONE);
|
|
extern char *print_generic_expr_to_str (tree);
|
|
extern void dump_omp_clauses (pretty_printer *, tree, int, dump_flags_t);
|
|
extern void dump_omp_atomic_memory_order (pretty_printer *,
|
|
enum omp_memory_order);
|
|
extern void dump_omp_loop_non_rect_expr (pretty_printer *, tree, int,
|
|
dump_flags_t);
|
|
extern int dump_generic_node (pretty_printer *, tree, int, dump_flags_t, bool);
|
|
extern void print_declaration (pretty_printer *, tree, int, dump_flags_t);
|
|
extern int op_code_prio (enum tree_code);
|
|
extern int op_prio (const_tree);
|
|
extern const char *op_symbol_code (enum tree_code);
|
|
extern void pretty_print_string (pretty_printer *, const char *, size_t);
|
|
extern void print_call_name (pretty_printer *, tree, dump_flags_t);
|
|
extern void percent_K_format (text_info *, location_t, tree);
|
|
extern void pp_tree_identifier (pretty_printer *, tree);
|
|
extern void dump_function_header (FILE *, tree, dump_flags_t);
|
|
extern void pp_double_int (pretty_printer *pp, double_int d, bool uns);
|
|
extern void dump_location (pretty_printer *buffer, location_t loc);
|
|
|
|
#endif /* ! GCC_TREE_PRETTY_PRINT_H */
|