asm clobbers, !SMALL_REGISTER_CLASSES patch.
Geoffrey KEATING
geoffk@discus.anu.edu.au
Fri Feb 13 02:28:00 GMT 1998
> 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>
More information about the Gcc
mailing list