+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
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;
}
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;
}
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
{
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));
#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
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
/* ??? 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
#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"
/* 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 \
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);
\f
/* Table of machine attributes. */
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
\f
/* Obstack for minipool constant handling. */
static struct obstack minipool_obstack;
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 {
#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
#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;
#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)
\f
/* Definitions for register eliminations.
#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. */
&& ((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
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. */
#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. */
|| (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,
? (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. */
#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
\f
bool
epiphany_is_interrupt_p (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;
#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) \
#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;
\f
&& 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
#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;
&& 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. */
}
}
+#undef TARGET_CONSTANT_ALIGNMENT
+#define TARGET_CONSTANT_ALIGNMENT constant_alignment_word_strings
+
struct gcc_target targetm = TARGET_INITIALIZER;
#include "gt-ft32.h"
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
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);
}
\f
-/* 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)
#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
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
#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;
\f
/* Returns TRUE iff the target attribute indicated by ATTR_ID takes a plain
&& 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
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
#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;
\f
/* Return nonzero if we split the address into high and low parts. */
|| 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"
|| 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
#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. */
#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) \
#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;
\f
/* Called by m32r_option_override to initialize various things. */
/* 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 \
#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;
\f
/* Adjust the stack and return the number of bytes taken to do it. */
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 \
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;
+}
\f
#undef TARGET_ENCODE_SECTION_INFO
#define TARGET_ENCODE_SECTION_INFO microblaze_encode_section_info
#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;
\f
#include "gt-microblaze.h"
#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 \
{
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;
+}
\f
/* Initialize the GCC target structure. */
#undef TARGET_ASM_ALIGNED_HI_OP
#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;
\f
#include "gt-mips.h"
#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
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);
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. */
#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.
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;
#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)
#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"
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 \
#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"
#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. */
#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;
\f
/* Parse the -mfixed-range= option string. */
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 \
#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
\f
/* Processor table. */
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;
+}
\f
struct gcc_target targetm = TARGET_INITIALIZER;
#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)
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"
#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"
#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
#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
\f
/* Processor table. */
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;
+}
\f
struct gcc_target targetm = TARGET_INITIALIZER;
#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)
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
#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"
#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. */
#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;
\f
/* 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. */
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);
\f
#ifdef SUBTARGET_ATTRIBUTE_TABLE
/* Table of valid machine attributes. */
#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. */
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"
#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 \
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
{
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);
+}
\f
/* Table of machine attributes. */
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"
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
#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"
&& 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
#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"
#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 \
#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"
#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 \
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
#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 {
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. */
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
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);
\f
#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;
\f
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"
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
#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
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
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
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. */
#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. */
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)
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);
&& (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)
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)
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);
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);