Re: [PATCH] Add __builtin_stack_top

2015-08-19 Thread Segher Boessenkool
On Wed, Aug 19, 2015 at 03:18:46PM -0700, H.J. Lu wrote: > @deftypefn {Built-in Function} {void *} __builtin_argument_pointer (void) > This function is similar to @code{__builtin_frame_address} with an > argument of 0, but it returns the address of the incoming arguments to > the current function r

Re: [PATCH] Add __builtin_stack_top

2015-08-19 Thread H.J. Lu
On Wed, Aug 19, 2015 at 3:10 PM, Segher Boessenkool wrote: > On Wed, Aug 19, 2015 at 02:53:47PM -0700, H.J. Lu wrote: >> How about this >> >> @deftypefn {Built-in Function} {void *} __builtin_argument_pointer (void) >> This function is similar to @code{__builtin_frame_address} with an >> argument

Re: [PATCH] Add __builtin_stack_top

2015-08-19 Thread Segher Boessenkool
On Wed, Aug 19, 2015 at 02:53:47PM -0700, H.J. Lu wrote: > How about this > > @deftypefn {Built-in Function} {void *} __builtin_argument_pointer (void) > This function is similar to @code{__builtin_frame_address} with an > argument of 0, but it returns the address of the incoming arguments to > th

Re: [PATCH] Add __builtin_stack_top

2015-08-19 Thread H.J. Lu
On Wed, Aug 19, 2015 at 10:53 AM, H.J. Lu wrote: > On Wed, Aug 19, 2015 at 10:48 AM, Segher Boessenkool > wrote: >> On Wed, Aug 19, 2015 at 10:08:01AM -0700, H.J. Lu wrote: >>> > Maybe something like (heavily cut'n'pasted): >>> > >>> > >>> > @deftypefn {Built-in Function} {void *} __builtin_argum

Re: [PATCH] Add __builtin_stack_top

2015-08-19 Thread H.J. Lu
On Wed, Aug 19, 2015 at 10:48 AM, Segher Boessenkool wrote: > On Wed, Aug 19, 2015 at 10:08:01AM -0700, H.J. Lu wrote: >> > Maybe something like (heavily cut'n'pasted): >> > >> > >> > @deftypefn {Built-in Function} {void *} __builtin_argument_address (void) >> > This function is similar to @code{_

Re: [PATCH] Add __builtin_stack_top

2015-08-19 Thread Segher Boessenkool
On Wed, Aug 19, 2015 at 10:08:01AM -0700, H.J. Lu wrote: > > Maybe something like (heavily cut'n'pasted): > > > > > > @deftypefn {Built-in Function} {void *} __builtin_argument_address (void) > > This function is similar to @code{__builtin_frame_address} with an > > argument of 0, but it returns th

Re: [PATCH] Add __builtin_stack_top

2015-08-19 Thread H.J. Lu
On Wed, Aug 19, 2015 at 9:58 AM, Segher Boessenkool wrote: > On Wed, Aug 19, 2015 at 08:25:49AM -0700, H.J. Lu wrote: >> Here is a patch to add __builtin_argument_pointer. I only have > > Sorry to be a pain but... all the other builtins use _address > instead of _pointer, it's probably best to f

Re: [PATCH] Add __builtin_stack_top

2015-08-19 Thread Segher Boessenkool
On Wed, Aug 19, 2015 at 08:25:49AM -0700, H.J. Lu wrote: > Here is a patch to add __builtin_argument_pointer. I only have Sorry to be a pain but... all the other builtins use _address instead of _pointer, it's probably best to follow that. > -- Built-in Function: void * __builtin_argument_poin

Re: [PATCH] Add __builtin_stack_top

2015-08-19 Thread H.J. Lu
On Wed, Aug 19, 2015 at 6:00 AM, H.J. Lu wrote: > On Wed, Aug 19, 2015 at 5:51 AM, Segher Boessenkool > wrote: >> On Wed, Aug 19, 2015 at 05:23:41AM -0700, H.J. Lu wrote: >>> >>> >> > You might have a reason why you want the entry stack address >>> >>> >> > instead of the >>> >>> >> > frame addr

Re: [PATCH] Add __builtin_stack_top

2015-08-19 Thread H.J. Lu
On Wed, Aug 19, 2015 at 5:51 AM, Segher Boessenkool wrote: > On Wed, Aug 19, 2015 at 05:23:41AM -0700, H.J. Lu wrote: >> >>> >> > You might have a reason why you want the entry stack address >> >>> >> > instead of the >> >>> >> > frame address, but you didn't really explain I think? Or I missed

Re: [PATCH] Add __builtin_stack_top

2015-08-19 Thread Segher Boessenkool
On Wed, Aug 19, 2015 at 05:23:41AM -0700, H.J. Lu wrote: > >>> >> > You might have a reason why you want the entry stack address instead > >>> >> > of the > >>> >> > frame address, but you didn't really explain I think? Or I missed > >>> >> > it. > >> > >> What would a C program do with this, th

Re: [PATCH] Add __builtin_stack_top

2015-08-19 Thread H.J. Lu
On Tue, Aug 4, 2015 at 1:50 PM, H.J. Lu wrote: > On Tue, Aug 4, 2015 at 1:45 PM, Segher Boessenkool > wrote: >> On Tue, Aug 04, 2015 at 01:00:32PM -0700, H.J. Lu wrote: >>> There is another issue with x86, maybe other targets. You >>> can't get the real stack top when stack is realigned and >>>

Re: [PATCH] Add __builtin_stack_top

2015-08-04 Thread H.J. Lu
On Tue, Aug 4, 2015 at 1:45 PM, Segher Boessenkool wrote: > On Tue, Aug 04, 2015 at 01:00:32PM -0700, H.J. Lu wrote: >> There is another issue with x86, maybe other targets. You >> can't get the real stack top when stack is realigned and >> -maccumulate-outgoing-args isn't used since ix86_expand_

Re: [PATCH] Add __builtin_stack_top

2015-08-04 Thread Segher Boessenkool
On Tue, Aug 04, 2015 at 01:00:32PM -0700, H.J. Lu wrote: > There is another issue with x86, maybe other targets. You > can't get the real stack top when stack is realigned and > -maccumulate-outgoing-args isn't used since ix86_expand_prologue > will create and return another stack frame for > __bu

Re: [PATCH] Add __builtin_stack_top

2015-08-04 Thread H.J. Lu
On Tue, Aug 4, 2015 at 12:29 PM, Segher Boessenkool wrote: > On Tue, Aug 04, 2015 at 11:50:00AM -0700, H.J. Lu wrote: >> >> The motivation of __builtin_stack_top is that frame_address requires a >> >> frame pointer register, which isn't desirable for x86. >> >> __builtin_stack_top >> >> doesn't

Re: [PATCH] Add __builtin_stack_top

2015-08-04 Thread Segher Boessenkool
On Tue, Aug 04, 2015 at 11:50:00AM -0700, H.J. Lu wrote: > >> The motivation of __builtin_stack_top is that frame_address requires a > >> frame pointer register, which isn't desirable for x86. __builtin_stack_top > >> doesn't require a frame pointer register. > > > > If the target just returns fra

Re: [PATCH] Add __builtin_stack_top

2015-08-04 Thread H.J. Lu
On Tue, Aug 4, 2015 at 11:50 AM, H.J. Lu wrote: > On Tue, Aug 4, 2015 at 10:43 AM, Segher Boessenkool > wrote: >> On Tue, Aug 04, 2015 at 10:28:00AM -0700, H.J. Lu wrote: >>> >> Any comments on my middle-end patch? >>> > >>> > So, if the answer is the same as frame_address (0), why not have the

Re: [PATCH] Add __builtin_stack_top

2015-08-04 Thread H.J. Lu
On Tue, Aug 4, 2015 at 10:43 AM, Segher Boessenkool wrote: > On Tue, Aug 04, 2015 at 10:28:00AM -0700, H.J. Lu wrote: >> >> Any comments on my middle-end patch? >> > >> > So, if the answer is the same as frame_address (0), why not have the >> > fallback just expand to that? Then, one can use thi

Re: [PATCH] Add __builtin_stack_top

2015-08-04 Thread Segher Boessenkool
On Tue, Aug 04, 2015 at 10:28:00AM -0700, H.J. Lu wrote: > >> Any comments on my middle-end patch? > > > > So, if the answer is the same as frame_address (0), why not have the > > fallback just expand to that? Then, one can use this builtin everywhere > > that frame address is used today. Peopl

Re: [PATCH] Add __builtin_stack_top

2015-08-04 Thread H.J. Lu
On Tue, Aug 4, 2015 at 10:16 AM, Mike Stump wrote: > On Aug 4, 2015, at 8:44 AM, H.J. Lu wrote: >> On Tue, Aug 4, 2015 at 8:40 AM, Mike Stump wrote: >>> On Aug 4, 2015, at 5:30 AM, H.J. Lu wrote: Where does this feature belong? >>> >>> I prefer the middle end. >> >> Any comments on my midd

Re: [PATCH] Add __builtin_stack_top

2015-08-04 Thread Mike Stump
On Aug 4, 2015, at 8:44 AM, H.J. Lu wrote: > On Tue, Aug 4, 2015 at 8:40 AM, Mike Stump wrote: >> On Aug 4, 2015, at 5:30 AM, H.J. Lu wrote: >>> Where does this feature belong? >> >> I prefer the middle end. > > Any comments on my middle-end patch? So, if the answer is the same as frame_addre

Re: [PATCH] Add __builtin_stack_top

2015-08-04 Thread H.J. Lu
On Tue, Aug 4, 2015 at 8:40 AM, Mike Stump wrote: > On Aug 4, 2015, at 5:30 AM, H.J. Lu wrote: >> Where does this feature belong? > > I prefer the middle end. Any comments on my middle-end patch? Thanks. -- H.J.

Re: [PATCH] Add __builtin_stack_top

2015-08-04 Thread Mike Stump
On Aug 4, 2015, at 5:30 AM, H.J. Lu wrote: > Where does this feature belong? I prefer the middle end.

[PATCH] Add __builtin_stack_top

2015-08-04 Thread H.J. Lu
: Document __builtin_stack_top. > * doc/tm.texi.in (TARGET_STACK_TOP_RTX): New. > * doc/tm.texi: Regenerated. > > gcc/testsuite/ > > PR target/66960 > * gcc.target/i386/pr66960-1.c: New test. > * gcc.target/i386/pr66960-2.c: Likewise. > * gcc.target/i386/pr66960-3.c: Likew

Re: [PATCH] Add __builtin_stack_top to x86 backend

2015-08-03 Thread Uros Bizjak
On Thu, Jul 30, 2015 at 8:41 PM, H.J. Lu wrote: > On Tue, Jul 21, 2015 at 02:45:39PM -0700, H.J. Lu wrote: >> When __builtin_frame_address is used to retrieve the address of the >> function stack frame, the frame pointer is always kept, which wastes one >> register and 2 instructions. For x86-32,

[PATCH] Add __builtin_stack_top to x86 backend

2015-07-30 Thread H.J. Lu
On Tue, Jul 21, 2015 at 02:45:39PM -0700, H.J. Lu wrote: > When __builtin_frame_address is used to retrieve the address of the > function stack frame, the frame pointer is always kept, which wastes one > register and 2 instructions. For x86-32, one less register means > significant negative impact