+2017-10-26 Richard Sandiford <richard.sandiford@linaro.org>
+
+ * 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.
+
2017-10-26 Tamar Christina <tamar.christina@arm.com>
PR target/81800
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
#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
|| (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
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
}
\f
+/* Implement TARGET_STATIC_RTX_ALIGNMENT. */
+
+static HOST_WIDE_INT
+ix86_static_rtx_alignment (machine_mode mode)
+{
+ if (mode == DFmode)
+ return 64;
+ if (ALIGN_MODE_128 (mode))
+ return MAX (128, GET_MODE_ALIGNMENT (mode));
+ return GET_MODE_ALIGNMENT (mode);
+}
+
/* Implement TARGET_CONSTANT_ALIGNMENT. */
static HOST_WIDE_INT
if (TREE_CODE (exp) == REAL_CST || TREE_CODE (exp) == VECTOR_CST
|| TREE_CODE (exp) == INTEGER_CST)
{
- if (TYPE_MODE (TREE_TYPE (exp)) == DFmode && align < 64)
- return 64;
- else if (ALIGN_MODE_128 (TYPE_MODE (TREE_TYPE (exp))) && align < 128)
- return 128;
+ machine_mode mode = TYPE_MODE (TREE_TYPE (exp));
+ HOST_WIDE_INT mode_align = ix86_static_rtx_alignment (mode);
+ return MAX (mode_align, align);
}
else if (!optimize_size && TREE_CODE (exp) == STRING_CST
&& TREE_STRING_LENGTH (exp) >= 31 && align < BITS_PER_WORD)
#undef TARGET_CAN_CHANGE_MODE_CLASS
#define TARGET_CAN_CHANGE_MODE_CLASS ix86_can_change_mode_class
+#undef TARGET_STATIC_RTX_ALIGNMENT
+#define TARGET_STATIC_RTX_ALIGNMENT ix86_static_rtx_alignment
#undef TARGET_CONSTANT_ALIGNMENT
#define TARGET_CONSTANT_ALIGNMENT ix86_constant_alignment
static void mmix_print_operand_address (FILE *, machine_mode, rtx);
static bool mmix_print_operand_punct_valid_p (unsigned char);
static void mmix_conditional_register_usage (void);
+static HOST_WIDE_INT mmix_static_rtx_alignment (machine_mode);
static HOST_WIDE_INT mmix_constant_alignment (const_tree, HOST_WIDE_INT);
static HOST_WIDE_INT mmix_starting_frame_offset (void);
#undef TARGET_OPTION_OVERRIDE
#define TARGET_OPTION_OVERRIDE mmix_option_override
+#undef TARGET_STATIC_RTX_ALIGNMENT
+#define TARGET_STATIC_RTX_ALIGNMENT mmix_static_rtx_alignment
#undef TARGET_CONSTANT_ALIGNMENT
#define TARGET_CONSTANT_ALIGNMENT mmix_constant_alignment
return basic_align;
}
+/* Implement TARGET_STATIC_RTX_ALIGNMENT. */
+
+static HOST_WIDE_INT
+mmix_static_rtx_alignment (machine_mode mode)
+{
+ return MAX (GET_MODE_ALIGNMENT (mode), 32);
+}
+
/* Implement tARGET_CONSTANT_ALIGNMENT. */
static HOST_WIDE_INT
return inprec <= 32 && outprec <= inprec;
}
+/* Implement TARGET_STATIC_RTX_ALIGNMENT.
+
+ Make all static objects 16-byte aligned. This allows us to assume
+ they are also padded to 16 bytes, which means we can use a single
+ load or store instruction to access them. */
+
+static HOST_WIDE_INT
+spu_static_rtx_alignment (machine_mode mode)
+{
+ return MAX (GET_MODE_ALIGNMENT (mode), 128);
+}
+
/* Implement TARGET_CONSTANT_ALIGNMENT.
Make all static objects 16-byte aligned. This allows us to assume
#undef TARGET_TRULY_NOOP_TRUNCATION
#define TARGET_TRULY_NOOP_TRUNCATION spu_truly_noop_truncation
+#undef TARGET_STATIC_RTX_ALIGNMENT
+#define TARGET_STATIC_RTX_ALIGNMENT spu_static_rtx_alignment
#undef TARGET_CONSTANT_ALIGNMENT
#define TARGET_CONSTANT_ALIGNMENT spu_constant_alignment
@samp{(0x80000000 * 8)}, but this is not representable on 32-bit hosts.
@end defmac
+@deftypefn {Target Hook} HOST_WIDE_INT TARGET_STATIC_RTX_ALIGNMENT (machine_mode @var{mode})
+This hook returns the preferred alignment in bits for a
+statically-allocated rtx, such as a constant pool entry. @var{mode}
+is the mode of the rtx. The default implementation returns
+@samp{GET_MODE_ALIGNMENT (@var{mode})}.
+@end deftypefn
+
@defmac DATA_ALIGNMENT (@var{type}, @var{basic-align})
If defined, a C expression to compute the alignment for a variable in
the static store. @var{type} is the data type, and @var{basic-align} is
@samp{(0x80000000 * 8)}, but this is not representable on 32-bit hosts.
@end defmac
+@hook TARGET_STATIC_RTX_ALIGNMENT
+
@defmac DATA_ALIGNMENT (@var{type}, @var{basic-align})
If defined, a C expression to compute the alignment for a variable in
the static store. @var{type} is the data type, and @var{basic-align} is
#undef HOOK_PREFIX
#define HOOK_PREFIX "TARGET_"
+DEFHOOK
+(static_rtx_alignment,
+ "This hook returns the preferred alignment in bits for a\n\
+statically-allocated rtx, such as a constant pool entry. @var{mode}\n\
+is the mode of the rtx. The default implementation returns\n\
+@samp{GET_MODE_ALIGNMENT (@var{mode})}.",
+ HOST_WIDE_INT, (machine_mode mode),
+ default_static_rtx_alignment)
+
DEFHOOK
(constant_alignment,
"This hook returns the alignment in bits of a constant that is being\n\
return id;
}
+/* The default implementation of TARGET_STATIC_RTX_ALIGNMENT. */
+
+HOST_WIDE_INT
+default_static_rtx_alignment (machine_mode mode)
+{
+ return GET_MODE_ALIGNMENT (mode);
+}
+
/* The default implementation of TARGET_CONSTANT_ALIGNMENT. */
HOST_WIDE_INT
extern tree default_builtin_reciprocal (tree);
+extern HOST_WIDE_INT default_static_rtx_alignment (machine_mode);
extern HOST_WIDE_INT default_constant_alignment (const_tree, HOST_WIDE_INT);
extern HOST_WIDE_INT constant_alignment_word_strings (const_tree,
HOST_WIDE_INT);
*slot = desc;
/* Align the location counter as required by EXP's data type. */
- align = GET_MODE_ALIGNMENT (mode == VOIDmode ? word_mode : mode);
-
- tree type = lang_hooks.types.type_for_mode (mode, 0);
- if (type != NULL_TREE)
- align = targetm.constant_alignment (make_tree (type, x), align);
+ machine_mode align_mode = (mode == VOIDmode ? word_mode : mode);
+ align = targetm.static_rtx_alignment (align_mode);
pool->offset += (align / BITS_PER_UNIT) - 1;
pool->offset &= ~ ((align / BITS_PER_UNIT) - 1);
/* Construct the MEM. */
desc->mem = def = gen_const_mem (mode, symbol);
- set_mem_attributes (def, lang_hooks.types.type_for_mode (mode, 0), 1);
set_mem_align (def, align);
/* If we're dropping a label to the constant pool, make sure we