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]

RE: register variables: list?


On 23 October 2007 18:25, skaller wrote:

> In
> 
>
http://gcc.gnu.org/onlinedocs/gcc-4.2.2/gcc/Explicit-Reg-Vars.html#Explicit-Re
g-Vars
> 
> it explains how to use register variables .. but doesn't list them.
> 
> Is there a document somewhere which lists
> 
> a) each CPU macro name

  Don't at all understand what you're referring to there.  Macro?  You mean a
#define?  Name of the cpu?  I don't see anything referring to the cpu name in
the explicit reg vars docs.

> b) all the registers supported

  Nope, but it should be the standard notation as defined by the manufacturer
in their reference manuals and as accepted by gas for the target in question.
If you absolutely have to know for certain, look at
gcc/config/<cpu-type>/<cpu-type.h> for the various *REGISTER_NAMES* macros
(same as what -ffixed-REGNAME accepts).

> I need to get the stack pointer when __builtin_frame_address(0) isn't
> working .. on amd64 this:
> 
> 
> register void *stack asm ("%rsp");
> 
> appears to work. 

  Yep.  I'd recommend using it like so:

#define STACK_POINTER_VALUE ({ register void *stack asm ("%rsp"); stack; })

just for safety's sake... you wouldn't want to go and accidentally use it as
an lvalue, now, would you?  :-O

> Also this is the current stack pointer .. not
> the frame pointer, which could be different.

  Yep, almost inevitably so I'm afraid.  Maybe a better solution than making
__builtin_frame_address(0) return an artificial address in functions where
there is no frame pointer would be just to have a
__builtin_initial_frame_pointer_offset() function that returns the size of the
frame, but even that wouldn't help if you're in the middle of a function call
sequence or something where gcc is pushing args to the stack.

    cheers,
      DaveK
-- 
Can't think of a witty .sigline today....


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