public inbox for gcc@gcc.gnu.org
 help / color / mirror / Atom feed
From: Geoffrey KEATING <geoffk@discus.anu.edu.au>
To: law@cygnus.com
Cc: Geoffrey KEATING <geoffk@discus.anu.edu.au>, egcs@cygnus.com
Subject: Re: asm clobbers, !SMALL_REGISTER_CLASSES patch.
Date: Fri, 13 Feb 1998 02:28:00 -0000	[thread overview]
Message-ID: <199802130931.UAA18941@discus.anu.edu.au> (raw)
In-Reply-To: <25345.887357311@hurl.cygnus.com>

> From: Jeffrey A Law <law@hurl.cygnus.com>
...
> [David:]
>   > I think that the correct solution is to turn the clobber
>   > of a named register into the equivalent that GCC uses internally for
>   > machine description files: match_scratch.  ... 
>   > lying to GCC always causes problems in the long run.

> David's approach sounds cleaner, but I haven't thought too much about
> where to "hook in" and do this.

I agree with this.

> Also, with your patch you could end up introducing new aborts.
> 
> Basically, if you had two asms which clobbered "r1" (assume that it is
> in a class by itself) and you were only able to "fix" one of them
> with your trick, then you can lose.

On PPC, of course, this is not a problem; generally, if you can't fix
a clobber of a register in a class of its own, eventually gcc will
abort anyway :-(.  The only small register classes contain cr0, lr, ctr,
and mq, and they all have this same problem (although I can't find an
example for ctr, because I can't get gcc to use it at all... this is
probably a bug).

Also, fortunately, the cases it can't fix are rare (they relate to
relatively complex 'asm' statements).  It would be easy to extend it
to cope with multiple alternatives, but the (inputs + outputs < 10)
problem is a harder limit.

One big advantage of David's solution is that, if I understand
correctly, it would just come out as (clobber some_pseudo), so there
would be no problem with having too many inputs/outputs.  You would
need to teach register allocation that whatever pseudo some_pseudo is
can only be put in one class, and I'm not sure how to do this.

Hmmm.  I'd like to write asm ("bar" : : : "cc0") as

(parallel [
     (asm_operands "bar" "x" 0 [] []))
     (set something-2 (asm_operands "" "x" 0 [] []))
     ;; aka '(clobber cc0)'
  ])

but I imagine gcc will say `something-2 isn't used anywhere, so we can
just eliminate the second asm statement'.

> Note the same applies to David's approach.  In fact, we may have a fundamental
> problem -- if the register appeared as an explicit inout/output to one
> asm, but was turned into a max_scratch for another asm because it was a 
> clobber, then we run into the same problem.  So it seems that we have to
> fix the inputs, outputs, and clobbers.  Yuck.  Sorry I didn't think of this
> earlier.

I don't understand this.  Does this mean that

int something, dummy2;
asm ("foo" : "+l"(something) );
asm ("bar" : "=&l"(dummy2) );

(on ppc, say) should crash, because "l" is a class with only one
register?

This is equivalent, with my patch, to:

int something;
asm ("foo" : "+l"(something) );
asm ("bar" : : : "lr");

-- 
Geoff Keating <Geoff.Keating@anu.edu.au>

  reply	other threads:[~1998-02-13  2:28 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
1998-02-12 19:36 Geoffrey KEATING
1998-02-12 20:24 ` David Edelsohn
1998-02-12 20:24   ` Geoffrey KEATING
1998-02-13  2:28   ` Jeffrey A Law
1998-02-13  2:28     ` Geoffrey KEATING [this message]
1998-02-14  0:32       ` Jeffrey A Law
1998-02-14 21:14         ` Geoffrey KEATING
1998-02-15 11:33           ` Jeffrey A Law
1998-02-15 18:47             ` David Edelsohn
1998-02-13  2:28   ` Richard Henderson
1998-02-13 10:34     ` David Edelsohn
1998-02-13 10:58       ` Richard Henderson
1998-02-13 10:58         ` David Edelsohn
1998-02-14 20:23         ` Geoffrey KEATING

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=199802130931.UAA18941@discus.anu.edu.au \
    --to=geoffk@discus.anu.edu.au \
    --cc=egcs@cygnus.com \
    --cc=law@cygnus.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).