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.oc...@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. */


Reply via email to