rs6000.c (rs6000_alignment_string, [...]): New variables.
authorKevin B. Hendricks <kevin.hendricks@sympatico.ca>
Mon, 19 May 2003 17:39:51 +0000 (17:39 +0000)
committerDavid Edelsohn <dje@gcc.gnu.org>
Mon, 19 May 2003 17:39:51 +0000 (13:39 -0400)
2003-05-18  Kevin B. Hendricks  <kevin.hendricks@sympatico.ca>
            David Edelsohn  <edelsohn@gnu.org>

        * 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 <edelsohn@gnu.org>
From-SVN: r66967

gcc/ChangeLog
gcc/config/rs6000/aix.h
gcc/config/rs6000/darwin.h
gcc/config/rs6000/linux64.h
gcc/config/rs6000/rs6000.c
gcc/config/rs6000/rs6000.h

index 484a2d8..797e9d5 100644 (file)
@@ -1,3 +1,22 @@
+2003-05-19  Kevin B. Hendricks  <kevin.hendricks@sympatico.ca>
+            David Edelsohn  <edelsohn@gnu.org>
+
+       * 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 <joern.rennecke@superh.com>
 
        * c-decl.c (finish_decl): When setting the DECL_ASSEMBLER_NAME
index 53425bd..0ca22cd 100644 (file)
 #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.  */
     || 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)))
index 20f1ca2..478b9a6 100644 (file)
@@ -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) \
index 128e3b7..bd3a6a8 100644 (file)
 
 #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.  */
     || 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)))
index 770df4f..ff7cec6 100644 (file)
@@ -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
index 8cd28ac..4eaae01 100644 (file)
@@ -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