From 4d58c533a8a54cfd07f617fd4cfa91e67e51c57d Mon Sep 17 00:00:00 2001 From: Nathan Sidwell Date: Tue, 27 Sep 2016 16:46:21 +0000 Subject: [PATCH] internal-fn.h (IFN_UNIQUE_CODES, [...]): New. * internal-fn.h (IFN_UNIQUE_CODES, IFN_GOACC_LOOP_CODES, IFN_GOACC_REDUCTION_CODES): New. (enum ifn_unique_kind, enum ifn_goacc_loop_kind, enum ifn_goacc_reduction_kind): Use them. * gimple-pretty-print.c (dump_gimple_call_args): Decode first arg of internal functions, when applicable. From-SVN: r240552 --- gcc/ChangeLog | 9 ++++++ gcc/gimple-pretty-print.c | 58 +++++++++++++++++++++++++++++++++++++-- gcc/internal-fn.h | 58 +++++++++++++++++++++------------------ 3 files changed, 96 insertions(+), 29 deletions(-) diff --git a/gcc/ChangeLog b/gcc/ChangeLog index fb011a17a62..39e18fdf0ec 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,12 @@ +2016-09-27 Nathan Sidwell + + * internal-fn.h (IFN_UNIQUE_CODES, IFN_GOACC_LOOP_CODES, + IFN_GOACC_REDUCTION_CODES): New. + (enum ifn_unique_kind, enum ifn_goacc_loop_kind, enum + ifn_goacc_reduction_kind): Use them. + * gimple-pretty-print.c (dump_gimple_call_args): Decode first arg + of internal functions, when applicable. + 2016-09-27 Maciej W. Rozycki * config/mips/constraints.md (d): Fix documentation. diff --git a/gcc/gimple-pretty-print.c b/gcc/gimple-pretty-print.c index 12d9a9c577b..10cb168af74 100644 --- a/gcc/gimple-pretty-print.c +++ b/gcc/gimple-pretty-print.c @@ -599,9 +599,63 @@ dump_gimple_return (pretty_printer *buffer, greturn *gs, int spc, int flags) static void dump_gimple_call_args (pretty_printer *buffer, gcall *gs, int flags) { - size_t i; + size_t i = 0; + + /* Pretty print first arg to certain internal fns. */ + if (gimple_call_internal_p (gs)) + { + const char *const *enums = NULL; + unsigned limit = 0; + + switch (gimple_call_internal_fn (gs)) + { + case IFN_UNIQUE: +#define DEF(X) #X + static const char *const unique_args[] = {IFN_UNIQUE_CODES}; +#undef DEF + enums = unique_args; + + limit = ARRAY_SIZE (unique_args); + break; + + case IFN_GOACC_LOOP: +#define DEF(X) #X + static const char *const loop_args[] = {IFN_GOACC_LOOP_CODES}; +#undef DEF + enums = loop_args; + limit = ARRAY_SIZE (loop_args); + break; + + case IFN_GOACC_REDUCTION: +#define DEF(X) #X + static const char *const reduction_args[] + = {IFN_GOACC_REDUCTION_CODES}; +#undef DEF + enums = reduction_args; + limit = ARRAY_SIZE (reduction_args); + break; + + default: + break; + } + if (limit) + { + tree arg0 = gimple_call_arg (gs, 0); + HOST_WIDE_INT v; + + if (TREE_CODE (arg0) == INTEGER_CST + && tree_fits_shwi_p (arg0) + && (v = tree_to_shwi (arg0)) >= 0 && v < limit) + { + i++; + pp_string (buffer, enums[v]); + if (i < gimple_call_num_args (gs)) + pp_string (buffer, ", "); + } + } + } - for (i = 0; i < gimple_call_num_args (gs); i++) + for (; i < gimple_call_num_args (gs); i++) { dump_generic_node (buffer, gimple_call_arg (gs, i), 0, flags, false); if (i < gimple_call_num_args (gs) - 1) diff --git a/gcc/internal-fn.h b/gcc/internal-fn.h index bb3146558bd..4e5dbaa79d4 100644 --- a/gcc/internal-fn.h +++ b/gcc/internal-fn.h @@ -20,26 +20,28 @@ along with GCC; see the file COPYING3. If not see #ifndef GCC_INTERNAL_FN_H #define GCC_INTERNAL_FN_H -/* INTEGER_CST values for IFN_UNIQUE function arg-0. */ +/* INTEGER_CST values for IFN_UNIQUE function arg-0. + + UNSPEC: Undifferentiated UNIQUE. + + FORK and JOIN mark the points at which OpenACC partitioned + execution is entered or exited. + DEP_VAR = UNIQUE ({FORK,JOIN}, DEP_VAR, AXIS) + + HEAD_MARK and TAIL_MARK are used to demark the sequence entering + or leaving partitioned execution. + DEP_VAR = UNIQUE ({HEAD,TAIL}_MARK, REMAINING_MARKS, ...PRIMARY_FLAGS) + + The PRIMARY_FLAGS only occur on the first HEAD_MARK of a sequence. */ +#define IFN_UNIQUE_CODES \ + DEF(UNSPEC), \ + DEF(OACC_FORK), DEF(OACC_JOIN), \ + DEF(OACC_HEAD_MARK), DEF(OACC_TAIL_MARK) + enum ifn_unique_kind { - IFN_UNIQUE_UNSPEC, /* Undifferentiated UNIQUE. */ - - /* FORK and JOIN mark the points at which OpenACC partitioned - execution is entered or exited. - return: data dependency value - arg-1: data dependency var - arg-2: INTEGER_CST argument, indicating the axis. */ - IFN_UNIQUE_OACC_FORK, - IFN_UNIQUE_OACC_JOIN, - - /* HEAD_MARK and TAIL_MARK are used to demark the sequence entering - or leaving partitioned execution. - return: data dependency value - arg-1: data dependency var - arg-2: INTEGER_CST argument, remaining markers in this sequence - arg-3...: varargs on primary header */ - IFN_UNIQUE_OACC_HEAD_MARK, - IFN_UNIQUE_OACC_TAIL_MARK +#define DEF(X) IFN_UNIQUE_##X + IFN_UNIQUE_CODES +#undef DEF }; /* INTEGER_CST values for IFN_GOACC_LOOP arg-0. Allows the precise @@ -59,11 +61,12 @@ enum ifn_unique_kind { CHUNK_NO - chunk number MASK - partitioning mask. */ +#define IFN_GOACC_LOOP_CODES \ + DEF(CHUNKS), DEF(STEP), DEF(OFFSET), DEF(BOUND) enum ifn_goacc_loop_kind { - IFN_GOACC_LOOP_CHUNKS, /* Number of chunks. */ - IFN_GOACC_LOOP_STEP, /* Size of each thread's step. */ - IFN_GOACC_LOOP_OFFSET, /* Initial iteration value. */ - IFN_GOACC_LOOP_BOUND /* Limit of iteration value. */ +#define DEF(X) IFN_GOACC_LOOP_##X + IFN_GOACC_LOOP_CODES +#undef DEF }; /* The GOACC_REDUCTION function defines a generic interface to support @@ -81,11 +84,12 @@ enum ifn_goacc_loop_kind { In general the return value is LOCAL_VAR, which creates a data dependency between calls operating on the same reduction. */ +#define IFN_GOACC_REDUCTION_CODES \ + DEF(SETUP), DEF(INIT), DEF(FINI), DEF(TEARDOWN) enum ifn_goacc_reduction_kind { - IFN_GOACC_REDUCTION_SETUP, - IFN_GOACC_REDUCTION_INIT, - IFN_GOACC_REDUCTION_FINI, - IFN_GOACC_REDUCTION_TEARDOWN +#define DEF(X) IFN_GOACC_REDUCTION_##X + IFN_GOACC_REDUCTION_CODES +#undef DEF }; /* Initialize internal function tables. */ -- 2.30.2