This is the mail archive of the gcc-patches@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: RFC: [PATCH] Add __builtin_ia32_stack_top


On Tue, Jul 21, 2015 at 2:45 PM, H.J. Lu <hongjiu.lu@intel.com> 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 on performance.  This patch adds a new
> builtin function, __builtin_ia32_stack_top, to x86 backend.  It
> returns the stack address when the function is called.
>
> Any comments, feedbacks?
>
> Thanks.
>
>
> H.J.
> ---
> gcc/
>
>         PR target/66960
>         * config/i386/i386.c (ix86_expand_prologue): Sorry if DRAP is
>         used and the stack address has been taken.
>         (ix86_builtins): Add IX86_BUILTIN_STACK_TOP.
>         (ix86_init_mmx_sse_builtins): Add __builtin_ia32_stack_top.
>         (ix86_expand_builtin): Handle IX86_BUILTIN_STACK_TOP.
>         * config/i386/i386.h (machine_function): Add stack_top_taken.
>         * doc/extend.texi: Document __builtin_ia32_stack_top.
>

I got a feedback, suggesting __builtin_stack_top, instead of
__builtin_ia32_stack_top.  But I don't know if

+      /* After the prologue, stack top is at -WORD(AP) in the current
+        frame.  */
+      emit_insn (gen_rtx_SET (target,
+                             plus_constant (Pmode, arg_pointer_rtx,
+                                            -UNITS_PER_WORD)));

is true for all backends.  If it works on all backends, I can move
it to builtins.c.

-- 
H.J.


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