public inbox for gcc@gcc.gnu.org
 help / color / mirror / Atom feed
From: Alexander Monakov <amonakov@ispras.ru>
To: Uros Bizjak <ubizjak@gmail.com>
Cc: Richard Biener <richard.guenther@gmail.com>,
	 Jakub Jelinek <jakub@redhat.com>,
	GCC Development <gcc@gcc.gnu.org>,  X86 ML <x86@kernel.org>,
	Andy Lutomirski <luto@amacapital.net>
Subject: Re: typeof and operands in named address spaces
Date: Thu, 5 Nov 2020 12:36:01 +0300 (MSK)	[thread overview]
Message-ID: <alpine.LNX.2.20.13.2011051224220.9902@monopod.intra.ispras.ru> (raw)
In-Reply-To: <CAFULd4aoEG4b3AHKMcj-xK6OG0R-wH0HsjUoVyM6WnUB00gAtw@mail.gmail.com>

On Thu, 5 Nov 2020, Uros Bizjak via Gcc wrote:

> > Looks like writing
> >
> >     typeof((typeof(_var))0) tmp__;
> >
> > makes it work.  Assumes there's a literal zero for the type of course.
> 
> This is very limiting assumption, which already breaks for the following test:

To elaborate Richard's idea, you need a way to decay lvalue to rvalue inside
the typeof to strip the address space; if you need the macro to work for
more types than just scalar types, the following expression may be useful:

  typeof(0?(_var):(_var))

(though there's a bug: +(_var) should also suffice for scalar types, but
 somehow GCC keeps the address space on the resulting rvalue)

But I wonder if you actually need this at all:

> > works around the warning.  I think the wording you cite
> > suggests (uintptr_t) &y here, not sure if there's a reliable
> > way to get the lea with just a uintptr_t operand though.
> 
> No, because we have to use the "m" constraint for the LEA. We get the
> following error:

What is the usecase for stripping the address space for asm operands?
From reading the patch I understand the kernel wants to pass qualified
lvalues to inline assembly to get

  lea <reg>, %fs:<mem>

LEA without the %fs will produce the offset within the segment, which
you can obtain simply by casting the pointer to intptr_t in the first place.

Alexander

  reply	other threads:[~2020-11-05  9:36 UTC|newest]

Thread overview: 28+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-11-04 18:31 Uros Bizjak
2020-11-05  7:26 ` Richard Biener
2020-11-05  8:56   ` Uros Bizjak
2020-11-05  9:36     ` Alexander Monakov [this message]
2020-11-05 10:33       ` Uros Bizjak
2020-11-05 11:38         ` Alexander Monakov
2020-11-05 12:00           ` Uros Bizjak
2020-11-05 12:14             ` Alexander Monakov
2020-11-05 12:24               ` Richard Biener
2020-11-05 12:32                 ` Uros Bizjak
2020-11-05 12:35                   ` Uros Bizjak
2020-11-05 13:22                     ` Alexander Monakov
2020-11-05 13:39                       ` Alexander Monakov
2020-11-05 13:46                         ` Uros Bizjak
2020-11-05 12:26               ` Uros Bizjak
2020-11-05 15:27                 ` Andy Lutomirski
2020-11-05 11:03       ` Uros Bizjak
2020-11-05  9:45     ` Richard Biener
2020-11-05  9:51       ` Jakub Jelinek
2020-11-09 12:47 ` Peter Zijlstra
2020-11-09 19:38   ` Segher Boessenkool
2020-11-09 19:50     ` Nick Desaulniers
2020-11-10  7:57       ` Peter Zijlstra
2020-11-10 18:42         ` Nick Desaulniers
2020-11-10 20:11           ` Peter Zijlstra
2020-11-12  0:40             ` Segher Boessenkool
2020-11-12  0:47         ` Segher Boessenkool
2020-11-10  7:52     ` Peter Zijlstra

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.LNX.2.20.13.2011051224220.9902@monopod.intra.ispras.ru \
    --to=amonakov@ispras.ru \
    --cc=gcc@gcc.gnu.org \
    --cc=jakub@redhat.com \
    --cc=luto@amacapital.net \
    --cc=richard.guenther@gmail.com \
    --cc=ubizjak@gmail.com \
    --cc=x86@kernel.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).