]> git.ipfire.org Git - thirdparty/gcc.git/commit
cobol: Improve MOVE BINARY/COMP-5 to PACKED-DECIMAL and NUMERIC-DISPLAY master trunk
authorRobert Dubner <rdubner@symas.com>
Thu, 25 Jun 2026 02:46:34 +0000 (22:46 -0400)
committerRobert Dubner <rdubner@symas.com>
Thu, 25 Jun 2026 02:59:02 +0000 (22:59 -0400)
commite36ce9a6a54e3709b95da494732a55e481336360
treefb42eeead8f8af1d5153a2a2a0e36c8a24c4470c
parent3e7b6ef6bca0173902e9f3d81ec51581f0e81846
cobol: Improve MOVE BINARY/COMP-5 to PACKED-DECIMAL and NUMERIC-DISPLAY

These are more efficient algorithms for converting binary values to
packed-decimal and zoned decimal byte strings.  There is also an
improved routine that generates GENERIC to do COBOL rounding during
such moves.

gcc/cobol/ChangeLog:

* gengen.cc (gg_abs): Use fold_build1().
* genutil.cc (scale_and_round): Remove function.
(round_this_value): New function for rounding.
* genutil.h (scale_and_round): Remove function.
(round_this_value): New declaration.
* move.cc (cobol_wider_type_with_x_signedness): New function.
(mh_binary_to_numdisp): Faster routine.
(mh_binary_to_packed): Faster routine.
(move_helper): Use the faster routines.

libgcobol/ChangeLog:

* charmaps.cc (__gg__miconverter): Use table instead of a map.
(__gg__get_charmap): Likewise.
* charmaps.h (ebcdic_zero): New constant.
(ebcdic_plus): Likewise.
(ebcdic_minus): Likewise.
* encodings.h (enum cbl_encoding_t): Guardrail for table.
(ASCII_e): Remove trailing spaces.
* stringbin.cc (string_from_combined): Improved routine.
(defined): Likewise.
(FALLTHROUGH): Likewise.
(uint_to_8_digits): Improve speed.
(__gg__binary_to_string_ascii): Likewise.
(binary_to_string): Likewise.
(__gg__binary_to_string_ebcdic): Likewise.
(__gg__binary_to_string_encoded): Likewise.
(packed_from_combined): Likewise.
(__gg__binary_to_packed): Likewise.
(__gg__packed_to_binary): Likewise.

gcc/testsuite/ChangeLog:

* cobol.dg/group1/simple-classes.cob:
* cobol.dg/group1/simple-if.cob:
* cobol.dg/group2/Rounding_from_BINARY_signable_and_negative.cob: New test.
* cobol.dg/group2/Rounding_from_BINARY_signable_and_negative.out: New test.
* cobol.dg/group2/Rounding_from_BINARY_signable_and_positive.cob: New test.
* cobol.dg/group2/Rounding_from_BINARY_signable_and_positive.out: New test.
* cobol.dg/group2/Rounding_from_BINARY_unsignable.cob: New test.
* cobol.dg/group2/Rounding_from_BINARY_unsignable.out: New test.
16 files changed:
gcc/cobol/gengen.cc
gcc/cobol/genutil.cc
gcc/cobol/genutil.h
gcc/cobol/move.cc
gcc/testsuite/cobol.dg/group1/simple-classes.cob
gcc/testsuite/cobol.dg/group1/simple-if.cob
gcc/testsuite/cobol.dg/group2/Rounding_from_BINARY_signable_and_negative.cob [new file with mode: 0644]
gcc/testsuite/cobol.dg/group2/Rounding_from_BINARY_signable_and_negative.out [new file with mode: 0644]
gcc/testsuite/cobol.dg/group2/Rounding_from_BINARY_signable_and_positive.cob [new file with mode: 0644]
gcc/testsuite/cobol.dg/group2/Rounding_from_BINARY_signable_and_positive.out [new file with mode: 0644]
gcc/testsuite/cobol.dg/group2/Rounding_from_BINARY_unsignable.cob [new file with mode: 0644]
gcc/testsuite/cobol.dg/group2/Rounding_from_BINARY_unsignable.out [new file with mode: 0644]
libgcobol/charmaps.cc
libgcobol/charmaps.h
libgcobol/encodings.h
libgcobol/stringbin.cc