]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
Abstract out REAL_VALUE_TYPE streaming.
authorAldy Hernandez <aldyh@redhat.com>
Tue, 18 Apr 2023 05:56:52 +0000 (07:56 +0200)
committerAldy Hernandez <aldyh@redhat.com>
Tue, 18 Apr 2023 08:49:33 +0000 (10:49 +0200)
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
gcc/data-streamer.h
gcc/tree-streamer-in.cc
gcc/tree-streamer-out.cc

index d4b663ba6df0e08c34dbccecd61f17692a72106b..0b9c457f58b955acb855f3ea80633a1449fdc0d4 100644 (file)
@@ -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);
+}
index d8c7e21dad9b32814695c6ee09a19a8bc23b4d05..19c9d6ea6069348521b5b77e6d2114cca5df06e2 100644 (file)
@@ -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 *);
 
index d4dc30f048f5c975ff0f11fdc89e84a582ff36b7..bf4bd5c3dd36dc6f2600bcab44082d1add10a221 100644 (file)
@@ -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));
 }
 
index d107229da5cc0d62752f3e37b0438457f3af99c9..81e6fcb5af0ce7262dacd4f553377150146a1519 100644 (file)
@@ -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);
 }