From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 12883 invoked by alias); 25 Jan 2006 17:41:29 -0000 Received: (qmail 12871 invoked by uid 22791); 25 Jan 2006 17:41:25 -0000 X-Spam-Check-By: sourceware.org Received: from mx1.redhat.com (HELO mx1.redhat.com) (66.187.233.31) by sourceware.org (qpsmtpd/0.31) with ESMTP; Wed, 25 Jan 2006 17:41:21 +0000 Received: from int-mx1.corp.redhat.com (int-mx1.corp.redhat.com [172.16.52.254]) by mx1.redhat.com (8.12.11/8.12.11) with ESMTP id k0PHfJpK010104 for ; Wed, 25 Jan 2006 12:41:19 -0500 Received: from pobox.toronto.redhat.com (pobox.toronto.redhat.com [172.16.14.4]) by int-mx1.corp.redhat.com (8.11.6/8.11.6) with ESMTP id k0PHfG124929; Wed, 25 Jan 2006 12:41:16 -0500 Received: from [127.0.0.1] (sebastian-int.corp.redhat.com [172.16.52.221]) by pobox.toronto.redhat.com (8.12.8/8.12.8) with ESMTP id k0PHfEje008310; Wed, 25 Jan 2006 12:41:14 -0500 Message-ID: <43D7B83A.3060802@redhat.com> Date: Wed, 25 Jan 2006 18:05:00 -0000 From: Diego Novillo User-Agent: Thunderbird 1.5 (X11/20051201) MIME-Version: 1.0 To: gcc-patches@gcc.gnu.org CC: Richard Henderson Subject: Fix PR 25886. Convert OMP_CLAUSE_* into sub-codes. Content-Type: multipart/mixed; boundary="------------000706080000000102060808" X-IsSubscribed: yes Mailing-List: contact gcc-patches-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Archive: List-Post: List-Help: Sender: gcc-patches-owner@gcc.gnu.org X-SW-Source: 2006-01/txt/msg01748.txt.bz2 This is a multi-part message in MIME format. --------------000706080000000102060808 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit Content-length: 1341 This patch replaces all the OMP_CLAUSE_* tree codes with a single OMP_CLAUSE tree with sub-codes. This avoids the code space overflow in languages with more than 256 tree codes. Although this could be used as template for a generic sub-code solution, it's not clear to me whether the benefit would be worth the effort and we are already entering stage 2. Sub-coding other trees is likely to be pretty invasive. The idea is pretty straightforward. OMP_CLAUSE_* codes are now a separate enum that lives in tree_omp_clause. Clauses can also have sub-codes of their own (for reduction, schedule and default), which prevents us from stealing a random field from some other tree structure (we were using TREE_COMPLEXITY before and should provide a bit stronger typing. Other than that, the changes were mechanical search and replace, compounded by the annoyance that most of the typing mistakes are exposed at runtime via ICEs or dereferences into invalid memory. There are two changes not directly related to the actual fix: 1- The range predicate in TREE_RANGE_CHECK was using && instead of ||. 2- TREE_BLOCK was not using EXPR_CHECK to make sure it was dealing with an expr node. Bootstrapped and tested on x86, x86-64 and ppc64. OK for mainline? I'll apply the C++ and Fortran changes to the gomp branch after this is approved. --------------000706080000000102060808 Content-Type: text/x-patch; name="20060125-subcodes-for-omp-clauses.diff" Content-Transfer-Encoding: 7bit Content-Disposition: inline; filename="20060125-subcodes-for-omp-clauses.diff" Content-length: 48144 2006-01-25 Diego Novillo * tree.h (TREE_RANGE_CHECK): Fix range predicate. (TREE_BLOCK): Add call to EXPR_CHECK. 2006-01-25 Diego Novillo PR 25886 * tree-dump.c (dequeue_and_dump): Handle OMP_CLAUSE. * tree-pretty-print.c (dump_omp_clause): Extract from ... (dump_omp_clauses): ... here. (dump_generic_node): Handle OMP_CLAUSE. * tree.c (omp_clause_num_ops): New. (omp_clause_code_name): New. (tree_code_size): Handle OMP_CLAUSE. (tree_size): Likewise. (make_node): Document handling of OMP_CLAUSE. (tree_node_structure): Handle OMP_CLAUSE. (omp_clause_check_failed): New. (omp_clause_range_check_failed): New. (omp_clause_operand_check_failed): New. (build_omp_clause): New. (walk_tree): Adjust handling of OMP_CLAUSE_* nodes. * tree.h (enum omp_clause_code): Declare. (OMP_CLAUSE_SUBCODE): Define. (OMP_CLAUSE_RANGE_CHECK): Define. (OMP_CLAUSE_ELT_CHECK): Define. (omp_clause_check_failed): Declare. (omp_clause_operand_check_failed): Declare. (omp_clause_range_check_failed): Declare. (OMP_CLAUSE_CHAIN): Do not use TREE_RANGE_CHECK. (OMP_CLAUSE_OPERAND): Use OMP_CLAUSE_RANGE_CHECK. (OMP_CLAUSE_PRIVATE_DEBUG): Use OMP_CLAUSE_SUBCODE_CHECK. (OMP_CLAUSE_LASTPRIVATE): Likewise. (OMP_CLAUSE_IF_EXPR): Likewise. (OMP_CLAUSE_NUM_THREADS_EXPR): Likewise. (OMP_CLAUSE_SCHEDULE_CHUNK_EXPR): Likewise. (OMP_CLAUSE_REDUCTION_CODE): Likewise. (OMP_CLAUSE_REDUCTION_INIT): Likewise. (OMP_CLAUSE_REDUCTION_MERGE): Likewise. (OMP_CLAUSE_REDUCTION_PLACEHOLDER): Likewise. Use tree_node.omp_clause.subcode instead of TREE_COMPLEXITY. (OMP_CLAUSE_SCHEDULE_KIND): Likewise. (OMP_CLAUSE_DEFAULT_KIND): Likewise. (OMP_CLAUSE_CODE): Define. (OMP_CLAUSE_SET_CODE): Define. (OMP_CLAUSE_CODE): Define. (OMP_CLAUSE_OPERAND): Define. (struct tree_omp_clause): Declare. (union tree_node): Add field 'omp_clause'. * treestruct.def (TS_OMP_CLAUSE): Define. * tree.def (OMP_CLAUSE_PRIVATE, OMP_CLAUSE_SHARED OMP_CLAUSE_FIRSTPRIVATE, OMP_CLAUSE_LASTPRIVATE, OMP_CLAUSE_REDUCTION, OMP_CLAUSE_COPYIN, OMP_CLAUSE_COPYPRIVATE, OMP_CLAUSE_IF, OMP_CLAUSE_NUM_THREADS, OMP_CLAUSE_SCHEDULE, OMP_CLAUSE_NOWAIT, OMP_CLAUSE_ORDERED, OMP_CLAUSE_DEFAULT): Remove. (OMP_CLAUSE): Define. * print-tree.c (print_node): Handle OMP_CLAUSE. * omp-low.c: Adapt all uses of OMP_CLAUSE_* nodes. * c-typeck.c: Likewise. * gimplify.c: Likewise. * c-omp.c: Likewise. * tree-nested.c: Likewise. * tree-inline.c: Likewise. * c-parser.c: Likewise. * gimple-low.c (lower_omp_directive): Do not set TREE_BLOCK on clauses. Index: tree-dump.c =================================================================== --- tree-dump.c (revision 110178) +++ tree-dump.c (working copy) @@ -653,6 +653,14 @@ dequeue_and_dump (dump_info_p di) dump_child ("labl", TREE_OPERAND (t,2)); } break; + case OMP_CLAUSE: + { + int i; + fprintf (di->stream, "%s\n", omp_clause_code_name[OMP_CLAUSE_CODE (t)]); + for (i = 0; i < omp_clause_num_ops[OMP_CLAUSE_CODE (t)]; i++) + dump_child ("op: ", OMP_CLAUSE_OPERAND (t, i)); + } + break; default: /* There are no additional fields to print. */ break; Index: tree-pretty-print.c =================================================================== --- tree-pretty-print.c (revision 110178) +++ tree-pretty-print.c (working copy) @@ -263,133 +263,144 @@ dump_array_domain (pretty_printer *buffe pp_character (buffer, ']'); } -/* Dump the list of OpenMP clauses. */ + +/* Dump OpenMP clause CLAUSE. BUFFER, CLAUSE, SPC and FLAGS are as in + dump_generic_node. */ static void -dump_omp_clauses (pretty_printer *buffer, tree clause, int spc, int flags) +dump_omp_clause (pretty_printer *buffer, tree clause, int spc, int flags) { const char *name; - if (clause == NULL) - return; - - pp_space (buffer); - while (1) + switch (OMP_CLAUSE_CODE (clause)) { - switch (TREE_CODE (clause)) - { - case OMP_CLAUSE_PRIVATE: - name = "private"; - goto print_remap; - case OMP_CLAUSE_SHARED: - name = "shared"; - goto print_remap; - case OMP_CLAUSE_FIRSTPRIVATE: - name = "firstprivate"; - goto print_remap; - case OMP_CLAUSE_LASTPRIVATE: - name = "lastprivate"; - goto print_remap; - case OMP_CLAUSE_COPYIN: - name = "copyin"; - goto print_remap; - case OMP_CLAUSE_COPYPRIVATE: - name = "copyprivate"; - goto print_remap; - print_remap: - pp_string (buffer, name); - pp_character (buffer, '('); - dump_generic_node (buffer, OMP_CLAUSE_DECL (clause), - spc, flags, false); - pp_character (buffer, ')'); - break; - - case OMP_CLAUSE_REDUCTION: - pp_string (buffer, "reduction("); - pp_string (buffer, op_symbol_1 (OMP_CLAUSE_REDUCTION_CODE (clause))); - pp_character (buffer, ':'); - dump_generic_node (buffer, OMP_CLAUSE_DECL (clause), - spc, flags, false); - pp_character (buffer, ')'); - break; + case OMP_CLAUSE_PRIVATE: + name = "private"; + goto print_remap; + case OMP_CLAUSE_SHARED: + name = "shared"; + goto print_remap; + case OMP_CLAUSE_FIRSTPRIVATE: + name = "firstprivate"; + goto print_remap; + case OMP_CLAUSE_LASTPRIVATE: + name = "lastprivate"; + goto print_remap; + case OMP_CLAUSE_COPYIN: + name = "copyin"; + goto print_remap; + case OMP_CLAUSE_COPYPRIVATE: + name = "copyprivate"; + goto print_remap; + print_remap: + pp_string (buffer, name); + pp_character (buffer, '('); + dump_generic_node (buffer, OMP_CLAUSE_DECL (clause), + spc, flags, false); + pp_character (buffer, ')'); + break; - case OMP_CLAUSE_IF: - pp_string (buffer, "if("); - dump_generic_node (buffer, OMP_CLAUSE_IF_EXPR (clause), - spc, flags, false); - pp_character (buffer, ')'); - break; + case OMP_CLAUSE_REDUCTION: + pp_string (buffer, "reduction("); + pp_string (buffer, op_symbol_1 (OMP_CLAUSE_REDUCTION_CODE (clause))); + pp_character (buffer, ':'); + dump_generic_node (buffer, OMP_CLAUSE_DECL (clause), + spc, flags, false); + pp_character (buffer, ')'); + break; - case OMP_CLAUSE_NUM_THREADS: - pp_string (buffer, "num_threads("); - dump_generic_node (buffer, OMP_CLAUSE_NUM_THREADS_EXPR (clause), - spc, flags, false); - pp_character (buffer, ')'); - break; + case OMP_CLAUSE_IF: + pp_string (buffer, "if("); + dump_generic_node (buffer, OMP_CLAUSE_IF_EXPR (clause), + spc, flags, false); + pp_character (buffer, ')'); + break; - case OMP_CLAUSE_NOWAIT: - pp_string (buffer, "nowait"); - break; - case OMP_CLAUSE_ORDERED: - pp_string (buffer, "ordered"); - break; + case OMP_CLAUSE_NUM_THREADS: + pp_string (buffer, "num_threads("); + dump_generic_node (buffer, OMP_CLAUSE_NUM_THREADS_EXPR (clause), + spc, flags, false); + pp_character (buffer, ')'); + break; - case OMP_CLAUSE_DEFAULT: - pp_string (buffer, "default("); - switch (OMP_CLAUSE_DEFAULT_KIND (clause)) - { - case OMP_CLAUSE_DEFAULT_UNSPECIFIED: - break; - case OMP_CLAUSE_DEFAULT_SHARED: - pp_string (buffer, "shared"); - break; - case OMP_CLAUSE_DEFAULT_NONE: - pp_string (buffer, "none"); - break; - case OMP_CLAUSE_DEFAULT_PRIVATE: - pp_string (buffer, "private"); - break; - default: - gcc_unreachable (); - } - pp_character (buffer, ')'); - break; + case OMP_CLAUSE_NOWAIT: + pp_string (buffer, "nowait"); + break; + case OMP_CLAUSE_ORDERED: + pp_string (buffer, "ordered"); + break; - case OMP_CLAUSE_SCHEDULE: - pp_string (buffer, "schedule("); - switch (OMP_CLAUSE_SCHEDULE_KIND (clause)) - { - case OMP_CLAUSE_SCHEDULE_STATIC: - pp_string (buffer, "static"); - break; - case OMP_CLAUSE_SCHEDULE_DYNAMIC: - pp_string (buffer, "dynamic"); - break; - case OMP_CLAUSE_SCHEDULE_GUIDED: - pp_string (buffer, "guided"); - break; - case OMP_CLAUSE_SCHEDULE_RUNTIME: - pp_string (buffer, "runtime"); - break; - default: - gcc_unreachable (); - } - if (OMP_CLAUSE_SCHEDULE_CHUNK_EXPR (clause)) - { - pp_character (buffer, ','); - dump_generic_node (buffer, - OMP_CLAUSE_SCHEDULE_CHUNK_EXPR (clause), - spc, flags, false); - } - pp_character (buffer, ')'); - break; + case OMP_CLAUSE_DEFAULT: + pp_string (buffer, "default("); + switch (OMP_CLAUSE_DEFAULT_KIND (clause)) + { + case OMP_CLAUSE_DEFAULT_UNSPECIFIED: + break; + case OMP_CLAUSE_DEFAULT_SHARED: + pp_string (buffer, "shared"); + break; + case OMP_CLAUSE_DEFAULT_NONE: + pp_string (buffer, "none"); + break; + case OMP_CLAUSE_DEFAULT_PRIVATE: + pp_string (buffer, "private"); + break; + default: + gcc_unreachable (); + } + pp_character (buffer, ')'); + break; - default: - /* Should never happen. */ - dump_generic_node (buffer, clause, spc, flags, false); - break; + case OMP_CLAUSE_SCHEDULE: + pp_string (buffer, "schedule("); + switch (OMP_CLAUSE_SCHEDULE_KIND (clause)) + { + case OMP_CLAUSE_SCHEDULE_STATIC: + pp_string (buffer, "static"); + break; + case OMP_CLAUSE_SCHEDULE_DYNAMIC: + pp_string (buffer, "dynamic"); + break; + case OMP_CLAUSE_SCHEDULE_GUIDED: + pp_string (buffer, "guided"); + break; + case OMP_CLAUSE_SCHEDULE_RUNTIME: + pp_string (buffer, "runtime"); + break; + default: + gcc_unreachable (); + } + if (OMP_CLAUSE_SCHEDULE_CHUNK_EXPR (clause)) + { + pp_character (buffer, ','); + dump_generic_node (buffer, + OMP_CLAUSE_SCHEDULE_CHUNK_EXPR (clause), + spc, flags, false); } + pp_character (buffer, ')'); + break; + + default: + /* Should never happen. */ + dump_generic_node (buffer, clause, spc, flags, false); + break; + } +} + + +/* Dump the list of OpenMP clauses. BUFFER, SPC and FLAGS are as in + dump_generic_node. */ + +static void +dump_omp_clauses (pretty_printer *buffer, tree clause, int spc, int flags) +{ + if (clause == NULL) + return; + pp_space (buffer); + while (1) + { + dump_omp_clause (buffer, clause, spc, flags); clause = OMP_CLAUSE_CHAIN (clause); if (clause == NULL) return; @@ -397,6 +408,7 @@ dump_omp_clauses (pretty_printer *buffer } } + /* Dump the node NODE on the pretty_printer BUFFER, SPC spaces of indent. FLAGS specifies details to show in the dump (see TDF_* in tree.h). If IS_STMT is true, the object printed is considered to be a statement @@ -1823,6 +1835,11 @@ dump_generic_node (pretty_printer *buffe is_expr = false; break; + case OMP_CLAUSE: + dump_omp_clause (buffer, node, spc, flags); + is_expr = false; + break; + case REDUC_MAX_EXPR: pp_string (buffer, " REDUC_MAX_EXPR < "); dump_generic_node (buffer, TREE_OPERAND (node, 0), spc, flags, false); Index: tree.c =================================================================== --- tree.c (revision 110178) +++ tree.c (working copy) @@ -172,13 +172,49 @@ tree global_trees[TI_MAX]; tree integer_types[itk_none]; unsigned char tree_contains_struct[256][64]; + +/* Number of operands for each OpenMP clause. */ +unsigned char omp_clause_num_ops[] = +{ + 0, /* OMP_CLAUSE_ERROR */ + 1, /* OMP_CLAUSE_PRIVATE */ + 1, /* OMP_CLAUSE_SHARED */ + 1, /* OMP_CLAUSE_FIRSTPRIVATE */ + 1, /* OMP_CLAUSE_LASTPRIVATE */ + 4, /* OMP_CLAUSE_REDUCTION */ + 1, /* OMP_CLAUSE_COPYIN */ + 1, /* OMP_CLAUSE_COPYPRIVATE */ + 1, /* OMP_CLAUSE_IF */ + 1, /* OMP_CLAUSE_NUM_THREADS */ + 1, /* OMP_CLAUSE_SCHEDULE */ + 0, /* OMP_CLAUSE_NOWAIT */ + 0, /* OMP_CLAUSE_ORDERED */ + 0 /* OMP_CLAUSE_DEFAULT */ +}; + +const char *omp_clause_code_name[] = +{ + "error_clause", + "private", + "shared", + "firstprivate", + "lastprivate", + "reduction", + "copyin", + "copyprivate", + "if", + "num_threads", + "schedule", + "nowait", + "ordered", + "default" +}; /* Init tree.c. */ void init_ttree (void) { - /* Initialize the hash table of types. */ type_hash_table = htab_create_ggc (TYPE_HASH_INITIAL_SIZE, type_hash_hash, type_hash_eq, 0); @@ -338,6 +374,7 @@ tree_code_size (enum tree_code code) case PLACEHOLDER_EXPR: return sizeof (struct tree_common); case TREE_VEC: + case OMP_CLAUSE: case PHI_NODE: gcc_unreachable (); case SSA_NAME: return sizeof (struct tree_ssa_name); @@ -379,6 +416,11 @@ tree_size (tree node) case STRING_CST: return sizeof (struct tree_string) + TREE_STRING_LENGTH (node) - 1; + case OMP_CLAUSE: + return (sizeof (struct tree_omp_clause) + + (omp_clause_num_ops[OMP_CLAUSE_CODE (node)] - 1) + * sizeof (char *)); + default: return tree_code_size (code); } @@ -386,8 +428,9 @@ tree_size (tree node) /* Return a newly allocated node of code CODE. For decl and type nodes, some other fields are initialized. The rest of the node is - initialized to zero. This function cannot be used for PHI_NODE or - TREE_VEC nodes, which is enforced by asserts in tree_code_size. + initialized to zero. This function cannot be used for PHI_NODE, + TREE_VEC or OMP_CLAUSE nodes, which is enforced by asserts in + tree_code_size. Achoo! I got a code in the node. */ @@ -2036,6 +2079,7 @@ tree_node_structure (tree t) case CONSTRUCTOR: return TS_CONSTRUCTOR; case TREE_BINFO: return TS_BINFO; case VALUE_HANDLE: return TS_VALUE_HANDLE; + case OMP_CLAUSE: return TS_OMP_CLAUSE; default: gcc_unreachable (); @@ -6109,6 +6153,53 @@ tree_not_class_check_failed (const tree tree_code_name[TREE_CODE (node)], function, trim_filename (file), line); } + +/* Similar to tree_check_failed but applied to OMP_CLAUSE codes. */ + +void +omp_clause_check_failed (const tree node, const char *file, int line, + const char *function, enum omp_clause_code code) +{ + internal_error ("tree check: expected omp_clause %s, have %s in %s, at %s:%d", + omp_clause_code_name[code], tree_code_name[TREE_CODE (node)], + function, trim_filename (file), line); +} + + +/* Similar to tree_range_check_failed but applied to OMP_CLAUSE codes. */ + +void +omp_clause_range_check_failed (const tree node, const char *file, int line, + const char *function, enum omp_clause_code c1, + enum omp_clause_code c2) +{ + char *buffer; + unsigned length = 0; + enum omp_clause_code c; + + for (c = c1; c <= c2; ++c) + length += 4 + strlen (omp_clause_code_name[c]); + + length += strlen ("expected "); + buffer = alloca (length); + length = 0; + + for (c = c1; c <= c2; ++c) + { + const char *prefix = length ? " or " : "expected "; + + strcpy (buffer + length, prefix); + length += strlen (prefix); + strcpy (buffer + length, omp_clause_code_name[c]); + length += strlen (omp_clause_code_name[c]); + } + + internal_error ("tree check: %s, have %s in %s, at %s:%d", + buffer, omp_clause_code_name[TREE_CODE (node)], + function, trim_filename (file), line); +} + + #undef DEFTREESTRUCT #define DEFTREESTRUCT(VAL, NAME) NAME, @@ -6171,6 +6262,20 @@ tree_operand_check_failed (int idx, enum idx + 1, tree_code_name[code], TREE_CODE_LENGTH (code), function, trim_filename (file), line); } + +/* Similar to above, except that the check is for the number of + operands of an OMP_CLAUSE node. */ + +void +omp_clause_operand_check_failed (int idx, tree t, const char *file, + int line, const char *function) +{ + internal_error + ("tree check: accessed operand %d of omp_clause %s with %d operands " + "in %s, at %s:%d", idx + 1, omp_clause_code_name[OMP_CLAUSE_CODE (t)], + omp_clause_num_ops [OMP_CLAUSE_CODE (t)], function, + trim_filename (file), line); +} #endif /* ENABLE_TREE_CHECKING */ /* Create a new vector type node holding SUBPARTS units of type INNERTYPE, @@ -6733,6 +6838,31 @@ build_empty_stmt (void) } +/* Build an OpenMP clause with code CODE. */ + +tree +build_omp_clause (enum omp_clause_code code) +{ + tree t, op; + int size, i, length; + + length = omp_clause_num_ops[code]; + size = (sizeof (struct tree_omp_clause) + (length - 1) * sizeof (tree)); + + t = ggc_alloc_zone_pass_stat (size, &tree_zone); + memset (t, 0, size); + TREE_SET_CODE (t, OMP_CLAUSE); + OMP_CLAUSE_SET_CODE (t, code); + +#ifdef GATHER_STATISTICS + tree_node_counts[(int) x_kind]++; + tree_node_sizes[(int) x_kind] += size; +#endif + + return t; +} + + /* Returns true if it is possible to prove that the index of an array access REF (an ARRAY_REF expression) falls into the array bounds. */ @@ -7211,7 +7341,7 @@ walk_tree (tree *tp, walk_tree_fn func, /* But we still need to check our siblings. */ if (code == TREE_LIST) WALK_SUBTREE_TAIL (TREE_CHAIN (*tp)); - else if (code >= OMP_CLAUSE_PRIVATE && code <= OMP_CLAUSE_DEFAULT) + else if (code == OMP_CLAUSE) WALK_SUBTREE_TAIL (OMP_CLAUSE_CHAIN (*tp)); else return NULL_TREE; @@ -7303,30 +7433,38 @@ walk_tree (tree *tp, walk_tree_fn func, } break; - case OMP_CLAUSE_PRIVATE: - case OMP_CLAUSE_SHARED: - case OMP_CLAUSE_FIRSTPRIVATE: - case OMP_CLAUSE_LASTPRIVATE: - case OMP_CLAUSE_COPYIN: - case OMP_CLAUSE_COPYPRIVATE: - case OMP_CLAUSE_IF: - case OMP_CLAUSE_NUM_THREADS: - case OMP_CLAUSE_SCHEDULE: - WALK_SUBTREE (TREE_OPERAND (*tp, 0)); - /* FALLTHRU */ + case OMP_CLAUSE: + switch (OMP_CLAUSE_CODE (*tp)) + { + case OMP_CLAUSE_PRIVATE: + case OMP_CLAUSE_SHARED: + case OMP_CLAUSE_FIRSTPRIVATE: + case OMP_CLAUSE_LASTPRIVATE: + case OMP_CLAUSE_COPYIN: + case OMP_CLAUSE_COPYPRIVATE: + case OMP_CLAUSE_IF: + case OMP_CLAUSE_NUM_THREADS: + case OMP_CLAUSE_SCHEDULE: + WALK_SUBTREE (OMP_CLAUSE_OPERAND (*tp, 0)); + /* FALLTHRU */ - case OMP_CLAUSE_NOWAIT: - case OMP_CLAUSE_ORDERED: - case OMP_CLAUSE_DEFAULT: - WALK_SUBTREE_TAIL (OMP_CLAUSE_CHAIN (*tp)); + case OMP_CLAUSE_NOWAIT: + case OMP_CLAUSE_ORDERED: + case OMP_CLAUSE_DEFAULT: + WALK_SUBTREE_TAIL (OMP_CLAUSE_CHAIN (*tp)); - case OMP_CLAUSE_REDUCTION: - { - int i; - for (i = 0; i < 4; i++) - WALK_SUBTREE (TREE_OPERAND (*tp, i)); - WALK_SUBTREE_TAIL (OMP_CLAUSE_CHAIN (*tp)); - } + case OMP_CLAUSE_REDUCTION: + { + int i; + for (i = 0; i < 4; i++) + WALK_SUBTREE (OMP_CLAUSE_OPERAND (*tp, i)); + WALK_SUBTREE_TAIL (OMP_CLAUSE_CHAIN (*tp)); + } + + default: + gcc_unreachable (); + } + break; case TARGET_EXPR: { Index: tree.h =================================================================== --- tree.h (revision 110178) +++ tree.h (working copy) @@ -262,6 +262,66 @@ extern const char * built_in_names[(int) extern GTY(()) tree built_in_decls[(int) END_BUILTINS]; extern GTY(()) tree implicit_built_in_decls[(int) END_BUILTINS]; +/* In an OMP_CLAUSE node. */ + +/* Number of operands and names for each clause. */ +extern unsigned char omp_clause_num_ops[]; +extern const char *omp_clause_code_name[]; + +/* Clause codes. Do not reorder, as this is used to index into the tables + omp_clause_num_ops and omp_clause_code_name. */ +enum omp_clause_code +{ + /* Clause zero is special-cased inside the parser + (c_parser_omp_variable_list). */ + OMP_CLAUSE_ERROR = 0, + + /* OpenMP clause: private (variable_list). */ + OMP_CLAUSE_PRIVATE, + + /* OpenMP clause: shared (variable_list). */ + OMP_CLAUSE_SHARED, + + /* OpenMP clause: firstprivate (variable_list). */ + OMP_CLAUSE_FIRSTPRIVATE, + + /* OpenMP clause: lastprivate (variable_list). */ + OMP_CLAUSE_LASTPRIVATE, + + /* OpenMP clause: reduction (operator:variable_list). + OMP_CLAUSE_REDUCTION_CODE: The tree_code of the operator. + Operand 1: OMP_CLAUSE_REDUCTION_INIT: Stmt-list to initialize the var. + Operand 2: OMP_CLAUSE_REDUCTION_MERGE: Stmt-list to merge private var + into the shared one. + Operand 3: OMP_CLAUSE_REDUCTION_PLACEHOLDER: A dummy VAR_DECL + placeholder used in OMP_CLAUSE_REDUCTION_MERGE. */ + OMP_CLAUSE_REDUCTION, + + /* OpenMP clause: copyin (variable_list). */ + OMP_CLAUSE_COPYIN, + + /* OpenMP clause: copyprivate (variable_list). */ + OMP_CLAUSE_COPYPRIVATE, + + /* OpenMP clause: if (scalar-expression). */ + OMP_CLAUSE_IF, + + /* OpenMP clause: num_threads (integer-expression). */ + OMP_CLAUSE_NUM_THREADS, + + /* OpenMP clause: schedule. */ + OMP_CLAUSE_SCHEDULE, + + /* OpenMP clause: nowait. */ + OMP_CLAUSE_NOWAIT, + + /* OpenMP clause: ordered. */ + OMP_CLAUSE_ORDERED, + + /* OpenMP clause: default. */ + OMP_CLAUSE_DEFAULT +}; + /* The definition of tree nodes fills the next several pages. */ /* A tree node can represent a data type, a variable, an expression @@ -598,11 +658,32 @@ enum tree_node_structure_enum { #define TREE_RANGE_CHECK(T, CODE1, CODE2) __extension__ \ ({ const tree __t = (T); \ - if (TREE_CODE (__t) < (CODE1) && TREE_CODE (__t) > (CODE2)) \ + if (TREE_CODE (__t) < (CODE1) || TREE_CODE (__t) > (CODE2)) \ tree_range_check_failed (__t, __FILE__, __LINE__, __FUNCTION__, \ (CODE1), (CODE2)); \ __t; }) +#define OMP_CLAUSE_SUBCODE_CHECK(T, CODE) __extension__ \ +({ const tree __t = (T); \ + if (TREE_CODE (__t) != OMP_CLAUSE) \ + tree_check_failed (__t, __FILE__, __LINE__, __FUNCTION__, \ + OMP_CLAUSE, 0); \ + if (__t->omp_clause.code != (CODE)) \ + omp_clause_check_failed (__t, __FILE__, __LINE__, __FUNCTION__, \ + (CODE)); \ + __t; }) + +#define OMP_CLAUSE_RANGE_CHECK(T, CODE1, CODE2) __extension__ \ +({ const tree __t = (T); \ + if (TREE_CODE (__t) != OMP_CLAUSE) \ + tree_check_failed (__t, __FILE__, __LINE__, __FUNCTION__, \ + OMP_CLAUSE, 0); \ + if ((int) __t->omp_clause.code < (int) (CODE1) \ + || (int) __t->omp_clause.code > (int) (CODE2)) \ + omp_clause_range_check_failed (__t, __FILE__, __LINE__, \ + __FUNCTION__, (CODE1), (CODE2)); \ + __t; }) + /* These checks have to be special cased. */ #define EXPR_CHECK(T) __extension__ \ ({ const tree __t = (T); \ @@ -642,6 +723,17 @@ enum tree_node_structure_enum { __FILE__, __LINE__, __FUNCTION__); \ &__t->phi.a[__i]; })) +#define OMP_CLAUSE_ELT_CHECK(t, i) __extension__ \ +(*({const tree __t = t; \ + const int __i = (i); \ + if (TREE_CODE (__t) != OMP_CLAUSE) \ + tree_check_failed (__t, __FILE__, __LINE__, __FUNCTION__, \ + OMP_CLAUSE, 0); \ + if (__i < 0 || __i >= omp_clause_num_ops [__t->omp_clause.code]) \ + omp_clause_operand_check_failed (__i, __t, __FILE__, __LINE__, \ + __FUNCTION__); \ + &__t->omp_clause.ops[__i]; })) + /* Special checks for TREE_OPERANDs. */ #define TREE_OPERAND_CHECK(T, I) __extension__ \ (*({const tree __t = EXPR_CHECK (T); \ @@ -700,6 +792,16 @@ extern void phi_node_elt_check_failed (i extern void tree_operand_check_failed (int, enum tree_code, const char *, int, const char *) ATTRIBUTE_NORETURN; +extern void omp_clause_check_failed (const tree, const char *, int, + const char *, enum omp_clause_code) + ATTRIBUTE_NORETURN; +extern void omp_clause_operand_check_failed (int, tree, const char *, + int, const char *) + ATTRIBUTE_NORETURN; +extern void omp_clause_range_check_failed (const tree, const char *, int, + const char *, enum omp_clause_code, + enum omp_clause_code) + ATTRIBUTE_NORETURN; #else /* not ENABLE_TREE_CHECKING, or not gcc */ @@ -723,10 +825,12 @@ extern void tree_operand_check_failed (i #define TREE_OPERAND_CHECK_CODE(T, CODE, I) ((T)->exp.operands[I]) #define TREE_RTL_OPERAND_CHECK(T, CODE, I) (*(rtx *) &((T)->exp.operands[I])) #define PHI_NODE_ELT_CHECK(T, i) ((T)->phi.a[i]) +#define OMP_CLAUSE_ELT_CHECK(T, i) ((T)->omp_clause.ops[i]) +#define OMP_CLAUSE_RANGE_CHECK(T, CODE1, CODE2) (T) #endif -#define TREE_BLOCK(NODE) ((NODE)->exp.block) +#define TREE_BLOCK(NODE) (EXPR_CHECK (NODE)->exp.block) #include "tree-check.h" @@ -1463,38 +1567,38 @@ struct tree_constructor GTY(()) #define OMP_CRITICAL_BODY(NODE) TREE_OPERAND (OMP_CRITICAL_CHECK (NODE), 0) #define OMP_CRITICAL_NAME(NODE) TREE_OPERAND (OMP_CRITICAL_CHECK (NODE), 1) -#define OMP_CLAUSE_CHAIN(NODE) \ - TREE_CHAIN (TREE_RANGE_CHECK (NODE, OMP_CLAUSE_PRIVATE, OMP_CLAUSE_DEFAULT)) -#define OMP_CLAUSE_DECL(NODE) \ - TREE_OPERAND (TREE_RANGE_CHECK (NODE, OMP_CLAUSE_PRIVATE, \ - OMP_CLAUSE_COPYPRIVATE), 0) +#define OMP_CLAUSE_CHAIN(NODE) TREE_CHAIN (OMP_CLAUSE_CHECK (NODE)) +#define OMP_CLAUSE_DECL(NODE) \ + OMP_CLAUSE_OPERAND (OMP_CLAUSE_RANGE_CHECK (OMP_CLAUSE_CHECK (NODE), \ + OMP_CLAUSE_PRIVATE, \ + OMP_CLAUSE_COPYPRIVATE), 0) /* True on a PRIVATE clause if its decl is kept around for debugging information only and its DECL_VALUE_EXPR is supposed to point to what it has been remapped to. */ #define OMP_CLAUSE_PRIVATE_DEBUG(NODE) \ - TREE_PUBLIC (OMP_CLAUSE_PRIVATE_CHECK (NODE)) + TREE_PUBLIC (OMP_CLAUSE_SUBCODE_CHECK (NODE, OMP_CLAUSE_PRIVATE)) /* True on a LASTPRIVATE clause if a FIRSTPRIVATE clause for the same decl is present in the chain. */ #define OMP_CLAUSE_LASTPRIVATE_FIRSTPRIVATE(NODE) \ - TREE_PUBLIC (OMP_CLAUSE_LASTPRIVATE_CHECK (NODE)) + TREE_PUBLIC (OMP_CLAUSE_SUBCODE_CHECK (NODE, OMP_CLAUSE_LASTPRIVATE)) #define OMP_CLAUSE_IF_EXPR(NODE) \ - TREE_OPERAND (OMP_CLAUSE_IF_CHECK (NODE), 0) + OMP_CLAUSE_OPERAND (OMP_CLAUSE_SUBCODE_CHECK (NODE, OMP_CLAUSE_IF), 0) #define OMP_CLAUSE_NUM_THREADS_EXPR(NODE) \ - TREE_OPERAND (OMP_CLAUSE_NUM_THREADS_CHECK (NODE), 0) + OMP_CLAUSE_OPERAND (OMP_CLAUSE_SUBCODE_CHECK (NODE, OMP_CLAUSE_NUM_THREADS),0) #define OMP_CLAUSE_SCHEDULE_CHUNK_EXPR(NODE) \ - TREE_OPERAND (OMP_CLAUSE_SCHEDULE_CHECK (NODE), 0) + OMP_CLAUSE_OPERAND (OMP_CLAUSE_SUBCODE_CHECK (NODE, OMP_CLAUSE_SCHEDULE), 0) #define OMP_CLAUSE_REDUCTION_CODE(NODE) \ - (OMP_CLAUSE_REDUCTION_CHECK (NODE)->exp.complexity) + (OMP_CLAUSE_SUBCODE_CHECK (NODE, OMP_CLAUSE_REDUCTION)->omp_clause.subcode.reduction_code) #define OMP_CLAUSE_REDUCTION_INIT(NODE) \ - TREE_OPERAND (OMP_CLAUSE_REDUCTION_CHECK (NODE), 1) + OMP_CLAUSE_OPERAND (OMP_CLAUSE_SUBCODE_CHECK (NODE, OMP_CLAUSE_REDUCTION), 1) #define OMP_CLAUSE_REDUCTION_MERGE(NODE) \ - TREE_OPERAND (OMP_CLAUSE_REDUCTION_CHECK (NODE), 2) + OMP_CLAUSE_OPERAND (OMP_CLAUSE_SUBCODE_CHECK (NODE, OMP_CLAUSE_REDUCTION), 2) #define OMP_CLAUSE_REDUCTION_PLACEHOLDER(NODE) \ - TREE_OPERAND (OMP_CLAUSE_REDUCTION_CHECK (NODE), 3) + OMP_CLAUSE_OPERAND (OMP_CLAUSE_SUBCODE_CHECK (NODE, OMP_CLAUSE_REDUCTION), 3) enum omp_clause_schedule_kind { @@ -1505,7 +1609,7 @@ enum omp_clause_schedule_kind }; #define OMP_CLAUSE_SCHEDULE_KIND(NODE) \ - (OMP_CLAUSE_SCHEDULE_CHECK (NODE)->exp.complexity) + (OMP_CLAUSE_SUBCODE_CHECK (NODE, OMP_CLAUSE_SCHEDULE)->omp_clause.subcode.schedule_kind) enum omp_clause_default_kind { @@ -1516,7 +1620,7 @@ enum omp_clause_default_kind }; #define OMP_CLAUSE_DEFAULT_KIND(NODE) \ - (OMP_CLAUSE_DEFAULT_CHECK (NODE)->exp.complexity) + (OMP_CLAUSE_SUBCODE_CHECK (NODE, OMP_CLAUSE_DEFAULT)->omp_clause.subcode.default_kind) struct tree_exp GTY(()) { @@ -1662,6 +1766,30 @@ struct tree_phi_node GTY(()) struct phi_arg_d GTY ((length ("((tree)&%h)->phi.num_args"))) a[1]; }; +#define OMP_CLAUSE_CODE(NODE) \ + (OMP_CLAUSE_CHECK (NODE))->omp_clause.code + +#define OMP_CLAUSE_SET_CODE(NODE, CODE) \ + ((OMP_CLAUSE_CHECK (NODE))->omp_clause.code = (CODE)) + +#define OMP_CLAUSE_CODE(NODE) \ + (OMP_CLAUSE_CHECK (NODE))->omp_clause.code + +#define OMP_CLAUSE_OPERAND(NODE, I) \ + OMP_CLAUSE_ELT_CHECK (NODE, I) + +struct tree_omp_clause GTY(()) +{ + struct tree_common common; + enum omp_clause_code code; + union omp_clause_subcode { + enum omp_clause_default_kind default_kind; + enum omp_clause_schedule_kind schedule_kind; + enum tree_code reduction_code; + } GTY ((skip)) subcode; + tree GTY ((length ("omp_clause_num_ops[TREE_CODE ((tree)&%h)]"))) ops[1]; +}; + struct varray_head_tag; @@ -2997,6 +3125,7 @@ union tree_node GTY ((ptr_alias (union l struct tree_value_handle GTY ((tag ("TS_VALUE_HANDLE"))) value_handle; struct tree_constructor GTY ((tag ("TS_CONSTRUCTOR"))) constructor; struct tree_memory_tag GTY ((tag ("TS_MEMORY_TAG"))) mtag; + struct tree_omp_clause GTY ((tag ("TS_OMP_CLAUSE"))) omp_clause; }; /* Standard named or nameless data types of the C compiler. */ @@ -3359,6 +3488,7 @@ extern void annotate_with_file_line (tre extern void annotate_with_locus (tree, location_t); #endif extern tree build_empty_stmt (void); +extern tree build_omp_clause (enum omp_clause_code); /* Construct various nodes representing data types. */ Index: omp-low.c =================================================================== --- omp-low.c (revision 110178) +++ omp-low.c (working copy) @@ -154,7 +154,7 @@ static tree find_omp_clause (tree clauses, enum tree_code kind) { for (; clauses ; clauses = OMP_CLAUSE_CHAIN (clauses)) - if (TREE_CODE (clauses) == kind) + if (OMP_CLAUSE_CODE (clauses) == kind) return clauses; return NULL_TREE; @@ -242,7 +242,7 @@ extract_omp_for_data (tree for_stmt, str fd->chunk_size = NULL_TREE; for (t = OMP_FOR_CLAUSES (for_stmt); t ; t = OMP_CLAUSE_CHAIN (t)) - switch (TREE_CODE (t)) + switch (OMP_CLAUSE_CODE (t)) { case OMP_CLAUSE_NOWAIT: fd->have_nowait = true; @@ -943,7 +943,7 @@ scan_sharing_clauses (tree clauses, omp_ { bool by_ref; - switch (TREE_CODE (c)) + switch (OMP_CLAUSE_CODE (c)) { case OMP_CLAUSE_PRIVATE: decl = OMP_CLAUSE_DECL (c); @@ -966,7 +966,7 @@ scan_sharing_clauses (tree clauses, omp_ break; } /* We don't need to copy const scalar vars back. */ - TREE_SET_CODE (c, OMP_CLAUSE_FIRSTPRIVATE); + OMP_CLAUSE_SET_CODE (c, OMP_CLAUSE_FIRSTPRIVATE); goto do_private; case OMP_CLAUSE_LASTPRIVATE: @@ -1009,7 +1009,7 @@ scan_sharing_clauses (tree clauses, omp_ case OMP_CLAUSE_NUM_THREADS: case OMP_CLAUSE_SCHEDULE: if (ctx->outer) - scan_omp (&TREE_OPERAND (c, 0), ctx->outer); + scan_omp (&OMP_CLAUSE_OPERAND (c, 0), ctx->outer); break; case OMP_CLAUSE_NOWAIT: @@ -1023,7 +1023,7 @@ scan_sharing_clauses (tree clauses, omp_ for (c = clauses; c; c = OMP_CLAUSE_CHAIN (c)) { - switch (TREE_CODE (c)) + switch (OMP_CLAUSE_CODE (c)) { case OMP_CLAUSE_LASTPRIVATE: /* Let the corresponding firstprivate clause create @@ -1039,9 +1039,9 @@ scan_sharing_clauses (tree clauses, omp_ if (is_variable_sized (decl)) install_var_local (decl, ctx); fixup_remapped_decl (decl, ctx, - TREE_CODE (c) == OMP_CLAUSE_PRIVATE + OMP_CLAUSE_CODE (c) == OMP_CLAUSE_PRIVATE && OMP_CLAUSE_PRIVATE_DEBUG (c)); - if (TREE_CODE (c) == OMP_CLAUSE_REDUCTION + if (OMP_CLAUSE_CODE (c) == OMP_CLAUSE_REDUCTION && OMP_CLAUSE_REDUCTION_PLACEHOLDER (c)) scan_array_reductions = true; break; @@ -1068,7 +1068,7 @@ scan_sharing_clauses (tree clauses, omp_ if (scan_array_reductions) for (c = clauses; c; c = OMP_CLAUSE_CHAIN (c)) - if (TREE_CODE (c) == OMP_CLAUSE_REDUCTION + if (OMP_CLAUSE_CODE (c) == OMP_CLAUSE_REDUCTION && OMP_CLAUSE_REDUCTION_PLACEHOLDER (c)) { scan_omp (&OMP_CLAUSE_REDUCTION_INIT (c), ctx); @@ -1525,7 +1525,7 @@ lower_rec_input_clauses (tree clauses, t { for (c = clauses; c ; c = OMP_CLAUSE_CHAIN (c)) { - enum tree_code c_kind = TREE_CODE (c); + enum omp_clause_code c_kind = OMP_CLAUSE_CODE (c); tree var, new_var; bool by_ref; @@ -1619,7 +1619,7 @@ lower_rec_input_clauses (tree clauses, t else if (pass != 0) continue; - switch (TREE_CODE (c)) + switch (OMP_CLAUSE_CODE (c)) { case OMP_CLAUSE_SHARED: /* Set up the DECL_VALUE_EXPR for shared variables now. This @@ -1753,7 +1753,7 @@ lower_lastprivate_clauses (tree clauses, { tree var, new_var; - if (TREE_CODE (c) != OMP_CLAUSE_LASTPRIVATE) + if (OMP_CLAUSE_CODE (c) != OMP_CLAUSE_LASTPRIVATE) continue; var = OMP_CLAUSE_DECL (c); @@ -1786,7 +1786,7 @@ lower_reduction_clauses (tree clauses, t /* First see if there is exactly one reduction clause. Use OMP_ATOMIC update in that case, otherwise use a lock. */ for (c = clauses; c && count < 2; c = OMP_CLAUSE_CHAIN (c)) - if (TREE_CODE (c) == OMP_CLAUSE_REDUCTION) + if (OMP_CLAUSE_CODE (c) == OMP_CLAUSE_REDUCTION) { if (OMP_CLAUSE_REDUCTION_PLACEHOLDER (c)) { @@ -1805,7 +1805,7 @@ lower_reduction_clauses (tree clauses, t tree var, ref, new_var; enum tree_code code; - if (TREE_CODE (c) != OMP_CLAUSE_REDUCTION) + if (OMP_CLAUSE_CODE (c) != OMP_CLAUSE_REDUCTION) continue; var = OMP_CLAUSE_DECL (c); @@ -1878,7 +1878,7 @@ lower_copyprivate_clauses (tree clauses, tree var, ref, x; bool by_ref; - if (TREE_CODE (c) != OMP_CLAUSE_COPYPRIVATE) + if (OMP_CLAUSE_CODE (c) != OMP_CLAUSE_COPYPRIVATE) continue; var = OMP_CLAUSE_DECL (c); @@ -1915,7 +1915,7 @@ lower_send_clauses (tree clauses, tree * tree val, ref, x, var; bool by_ref, do_in = false, do_out = false; - switch (TREE_CODE (c)) + switch (OMP_CLAUSE_CODE (c)) { case OMP_CLAUSE_FIRSTPRIVATE: case OMP_CLAUSE_COPYIN: @@ -1934,7 +1934,7 @@ lower_send_clauses (tree clauses, tree * continue; by_ref = use_pointer_for_field (val, false); - switch (TREE_CODE (c)) + switch (OMP_CLAUSE_CODE (c)) { case OMP_CLAUSE_FIRSTPRIVATE: case OMP_CLAUSE_COPYIN: Index: gimple-low.c =================================================================== --- gimple-low.c (revision 110178) +++ gimple-low.c (working copy) @@ -166,9 +166,6 @@ lower_omp_directive (tree_stmt_iterator ? OMP_CLAUSES (stmt) : NULL_TREE; - for (; clause; clause = OMP_CLAUSE_CHAIN (clause)) - TREE_BLOCK (clause) = TREE_BLOCK (stmt); - lower_stmt_body (OMP_BODY (stmt), data); tsi_link_before (tsi, stmt, TSI_SAME_STMT); tsi_link_before (tsi, OMP_BODY (stmt), TSI_SAME_STMT); Index: treestruct.def =================================================================== --- treestruct.def (revision 110178) +++ treestruct.def (working copy) @@ -60,3 +60,4 @@ DEFTREESTRUCT(TS_STATEMENT_LIST, "statem DEFTREESTRUCT(TS_VALUE_HANDLE, "value handle") DEFTREESTRUCT(TS_CONSTRUCTOR, "constructor") DEFTREESTRUCT(TS_MEMORY_TAG, "memory tag") +DEFTREESTRUCT(TS_OMP_CLAUSE, "omp clause") Index: c-typeck.c =================================================================== --- c-typeck.c (revision 110178) +++ c-typeck.c (working copy) @@ -8482,7 +8482,7 @@ c_finish_omp_clauses (tree clauses) bool need_complete = false; bool need_implicitly_determined = false; - switch (TREE_CODE (c)) + switch (OMP_CLAUSE_CODE (c)) { case OMP_CLAUSE_SHARED: name = "shared"; Index: gimplify.c =================================================================== --- gimplify.c (revision 110178) +++ gimplify.c (working copy) @@ -4443,7 +4443,7 @@ gimplify_scan_omp_clauses (tree *list_p, unsigned int flags; tree decl; - switch (TREE_CODE (c)) + switch (OMP_CLAUSE_CODE (c)) { case OMP_CLAUSE_PRIVATE: flags = GOVD_PRIVATE | GOVD_EXPLICIT; @@ -4504,7 +4504,7 @@ gimplify_scan_omp_clauses (tree *list_p, case OMP_CLAUSE_SCHEDULE: case OMP_CLAUSE_IF: case OMP_CLAUSE_NUM_THREADS: - gs = gimplify_expr (&TREE_OPERAND (c, 0), pre_p, NULL, + gs = gimplify_expr (&OMP_CLAUSE_OPERAND (c, 0), pre_p, NULL, is_gimple_val, fb_rvalue); if (gs == GS_ERROR) remove = true; @@ -4540,7 +4540,7 @@ gimplify_adjust_omp_clauses_1 (splay_tre tree *list_p = (tree *) data; tree decl = (tree) n->key; unsigned flags = n->value; - enum tree_code code; + enum omp_clause_code code; tree clause; bool private_debug; @@ -4572,7 +4572,8 @@ gimplify_adjust_omp_clauses_1 (splay_tre else gcc_unreachable (); - clause = build1 (code, void_type_node, decl); + clause = build_omp_clause (code); + OMP_CLAUSE_DECL (clause) = decl; OMP_CLAUSE_CHAIN (clause) = *list_p; if (private_debug) OMP_CLAUSE_PRIVATE_DEBUG (clause) = 1; @@ -4592,7 +4593,7 @@ gimplify_adjust_omp_clauses (tree *list_ splay_tree_node n; bool remove = false; - switch (TREE_CODE (c)) + switch (OMP_CLAUSE_CODE (c)) { case OMP_CLAUSE_PRIVATE: case OMP_CLAUSE_SHARED: @@ -4602,14 +4603,14 @@ gimplify_adjust_omp_clauses (tree *list_ remove = !(n->value & GOVD_SEEN); if (! remove) { - bool shared = TREE_CODE (c) == OMP_CLAUSE_SHARED; + bool shared = OMP_CLAUSE_CODE (c) == OMP_CLAUSE_SHARED; if ((n->value & GOVD_DEBUG_PRIVATE) || lang_hooks.decls.omp_private_debug_clause (decl, shared)) { gcc_assert ((n->value & GOVD_DEBUG_PRIVATE) == 0 || ((n->value & GOVD_DATA_SHARE_CLASS) == GOVD_PRIVATE)); - TREE_SET_CODE (c, OMP_CLAUSE_PRIVATE); + OMP_CLAUSE_SET_CODE (c, OMP_CLAUSE_PRIVATE); OMP_CLAUSE_PRIVATE_DEBUG (c) = 1; } } Index: tree.def =================================================================== --- tree.def (revision 110178) +++ tree.def (working copy) @@ -1025,52 +1025,8 @@ DEFTREECODE (OMP_CRITICAL, "omp_critical build_fold_indirect_ref of the address. */ DEFTREECODE (OMP_ATOMIC, "omp_atomic", tcc_statement, 2) -/* The ordering of the codes between OMP_CLAUSE_PRIVATE and - OMP_CLAUSE_DEFAULT is exposed to TREE_RANGE_CHECK. */ -/* OpenMP clause: private (variable_list). */ -DEFTREECODE (OMP_CLAUSE_PRIVATE, "private", tcc_expression, 1) - -/* OpenMP clause: shared (variable_list). */ -DEFTREECODE (OMP_CLAUSE_SHARED, "shared", tcc_expression, 1) - -/* OpenMP clause: firstprivate (variable_list). */ -DEFTREECODE (OMP_CLAUSE_FIRSTPRIVATE, "firstprivate", tcc_expression, 1) - -/* OpenMP clause: lastprivate (variable_list). */ -DEFTREECODE (OMP_CLAUSE_LASTPRIVATE, "lastprivate", tcc_expression, 1) - -/* OpenMP clause: reduction (operator:variable_list). - OMP_CLAUSE_REDUCTION_CODE: The tree_code of the operator. - Operand 1: OMP_CLAUSE_REDUCTION_INIT: Stmt-list to initialize the var. - Operand 2: OMP_CLAUSE_REDUCTION_MERGE: - Stmt-list to merge private var into the shared one. - Operand 3: OMP_CLAUSE_REDUCTION_PLACEHOLDER: - A dummy VAR_DECL placeholder used in OMP_CLAUSE_REDUCTION_MERGE. */ -DEFTREECODE (OMP_CLAUSE_REDUCTION, "reduction", tcc_expression, 4) - -/* OpenMP clause: copyin (variable_list). */ -DEFTREECODE (OMP_CLAUSE_COPYIN, "copyin", tcc_expression, 1) - -/* OpenMP clause: copyprivate (variable_list). */ -DEFTREECODE (OMP_CLAUSE_COPYPRIVATE, "copyprivate", tcc_expression, 1) - -/* OpenMP clause: if (scalar-expression). */ -DEFTREECODE (OMP_CLAUSE_IF, "if", tcc_expression, 1) - -/* OpenMP clause: num_threads (integer-expression). */ -DEFTREECODE (OMP_CLAUSE_NUM_THREADS, "num_threads", tcc_expression, 1) - -/* OpenMP clause: schedule. */ -DEFTREECODE (OMP_CLAUSE_SCHEDULE, "schedule", tcc_expression, 1) - -/* OpenMP clause: nowait. */ -DEFTREECODE (OMP_CLAUSE_NOWAIT, "nowait", tcc_expression, 0) - -/* OpenMP clause: ordered. */ -DEFTREECODE (OMP_CLAUSE_ORDERED, "ordered", tcc_expression, 0) - -/* OpenMP clause: default. */ -DEFTREECODE (OMP_CLAUSE_DEFAULT, "default", tcc_expression, 0) +/* OpenMP clauses. */ +DEFTREECODE (OMP_CLAUSE, "omp_clause", tcc_exceptional, 0) /* Return from an OpenMP directive. */ DEFTREECODE (OMP_RETURN_EXPR, "omp_return", tcc_statement, 0) Index: print-tree.c =================================================================== --- print-tree.c (revision 110178) +++ print-tree.c (working copy) @@ -825,6 +825,20 @@ print_node (FILE *file, const char *pref } break; + case OMP_CLAUSE: + { + int i; + fprintf (file, " %s", + omp_clause_code_name[OMP_CLAUSE_CODE (node)]); + for (i = 0; i < omp_clause_num_ops[OMP_CLAUSE_CODE (node)]; i++) + { + indent_to (file, indent + 4); + fprintf (file, "op %d:", i); + print_node_brief (file, "", OMP_CLAUSE_OPERAND (node, i), 0); + } + } + break; + default: if (EXCEPTIONAL_CLASS_P (node)) lang_hooks.print_xnode (file, node, indent); Index: c-omp.c =================================================================== --- c-omp.c (revision 110178) +++ c-omp.c (working copy) @@ -382,13 +382,13 @@ c_split_parallel_clauses (tree clauses, tree next; *par_clauses = NULL; - *ws_clauses = make_node (OMP_CLAUSE_NOWAIT); + *ws_clauses = build_omp_clause (OMP_CLAUSE_NOWAIT); for (; clauses ; clauses = next) { next = OMP_CLAUSE_CHAIN (clauses); - switch (TREE_CODE (clauses)) + switch (OMP_CLAUSE_CODE (clauses)) { case OMP_CLAUSE_PRIVATE: case OMP_CLAUSE_SHARED: Index: tree-nested.c =================================================================== --- tree-nested.c (revision 110178) +++ tree-nested.c (working copy) @@ -1034,9 +1034,10 @@ convert_nonlocal_reference (tree *tp, in save_suppress = info->suppress_expansion; if (convert_nonlocal_omp_clauses (&OMP_PARALLEL_CLAUSES (t), wi)) { - tree c; - c = get_chain_decl (info); - c = build1 (OMP_CLAUSE_FIRSTPRIVATE, void_type_node, c); + tree c, decl; + decl = get_chain_decl (info); + c = build_omp_clause (OMP_CLAUSE_FIRSTPRIVATE); + OMP_CLAUSE_DECL (c) = decl; OMP_CLAUSE_CHAIN (c) = OMP_PARALLEL_CLAUSES (t); OMP_PARALLEL_CLAUSES (t) = c; } @@ -1094,7 +1095,7 @@ convert_nonlocal_omp_clauses (tree *pcla for (clause = *pclauses; clause ; clause = OMP_CLAUSE_CHAIN (clause)) { - switch (TREE_CODE (clause)) + switch (OMP_CLAUSE_CODE (clause)) { case OMP_CLAUSE_PRIVATE: case OMP_CLAUSE_FIRSTPRIVATE: @@ -1119,7 +1120,8 @@ convert_nonlocal_omp_clauses (tree *pcla case OMP_CLAUSE_NUM_THREADS: wi->val_only = true; wi->is_lhs = false; - convert_nonlocal_reference (&TREE_OPERAND (clause, 0), &dummy, wi); + convert_nonlocal_reference (&OMP_CLAUSE_OPERAND (clause, 0), &dummy, + wi); break; case OMP_CLAUSE_NOWAIT: @@ -1317,7 +1319,8 @@ convert_local_reference (tree *tp, int * { tree c; (void) get_frame_type (info); - c = build1 (OMP_CLAUSE_SHARED, void_type_node, info->frame_decl); + c = build_omp_clause (OMP_CLAUSE_SHARED); + OMP_CLAUSE_DECL (c) = info->frame_decl; OMP_CLAUSE_CHAIN (c) = OMP_PARALLEL_CLAUSES (t); OMP_PARALLEL_CLAUSES (t) = c; } @@ -1375,7 +1378,7 @@ convert_local_omp_clauses (tree *pclause for (clause = *pclauses; clause ; clause = OMP_CLAUSE_CHAIN (clause)) { - switch (TREE_CODE (clause)) + switch (OMP_CLAUSE_CODE (clause)) { case OMP_CLAUSE_PRIVATE: case OMP_CLAUSE_FIRSTPRIVATE: @@ -1406,7 +1409,7 @@ convert_local_omp_clauses (tree *pclause case OMP_CLAUSE_NUM_THREADS: wi->val_only = true; wi->is_lhs = false; - convert_local_reference (&TREE_OPERAND (clause, 0), &dummy, wi); + convert_local_reference (&OMP_CLAUSE_OPERAND (clause, 0), &dummy, wi); break; case OMP_CLAUSE_NOWAIT: Index: tree-inline.c =================================================================== --- tree-inline.c (revision 110178) +++ tree-inline.c (working copy) @@ -1607,19 +1607,7 @@ estimate_num_insns_1 (tree *tp, int *wal case OMP_ORDERED: case OMP_CRITICAL: case OMP_ATOMIC: - case OMP_CLAUSE_PRIVATE: - case OMP_CLAUSE_SHARED: - case OMP_CLAUSE_FIRSTPRIVATE: - case OMP_CLAUSE_LASTPRIVATE: - case OMP_CLAUSE_REDUCTION: - case OMP_CLAUSE_COPYIN: - case OMP_CLAUSE_COPYPRIVATE: - case OMP_CLAUSE_IF: - case OMP_CLAUSE_NUM_THREADS: - case OMP_CLAUSE_SCHEDULE: - case OMP_CLAUSE_NOWAIT: - case OMP_CLAUSE_ORDERED: - case OMP_CLAUSE_DEFAULT: + case OMP_CLAUSE: case OMP_RETURN_EXPR: break; @@ -2310,20 +2298,7 @@ copy_tree_r (tree *tp, int *walk_subtree walk_tree to walk into the chain as well. */ if (code == PARM_DECL || code == TREE_LIST - /* OpenMP clauses are linked through TREE_CHAIN. */ - || code == OMP_CLAUSE_PRIVATE - || code == OMP_CLAUSE_SHARED - || code == OMP_CLAUSE_FIRSTPRIVATE - || code == OMP_CLAUSE_LASTPRIVATE - || code == OMP_CLAUSE_REDUCTION - || code == OMP_CLAUSE_COPYIN - || code == OMP_CLAUSE_COPYPRIVATE - || code == OMP_CLAUSE_IF - || code == OMP_CLAUSE_NUM_THREADS - || code == OMP_CLAUSE_SCHEDULE - || code == OMP_CLAUSE_NOWAIT - || code == OMP_CLAUSE_ORDERED - || code == OMP_CLAUSE_DEFAULT) + || code == OMP_CLAUSE) TREE_CHAIN (*tp) = chain; /* For now, we don't update BLOCKs when we make copies. So, we Index: c-parser.c =================================================================== --- c-parser.c (revision 110178) +++ c-parser.c (working copy) @@ -6625,7 +6625,7 @@ check_no_duplicate_clause (tree clauses, tree c; for (c = clauses; c ; c = OMP_CLAUSE_CHAIN (c)) - if (TREE_CODE (c) == code) + if (OMP_CLAUSE_CODE (c) == code) { error ("too many %qs clauses", name); break; @@ -6644,7 +6644,8 @@ check_no_duplicate_clause (tree clauses, return the list created. */ static tree -c_parser_omp_variable_list (c_parser *parser, enum tree_code kind, tree list) +c_parser_omp_variable_list (c_parser *parser, enum omp_clause_code kind, + tree list) { if (c_parser_next_token_is_not (parser, CPP_NAME) || c_parser_peek_token (parser)->id_kind != C_ID_ID) @@ -6662,7 +6663,7 @@ c_parser_omp_variable_list (c_parser *pa ; else if (kind != 0) { - tree u = make_node (kind); + tree u = build_omp_clause (kind); OMP_CLAUSE_DECL (u) = t; OMP_CLAUSE_CHAIN (u) = list; list = u; @@ -6759,7 +6760,7 @@ c_parser_omp_clause_default (c_parser *p return list; check_no_duplicate_clause (list, OMP_CLAUSE_DEFAULT, "default"); - c = make_node (OMP_CLAUSE_DEFAULT); + c = build_omp_clause (OMP_CLAUSE_DEFAULT); OMP_CLAUSE_CHAIN (c) = list; OMP_CLAUSE_DEFAULT_KIND (c) = kind; @@ -6788,7 +6789,7 @@ c_parser_omp_clause_if (c_parser *parser check_no_duplicate_clause (list, OMP_CLAUSE_IF, "if"); - c = make_node (OMP_CLAUSE_IF); + c = build_omp_clause (OMP_CLAUSE_IF); OMP_CLAUSE_IF_EXPR (c) = t; OMP_CLAUSE_CHAIN (c) = list; list = c; @@ -6818,7 +6819,7 @@ c_parser_omp_clause_nowait (c_parser *pa check_no_duplicate_clause (list, OMP_CLAUSE_NOWAIT, "nowait"); - c = make_node (OMP_CLAUSE_NOWAIT); + c = build_omp_clause (OMP_CLAUSE_NOWAIT); OMP_CLAUSE_CHAIN (c) = list; return c; } @@ -6852,7 +6853,7 @@ c_parser_omp_clause_num_threads (c_parse check_no_duplicate_clause (list, OMP_CLAUSE_NUM_THREADS, "num_threads"); - c = make_node (OMP_CLAUSE_NUM_THREADS); + c = build_omp_clause (OMP_CLAUSE_NUM_THREADS); OMP_CLAUSE_NUM_THREADS_EXPR (c) = t; OMP_CLAUSE_CHAIN (c) = list; list = c; @@ -6871,7 +6872,7 @@ c_parser_omp_clause_ordered (c_parser *p check_no_duplicate_clause (list, OMP_CLAUSE_ORDERED, "ordered"); - c = make_node (OMP_CLAUSE_ORDERED); + c = build_omp_clause (OMP_CLAUSE_ORDERED); OMP_CLAUSE_CHAIN (c) = list; return c; } @@ -6963,7 +6964,7 @@ c_parser_omp_clause_schedule (c_parser * if (!c_parser_require (parser, CPP_OPEN_PAREN, "expected %<(%>")) return list; - c = make_node (OMP_CLAUSE_SCHEDULE); + c = build_omp_clause (OMP_CLAUSE_SCHEDULE); if (c_parser_next_token_is (parser, CPP_NAME)) { --------------000706080000000102060808--