From 95727fb877e650d1d4be5798151a2cde09cd0553 Mon Sep 17 00:00:00 2001 From: Andrew Pinski Date: Sat, 17 Jan 2004 19:48:50 +0000 Subject: [PATCH] re PR target/10781 (wrong class size and alignment with static class member) 2004-01-17 Andrew Pinski PR target/10781 * config/rs6000/rs6000-protos.h (rs6000_special_round_type_align): Prototype. * config/rs6000/rs6000.c (rs6000_special_round_type_align): New function. * config/rs6000/linux64.h (ROUND_TYPE_ALIGN): Use it. * config/rs6000/aix.h (ROUND_TYPE_ALIGN): Likewise. * config/rs6000/darwin.h (ROUND_TYPE_ALIGN): Likewise. 2004-01-17 Andrew Pinski PR target/10781 * encoding.c (rs6000_special_round_type_align): Define. From-SVN: r76043 --- gcc/ChangeLog | 11 +++++++++++ gcc/config/rs6000/aix.h | 14 ++++++-------- gcc/config/rs6000/darwin.h | 19 +++++++++---------- gcc/config/rs6000/linux64.h | 22 ++++++++++------------ gcc/config/rs6000/rs6000-protos.h | 1 + gcc/config/rs6000/rs6000.c | 22 ++++++++++++++++++++++ libobjc/ChangeLog | 5 +++++ libobjc/encoding.c | 11 +++++++++++ 8 files changed, 75 insertions(+), 30 deletions(-) diff --git a/gcc/ChangeLog b/gcc/ChangeLog index e1f443c2db3..ee0da69d6a4 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,14 @@ +2004-01-17 Andrew Pinski + + PR target/10781 + * config/rs6000/rs6000-protos.h (rs6000_special_round_type_align): + Prototype. + * config/rs6000/rs6000.c (rs6000_special_round_type_align): + New function. + * config/rs6000/linux64.h (ROUND_TYPE_ALIGN): Use it. + * config/rs6000/aix.h (ROUND_TYPE_ALIGN): Likewise. + * config/rs6000/darwin.h (ROUND_TYPE_ALIGN): Likewise. + 2004-01-17 Jan Hubicka * toplev.c (rest_of_handle_reorder_blocks): Fix pasto in previous diff --git a/gcc/config/rs6000/aix.h b/gcc/config/rs6000/aix.h index 3318621a253..69a0a017920 100644 --- a/gcc/config/rs6000/aix.h +++ b/gcc/config/rs6000/aix.h @@ -139,14 +139,12 @@ /* AIX increases natural record alignment to doubleword if the first field is an FP double while the FP fields remain word aligned. */ -#define ROUND_TYPE_ALIGN(STRUCT, COMPUTED, SPECIFIED) \ - ((TREE_CODE (STRUCT) == RECORD_TYPE \ - || TREE_CODE (STRUCT) == UNION_TYPE \ - || TREE_CODE (STRUCT) == QUAL_UNION_TYPE) \ - && TYPE_FIELDS (STRUCT) != 0 \ - && TARGET_ALIGN_NATURAL == 0 \ - && DECL_MODE (TYPE_FIELDS (STRUCT)) == DFmode \ - ? MAX (MAX ((COMPUTED), (SPECIFIED)), 64) \ +#define ROUND_TYPE_ALIGN(STRUCT, COMPUTED, SPECIFIED) \ + ((TREE_CODE (STRUCT) == RECORD_TYPE \ + || TREE_CODE (STRUCT) == UNION_TYPE \ + || TREE_CODE (STRUCT) == QUAL_UNION_TYPE) \ + && TARGET_ALIGN_NATURAL == 0 \ + ? rs6000_special_round_type_align (STRUCT, COMPUTED, SPECIFIED) \ : MAX ((COMPUTED), (SPECIFIED))) /* The AIX ABI isn't explicit on whether aggregates smaller than a diff --git a/gcc/config/rs6000/darwin.h b/gcc/config/rs6000/darwin.h index c77279d2142..6db00069991 100644 --- a/gcc/config/rs6000/darwin.h +++ b/gcc/config/rs6000/darwin.h @@ -295,16 +295,14 @@ do { \ /* Darwin increases natural record alignment to doubleword if the first field is an FP double while the FP fields remain word aligned. */ -#define ROUND_TYPE_ALIGN(STRUCT, COMPUTED, SPECIFIED) \ - ((TREE_CODE (STRUCT) == RECORD_TYPE \ - || TREE_CODE (STRUCT) == UNION_TYPE \ - || TREE_CODE (STRUCT) == QUAL_UNION_TYPE) \ - && TYPE_FIELDS (STRUCT) != 0 \ - && TARGET_ALIGN_NATURAL == 0 \ - && DECL_MODE (TYPE_FIELDS (STRUCT)) == DFmode \ - ? MAX (MAX ((COMPUTED), (SPECIFIED)), 64) \ - : (TARGET_ALTIVEC && TREE_CODE (STRUCT) == VECTOR_TYPE) \ - ? MAX (MAX ((COMPUTED), (SPECIFIED)), 128) \ +#define ROUND_TYPE_ALIGN(STRUCT, COMPUTED, SPECIFIED) \ + ((TREE_CODE (STRUCT) == RECORD_TYPE \ + || TREE_CODE (STRUCT) == UNION_TYPE \ + || TREE_CODE (STRUCT) == QUAL_UNION_TYPE) \ + && TARGET_ALIGN_NATURAL == 0 \ + ? rs6000_special_round_type_align (STRUCT, COMPUTED, SPECIFIED) \ + : (TARGET_ALTIVEC && TREE_CODE (STRUCT) == VECTOR_TYPE) \ + ? MAX (MAX ((COMPUTED), (SPECIFIED)), 128) \ : MAX ((COMPUTED), (SPECIFIED))) /* XXX: Darwin supports neither .quad, or .llong, but it also doesn't @@ -322,3 +320,4 @@ do { \ #undef REGISTER_TARGET_PRAGMAS #define REGISTER_TARGET_PRAGMAS DARWIN_REGISTER_TARGET_PRAGMAS + diff --git a/gcc/config/rs6000/linux64.h b/gcc/config/rs6000/linux64.h index d56c106b533..d36aef4485e 100644 --- a/gcc/config/rs6000/linux64.h +++ b/gcc/config/rs6000/linux64.h @@ -224,19 +224,17 @@ : (COMPUTED)) /* PowerPC64 Linux increases natural record alignment to doubleword if - the first field is an FP double. */ + the first field is an FP double, only if in power alignment mode. */ #undef ROUND_TYPE_ALIGN -#define ROUND_TYPE_ALIGN(STRUCT, COMPUTED, SPECIFIED) \ - ((TARGET_ALTIVEC && TREE_CODE (STRUCT) == VECTOR_TYPE) \ - ? MAX (MAX ((COMPUTED), (SPECIFIED)), 128) \ - : (TARGET_64BIT \ - && (TREE_CODE (STRUCT) == RECORD_TYPE \ - || TREE_CODE (STRUCT) == UNION_TYPE \ - || TREE_CODE (STRUCT) == QUAL_UNION_TYPE) \ - && TYPE_FIELDS (STRUCT) != 0 \ - && TARGET_ALIGN_NATURAL == 0 \ - && DECL_MODE (TYPE_FIELDS (STRUCT)) == DFmode) \ - ? MAX (MAX ((COMPUTED), (SPECIFIED)), 64) \ +#define ROUND_TYPE_ALIGN(STRUCT, COMPUTED, SPECIFIED) \ + ((TARGET_ALTIVEC && TREE_CODE (STRUCT) == VECTOR_TYPE) \ + ? MAX (MAX ((COMPUTED), (SPECIFIED)), 128) \ + : (TARGET_64BIT \ + && (TREE_CODE (STRUCT) == RECORD_TYPE \ + || TREE_CODE (STRUCT) == UNION_TYPE \ + || TREE_CODE (STRUCT) == QUAL_UNION_TYPE) \ + && TARGET_ALIGN_NATURAL == 0) \ + ? rs6000_special_round_type_align (STRUCT, COMPUTED, SPECIFIED) \ : MAX ((COMPUTED), (SPECIFIED))) /* Indicate that jump tables go in the text section. */ diff --git a/gcc/config/rs6000/rs6000-protos.h b/gcc/config/rs6000/rs6000-protos.h index abf39c6ed96..b98027ef822 100644 --- a/gcc/config/rs6000/rs6000-protos.h +++ b/gcc/config/rs6000/rs6000-protos.h @@ -144,6 +144,7 @@ extern rtx rs6000_machopic_legitimize_pic_address (rtx orig, #endif /* RTX_CODE */ #ifdef TREE_CODE +extern int rs6000_special_round_type_align (tree, int, int); extern void function_arg_advance (CUMULATIVE_ARGS *, enum machine_mode, tree, int); extern int function_arg_boundary (enum machine_mode, tree); diff --git a/gcc/config/rs6000/rs6000.c b/gcc/config/rs6000/rs6000.c index 183cf21ab7e..0a5de536d91 100644 --- a/gcc/config/rs6000/rs6000.c +++ b/gcc/config/rs6000/rs6000.c @@ -2317,6 +2317,28 @@ input_operand (rtx op, enum machine_mode mode) return 0; } + +/* Darwin, AIX increases natural record alignment to doubleword if the first + field is an FP double while the FP fields remain word aligned. */ + +int +rs6000_special_round_type_align (tree type, int computed, int specified) +{ + tree field = TYPE_FIELDS (type); + if (!field) + return MAX (computed, specified); + + /* Skip all the static variables only if ABI is greater than + 1 or equal to 0. */ + while (TREE_CODE (field) == VAR_DECL) + field = TREE_CHAIN (field); + + if (field == type || DECL_MODE (field) != DFmode) + return MAX (computed, specified); + + return MAX (MAX (computed, specified), 64); +} + /* Return 1 for an operand in small memory on V.4/eabi. */ int diff --git a/libobjc/ChangeLog b/libobjc/ChangeLog index 069a1f9dc51..cf2fe5f73ac 100644 --- a/libobjc/ChangeLog +++ b/libobjc/ChangeLog @@ -1,3 +1,8 @@ +2004-01-17 Andrew Pinski + + PR target/10781 + * encoding.c (rs6000_special_round_type_align): Define. + 2004-01-14 Adam Fedor PR libobjc/12155 diff --git a/libobjc/encoding.c b/libobjc/encoding.c index bed0653cff7..17bc8d4e2e1 100644 --- a/libobjc/encoding.c +++ b/libobjc/encoding.c @@ -88,6 +88,17 @@ Boston, MA 02111-1307, USA. */ eliminate the warning. */ static int __attribute__ ((__unused__)) target_flags = 0; + +/* FIXME: while this file has no business including tm.h, this + definitely has no business defining this macro but it + is only way around without really rewritting this file, + should look after the branch of 3.4 to fix this. */ +#define rs6000_special_round_type_align(STRUCT, COMPUTED, SPECIFIED) \ + ((TYPE_FIELDS (STRUCT) != 0 \ + && DECL_MODE (TYPE_FIELDS (STRUCT)) == DFmode) \ + ? MAX (MAX (COMPUTED, SPECIFIED), 64) \ + : MAX (COMPUTED, SPECIFIED)) + /* return the size of an object specified by type */