From: Kevin B. Hendricks Date: Mon, 19 May 2003 17:39:51 +0000 (+0000) Subject: rs6000.c (rs6000_alignment_string, [...]): New variables. X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=025d9908d3e3816f06a045d936c569361522ec6e;p=gcc.git rs6000.c (rs6000_alignment_string, [...]): New variables. 2003-05-18 Kevin B. Hendricks David Edelsohn * config/rs6000/rs6000.c (rs6000_alignment_string, rs6000_alignment_flags): New variables. (rs6000_parse_alignment_option): New function. (rs6000_override_options): Call it. * config/rs6000/rs6000.h (TARGET_OPTIONS): Add -malign-XXX option. (MASK_ALIGN_POWER, MASK_ALIGN_NATURAL, TARGET_ALIGN_NATURAL): New macros. * config/rs6000/aix.h (ADJUST_FIELD_ALIGN): Always use COMPUTED natural alignment if TARGET_NATURAL_ALIGNMENT (ROUND_TYPE_ALIGN): Always use default record alignment if TAGET_NATURAL_ALIGNMENT. * config/rs6000/darwin.h (ADJUST_FIELD_ALIGN): Same (ROUND_TYPE_ALIGN): Same. * config/rs6000/linux64.h (ADJUST_FIELD_ALIGN): Same (ROUND_TYPE_ALIGN): Same. Co-Authored-By: David Edelsohn From-SVN: r66967 --- diff --git a/gcc/ChangeLog b/gcc/ChangeLog index 484a2d84bf4..797e9d53083 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,22 @@ +2003-05-19 Kevin B. Hendricks + David Edelsohn + + * config/rs6000/rs6000.c (rs6000_alignment_string, + rs6000_alignment_flags): New variables. + (rs6000_parse_alignment_option): New function. + (rs6000_override_options): Call it. + * config/rs6000/rs6000.h (TARGET_OPTIONS): Add -malign-XXX option. + (MASK_ALIGN_POWER, MASK_ALIGN_NATURAL, TARGET_ALIGN_NATURAL): New + macros. + * config/rs6000/aix.h (ADJUST_FIELD_ALIGN): Always use COMPUTED + natural alignment if TARGET_NATURAL_ALIGNMENT + (ROUND_TYPE_ALIGN): Always use default record alignment if + TAGET_NATURAL_ALIGNMENT. + * config/rs6000/darwin.h (ADJUST_FIELD_ALIGN): Same + (ROUND_TYPE_ALIGN): Same. + * config/rs6000/linux64.h (ADJUST_FIELD_ALIGN): Same + (ROUND_TYPE_ALIGN): Same. + 2003-05-19 J"orn Rennecke * c-decl.c (finish_decl): When setting the DECL_ASSEMBLER_NAME diff --git a/gcc/config/rs6000/aix.h b/gcc/config/rs6000/aix.h index 53425bd0cbd..0ca22cd72d6 100644 --- a/gcc/config/rs6000/aix.h +++ b/gcc/config/rs6000/aix.h @@ -128,12 +128,14 @@ #define LIB_SPEC "%{pg:-L/lib/profiled -L/usr/lib/profiled}\ %{p:-L/lib/profiled -L/usr/lib/profiled} %{!shared:%{g*:-lg}} -lc" +/* This now supports a natural alignment mode. */ /* AIX word-aligns FP doubles but doubleword-aligns 64-bit ints. */ #define ADJUST_FIELD_ALIGN(FIELD, COMPUTED) \ + (TARGET_ALIGN_NATURAL ? (COMPUTED) : \ (TYPE_MODE (TREE_CODE (TREE_TYPE (FIELD)) == ARRAY_TYPE \ ? get_inner_array_type (FIELD) \ : TREE_TYPE (FIELD)) == DFmode \ - ? MIN ((COMPUTED), 32) : (COMPUTED)) + ? MIN ((COMPUTED), 32) : (COMPUTED))) /* AIX increases natural record alignment to doubleword if the first field is an FP double while the FP fields remain word aligned. */ @@ -142,6 +144,7 @@ || 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) \ : MAX ((COMPUTED), (SPECIFIED))) diff --git a/gcc/config/rs6000/darwin.h b/gcc/config/rs6000/darwin.h index 20f1ca229fc..478b9a6176b 100644 --- a/gcc/config/rs6000/darwin.h +++ b/gcc/config/rs6000/darwin.h @@ -250,12 +250,14 @@ do { \ /* Fix for emit_group_load (): force large constants to be pushed via regs. */ #define ALWAYS_PUSH_CONSTS_USING_REGS_P 1 +/* This now supports a natural alignment mode */ /* Darwin word-aligns FP doubles but doubleword-aligns 64-bit ints. */ #define ADJUST_FIELD_ALIGN(FIELD, COMPUTED) \ + (TARGET_ALIGN_NATURAL ? (COMPUTED) : \ (TYPE_MODE (TREE_CODE (TREE_TYPE (FIELD)) == ARRAY_TYPE \ ? get_inner_array_type (FIELD) \ : TREE_TYPE (FIELD)) == DFmode \ - ? MIN ((COMPUTED), 32) : (COMPUTED)) + ? MIN ((COMPUTED), 32) : (COMPUTED))) /* Darwin increases natural record alignment to doubleword if the first field is an FP double while the FP fields remain word aligned. */ @@ -264,6 +266,7 @@ do { \ || 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) \ diff --git a/gcc/config/rs6000/linux64.h b/gcc/config/rs6000/linux64.h index 128e3b75536..bd3a6a85b18 100644 --- a/gcc/config/rs6000/linux64.h +++ b/gcc/config/rs6000/linux64.h @@ -119,13 +119,15 @@ #define USER_LABEL_PREFIX "" +/* This now supports a natural alignment mode. */ /* AIX word-aligns FP doubles but doubleword-aligns 64-bit ints. */ #undef ADJUST_FIELD_ALIGN #define ADJUST_FIELD_ALIGN(FIELD, COMPUTED) \ + (TARGET_ALIGN_NATURAL ? (COMPUTED) : \ (TYPE_MODE (TREE_CODE (TREE_TYPE (FIELD)) == ARRAY_TYPE \ ? get_inner_array_type (FIELD) \ : TREE_TYPE (FIELD)) == DFmode \ - ? MIN ((COMPUTED), 32) : (COMPUTED)) + ? MIN ((COMPUTED), 32) : (COMPUTED))) /* AIX increases natural record alignment to doubleword if the first field is an FP double while the FP fields remain word aligned. */ @@ -135,6 +137,7 @@ || 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) \ : MAX ((COMPUTED), (SPECIFIED))) diff --git a/gcc/config/rs6000/rs6000.c b/gcc/config/rs6000/rs6000.c index 770df4f3d53..ff7cec6a9d6 100644 --- a/gcc/config/rs6000/rs6000.c +++ b/gcc/config/rs6000/rs6000.c @@ -178,6 +178,11 @@ static int rs6000_sr_alias_set; int rs6000_default_long_calls; const char *rs6000_longcall_switch; +/* Control alignment for fields within structures. */ +/* String from -malign-XXXXX. */ +const char *rs6000_alignment_string; +int rs6000_alignment_flags; + struct builtin_description { /* mask is not const because we're going to alter it below. This @@ -290,6 +295,7 @@ static rtx altivec_expand_abs_builtin PARAMS ((enum insn_code, tree, rtx)); static rtx altivec_expand_predicate_builtin PARAMS ((enum insn_code, const char *, tree, rtx)); static rtx altivec_expand_stv_builtin PARAMS ((enum insn_code, tree)); static void rs6000_parse_abi_options PARAMS ((void)); +static void rs6000_parse_alignment_option PARAMS ((void)); static void rs6000_parse_tls_size_option PARAMS ((void)); static void rs6000_parse_yes_no_option (const char *, const char *, int *); static int first_altivec_reg_to_save PARAMS ((void)); @@ -739,6 +745,9 @@ rs6000_override_options (default_cpu) /* Handle -mabi= options. */ rs6000_parse_abi_options (); + /* Handle -malign-XXXXX option. */ + rs6000_parse_alignment_option (); + /* Handle generic -mFOO=YES/NO options. */ rs6000_parse_yes_no_option ("vrsave", rs6000_altivec_vrsave_string, &rs6000_altivec_vrsave); @@ -888,6 +897,20 @@ rs6000_parse_abi_options () error ("unknown ABI specified: '%s'", rs6000_abi_string); } +/* Handle -malign-XXXXXX options. */ +static void +rs6000_parse_alignment_option () +{ + if (rs6000_alignment_string == 0 + || ! strcmp (rs6000_alignment_string, "power")) + rs6000_alignment_flags = MASK_ALIGN_POWER; + else if (! strcmp (rs6000_alignment_string, "natural")) + rs6000_alignment_flags = MASK_ALIGN_NATURAL; + else + error ("unknown -malign-XXXXX option specified: '%s'", + rs6000_alignment_string); +} + /* Validate and record the size specified with the -mtls-size option. */ static void diff --git a/gcc/config/rs6000/rs6000.h b/gcc/config/rs6000/rs6000.h index 8cd28acb374..4eaae019fa5 100644 --- a/gcc/config/rs6000/rs6000.h +++ b/gcc/config/rs6000/rs6000.h @@ -402,6 +402,8 @@ extern enum processor_type rs6000_cpu; {"longcall", &rs6000_longcall_switch, \ N_("Avoid all range limits on call instructions"), 0}, \ {"no-longcall", &rs6000_longcall_switch, "", 0}, \ + {"align-", &rs6000_alignment_string, \ + N_("Specify alignment of structure fields default/natural"), 0}, \ SUBTARGET_OPTIONS \ } @@ -443,6 +445,25 @@ extern const char *rs6000_altivec_vrsave_string; extern int rs6000_altivec_vrsave; extern const char *rs6000_longcall_switch; extern int rs6000_default_long_calls; +extern const char* rs6000_alignment_string; +extern int rs6000_alignment_flags; + +/* Alignment options for fields in structures for sub-targets following + AIX-like ABI. + ALIGN_POWER word-aligns FP doubles (default AIX ABI). + ALIGN_NATURAL doubleword-aligns FP doubles (align to object size). + + Override the macro definitions when compiling libobjc to avoid undefined + reference to rs6000_alignment_flags due to library's use of GCC alignment + macros which use the macros below. */ + +#ifndef IN_TARGET_LIBS +#define MASK_ALIGN_POWER 0x00000000 +#define MASK_ALIGN_NATURAL 0x00000001 +#define TARGET_ALIGN_NATURAL (rs6000_alignment_flags & MASK_ALIGN_NATURAL) +#else +#define TARGET_ALIGN_NATURAL 0 +#endif #define TARGET_LONG_DOUBLE_128 (rs6000_long_double_type_size == 128) #define TARGET_ALTIVEC_ABI rs6000_altivec_abi