diff options
author | Richard Sandiford <richard.sandiford@linaro.org> | 2017-09-25 16:04:27 +0000 |
---|---|---|
committer | Richard Sandiford <rsandifo@gcc.gnu.org> | 2017-09-25 16:04:27 +0000 |
commit | 58e17cf84636d72e3620b5af50b0336d9364ddd0 (patch) | |
tree | 324fdb8176bd47aa09f1fbed5815c901bc84370e /gcc/config | |
parent | 75c44d224641800c6f5d4cad4487cea3524852a6 (diff) | |
download | gcc-58e17cf84636d72e3620b5af50b0336d9364ddd0.zip gcc-58e17cf84636d72e3620b5af50b0336d9364ddd0.tar.gz gcc-58e17cf84636d72e3620b5af50b0336d9364ddd0.tar.bz2 |
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
Diffstat (limited to 'gcc/config')
71 files changed, 285 insertions, 259 deletions
diff --git a/gcc/config/aarch64/aarch64.c b/gcc/config/aarch64/aarch64.c index 9b02c6e..71d8dc4 100644 --- a/gcc/config/aarch64/aarch64.c +++ b/gcc/config/aarch64/aarch64.c @@ -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 diff --git a/gcc/config/aarch64/aarch64.h b/gcc/config/aarch64/aarch64.h index fe3dd43..0786b28 100644 --- a/gcc/config/aarch64/aarch64.h +++ b/gcc/config/aarch64/aarch64.h @@ -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 diff --git a/gcc/config/alpha/alpha.h b/gcc/config/alpha/alpha.h index 82d04d6..a2878c6 100644 --- a/gcc/config/alpha/alpha.h +++ b/gcc/config/alpha/alpha.h @@ -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 diff --git a/gcc/config/arc/arc.c b/gcc/config/arc/arc.c index 61c83fc..a0b66758 100644 --- a/gcc/config/arc/arc.c +++ b/gcc/config/arc/arc.c @@ -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" diff --git a/gcc/config/arc/arc.h b/gcc/config/arc/arc.h index 6c63430..91a4c90 100644 --- a/gcc/config/arc/arc.h +++ b/gcc/config/arc/arc.h @@ -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 \ diff --git a/gcc/config/arm/arm.c b/gcc/config/arm/arm.c index f9c1ce3..363f549 100644 --- a/gcc/config/arm/arm.c +++ b/gcc/config/arm/arm.c @@ -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 { diff --git a/gcc/config/arm/arm.h b/gcc/config/arm/arm.h index 9a171b0..c71ad5c 100644 --- a/gcc/config/arm/arm.h +++ b/gcc/config/arm/arm.h @@ -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 diff --git a/gcc/config/bfin/bfin.c b/gcc/config/bfin/bfin.c index 7ef173a..ed9ea03 100644 --- a/gcc/config/bfin/bfin.c +++ b/gcc/config/bfin/bfin.c @@ -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; diff --git a/gcc/config/bfin/bfin.h b/gcc/config/bfin/bfin.h index e0443da..787600f 100644 --- a/gcc/config/bfin/bfin.h +++ b/gcc/config/bfin/bfin.h @@ -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. diff --git a/gcc/config/cr16/cr16.c b/gcc/config/cr16/cr16.c index c410071..55e0965 100644 --- a/gcc/config/cr16/cr16.c +++ b/gcc/config/cr16/cr16.c @@ -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. */ diff --git a/gcc/config/cr16/cr16.h b/gcc/config/cr16/cr16.h index ce54dd74..143a1db 100644 --- a/gcc/config/cr16/cr16.h +++ b/gcc/config/cr16/cr16.h @@ -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 diff --git a/gcc/config/cris/cris.c b/gcc/config/cris/cris.c index 1b2add0..fe80a27 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_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, diff --git a/gcc/config/cris/cris.h b/gcc/config/cris/cris.h index b44164f..570e2d9 100644 --- a/gcc/config/cris/cris.h +++ b/gcc/config/cris/cris.h @@ -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. */ diff --git a/gcc/config/epiphany/epiphany.c b/gcc/config/epiphany/epiphany.c index 67d52b8..d1d9ee9 100644 --- a/gcc/config/epiphany/epiphany.c +++ b/gcc/config/epiphany/epiphany.c @@ -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; diff --git a/gcc/config/epiphany/epiphany.h b/gcc/config/epiphany/epiphany.h index 303ac5e..290ea20 100644 --- a/gcc/config/epiphany/epiphany.h +++ b/gcc/config/epiphany/epiphany.h @@ -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) \ diff --git a/gcc/config/fr30/fr30.c b/gcc/config/fr30/fr30.c index d83b2f3..9188481 100644 --- a/gcc/config/fr30/fr30.c +++ b/gcc/config/fr30/fr30.c @@ -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; diff --git a/gcc/config/fr30/fr30.h b/gcc/config/fr30/fr30.h index 2e6b793..c448509 100644 --- a/gcc/config/fr30/fr30.h +++ b/gcc/config/fr30/fr30.h @@ -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 diff --git a/gcc/config/frv/frv.c b/gcc/config/frv/frv.c index 85e22c7..c9877e7 100644 --- a/gcc/config/frv/frv.c +++ b/gcc/config/frv/frv.c @@ -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; diff --git a/gcc/config/frv/frv.h b/gcc/config/frv/frv.h index 350a59f..44a73e0 100644 --- a/gcc/config/frv/frv.h +++ b/gcc/config/frv/frv.h @@ -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. */ diff --git a/gcc/config/ft32/ft32.c b/gcc/config/ft32/ft32.c index fada924..0386e06 100644 --- a/gcc/config/ft32/ft32.c +++ b/gcc/config/ft32/ft32.c @@ -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" diff --git a/gcc/config/ft32/ft32.h b/gcc/config/ft32/ft32.h index 6438393..32aa320 100644 --- a/gcc/config/ft32/ft32.h +++ b/gcc/config/ft32/ft32.h @@ -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 diff --git a/gcc/config/i386/i386-protos.h b/gcc/config/i386/i386-protos.h index 4df6274..fbe9f27 100644 --- a/gcc/config/i386/i386-protos.h +++ b/gcc/config/i386/i386-protos.h @@ -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); diff --git a/gcc/config/i386/i386.c b/gcc/config/i386/i386.c index 29b5a9c..d52d1df 100644 --- a/gcc/config/i386/i386.c +++ b/gcc/config/i386/i386.c @@ -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 diff --git a/gcc/config/i386/i386.h b/gcc/config/i386/i386.h index 012b85d..899ba8b 100644 --- a/gcc/config/i386/i386.h +++ b/gcc/config/i386/i386.h @@ -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 diff --git a/gcc/config/ia64/ia64.c b/gcc/config/ia64/ia64.c index 5573f27..fce3006 100644 --- a/gcc/config/ia64/ia64.c +++ b/gcc/config/ia64/ia64.c @@ -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 diff --git a/gcc/config/ia64/ia64.h b/gcc/config/ia64/ia64.h index 9cfb009..4a9313e 100644 --- a/gcc/config/ia64/ia64.h +++ b/gcc/config/ia64/ia64.h @@ -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 diff --git a/gcc/config/iq2000/iq2000.c b/gcc/config/iq2000/iq2000.c index 460e38d..297bd2b 100644 --- a/gcc/config/iq2000/iq2000.c +++ b/gcc/config/iq2000/iq2000.c @@ -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" diff --git a/gcc/config/iq2000/iq2000.h b/gcc/config/iq2000/iq2000.h index ef4cd270..58c3597 100644 --- a/gcc/config/iq2000/iq2000.h +++ b/gcc/config/iq2000/iq2000.h @@ -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 diff --git a/gcc/config/lm32/lm32.c b/gcc/config/lm32/lm32.c index f088069..a4aade4 100644 --- a/gcc/config/lm32/lm32.c +++ b/gcc/config/lm32/lm32.c @@ -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. */ diff --git a/gcc/config/lm32/lm32.h b/gcc/config/lm32/lm32.h index 9169834..605bd68 100644 --- a/gcc/config/lm32/lm32.h +++ b/gcc/config/lm32/lm32.h @@ -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) \ diff --git a/gcc/config/m32r/m32r.c b/gcc/config/m32r/m32r.c index 9b7cb5f..aefab93 100644 --- a/gcc/config/m32r/m32r.c +++ b/gcc/config/m32r/m32r.c @@ -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. */ diff --git a/gcc/config/m32r/m32r.h b/gcc/config/m32r/m32r.h index 09d73bc..5b2a93b 100644 --- a/gcc/config/m32r/m32r.h +++ b/gcc/config/m32r/m32r.h @@ -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 \ diff --git a/gcc/config/mcore/mcore.c b/gcc/config/mcore/mcore.c index 81a5820..04dfb9d 100644 --- a/gcc/config/mcore/mcore.c +++ b/gcc/config/mcore/mcore.c @@ -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. */ diff --git a/gcc/config/mcore/mcore.h b/gcc/config/mcore/mcore.h index 4e93343..f411186 100644 --- a/gcc/config/mcore/mcore.h +++ b/gcc/config/mcore/mcore.h @@ -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 \ diff --git a/gcc/config/microblaze/microblaze.c b/gcc/config/microblaze/microblaze.c index d935c3e..53ca016 100644 --- a/gcc/config/microblaze/microblaze.c +++ b/gcc/config/microblaze/microblaze.c @@ -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" diff --git a/gcc/config/microblaze/microblaze.h b/gcc/config/microblaze/microblaze.h index 1726e26..2fc7fc5 100644 --- a/gcc/config/microblaze/microblaze.h +++ b/gcc/config/microblaze/microblaze.h @@ -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 \ diff --git a/gcc/config/mips/mips.c b/gcc/config/mips/mips.c index a71732e..4133375 100644 --- a/gcc/config/mips/mips.c +++ b/gcc/config/mips/mips.c @@ -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" diff --git a/gcc/config/mips/mips.h b/gcc/config/mips/mips.h index 1f4cad8..a2d8c7c 100644 --- a/gcc/config/mips/mips.h +++ b/gcc/config/mips/mips.h @@ -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 diff --git a/gcc/config/mmix/mmix-protos.h b/gcc/config/mmix/mmix-protos.h index 7cb4670..6c38924 100644 --- a/gcc/config/mmix/mmix-protos.h +++ b/gcc/config/mmix/mmix-protos.h @@ -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); diff --git a/gcc/config/mmix/mmix.c b/gcc/config/mmix/mmix.c index 90a4651..09e752d 100644 --- a/gcc/config/mmix/mmix.c +++ b/gcc/config/mmix/mmix.c @@ -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; diff --git a/gcc/config/mmix/mmix.h b/gcc/config/mmix/mmix.h index 7161656..7d1e83c 100644 --- a/gcc/config/mmix/mmix.h +++ b/gcc/config/mmix/mmix.h @@ -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) diff --git a/gcc/config/moxie/moxie.c b/gcc/config/moxie/moxie.c index 19cd83f..4901237 100644 --- a/gcc/config/moxie/moxie.c +++ b/gcc/config/moxie/moxie.c @@ -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" diff --git a/gcc/config/moxie/moxie.h b/gcc/config/moxie/moxie.h index 9ae5f82..29442fb 100644 --- a/gcc/config/moxie/moxie.h +++ b/gcc/config/moxie/moxie.h @@ -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 \ diff --git a/gcc/config/nios2/nios2.c b/gcc/config/nios2/nios2.c index 893ddd1..2602605 100644 --- a/gcc/config/nios2/nios2.c +++ b/gcc/config/nios2/nios2.c @@ -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" diff --git a/gcc/config/nios2/nios2.h b/gcc/config/nios2/nios2.h index d911b54..10bebfb 100644 --- a/gcc/config/nios2/nios2.h +++ b/gcc/config/nios2/nios2.h @@ -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. */ diff --git a/gcc/config/pa/pa.c b/gcc/config/pa/pa.c index 651ae59..2586f92 100644 --- a/gcc/config/pa/pa.c +++ b/gcc/config/pa/pa.c @@ -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. */ diff --git a/gcc/config/pa/pa.h b/gcc/config/pa/pa.h index 2edf0db..fbfbe48 100644 --- a/gcc/config/pa/pa.h +++ b/gcc/config/pa/pa.h @@ -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 \ diff --git a/gcc/config/powerpcspe/powerpcspe.c b/gcc/config/powerpcspe/powerpcspe.c index 26692aa..12af884 100644 --- a/gcc/config/powerpcspe/powerpcspe.c +++ b/gcc/config/powerpcspe/powerpcspe.c @@ -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; diff --git a/gcc/config/powerpcspe/powerpcspe.h b/gcc/config/powerpcspe/powerpcspe.h index 52c0376..8381785 100644 --- a/gcc/config/powerpcspe/powerpcspe.h +++ b/gcc/config/powerpcspe/powerpcspe.h @@ -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) diff --git a/gcc/config/riscv/riscv.c b/gcc/config/riscv/riscv.c index 42ddac9..c34468e 100644 --- a/gcc/config/riscv/riscv.c +++ b/gcc/config/riscv/riscv.c @@ -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" diff --git a/gcc/config/riscv/riscv.h b/gcc/config/riscv/riscv.h index a04da2c..c31d2cc 100644 --- a/gcc/config/riscv/riscv.h +++ b/gcc/config/riscv/riscv.h @@ -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 diff --git a/gcc/config/rs6000/rs6000.c b/gcc/config/rs6000/rs6000.c index 3212634..3c01546 100644 --- a/gcc/config/rs6000/rs6000.c +++ b/gcc/config/rs6000/rs6000.c @@ -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; diff --git a/gcc/config/rs6000/rs6000.h b/gcc/config/rs6000/rs6000.h index da2f4f5..6021972 100644 --- a/gcc/config/rs6000/rs6000.h +++ b/gcc/config/rs6000/rs6000.h @@ -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) diff --git a/gcc/config/s390/s390.c b/gcc/config/s390/s390.c index 037e22e..e3fafa2a6 100644 --- a/gcc/config/s390/s390.c +++ b/gcc/config/s390/s390.c @@ -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" diff --git a/gcc/config/s390/s390.h b/gcc/config/s390/s390.h index 00652da..52eee94 100644 --- a/gcc/config/s390/s390.h +++ b/gcc/config/s390/s390.h @@ -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. */ diff --git a/gcc/config/sh/sh.c b/gcc/config/sh/sh.c index fa9f9ad..3c6d525 100644 --- a/gcc/config/sh/sh.c +++ b/gcc/config/sh/sh.c @@ -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; diff --git a/gcc/config/sh/sh.h b/gcc/config/sh/sh.h index a18044d..339bf28 100644 --- a/gcc/config/sh/sh.h +++ b/gcc/config/sh/sh.h @@ -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. */ diff --git a/gcc/config/sparc/sparc.c b/gcc/config/sparc/sparc.c index 11e4f45..d3f002d 100644 --- a/gcc/config/sparc/sparc.c +++ b/gcc/config/sparc/sparc.c @@ -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" diff --git a/gcc/config/sparc/sparc.h b/gcc/config/sparc/sparc.h index 946605d..9ac741f 100644 --- a/gcc/config/sparc/sparc.h +++ b/gcc/config/sparc/sparc.h @@ -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 \ diff --git a/gcc/config/spu/spu.c b/gcc/config/spu/spu.c index ed8047d..b9af9a9 100644 --- a/gcc/config/spu/spu.c +++ b/gcc/config/spu/spu.c @@ -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" diff --git a/gcc/config/spu/spu.h b/gcc/config/spu/spu.h index 4cf426b..de4aa99 100644 --- a/gcc/config/spu/spu.h +++ b/gcc/config/spu/spu.h @@ -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 diff --git a/gcc/config/stormy16/stormy16.c b/gcc/config/stormy16/stormy16.c index 89f474e..d0bd433 100644 --- a/gcc/config/stormy16/stormy16.c +++ b/gcc/config/stormy16/stormy16.c @@ -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" diff --git a/gcc/config/stormy16/stormy16.h b/gcc/config/stormy16/stormy16.h index 0f19686..31d6156 100644 --- a/gcc/config/stormy16/stormy16.h +++ b/gcc/config/stormy16/stormy16.h @@ -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 diff --git a/gcc/config/tilegx/tilegx.c b/gcc/config/tilegx/tilegx.c index 368821e..63fe340 100644 --- a/gcc/config/tilegx/tilegx.c +++ b/gcc/config/tilegx/tilegx.c @@ -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" diff --git a/gcc/config/tilegx/tilegx.h b/gcc/config/tilegx/tilegx.h index 55fd89a..066c34d 100644 --- a/gcc/config/tilegx/tilegx.h +++ b/gcc/config/tilegx/tilegx.h @@ -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 \ diff --git a/gcc/config/tilepro/tilepro.c b/gcc/config/tilepro/tilepro.c index ae3337b..ee9bc0a 100644 --- a/gcc/config/tilepro/tilepro.c +++ b/gcc/config/tilepro/tilepro.c @@ -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" diff --git a/gcc/config/tilepro/tilepro.h b/gcc/config/tilepro/tilepro.h index 325b2ed..5ab8be4 100644 --- a/gcc/config/tilepro/tilepro.h +++ b/gcc/config/tilepro/tilepro.h @@ -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 \ diff --git a/gcc/config/visium/visium.c b/gcc/config/visium/visium.c index 4dd66dc..381d432 100644 --- a/gcc/config/visium/visium.c +++ b/gcc/config/visium/visium.c @@ -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. */ diff --git a/gcc/config/visium/visium.h b/gcc/config/visium/visium.h index 4b086d3..3cc0bc4 100644 --- a/gcc/config/visium/visium.h +++ b/gcc/config/visium/visium.h @@ -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 diff --git a/gcc/config/xtensa/xtensa.c b/gcc/config/xtensa/xtensa.c index 9c11ae0..3d60e31 100644 --- a/gcc/config/xtensa/xtensa.c +++ b/gcc/config/xtensa/xtensa.c @@ -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" diff --git a/gcc/config/xtensa/xtensa.h b/gcc/config/xtensa/xtensa.h index 74c5e52..f921639 100644 --- a/gcc/config/xtensa/xtensa.h +++ b/gcc/config/xtensa/xtensa.h @@ -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 |