public inbox for jit@gcc.gnu.org
 help / color / mirror / Atom feed
From: "Marc Nieper-Wißkirchen" <marc.nieper+gnu@gmail.com>
To: "Marc Nieper-Wißkirchen via Jit" <jit@gcc.gnu.org>
Subject: Pointer difference
Date: Sun, 26 Dec 2021 11:12:37 +0100	[thread overview]
Message-ID: <CAEYrNrRyWVNxgdijNT+0cQ9p+bt54OM-pubc6SJzSP-xTmJMAQ@mail.gmail.com> (raw)

Using gcc_jit_context_new_binary_op together with
GCC_JIT_BINARY_OP_MINUS, one can generate code to calculate the
difference of two pointer rvalues P and Q.

According to my experiments, however, the difference is not taken in
the C sense where the difference is the number of units between the
two pointers, which depends on the types of P and Q. Instead,
libgccjit seems to calculate the equivalent of GCC's (void *) P -
(void *) Q.

It's probably worth noting this in the documentation.

Thanks,

Marc

PS Coincidentally, libgccjit doesn't support the addition of an
integral type to a pointer type using GCC_JIT_BINARY_OP_PLUS; for that
one has to go through gcc_jit_context_new_array_access and then
gcc_jit_lvalue_get_address.

                 reply	other threads:[~2021-12-26 10:12 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

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=CAEYrNrRyWVNxgdijNT+0cQ9p+bt54OM-pubc6SJzSP-xTmJMAQ@mail.gmail.com \
    --to=marc.nieper+gnu@gmail.com \
    --cc=jit@gcc.gnu.org \
    /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).