🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: gnu.gcc.bug
Article #6210

Power PC ABI requires long long parameter alignment

#6210
From: Donn Seeley
Date: Thu, 11 Jan 1996 00:00
81 lines
3314 bytes
The Power PC ABI requires that long long parameters be passed in
odd/even register pairs, but gcc2 configured for ELF ABI doesn't
appear to provide this behavior.  It broke my stdarg implementation...

The 'Parameter Passing' section of the Power PC ABI Processor
Supplement (pp 3-18 to 3-21 in my copy) describes how to pass long
longs, where 'gr' is the next available parameter register number:

'If gr > 9, [use the overflow space on the stack].  If gr is even,
set gr to gr + 1.  Load the lower-addressed word of the long long
into gr and the higher addressed word into gr + 1, set gr to gr + 2,
and [select the next argument].'

Donn Seeley / BSDI Engineering

% cat q.c 
void bar(const char *fmt, ...);

void
foo(int i, long long l)
{

        bar("%d %d %lld\n", i, i + 1, l);
}
% cc -O2 -S -v q.c
gcc version 2.7.1
 /u/donn/ppclibexec/cpp -lang-c -v -iprefix /u/donn/ppclibexec/powerpc/2.7.1/ -undef -D__GNUC__=2 -D__GNUC_MINOR__=7 -D__bsdi__ -Dbsdi -Dunix -D__powerpc__ -D__bsdi__ -D__bsdi__ -D__unix__ -D__powerpc__ -D__bsdi -D__unix -Asystem(unix) -Asystem(bsd) -Acpu(powerpc) -Amachine(powerpc) -D__CHAR_UNSIGNED__ -D__OPTIMIZE__ -D_CALL_SYSV -D_BIG_ENDIAN -Amachine(bigendian) -D_ARCH_PPC q.c /tmp/cc023839.i
GNU CPP version 2.7.1 (PowerPC BSD/OS)
#include "..." search starts here:
#include <...> search starts here:
 /u/donn/ppclibexec/powerpc/2.7.1/local/include
 /u/donn/ppclibexec/powerpc/2.7.1/include
 /u/donn/ppclibexec/powerpc/2.7.1/include
 /u/donn/ppclibexec/powerpc/2.7.1/include
 /usr/local/include
 /usr/include
 /usr/include
 /usr/include
End of search list.
 /u/donn/ppclibexec/cc1 /tmp/cc023839.i -quiet -dumpbase q.c -O2 -version -o q.s
GNU C version 2.7.2 (PowerPC BSD/OS) compiled by GNU C version 2.7.1.
% cat q.s
 # GNU C 2.7.2
 # -O2 -fdefer-pop -fomit-frame-pointer -fcse-follow-jumps -fcse-skip-blocks
 # -fexpensive-optimizations -fthread-jumps -fstrength-reduce -fpeephole
 # -fforce-mem -ffunction-cse -finline -fcaller-saves -fpcc-struct-return
 # -frerun-cse-after-loop -fschedule-insns -fschedule-insns2 -fcommon
 # -fgnu-linker -mpowerpc -mnew-mnemonics

        .file   "q.c"
gcc2_compiled.:
.section        .rodata
        .align 2
.LC0:
        .string "%d %d %lld\n"
        .section        ".text"
        .align 2
        .globl foo
        .type    foo,@function
        .long 0x400c
foo:
        mflr 0
        stwu 1,-16(1)
        stw 0,20(1)
        mr 0,3
        mr 6,4			# lower addressed word is in an even register!
        mr 7,5			# ... and higher addressed word in odd register
        addis 3,0,.LC0@ha
        addi 3,3,.LC0@l
        mr 4,0
        addi 5,4,1
        crxor 6,6,6
        bl bar
        lwz 0,20(1)
        mtlr 0
        addi 1,1,16
        blr
.Lfe1:
        .size    foo,.Lfe1-foo
        .ident  "GCC: (GNU) 2.7.2"
% 
Technical Details
Message-ID: <199601110501.WAA21565@forge.BSDI.COM>
Path: arc1-ca.pugleaf.net!unknown!not-for-mail

Show Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit
X-Google-Thread: 113d02,b0035ed1ce65df43,start
X-Google-Attributes: gid113d02,public
From: donn@bsdi.com (Donn Seeley)
Subject: Power PC ABI requires long long parameter alignment
Date: 1996/01/11
Message-ID: <199601110501.WAA21565@forge.BSDI.COM>
X-Deja-AN: 135045612
distribution: gnu
sender: daemon@cis.ohio-state.edu
organization: GNUs Not Usenet
newsgroups: gnu.gcc.bug