@@ -89,6 +89,7 @@
;; ZR -- Pointer with index register and short displacement.
;; ZS -- Pointer without index register but with long displacement.
;; ZT -- Pointer with index register and long displacement.
+;; ZL -- LARL operand when in 64-bit mode, otherwise nothing.
;;
;;
@@ -562,3 +563,7 @@
(define_address_constraint "ZT"
"Pointer with index register and long displacement."
(match_test "s390_mem_constraint (\"ZT\", op)"))
+
+(define_constraint "ZL"
+ "LARL operand when in 64-bit mode, otherwise nothing."
+ (match_test "TARGET_64BIT && larl_operand (op, VOIDmode)"))
@@ -3859,6 +3859,10 @@ legitimate_pic_operand_p (rtx op)
if (!SYMBOLIC_CONST (op))
return 1;
+ /* Accept addresses that can be expressed relative to (pc). */
+ if (larl_operand (op, VOIDmode))
+ return 1;
+
/* Reject everything else; must be handled
via emit_symbolic_move. */
return 0;
@@ -1729,21 +1729,11 @@
emit_symbolic_move (operands);
})
-(define_insn "*movdi_larl"
- [(set (match_operand:DI 0 "register_operand" "=d")
- (match_operand:DI 1 "larl_operand" "X"))]
- "TARGET_64BIT
- && !FP_REG_P (operands[0])"
- "larl\t%0,%1"
- [(set_attr "op_type" "RIL")
- (set_attr "type" "larl")
- (set_attr "z10prop" "z10_super_A1")])
-
(define_insn "*movdi_64"
[(set (match_operand:DI 0 "nonimmediate_operand"
- "=d, d, d, d, d, d, d, d,f,d,d,d,d,d,T,!*f,!*f,!*f,!R,!T,b,Q,d,t,Q,t,v,v,v,d,v,R")
+ "=d, d, d, d, d, d, d, d,f,d,d,d,d,d,T,!*f,!*f,!*f,!R,!T,b,Q,d,t,Q,t,v,v,v,d,v,R,d")
(match_operand:DI 1 "general_operand"
- " K,N0HD0,N1HD0,N2HD0,N3HD0,Os,N0SD0,N1SD0,d,f,L,b,d,T,d, *f, R, T,*f,*f,d,K,t,d,t,Q,K,v,d,v,R,v"))]
+ " K,N0HD0,N1HD0,N2HD0,N3HD0,Os,N0SD0,N1SD0,d,f,L,b,d,T,d, *f, R, T,*f,*f,d,K,t,d,t,Q,K,v,d,v,R,v,ZL"))]
"TARGET_ZARCH"
"@
lghi\t%0,%h1
@@ -1777,15 +1767,17 @@
vlvgg\t%v0,%1,0
vlgvg\t%0,%v1,0
vleg\t%v0,%1,0
- vsteg\t%v1,%0,0"
+ vsteg\t%v1,%0,0
+ larl\t%0,%1"
[(set_attr "op_type" "RI,RI,RI,RI,RI,RIL,RIL,RIL,RRE,RRE,RXY,RIL,RRE,RXY,
- RXY,RR,RX,RXY,RX,RXY,RIL,SIL,*,*,RS,RS,VRI,VRR,VRS,VRS,VRX,VRX")
+ RXY,RR,RX,RXY,RX,RXY,RIL,SIL,*,*,RS,RS,VRI,VRR,VRS,VRS,
+ VRX,VRX,RIL")
(set_attr "type" "*,*,*,*,*,*,*,*,floaddf,floaddf,la,larl,lr,load,store,
floaddf,floaddf,floaddf,fstoredf,fstoredf,larl,*,*,*,*,
- *,*,*,*,*,*,*")
+ *,*,*,*,*,*,*,larl")
(set_attr "cpu_facility" "*,*,*,*,*,extimm,extimm,extimm,dfp,dfp,longdisp,
z10,*,*,*,*,*,longdisp,*,longdisp,
- z10,z10,*,*,*,*,vx,vx,vx,vx,vx,vx")
+ z10,z10,*,*,*,*,vx,vx,vx,vx,vx,vx,*")
(set_attr "z10prop" "z10_fwd_A1,
z10_fwd_E1,
z10_fwd_E1,
@@ -1811,7 +1803,8 @@
*,
*,
*,
- *,*,*,*,*,*,*")
+ *,*,*,*,*,*,*,
+ z10_super_A1")
])
(define_split
new file mode 100644
@@ -0,0 +1,12 @@
+/* Test the maximum possible LARL offset. */
+/* { dg-do compile } */
+/* { dg-options "-O1" } */
+
+extern char a[] __attribute__ ((aligned (2)));
+extern char *b;
+
+void almost_huge()
+{
+ b = a + 0x7ffffffeULL;
+ /* { dg-final { scan-assembler {(?n)\n\tlarl\t%r\d+,a\+2147483646\n} } } */
+}
new file mode 100644
@@ -0,0 +1,12 @@
+/* Test the minimum LARL offset. */
+/* { dg-do compile } */
+/* { dg-options "-O1" } */
+
+extern char a[] __attribute__ ((aligned (2)));
+extern char *b;
+
+void almost_negative_huge()
+{
+ b = a - 0x80000000ULL;
+ /* { dg-final { scan-assembler {(?n)\n\tlarl\t%r\d+,a-2147483648\n} } } */
+}
new file mode 100644
@@ -0,0 +1,13 @@
+/* Test accesses to global array elements in PIC code. */
+/* { dg-do compile } */
+/* { dg-options "-O1 -fPIC" } */
+
+extern char a[] __attribute__ ((aligned (2)));
+extern char *b;
+
+void c()
+{
+ b = a + 4;
+ /* { dg-final { scan-assembler {(?n)\n\tlarl\t%r\d+,a@GOTENT\n} } } */
+ /* { dg-final { scan-assembler-not {(?n)\n\tlarl\t%r\d+,a[^@]} } } */
+}
new file mode 100644
@@ -0,0 +1,12 @@
+/* Test accesses to even global array elements. */
+/* { dg-do compile } */
+/* { dg-options "-O1" } */
+
+extern char a[] __attribute__ ((aligned (2)));
+extern char *b;
+
+void even()
+{
+ b = a + 4;
+ /* { dg-final { scan-assembler {(?n)\n\tlarl\t%r\d+,a\+4\n} } } */
+}
new file mode 100644
@@ -0,0 +1,12 @@
+/* Test minimum invalid LARL offset. */
+/* { dg-do compile } */
+/* { dg-options "-O1" } */
+
+extern char a[] __attribute__ ((aligned (2)));
+extern char *b;
+
+void huge()
+{
+ b = a + 0x80000000ULL;
+ /* { dg-final { scan-assembler-not {(?n)\n\tlarl\t%r\d+,a} } } */
+}
new file mode 100644
@@ -0,0 +1,12 @@
+/* Test maximum invalid LARL offset. */
+/* { dg-do compile } */
+/* { dg-options "-O1" } */
+
+extern char a[] __attribute__ ((aligned (2)));
+extern char *b;
+
+void negative_huge()
+{
+ b = a - 0x80000004ULL;
+ /* { dg-final { scan-assembler-not {(?n)\n\tlarl\t%r\d+,a} } } */
+}
new file mode 100644
@@ -0,0 +1,12 @@
+/* Test accesses to odd global array elements. */
+/* { dg-do compile } */
+/* { dg-options "-O1" } */
+
+extern char a[] __attribute__ ((aligned (2)));
+extern char *b;
+
+void odd()
+{
+ b = a + 1;
+ /* { dg-final { scan-assembler-not {(?n)\n\tlarl\t%r\d+,a} } } */
+}