@@ -74,6 +74,9 @@ s390_option_init_struct (struct gcc_options *opts)
/* By default, always emit DWARF-2 unwind info. This allows debugging
without maintaining a stack frame back-chain. */
opts->x_flag_asynchronous_unwind_tables = 1;
+
+ /* Enable section anchors by default. */
+ opts->x_flag_section_anchors = 1;
}
/* Implement TARGET_HANDLE_OPTION. */
@@ -4187,6 +4187,20 @@ s390_check_symref_alignment (rtx addr, HOST_WIDE_INT alignment)
if (GET_CODE (symref) == SYMBOL_REF)
{
+ /* s390_encode_section_info is not called for anchors, since they don't
+ have corresponding VAR_DECLs. Therefore, we cannot rely on
+ SYMBOL_FLAG_NOTALIGN{2,4,8}_P returning useful information. */
+ if (SYMBOL_REF_ANCHOR_P (symref))
+ {
+ HOST_WIDE_INT block_offset = SYMBOL_REF_BLOCK_OFFSET (symref);
+ unsigned int block_alignment = (SYMBOL_REF_BLOCK (symref)->alignment
+ / BITS_PER_UNIT);
+
+ gcc_assert (block_offset >= 0);
+ return ((block_offset & (alignment - 1)) == 0
+ && block_alignment >= alignment);
+ }
+
/* We have load-relative instructions for 2-byte, 4-byte, and
8-byte alignment so allow only these. */
switch (alignment)
@@ -16338,6 +16352,11 @@ s390_case_values_threshold (void)
#undef TARGET_CASE_VALUES_THRESHOLD
#define TARGET_CASE_VALUES_THRESHOLD s390_case_values_threshold
+/* Use only short displacement, since long displacement is not available for
+ the floating point instructions. */
+#undef TARGET_MAX_ANCHOR_OFFSET
+#define TARGET_MAX_ANCHOR_OFFSET 0xfff
+
struct gcc_target targetm = TARGET_INITIALIZER;
#include "gt-s390.h"
@@ -219,7 +219,7 @@ extern void assemble_external (tree);
extern void assemble_zeros (unsigned HOST_WIDE_INT);
/* Assemble an alignment pseudo op for an ALIGN-bit boundary. */
-extern void assemble_align (int);
+extern void assemble_align (unsigned int);
/* Assemble a string constant with the specified C string as contents. */
extern void assemble_string (const char *, int);
@@ -29,7 +29,7 @@ bar (int b)
a = b;
}
-/* { dg-final { scan-assembler-times "a@GOTENT" 3 } } */
+/* { dg-final { scan-assembler-times "\\.LANCHOR\\d+@GOTENT" 3 } } */
/* The exrl target is a label_ref which should not be affected at
all. */
new file mode 100644
@@ -0,0 +1,14 @@
+/* Test basic section anchor functionality. */
+
+/* { dg-do compile { target { lp64 } } } */
+/* { dg-options "-O3 -march=z13" } */
+
+int a = 1, b = 2;
+
+void
+f ()
+{
+ a = 1234;
+ b = 5678;
+ /* { dg-final { scan-assembler {(?n)\n\tlarl\t(%r\d+),\.LANCHOR\d+\n\tmvhi\t\d+\(\1\),1234\n\tmvhi\t\d+\(\1\),5678} } } */
+}
new file mode 100644
@@ -0,0 +1,26 @@
+/* Test corner case when LG from literal pool could be preferred to LARL. */
+
+/* { dg-do compile { target { lp64 } } } */
+/* { dg-options "-O3 -march=z13" } */
+
+int e = 42;
+int *c = &e;
+
+void
+h (int *i)
+{
+ c = i;
+}
+
+void
+j ()
+{
+ h (&e);
+ /* { dg-final { scan-assembler {(?n)\n\tlarl\t.+\n\tstgrl\t.+\n\tbr\t%r14\n} } } */
+}
+
+void
+f ()
+{
+ h (c);
+}
new file mode 100644
@@ -0,0 +1,11 @@
+/* Test corner case when LG from literal pool could be preferred to LARL. */
+
+/* { dg-do compile { target { lp64 } } } */
+/* { dg-options "-O3 -march=z13" } */
+
+int
+a (int b)
+{
+ return b / 100;
+ /* { dg-final { scan-assembler-not {\n\t\.quad\t\.LC} } } */
+}
@@ -1974,7 +1974,7 @@ assemble_zeros (unsigned HOST_WIDE_INT size)
/* Assemble an alignment pseudo op for an ALIGN-bit boundary. */
void
-assemble_align (int align)
+assemble_align (unsigned int align)
{
if (align > BITS_PER_UNIT)
{