]> git.ipfire.org Git - thirdparty/gcc.git/commit
fold-const, cobol: Add native_encode_wide_int and use it in COBOL FE [PR119242]
authorJakub Jelinek <jakub@redhat.com>
Thu, 3 Apr 2025 06:32:09 +0000 (08:32 +0200)
committerJakub Jelinek <jakub@gcc.gnu.org>
Thu, 3 Apr 2025 06:32:09 +0000 (08:32 +0200)
commit1bfc026035e6bade36538077dc1dd4f9baff0bf2
tree016d65e79f444e56ad5eda60ee134f9a349f891a
parent366dd47dc560a37cdf01a4c49a446596564419a0
fold-const, cobol: Add native_encode_wide_int and use it in COBOL FE [PR119242]

As has been mentioned earlier, various parts of the COBOL FE and the library
aren't endian clean.  In the library that means that for now we have to
live with no support for big endian targets, but in the FE that means
that as well as not being able to build cross-compilers from big endian
or pdp endian hosts to little endian targets which are otherwise supported.

The following patch attempts to fix one such spot, where it wants to encode
in target byte ordering wide_int constants into 1, 2, 4, 8 or 16 bytes.

We could wide_int_to_tree and then native_encode_expr, but so that we don't
need to build the constants, the following patch exports from fold-const.cc
a helper for native_encode_int which takes type and const wide_int_ref
reference rather than an expression.

2025-04-03  Jakub Jelinek  <jakub@redhat.com>

PR cobol/119242
gcc/
* fold-const.h (native_encode_wide_int): Declare.
* fold-const.cc (native_encode_wide_int): New function.
(native_encode_int): Use it.
gcc/cobol/
* genapi.cc (binary_initial_from_float128): Use
native_encode_wide_int.
gcc/cobol/genapi.cc
gcc/fold-const.cc
gcc/fold-const.h