extern bool aarch64_gcs_enabled ();
+extern unsigned aarch64_data_alignment (const_tree exp, unsigned align);
+extern unsigned aarch64_stack_alignment (const_tree exp, unsigned align);
+
#endif /* GCC_AARCH64_PROTOS_H */
return 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
+ definition. Increasing the alignment tends to introduce padding,
+ so don't do this when optimizing for size/conserving stack space. */
+
+unsigned
+aarch64_data_alignment (const_tree type, unsigned align)
+{
+ if (optimize_size)
+ return align;
+
+ if (AGGREGATE_TYPE_P (type))
+ {
+ unsigned HOST_WIDE_INT size = 0;
+
+ if (TYPE_SIZE (type) && TREE_CODE (TYPE_SIZE (type)) == INTEGER_CST
+ && tree_fits_uhwi_p (TYPE_SIZE (type)))
+ size = tree_to_uhwi (TYPE_SIZE (type));
+
+ /* Align small structs/arrays to 32 bits, or 64 bits if larger. */
+ if (align < 32 && size <= 32)
+ align = 32;
+ else if (align < 64)
+ align = 64;
+ }
+
+ return align;
+}
+
+unsigned
+aarch64_stack_alignment (const_tree type, unsigned align)
+{
+ if (flag_conserve_stack)
+ return align;
+
+ if (AGGREGATE_TYPE_P (type))
+ {
+ unsigned HOST_WIDE_INT size = 0;
+
+ if (TYPE_SIZE (type) && TREE_CODE (TYPE_SIZE (type)) == INTEGER_CST
+ && tree_fits_uhwi_p (TYPE_SIZE (type)))
+ size = tree_to_uhwi (TYPE_SIZE (type));
+
+ /* Align small structs/arrays to 32 bits, or 64 bits if larger. */
+ if (align < 32 && size <= 32)
+ align = 32;
+ else if (align < 64)
+ align = 64;
+ }
+
+ return align;
+}
+
/* Return true if calls to DECL should be treated as
long-calls (ie called via a register). */
static bool
of LSE instructions. */
#define TARGET_OUTLINE_ATOMICS (aarch64_flag_outline_atomics)
-/* 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
- definition. Increasing the alignment tends to introduce padding,
- so don't do this when optimizing for size/conserving stack space. */
-#define AARCH64_EXPAND_ALIGNMENT(COND, EXP, ALIGN) \
- (((COND) && ((ALIGN) < BITS_PER_WORD) \
- && (TREE_CODE (EXP) == ARRAY_TYPE \
- || TREE_CODE (EXP) == UNION_TYPE \
- || TREE_CODE (EXP) == RECORD_TYPE)) ? BITS_PER_WORD : (ALIGN))
-
-/* Align global data. */
-#define DATA_ALIGNMENT(EXP, ALIGN) \
- AARCH64_EXPAND_ALIGNMENT (!optimize_size, EXP, ALIGN)
-
-/* Similarly, make sure that objects on the stack are sensibly aligned. */
-#define LOCAL_ALIGNMENT(EXP, ALIGN) \
- AARCH64_EXPAND_ALIGNMENT (!flag_conserve_stack, EXP, ALIGN)
+/* Align global data as an optimization. */
+#define DATA_ALIGNMENT(EXP, ALIGN) aarch64_data_alignment (EXP, ALIGN)
+
+/* Align stack data as an optimization. */
+#define LOCAL_ALIGNMENT(EXP, ALIGN) aarch64_stack_alignment (EXP, ALIGN)
#define STRUCTURE_SIZE_BOUNDARY 8