* [PATCH] Abstract out REAL_VALUE_TYPE streaming.
@ 2023-04-18 5:59 Aldy Hernandez
2023-04-18 6:00 ` Aldy Hernandez
0 siblings, 1 reply; 3+ messages in thread
From: Aldy Hernandez @ 2023-04-18 5:59 UTC (permalink / raw)
To: GCC patches; +Cc: Andrew MacLeod, Aldy Hernandez
In upcoming patches I will contribute code to stream out frange's as
well as vrange's. This patch abstracts out the REAL_VALUE_TYPE
streaming into their own functions, so that they may be used elsewhere.
gcc/ChangeLog:
* data-streamer.cc (bp_pack_real_value): New.
(bp_unpack_real_value): New.
* data-streamer.h (bp_pack_real_value): New.
(bp_unpack_real_value): New.
* tree-streamer-in.cc (unpack_ts_real_cst_value_fields): Use
bp_unpack_real_value.
* tree-streamer-out.cc (pack_ts_real_cst_value_fields): Use
bp_pack_real_value.
---
gcc/data-streamer.cc | 33 +++++++++++++++++++++++++++++++++
gcc/data-streamer.h | 2 ++
gcc/tree-streamer-in.cc | 14 +-------------
gcc/tree-streamer-out.cc | 14 ++------------
4 files changed, 38 insertions(+), 25 deletions(-)
diff --git a/gcc/data-streamer.cc b/gcc/data-streamer.cc
index d4b663ba6df..0b9c457f58b 100644
--- a/gcc/data-streamer.cc
+++ b/gcc/data-streamer.cc
@@ -113,3 +113,36 @@ bp_unpack_var_len_int (struct bitpack_d *bp)
}
}
}
+
+/* Pack REAL_VALUE_TYPE R into BP. */
+
+void
+bp_pack_real_value (struct bitpack_d *bp, const REAL_VALUE_TYPE *r)
+{
+ bp_pack_value (bp, r->cl, 2);
+ bp_pack_value (bp, r->decimal, 1);
+ bp_pack_value (bp, r->sign, 1);
+ bp_pack_value (bp, r->signalling, 1);
+ bp_pack_value (bp, r->canonical, 1);
+ bp_pack_value (bp, r->uexp, EXP_BITS);
+ for (unsigned i = 0; i < SIGSZ; i++)
+ bp_pack_value (bp, r->sig[i], HOST_BITS_PER_LONG);
+}
+
+/* Unpack REAL_VALUE_TYPE R from BP. */
+
+void
+bp_unpack_real_value (struct bitpack_d *bp, REAL_VALUE_TYPE *r)
+{
+ /* Clear all bits of the real value type so that we can later do
+ bitwise comparisons to see if two values are the same. */
+ memset (r, 0, sizeof (*r));
+ r->cl = (unsigned) bp_unpack_value (bp, 2);
+ r->decimal = (unsigned) bp_unpack_value (bp, 1);
+ r->sign = (unsigned) bp_unpack_value (bp, 1);
+ r->signalling = (unsigned) bp_unpack_value (bp, 1);
+ r->canonical = (unsigned) bp_unpack_value (bp, 1);
+ r->uexp = (unsigned) bp_unpack_value (bp, EXP_BITS);
+ for (unsigned i = 0; i < SIGSZ; i++)
+ r->sig[i] = (unsigned long) bp_unpack_value (bp, HOST_BITS_PER_LONG);
+}
diff --git a/gcc/data-streamer.h b/gcc/data-streamer.h
index d8c7e21dad9..19c9d6ea606 100644
--- a/gcc/data-streamer.h
+++ b/gcc/data-streamer.h
@@ -46,6 +46,8 @@ struct bitpack_d
/* In data-streamer.cc */
void bp_pack_var_len_unsigned (struct bitpack_d *, unsigned HOST_WIDE_INT);
void bp_pack_var_len_int (struct bitpack_d *, HOST_WIDE_INT);
+void bp_pack_real_value (struct bitpack_d *, const REAL_VALUE_TYPE *);
+void bp_unpack_real_value (struct bitpack_d *, REAL_VALUE_TYPE *);
unsigned HOST_WIDE_INT bp_unpack_var_len_unsigned (struct bitpack_d *);
HOST_WIDE_INT bp_unpack_var_len_int (struct bitpack_d *);
diff --git a/gcc/tree-streamer-in.cc b/gcc/tree-streamer-in.cc
index d4dc30f048f..bf4bd5c3dd3 100644
--- a/gcc/tree-streamer-in.cc
+++ b/gcc/tree-streamer-in.cc
@@ -188,21 +188,9 @@ unpack_ts_int_cst_value_fields (struct bitpack_d *bp, tree expr)
static void
unpack_ts_real_cst_value_fields (struct bitpack_d *bp, tree expr)
{
- unsigned i;
REAL_VALUE_TYPE r;
- /* Clear all bits of the real value type so that we can later do
- bitwise comparisons to see if two values are the same. */
- memset (&r, 0, sizeof r);
- r.cl = (unsigned) bp_unpack_value (bp, 2);
- r.decimal = (unsigned) bp_unpack_value (bp, 1);
- r.sign = (unsigned) bp_unpack_value (bp, 1);
- r.signalling = (unsigned) bp_unpack_value (bp, 1);
- r.canonical = (unsigned) bp_unpack_value (bp, 1);
- r.uexp = (unsigned) bp_unpack_value (bp, EXP_BITS);
- for (i = 0; i < SIGSZ; i++)
- r.sig[i] = (unsigned long) bp_unpack_value (bp, HOST_BITS_PER_LONG);
-
+ bp_unpack_real_value (bp, &r);
memcpy (TREE_REAL_CST_PTR (expr), &r, sizeof (REAL_VALUE_TYPE));
}
diff --git a/gcc/tree-streamer-out.cc b/gcc/tree-streamer-out.cc
index d107229da5c..81e6fcb5af0 100644
--- a/gcc/tree-streamer-out.cc
+++ b/gcc/tree-streamer-out.cc
@@ -166,18 +166,8 @@ pack_ts_int_cst_value_fields (struct bitpack_d *bp, tree expr)
static void
pack_ts_real_cst_value_fields (struct bitpack_d *bp, tree expr)
{
- unsigned i;
- REAL_VALUE_TYPE r;
-
- r = TREE_REAL_CST (expr);
- bp_pack_value (bp, r.cl, 2);
- bp_pack_value (bp, r.decimal, 1);
- bp_pack_value (bp, r.sign, 1);
- bp_pack_value (bp, r.signalling, 1);
- bp_pack_value (bp, r.canonical, 1);
- bp_pack_value (bp, r.uexp, EXP_BITS);
- for (i = 0; i < SIGSZ; i++)
- bp_pack_value (bp, r.sig[i], HOST_BITS_PER_LONG);
+ REAL_VALUE_TYPE r = TREE_REAL_CST (expr);
+ bp_pack_real_value (bp, &r);
}
--
2.39.2
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] Abstract out REAL_VALUE_TYPE streaming.
2023-04-18 5:59 [PATCH] Abstract out REAL_VALUE_TYPE streaming Aldy Hernandez
@ 2023-04-18 6:00 ` Aldy Hernandez
2023-04-18 8:03 ` Richard Biener
0 siblings, 1 reply; 3+ messages in thread
From: Aldy Hernandez @ 2023-04-18 6:00 UTC (permalink / raw)
To: GCC patches; +Cc: Andrew MacLeod
Sorry, forgot to ask...
Tested on x86-64 Linux.
OK for trunk?
On 4/18/23 07:59, Aldy Hernandez wrote:
> In upcoming patches I will contribute code to stream out frange's as
> well as vrange's. This patch abstracts out the REAL_VALUE_TYPE
> streaming into their own functions, so that they may be used elsewhere.
>
> gcc/ChangeLog:
>
> * data-streamer.cc (bp_pack_real_value): New.
> (bp_unpack_real_value): New.
> * data-streamer.h (bp_pack_real_value): New.
> (bp_unpack_real_value): New.
> * tree-streamer-in.cc (unpack_ts_real_cst_value_fields): Use
> bp_unpack_real_value.
> * tree-streamer-out.cc (pack_ts_real_cst_value_fields): Use
> bp_pack_real_value.
> ---
> gcc/data-streamer.cc | 33 +++++++++++++++++++++++++++++++++
> gcc/data-streamer.h | 2 ++
> gcc/tree-streamer-in.cc | 14 +-------------
> gcc/tree-streamer-out.cc | 14 ++------------
> 4 files changed, 38 insertions(+), 25 deletions(-)
>
> diff --git a/gcc/data-streamer.cc b/gcc/data-streamer.cc
> index d4b663ba6df..0b9c457f58b 100644
> --- a/gcc/data-streamer.cc
> +++ b/gcc/data-streamer.cc
> @@ -113,3 +113,36 @@ bp_unpack_var_len_int (struct bitpack_d *bp)
> }
> }
> }
> +
> +/* Pack REAL_VALUE_TYPE R into BP. */
> +
> +void
> +bp_pack_real_value (struct bitpack_d *bp, const REAL_VALUE_TYPE *r)
> +{
> + bp_pack_value (bp, r->cl, 2);
> + bp_pack_value (bp, r->decimal, 1);
> + bp_pack_value (bp, r->sign, 1);
> + bp_pack_value (bp, r->signalling, 1);
> + bp_pack_value (bp, r->canonical, 1);
> + bp_pack_value (bp, r->uexp, EXP_BITS);
> + for (unsigned i = 0; i < SIGSZ; i++)
> + bp_pack_value (bp, r->sig[i], HOST_BITS_PER_LONG);
> +}
> +
> +/* Unpack REAL_VALUE_TYPE R from BP. */
> +
> +void
> +bp_unpack_real_value (struct bitpack_d *bp, REAL_VALUE_TYPE *r)
> +{
> + /* Clear all bits of the real value type so that we can later do
> + bitwise comparisons to see if two values are the same. */
> + memset (r, 0, sizeof (*r));
> + r->cl = (unsigned) bp_unpack_value (bp, 2);
> + r->decimal = (unsigned) bp_unpack_value (bp, 1);
> + r->sign = (unsigned) bp_unpack_value (bp, 1);
> + r->signalling = (unsigned) bp_unpack_value (bp, 1);
> + r->canonical = (unsigned) bp_unpack_value (bp, 1);
> + r->uexp = (unsigned) bp_unpack_value (bp, EXP_BITS);
> + for (unsigned i = 0; i < SIGSZ; i++)
> + r->sig[i] = (unsigned long) bp_unpack_value (bp, HOST_BITS_PER_LONG);
> +}
> diff --git a/gcc/data-streamer.h b/gcc/data-streamer.h
> index d8c7e21dad9..19c9d6ea606 100644
> --- a/gcc/data-streamer.h
> +++ b/gcc/data-streamer.h
> @@ -46,6 +46,8 @@ struct bitpack_d
> /* In data-streamer.cc */
> void bp_pack_var_len_unsigned (struct bitpack_d *, unsigned HOST_WIDE_INT);
> void bp_pack_var_len_int (struct bitpack_d *, HOST_WIDE_INT);
> +void bp_pack_real_value (struct bitpack_d *, const REAL_VALUE_TYPE *);
> +void bp_unpack_real_value (struct bitpack_d *, REAL_VALUE_TYPE *);
> unsigned HOST_WIDE_INT bp_unpack_var_len_unsigned (struct bitpack_d *);
> HOST_WIDE_INT bp_unpack_var_len_int (struct bitpack_d *);
>
> diff --git a/gcc/tree-streamer-in.cc b/gcc/tree-streamer-in.cc
> index d4dc30f048f..bf4bd5c3dd3 100644
> --- a/gcc/tree-streamer-in.cc
> +++ b/gcc/tree-streamer-in.cc
> @@ -188,21 +188,9 @@ unpack_ts_int_cst_value_fields (struct bitpack_d *bp, tree expr)
> static void
> unpack_ts_real_cst_value_fields (struct bitpack_d *bp, tree expr)
> {
> - unsigned i;
> REAL_VALUE_TYPE r;
>
> - /* Clear all bits of the real value type so that we can later do
> - bitwise comparisons to see if two values are the same. */
> - memset (&r, 0, sizeof r);
> - r.cl = (unsigned) bp_unpack_value (bp, 2);
> - r.decimal = (unsigned) bp_unpack_value (bp, 1);
> - r.sign = (unsigned) bp_unpack_value (bp, 1);
> - r.signalling = (unsigned) bp_unpack_value (bp, 1);
> - r.canonical = (unsigned) bp_unpack_value (bp, 1);
> - r.uexp = (unsigned) bp_unpack_value (bp, EXP_BITS);
> - for (i = 0; i < SIGSZ; i++)
> - r.sig[i] = (unsigned long) bp_unpack_value (bp, HOST_BITS_PER_LONG);
> -
> + bp_unpack_real_value (bp, &r);
> memcpy (TREE_REAL_CST_PTR (expr), &r, sizeof (REAL_VALUE_TYPE));
> }
>
> diff --git a/gcc/tree-streamer-out.cc b/gcc/tree-streamer-out.cc
> index d107229da5c..81e6fcb5af0 100644
> --- a/gcc/tree-streamer-out.cc
> +++ b/gcc/tree-streamer-out.cc
> @@ -166,18 +166,8 @@ pack_ts_int_cst_value_fields (struct bitpack_d *bp, tree expr)
> static void
> pack_ts_real_cst_value_fields (struct bitpack_d *bp, tree expr)
> {
> - unsigned i;
> - REAL_VALUE_TYPE r;
> -
> - r = TREE_REAL_CST (expr);
> - bp_pack_value (bp, r.cl, 2);
> - bp_pack_value (bp, r.decimal, 1);
> - bp_pack_value (bp, r.sign, 1);
> - bp_pack_value (bp, r.signalling, 1);
> - bp_pack_value (bp, r.canonical, 1);
> - bp_pack_value (bp, r.uexp, EXP_BITS);
> - for (i = 0; i < SIGSZ; i++)
> - bp_pack_value (bp, r.sig[i], HOST_BITS_PER_LONG);
> + REAL_VALUE_TYPE r = TREE_REAL_CST (expr);
> + bp_pack_real_value (bp, &r);
> }
>
>
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] Abstract out REAL_VALUE_TYPE streaming.
2023-04-18 6:00 ` Aldy Hernandez
@ 2023-04-18 8:03 ` Richard Biener
0 siblings, 0 replies; 3+ messages in thread
From: Richard Biener @ 2023-04-18 8:03 UTC (permalink / raw)
To: Aldy Hernandez; +Cc: GCC patches, Andrew MacLeod
On Tue, Apr 18, 2023 at 8:01 AM Aldy Hernandez via Gcc-patches
<gcc-patches@gcc.gnu.org> wrote:
>
> Sorry, forgot to ask...
>
> Tested on x86-64 Linux.
>
> OK for trunk?
OK.
> On 4/18/23 07:59, Aldy Hernandez wrote:
> > In upcoming patches I will contribute code to stream out frange's as
> > well as vrange's. This patch abstracts out the REAL_VALUE_TYPE
> > streaming into their own functions, so that they may be used elsewhere.
> >
> > gcc/ChangeLog:
> >
> > * data-streamer.cc (bp_pack_real_value): New.
> > (bp_unpack_real_value): New.
> > * data-streamer.h (bp_pack_real_value): New.
> > (bp_unpack_real_value): New.
> > * tree-streamer-in.cc (unpack_ts_real_cst_value_fields): Use
> > bp_unpack_real_value.
> > * tree-streamer-out.cc (pack_ts_real_cst_value_fields): Use
> > bp_pack_real_value.
> > ---
> > gcc/data-streamer.cc | 33 +++++++++++++++++++++++++++++++++
> > gcc/data-streamer.h | 2 ++
> > gcc/tree-streamer-in.cc | 14 +-------------
> > gcc/tree-streamer-out.cc | 14 ++------------
> > 4 files changed, 38 insertions(+), 25 deletions(-)
> >
> > diff --git a/gcc/data-streamer.cc b/gcc/data-streamer.cc
> > index d4b663ba6df..0b9c457f58b 100644
> > --- a/gcc/data-streamer.cc
> > +++ b/gcc/data-streamer.cc
> > @@ -113,3 +113,36 @@ bp_unpack_var_len_int (struct bitpack_d *bp)
> > }
> > }
> > }
> > +
> > +/* Pack REAL_VALUE_TYPE R into BP. */
> > +
> > +void
> > +bp_pack_real_value (struct bitpack_d *bp, const REAL_VALUE_TYPE *r)
> > +{
> > + bp_pack_value (bp, r->cl, 2);
> > + bp_pack_value (bp, r->decimal, 1);
> > + bp_pack_value (bp, r->sign, 1);
> > + bp_pack_value (bp, r->signalling, 1);
> > + bp_pack_value (bp, r->canonical, 1);
> > + bp_pack_value (bp, r->uexp, EXP_BITS);
> > + for (unsigned i = 0; i < SIGSZ; i++)
> > + bp_pack_value (bp, r->sig[i], HOST_BITS_PER_LONG);
> > +}
> > +
> > +/* Unpack REAL_VALUE_TYPE R from BP. */
> > +
> > +void
> > +bp_unpack_real_value (struct bitpack_d *bp, REAL_VALUE_TYPE *r)
> > +{
> > + /* Clear all bits of the real value type so that we can later do
> > + bitwise comparisons to see if two values are the same. */
> > + memset (r, 0, sizeof (*r));
> > + r->cl = (unsigned) bp_unpack_value (bp, 2);
> > + r->decimal = (unsigned) bp_unpack_value (bp, 1);
> > + r->sign = (unsigned) bp_unpack_value (bp, 1);
> > + r->signalling = (unsigned) bp_unpack_value (bp, 1);
> > + r->canonical = (unsigned) bp_unpack_value (bp, 1);
> > + r->uexp = (unsigned) bp_unpack_value (bp, EXP_BITS);
> > + for (unsigned i = 0; i < SIGSZ; i++)
> > + r->sig[i] = (unsigned long) bp_unpack_value (bp, HOST_BITS_PER_LONG);
> > +}
> > diff --git a/gcc/data-streamer.h b/gcc/data-streamer.h
> > index d8c7e21dad9..19c9d6ea606 100644
> > --- a/gcc/data-streamer.h
> > +++ b/gcc/data-streamer.h
> > @@ -46,6 +46,8 @@ struct bitpack_d
> > /* In data-streamer.cc */
> > void bp_pack_var_len_unsigned (struct bitpack_d *, unsigned HOST_WIDE_INT);
> > void bp_pack_var_len_int (struct bitpack_d *, HOST_WIDE_INT);
> > +void bp_pack_real_value (struct bitpack_d *, const REAL_VALUE_TYPE *);
> > +void bp_unpack_real_value (struct bitpack_d *, REAL_VALUE_TYPE *);
> > unsigned HOST_WIDE_INT bp_unpack_var_len_unsigned (struct bitpack_d *);
> > HOST_WIDE_INT bp_unpack_var_len_int (struct bitpack_d *);
> >
> > diff --git a/gcc/tree-streamer-in.cc b/gcc/tree-streamer-in.cc
> > index d4dc30f048f..bf4bd5c3dd3 100644
> > --- a/gcc/tree-streamer-in.cc
> > +++ b/gcc/tree-streamer-in.cc
> > @@ -188,21 +188,9 @@ unpack_ts_int_cst_value_fields (struct bitpack_d *bp, tree expr)
> > static void
> > unpack_ts_real_cst_value_fields (struct bitpack_d *bp, tree expr)
> > {
> > - unsigned i;
> > REAL_VALUE_TYPE r;
> >
> > - /* Clear all bits of the real value type so that we can later do
> > - bitwise comparisons to see if two values are the same. */
> > - memset (&r, 0, sizeof r);
> > - r.cl = (unsigned) bp_unpack_value (bp, 2);
> > - r.decimal = (unsigned) bp_unpack_value (bp, 1);
> > - r.sign = (unsigned) bp_unpack_value (bp, 1);
> > - r.signalling = (unsigned) bp_unpack_value (bp, 1);
> > - r.canonical = (unsigned) bp_unpack_value (bp, 1);
> > - r.uexp = (unsigned) bp_unpack_value (bp, EXP_BITS);
> > - for (i = 0; i < SIGSZ; i++)
> > - r.sig[i] = (unsigned long) bp_unpack_value (bp, HOST_BITS_PER_LONG);
> > -
> > + bp_unpack_real_value (bp, &r);
> > memcpy (TREE_REAL_CST_PTR (expr), &r, sizeof (REAL_VALUE_TYPE));
> > }
> >
> > diff --git a/gcc/tree-streamer-out.cc b/gcc/tree-streamer-out.cc
> > index d107229da5c..81e6fcb5af0 100644
> > --- a/gcc/tree-streamer-out.cc
> > +++ b/gcc/tree-streamer-out.cc
> > @@ -166,18 +166,8 @@ pack_ts_int_cst_value_fields (struct bitpack_d *bp, tree expr)
> > static void
> > pack_ts_real_cst_value_fields (struct bitpack_d *bp, tree expr)
> > {
> > - unsigned i;
> > - REAL_VALUE_TYPE r;
> > -
> > - r = TREE_REAL_CST (expr);
> > - bp_pack_value (bp, r.cl, 2);
> > - bp_pack_value (bp, r.decimal, 1);
> > - bp_pack_value (bp, r.sign, 1);
> > - bp_pack_value (bp, r.signalling, 1);
> > - bp_pack_value (bp, r.canonical, 1);
> > - bp_pack_value (bp, r.uexp, EXP_BITS);
> > - for (i = 0; i < SIGSZ; i++)
> > - bp_pack_value (bp, r.sig[i], HOST_BITS_PER_LONG);
> > + REAL_VALUE_TYPE r = TREE_REAL_CST (expr);
> > + bp_pack_real_value (bp, &r);
> > }
> >
> >
>
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2023-04-18 8:03 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-04-18 5:59 [PATCH] Abstract out REAL_VALUE_TYPE streaming Aldy Hernandez
2023-04-18 6:00 ` Aldy Hernandez
2023-04-18 8:03 ` 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).