diff options
author | Richard Sandiford <richard.sandiford@arm.com> | 2023-09-29 09:24:43 +0100 |
---|---|---|
committer | Richard Sandiford <richard.sandiford@arm.com> | 2023-09-29 09:24:43 +0100 |
commit | bcc97edf8c9e40232fa30e7f0070057b6516fd77 (patch) | |
tree | 4457e05d3703a635195bde481715f7045391da0a /gcc/expr.cc | |
parent | a561369743025fd64a3d87bc571d0503b17a82c8 (diff) | |
download | gcc-bcc97edf8c9e40232fa30e7f0070057b6516fd77.zip gcc-bcc97edf8c9e40232fa30e7f0070057b6516fd77.tar.gz gcc-bcc97edf8c9e40232fa30e7f0070057b6516fd77.tar.bz2 |
Simplify & expand c_readstr
c_readstr only operated on integer modes. It worked by reading
the source string into an array of HOST_WIDE_INTs, converting
that array into a wide_int, and from there to an rtx.
It's simpler to do this by building a target memory image and
using native_decode_rtx to convert that memory image into an rtx.
It avoids all the endianness shenanigans because both the string and
native_decode_rtx follow target memory order. It also means that the
function can handle all fixed-size modes, which simplifies callers
and allows vector modes to be used more widely.
gcc/
* builtins.h (c_readstr): Take a fixed_size_mode rather than a
scalar_int_mode.
* builtins.cc (c_readstr): Likewise. Build a local array of
bytes and use native_decode_rtx to get the rtx image.
(builtin_memcpy_read_str): Simplify accordingly.
(builtin_strncpy_read_str): Likewise.
(builtin_memset_read_str): Likewise.
(builtin_memset_gen_str): Likewise.
* expr.cc (string_cst_read_str): Likewise.
Diffstat (limited to 'gcc/expr.cc')
-rw-r--r-- | gcc/expr.cc | 7 |
1 files changed, 2 insertions, 5 deletions
diff --git a/gcc/expr.cc b/gcc/expr.cc index 308ddc0..2c9930e 100644 --- a/gcc/expr.cc +++ b/gcc/expr.cc @@ -6083,13 +6083,10 @@ string_cst_read_str (void *data, void *, HOST_WIDE_INT offset, size_t l = TREE_STRING_LENGTH (str) - offset; memcpy (p, TREE_STRING_POINTER (str) + offset, l); memset (p + l, '\0', GET_MODE_SIZE (mode) - l); - return c_readstr (p, as_a <scalar_int_mode> (mode), false); + return c_readstr (p, mode, false); } - /* The by-pieces infrastructure does not try to pick a vector mode - for storing STRING_CST. */ - return c_readstr (TREE_STRING_POINTER (str) + offset, - as_a <scalar_int_mode> (mode), false); + return c_readstr (TREE_STRING_POINTER (str) + offset, mode, false); } /* Generate code for computing expression EXP, |