diff options
author | Aldy Hernandez <aldyh@redhat.com> | 2023-04-18 07:56:52 +0200 |
---|---|---|
committer | Aldy Hernandez <aldyh@redhat.com> | 2023-04-18 10:49:33 +0200 |
commit | 6e552ec218a04dac046066e2608202ba90d66f11 (patch) | |
tree | 507cc5dc793ec27e6655fcf0c1074e3ddacb2e95 /gcc/data-streamer.cc | |
parent | 5baf2cccd0345a7ac3d4467343414f8b7ff1724b (diff) | |
download | gcc-6e552ec218a04dac046066e2608202ba90d66f11.zip gcc-6e552ec218a04dac046066e2608202ba90d66f11.tar.gz gcc-6e552ec218a04dac046066e2608202ba90d66f11.tar.bz2 |
Abstract out REAL_VALUE_TYPE streaming.
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.
Diffstat (limited to 'gcc/data-streamer.cc')
-rw-r--r-- | gcc/data-streamer.cc | 33 |
1 files changed, 33 insertions, 0 deletions
diff --git a/gcc/data-streamer.cc b/gcc/data-streamer.cc index d4b663b..0b9c457 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); +} |