* [PATCH] Adds wrapper for gimple_return_retval to accept gimple*
@ 2020-05-16 9:41 Erick Ochoa
2020-05-16 17:56 ` Richard Biener
0 siblings, 1 reply; 2+ messages in thread
From: Erick Ochoa @ 2020-05-16 9:41 UTC (permalink / raw)
To: gcc-patches; +Cc: Christoph Müllner, Philipp Tomsich
Adds wrapper for gimple_return_retval to accept gimple*
Most functions interact with GIMPLE IL using arguments of type gimple*.
Functions interacting with GIMPLE_RETURN instructions still use greturn*
types as arguments. This patch adds wrappers around functions taking
greturn* as inputs. The wrapper takes gimple* as arguments.
ChangeLog:
2020-05-16 Erick Ochoa <erick.ochoa@theobroma-systems.com>
* gcc/gimple.h (gimple_return_retval): New function
(gimple_return_retval_ptr): same
(gimple_return_set_retval): same
* gcc/gimple.texi (gimple_return_retval): Fix documentation
(gimple_return_retval_ptr): same
(gimple_return_set_retval): same
diff --git a/gcc/doc/gimple.texi b/gcc/doc/gimple.texi
index 5e0fc2e0dc5..d4a73b8397c 100644
--- a/gcc/doc/gimple.texi
+++ b/gcc/doc/gimple.texi
@@ -2234,11 +2234,15 @@ Set @code{REGION} to be the region number for
@code{GIMPLE_RESX} @code{G}.
Build a @code{GIMPLE_RETURN} statement whose return value is retval.
@end deftypefn
-@deftypefn {GIMPLE function} tree gimple_return_retval (const greturn *g)
+@deftypefn {GIMPLE function} tree gimple_return_retval (const gimple *g)
Return the return value for @code{GIMPLE_RETURN} @code{G}.
@end deftypefn
-@deftypefn {GIMPLE function} void gimple_return_set_retval (greturn *g, @
+@deftypefn {GIMPLE function} {tree *} gimple_return_retval_ptr (gimple *g)
+Return the return value for @code{GIMPLE_RETURN} @code{G}.
+@end deftypefn
+
+@deftypefn {GIMPLE function} void gimple_return_set_retval (gimple *g, @
tree retval)
Set @code{RETVAL} to be the return value for @code{GIMPLE_RETURN}
@code{G}.
@end deftypefn
diff --git a/gcc/gimple.h b/gcc/gimple.h
index ca7fec6247e..730803f0924 100644
--- a/gcc/gimple.h
+++ b/gcc/gimple.h
@@ -6502,6 +6502,14 @@ gimple_return_retval_ptr (greturn *gs)
return &gs->op[0];
}
+static inline tree *
+gimple_return_retval_ptr (gimple *gs)
+{
+ GIMPLE_CHECK (gs, GIMPLE_RETURN);
+ greturn *gr = dyn_cast <greturn *> (gs);
+ return gimple_return_retval_ptr (gr);
+}
+
/* Return the return value for GIMPLE_RETURN GS. */
static inline tree
@@ -6510,6 +6518,15 @@ gimple_return_retval (const greturn *gs)
return gs->op[0];
}
+static inline tree
+gimple_return_retval (const gimple *gs)
+{
+ GIMPLE_CHECK (gs, GIMPLE_RETURN);
+ const greturn *gr = dyn_cast <const greturn *> (gs);
+ return gimple_return_retval (gr);
+}
+
+
/* Set RETVAL to be the return value for GIMPLE_RETURN GS. */
@@ -6519,6 +6536,14 @@ gimple_return_set_retval (greturn *gs, tree retval)
gs->op[0] = retval;
}
+static inline void
+gimple_return_set_retval (gimple *gs, tree retval)
+{
+ GIMPLE_CHECK (gs, GIMPLE_RETURN);
+ greturn *gr = dyn_cast <greturn *> (gs);
+ gimple_return_set_retval (gr, retval);
+}
+
/* Returns true when the gimple statement STMT is any of the OMP
types. */
^ permalink raw reply [flat|nested] 2+ messages in thread
* Re: [PATCH] Adds wrapper for gimple_return_retval to accept gimple*
2020-05-16 9:41 [PATCH] Adds wrapper for gimple_return_retval to accept gimple* Erick Ochoa
@ 2020-05-16 17:56 ` Richard Biener
0 siblings, 0 replies; 2+ messages in thread
From: Richard Biener @ 2020-05-16 17:56 UTC (permalink / raw)
To: gcc-patches, Erick Ochoa; +Cc: Philipp Tomsich, Christoph Müllner
On May 16, 2020 11:41:51 AM GMT+02:00, Erick Ochoa <erick.ochoa@theobroma-systems.com> wrote:
>Adds wrapper for gimple_return_retval to accept gimple*
>
>Most functions interact with GIMPLE IL using arguments of type gimple*.
>
>Functions interacting with GIMPLE_RETURN instructions still use
>greturn*
>types as arguments. This patch adds wrappers around functions taking
>greturn* as inputs. The wrapper takes gimple* as arguments.
That's backwards. The gimple * variants are legacy and should go away. Code should use the strongly typed accessors instead.
Richard.
>ChangeLog:
>
>2020-05-16 Erick Ochoa <erick.ochoa@theobroma-systems.com>
>
> * gcc/gimple.h (gimple_return_retval): New function
> (gimple_return_retval_ptr): same
> (gimple_return_set_retval): same
> * gcc/gimple.texi (gimple_return_retval): Fix documentation
> (gimple_return_retval_ptr): same
> (gimple_return_set_retval): same
>
>diff --git a/gcc/doc/gimple.texi b/gcc/doc/gimple.texi
>index 5e0fc2e0dc5..d4a73b8397c 100644
>--- a/gcc/doc/gimple.texi
>+++ b/gcc/doc/gimple.texi
>@@ -2234,11 +2234,15 @@ Set @code{REGION} to be the region number for
>@code{GIMPLE_RESX} @code{G}.
> Build a @code{GIMPLE_RETURN} statement whose return value is retval.
> @end deftypefn
>
>-@deftypefn {GIMPLE function} tree gimple_return_retval (const greturn
>*g)
>+@deftypefn {GIMPLE function} tree gimple_return_retval (const gimple
>*g)
> Return the return value for @code{GIMPLE_RETURN} @code{G}.
> @end deftypefn
>
>-@deftypefn {GIMPLE function} void gimple_return_set_retval (greturn
>*g, @
>+@deftypefn {GIMPLE function} {tree *} gimple_return_retval_ptr (gimple
>*g)
>+Return the return value for @code{GIMPLE_RETURN} @code{G}.
>+@end deftypefn
>+
>+@deftypefn {GIMPLE function} void gimple_return_set_retval (gimple *g,
>@
> tree retval)
> Set @code{RETVAL} to be the return value for @code{GIMPLE_RETURN}
>@code{G}.
> @end deftypefn
>diff --git a/gcc/gimple.h b/gcc/gimple.h
>index ca7fec6247e..730803f0924 100644
>--- a/gcc/gimple.h
>+++ b/gcc/gimple.h
>@@ -6502,6 +6502,14 @@ gimple_return_retval_ptr (greturn *gs)
> return &gs->op[0];
> }
>
>+static inline tree *
>+gimple_return_retval_ptr (gimple *gs)
>+{
>+ GIMPLE_CHECK (gs, GIMPLE_RETURN);
>+ greturn *gr = dyn_cast <greturn *> (gs);
>+ return gimple_return_retval_ptr (gr);
>+}
>+
> /* Return the return value for GIMPLE_RETURN GS. */
>
> static inline tree
>@@ -6510,6 +6518,15 @@ gimple_return_retval (const greturn *gs)
> return gs->op[0];
> }
>
>+static inline tree
>+gimple_return_retval (const gimple *gs)
>+{
>+ GIMPLE_CHECK (gs, GIMPLE_RETURN);
>+ const greturn *gr = dyn_cast <const greturn *> (gs);
>+ return gimple_return_retval (gr);
>+}
>+
>+
>
> /* Set RETVAL to be the return value for GIMPLE_RETURN GS. */
>
>@@ -6519,6 +6536,14 @@ gimple_return_set_retval (greturn *gs, tree
>retval)
> gs->op[0] = retval;
> }
>
>+static inline void
>+gimple_return_set_retval (gimple *gs, tree retval)
>+{
>+ GIMPLE_CHECK (gs, GIMPLE_RETURN);
>+ greturn *gr = dyn_cast <greturn *> (gs);
>+ gimple_return_set_retval (gr, retval);
>+}
>+
>
> /* Returns true when the gimple statement STMT is any of the OMP
>types. */
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2020-05-16 17:56 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-05-16 9:41 [PATCH] Adds wrapper for gimple_return_retval to accept gimple* Erick Ochoa
2020-05-16 17:56 ` Richard Biener
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).