public inbox for gcc-help@gcc.gnu.org
 help / color / mirror / Atom feed
* Inline assembly clobbered registers
@ 2003-11-06 13:23 Christian Hildner
  2003-11-06 13:28 ` Falk Hueffner
  0 siblings, 1 reply; 5+ messages in thread
From: Christian Hildner @ 2003-11-06 13:23 UTC (permalink / raw)
  To: gcc-help

Hi there,

I need a temporary general register inside the inline assembly code. The 
definition for a particular register is possible by for example "eax". 
But how to define a general register that the compiler is allowed to 
choose as it is possible with input/output registers who are referenced 
by %0, %1, ... ? So simply to allow "r" in the clobbered list and 
reference it by %x in the assembly code. That would be great for the 
optimizer because defining a specific register as clobbered is always 
the second best solution.

Might this be an idea for the next gcc release?

Comments?

Christian

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: Inline assembly clobbered registers
  2003-11-06 13:23 Inline assembly clobbered registers Christian Hildner
@ 2003-11-06 13:28 ` Falk Hueffner
  2003-11-06 14:58   ` Christian Hildner
  0 siblings, 1 reply; 5+ messages in thread
From: Falk Hueffner @ 2003-11-06 13:28 UTC (permalink / raw)
  To: Christian Hildner; +Cc: gcc-help

Christian Hildner <christian.hildner@hob.de> writes:

> I need a temporary general register inside the inline assembly
> code. The definition for a particular register is possible by for
> example "eax". But how to define a general register that the
> compiler is allowed to choose as it is possible with input/output
> registers who are referenced by %0, %1, ... ? So simply to allow "r"
> in the clobbered list and reference it by %x in the assembly code.

Why can't you just make it an output variable?

-- 
	Falk

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: Inline assembly clobbered registers
  2003-11-06 13:28 ` Falk Hueffner
@ 2003-11-06 14:58   ` Christian Hildner
  2003-11-06 15:08     ` Falk Hueffner
  0 siblings, 1 reply; 5+ messages in thread
From: Christian Hildner @ 2003-11-06 14:58 UTC (permalink / raw)
  To: Falk Hueffner; +Cc: gcc-help

Falk Hueffner schrieb:

>Christian Hildner <christian.hildner@hob.de> writes:
>
>  
>
>>I need a temporary general register inside the inline assembly
>>code. The definition for a particular register is possible by for
>>example "eax". But how to define a general register that the
>>compiler is allowed to choose as it is possible with input/output
>>registers who are referenced by %0, %1, ... ? So simply to allow "r"
>>in the clobbered list and reference it by %x in the assembly code.
>>    
>>
>
>Why can't you just make it an output variable?
>
I made it an input one instead. This is possible, but it would be nicer 
to allow an unspecified general register in the clobbered list.

Christian

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: Inline assembly clobbered registers
  2003-11-06 14:58   ` Christian Hildner
@ 2003-11-06 15:08     ` Falk Hueffner
  2003-11-10  7:07       ` Christian Hildner
  0 siblings, 1 reply; 5+ messages in thread
From: Falk Hueffner @ 2003-11-06 15:08 UTC (permalink / raw)
  To: Christian Hildner; +Cc: gcc-help

Christian Hildner <christian.hildner@hob.de> writes:

> Falk Hueffner schrieb:
> >Christian Hildner <christian.hildner@hob.de> writes:
> >>I need a temporary general register inside the inline assembly
> >>code. The definition for a particular register is possible by for
> >>example "eax". But how to define a general register that the
> >>compiler is allowed to choose as it is possible with input/output
> >>registers who are referenced by %0, %1, ... ? So simply to allow "r"
> >>in the clobbered list and reference it by %x in the assembly code.
> >
> >Why can't you just make it an output variable?
> >
> I made it an input one instead.

That will lead to wrong code, since gcc thinks you won't change it.

> This is possible, but it would be nicer to allow an unspecified
> general register in the clobbered list.

But since the functioinality is trivially available by another way, I
don't think it's worth adding complexity to the compiler for this.

-- 
	Falk

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: Inline assembly clobbered registers
  2003-11-06 15:08     ` Falk Hueffner
@ 2003-11-10  7:07       ` Christian Hildner
  0 siblings, 0 replies; 5+ messages in thread
From: Christian Hildner @ 2003-11-10  7:07 UTC (permalink / raw)
  To: Falk Hueffner; +Cc: gcc-help

Falk Hueffner schrieb:

>Christian Hildner <christian.hildner@hob.de> writes:
>
>  
>
>>Falk Hueffner schrieb:
>>    
>>
>>>Christian Hildner <christian.hildner@hob.de> writes:
>>>      
>>>
>>>>I need a temporary general register inside the inline assembly
>>>>code. The definition for a particular register is possible by for
>>>>example "eax". But how to define a general register that the
>>>>compiler is allowed to choose as it is possible with input/output
>>>>registers who are referenced by %0, %1, ... ? So simply to allow "r"
>>>>in the clobbered list and reference it by %x in the assembly code.
>>>>        
>>>>
>>>Why can't you just make it an output variable?
>>>
>>>      
>>>
>>I made it an input one instead.
>>    
>>
>
>That will lead to wrong code, since gcc thinks you won't change it.
>
Inspecting the output I found that there will be no corruption of 
registers. But since it may not be 100% save I will switch to the usage 
of output registers (as you suggested).

>>This is possible, but it would be nicer to allow an unspecified
>>general register in the clobbered list.
>>    
>>
>
>But since the functioinality is trivially available by another way, I
>don't think it's worth adding complexity to the compiler for this.
>
I am just wondering to be at least the only one that would need that 
feature.

Thanks

Christian








^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2003-11-10  7:07 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2003-11-06 13:23 Inline assembly clobbered registers Christian Hildner
2003-11-06 13:28 ` Falk Hueffner
2003-11-06 14:58   ` Christian Hildner
2003-11-06 15:08     ` Falk Hueffner
2003-11-10  7:07       ` Christian Hildner

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).