Turn CONSTANT_ALIGNMENT into a hook
commit579d67ba4296cf7ca934e64d83f6edbd6bccd23c
authorrsandifo <rsandifo@138bc75d-0d04-0410-961f-82ee72b054a4>
Mon, 25 Sep 2017 16:04:27 +0000 (25 16:04 +0000)
committerrsandifo <rsandifo@138bc75d-0d04-0410-961f-82ee72b054a4>
Mon, 25 Sep 2017 16:04:27 +0000 (25 16:04 +0000)
tree324fdb8176bd47aa09f1fbed5815c901bc84370e
parent2c3133a09ceedead50c2b585ef7f62738ad5c81e
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.

git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@253154 138bc75d-0d04-0410-961f-82ee72b054a4
81 files changed:
gcc/ChangeLog
gcc/builtins.c
gcc/config/aarch64/aarch64.c
gcc/config/aarch64/aarch64.h
gcc/config/alpha/alpha.h
gcc/config/arc/arc.c
gcc/config/arc/arc.h
gcc/config/arm/arm.c
gcc/config/arm/arm.h
gcc/config/bfin/bfin.c
gcc/config/bfin/bfin.h
gcc/config/cr16/cr16.c
gcc/config/cr16/cr16.h
gcc/config/cris/cris.c
gcc/config/cris/cris.h
gcc/config/epiphany/epiphany.c
gcc/config/epiphany/epiphany.h
gcc/config/fr30/fr30.c
gcc/config/fr30/fr30.h
gcc/config/frv/frv.c
gcc/config/frv/frv.h
gcc/config/ft32/ft32.c
gcc/config/ft32/ft32.h
gcc/config/i386/i386-protos.h
gcc/config/i386/i386.c
gcc/config/i386/i386.h
gcc/config/ia64/ia64.c
gcc/config/ia64/ia64.h
gcc/config/iq2000/iq2000.c
gcc/config/iq2000/iq2000.h
gcc/config/lm32/lm32.c
gcc/config/lm32/lm32.h
gcc/config/m32r/m32r.c
gcc/config/m32r/m32r.h
gcc/config/mcore/mcore.c
gcc/config/mcore/mcore.h
gcc/config/microblaze/microblaze.c
gcc/config/microblaze/microblaze.h
gcc/config/mips/mips.c
gcc/config/mips/mips.h
gcc/config/mmix/mmix-protos.h
gcc/config/mmix/mmix.c
gcc/config/mmix/mmix.h
gcc/config/moxie/moxie.c
gcc/config/moxie/moxie.h
gcc/config/nios2/nios2.c
gcc/config/nios2/nios2.h
gcc/config/pa/pa.c
gcc/config/pa/pa.h
gcc/config/powerpcspe/powerpcspe.c
gcc/config/powerpcspe/powerpcspe.h
gcc/config/riscv/riscv.c
gcc/config/riscv/riscv.h
gcc/config/rs6000/rs6000.c
gcc/config/rs6000/rs6000.h
gcc/config/s390/s390.c
gcc/config/s390/s390.h
gcc/config/sh/sh.c
gcc/config/sh/sh.h
gcc/config/sparc/sparc.c
gcc/config/sparc/sparc.h
gcc/config/spu/spu.c
gcc/config/spu/spu.h
gcc/config/stormy16/stormy16.c
gcc/config/stormy16/stormy16.h
gcc/config/tilegx/tilegx.c
gcc/config/tilegx/tilegx.h
gcc/config/tilepro/tilepro.c
gcc/config/tilepro/tilepro.h
gcc/config/visium/visium.c
gcc/config/visium/visium.h
gcc/config/xtensa/xtensa.c
gcc/config/xtensa/xtensa.h
gcc/defaults.h
gcc/doc/tm.texi
gcc/doc/tm.texi.in
gcc/system.h
gcc/target.def
gcc/targhooks.c
gcc/targhooks.h
gcc/varasm.c