* internal fn pretty printing
@ 2016-09-27 11:05 Nathan Sidwell
2016-09-27 13:42 ` Bernd Schmidt
0 siblings, 1 reply; 3+ messages in thread
From: Nathan Sidwell @ 2016-09-27 11:05 UTC (permalink / raw)
To: Richard Guenther, Jakub Jelinek; +Cc: GCC Patches
[-- Attachment #1: Type: text/plain, Size: 662 bytes --]
In working on some new code I got sufficiently frustrated to implement pretty
printing on internal function discriminators, as I think one of you suggested a
while back. With this patch we get:
.data_dep.2 = UNIQUE (OACC_FORK, .data_dep.2, -1);
rather than an obscure raw integer for the first argument.
For the internal fns (I know of) that have a discriminator argument, I define
the codes in appropriate macros, and then expand them to create the enum
definitions. In the pretty printer I examine the first argument and use that to
index into a string array also built from the code macro.
Ok for trunk? (I've just applied it to gomp4).
nathan
[-- Attachment #2: trunk-pretty.patch --]
[-- Type: text/x-patch, Size: 5188 bytes --]
2016-09-27 Nathan Sidwell <nathan@codesourcery.com>
* 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.
Index: gimple-pretty-print.c
===================================================================
--- gimple-pretty-print.c (revision 240525)
+++ gimple-pretty-print.c (working copy)
@@ -599,9 +599,63 @@ dump_gimple_return (pretty_printer *buff
static void
dump_gimple_call_args (pretty_printer *buffer, gcall *gs, int flags)
{
- size_t i;
+ size_t i = 0;
- for (i = 0; i < gimple_call_num_args (gs); i++)
+ /* 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 < 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)
Index: internal-fn.h
===================================================================
--- internal-fn.h (revision 240525)
+++ internal-fn.h (working copy)
@@ -20,26 +20,28 @@ along with GCC; see the file COPYING3.
#ifndef GCC_INTERNAL_FN_H
#define GCC_INTERNAL_FN_H
-/* INTEGER_CST values for IFN_UNIQUE function arg-0. */
-enum ifn_unique_kind {
- IFN_UNIQUE_UNSPEC, /* Undifferentiated UNIQUE. */
+/* 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.
- 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
+ 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 {
+#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. */
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: internal fn pretty printing
2016-09-27 11:05 internal fn pretty printing Nathan Sidwell
@ 2016-09-27 13:42 ` Bernd Schmidt
2016-09-28 11:33 ` Nathan Sidwell
0 siblings, 1 reply; 3+ messages in thread
From: Bernd Schmidt @ 2016-09-27 13:42 UTC (permalink / raw)
To: Nathan Sidwell, Richard Guenther, Jakub Jelinek; +Cc: GCC Patches
On 09/27/2016 12:58 PM, Nathan Sidwell wrote:
> In working on some new code I got sufficiently frustrated to implement
> pretty printing on internal function discriminators, as I think one of
> you suggested a while back. With this patch we get:
>
> .data_dep.2 = UNIQUE (OACC_FORK, .data_dep.2, -1);
>
> rather than an obscure raw integer for the first argument.
>
> For the internal fns (I know of) that have a discriminator argument, I
> define the codes in appropriate macros, and then expand them to create
> the enum definitions. In the pretty printer I examine the first
> argument and use that to index into a string array also built from the
> code macro.
>
> Ok for trunk? (I've just applied it to gomp4).
Ok.
Bernd
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: internal fn pretty printing
2016-09-27 13:42 ` Bernd Schmidt
@ 2016-09-28 11:33 ` Nathan Sidwell
0 siblings, 0 replies; 3+ messages in thread
From: Nathan Sidwell @ 2016-09-28 11:33 UTC (permalink / raw)
To: Bernd Schmidt, Richard Guenther, Jakub Jelinek; +Cc: GCC Patches
[-- Attachment #1: Type: text/plain, Size: 559 bytes --]
On 09/27/16 09:30, Bernd Schmidt wrote:
> On 09/27/2016 12:58 PM, Nathan Sidwell wrote:
>> In working on some new code I got sufficiently frustrated to implement
>> pretty printing on internal function discriminators, as I think one of
>> you suggested a while back. With this patch we get:
>>
>> .data_dep.2 = UNIQUE (OACC_FORK, .data_dep.2, -1);
>>
>> rather than an obscure raw integer for the first argument.
I realized I could simplify the comma separator logic, by checking i for
non-zeroness before emitting the arg. Committed as obvious.
nathan
[-- Attachment #2: pretty-tweak.patch --]
[-- Type: text/x-patch, Size: 1099 bytes --]
2016-09-28 Nathan Sidwell <nathan@acm.org>
* gimple-pretty-print.c (dump_gimple_call_args): Simplify "' "
printing.
Index: gimple-pretty-print.c
===================================================================
--- gimple-pretty-print.c (revision 240552)
+++ gimple-pretty-print.c (working copy)
@@ -649,26 +649,21 @@ dump_gimple_call_args (pretty_printer *b
{
i++;
pp_string (buffer, enums[v]);
- if (i < gimple_call_num_args (gs))
- pp_string (buffer, ", ");
}
}
}
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)
+ if (i)
pp_string (buffer, ", ");
+ dump_generic_node (buffer, gimple_call_arg (gs, i), 0, flags, false);
}
if (gimple_call_va_arg_pack_p (gs))
{
- if (gimple_call_num_args (gs) > 0)
- {
- pp_comma (buffer);
- pp_space (buffer);
- }
+ if (i)
+ pp_string (buffer, ", ");
pp_string (buffer, "__builtin_va_arg_pack ()");
}
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2016-09-28 11:28 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-09-27 11:05 internal fn pretty printing Nathan Sidwell
2016-09-27 13:42 ` Bernd Schmidt
2016-09-28 11:33 ` Nathan Sidwell
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).