small struct bugs for ppc sysv4
Aldy Hernandez
aldyh@redhat.com
Thu Apr 25 20:09:00 GMT 2002
hi david.
here's the small structure bug we had talked about a month ago.
i forgot about the patch and just committed it in a redhat local tree.
alan was nice enough to bootstrap it and test it for regressions while
i was on vacation.
is this ok for branch and trunk?
----- Forwarded message from Aldy Hernandez <aldyh@redhat.com> -----
From: Aldy Hernandez <aldyh@redhat.com>
Subject: small struct problem
To: dje@watson.ibm.com
Date: Sun, 17 Mar 2002 15:32:35 +1100
User-Agent: Mutt/1.3.25i
and the culprit is stmt.c's expand_return():
/* Structures whose size is not a multiple of a word are aligned
to the least significant byte (to the right). On a BYTES_BIG_ENDIAN
machine, this means we must skip the empty high order bytes when
calculating the bit offset. */
if (BYTES_BIG_ENDIAN
&& !FUNCTION_ARG_REG_LITTLE_ENDIAN
&& bytes % UNITS_PER_WORD)
big_endian_correction = (BITS_PER_WORD - ((bytes % UNITS_PER_WORD)
* BITS_PER_UNIT));
that should be aligned to the left for sysv4. right now, the above
code is eventually generating (for the C code below):
r3 0x102
r4 0x03040506
when it should really be:
r3 0x01020304
r4 0x0506
...and here's a patch to fix the problem.
2002-04-26 Aldy Hernandez <aldyh@redhat.com>
* config/rs6000/rs6000.h (FUNCTION_ARG_REG_LITTLE_ENDIAN): New.
Index: config/rs6000/rs6000.h
===================================================================
RCS file: /cvs/uberbaum/gcc/config/rs6000/rs6000.h,v
retrieving revision 1.199
diff -c -p -r1.199 rs6000.h
*** config/rs6000/rs6000.h 12 Apr 2002 16:57:47 -0000 1.199
--- config/rs6000/rs6000.h 26 Apr 2002 03:02:33 -0000
*************** extern int rs6000_altivec_abi;
*** 519,524 ****
--- 519,530 ----
instructions for them. Might as well be consistent with bits and bytes. */
#define WORDS_BIG_ENDIAN 1
+ /* Define to TRUE on a big-endian system when structure arguments
+ passed (and returned) in registers are passed in a little-endian
+ manner instead of a big-endian manner. */
+
+ #define FUNCTION_ARG_REG_LITTLE_ENDIAN 1
+
#define MAX_BITS_PER_WORD 64
/* Width of a word, in units (bytes). */
More information about the Gcc-patches
mailing list