This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

Re: PATCH: Fix 20000724-1.c



On Tue, 1 May 2001, Richard Henderson wrote:
>
> On Mon, Apr 30, 2001 at 08:04:04PM -0700, Linus Torvalds wrote:
> > The fact that it has a pointer to the frame should be enough to key off.
> 
> We are in complete agreement.
> 
> I'm fairly sure that we've still got bugs in there wrt this,
> though I've not been able to construct a test case to show it.

I wonder what it is that a "call" instruction does differently from a
"asm"?

As far as I can tell, you could always make "asm" instructions work like
function calls, except the clobbers are a bit different. Because from a
conceptual point, that is exactly what they are: they are a "call" to
assembly language with special calling convention. It wouldn't really use
a "call" instruction - instead it would just insert the supplied assembly
code.

No?

Now, I suspect that making gcc treat asms as transfer control instructions
might make the generated code around the asm a bit worse, but on the other
hand it would certainly make conceptual sense. And improving code
generation around the asms would automatically improve code generation for
_common_ problems, instead of making asm's be more and more a "special
case".

In most cases that people use inline assembly, it is done because
something is simply not expressible in C code. The performance side is
secondary. It's just a lot more maintainable to create inline asm that is
accessible directly from C, than it is to have completely separate .S
files and have to make the assembly follow the C calling sequence.

Would it be horrible to implement asm's internally as control transfer
instructions to a "magic subroutine"?

		Linus

[ Side note: If we'd really move asms towards more of a "control transfer"
  construct, then it would be absolutely _lovely_ to have support for a
  "conditional goto" asm too, not just a "function call asm". There are
  tons of cases where we'd love to do somehting like

		asm("lock ; btsl %1,%0; jne %2"
			:"+m" (lockvariable)
			:"r" (bitnr),
			 "L" (label));
		..we got the lock..


	label:
		...asm failure case ..

  and I bet others would be able to use this too - things like inner
  routines in threaded interpreters etc might use these kinds of asms
  with control flow. This, of course, is a much more ambitious thing, but
  just _maybe_ it could fit into the gcc control flow structures? ]


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]