Turn CONSTANT_ALIGNMENT into a hook

The definition:

  #define CONSTANT_ALIGNMENT(EXP, ALIGN) \
    (TREE_CODE (EXP) == STRING_CST \
     && (ALIGN) < BITS_PER_WORD ? BITS_PER_WORD : (ALIGN))

was very common, so the patch adds a canned definition for that,
called constant_alignment_word_strings.  Some ports had a variation
that used a port-local FASTEST_ALIGNMENT instead of BITS_PER_WORD;
the patch uses constant_alignment_word_strings if FASTEST_ALIGNMENT
was always BITS_PER_WORD and a port-local hook function otherwise.

2017-09-25  Richard Sandiford  <richard.sandiford@linaro.org>

gcc/
	* target.def (constant_alignment): New hook.
	* defaults.h (CONSTANT_ALIGNMENT): Delete.
	* doc/tm.texi.in (CONSTANT_ALIGNMENT): Replace with...
	(TARGET_CONSTANT_ALIGNMENT): ...this new hook.
	* doc/tm.texi: Regenerate.
	* targhooks.h (default_constant_alignment): Declare.
	(constant_alignment_word_strings): Likewise.
	* targhooks.c (default_constant_alignment): New function.
	(constant_alignment_word_strings): Likewise.
	* builtins.c (get_object_alignment_2): Use targetm.constant_alignment
	instead of CONSTANT_ALIGNMENT.
	* varasm.c (align_variable, get_variable_align, build_constant_desc)
	(force_const_mem): Likewise.
	* config/aarch64/aarch64.h (CONSTANT_ALIGNMENT): Delete.
	* config/aarch64/aarch64.c (aarch64_constant_alignment): New function.
	(aarch64_classify_address): Call it instead of CONSTANT_ALIGNMENT.
	(TARGET_CONSTANT_ALIGNMENT): Redefine.
	* config/alpha/alpha.h (CONSTANT_ALIGNMENT): Delete commented-out
	definition.
	* config/arc/arc.h (CONSTANT_ALIGNMENT): Delete.
	* config/arc/arc.c (TARGET_CONSTANT_ALIGNMENT): Redefine to
	constant_alignment_word_strings.
	* config/arm/arm.h (CONSTANT_ALIGNMENT_FACTOR): Delete.
	(CONSTANT_ALIGNMENT): Likewise.
	* config/arm/arm.c (TARGET_CONSTANT_ALIGNMENT): Redefine.
	(arm_constant_alignment): New function.
	* config/bfin/bfin.h (CONSTANT_ALIGNMENT): Delete.
	* config/bfin/bfin.c (TARGET_CONSTANT_ALIGNMENT): Redefine to
	constant_alignment_word_strings.
	* config/cr16/cr16.h (CONSTANT_ALIGNMENT): Delete.
	* config/cr16/cr16.c (TARGET_CONSTANT_ALIGNMENT): Redefine to
	constant_alignment_word_strings.
	* config/cris/cris.h (CONSTANT_ALIGNMENT): Delete.
	* config/cris/cris.c (TARGET_CONSTANT_ALIGNMENT): Redefine.
	(cris_constant_alignment): New function.
	* config/epiphany/epiphany.h (CONSTANT_ALIGNMENT): Delete.
	* config/epiphany/epiphany.c (TARGET_CONSTANT_ALIGNMENT): Redefine.
	(epiphany_constant_alignment): New function.
	* config/fr30/fr30.h (CONSTANT_ALIGNMENT): Delete.
	* config/fr30/fr30.c (TARGET_CONSTANT_ALIGNMENT): Redefine to
	constant_alignment_word_strings.
	* config/frv/frv.h (CONSTANT_ALIGNMENT): Delete.
	* config/frv/frv.c (TARGET_CONSTANT_ALIGNMENT): Redefine to
	constant_alignment_word_strings.
	* config/ft32/ft32.h (CONSTANT_ALIGNMENT): Delete.
	* config/ft32/ft32.c (TARGET_CONSTANT_ALIGNMENT): Redefine to
	constant_alignment_word_strings.
	* config/i386/i386.h (CONSTANT_ALIGNMENT): Delete.
	* config/i386/i386-protos.h (ix86_constant_alignment): Delete.
	* config/i386/i386.c (ix86_constant_alignment): Make static.
	Use the same interface as the target hook.
	(TARGET_CONSTANT_ALIGNMENT): Redefine.
	* config/ia64/ia64.h (CONSTANT_ALIGNMENT): Delete.
	* config/ia64/ia64.c (TARGET_CONSTANT_ALIGNMENT): Redefine to
	constant_alignment_word_strings.
	* config/iq2000/iq2000.h (CONSTANT_ALIGNMENT): Delete.
	* config/iq2000/iq2000.c (iq2000_constant_alignment): New function.
	(TARGET_CONSTANT_ALIGNMENT): Redefine.
	* config/lm32/lm32.h (CONSTANT_ALIGNMENT): Delete.
	* config/lm32/lm32.c (TARGET_CONSTANT_ALIGNMENT): Redefine to
	constant_alignment_word_strings.
	* config/m32r/m32r.h (CONSTANT_ALIGNMENT): Delete.
	* config/m32r/m32r.c (TARGET_CONSTANT_ALIGNMENT): Redefine to
	constant_alignment_word_strings.
	* config/mcore/mcore.h (CONSTANT_ALIGNMENT): Delete.
	* config/mcore/mcore.c (TARGET_CONSTANT_ALIGNMENT): Redefine to
	constant_alignment_word_strings.
	* config/microblaze/microblaze.h (CONSTANT_ALIGNMENT): Delete.
	* config/microblaze/microblaze.c (microblaze_constant_alignment):
	New function.
	(TARGET_CONSTANT_ALIGNMENT): Redefine.
	* config/mips/mips.h (CONSTANT_ALIGNMENT): Delete.
	* config/mips/mips.c (mips_constant_alignment): New function.
	(TARGET_CONSTANT_ALIGNMENT): Redefine.
	* config/mmix/mmix.h (CONSTANT_ALIGNMENT): Delete.
	* config/mmix/mmix-protos.h (mmix_constant_alignment): Delete.
	* config/mmix/mmix.c (TARGET_CONSTANT_ALIGNMENT): Redefine.
	(mmix_constant_alignment): Make static.  Use the same interface
	as the target hook.
	* config/moxie/moxie.h (CONSTANT_ALIGNMENT): Delete.
	* config/moxie/moxie.c (TARGET_CONSTANT_ALIGNMENT): Redefine to
	constant_alignment_word_strings.
	* config/nios2/nios2.h (CONSTANT_ALIGNMENT): Delete.
	* config/nios2/nios2.c (TARGET_CONSTANT_ALIGNMENT): Redefine to
	constant_alignment_word_strings.
	* config/pa/pa.h (CONSTANT_ALIGNMENT): Delete.
	* config/pa/pa.c (TARGET_CONSTANT_ALIGNMENT): Redefine to
	constant_alignment_word_strings.
	* config/powerpcspe/powerpcspe.h (CONSTANT_ALIGNMENT): Delete.
	* config/powerpcspe/powerpcspe.c (TARGET_CONSTANT_ALIGNMENT): Redefine.
	(rs6000_constant_alignment): New function.
	* config/riscv/riscv.h (CONSTANT_ALIGNMENT): Delete.
	* config/riscv/riscv.c (riscv_constant_alignment): New function.
	(TARGET_CONSTANT_ALIGNMENT): Redefine.
	* config/rs6000/rs6000.h (CONSTANT_ALIGNMENT): Delete.
	* config/rs6000/rs6000.c (TARGET_CONSTANT_ALIGNMENT): Redefine.
	(rs6000_constant_alignment): New function.
	* config/s390/s390.h (CONSTANT_ALIGNMENT): Delete.
	* config/s390/s390.c (s390_constant_alignment): New function.
	(TARGET_CONSTANT_ALIGNMENT): Redefine.
	* config/sh/sh.h (CONSTANT_ALIGNMENT): Delete.
	* config/sh/sh.c (TARGET_CONSTANT_ALIGNMENT): Redefine to
	constant_alignment_word_strings.
	* config/sparc/sparc.h (CONSTANT_ALIGNMENT): Delete.
	* config/sparc/sparc.c (TARGET_CONSTANT_ALIGNMENT): Redefine.
	(sparc_constant_alignment): New function.
	* config/spu/spu.h (CONSTANT_ALIGNMENT): Delete.
	* config/spu/spu.c (spu_constant_alignment): New function.
	(TARGET_CONSTANT_ALIGNMENT): Redefine.
	* config/stormy16/stormy16.h (CONSTANT_ALIGNMENT): Delete.
	* config/stormy16/stormy16.c (TARGET_CONSTANT_ALIGNMENT): Redefine to
	constant_alignment_word_strings.
	* config/tilegx/tilegx.h (CONSTANT_ALIGNMENT): Delete.
	* config/tilegx/tilegx.c (TARGET_CONSTANT_ALIGNMENT): Redefine to
	constant_alignment_word_strings.
	* config/tilepro/tilepro.h (CONSTANT_ALIGNMENT): Delete.
	* config/tilepro/tilepro.c (TARGET_CONSTANT_ALIGNMENT): Redefine to
	constant_alignment_word_strings.
	* config/visium/visium.h (CONSTANT_ALIGNMENT): Delete.
	* config/visium/visium.c (TARGET_CONSTANT_ALIGNMENT): Redefine.
	(visium_constant_alignment): New function.
	* config/xtensa/xtensa.h (CONSTANT_ALIGNMENT): Delete.
	* config/xtensa/xtensa.c (TARGET_CONSTANT_ALIGNMENT): Redefine.
	(xtensa_constant_alignment): New function.
	* system.h (CONSTANT_ALIGNMENT): Poison.

From-SVN: r253154
This commit is contained in:
Richard Sandiford 2017-09-25 16:04:27 +00:00 committed by Richard Sandiford
parent 75c44d2246
commit 58e17cf846
81 changed files with 470 additions and 298 deletions

View File

@ -1,3 +1,131 @@
2017-09-25 Richard Sandiford <richard.sandiford@linaro.org>
* target.def (constant_alignment): New hook.
* defaults.h (CONSTANT_ALIGNMENT): Delete.
* doc/tm.texi.in (CONSTANT_ALIGNMENT): Replace with...
(TARGET_CONSTANT_ALIGNMENT): ...this new hook.
* doc/tm.texi: Regenerate.
* targhooks.h (default_constant_alignment): Declare.
(constant_alignment_word_strings): Likewise.
* targhooks.c (default_constant_alignment): New function.
(constant_alignment_word_strings): Likewise.
* builtins.c (get_object_alignment_2): Use targetm.constant_alignment
instead of CONSTANT_ALIGNMENT.
* varasm.c (align_variable, get_variable_align, build_constant_desc)
(force_const_mem): Likewise.
* config/aarch64/aarch64.h (CONSTANT_ALIGNMENT): Delete.
* config/aarch64/aarch64.c (aarch64_constant_alignment): New function.
(aarch64_classify_address): Call it instead of CONSTANT_ALIGNMENT.
(TARGET_CONSTANT_ALIGNMENT): Redefine.
* config/alpha/alpha.h (CONSTANT_ALIGNMENT): Delete commented-out
definition.
* config/arc/arc.h (CONSTANT_ALIGNMENT): Delete.
* config/arc/arc.c (TARGET_CONSTANT_ALIGNMENT): Redefine to
constant_alignment_word_strings.
* config/arm/arm.h (CONSTANT_ALIGNMENT_FACTOR): Delete.
(CONSTANT_ALIGNMENT): Likewise.
* config/arm/arm.c (TARGET_CONSTANT_ALIGNMENT): Redefine.
(arm_constant_alignment): New function.
* config/bfin/bfin.h (CONSTANT_ALIGNMENT): Delete.
* config/bfin/bfin.c (TARGET_CONSTANT_ALIGNMENT): Redefine to
constant_alignment_word_strings.
* config/cr16/cr16.h (CONSTANT_ALIGNMENT): Delete.
* config/cr16/cr16.c (TARGET_CONSTANT_ALIGNMENT): Redefine to
constant_alignment_word_strings.
* config/cris/cris.h (CONSTANT_ALIGNMENT): Delete.
* config/cris/cris.c (TARGET_CONSTANT_ALIGNMENT): Redefine.
(cris_constant_alignment): New function.
* config/epiphany/epiphany.h (CONSTANT_ALIGNMENT): Delete.
* config/epiphany/epiphany.c (TARGET_CONSTANT_ALIGNMENT): Redefine.
(epiphany_constant_alignment): New function.
* config/fr30/fr30.h (CONSTANT_ALIGNMENT): Delete.
* config/fr30/fr30.c (TARGET_CONSTANT_ALIGNMENT): Redefine to
constant_alignment_word_strings.
* config/frv/frv.h (CONSTANT_ALIGNMENT): Delete.
* config/frv/frv.c (TARGET_CONSTANT_ALIGNMENT): Redefine to
constant_alignment_word_strings.
* config/ft32/ft32.h (CONSTANT_ALIGNMENT): Delete.
* config/ft32/ft32.c (TARGET_CONSTANT_ALIGNMENT): Redefine to
constant_alignment_word_strings.
* config/i386/i386.h (CONSTANT_ALIGNMENT): Delete.
* config/i386/i386-protos.h (ix86_constant_alignment): Delete.
* config/i386/i386.c (ix86_constant_alignment): Make static.
Use the same interface as the target hook.
(TARGET_CONSTANT_ALIGNMENT): Redefine.
* config/ia64/ia64.h (CONSTANT_ALIGNMENT): Delete.
* config/ia64/ia64.c (TARGET_CONSTANT_ALIGNMENT): Redefine to
constant_alignment_word_strings.
* config/iq2000/iq2000.h (CONSTANT_ALIGNMENT): Delete.
* config/iq2000/iq2000.c (iq2000_constant_alignment): New function.
(TARGET_CONSTANT_ALIGNMENT): Redefine.
* config/lm32/lm32.h (CONSTANT_ALIGNMENT): Delete.
* config/lm32/lm32.c (TARGET_CONSTANT_ALIGNMENT): Redefine to
constant_alignment_word_strings.
* config/m32r/m32r.h (CONSTANT_ALIGNMENT): Delete.
* config/m32r/m32r.c (TARGET_CONSTANT_ALIGNMENT): Redefine to
constant_alignment_word_strings.
* config/mcore/mcore.h (CONSTANT_ALIGNMENT): Delete.
* config/mcore/mcore.c (TARGET_CONSTANT_ALIGNMENT): Redefine to
constant_alignment_word_strings.
* config/microblaze/microblaze.h (CONSTANT_ALIGNMENT): Delete.
* config/microblaze/microblaze.c (microblaze_constant_alignment):
New function.
(TARGET_CONSTANT_ALIGNMENT): Redefine.
* config/mips/mips.h (CONSTANT_ALIGNMENT): Delete.
* config/mips/mips.c (mips_constant_alignment): New function.
(TARGET_CONSTANT_ALIGNMENT): Redefine.
* config/mmix/mmix.h (CONSTANT_ALIGNMENT): Delete.
* config/mmix/mmix-protos.h (mmix_constant_alignment): Delete.
* config/mmix/mmix.c (TARGET_CONSTANT_ALIGNMENT): Redefine.
(mmix_constant_alignment): Make static. Use the same interface
as the target hook.
* config/moxie/moxie.h (CONSTANT_ALIGNMENT): Delete.
* config/moxie/moxie.c (TARGET_CONSTANT_ALIGNMENT): Redefine to
constant_alignment_word_strings.
* config/nios2/nios2.h (CONSTANT_ALIGNMENT): Delete.
* config/nios2/nios2.c (TARGET_CONSTANT_ALIGNMENT): Redefine to
constant_alignment_word_strings.
* config/pa/pa.h (CONSTANT_ALIGNMENT): Delete.
* config/pa/pa.c (TARGET_CONSTANT_ALIGNMENT): Redefine to
constant_alignment_word_strings.
* config/powerpcspe/powerpcspe.h (CONSTANT_ALIGNMENT): Delete.
* config/powerpcspe/powerpcspe.c (TARGET_CONSTANT_ALIGNMENT): Redefine.
(rs6000_constant_alignment): New function.
* config/riscv/riscv.h (CONSTANT_ALIGNMENT): Delete.
* config/riscv/riscv.c (riscv_constant_alignment): New function.
(TARGET_CONSTANT_ALIGNMENT): Redefine.
* config/rs6000/rs6000.h (CONSTANT_ALIGNMENT): Delete.
* config/rs6000/rs6000.c (TARGET_CONSTANT_ALIGNMENT): Redefine.
(rs6000_constant_alignment): New function.
* config/s390/s390.h (CONSTANT_ALIGNMENT): Delete.
* config/s390/s390.c (s390_constant_alignment): New function.
(TARGET_CONSTANT_ALIGNMENT): Redefine.
* config/sh/sh.h (CONSTANT_ALIGNMENT): Delete.
* config/sh/sh.c (TARGET_CONSTANT_ALIGNMENT): Redefine to
constant_alignment_word_strings.
* config/sparc/sparc.h (CONSTANT_ALIGNMENT): Delete.
* config/sparc/sparc.c (TARGET_CONSTANT_ALIGNMENT): Redefine.
(sparc_constant_alignment): New function.
* config/spu/spu.h (CONSTANT_ALIGNMENT): Delete.
* config/spu/spu.c (spu_constant_alignment): New function.
(TARGET_CONSTANT_ALIGNMENT): Redefine.
* config/stormy16/stormy16.h (CONSTANT_ALIGNMENT): Delete.
* config/stormy16/stormy16.c (TARGET_CONSTANT_ALIGNMENT): Redefine to
constant_alignment_word_strings.
* config/tilegx/tilegx.h (CONSTANT_ALIGNMENT): Delete.
* config/tilegx/tilegx.c (TARGET_CONSTANT_ALIGNMENT): Redefine to
constant_alignment_word_strings.
* config/tilepro/tilepro.h (CONSTANT_ALIGNMENT): Delete.
* config/tilepro/tilepro.c (TARGET_CONSTANT_ALIGNMENT): Redefine to
constant_alignment_word_strings.
* config/visium/visium.h (CONSTANT_ALIGNMENT): Delete.
* config/visium/visium.c (TARGET_CONSTANT_ALIGNMENT): Redefine.
(visium_constant_alignment): New function.
* config/xtensa/xtensa.h (CONSTANT_ALIGNMENT): Delete.
* config/xtensa/xtensa.c (TARGET_CONSTANT_ALIGNMENT): Redefine.
(xtensa_constant_alignment): New function.
* system.h (CONSTANT_ALIGNMENT): Poison.
2017-09-25 Will Schmidt <will_schmidt@vnet.ibm.com>
* config/rs6000/rs6000.c (rs6000_gimple_fold_builtin): Add handling

View File

@ -283,7 +283,7 @@ get_object_alignment_2 (tree exp, unsigned int *alignp,
exp = DECL_INITIAL (exp);
align = TYPE_ALIGN (TREE_TYPE (exp));
if (CONSTANT_CLASS_P (exp))
align = (unsigned) CONSTANT_ALIGNMENT (exp, align);
align = targetm.constant_alignment (exp, align);
known_alignment = true;
}
@ -359,7 +359,7 @@ get_object_alignment_2 (tree exp, unsigned int *alignp,
wrapped inside a CONST_DECL. */
align = TYPE_ALIGN (TREE_TYPE (exp));
if (CONSTANT_CLASS_P (exp))
align = (unsigned) CONSTANT_ALIGNMENT (exp, align);
align = targetm.constant_alignment (exp, align);
known_alignment = true;
}

View File

@ -1142,6 +1142,17 @@ aarch64_hard_regno_caller_save_mode (unsigned regno, unsigned nregs,
return choose_hard_reg_mode (regno, nregs, false);
}
/* Implement TARGET_CONSTANT_ALIGNMENT. Make strings word-aligned so
that strcpy from constants will be faster. */
static HOST_WIDE_INT
aarch64_constant_alignment (const_tree exp, HOST_WIDE_INT align)
{
if (TREE_CODE (exp) == STRING_CST && !optimize_size)
return MAX (align, BITS_PER_WORD);
return align;
}
/* Return true if calls to DECL should be treated as
long-calls (ie called via a register). */
static bool
@ -4622,7 +4633,7 @@ aarch64_classify_address (struct aarch64_address_info *info,
{
tree exp = SYMBOL_REF_DECL (sym);
align = TYPE_ALIGN (TREE_TYPE (exp));
align = CONSTANT_ALIGNMENT (exp, align);
align = aarch64_constant_alignment (exp, align);
}
else if (SYMBOL_REF_DECL (sym))
align = DECL_ALIGN (SYMBOL_REF_DECL (sym));
@ -15687,6 +15698,9 @@ aarch64_libgcc_floating_mode_supported_p
#define TARGET_HARD_REGNO_CALL_PART_CLOBBERED \
aarch64_hard_regno_call_part_clobbered
#undef TARGET_CONSTANT_ALIGNMENT
#define TARGET_CONSTANT_ALIGNMENT aarch64_constant_alignment
#if CHECKING_P
#undef TARGET_RUN_TARGET_SELFTESTS
#define TARGET_RUN_TARGET_SELFTESTS selftest::aarch64_run_selftests

View File

@ -90,14 +90,6 @@
port. */
#define TARGET_PTRMEMFUNC_VBIT_LOCATION ptrmemfunc_vbit_in_delta
/* Make strings word-aligned so that strcpy from constants will be
faster. */
#define CONSTANT_ALIGNMENT(EXP, ALIGN) \
((TREE_CODE (EXP) == STRING_CST \
&& !optimize_size \
&& (ALIGN) < BITS_PER_WORD) \
? BITS_PER_WORD : ALIGN)
/* Align definitions of arrays, unions and structures so that
initializations and copies can be made more efficient. This is not
ABI-changing, so it only affects places where we can see the

View File

@ -289,7 +289,6 @@ extern enum alpha_fp_trap_mode alpha_fptm;
/* ??? Only if block-move stuff knows about different source/destination
alignment. */
#if 0
#define CONSTANT_ALIGNMENT(EXP, ALIGN) MAX ((ALIGN), BITS_PER_WORD)
#define DATA_ALIGNMENT(EXP, ALIGN) MAX ((ALIGN), BITS_PER_WORD)
#endif

View File

@ -10657,6 +10657,9 @@ arc_use_anchors_for_symbol_p (const_rtx symbol)
#undef TARGET_USE_ANCHORS_FOR_SYMBOL_P
#define TARGET_USE_ANCHORS_FOR_SYMBOL_P arc_use_anchors_for_symbol_p
#undef TARGET_CONSTANT_ALIGNMENT
#define TARGET_CONSTANT_ALIGNMENT constant_alignment_word_strings
struct gcc_target targetm = TARGET_INITIALIZER;
#include "gt-arc.h"

View File

@ -271,13 +271,6 @@ if (GET_MODE_CLASS (MODE) == MODE_INT \
/* The best alignment to use in cases where we have a choice. */
#define FASTEST_ALIGNMENT 32
/* Make strings word-aligned so strcpy from constants will be faster. */
#define CONSTANT_ALIGNMENT(EXP, ALIGN) \
((TREE_CODE (EXP) == STRING_CST \
&& (ALIGN) < FASTEST_ALIGNMENT) \
? FASTEST_ALIGNMENT : (ALIGN))
/* Make arrays of chars word-aligned for the same reasons. */
#define LOCAL_ALIGNMENT(TYPE, ALIGN) \
(TREE_CODE (TYPE) == ARRAY_TYPE \

View File

@ -316,6 +316,7 @@ static opt_scalar_float_mode arm_floatn_mode (int, bool);
static unsigned int arm_hard_regno_nregs (unsigned int, machine_mode);
static bool arm_hard_regno_mode_ok (unsigned int, machine_mode);
static bool arm_modes_tieable_p (machine_mode, machine_mode);
static HOST_WIDE_INT arm_constant_alignment (const_tree, HOST_WIDE_INT);
/* Table of machine attributes. */
static const struct attribute_spec arm_attribute_table[] =
@ -795,6 +796,9 @@ static const struct attribute_spec arm_attribute_table[] =
#undef TARGET_CAN_CHANGE_MODE_CLASS
#define TARGET_CAN_CHANGE_MODE_CLASS arm_can_change_mode_class
#undef TARGET_CONSTANT_ALIGNMENT
#define TARGET_CONSTANT_ALIGNMENT arm_constant_alignment
/* Obstack for minipool constant handling. */
static struct obstack minipool_obstack;
@ -31276,6 +31280,18 @@ arm_can_change_mode_class (machine_mode from, machine_mode to,
return true;
}
/* Implement TARGET_CONSTANT_ALIGNMENT. Make strings word-aligned so
strcpy from constants will be faster. */
static HOST_WIDE_INT
arm_constant_alignment (const_tree exp, HOST_WIDE_INT align)
{
unsigned int factor = (TARGET_THUMB || ! arm_tune_xscale ? 1 : 2);
if (TREE_CODE (exp) == STRING_CST && !optimize_size)
return MAX (align, BITS_PER_WORD * factor);
return align;
}
#if CHECKING_P
namespace selftest {

View File

@ -592,15 +592,6 @@ extern int arm_arch_cmse;
#define BIGGEST_FIELD_ALIGNMENT 64
#endif
/* Make strings word-aligned so strcpy from constants will be faster. */
#define CONSTANT_ALIGNMENT_FACTOR (TARGET_THUMB || ! arm_tune_xscale ? 1 : 2)
#define CONSTANT_ALIGNMENT(EXP, ALIGN) \
((TREE_CODE (EXP) == STRING_CST \
&& !optimize_size \
&& (ALIGN) < BITS_PER_WORD * CONSTANT_ALIGNMENT_FACTOR) \
? BITS_PER_WORD * CONSTANT_ALIGNMENT_FACTOR : (ALIGN))
/* Align definitions of arrays, unions and structures so that
initializations and copies can be made more efficient. This is not
ABI-changing, so it only affects places where we can see the

View File

@ -5882,4 +5882,7 @@ bfin_conditional_register_usage (void)
#undef TARGET_MODES_TIEABLE_P
#define TARGET_MODES_TIEABLE_P bfin_modes_tieable_p
#undef TARGET_CONSTANT_ALIGNMENT
#define TARGET_CONSTANT_ALIGNMENT constant_alignment_word_strings
struct gcc_target targetm = TARGET_INITIALIZER;

View File

@ -321,11 +321,6 @@ extern const char *bfin_library_id_string;
#define LOCAL_ALIGNMENT(TYPE, ALIGN) bfin_local_alignment ((TYPE), (ALIGN))
/* Make strings word-aligned so strcpy from constants will be faster. */
#define CONSTANT_ALIGNMENT(EXP, ALIGN) \
(TREE_CODE (EXP) == STRING_CST \
&& (ALIGN) < BITS_PER_WORD ? BITS_PER_WORD : (ALIGN))
#define TRAMPOLINE_SIZE (TARGET_FDPIC ? 30 : 18)
/* Definitions for register eliminations.

View File

@ -200,6 +200,9 @@ static void cr16_print_operand_address (FILE *, machine_mode, rtx);
#undef TARGET_MEMORY_MOVE_COST
#define TARGET_MEMORY_MOVE_COST cr16_memory_move_cost
#undef TARGET_CONSTANT_ALIGNMENT
#define TARGET_CONSTANT_ALIGNMENT constant_alignment_word_strings
/* Table of machine attributes. */
static const struct attribute_spec cr16_attribute_table[] = {
/* ISRs have special prologue and epilogue requirements. */

View File

@ -114,11 +114,6 @@ while (0)
&& ((ALIGN) < BITS_PER_WORD)) \
? (BITS_PER_WORD) : (ALIGN))
/* In CR16 strings are word-aligned; strcpy from constants will be faster. */
#define CONSTANT_ALIGNMENT(CONSTANT, ALIGN) \
(((TREE_CODE (CONSTANT) == STRING_CST) && ((ALIGN) < BITS_PER_WORD)) \
? (BITS_PER_WORD) : (ALIGN))
#define STRICT_ALIGNMENT 0
#define PCC_BITFIELD_TYPE_MATTERS 1

View File

@ -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_constant_alignment (const_tree, HOST_WIDE_INT);
/* This is the parsed result of the "-max-stack-stackframe=" option. If
it (still) is zero, then there was no such option given. */
@ -287,6 +288,9 @@ 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_CONSTANT_ALIGNMENT
#define TARGET_CONSTANT_ALIGNMENT cris_constant_alignment
struct gcc_target targetm = TARGET_INITIALIZER;
/* Helper for cris_load_multiple_op and cris_ret_movem_op. */
@ -4325,6 +4329,23 @@ cris_hard_regno_mode_ok (unsigned int regno, machine_mode mode)
|| (regno != CRIS_MOF_REGNUM && regno != CRIS_ACR_REGNUM)));
}
/* 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
rushed assumption. Luckily we do not care about the "alignment"
operand to builtin memcpy (only place where it counts), so it doesn't
affect any bad spots. */
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);
}
#if 0
/* Various small functions to replace macros. Only called from a
debugger. They might collide with gcc functions or system functions,

View File

@ -368,17 +368,6 @@ extern int cris_cpu_version;
? (BASIC_ALIGN < 32 ? 32 : BASIC_ALIGN) \
: (BASIC_ALIGN < 16 ? 16 : BASIC_ALIGN)) : BASIC_ALIGN)
/* Note that CONSTANT_ALIGNMENT has the effect of making gcc believe that
ALL references to constant stuff (in code segment, like strings) has
this alignment. That is a rather rushed assumption. Luckily we do not
care about the "alignment" operand to builtin memcpy (only place where
it counts), so it doesn't affect any bad spots. */
#define CONSTANT_ALIGNMENT(CONSTANT, BASIC_ALIGN) \
(TARGET_CONST_ALIGN \
? (TARGET_ALIGN_BY_32 \
? (BASIC_ALIGN < 32 ? 32 : BASIC_ALIGN) \
: (BASIC_ALIGN < 16 ? 16 : BASIC_ALIGN)) : BASIC_ALIGN)
/* FIXME: Define LOCAL_ALIGNMENT for word and dword or arrays and
structures (if -mstack-align=), and check that it is good. */

View File

@ -173,6 +173,9 @@ static rtx_insn *frame_insn (rtx);
#undef TARGET_HARD_REGNO_MODE_OK
#define TARGET_HARD_REGNO_MODE_OK epiphany_hard_regno_mode_ok
#undef TARGET_CONSTANT_ALIGNMENT
#define TARGET_CONSTANT_ALIGNMENT epiphany_constant_alignment
bool
epiphany_is_interrupt_p (tree decl)
@ -3014,4 +3017,15 @@ epiphany_start_function (FILE *file, const char *name, tree decl)
ASM_OUTPUT_FUNCTION_LABEL (file, name, decl);
}
/* Implement TARGET_CONSTANT_ALIGNMENT. */
static HOST_WIDE_INT
epiphany_constant_alignment (const_tree exp, HOST_WIDE_INT align)
{
if (TREE_CODE (exp) == STRING_CST)
return MAX (align, FASTEST_ALIGNMENT);
return align;
}
struct gcc_target targetm = TARGET_INITIALIZER;

View File

@ -147,12 +147,6 @@ along with GCC; see the file COPYING3. If not see
#define MALLOC_ABI_ALIGNMENT BIGGEST_ALIGNMENT
/* Make strings dword-aligned so strcpy from constants will be faster. */
#define CONSTANT_ALIGNMENT(EXP, ALIGN) \
((TREE_CODE (EXP) == STRING_CST \
&& (ALIGN) < FASTEST_ALIGNMENT) \
? FASTEST_ALIGNMENT : (ALIGN))
/* Make arrays of chars dword-aligned for the same reasons.
Also, align arrays of SImode items. */
#define DATA_ALIGNMENT(TYPE, ALIGN) \

View File

@ -190,6 +190,9 @@ static int fr30_num_arg_regs (machine_mode, const_tree);
#undef TARGET_TRAMPOLINE_INIT
#define TARGET_TRAMPOLINE_INIT fr30_trampoline_init
#undef TARGET_CONSTANT_ALIGNMENT
#define TARGET_CONSTANT_ALIGNMENT constant_alignment_word_strings
struct gcc_target targetm = TARGET_INITIALIZER;

View File

@ -88,10 +88,6 @@ along with GCC; see the file COPYING3. If not see
&& TYPE_MODE (TREE_TYPE (TYPE)) == QImode \
&& (ALIGN) < BITS_PER_WORD ? BITS_PER_WORD : (ALIGN))
#define CONSTANT_ALIGNMENT(EXP, ALIGN) \
(TREE_CODE (EXP) == STRING_CST \
&& (ALIGN) < BITS_PER_WORD ? BITS_PER_WORD : (ALIGN))
#define STRICT_ALIGNMENT 1
#define PCC_BITFIELD_TYPE_MATTERS 1

View File

@ -523,6 +523,8 @@ static bool frv_modes_tieable_p (machine_mode, machine_mode);
#define TARGET_HARD_REGNO_MODE_OK frv_hard_regno_mode_ok
#undef TARGET_MODES_TIEABLE_P
#define TARGET_MODES_TIEABLE_P frv_modes_tieable_p
#undef TARGET_CONSTANT_ALIGNMENT
#define TARGET_CONSTANT_ALIGNMENT constant_alignment_word_strings
struct gcc_target targetm = TARGET_INITIALIZER;

View File

@ -351,20 +351,6 @@
&& TYPE_MODE (TREE_TYPE (TYPE)) == QImode \
&& (ALIGN) < BITS_PER_WORD ? BITS_PER_WORD : (ALIGN))
/* If defined, a C expression to compute the alignment given to a constant that
is being placed in memory. CONSTANT is the constant and ALIGN is the
alignment that the object would ordinarily have. The value of this macro is
used instead of that alignment to align the object.
If this macro is not defined, then ALIGN is used.
The typical use of this macro is to increase alignment for string constants
to be word aligned so that `strcpy' calls that copy constants can be done
inline. */
#define CONSTANT_ALIGNMENT(EXP, ALIGN) \
(TREE_CODE (EXP) == STRING_CST \
&& (ALIGN) < BITS_PER_WORD ? BITS_PER_WORD : (ALIGN))
/* Define this macro to be the value 1 if instructions will fail to work if
given data not on the nominal alignment. If instructions will merely go
slower in that case, define this macro as 0. */

View File

@ -940,6 +940,9 @@ ft32_elf_encode_section_info (tree decl, rtx rtl, int first)
}
}
#undef TARGET_CONSTANT_ALIGNMENT
#define TARGET_CONSTANT_ALIGNMENT constant_alignment_word_strings
struct gcc_target targetm = TARGET_INITIALIZER;
#include "gt-ft32.h"

View File

@ -354,12 +354,6 @@ enum reg_class
is GET_MODE_SIZE(DImode). */
#define MAX_FIXED_MODE_SIZE 32
/* Make strings word-aligned so strcpy from constants will be faster. */
#define CONSTANT_ALIGNMENT(EXP, ALIGN) \
((TREE_CODE (EXP) == STRING_CST \
&& (ALIGN) < FASTEST_ALIGNMENT) \
? FASTEST_ALIGNMENT : (ALIGN))
/* Set this nonzero if move instructions will actually fail to work
when given unaligned data. */
#define STRICT_ALIGNMENT 1

View File

@ -209,7 +209,6 @@ extern unsigned int ix86_local_alignment (tree, machine_mode,
unsigned int);
extern unsigned int ix86_minimum_alignment (tree, machine_mode,
unsigned int);
extern int ix86_constant_alignment (tree, int);
extern tree ix86_handle_shared_attribute (tree *, tree, tree, int, bool *);
extern tree ix86_handle_selectany_attribute (tree *, tree, tree, int, bool *);
extern int x86_field_alignment (tree, int);

View File

@ -31563,14 +31563,10 @@ ix86_sched_init_global (FILE *, int, int)
}
/* Compute the alignment given to a constant that is being placed in memory.
EXP is the constant and ALIGN is the alignment that the object would
ordinarily have.
The value of this function is used instead of that alignment to align
the object. */
/* Implement TARGET_CONSTANT_ALIGNMENT. */
int
ix86_constant_alignment (tree exp, int align)
static HOST_WIDE_INT
ix86_constant_alignment (const_tree exp, HOST_WIDE_INT align)
{
if (TREE_CODE (exp) == REAL_CST || TREE_CODE (exp) == VECTOR_CST
|| TREE_CODE (exp) == INTEGER_CST)
@ -53609,6 +53605,9 @@ ix86_run_selftests (void)
#undef TARGET_CAN_CHANGE_MODE_CLASS
#define TARGET_CAN_CHANGE_MODE_CLASS ix86_can_change_mode_class
#undef TARGET_CONSTANT_ALIGNMENT
#define TARGET_CONSTANT_ALIGNMENT ix86_constant_alignment
#if CHECKING_P
#undef TARGET_RUN_TARGET_SELFTESTS
#define TARGET_RUN_TARGET_SELFTESTS selftest::ix86_run_selftests

View File

@ -848,20 +848,6 @@ extern const char *host_detect_local_cpu (int argc, const char **argv);
x86_field_alignment ((TYPE), (COMPUTED))
#endif
/* If defined, a C expression to compute the alignment given to a
constant that is being placed in memory. EXP is the constant
and ALIGN is the alignment that the object would ordinarily have.
The value of this macro is used instead of that alignment to align
the object.
If this macro is not defined, then ALIGN is used.
The typical use of this macro is to increase alignment for string
constants to be word aligned so that `strcpy' calls that copy
constants can be done inline. */
#define CONSTANT_ALIGNMENT(EXP, ALIGN) ix86_constant_alignment ((EXP), (ALIGN))
/* If defined, a C expression to compute the alignment for a static
variable. TYPE is the data type, and ALIGN is the alignment that
the object would ordinarily have. The value of this macro is used

View File

@ -672,6 +672,9 @@ static const struct attribute_spec ia64_attribute_table[] =
#undef TARGET_CAN_CHANGE_MODE_CLASS
#define TARGET_CAN_CHANGE_MODE_CLASS ia64_can_change_mode_class
#undef TARGET_CONSTANT_ALIGNMENT
#define TARGET_CONSTANT_ALIGNMENT constant_alignment_word_strings
struct gcc_target targetm = TARGET_INITIALIZER;
/* Returns TRUE iff the target attribute indicated by ATTR_ID takes a plain

View File

@ -185,15 +185,6 @@ while (0)
&& TYPE_MODE (TREE_TYPE (TYPE)) == QImode \
&& (ALIGN) < BITS_PER_WORD ? BITS_PER_WORD : (ALIGN))
/* If defined, a C expression to compute the alignment given to a constant that
is being placed in memory. CONSTANT is the constant and ALIGN is the
alignment that the object would ordinarily have. The value of this macro is
used instead of that alignment to align the object. */
#define CONSTANT_ALIGNMENT(EXP, ALIGN) \
(TREE_CODE (EXP) == STRING_CST \
&& (ALIGN) < BITS_PER_WORD ? BITS_PER_WORD : (ALIGN))
#define STRICT_ALIGNMENT 1
/* Define this if you wish to imitate the way many other C compilers handle

View File

@ -180,6 +180,7 @@ static void iq2000_print_operand_address (FILE *, machine_mode, rtx);
static bool iq2000_print_operand_punct_valid_p (unsigned char code);
static bool iq2000_hard_regno_mode_ok (unsigned int, machine_mode);
static bool iq2000_modes_tieable_p (machine_mode, machine_mode);
static HOST_WIDE_INT iq2000_constant_alignment (const_tree, HOST_WIDE_INT);
#undef TARGET_INIT_BUILTINS
#define TARGET_INIT_BUILTINS iq2000_init_builtins
@ -264,6 +265,9 @@ static bool iq2000_modes_tieable_p (machine_mode, machine_mode);
#undef TARGET_MODES_TIEABLE_P
#define TARGET_MODES_TIEABLE_P iq2000_modes_tieable_p
#undef TARGET_CONSTANT_ALIGNMENT
#define TARGET_CONSTANT_ALIGNMENT iq2000_constant_alignment
struct gcc_target targetm = TARGET_INITIALIZER;
/* Return nonzero if we split the address into high and low parts. */
@ -3532,4 +3536,14 @@ iq2000_modes_tieable_p (machine_mode mode1, machine_mode mode2)
|| GET_MODE_CLASS (mode2) == MODE_COMPLEX_FLOAT));
}
/* Implement TARGET_CONSTANT_ALIGNMENT. */
static HOST_WIDE_INT
iq2000_constant_alignment (const_tree exp, HOST_WIDE_INT align)
{
if (TREE_CODE (exp) == STRING_CST || TREE_CODE (exp) == CONSTRUCTOR)
return MAX (align, BITS_PER_WORD);
return align;
}
#include "gt-iq2000.h"

View File

@ -96,10 +96,6 @@
|| TREE_CODE (TYPE) == UNION_TYPE \
|| TREE_CODE (TYPE) == RECORD_TYPE)) ? BITS_PER_WORD : (ALIGN))
#define CONSTANT_ALIGNMENT(EXP, ALIGN) \
((TREE_CODE (EXP) == STRING_CST || TREE_CODE (EXP) == CONSTRUCTOR) \
&& (ALIGN) < BITS_PER_WORD ? BITS_PER_WORD : (ALIGN))
#define EMPTY_FIELD_BOUNDARY 32
#define STRUCTURE_SIZE_BOUNDARY 8

View File

@ -113,6 +113,9 @@ static bool lm32_modes_tieable_p (machine_mode, machine_mode);
#undef TARGET_MODES_TIEABLE_P
#define TARGET_MODES_TIEABLE_P lm32_modes_tieable_p
#undef TARGET_CONSTANT_ALIGNMENT
#define TARGET_CONSTANT_ALIGNMENT constant_alignment_word_strings
struct gcc_target targetm = TARGET_INITIALIZER;
/* Current frame information calculated by lm32_compute_frame_size. */

View File

@ -99,11 +99,6 @@ do { \
#define TARGET_FLOAT_FORMAT IEEE_FLOAT_FORMAT
/* Make strings word-aligned so strcpy from constants will be faster. */
#define CONSTANT_ALIGNMENT(EXP, ALIGN) \
(TREE_CODE (EXP) == STRING_CST \
&& (ALIGN) < BITS_PER_WORD ? BITS_PER_WORD : (ALIGN))
/* Make arrays and structures word-aligned to allow faster copying etc. */
#define DATA_ALIGNMENT(TYPE, ALIGN) \
((((ALIGN) < BITS_PER_WORD) \

View File

@ -217,6 +217,9 @@ static const struct attribute_spec m32r_attribute_table[] =
#undef TARGET_MODES_TIEABLE_P
#define TARGET_MODES_TIEABLE_P m32r_modes_tieable_p
#undef TARGET_CONSTANT_ALIGNMENT
#define TARGET_CONSTANT_ALIGNMENT constant_alignment_word_strings
struct gcc_target targetm = TARGET_INITIALIZER;
/* Called by m32r_option_override to initialize various things. */

View File

@ -260,12 +260,6 @@
/* The best alignment to use in cases where we have a choice. */
#define FASTEST_ALIGNMENT 32
/* Make strings word-aligned so strcpy from constants will be faster. */
#define CONSTANT_ALIGNMENT(EXP, ALIGN) \
((TREE_CODE (EXP) == STRING_CST \
&& (ALIGN) < FASTEST_ALIGNMENT) \
? FASTEST_ALIGNMENT : (ALIGN))
/* Make arrays of chars word-aligned for the same reasons. */
#define DATA_ALIGNMENT(TYPE, ALIGN) \
(TREE_CODE (TYPE) == ARRAY_TYPE \

View File

@ -248,6 +248,9 @@ static const struct attribute_spec mcore_attribute_table[] =
#undef TARGET_MODES_TIEABLE_P
#define TARGET_MODES_TIEABLE_P mcore_modes_tieable_p
#undef TARGET_CONSTANT_ALIGNMENT
#define TARGET_CONSTANT_ALIGNMENT constant_alignment_word_strings
struct gcc_target targetm = TARGET_INITIALIZER;
/* Adjust the stack and return the number of bytes taken to do it. */

View File

@ -148,12 +148,6 @@ extern char * mcore_current_function_name;
is GET_MODE_SIZE(DImode). */
#define MAX_FIXED_MODE_SIZE 32
/* Make strings word-aligned so strcpy from constants will be faster. */
#define CONSTANT_ALIGNMENT(EXP, ALIGN) \
((TREE_CODE (EXP) == STRING_CST \
&& (ALIGN) < FASTEST_ALIGNMENT) \
? FASTEST_ALIGNMENT : (ALIGN))
/* Make arrays of chars word-aligned for the same reasons. */
#define DATA_ALIGNMENT(TYPE, ALIGN) \
(TREE_CODE (TYPE) == ARRAY_TYPE \

View File

@ -3800,6 +3800,16 @@ microblaze_machine_dependent_reorg (void)
return;
}
}
/* Implement TARGET_CONSTANT_ALIGNMENT. */
static HOST_WIDE_INT
microblaze_constant_alignment (const_tree exp, HOST_WIDE_INT align)
{
if (TREE_CODE (exp) == STRING_CST || TREE_CODE (exp) == CONSTRUCTOR)
return MAX (align, BITS_PER_WORD);
return align;
}
#undef TARGET_ENCODE_SECTION_INFO
#define TARGET_ENCODE_SECTION_INFO microblaze_encode_section_info
@ -3904,6 +3914,9 @@ microblaze_machine_dependent_reorg (void)
#undef TARGET_MODES_TIEABLE_P
#define TARGET_MODES_TIEABLE_P microblaze_modes_tieable_p
#undef TARGET_CONSTANT_ALIGNMENT
#define TARGET_CONSTANT_ALIGNMENT microblaze_constant_alignment
struct gcc_target targetm = TARGET_INITIALIZER;
#include "gt-microblaze.h"

View File

@ -234,12 +234,6 @@ extern enum pipeline_type microblaze_pipe;
#undef PTRDIFF_TYPE
#define PTRDIFF_TYPE "int"
#define CONSTANT_ALIGNMENT(EXP, ALIGN) \
((TREE_CODE (EXP) == STRING_CST || TREE_CODE (EXP) == CONSTRUCTOR) \
&& (ALIGN) < BITS_PER_WORD \
? BITS_PER_WORD \
: (ALIGN))
#define DATA_ALIGNMENT(TYPE, ALIGN) \
((((ALIGN) < BITS_PER_WORD) \
&& (TREE_CODE (TYPE) == ARRAY_TYPE \

View File

@ -22336,6 +22336,16 @@ mips_truly_noop_truncation (unsigned int outprec, unsigned int inprec)
{
return !TARGET_64BIT || inprec <= 32 || outprec > 32;
}
/* Implement TARGET_CONSTANT_ALIGNMENT. */
static HOST_WIDE_INT
mips_constant_alignment (const_tree exp, HOST_WIDE_INT align)
{
if (TREE_CODE (exp) == STRING_CST || TREE_CODE (exp) == CONSTRUCTOR)
return MAX (align, BITS_PER_WORD);
return align;
}
/* Initialize the GCC target structure. */
#undef TARGET_ASM_ALIGNED_HI_OP
@ -22634,6 +22644,9 @@ mips_truly_noop_truncation (unsigned int outprec, unsigned int inprec)
#undef TARGET_TRULY_NOOP_TRUNCATION
#define TARGET_TRULY_NOOP_TRUNCATION mips_truly_noop_truncation
#undef TARGET_CONSTANT_ALIGNMENT
#define TARGET_CONSTANT_ALIGNMENT mips_constant_alignment
struct gcc_target targetm = TARGET_INITIALIZER;
#include "gt-mips.h"

View File

@ -1636,22 +1636,6 @@ FP_ASM_SPEC "\
#define PCC_BITFIELD_TYPE_MATTERS 1
/* If defined, a C expression to compute the alignment given to a
constant that is being placed in memory. CONSTANT is the constant
and ALIGN is the alignment that the object would ordinarily have.
The value of this macro is used instead of that alignment to align
the object.
If this macro is not defined, then ALIGN is used.
The typical use of this macro is to increase alignment for string
constants to be word aligned so that `strcpy' calls that copy
constants can be done inline. */
#define CONSTANT_ALIGNMENT(EXP, ALIGN) \
((TREE_CODE (EXP) == STRING_CST || TREE_CODE (EXP) == CONSTRUCTOR) \
&& (ALIGN) < BITS_PER_WORD ? BITS_PER_WORD : (ALIGN))
/* If defined, a C expression to compute the alignment for a static
variable. TYPE is the data type, and ALIGN is the alignment that
the object would ordinarily have. The value of this macro is used

View File

@ -47,7 +47,6 @@ extern unsigned mmix_dbx_register_number (unsigned);
extern int mmix_use_simple_return (void);
extern void mmix_make_decl_one_only (tree);
extern int mmix_data_alignment (tree, int);
extern int mmix_constant_alignment (tree, int);
extern unsigned mmix_local_alignment (tree, unsigned);
extern void mmix_asm_output_pool_prologue (FILE *, const char *, tree, int);
extern void mmix_asm_output_aligned_common (FILE *, const char *, int, int);

View File

@ -168,6 +168,7 @@ static void mmix_print_operand (FILE *, rtx, int);
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_constant_alignment (const_tree, HOST_WIDE_INT);
/* Target structure macros. Listed by node. See `Using and Porting GCC'
for a general description. */
@ -282,6 +283,9 @@ static void mmix_conditional_register_usage (void);
#undef TARGET_OPTION_OVERRIDE
#define TARGET_OPTION_OVERRIDE mmix_option_override
#undef TARGET_CONSTANT_ALIGNMENT
#define TARGET_CONSTANT_ALIGNMENT mmix_constant_alignment
struct gcc_target targetm = TARGET_INITIALIZER;
/* Functions that are expansions for target macros.
@ -334,10 +338,10 @@ mmix_data_alignment (tree type ATTRIBUTE_UNUSED, int basic_align)
return basic_align;
}
/* CONSTANT_ALIGNMENT. */
/* Implement tARGET_CONSTANT_ALIGNMENT. */
int
mmix_constant_alignment (tree constant ATTRIBUTE_UNUSED, int basic_align)
static HOST_WIDE_INT
mmix_constant_alignment (const_tree, HOST_WIDE_INT basic_align)
{
if (basic_align < 32)
return 32;

View File

@ -167,9 +167,6 @@ struct GTY(()) machine_function
#define DATA_ABI_ALIGNMENT(TYPE, BASIC_ALIGN) \
mmix_data_alignment (TYPE, BASIC_ALIGN)
#define CONSTANT_ALIGNMENT(CONSTANT, BASIC_ALIGN) \
mmix_constant_alignment (CONSTANT, BASIC_ALIGN)
#define LOCAL_ALIGNMENT(TYPE, BASIC_ALIGN) \
mmix_local_alignment (TYPE, BASIC_ALIGN)

View File

@ -667,6 +667,9 @@ moxie_legitimate_address_p (machine_mode mode ATTRIBUTE_UNUSED,
#undef TARGET_PRINT_OPERAND_ADDRESS
#define TARGET_PRINT_OPERAND_ADDRESS moxie_print_operand_address
#undef TARGET_CONSTANT_ALIGNMENT
#define TARGET_CONSTANT_ALIGNMENT constant_alignment_word_strings
struct gcc_target targetm = TARGET_INITIALIZER;
#include "gt-moxie.h"

View File

@ -317,12 +317,6 @@ enum reg_class
is GET_MODE_SIZE(DImode). */
#define MAX_FIXED_MODE_SIZE 32
/* Make strings word-aligned so strcpy from constants will be faster. */
#define CONSTANT_ALIGNMENT(EXP, ALIGN) \
((TREE_CODE (EXP) == STRING_CST \
&& (ALIGN) < FASTEST_ALIGNMENT) \
? FASTEST_ALIGNMENT : (ALIGN))
/* Make arrays of chars word-aligned for the same reasons. */
#define DATA_ALIGNMENT(TYPE, ALIGN) \
(TREE_CODE (TYPE) == ARRAY_TYPE \

View File

@ -5116,6 +5116,9 @@ nios2_adjust_reg_alloc_order (void)
#undef TARGET_MACHINE_DEPENDENT_REORG
#define TARGET_MACHINE_DEPENDENT_REORG nios2_reorg
#undef TARGET_CONSTANT_ALIGNMENT
#define TARGET_CONSTANT_ALIGNMENT constant_alignment_word_strings
struct gcc_target targetm = TARGET_INITIALIZER;
#include "gt-nios2.h"

View File

@ -92,10 +92,6 @@
#define PREFERRED_STACK_BOUNDARY 32
#define MAX_FIXED_MODE_SIZE 64
#define CONSTANT_ALIGNMENT(EXP, ALIGN) \
((TREE_CODE (EXP) == STRING_CST) \
&& (ALIGN) < BITS_PER_WORD ? BITS_PER_WORD : (ALIGN))
#define LABEL_ALIGN(LABEL) nios2_label_align (LABEL)
/* Layout of source language data types. */

View File

@ -425,6 +425,9 @@ static size_t n_deferred_plabels = 0;
#undef TARGET_CAN_CHANGE_MODE_CLASS
#define TARGET_CAN_CHANGE_MODE_CLASS pa_can_change_mode_class
#undef TARGET_CONSTANT_ALIGNMENT
#define TARGET_CONSTANT_ALIGNMENT constant_alignment_word_strings
struct gcc_target targetm = TARGET_INITIALIZER;
/* Parse the -mfixed-range= option string. */

View File

@ -309,11 +309,6 @@ typedef struct GTY(()) machine_function
atomic operations. */
#define MALLOC_ABI_ALIGNMENT (TARGET_SOM ? 64 : 128)
/* Get around hp-ux assembler bug, and make strcpy of constants fast. */
#define CONSTANT_ALIGNMENT(EXP, ALIGN) \
(TREE_CODE (EXP) == STRING_CST \
&& (ALIGN) < BITS_PER_WORD ? BITS_PER_WORD : (ALIGN))
/* Make arrays of chars word-aligned for the same reasons. */
#define DATA_ALIGNMENT(TYPE, ALIGN) \
(TREE_CODE (TYPE) == ARRAY_TYPE \

View File

@ -1984,6 +1984,9 @@ static const struct attribute_spec rs6000_attribute_table[] =
#undef TARGET_CAN_CHANGE_MODE_CLASS
#define TARGET_CAN_CHANGE_MODE_CLASS rs6000_can_change_mode_class
#undef TARGET_CONSTANT_ALIGNMENT
#define TARGET_CONSTANT_ALIGNMENT rs6000_constant_alignment
/* Processor table. */
@ -43752,6 +43755,17 @@ rs6000_optab_supported_p (int op, machine_mode mode1, machine_mode,
return true;
}
}
/* Implement TARGET_CONSTANT_ALIGNMENT. */
static HOST_WIDE_INT
rs6000_constant_alignment (const_tree exp, HOST_WIDE_INT align)
{
if (TREE_CODE (exp) == STRING_CST
&& (STRICT_ALIGNMENT || !optimize_size))
return MAX (align, BITS_PER_WORD);
return align;
}
struct gcc_target targetm = TARGET_INITIALIZER;

View File

@ -978,14 +978,6 @@ enum data_align { align_abi, align_opt, align_both };
#define LOCAL_ALIGNMENT(TYPE, ALIGN) \
rs6000_data_alignment (TYPE, ALIGN, align_both)
/* Make strings word-aligned so strcpy from constants will be faster. */
#define CONSTANT_ALIGNMENT(EXP, ALIGN) \
(TREE_CODE (EXP) == STRING_CST \
&& (STRICT_ALIGNMENT || !optimize_size) \
&& (ALIGN) < BITS_PER_WORD \
? BITS_PER_WORD \
: (ALIGN))
/* Make arrays of chars word-aligned for the same reasons. */
#define DATA_ALIGNMENT(TYPE, ALIGN) \
rs6000_data_alignment (TYPE, ALIGN, align_opt)

View File

@ -3995,6 +3995,17 @@ riscv_can_change_mode_class (machine_mode, machine_mode, reg_class_t rclass)
return !reg_classes_intersect_p (FP_REGS, rclass);
}
/* Implement TARGET_CONSTANT_ALIGNMENT. */
static HOST_WIDE_INT
riscv_constant_alignment (const_tree exp, HOST_WIDE_INT align)
{
if (TREE_CODE (exp) == STRING_CST || TREE_CODE (exp) == CONSTRUCTOR)
return MAX (align, BITS_PER_WORD);
return align;
}
/* Initialize the GCC target structure. */
#undef TARGET_ASM_ALIGNED_HI_OP
#define TARGET_ASM_ALIGNED_HI_OP "\t.half\t"
@ -4142,6 +4153,9 @@ riscv_can_change_mode_class (machine_mode, machine_mode, reg_class_t rclass)
#undef TARGET_CAN_CHANGE_MODE_CLASS
#define TARGET_CAN_CHANGE_MODE_CLASS riscv_can_change_mode_class
#undef TARGET_CONSTANT_ALIGNMENT
#define TARGET_CONSTANT_ALIGNMENT riscv_constant_alignment
struct gcc_target targetm = TARGET_INITIALIZER;
#include "gt-riscv.h"

View File

@ -152,22 +152,6 @@ along with GCC; see the file COPYING3. If not see
#define PCC_BITFIELD_TYPE_MATTERS 1
/* If defined, a C expression to compute the alignment given to a
constant that is being placed in memory. CONSTANT is the constant
and ALIGN is the alignment that the object would ordinarily have.
The value of this macro is used instead of that alignment to align
the object.
If this macro is not defined, then ALIGN is used.
The typical use of this macro is to increase alignment for string
constants to be word aligned so that `strcpy' calls that copy
constants can be done inline. */
#define CONSTANT_ALIGNMENT(EXP, ALIGN) \
((TREE_CODE (EXP) == STRING_CST || TREE_CODE (EXP) == CONSTRUCTOR) \
&& (ALIGN) < BITS_PER_WORD ? BITS_PER_WORD : (ALIGN))
/* If defined, a C expression to compute the alignment for a static
variable. TYPE is the data type, and ALIGN is the alignment that
the object would ordinarily have. The value of this macro is used

View File

@ -1974,6 +1974,9 @@ static const struct attribute_spec rs6000_attribute_table[] =
#undef TARGET_CAN_CHANGE_MODE_CLASS
#define TARGET_CAN_CHANGE_MODE_CLASS rs6000_can_change_mode_class
#undef TARGET_CONSTANT_ALIGNMENT
#define TARGET_CONSTANT_ALIGNMENT rs6000_constant_alignment
/* Processor table. */
@ -39195,6 +39198,17 @@ rs6000_optab_supported_p (int op, machine_mode mode1, machine_mode,
return true;
}
}
/* Implement TARGET_CONSTANT_ALIGNMENT. */
static HOST_WIDE_INT
rs6000_constant_alignment (const_tree exp, HOST_WIDE_INT align)
{
if (TREE_CODE (exp) == STRING_CST
&& (STRICT_ALIGNMENT || !optimize_size))
return MAX (align, BITS_PER_WORD);
return align;
}
struct gcc_target targetm = TARGET_INITIALIZER;

View File

@ -950,14 +950,6 @@ enum data_align { align_abi, align_opt, align_both };
#define LOCAL_ALIGNMENT(TYPE, ALIGN) \
rs6000_data_alignment (TYPE, ALIGN, align_both)
/* Make strings word-aligned so strcpy from constants will be faster. */
#define CONSTANT_ALIGNMENT(EXP, ALIGN) \
(TREE_CODE (EXP) == STRING_CST \
&& (STRICT_ALIGNMENT || !optimize_size) \
&& (ALIGN) < BITS_PER_WORD \
? BITS_PER_WORD \
: (ALIGN))
/* Make arrays of chars word-aligned for the same reasons. */
#define DATA_ALIGNMENT(TYPE, ALIGN) \
rs6000_data_alignment (TYPE, ALIGN, align_opt)

View File

@ -15906,6 +15906,15 @@ s390_vector_alignment (const_tree type)
return MIN (64, tree_to_shwi (TYPE_SIZE (type)));
}
/* Implement TARGET_CONSTANT_ALIGNMENT. Alignment on even addresses for
LARL instruction. */
static HOST_WIDE_INT
s390_constant_alignment (const_tree, HOST_WIDE_INT align)
{
return MAX (align, 16);
}
#ifdef HAVE_AS_MACHINE_MACHINEMODE
/* Implement TARGET_ASM_FILE_START. */
static void
@ -16325,6 +16334,9 @@ s390_asan_shadow_offset (void)
#undef TARGET_CAN_CHANGE_MODE_CLASS
#define TARGET_CAN_CHANGE_MODE_CLASS s390_can_change_mode_class
#undef TARGET_CONSTANT_ALIGNMENT
#define TARGET_CONSTANT_ALIGNMENT s390_constant_alignment
struct gcc_target targetm = TARGET_INITIALIZER;
#include "gt-s390.h"

View File

@ -315,7 +315,6 @@ extern const char *s390_host_detect_local_cpu (int argc, const char **argv);
#define EMPTY_FIELD_BOUNDARY 32
/* Alignment on even addresses for LARL instruction. */
#define CONSTANT_ALIGNMENT(EXP, ALIGN) (ALIGN) < 16 ? 16 : (ALIGN)
#define DATA_ABI_ALIGNMENT(TYPE, ALIGN) (ALIGN) < 16 ? 16 : (ALIGN)
/* Alignment is not required by the hardware. */

View File

@ -657,6 +657,9 @@ static const struct attribute_spec sh_attribute_table[] =
#undef TARGET_CAN_CHANGE_MODE_CLASS
#define TARGET_CAN_CHANGE_MODE_CLASS sh_can_change_mode_class
#undef TARGET_CONSTANT_ALIGNMENT
#define TARGET_CONSTANT_ALIGNMENT constant_alignment_word_strings
struct gcc_target targetm = TARGET_INITIALIZER;

View File

@ -462,12 +462,6 @@ extern const sh_atomic_model& selected_atomic_model (void);
/* The best alignment to use in cases where we have a choice. */
#define FASTEST_ALIGNMENT (32)
/* Make strings word-aligned so strcpy from constants will be faster. */
#define CONSTANT_ALIGNMENT(EXP, ALIGN) \
((TREE_CODE (EXP) == STRING_CST \
&& (ALIGN) < FASTEST_ALIGNMENT) \
? FASTEST_ALIGNMENT : (ALIGN))
/* get_mode_alignment assumes complex values are always held in multiple
registers, but that is not the case on the SH; CQImode and CHImode are
held in a single integer register. */

View File

@ -684,6 +684,7 @@ static bool sparc_hard_regno_mode_ok (unsigned int, machine_mode);
static bool sparc_modes_tieable_p (machine_mode, machine_mode);
static bool sparc_can_change_mode_class (machine_mode, machine_mode,
reg_class_t);
static HOST_WIDE_INT sparc_constant_alignment (const_tree, HOST_WIDE_INT);
#ifdef SUBTARGET_ATTRIBUTE_TABLE
/* Table of valid machine attributes. */
@ -925,6 +926,9 @@ char sparc_hard_reg_printed[8];
#undef TARGET_CAN_CHANGE_MODE_CLASS
#define TARGET_CAN_CHANGE_MODE_CLASS sparc_can_change_mode_class
#undef TARGET_CONSTANT_ALIGNMENT
#define TARGET_CONSTANT_ALIGNMENT sparc_constant_alignment
struct gcc_target targetm = TARGET_INITIALIZER;
/* Return the memory reference contained in X if any, zero otherwise. */
@ -13429,4 +13433,14 @@ sparc_can_change_mode_class (machine_mode from, machine_mode to,
return true;
}
/* Implement TARGET_CONSTANT_ALIGNMENT. */
static HOST_WIDE_INT
sparc_constant_alignment (const_tree exp, HOST_WIDE_INT align)
{
if (TREE_CODE (exp) == STRING_CST)
return MAX (align, FASTEST_ALIGNMENT);
return align;
}
#include "gt-sparc.h"

View File

@ -579,12 +579,6 @@ extern enum cmodel sparc_cmodel;
#define STACK_SAVEAREA_MODE(LEVEL) \
((LEVEL) == SAVE_NONLOCAL ? (TARGET_ARCH64 ? TImode : DImode) : Pmode)
/* Make strings word-aligned so strcpy from constants will be faster. */
#define CONSTANT_ALIGNMENT(EXP, ALIGN) \
((TREE_CODE (EXP) == STRING_CST \
&& (ALIGN) < FASTEST_ALIGNMENT) \
? FASTEST_ALIGNMENT : (ALIGN))
/* Make arrays of chars word-aligned for the same reasons. */
#define DATA_ALIGNMENT(TYPE, ALIGN) \
(TREE_CODE (TYPE) == ARRAY_TYPE \

View File

@ -4159,7 +4159,7 @@ spu_encode_section_info (tree decl, rtx rtl, int first)
which is both 16-byte aligned and padded to a 16-byte boundary. This
would make it safe to store with a single instruction.
We guarantee the alignment and padding for static objects by aligning
all of them to 16-bytes. (DATA_ALIGNMENT and CONSTANT_ALIGNMENT.)
all of them to 16-bytes. (DATA_ALIGNMENT and TARGET_CONSTANT_ALIGNMENT.)
FIXME: We currently cannot guarantee this for objects on the stack
because assign_parm_setup_stack calls assign_stack_local with the
alignment of the parameter mode and in that case the alignment never
@ -7193,6 +7193,18 @@ spu_truly_noop_truncation (unsigned int outprec, unsigned int inprec)
{
return inprec <= 32 && outprec <= inprec;
}
/* Implement TARGET_CONSTANT_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_constant_alignment (const_tree, HOST_WIDE_INT align)
{
return MAX (align, 128);
}
/* Table of machine attributes. */
static const struct attribute_spec spu_attribute_table[] =
@ -7433,6 +7445,9 @@ static const struct attribute_spec spu_attribute_table[] =
#undef TARGET_TRULY_NOOP_TRUNCATION
#define TARGET_TRULY_NOOP_TRUNCATION spu_truly_noop_truncation
#undef TARGET_CONSTANT_ALIGNMENT
#define TARGET_CONSTANT_ALIGNMENT spu_constant_alignment
struct gcc_target targetm = TARGET_INITIALIZER;
#include "gt-spu.h"

View File

@ -96,7 +96,6 @@ extern GTY(()) int spu_tune;
on the stack. (Except a bug (?) allows some stack objects to be
unaligned.) */
#define DATA_ALIGNMENT(TYPE,ALIGN) ((ALIGN) > 128 ? (ALIGN) : 128)
#define CONSTANT_ALIGNMENT(TYPE,ALIGN) ((ALIGN) > 128 ? (ALIGN) : 128)
#define LOCAL_ALIGNMENT(TYPE,ALIGN) ((ALIGN) > 128 ? (ALIGN) : 128)
#define EMPTY_FIELD_BOUNDARY 32

View File

@ -2715,6 +2715,9 @@ xstormy16_modes_tieable_p (machine_mode mode1, machine_mode mode2)
#undef TARGET_MODES_TIEABLE_P
#define TARGET_MODES_TIEABLE_P xstormy16_modes_tieable_p
#undef TARGET_CONSTANT_ALIGNMENT
#define TARGET_CONSTANT_ALIGNMENT constant_alignment_word_strings
struct gcc_target targetm = TARGET_INITIALIZER;
#include "gt-stormy16.h"

View File

@ -87,10 +87,6 @@
&& TYPE_MODE (TREE_TYPE (TYPE)) == QImode \
&& (ALIGN) < BITS_PER_WORD ? BITS_PER_WORD : (ALIGN))
#define CONSTANT_ALIGNMENT(EXP, ALIGN) \
(TREE_CODE (EXP) == STRING_CST \
&& (ALIGN) < BITS_PER_WORD ? BITS_PER_WORD : (ALIGN))
#define STRICT_ALIGNMENT 1
#define PCC_BITFIELD_TYPE_MATTERS 1

View File

@ -5734,6 +5734,9 @@ tilegx_truly_noop_truncation (unsigned int outprec, unsigned int inprec)
#undef TARGET_TRULY_NOOP_TRUNCATION
#define TARGET_TRULY_NOOP_TRUNCATION tilegx_truly_noop_truncation
#undef TARGET_CONSTANT_ALIGNMENT
#define TARGET_CONSTANT_ALIGNMENT constant_alignment_word_strings
struct gcc_target targetm = TARGET_INITIALIZER;
#include "gt-tilegx.h"

View File

@ -94,13 +94,6 @@
#define BIGGEST_FIELD_ALIGNMENT 128
#define WIDEST_HARDWARE_FP_SIZE 64
/* Make strings word-aligned so strcpy from constants will be
faster. */
#define CONSTANT_ALIGNMENT(EXP, ALIGN) \
((TREE_CODE (EXP) == STRING_CST \
&& (ALIGN) < FASTEST_ALIGNMENT) \
? FASTEST_ALIGNMENT : (ALIGN))
/* Make arrays of chars word-aligned for the same reasons. */
#define DATA_ALIGNMENT(TYPE, ALIGN) \
(TREE_CODE (TYPE) == ARRAY_TYPE \

View File

@ -5091,6 +5091,9 @@ tilepro_file_end (void)
#undef TARGET_CAN_USE_DOLOOP_P
#define TARGET_CAN_USE_DOLOOP_P can_use_doloop_if_innermost
#undef TARGET_CONSTANT_ALIGNMENT
#define TARGET_CONSTANT_ALIGNMENT constant_alignment_word_strings
struct gcc_target targetm = TARGET_INITIALIZER;
#include "gt-tilepro.h"

View File

@ -58,13 +58,6 @@
#define FASTEST_ALIGNMENT 32
#define BIGGEST_FIELD_ALIGNMENT 64
/* Make strings word-aligned so strcpy from constants will be
faster. */
#define CONSTANT_ALIGNMENT(EXP, ALIGN) \
((TREE_CODE (EXP) == STRING_CST \
&& (ALIGN) < FASTEST_ALIGNMENT) \
? FASTEST_ALIGNMENT : (ALIGN))
/* Make arrays of chars word-aligned for the same reasons. */
#define DATA_ALIGNMENT(TYPE, ALIGN) \
(TREE_CODE (TYPE) == ARRAY_TYPE \

View File

@ -237,6 +237,8 @@ static bool visium_modes_tieable_p (machine_mode, machine_mode);
static bool visium_can_change_mode_class (machine_mode, machine_mode,
reg_class_t);
static HOST_WIDE_INT visium_constant_alignment (const_tree, HOST_WIDE_INT);
/* Setup the global target hooks structure. */
#undef TARGET_MAX_ANCHOR_OFFSET
@ -360,6 +362,9 @@ static bool visium_can_change_mode_class (machine_mode, machine_mode,
#undef TARGET_CAN_CHANGE_MODE_CLASS
#define TARGET_CAN_CHANGE_MODE_CLASS visium_can_change_mode_class
#undef TARGET_CONSTANT_ALIGNMENT
#define TARGET_CONSTANT_ALIGNMENT visium_constant_alignment
struct gcc_target targetm = TARGET_INITIALIZER;
namespace {
@ -834,6 +839,14 @@ visium_data_alignment (tree type, unsigned int align)
return align;
}
/* Implement TARGET_CONSTANT_ALIGNMENT. */
static HOST_WIDE_INT
visium_constant_alignment (const_tree exp, HOST_WIDE_INT align)
{
return visium_data_alignment (TREE_TYPE (exp), align);
}
/* Helper function for HARD_REGNO_RENAME_OK (FROM, TO). Return non-zero if
it is OK to rename a hard register FROM to another hard register TO. */

View File

@ -236,16 +236,6 @@
this macro is used instead of that alignment to align the object. */
#define DATA_ALIGNMENT(TYPE,ALIGN) visium_data_alignment (TYPE, ALIGN)
/* `CONSTANT_ALIGNMENT (CONSTANT, BASIC-ALIGN)`
If defined, a C expression to compute the alignment given to a
constant that is being placed in memory. CONSTANT is the constant
and BASIC-ALIGN is the alignment that the object would ordinarily
have. The value of this macro is used instead of that alignment to
align the object. */
#define CONSTANT_ALIGNMENT(EXP,ALIGN) \
visium_data_alignment (TREE_TYPE (EXP), ALIGN)
/* `LOCAL_ALIGNMENT (TYPE, BASIC-ALIGN)`
If defined, a C expression to compute the alignment for a variable

View File

@ -181,6 +181,7 @@ static void xtensa_conditional_register_usage (void);
static unsigned int xtensa_hard_regno_nregs (unsigned int, machine_mode);
static bool xtensa_hard_regno_mode_ok (unsigned int, machine_mode);
static bool xtensa_modes_tieable_p (machine_mode, machine_mode);
static HOST_WIDE_INT xtensa_constant_alignment (const_tree, HOST_WIDE_INT);
@ -317,6 +318,9 @@ static bool xtensa_modes_tieable_p (machine_mode, machine_mode);
#undef TARGET_MODES_TIEABLE_P
#define TARGET_MODES_TIEABLE_P xtensa_modes_tieable_p
#undef TARGET_CONSTANT_ALIGNMENT
#define TARGET_CONSTANT_ALIGNMENT xtensa_constant_alignment
struct gcc_target targetm = TARGET_INITIALIZER;
@ -4380,4 +4384,19 @@ enum reg_class xtensa_regno_to_class (int regno)
return regno_to_class[regno];
}
/* Implement TARGET_CONSTANT_ALIGNMENT. Align string constants and
constructors to at least a word boundary. The typical use of this
macro is to increase alignment for string constants to be word
aligned so that 'strcpy' calls that copy constants can be done
inline. */
static HOST_WIDE_INT
xtensa_constant_alignment (const_tree exp, HOST_WIDE_INT align)
{
if ((TREE_CODE (exp) == STRING_CST || TREE_CODE (exp) == CONSTRUCTOR)
&& !optimize_size)
return MAX (align, BITS_PER_WORD);
return align;
}
#include "gt-xtensa.h"

View File

@ -169,17 +169,6 @@ along with GCC; see the file COPYING3. If not see
bitfields and the structures that contain them. */
#define PCC_BITFIELD_TYPE_MATTERS 1
/* Align string constants and constructors to at least a word boundary.
The typical use of this macro is to increase alignment for string
constants to be word aligned so that 'strcpy' calls that copy
constants can be done inline. */
#define CONSTANT_ALIGNMENT(EXP, ALIGN) \
(!optimize_size && \
(TREE_CODE (EXP) == STRING_CST || TREE_CODE (EXP) == CONSTRUCTOR) \
&& (ALIGN) < BITS_PER_WORD \
? BITS_PER_WORD \
: (ALIGN))
/* Align arrays, unions and records to at least a word boundary.
One use of this macro is to increase alignment of medium-size
data to make it all fit in fewer cache lines. Another is to

View File

@ -1265,10 +1265,6 @@ see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
#define LOAD_EXTEND_OP(M) UNKNOWN
#endif
#ifndef CONSTANT_ALIGNMENT
#define CONSTANT_ALIGNMENT(EXP, ALIGN) ALIGN
#endif
#ifndef INITIAL_FRAME_ADDRESS_RTX
#define INITIAL_FRAME_ADDRESS_RTX NULL
#endif

View File

@ -1102,19 +1102,18 @@ must be aligned to 16 byte boundaries.
If this macro is not defined, then @var{basic-align} is used.
@end defmac
@defmac CONSTANT_ALIGNMENT (@var{constant}, @var{basic-align})
If defined, a C expression to compute the alignment given to a constant
that is being placed in memory. @var{constant} is the constant and
@var{basic-align} is the alignment that the object would ordinarily
have. The value of this macro is used instead of that alignment to
align the object.
@deftypefn {Target Hook} HOST_WIDE_INT TARGET_CONSTANT_ALIGNMENT (const_tree @var{constant}, HOST_WIDE_INT @var{basic_align})
This hook returns the alignment in bits of a constant that is being
placed in memory. @var{constant} is the constant and @var{basic_align}
is the alignment that the object would ordinarily have.
The default definition just returns @var{basic-align}.
The default definition just returns @var{basic_align}.
The typical use of this macro is to increase alignment for string
The typical use of this hook is to increase alignment for string
constants to be word aligned so that @code{strcpy} calls that copy
constants can be done inline.
@end defmac
constants can be done inline. The function
@code{constant_alignment_word_strings} provides such a definition.
@end deftypefn
@defmac LOCAL_ALIGNMENT (@var{type}, @var{basic-align})
If defined, a C expression to compute the alignment for a variable in

View File

@ -1050,19 +1050,7 @@ must be aligned to 16 byte boundaries.
If this macro is not defined, then @var{basic-align} is used.
@end defmac
@defmac CONSTANT_ALIGNMENT (@var{constant}, @var{basic-align})
If defined, a C expression to compute the alignment given to a constant
that is being placed in memory. @var{constant} is the constant and
@var{basic-align} is the alignment that the object would ordinarily
have. The value of this macro is used instead of that alignment to
align the object.
The default definition just returns @var{basic-align}.
The typical use of this macro is to increase alignment for string
constants to be word aligned so that @code{strcpy} calls that copy
constants can be done inline.
@end defmac
@hook TARGET_CONSTANT_ALIGNMENT
@defmac LOCAL_ALIGNMENT (@var{type}, @var{basic-align})
If defined, a C expression to compute the alignment for a variable in

View File

@ -915,7 +915,7 @@ extern void fancy_abort (const char *, int, const char *)
MODES_TIEABLE_P FUNCTION_ARG_PADDING SLOW_UNALIGNED_ACCESS \
HARD_REGNO_NREGS SECONDARY_MEMORY_NEEDED_MODE \
SECONDARY_MEMORY_NEEDED CANNOT_CHANGE_MODE_CLASS \
TRULY_NOOP_TRUNCATION FUNCTION_ARG_OFFSET
TRULY_NOOP_TRUNCATION FUNCTION_ARG_OFFSET CONSTANT_ALIGNMENT
/* Target macros only used for code built for the target, that have
moved to libgcc-tm.h or have never been present elsewhere. */

View File

@ -3335,6 +3335,21 @@ HOOK_VECTOR_END (addr_space)
#undef HOOK_PREFIX
#define HOOK_PREFIX "TARGET_"
DEFHOOK
(constant_alignment,
"This hook returns the alignment in bits of a constant that is being\n\
placed in memory. @var{constant} is the constant and @var{basic_align}\n\
is the alignment that the object would ordinarily have.\n\
\n\
The default definition just returns @var{basic_align}.\n\
\n\
The typical use of this hook is to increase alignment for string\n\
constants to be word aligned so that @code{strcpy} calls that copy\n\
constants can be done inline. The function\n\
@code{constant_alignment_word_strings} provides such a definition.",
HOST_WIDE_INT, (const_tree constant, HOST_WIDE_INT basic_align),
default_constant_alignment)
/* True if MODE is valid for the target. By "valid", we mean able to
be manipulated in non-trivial ways. In particular, this means all
the arithmetic is supported. */

View File

@ -1165,6 +1165,25 @@ tree default_mangle_decl_assembler_name (tree decl ATTRIBUTE_UNUSED,
return id;
}
/* The default implementation of TARGET_CONSTANT_ALIGNMENT. */
HOST_WIDE_INT
default_constant_alignment (const_tree, HOST_WIDE_INT align)
{
return align;
}
/* An implementation of TARGET_CONSTANT_ALIGNMENT that aligns strings
to at least BITS_PER_WORD but otherwise makes no changes. */
HOST_WIDE_INT
constant_alignment_word_strings (const_tree exp, HOST_WIDE_INT align)
{
if (TREE_CODE (exp) == STRING_CST)
return MAX (align, BITS_PER_WORD);
return align;
}
/* Default to natural alignment for vector types. */
HOST_WIDE_INT
default_vector_alignment (const_tree type)

View File

@ -93,6 +93,9 @@ extern int default_builtin_vectorization_cost (enum vect_cost_for_stmt, tree, in
extern tree default_builtin_reciprocal (tree);
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);
extern HOST_WIDE_INT default_vector_alignment (const_tree);
extern HOST_WIDE_INT default_preferred_vector_alignment (const_tree);

View File

@ -1055,7 +1055,7 @@ align_variable (tree decl, bool dont_output_data)
&& (in_lto_p || DECL_INITIAL (decl) != error_mark_node))
{
unsigned int const_align
= CONSTANT_ALIGNMENT (DECL_INITIAL (decl), align);
= targetm.constant_alignment (DECL_INITIAL (decl), align);
/* Don't increase alignment too much for TLS variables - TLS
space is too precious. */
if (! DECL_THREAD_LOCAL_P (decl) || const_align <= BITS_PER_WORD)
@ -1106,8 +1106,8 @@ get_variable_align (tree decl)
to mark offlined constructors. */
&& (in_lto_p || DECL_INITIAL (decl) != error_mark_node))
{
unsigned int const_align = CONSTANT_ALIGNMENT (DECL_INITIAL (decl),
align);
unsigned int const_align
= targetm.constant_alignment (DECL_INITIAL (decl), align);
/* Don't increase alignment too much for TLS variables - TLS space
is too precious. */
if (! DECL_THREAD_LOCAL_P (decl) || const_align <= BITS_PER_WORD)
@ -3326,12 +3326,10 @@ build_constant_desc (tree exp)
Instead we set the flag that will be recognized in make_decl_rtl. */
DECL_IN_CONSTANT_POOL (decl) = 1;
DECL_INITIAL (decl) = desc->value;
/* ??? CONSTANT_ALIGNMENT hasn't been updated for vector types on most
architectures so use DATA_ALIGNMENT as well, except for strings. */
/* ??? targetm.constant_alignment hasn't been updated for vector types on
most architectures so use DATA_ALIGNMENT as well, except for strings. */
if (TREE_CODE (exp) == STRING_CST)
{
SET_DECL_ALIGN (decl, CONSTANT_ALIGNMENT (exp, DECL_ALIGN (decl)));
}
SET_DECL_ALIGN (decl, targetm.constant_alignment (exp, DECL_ALIGN (decl)));
else
align_variable (decl, 0);
@ -3790,7 +3788,7 @@ force_const_mem (machine_mode mode, rtx x)
tree type = lang_hooks.types.type_for_mode (mode, 0);
if (type != NULL_TREE)
align = CONSTANT_ALIGNMENT (make_tree (type, x), align);
align = targetm.constant_alignment (make_tree (type, x), align);
pool->offset += (align / BITS_PER_UNIT) - 1;
pool->offset &= ~ ((align / BITS_PER_UNIT) - 1);