public inbox for gcc-help@gcc.gnu.org
 help / color / mirror / Atom feed
* Problems Forcing Global Register Allocation
@ 2001-01-03 13:33 Brendan Younger
  0 siblings, 0 replies; only message in thread
From: Brendan Younger @ 2001-01-03 13:33 UTC (permalink / raw)
  To: gcc-help

Hi,
I'm having a bit of trouble forcing gcc use a specific register for a
global variable.  I use the syntax:
register int foo asm ("r1");
but this doesn't work perfectly.  For instance, it will only compile using
the -traditional-cpp option and only if the register I use is r1 or r2
(general purpose registers on the PowerPC).  These registers, however, are
clobbered after any function call.  I can't not assign a specific register
since it then complains that no register was assigned.  I'm using Mac OS X
Public Beta and compiling with "cc," Apple's port of gcc 2.95.x.  Specific
things I've tried and their error codes are below:

register int foo asm ("r13");  //the first register that is preserved by
callees
compiling with the -traditional-cpp option, I get:
error: global register variable follows a function definition

register int foo asm ("r1");
compiling with the -traditional-cpp option, I get:
error: global register variable follows a function definition
warning: call-clobbered register used for global register variable

register int foo asm ("r1");
compiling without -traditional-cpp
error: illegal external declaration, missing ";" after foo

now, I was looking in the system.framework headers and they have mappings
of the PPC registers to other register names, like so:
#define  a5     r4
substituting these names does no good since it produces an error to this
effect, "not a valid register assignment"

if anyone could please help, I'm compiling in Project Builder as a Standard
Tool (a standard UNIX console app).  Also, I believe my problem lies
somewhere with the __ASSEMBLER__ macro.   All the architecture-dependent
headers in the system framework have #ifdef __ASSEMBLER__ in them.  Also,
in desperation I tried making the register one of gcc's virtual ones like
"%0" and that crashes my program with a bad memory access.  Please help.

Brendan Younger

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2001-01-03 13:33 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2001-01-03 13:33 Problems Forcing Global Register Allocation Brendan Younger

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