public inbox for jit@gcc.gnu.org
 help / color / mirror / Atom feed
From: David Malcolm <dmalcolm@redhat.com>
To: Dibyendu Majumdar <mobile@majumdar.org.uk>
Cc: jit@gcc.gnu.org
Subject: Re: Labeling of blocks and locals
Date: Thu, 01 Jan 2015 00:00:00 -0000	[thread overview]
Message-ID: <1434339718.3192.37.camel@surprise> (raw)
In-Reply-To: <CACXZuxf=eHYcHcBfbkRP_raqOa6fcwFps60-pKCn2p+mBLYcDQ@mail.gmail.com>

On Sun, 2015-06-14 at 20:21 +0100, Dibyendu Majumdar wrote:
> It seems that if a name is supplied to a block it is translated as a
> label - but then if the same name is supplied to two blocks the labels
> show up as the same.

They show up in dumps the same, which is going to be ambiguous to a
human reader, but I don't think it's a problem for the IR and the
compiler, I *think* it does it by identity, rather than be name, as it
were (not sure, but it's late here).

> In LLVM the block labels are automatically made unique - the user
> supplied name is suffixed with a unique integer value. This is useful
> as one can use meaningful labels without having to worry about making
> the labels unique.
> 
> As it stands I would have to ensure unique label names before I could use them.

FWIW in my compilers I've given them names based on the bytecode index,
so you might have e.g. "op0", "op0_true", "op0_false" etc for the 0th
bytecode, "op1" etc...   Although it's some extra work, it has an
advantage in that the names are more meaningful.  (BTW, the "const char
*" is copied, so you can build them up using snprintf into an on-stack
temporary buffer:
   char buf[16];
   snprintf(buf, sizeof(buf), "op%i", idx);
or somesuch).


> A similar question involves naming of locals. When I declare a local
> and assign it a name - the name is not made unique. During code
> generation whenever certain types of statements are processed, local
> variables may be generated. These are given the same name - in LLVM
> the names are automatically made unqiue, but I notice that in
> libgccjit this is not so.

Again, I'm not sure that this is a problem other than the ambiguity of
the dumps for the human reader; I *think* the IR/compiler treats two
locals created with multiple calls to gcc_jit_function_new_local as
different, even if they have the same name (it'd be a problem for
*globals* though).

> Of course I can work around this by creating unique label and local
> names myself but that is an unnecessary pain.
> 
> Is it possible to consider changing this behaviour?

Maybe.

Dave

  reply	other threads:[~2015-06-15  3:49 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-01-01  0:00 Dibyendu Majumdar
2015-01-01  0:00 ` David Malcolm [this message]
2015-01-01  0:00   ` Dibyendu Majumdar
2015-01-01  0:00   ` Dibyendu Majumdar
2015-01-01  0:00     ` David Malcolm

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=1434339718.3192.37.camel@surprise \
    --to=dmalcolm@redhat.com \
    --cc=jit@gcc.gnu.org \
    --cc=mobile@majumdar.org.uk \
    /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).