aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--gcc/ChangeLog69
-rw-r--r--gcc/c-omp.c4
-rw-r--r--gcc/c-parser.c19
-rw-r--r--gcc/c-typeck.c2
-rw-r--r--gcc/gimple-low.c3
-rw-r--r--gcc/gimplify.c15
-rw-r--r--gcc/omp-low.c34
-rw-r--r--gcc/print-tree.c14
-rw-r--r--gcc/tree-dump.c8
-rw-r--r--gcc/tree-inline.c29
-rw-r--r--gcc/tree-nested.c19
-rw-r--r--gcc/tree-pretty-print.c243
-rw-r--r--gcc/tree.c195
-rw-r--r--gcc/tree.def48
-rw-r--r--gcc/tree.h167
-rw-r--r--gcc/treestruct.def1
16 files changed, 591 insertions, 279 deletions
diff --git a/gcc/ChangeLog b/gcc/ChangeLog
index df995ab..80c94b3 100644
--- a/gcc/ChangeLog
+++ b/gcc/ChangeLog
@@ -1,3 +1,72 @@
+2006-01-25 Diego Novillo <dnovillo@redhat.com>
+
+ * tree.h (TREE_RANGE_CHECK): Fix range predicate.
+ (TREE_BLOCK): Add call to EXPR_CHECK.
+
+2006-01-25 Diego Novillo <dnovillo@redhat.com>
+
+ 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.
+
2006-01-25 Roger Sayle <roger@eyesopen.com>
PR rtl-optimization/25703
diff --git a/gcc/c-omp.c b/gcc/c-omp.c
index 30e7e64..ac107e6 100644
--- a/gcc/c-omp.c
+++ b/gcc/c-omp.c
@@ -382,13 +382,13 @@ c_split_parallel_clauses (tree clauses, tree *par_clauses, tree *ws_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:
diff --git a/gcc/c-parser.c b/gcc/c-parser.c
index a5fa523..b572273 100644
--- a/gcc/c-parser.c
+++ b/gcc/c-parser.c
@@ -6625,7 +6625,7 @@ check_no_duplicate_clause (tree clauses, enum tree_code code, const char *name)
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, enum tree_code code, const char *name)
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 *parser, enum tree_code kind, tree list)
;
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 *parser, tree list)
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, tree list)
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 *parser ATTRIBUTE_UNUSED, tree list)
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_parser *parser, tree list)
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 *parser ATTRIBUTE_UNUSED, tree list)
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 *parser, tree list)
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))
{
diff --git a/gcc/c-typeck.c b/gcc/c-typeck.c
index c6f658b..e1f7845 100644
--- a/gcc/c-typeck.c
+++ b/gcc/c-typeck.c
@@ -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";
diff --git a/gcc/gimple-low.c b/gcc/gimple-low.c
index 8b2581b..a298cbb 100644
--- a/gcc/gimple-low.c
+++ b/gcc/gimple-low.c
@@ -166,9 +166,6 @@ lower_omp_directive (tree_stmt_iterator *tsi, struct lower_data *data)
? 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);
diff --git a/gcc/gimplify.c b/gcc/gimplify.c
index 7d7b80f..cb1b95e 100644
--- a/gcc/gimplify.c
+++ b/gcc/gimplify.c
@@ -4443,7 +4443,7 @@ gimplify_scan_omp_clauses (tree *list_p, tree *pre_p, bool in_parallel)
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, tree *pre_p, bool in_parallel)
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_tree_node n, void *data)
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_tree_node n, void *data)
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_p)
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_p)
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;
}
}
diff --git a/gcc/omp-low.c b/gcc/omp-low.c
index 44f1b7e..93ceb8e 100644
--- a/gcc/omp-low.c
+++ b/gcc/omp-low.c
@@ -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, struct omp_for_data *fd)
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_context *ctx)
{
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_context *ctx)
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_context *ctx)
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_context *ctx)
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_context *ctx)
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_context *ctx)
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, tree *ilist, tree *dlist,
{
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, tree *ilist, tree *dlist,
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 predicate, tree *stmt_list,
{
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, tree *stmt_list, omp_context *ctx)
/* 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, tree *stmt_list, omp_context *ctx)
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 *slist, tree *rlist,
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 *ilist, tree *olist, omp_context *ctx)
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 *ilist, tree *olist, omp_context *ctx)
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:
diff --git a/gcc/print-tree.c b/gcc/print-tree.c
index a371f09..65587ae 100644
--- a/gcc/print-tree.c
+++ b/gcc/print-tree.c
@@ -825,6 +825,20 @@ print_node (FILE *file, const char *prefix, tree node, int indent)
}
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);
diff --git a/gcc/tree-dump.c b/gcc/tree-dump.c
index dfcf456..a76486c 100644
--- a/gcc/tree-dump.c
+++ b/gcc/tree-dump.c
@@ -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;
diff --git a/gcc/tree-inline.c b/gcc/tree-inline.c
index c75cc9b..012ef68 100644
--- a/gcc/tree-inline.c
+++ b/gcc/tree-inline.c
@@ -1607,19 +1607,7 @@ estimate_num_insns_1 (tree *tp, int *walk_subtrees, void *data)
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_subtrees, void *data ATTRIBUTE_UNUSED)
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
diff --git a/gcc/tree-nested.c b/gcc/tree-nested.c
index 4c65a1d..8866819 100644
--- a/gcc/tree-nested.c
+++ b/gcc/tree-nested.c
@@ -1034,9 +1034,10 @@ convert_nonlocal_reference (tree *tp, int *walk_subtrees, void *data)
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 *pclauses, struct walk_stmt_info *wi)
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 *pclauses, struct walk_stmt_info *wi)
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 *walk_subtrees, void *data)
{
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 *pclauses, struct walk_stmt_info *wi)
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 *pclauses, struct walk_stmt_info *wi)
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:
diff --git a/gcc/tree-pretty-print.c b/gcc/tree-pretty-print.c
index b23416d..62b5899 100644
--- a/gcc/tree-pretty-print.c
+++ b/gcc/tree-pretty-print.c
@@ -263,133 +263,144 @@ dump_array_domain (pretty_printer *buffer, tree domain, int spc, int flags)
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, tree clause, int spc, int flags)
}
}
+
/* 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 *buffer, tree node, int spc, int flags,
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);
diff --git a/gcc/tree.c b/gcc/tree.c
index 140676b..a4c8822 100644
--- a/gcc/tree.c
+++ b/gcc/tree.c
@@ -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:
{
diff --git a/gcc/tree.def b/gcc/tree.def
index f99b247..5810a29 100644
--- a/gcc/tree.def
+++ b/gcc/tree.def
@@ -1025,52 +1025,8 @@ DEFTREECODE (OMP_CRITICAL, "omp_critical", tcc_statement, 2)
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)
diff --git a/gcc/tree.h b/gcc/tree.h
index 99463ae..f93a764 100644
--- a/gcc/tree.h
+++ b/gcc/tree.h
@@ -262,6 +262,66 @@ extern const char * built_in_names[(int) END_BUILTINS];
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 const char omp_clause_num_ops[];
+extern const char * const 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 (int, int, const char *,
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 (int, enum tree_code,
#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 lang_tree_node),
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 (tree, const char *, int);
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. */
@@ -4341,6 +4471,7 @@ typedef enum
x_kind,
lang_decl,
lang_type,
+ omp_clause_kind,
all_kinds
} tree_node_kind;
diff --git a/gcc/treestruct.def b/gcc/treestruct.def
index e8d016a..3131d4b 100644
--- a/gcc/treestruct.def
+++ b/gcc/treestruct.def
@@ -60,3 +60,4 @@ DEFTREESTRUCT(TS_STATEMENT_LIST, "statement list")
DEFTREESTRUCT(TS_VALUE_HANDLE, "value handle")
DEFTREESTRUCT(TS_CONSTRUCTOR, "constructor")
DEFTREESTRUCT(TS_MEMORY_TAG, "memory tag")
+DEFTREESTRUCT(TS_OMP_CLAUSE, "omp clause")