diff options
author | Diego Novillo <dnovillo@redhat.com> | 2006-01-26 02:53:01 +0000 |
---|---|---|
committer | Diego Novillo <dnovillo@gcc.gnu.org> | 2006-01-25 21:53:01 -0500 |
commit | aaf46ef9792bbc562175b606bd1c3f225ea56924 (patch) | |
tree | 6b35ae8b0d86fdf04a2e7d85a967d4e8e0d276fd /gcc/tree.c | |
parent | d89b36e1a2179df76edf089cc2a11f5f3409cb72 (diff) | |
download | gcc-aaf46ef9792bbc562175b606bd1c3f225ea56924.zip gcc-aaf46ef9792bbc562175b606bd1c3f225ea56924.tar.gz gcc-aaf46ef9792bbc562175b606bd1c3f225ea56924.tar.bz2 |
re PR middle-end/25886 (up to 256 tree codes for Objective-C++)
* tree.h (TREE_RANGE_CHECK): Fix range predicate.
(TREE_BLOCK): Add call to EXPR_CHECK.
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.
From-SVN: r110243
Diffstat (limited to 'gcc/tree.c')
-rw-r--r-- | gcc/tree.c | 195 |
1 files changed, 167 insertions, 28 deletions
@@ -96,7 +96,8 @@ static const char * const tree_node_kind_names[] = { "constructors", "random kinds", "lang_decl kinds", - "lang_type kinds" + "lang_type kinds", + "omp clauses" }; #endif /* GATHER_STATISTICS */ @@ -172,13 +173,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 const 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 * const 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 +375,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 +417,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 (tree)); + default: return tree_code_size (code); } @@ -386,8 +429,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 +2080,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 +6154,53 @@ tree_not_class_check_failed (const tree node, const enum tree_code_class cl, 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 +6263,20 @@ tree_operand_check_failed (int idx, enum tree_code code, const char *file, 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 +6839,31 @@ build_empty_stmt (void) } +/* Build an OpenMP clause with code CODE. */ + +tree +build_omp_clause (enum omp_clause_code code) +{ + tree t; + int size, length; + + length = omp_clause_num_ops[code]; + size = (sizeof (struct tree_omp_clause) + (length - 1) * sizeof (tree)); + + t = ggc_alloc (size); + memset (t, 0, size); + TREE_SET_CODE (t, OMP_CLAUSE); + OMP_CLAUSE_SET_CODE (t, code); + +#ifdef GATHER_STATISTICS + tree_node_counts[(int) omp_clause_kind]++; + tree_node_sizes[(int) omp_clause_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 +7342,7 @@ walk_tree (tree *tp, walk_tree_fn func, void *data, struct pointer_set_t *pset) /* 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 +7434,38 @@ walk_tree (tree *tp, walk_tree_fn func, void *data, struct pointer_set_t *pset) } 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_NOWAIT: - case OMP_CLAUSE_ORDERED: - case OMP_CLAUSE_DEFAULT: - WALK_SUBTREE_TAIL (OMP_CLAUSE_CHAIN (*tp)); + 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_REDUCTION: + { + int i; + for (i = 0; i < 4; i++) + WALK_SUBTREE (OMP_CLAUSE_OPERAND (*tp, i)); + 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)); - } + default: + gcc_unreachable (); + } + break; case TARGET_EXPR: { |