This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Re: [PATCH] diagnose unsupported uses of hardware register variables (PR 88000)
- From: Segher Boessenkool <segher at kernel dot crashing dot org>
- To: Alexander Monakov <amonakov at ispras dot ru>
- Cc: Jakub Jelinek <jakub at redhat dot com>, Martin Sebor <msebor at gmail dot com>, Gcc Patch List <gcc-patches at gcc dot gnu dot org>
- Date: Wed, 14 Nov 2018 07:53:06 -0600
- Subject: Re: [PATCH] diagnose unsupported uses of hardware register variables (PR 88000)
- References: <20181114122250.GZ23873@gate.crashing.org> <20181114122726.GW11625@tucnak> <alpine.LNX.2.20.13.1811141531160.10221@monopod.intra.ispras.ru>
On Wed, Nov 14, 2018 at 03:33:43PM +0300, Alexander Monakov wrote:
> On Wed, 14 Nov 2018, Jakub Jelinek wrote:
>
> > On Wed, Nov 14, 2018 at 06:22:51AM -0600, Segher Boessenkool wrote:
> > > Btw, if you just add
> > >
> > > void *
> > > retsp (void)
> > > {
> > > register void *sp __asm ("sp");
> > > asm ("" : "+g" (sp)); // <-- this line
> > > return sp;
> > > }
> > >
> > > everything works fine.
> >
> > Even in what you are proposing, i.e. handle the var as any other var
> > in SSA form and only copy into the hard register right before asm and out of
> > it after it?
> > Because
> > {
> > void *sp;
> > asm ("" : "+g" (sp));
> > return sp;
> > }
> > would store into the register default definition of the SSA_NAME (the var
> > has no initializer).
>
> I think with "=g" rather than "+g" this example is ok.
No, it needs the register var as an input. That is the whole *point*.
It could output elsewhere, like with
void *
retsp (void)
{
register void *sp __asm ("sp");
void *p;
asm ("" : "=g" (p) : "0" (sp));
return p;
}
(which also works reliably with current GCC).
Or like
void *
retsp (void)
{
register void *sp __asm ("sp");
void *p;
asm ("mov %0,%1" : "=r" (p) : "r" (sp));
return p;
}
if you don't want to tie the asm input and output (but use an extra
machine instruction, alas).
Segher