public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
[parent not found: <bug-11824-4@http.gcc.gnu.org/bugzilla/>]
[parent not found: <20030806085250.11824.loki@gcc.gnu.org>]
* [Bug target/11824] New: [ARM] Parameter passing via stack could be improved
@ 2003-08-06  8:52 alga at rgai dot hu
  2003-08-11 12:44 ` [Bug target/11824] " pinskia at gcc dot gnu dot org
  0 siblings, 1 reply; 5+ messages in thread
From: alga at rgai dot hu @ 2003-08-06  8:52 UTC (permalink / raw)
  To: gcc-bugs

PLEASE REPLY TO gcc-bugzilla@gcc.gnu.org ONLY, *NOT* gcc-bugs@gcc.gnu.org.

http://gcc.gnu.org/bugzilla/show_bug.cgi?id=11824

           Summary: [ARM] Parameter passing via stack could be improved
           Product: gcc
           Version: 3.4
            Status: UNCONFIRMED
          Severity: minor
          Priority: P3
         Component: target
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: alga at rgai dot hu
                CC: gcc-bugs at gcc dot gnu dot org
 GCC build triplet: i686-pc-linux-gnu
  GCC host triplet: i686-pc-linux-gnu
GCC target triplet: arm-unknown-elf

For each function that uses the stack for parameter passing GCC generally
first stores lr and decrements sp, and before returning it increments
sp and loads lr into pc.
If the number of the parameters is not too much, then GCC could perform the
parameter passing in a tricky way (as far as code size is concerned),
i.e. save some arbitrary registers with lr on the stack
(so the sp is modified implicitly).

--- c example ---
// arm-elf-gcc -S -g0 -Os -o param-stack.s param-stack.c
void func (int* a, int* b);
void foo ()
{
   int a=6, b=7;
   func(&a, &b);
}

--- asm code ---
foo:
 mov ip, sp
 stmfd sp!, {fp, ip, lr, pc} <- OLD
 mov r3, #6
 sub fp, ip, #4
 sub sp, sp, #8 <- OLD
 sub r0, fp, #16
 str r3, [fp, #-16]
 sub r1, fp, #20
 add r3, r3, #1
 str r3, [fp, #-20]
 bl func
 ldmea fp, {fp, sp, pc}

--- possible solution ---
foo:
 mov ip, sp
 stmfd sp!, {r1, r2, fp, ip, lr, pc} <-NEW
 mov r3, #6
 sub fp, ip, #4
 sub r0, fp, #16
 str r3, [fp, #-16]
 sub r1, fp, #20
 add r3, r3, #1
 str r3, [fp, #-20]
 bl func
 ldmea fp, {fp, sp, pc}


^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2013-04-20 13:59 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
     [not found] <20030806085250.11824.loki@inf.u-szeged.hu>
2004-08-12  1:51 ` [Bug target/11824] [ARM] Parameter passing via stack could be improved pinskia at gcc dot gnu dot org
     [not found] <bug-11824-4@http.gcc.gnu.org/bugzilla/>
2013-04-20 13:59 ` bpringlemeir at gmail dot com
     [not found] <20030806085250.11824.loki@gcc.gnu.org>
2005-09-02 11:21 ` steven at gcc dot gnu dot org
2005-09-02 12:39 ` rearnsha at gcc dot gnu dot org
2003-08-06  8:52 [Bug target/11824] New: " alga at rgai dot hu
2003-08-11 12:44 ` [Bug target/11824] " pinskia at gcc dot gnu dot org

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