aboutsummaryrefslogtreecommitdiff
path: root/gcc/config/cris
diff options
context:
space:
mode:
authorRichard Sandiford <richard.sandiford@linaro.org>2017-10-26 11:28:25 +0000
committerRichard Sandiford <rsandifo@gcc.gnu.org>2017-10-26 11:28:25 +0000
commitf073de07ad00d4be604bdbaeab14786850932601 (patch)
tree825db4f6d56d10a34af45d9e3c9e8dcaf128e151 /gcc/config/cris
parent4bc19a3b1a9fe74e515b7c54082bbad27decc227 (diff)
downloadgcc-f073de07ad00d4be604bdbaeab14786850932601.zip
gcc-f073de07ad00d4be604bdbaeab14786850932601.tar.gz
gcc-f073de07ad00d4be604bdbaeab14786850932601.tar.bz2
This patch adds a new hook that gives the preferred alignment for a static rtx...
TARGET_STATIC_RTX_ALIGNMENT This patch adds a new hook that gives the preferred alignment for a static rtx, so that we don't need to query the front end in force_const_mem. 2017-10-26 Richard Sandiford <richard.sandiford@linaro.org> gcc/ * target.def (static_rtx_alignment): New hook. * targhooks.h (default_static_rtx_alignment): Declare. * targhooks.c (default_static_rtx_alignment): New function. * doc/tm.texi.in (TARGET_STATIC_RTX_ALIGNMENT): New hook. * doc/tm.texi: Regenerate. * varasm.c (force_const_mem): Use targetm.static_rtx_alignment instead of targetm.constant_alignment. Remove call to set_mem_attributes. * config/cris/cris.c (TARGET_STATIC_RTX_ALIGNMENT): Redefine. (cris_preferred_mininum_alignment): New function, split out from... (cris_constant_alignment): ...here. (cris_static_rtx_alignment): New function. * config/i386/i386.c (ix86_static_rtx_alignment): New function, split out from... (ix86_constant_alignment): ...here. (TARGET_STATIC_RTX_ALIGNMENT): Redefine. * config/mmix/mmix.c (TARGET_STATIC_RTX_ALIGNMENT): Redefine. (mmix_static_rtx_alignment): New function. * config/spu/spu.c (spu_static_rtx_alignment): New function. (TARGET_STATIC_RTX_ALIGNMENT): Redefine. From-SVN: r254102
Diffstat (limited to 'gcc/config/cris')
-rw-r--r--gcc/config/cris/cris.c29
1 files changed, 24 insertions, 5 deletions
diff --git a/gcc/config/cris/cris.c b/gcc/config/cris/cris.c
index fe80a27..8fa234f 100644
--- a/gcc/config/cris/cris.c
+++ b/gcc/config/cris/cris.c
@@ -165,6 +165,7 @@ static bool cris_function_value_regno_p (const unsigned int);
static void cris_file_end (void);
static unsigned int cris_hard_regno_nregs (unsigned int, machine_mode);
static bool cris_hard_regno_mode_ok (unsigned int, machine_mode);
+static HOST_WIDE_INT cris_static_rtx_alignment (machine_mode);
static HOST_WIDE_INT cris_constant_alignment (const_tree, HOST_WIDE_INT);
/* This is the parsed result of the "-max-stack-stackframe=" option. If
@@ -288,6 +289,8 @@ int cris_cpu_version = CRIS_DEFAULT_CPU_VERSION;
#undef TARGET_HARD_REGNO_MODE_OK
#define TARGET_HARD_REGNO_MODE_OK cris_hard_regno_mode_ok
+#undef TARGET_STATIC_RTX_ALIGNMENT
+#define TARGET_STATIC_RTX_ALIGNMENT cris_static_rtx_alignment
#undef TARGET_CONSTANT_ALIGNMENT
#define TARGET_CONSTANT_ALIGNMENT cris_constant_alignment
@@ -4329,6 +4332,26 @@ cris_hard_regno_mode_ok (unsigned int regno, machine_mode mode)
|| (regno != CRIS_MOF_REGNUM && regno != CRIS_ACR_REGNUM)));
}
+/* Return the preferred minimum alignment for a static object. */
+
+static HOST_WIDE_INT
+cris_preferred_mininum_alignment (void)
+{
+ if (!TARGET_CONST_ALIGN)
+ return 8;
+ if (TARGET_ALIGN_BY_32)
+ return 32;
+ return 16;
+}
+
+/* Implement TARGET_STATIC_RTX_ALIGNMENT. */
+
+static HOST_WIDE_INT
+cris_static_rtx_alignment (machine_mode mode)
+{
+ return MAX (cris_preferred_mininum_alignment (), GET_MODE_ALIGNMENT (mode));
+}
+
/* Implement TARGET_CONSTANT_ALIGNMENT. Note that this hook has the
effect of making gcc believe that ALL references to constant stuff
(in code segment, like strings) have this alignment. That is a rather
@@ -4339,11 +4362,7 @@ cris_hard_regno_mode_ok (unsigned int regno, machine_mode mode)
static HOST_WIDE_INT
cris_constant_alignment (const_tree, HOST_WIDE_INT basic_align)
{
- if (!TARGET_CONST_ALIGN)
- return basic_align;
- if (TARGET_ALIGN_BY_32)
- return MAX (basic_align, 32);
- return MAX (basic_align, 16);
+ return MAX (cris_preferred_mininum_alignment (), basic_align);
}
#if 0