This is the mail archive of the gcc@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]
Other format: [Raw text]

RegRegname vs. Explicit Local Register Variables ...



Hi All,

  I am using explicit register variables to place arguments and return 
values in the correct registers for system calls.  eg.

------------------
static inline int
sem_wait(sem_t sem)
{
	register unsigned int arg0 __asm__ ("r0");
	register unsigned int rc __asm__ ("r0");

	arg0 = (unsigned int)sem;

	__asm__ __volatile__ (
		"swi	0xff0028"
		: "=r" (rc) : "0" (arg0)
		: "r1", "r2", "r3, "r12", "lr", "memory"
	);

	return (int)rc;
}
-----------------

  The problem here is that regrename.c does not know that it is not good 
to move "arg0" from the specified "r0" and sometimes ends up doing so.

  I see a few solutions and would like to know what is seen as the best 
solution to implement:

  1. Prevent regrename from renaming arguments to asm blocks just like
     it knows not to rename arguments to calls.  This could be all 
     arguments or just ones with a new constraint.

  2. Somehow be able to mark the asm block as a "call" and hence have
     the current regrename exception for calls handle this.  Other 
     optimisation passes might also like to know that this asm block is
     effectively a "call".

  3. Give up and increase the already large overhead of the syscall with
     extra "mov" instructions that in a lot of cases are not needed.

  I think that 2. might be the best for this exact case if other passes 
can easily use the call knowledge but 1. would be the most flexable when 
used with the addition of a constraint.

  Any ideas before I waste too much time figuring out more about the 
internals of GCC than I really need to know? 

	Thanks,

		CraigN
--
      Craig Newell                email: CraigN@ieee.org
      Free Spirit                 icbm:  N 42°38'47" W 71°18'19"



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