From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from esa3.mentor.iphmx.com (esa3.mentor.iphmx.com [68.232.137.180]) by sourceware.org (Postfix) with ESMTPS id 5F7E03888C65; Fri, 18 Mar 2022 16:28:16 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 5F7E03888C65 Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=codesourcery.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=mentor.com X-IronPort-AV: E=Sophos;i="5.90,192,1643702400"; d="scan'208";a="73169614" Received: from orw-gwy-02-in.mentorg.com ([192.94.38.167]) by esa3.mentor.iphmx.com with ESMTP; 18 Mar 2022 08:28:16 -0800 IronPort-SDR: bPtT8QHXgw+rMKDaUEyswxPLXZJCgeIYYw3pmCc8shjcW/8hLJKZTUHvUkqrOXOWv4xGwYLQAv +XqQT3NerMZjwgz7JPLvAlygBrPJFrRaOWQjoaf9UcWVlH8/2W0V2ylghAjWnXybhuOCg83yV0 /X2uMKfdPtkE3Tcrc24yv7Khqkypu/joR8UbHRUU6UXgHFOiYALGYSYKMtigWiMpczpUy6l6kJ 9G0gsVjshlYUNgjwNHqTf88vnOuP9Dh6YtaP6paLFjlRmHF7AQbzttlj1l+Ng8Cfd8+HDRb/PL UYo= From: Julian Brown To: CC: Jakub Jelinek , Thomas Schwinge , Tobias Burnus , Fortran List Subject: [PATCH v2 10/11] OpenMP: Use OMP_ARRAY_SECTION instead of TREE_LIST for array sections in C FE Date: Fri, 18 Mar 2022 09:28:05 -0700 Message-ID: <67bc13bbf311cd7d1181605c3a4b8f50d11bab68.1647619145.git.julian@codesourcery.com> X-Mailer: git-send-email 2.29.2 In-Reply-To: References: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Content-Type: text/plain X-Originating-IP: [137.202.0.90] X-ClientProxiedBy: svr-ies-mbx-06.mgc.mentorg.com (139.181.222.6) To SVR-IES-MBX-04.mgc.mentorg.com (139.181.222.4) X-Spam-Status: No, score=-11.8 required=5.0 tests=BAYES_00, GIT_PATCH_0, HEADER_FROM_DIFFERENT_DOMAINS, KAM_DMARC_STATUS, SPF_HELO_PASS, SPF_PASS, TXREP, T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.4 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on server2.sourceware.org X-BeenThere: fortran@gcc.gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Fortran mailing list List-Unsubscribe: , List-Archive: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 18 Mar 2022 16:28:18 -0000 This patch uses the new OMP_ARRAY_SECTION tree code to represent OpenMP array sections, rather than TREE_LIST. As for the C++ FE, using TREE_LIST becomes unwieldy when the array-section representation sticks around for longer due to adding "declare mapper" support. We must be a little careful here because OMP_CLAUSE_DEPEND and OMP_CLAUSE_AFFINITY also use TREE_LIST for their own purposes, and we're not changing those ones. No behavioural changes should be introduced by this patch. 2022-03-04 Julian Brown gcc/c/ * c-parser.cc (c_parser_omp_variable_list): Use OMP_ARRAY_SECTION instead of TREE_LIST for array sections. (c_parser_omp_clause_reduction): Likewise. * c-typeck.cc (handle_omp_array_sections_1, handle_omp_array_sections, c_oacc_check_attachments, c_finish_omp_clauses): Likewise. --- gcc/c/c-parser.cc | 21 +++++++++++++++------ gcc/c/c-typeck.cc | 37 +++++++++++++++++++------------------ 2 files changed, 34 insertions(+), 24 deletions(-) diff --git a/gcc/c/c-parser.cc b/gcc/c/c-parser.cc index cc590e56e75..1ca03b6a632 100644 --- a/gcc/c/c-parser.cc +++ b/gcc/c/c-parser.cc @@ -13165,16 +13165,20 @@ c_parser_omp_variable_list (c_parser *parser, } for (int i = dims.length () - 1; i >= 0; i--) - decl = tree_cons (dims[i].low_bound, dims[i].length, decl); + decl = build3_loc (loc, OMP_ARRAY_SECTION, TREE_TYPE (decl), + decl, dims[i].low_bound, dims[i].length); } else if (TREE_CODE (decl) == INDIRECT_REF) { + tree type = TREE_TYPE (decl); + /* Turn *foo into the representation previously used for foo[0]. */ decl = TREE_OPERAND (decl, 0); STRIP_NOPS (decl); - decl = tree_cons (integer_zero_node, integer_one_node, decl); + decl = build3_loc (loc, OMP_ARRAY_SECTION, type, decl, + integer_zero_node, integer_one_node); } else if (TREE_CODE (decl) == ARRAY_REF) { @@ -13183,7 +13187,8 @@ c_parser_omp_variable_list (c_parser *parser, decl = TREE_OPERAND (decl, 0); STRIP_NOPS (decl); - decl = tree_cons (idx, integer_one_node, decl); + decl = build3_loc (loc, OMP_ARRAY_SECTION, TREE_TYPE (decl), + decl, idx, integer_one_node); } else if (TREE_CODE (decl) == NON_LVALUE_EXPR || CONVERT_EXPR_P (decl)) @@ -13345,7 +13350,9 @@ c_parser_omp_variable_list (c_parser *parser, } else for (unsigned i = 0; i < dims.length (); i++) - t = tree_cons (dims[i].low_bound, dims[i].length, t); + t = build3_loc (clause_loc, OMP_ARRAY_SECTION, + TREE_TYPE (t), t, dims[i].low_bound, + dims[i].length); } if ((kind == OMP_CLAUSE_DEPEND || kind == OMP_CLAUSE_AFFINITY) @@ -15061,13 +15068,15 @@ c_parser_omp_clause_reduction (c_parser *parser, enum omp_clause_code kind, for (c = nl; c != list; c = OMP_CLAUSE_CHAIN (c)) { tree d = OMP_CLAUSE_DECL (c), type; - if (TREE_CODE (d) != TREE_LIST) + if (TREE_CODE (d) != OMP_ARRAY_SECTION) type = TREE_TYPE (d); else { int cnt = 0; tree t; - for (t = d; TREE_CODE (t) == TREE_LIST; t = TREE_CHAIN (t)) + for (t = d; + TREE_CODE (t) == OMP_ARRAY_SECTION; + t = TREE_OPERAND (t, 0)) cnt++; type = TREE_TYPE (t); while (cnt > 0) diff --git a/gcc/c/c-typeck.cc b/gcc/c/c-typeck.cc index 162ed0a18a2..98212c6b7f5 100644 --- a/gcc/c/c-typeck.cc +++ b/gcc/c/c-typeck.cc @@ -13218,7 +13218,7 @@ handle_omp_array_sections_1 (tree c, tree t, vec &types, enum c_omp_region_type ort) { tree ret, low_bound, length, type; - if (TREE_CODE (t) != TREE_LIST) + if (TREE_CODE (t) != OMP_ARRAY_SECTION) { if (error_operand_p (t)) return error_mark_node; @@ -13293,14 +13293,14 @@ handle_omp_array_sections_1 (tree c, tree t, vec &types, return ret; } - ret = handle_omp_array_sections_1 (c, TREE_CHAIN (t), types, + ret = handle_omp_array_sections_1 (c, TREE_OPERAND (t, 0), types, maybe_zero_len, first_non_one, ort); if (ret == error_mark_node || ret == NULL_TREE) return ret; type = TREE_TYPE (ret); - low_bound = TREE_PURPOSE (t); - length = TREE_VALUE (t); + low_bound = TREE_OPERAND (t, 1); + length = TREE_OPERAND (t, 2); if (low_bound == error_mark_node || length == error_mark_node) return error_mark_node; @@ -13493,7 +13493,7 @@ handle_omp_array_sections_1 (tree c, tree t, vec &types, tree lb = save_expr (low_bound); if (lb != low_bound) { - TREE_PURPOSE (t) = lb; + TREE_OPERAND (t, 1) = lb; low_bound = lb; } } @@ -13524,14 +13524,15 @@ handle_omp_array_sections_1 (tree c, tree t, vec &types, array-section-subscript, the array section could be non-contiguous. */ if (OMP_CLAUSE_CODE (c) != OMP_CLAUSE_DEPEND && OMP_CLAUSE_CODE (c) != OMP_CLAUSE_AFFINITY - && TREE_CODE (TREE_CHAIN (t)) == TREE_LIST) + && TREE_CODE (TREE_OPERAND (t, 0)) == OMP_ARRAY_SECTION) { /* If any prior dimension has a non-one length, then deem this array section as non-contiguous. */ - for (tree d = TREE_CHAIN (t); TREE_CODE (d) == TREE_LIST; - d = TREE_CHAIN (d)) + for (tree d = TREE_OPERAND (t, 0); + TREE_CODE (d) == OMP_ARRAY_SECTION; + d = TREE_OPERAND (d, 0)) { - tree d_length = TREE_VALUE (d); + tree d_length = TREE_OPERAND (d, 2); if (d_length == NULL_TREE || !integer_onep (d_length)) { error_at (OMP_CLAUSE_LOCATION (c), @@ -13554,7 +13555,7 @@ handle_omp_array_sections_1 (tree c, tree t, vec &types, tree lb = save_expr (low_bound); if (lb != low_bound) { - TREE_PURPOSE (t) = lb; + TREE_OPERAND (t, 1) = lb; low_bound = lb; } ret = build_array_ref (OMP_CLAUSE_LOCATION (c), ret, low_bound); @@ -13617,10 +13618,10 @@ handle_omp_array_sections (tree c, enum c_omp_region_type ort) maybe_zero_len = true; for (i = num, t = OMP_CLAUSE_DECL (c); i > 0; - t = TREE_CHAIN (t)) + t = TREE_OPERAND (t, 0)) { - tree low_bound = TREE_PURPOSE (t); - tree length = TREE_VALUE (t); + tree low_bound = TREE_OPERAND (t, 1); + tree length = TREE_OPERAND (t, 2); i--; if (low_bound @@ -14069,8 +14070,8 @@ c_oacc_check_attachments (tree c) { tree t = OMP_CLAUSE_DECL (c); - while (TREE_CODE (t) == TREE_LIST) - t = TREE_CHAIN (t); + while (TREE_CODE (t) == OMP_ARRAY_SECTION) + t = TREE_OPERAND (t, 0); if (TREE_CODE (TREE_TYPE (t)) != POINTER_TYPE) { @@ -14170,7 +14171,7 @@ c_finish_omp_clauses (tree clauses, enum c_omp_region_type ort) case OMP_CLAUSE_TASK_REDUCTION: need_implicitly_determined = true; t = OMP_CLAUSE_DECL (c); - if (TREE_CODE (t) == TREE_LIST) + if (TREE_CODE (t) == OMP_ARRAY_SECTION) { if (handle_omp_array_sections (c, ort)) { @@ -14790,7 +14791,7 @@ c_finish_omp_clauses (tree clauses, enum c_omp_region_type ort) } else last_iterators = NULL_TREE; - if (TREE_CODE (t) == TREE_LIST) + if (TREE_CODE (t) == OMP_ARRAY_SECTION) { if (handle_omp_array_sections (c, ort)) remove = true; @@ -14876,7 +14877,7 @@ c_finish_omp_clauses (tree clauses, enum c_omp_region_type ort) case OMP_CLAUSE_FROM: case OMP_CLAUSE__CACHE_: t = OMP_CLAUSE_DECL (c); - if (TREE_CODE (t) == TREE_LIST) + if (TREE_CODE (t) == OMP_ARRAY_SECTION) { if (handle_omp_array_sections (c, ort)) remove = true; -- 2.29.2