From: Joseph Myers <joseph@codesourcery.com>
To: Bernd Schmidt <bschmidt@redhat.com>
Cc: Richard Biener <richard.guenther@gmail.com>,
GCC Patches <gcc-patches@gcc.gnu.org>,
Nick Clifton <nickc@redhat.com>
Subject: Re: Thoughts on memcmp expansion (PR43052)
Date: Fri, 13 May 2016 13:53:00 -0000 [thread overview]
Message-ID: <alpine.DEB.2.20.1605131338540.28166@digraph.polyomino.org.uk> (raw)
In-Reply-To: <5735D2F1.20501@redhat.com>
On Fri, 13 May 2016, Bernd Schmidt wrote:
> On 05/13/2016 03:07 PM, Richard Biener wrote:
> > On Fri, May 13, 2016 at 3:05 PM, Bernd Schmidt <bschmidt@redhat.com> wrote:
> > > Huh? Can you elaborate?
> >
> > When you have a builtin taking a size in bytes then a byte is 8 bits,
> > not BITS_PER_UNIT bits.
>
> That makes no sense to me. I think the definition of a byte depends on the
> machine (hence the term "octet" was coined to be unambiguous). Also, such a
> definition would seem to imply that machines with 10-bit bytes cannot
> implement memcpy or memcmp.
>
> Joseph, can you clarify the standard's meaning here?
* In C: a byte is the minimal addressable unit; an N-byte object is made
up of N "unsigned char" objects, with successive addresses in terms of
incrementing an "unsigned char *" pointer. A byte is at least 8 bits.
* In GCC, at the level of GNU C APIs on the target, which generally
includes built-in functions: a byte (on the target) is made of
CHAR_TYPE_SIZE bits. In theory this could be more than BITS_PER_UNIT, or
that could be more than 8, though support for either of those cases would
be very bit-rotten (and I'm not sure there ever have been targets with
CHAR_TYPE_SIZE > BITS_PER_UNIT). Sizes passed to memcpy and memcmp are
sizes in units of CHAR_TYPE_SIZE bits.
* In GCC, at the RTL level: a byte (on the target) is a QImode object,
which is made of BITS_PER_UNIT bits. (HImode is always two bytes, SImode
four, etc., if those modes exist.) Support for BITS_PER_UNIT being more
than 8 is very bit-rotten.
* In GCC, on the host: GCC only supports hosts (and $build) where bytes
are 8-bit (though writing it as CHAR_BIT makes it clear that this 8 means
the number of bits in a host byte).
Internal interfaces e.g. representing the contents of strings or other
memory on the target may not currently be well-defined except when
BITS_PER_UNIT is 8. Cf. e.g.
<https://gcc.gnu.org/ml/gcc/2003-06/msg01159.html>. But the above should
at least give guidance as to whether BITS_PER_UNIT, CHAR_TYPE_SIZE (or
TYPE_PRECISION (char_type_node), preferred where possible to minimize
usage of target macros) or CHAR_BIT is logically right in a particular
place.
--
Joseph S. Myers
joseph@codesourcery.com
next prev parent reply other threads:[~2016-05-13 13:53 UTC|newest]
Thread overview: 19+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-01-15 16:58 Bernd Schmidt
2016-01-18 9:22 ` Richard Biener
2016-04-28 18:36 ` Bernd Schmidt
2016-05-02 12:52 ` Richard Biener
2016-05-02 12:57 ` Bernd Schmidt
2016-05-02 13:14 ` Richard Biener
2016-05-12 17:14 ` Bernd Schmidt
2016-05-13 10:20 ` Richard Biener
2016-05-13 13:05 ` Bernd Schmidt
2016-05-13 13:07 ` Richard Biener
2016-05-13 13:13 ` Bernd Schmidt
2016-05-13 13:53 ` Joseph Myers [this message]
2016-05-13 14:00 ` Bernd Schmidt
2016-05-13 20:41 ` Joseph Myers
2016-05-31 23:50 ` Bernd Schmidt
2016-01-18 12:22 ` Nick Clifton
2016-01-19 21:36 ` Jeff Law
2016-05-30 11:29 ` Florian Weimer
2016-05-31 15:05 ` Bernd Schmidt
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=alpine.DEB.2.20.1605131338540.28166@digraph.polyomino.org.uk \
--to=joseph@codesourcery.com \
--cc=bschmidt@redhat.com \
--cc=gcc-patches@gcc.gnu.org \
--cc=nickc@redhat.com \
--cc=richard.guenther@gmail.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).