Mark Wielaard 75fe92
From 3fbde55a5696c9273084ee2c44daca752e407597 Mon Sep 17 00:00:00 2001
Mark Wielaard 75fe92
From: Andreas Arnez <arnez@linux.ibm.com>
Mark Wielaard 75fe92
Date: Tue, 26 Jan 2021 15:06:47 +0100
Mark Wielaard 75fe92
Subject: [PATCH 01/13] s390x: Misc-insn-3, bitwise logical 3-way instructions
Mark Wielaard 75fe92
Mark Wielaard 75fe92
Add support for the instructions NCRK, NCGRK, NNRK, NNGRK, NORK, NOGRK,
Mark Wielaard 75fe92
NXRK, NXGRK, OCRK, and OCGRK.  Introduce a common helper and use it for
Mark Wielaard 75fe92
the existing instructions NRK, NGRK, XRK, XGRK, ORK, and OGRK as well.
Mark Wielaard 75fe92
---
Mark Wielaard 75fe92
 VEX/priv/guest_s390_toIR.c | 154 ++++++++++++++++++++++++++-----------
Mark Wielaard 75fe92
 1 file changed, 109 insertions(+), 45 deletions(-)
Mark Wielaard 75fe92
Mark Wielaard 75fe92
diff --git a/VEX/priv/guest_s390_toIR.c b/VEX/priv/guest_s390_toIR.c
Mark Wielaard 75fe92
index a73dcfb14..f8afd5b96 100644
Mark Wielaard 75fe92
--- a/VEX/priv/guest_s390_toIR.c
Mark Wielaard 75fe92
+++ b/VEX/priv/guest_s390_toIR.c
Mark Wielaard 75fe92
@@ -5022,8 +5022,12 @@ s390_irgen_NGR(UChar r1, UChar r2)
Mark Wielaard 75fe92
    return "ngr";
Mark Wielaard 75fe92
 }
Mark Wielaard 75fe92
 
Mark Wielaard 75fe92
+/* Helper for bitwise logical instructions with two 32-bit input operands and a
Mark Wielaard 75fe92
+   32-bit output operand.  `inv3' and `inv' indicate whether to invert (build
Mark Wielaard 75fe92
+   bitwise complement of) operand 3 or the result, respectively. */
Mark Wielaard 75fe92
 static const HChar *
Mark Wielaard 75fe92
-s390_irgen_NRK(UChar r3, UChar r1, UChar r2)
Mark Wielaard 75fe92
+s390_irgen_logicalK32(UChar r3, UChar r1, UChar r2,
Mark Wielaard 75fe92
+                      const HChar *mnem, IROp op, Bool inv3, Bool inv)
Mark Wielaard 75fe92
 {
Mark Wielaard 75fe92
    IRTemp op2 = newTemp(Ity_I32);
Mark Wielaard 75fe92
    IRTemp op3 = newTemp(Ity_I32);
Mark Wielaard 75fe92
@@ -5031,15 +5035,19 @@ s390_irgen_NRK(UChar r3, UChar r1, UChar r2)
Mark Wielaard 75fe92
 
Mark Wielaard 75fe92
    assign(op2, get_gpr_w1(r2));
Mark Wielaard 75fe92
    assign(op3, get_gpr_w1(r3));
Mark Wielaard 75fe92
-   assign(result, binop(Iop_And32, mkexpr(op2), mkexpr(op3)));
Mark Wielaard 75fe92
+   IRExpr* tmp = binop(op, mkexpr(op2),
Mark Wielaard 75fe92
+                       inv3 ? unop(Iop_Not32, mkexpr(op3)) : mkexpr(op3));
Mark Wielaard 75fe92
+   assign(result, inv ? unop(Iop_Not32, tmp) : tmp);
Mark Wielaard 75fe92
    s390_cc_thunk_putZ(S390_CC_OP_BITWISE, result);
Mark Wielaard 75fe92
    put_gpr_w1(r1, mkexpr(result));
Mark Wielaard 75fe92
 
Mark Wielaard 75fe92
-   return "nrk";
Mark Wielaard 75fe92
+   return mnem;
Mark Wielaard 75fe92
 }
Mark Wielaard 75fe92
 
Mark Wielaard 75fe92
+/* Same as s390_irgen_logicalK32, but for 64-bit operands. */
Mark Wielaard 75fe92
 static const HChar *
Mark Wielaard 75fe92
-s390_irgen_NGRK(UChar r3, UChar r1, UChar r2)
Mark Wielaard 75fe92
+s390_irgen_logicalK64(UChar r3, UChar r1, UChar r2,
Mark Wielaard 75fe92
+                      const HChar *mnem, IROp op, Bool inv3, Bool inv)
Mark Wielaard 75fe92
 {
Mark Wielaard 75fe92
    IRTemp op2 = newTemp(Ity_I64);
Mark Wielaard 75fe92
    IRTemp op3 = newTemp(Ity_I64);
Mark Wielaard 75fe92
@@ -5047,11 +5055,49 @@ s390_irgen_NGRK(UChar r3, UChar r1, UChar r2)
Mark Wielaard 75fe92
 
Mark Wielaard 75fe92
    assign(op2, get_gpr_dw0(r2));
Mark Wielaard 75fe92
    assign(op3, get_gpr_dw0(r3));
Mark Wielaard 75fe92
-   assign(result, binop(Iop_And64, mkexpr(op2), mkexpr(op3)));
Mark Wielaard 75fe92
+   IRExpr* tmp = binop(op, mkexpr(op2),
Mark Wielaard 75fe92
+                       inv3 ? unop(Iop_Not64, mkexpr(op3)) : mkexpr(op3));
Mark Wielaard 75fe92
+   assign(result, inv ? unop(Iop_Not64, tmp) : tmp);
Mark Wielaard 75fe92
    s390_cc_thunk_putZ(S390_CC_OP_BITWISE, result);
Mark Wielaard 75fe92
    put_gpr_dw0(r1, mkexpr(result));
Mark Wielaard 75fe92
 
Mark Wielaard 75fe92
-   return "ngrk";
Mark Wielaard 75fe92
+   return mnem;
Mark Wielaard 75fe92
+}
Mark Wielaard 75fe92
+
Mark Wielaard 75fe92
+static const HChar *
Mark Wielaard 75fe92
+s390_irgen_NRK(UChar r3, UChar r1, UChar r2)
Mark Wielaard 75fe92
+{
Mark Wielaard 75fe92
+   return s390_irgen_logicalK32(r3, r1, r2, "nrk", Iop_And32, False, False);
Mark Wielaard 75fe92
+}
Mark Wielaard 75fe92
+
Mark Wielaard 75fe92
+static const HChar *
Mark Wielaard 75fe92
+s390_irgen_NGRK(UChar r3, UChar r1, UChar r2)
Mark Wielaard 75fe92
+{
Mark Wielaard 75fe92
+   return s390_irgen_logicalK64(r3, r1, r2, "ngrk", Iop_And64, False, False);
Mark Wielaard 75fe92
+}
Mark Wielaard 75fe92
+
Mark Wielaard 75fe92
+static const HChar *
Mark Wielaard 75fe92
+s390_irgen_NCRK(UChar r3, UChar r1, UChar r2)
Mark Wielaard 75fe92
+{
Mark Wielaard 75fe92
+   return s390_irgen_logicalK32(r3, r1, r2, "ncrk", Iop_And32, True, False);
Mark Wielaard 75fe92
+}
Mark Wielaard 75fe92
+
Mark Wielaard 75fe92
+static const HChar *
Mark Wielaard 75fe92
+s390_irgen_NCGRK(UChar r3, UChar r1, UChar r2)
Mark Wielaard 75fe92
+{
Mark Wielaard 75fe92
+   return s390_irgen_logicalK64(r3, r1, r2, "ncgrk", Iop_And64, True, False);
Mark Wielaard 75fe92
+}
Mark Wielaard 75fe92
+
Mark Wielaard 75fe92
+static const HChar *
Mark Wielaard 75fe92
+s390_irgen_NNRK(UChar r3, UChar r1, UChar r2)
Mark Wielaard 75fe92
+{
Mark Wielaard 75fe92
+   return s390_irgen_logicalK32(r3, r1, r2, "nnrk", Iop_And32, False, True);
Mark Wielaard 75fe92
+}
Mark Wielaard 75fe92
+
Mark Wielaard 75fe92
+static const HChar *
Mark Wielaard 75fe92
+s390_irgen_NNGRK(UChar r3, UChar r1, UChar r2)
Mark Wielaard 75fe92
+{
Mark Wielaard 75fe92
+   return s390_irgen_logicalK64(r3, r1, r2, "nngrk", Iop_And64, False, True);
Mark Wielaard 75fe92
 }
Mark Wielaard 75fe92
 
Mark Wielaard 75fe92
 static const HChar *
Mark Wielaard 75fe92
@@ -7071,33 +7117,25 @@ s390_irgen_XGR(UChar r1, UChar r2)
Mark Wielaard 75fe92
 static const HChar *
Mark Wielaard 75fe92
 s390_irgen_XRK(UChar r3, UChar r1, UChar r2)
Mark Wielaard 75fe92
 {
Mark Wielaard 75fe92
-   IRTemp op2 = newTemp(Ity_I32);
Mark Wielaard 75fe92
-   IRTemp op3 = newTemp(Ity_I32);
Mark Wielaard 75fe92
-   IRTemp result = newTemp(Ity_I32);
Mark Wielaard 75fe92
-
Mark Wielaard 75fe92
-   assign(op2, get_gpr_w1(r2));
Mark Wielaard 75fe92
-   assign(op3, get_gpr_w1(r3));
Mark Wielaard 75fe92
-   assign(result, binop(Iop_Xor32, mkexpr(op2), mkexpr(op3)));
Mark Wielaard 75fe92
-   s390_cc_thunk_putZ(S390_CC_OP_BITWISE, result);
Mark Wielaard 75fe92
-   put_gpr_w1(r1, mkexpr(result));
Mark Wielaard 75fe92
-
Mark Wielaard 75fe92
-   return "xrk";
Mark Wielaard 75fe92
+   return s390_irgen_logicalK32(r3, r1, r2, "xrk", Iop_Xor32, False, False);
Mark Wielaard 75fe92
 }
Mark Wielaard 75fe92
 
Mark Wielaard 75fe92
 static const HChar *
Mark Wielaard 75fe92
 s390_irgen_XGRK(UChar r3, UChar r1, UChar r2)
Mark Wielaard 75fe92
 {
Mark Wielaard 75fe92
-   IRTemp op2 = newTemp(Ity_I64);
Mark Wielaard 75fe92
-   IRTemp op3 = newTemp(Ity_I64);
Mark Wielaard 75fe92
-   IRTemp result = newTemp(Ity_I64);
Mark Wielaard 75fe92
+   return s390_irgen_logicalK64(r3, r1, r2, "xgrk", Iop_Xor64, False, False);
Mark Wielaard 75fe92
+}
Mark Wielaard 75fe92
 
Mark Wielaard 75fe92
-   assign(op2, get_gpr_dw0(r2));
Mark Wielaard 75fe92
-   assign(op3, get_gpr_dw0(r3));
Mark Wielaard 75fe92
-   assign(result, binop(Iop_Xor64, mkexpr(op2), mkexpr(op3)));
Mark Wielaard 75fe92
-   s390_cc_thunk_putZ(S390_CC_OP_BITWISE, result);
Mark Wielaard 75fe92
-   put_gpr_dw0(r1, mkexpr(result));
Mark Wielaard 75fe92
+static const HChar *
Mark Wielaard 75fe92
+s390_irgen_NXRK(UChar r3, UChar r1, UChar r2)
Mark Wielaard 75fe92
+{
Mark Wielaard 75fe92
+   return s390_irgen_logicalK32(r3, r1, r2, "nxrk", Iop_Xor32, False, True);
Mark Wielaard 75fe92
+}
Mark Wielaard 75fe92
 
Mark Wielaard 75fe92
-   return "xgrk";
Mark Wielaard 75fe92
+static const HChar *
Mark Wielaard 75fe92
+s390_irgen_NXGRK(UChar r3, UChar r1, UChar r2)
Mark Wielaard 75fe92
+{
Mark Wielaard 75fe92
+   return s390_irgen_logicalK64(r3, r1, r2, "nxgrk", Iop_Xor64, False, True);
Mark Wielaard 75fe92
 }
Mark Wielaard 75fe92
 
Mark Wielaard 75fe92
 static const HChar *
Mark Wielaard 75fe92
@@ -8920,33 +8958,37 @@ s390_irgen_OGR(UChar r1, UChar r2)
Mark Wielaard 75fe92
 static const HChar *
Mark Wielaard 75fe92
 s390_irgen_ORK(UChar r3, UChar r1, UChar r2)
Mark Wielaard 75fe92
 {
Mark Wielaard 75fe92
-   IRTemp op2 = newTemp(Ity_I32);
Mark Wielaard 75fe92
-   IRTemp op3 = newTemp(Ity_I32);
Mark Wielaard 75fe92
-   IRTemp result = newTemp(Ity_I32);
Mark Wielaard 75fe92
+   return s390_irgen_logicalK32(r3, r1, r2, "ork", Iop_Or32, False, False);
Mark Wielaard 75fe92
+}
Mark Wielaard 75fe92
 
Mark Wielaard 75fe92
-   assign(op2, get_gpr_w1(r2));
Mark Wielaard 75fe92
-   assign(op3, get_gpr_w1(r3));
Mark Wielaard 75fe92
-   assign(result, binop(Iop_Or32, mkexpr(op2), mkexpr(op3)));
Mark Wielaard 75fe92
-   s390_cc_thunk_putZ(S390_CC_OP_BITWISE, result);
Mark Wielaard 75fe92
-   put_gpr_w1(r1, mkexpr(result));
Mark Wielaard 75fe92
+static const HChar *
Mark Wielaard 75fe92
+s390_irgen_OGRK(UChar r3, UChar r1, UChar r2)
Mark Wielaard 75fe92
+{
Mark Wielaard 75fe92
+   return s390_irgen_logicalK64(r3, r1, r2, "ogrk", Iop_Or64, False, False);
Mark Wielaard 75fe92
+}
Mark Wielaard 75fe92
 
Mark Wielaard 75fe92
-   return "ork";
Mark Wielaard 75fe92
+static const HChar *
Mark Wielaard 75fe92
+s390_irgen_OCRK(UChar r3, UChar r1, UChar r2)
Mark Wielaard 75fe92
+{
Mark Wielaard 75fe92
+   return s390_irgen_logicalK32(r3, r1, r2, "ocrk", Iop_Or32, True, False);
Mark Wielaard 75fe92
 }
Mark Wielaard 75fe92
 
Mark Wielaard 75fe92
 static const HChar *
Mark Wielaard 75fe92
-s390_irgen_OGRK(UChar r3, UChar r1, UChar r2)
Mark Wielaard 75fe92
+s390_irgen_OCGRK(UChar r3, UChar r1, UChar r2)
Mark Wielaard 75fe92
 {
Mark Wielaard 75fe92
-   IRTemp op2 = newTemp(Ity_I64);
Mark Wielaard 75fe92
-   IRTemp op3 = newTemp(Ity_I64);
Mark Wielaard 75fe92
-   IRTemp result = newTemp(Ity_I64);
Mark Wielaard 75fe92
+   return s390_irgen_logicalK64(r3, r1, r2, "ocgrk", Iop_Or64, True, False);
Mark Wielaard 75fe92
+}
Mark Wielaard 75fe92
 
Mark Wielaard 75fe92
-   assign(op2, get_gpr_dw0(r2));
Mark Wielaard 75fe92
-   assign(op3, get_gpr_dw0(r3));
Mark Wielaard 75fe92
-   assign(result, binop(Iop_Or64, mkexpr(op2), mkexpr(op3)));
Mark Wielaard 75fe92
-   s390_cc_thunk_putZ(S390_CC_OP_BITWISE, result);
Mark Wielaard 75fe92
-   put_gpr_dw0(r1, mkexpr(result));
Mark Wielaard 75fe92
+static const HChar *
Mark Wielaard 75fe92
+s390_irgen_NORK(UChar r3, UChar r1, UChar r2)
Mark Wielaard 75fe92
+{
Mark Wielaard 75fe92
+   return s390_irgen_logicalK32(r3, r1, r2, "nork", Iop_Or32, False, True);
Mark Wielaard 75fe92
+}
Mark Wielaard 75fe92
 
Mark Wielaard 75fe92
-   return "ogrk";
Mark Wielaard 75fe92
+static const HChar *
Mark Wielaard 75fe92
+s390_irgen_NOGRK(UChar r3, UChar r1, UChar r2)
Mark Wielaard 75fe92
+{
Mark Wielaard 75fe92
+   return s390_irgen_logicalK64(r3, r1, r2, "nogrk", Iop_Or64, False, True);
Mark Wielaard 75fe92
 }
Mark Wielaard 75fe92
 
Mark Wielaard 75fe92
 static const HChar *
Mark Wielaard 75fe92
@@ -20031,12 +20073,28 @@ s390_decode_4byte_and_irgen(const UChar *bytes)
Mark Wielaard 75fe92
    case 0xb961: s390_format_RRF_U0RR(s390_irgen_CLGRT, RRF2_m3(ovl),
Mark Wielaard 75fe92
                                      RRF2_r1(ovl), RRF2_r2(ovl),
Mark Wielaard 75fe92
                                      S390_XMNM_CAB); goto ok;
Mark Wielaard 75fe92
+   case 0xb964: s390_format_RRF_R0RR2(s390_irgen_NNGRK, RRF4_r3(ovl),
Mark Wielaard 75fe92
+                                      RRF4_r1(ovl), RRF4_r2(ovl)); goto ok;
Mark Wielaard 75fe92
+   case 0xb965: s390_format_RRF_R0RR2(s390_irgen_OCGRK, RRF4_r3(ovl),
Mark Wielaard 75fe92
+                                      RRF4_r1(ovl), RRF4_r2(ovl)); goto ok;
Mark Wielaard 75fe92
+   case 0xb966: s390_format_RRF_R0RR2(s390_irgen_NOGRK, RRF4_r3(ovl),
Mark Wielaard 75fe92
+                                      RRF4_r1(ovl), RRF4_r2(ovl)); goto ok;
Mark Wielaard 75fe92
+   case 0xb967: s390_format_RRF_R0RR2(s390_irgen_NXGRK, RRF4_r3(ovl),
Mark Wielaard 75fe92
+                                      RRF4_r1(ovl), RRF4_r2(ovl)); goto ok;
Mark Wielaard 75fe92
    case 0xb972: s390_format_RRF_U0RR(s390_irgen_CRT, RRF2_m3(ovl),
Mark Wielaard 75fe92
                                      RRF2_r1(ovl), RRF2_r2(ovl),
Mark Wielaard 75fe92
                                      S390_XMNM_CAB); goto ok;
Mark Wielaard 75fe92
    case 0xb973: s390_format_RRF_U0RR(s390_irgen_CLRT, RRF2_m3(ovl),
Mark Wielaard 75fe92
                                      RRF2_r1(ovl), RRF2_r2(ovl),
Mark Wielaard 75fe92
                                      S390_XMNM_CAB); goto ok;
Mark Wielaard 75fe92
+   case 0xb974: s390_format_RRF_R0RR2(s390_irgen_NNRK, RRF4_r3(ovl),
Mark Wielaard 75fe92
+                                      RRF4_r1(ovl), RRF4_r2(ovl)); goto ok;
Mark Wielaard 75fe92
+   case 0xb975: s390_format_RRF_R0RR2(s390_irgen_OCRK, RRF4_r3(ovl),
Mark Wielaard 75fe92
+                                      RRF4_r1(ovl), RRF4_r2(ovl)); goto ok;
Mark Wielaard 75fe92
+   case 0xb976: s390_format_RRF_R0RR2(s390_irgen_NORK, RRF4_r3(ovl),
Mark Wielaard 75fe92
+                                      RRF4_r1(ovl), RRF4_r2(ovl)); goto ok;
Mark Wielaard 75fe92
+   case 0xb977: s390_format_RRF_R0RR2(s390_irgen_NXRK, RRF4_r3(ovl),
Mark Wielaard 75fe92
+                                      RRF4_r1(ovl), RRF4_r2(ovl)); goto ok;
Mark Wielaard 75fe92
    case 0xb980: s390_format_RRE_RR(s390_irgen_NGR, RRE_r1(ovl),
Mark Wielaard 75fe92
                                    RRE_r2(ovl));  goto ok;
Mark Wielaard 75fe92
    case 0xb981: s390_format_RRE_RR(s390_irgen_OGR, RRE_r1(ovl),
Mark Wielaard 75fe92
@@ -20148,6 +20206,9 @@ s390_decode_4byte_and_irgen(const UChar *bytes)
Mark Wielaard 75fe92
    case 0xb9e4: s390_format_RRF_R0RR2(s390_irgen_NGRK, RRF4_r3(ovl),
Mark Wielaard 75fe92
                                       RRF4_r1(ovl), RRF4_r2(ovl));
Mark Wielaard 75fe92
                                       goto ok;
Mark Wielaard 75fe92
+   case 0xb9e5: s390_format_RRF_R0RR2(s390_irgen_NCGRK, RRF4_r3(ovl),
Mark Wielaard 75fe92
+                                      RRF4_r1(ovl), RRF4_r2(ovl));
Mark Wielaard 75fe92
+                                      goto ok;
Mark Wielaard 75fe92
    case 0xb9e6: s390_format_RRF_R0RR2(s390_irgen_OGRK, RRF4_r3(ovl),
Mark Wielaard 75fe92
                                       RRF4_r1(ovl), RRF4_r2(ovl));
Mark Wielaard 75fe92
                                       goto ok;
Mark Wielaard 75fe92
@@ -20178,6 +20239,9 @@ s390_decode_4byte_and_irgen(const UChar *bytes)
Mark Wielaard 75fe92
    case 0xb9f4: s390_format_RRF_R0RR2(s390_irgen_NRK, RRF4_r3(ovl),
Mark Wielaard 75fe92
                                       RRF4_r1(ovl), RRF4_r2(ovl));
Mark Wielaard 75fe92
                                       goto ok;
Mark Wielaard 75fe92
+   case 0xb9f5: s390_format_RRF_R0RR2(s390_irgen_NCRK, RRF4_r3(ovl),
Mark Wielaard 75fe92
+                                      RRF4_r1(ovl), RRF4_r2(ovl));
Mark Wielaard 75fe92
+                                      goto ok;
Mark Wielaard 75fe92
    case 0xb9f6: s390_format_RRF_R0RR2(s390_irgen_ORK, RRF4_r3(ovl),
Mark Wielaard 75fe92
                                       RRF4_r1(ovl), RRF4_r2(ovl));
Mark Wielaard 75fe92
                                       goto ok;
Mark Wielaard 75fe92
-- 
Mark Wielaard 75fe92
2.23.0
Mark Wielaard 75fe92
Mark Wielaard 75fe92
From 748421b31ab6b15cc849bd6b9588ad759b807324 Mon Sep 17 00:00:00 2001
Mark Wielaard 75fe92
From: Andreas Arnez <arnez@linux.ibm.com>
Mark Wielaard 75fe92
Date: Wed, 27 Jan 2021 18:11:06 +0100
Mark Wielaard 75fe92
Subject: [PATCH 02/13] s390x: Misc-insn-3, "select" instructions
Mark Wielaard 75fe92
Mark Wielaard 75fe92
Add support for the instructions SELR, SELGR, and SELFHR.
Mark Wielaard 75fe92
---
Mark Wielaard 75fe92
 VEX/priv/guest_s390_toIR.c | 43 ++++++++++++++++++++++++++++++++++++++
Mark Wielaard 75fe92
 1 file changed, 43 insertions(+)
Mark Wielaard 75fe92
Mark Wielaard 75fe92
diff --git a/VEX/priv/guest_s390_toIR.c b/VEX/priv/guest_s390_toIR.c
Mark Wielaard 75fe92
index f8afd5b96..41265631b 100644
Mark Wielaard 75fe92
--- a/VEX/priv/guest_s390_toIR.c
Mark Wielaard 75fe92
+++ b/VEX/priv/guest_s390_toIR.c
Mark Wielaard 75fe92
@@ -3113,6 +3113,16 @@ s390_format_RRF_FUFF2(const HChar *(*irgen)(UChar, UChar, UChar, UChar),
Mark Wielaard 75fe92
       s390_disasm(ENC5(MNM, FPR, FPR, FPR, UINT), mnm, r1, r2, r3, m4);
Mark Wielaard 75fe92
 }
Mark Wielaard 75fe92
 
Mark Wielaard 75fe92
+static void
Mark Wielaard 75fe92
+s390_format_RRF_RURR(const HChar *(*irgen)(UChar, UChar, UChar, UChar),
Mark Wielaard 75fe92
+                     UChar r3, UChar m4, UChar r1, UChar r2)
Mark Wielaard 75fe92
+{
Mark Wielaard 75fe92
+   const HChar *mnm = irgen(r3, m4, r1, r2);
Mark Wielaard 75fe92
+
Mark Wielaard 75fe92
+   if (UNLIKELY(vex_traceflags & VEX_TRACE_FE))
Mark Wielaard 75fe92
+      s390_disasm(ENC5(MNM, GPR, GPR, GPR, UINT), mnm, r1, r3, r2, m4);
Mark Wielaard 75fe92
+}
Mark Wielaard 75fe92
+
Mark Wielaard 75fe92
 static void
Mark Wielaard 75fe92
 s390_format_RRF_R0RR2(const HChar *(*irgen)(UChar r3, UChar r1, UChar r2),
Mark Wielaard 75fe92
                       UChar r3, UChar r1, UChar r2)
Mark Wielaard 75fe92
@@ -19254,6 +19264,30 @@ s390_irgen_VBPERM(UChar v1, UChar v2, UChar v3)
Mark Wielaard 75fe92
    return "vbperm";
Mark Wielaard 75fe92
 }
Mark Wielaard 75fe92
 
Mark Wielaard 75fe92
+static const HChar *
Mark Wielaard 75fe92
+s390_irgen_SELR(UChar r3, UChar m4, UChar r1, UChar r2)
Mark Wielaard 75fe92
+{
Mark Wielaard 75fe92
+   IRExpr* cond = binop(Iop_CmpNE32, s390_call_calculate_cond(m4), mkU32(0));
Mark Wielaard 75fe92
+   put_gpr_w1(r1, mkite(cond, get_gpr_w1(r2), get_gpr_w1(r3)));
Mark Wielaard 75fe92
+   return "selr";
Mark Wielaard 75fe92
+}
Mark Wielaard 75fe92
+
Mark Wielaard 75fe92
+static const HChar *
Mark Wielaard 75fe92
+s390_irgen_SELGR(UChar r3, UChar m4, UChar r1, UChar r2)
Mark Wielaard 75fe92
+{
Mark Wielaard 75fe92
+   IRExpr* cond = binop(Iop_CmpNE32, s390_call_calculate_cond(m4), mkU32(0));
Mark Wielaard 75fe92
+   put_gpr_dw0(r1, mkite(cond, get_gpr_dw0(r2), get_gpr_dw0(r3)));
Mark Wielaard 75fe92
+   return "selgr";
Mark Wielaard 75fe92
+}
Mark Wielaard 75fe92
+
Mark Wielaard 75fe92
+static const HChar *
Mark Wielaard 75fe92
+s390_irgen_SELFHR(UChar r3, UChar m4, UChar r1, UChar r2)
Mark Wielaard 75fe92
+{
Mark Wielaard 75fe92
+   IRExpr* cond = binop(Iop_CmpNE32, s390_call_calculate_cond(m4), mkU32(0));
Mark Wielaard 75fe92
+   put_gpr_w0(r1, mkite(cond, get_gpr_w0(r2), get_gpr_w0(r3)));
Mark Wielaard 75fe92
+   return "selfhr";
Mark Wielaard 75fe92
+}
Mark Wielaard 75fe92
+
Mark Wielaard 75fe92
 /* New insns are added here.
Mark Wielaard 75fe92
    If an insn is contingent on a facility being installed also
Mark Wielaard 75fe92
    check whether the list of supported facilities in function
Mark Wielaard 75fe92
@@ -20163,6 +20197,9 @@ s390_decode_4byte_and_irgen(const UChar *bytes)
Mark Wielaard 75fe92
    case 0xb9bd: /* TRTRE */ goto unimplemented;
Mark Wielaard 75fe92
    case 0xb9be: /* SRSTU */ goto unimplemented;
Mark Wielaard 75fe92
    case 0xb9bf: /* TRTE */ goto unimplemented;
Mark Wielaard 75fe92
+   case 0xb9c0: s390_format_RRF_RURR(s390_irgen_SELFHR, RRF4_r3(ovl),
Mark Wielaard 75fe92
+                                     RRF4_m4(ovl), RRF4_r1(ovl),
Mark Wielaard 75fe92
+                                     RRF4_r2(ovl)); goto ok;
Mark Wielaard 75fe92
    case 0xb9c8: s390_format_RRF_R0RR2(s390_irgen_AHHHR, RRF4_r3(ovl),
Mark Wielaard 75fe92
                                       RRF4_r1(ovl), RRF4_r2(ovl));
Mark Wielaard 75fe92
                                       goto ok;
Mark Wielaard 75fe92
@@ -20203,6 +20240,9 @@ s390_decode_4byte_and_irgen(const UChar *bytes)
Mark Wielaard 75fe92
    case 0xb9e2: s390_format_RRF_U0RR(s390_irgen_LOCGR, RRF3_r3(ovl),
Mark Wielaard 75fe92
                                      RRF3_r1(ovl), RRF3_r2(ovl),
Mark Wielaard 75fe92
                                      S390_XMNM_LOCGR);  goto ok;
Mark Wielaard 75fe92
+   case 0xb9e3: s390_format_RRF_RURR(s390_irgen_SELGR, RRF4_r3(ovl),
Mark Wielaard 75fe92
+                                     RRF4_m4(ovl), RRF4_r1(ovl),
Mark Wielaard 75fe92
+                                     RRF4_r2(ovl)); goto ok;
Mark Wielaard 75fe92
    case 0xb9e4: s390_format_RRF_R0RR2(s390_irgen_NGRK, RRF4_r3(ovl),
Mark Wielaard 75fe92
                                       RRF4_r1(ovl), RRF4_r2(ovl));
Mark Wielaard 75fe92
                                       goto ok;
Mark Wielaard 75fe92
@@ -20233,6 +20273,9 @@ s390_decode_4byte_and_irgen(const UChar *bytes)
Mark Wielaard 75fe92
    case 0xb9ed: s390_format_RRF_R0RR2(s390_irgen_MSGRKC, RRF4_r3(ovl),
Mark Wielaard 75fe92
                                       RRF4_r1(ovl), RRF4_r2(ovl));
Mark Wielaard 75fe92
                                       goto ok;
Mark Wielaard 75fe92
+   case 0xb9f0: s390_format_RRF_RURR(s390_irgen_SELR, RRF4_r3(ovl),
Mark Wielaard 75fe92
+                                     RRF4_m4(ovl), RRF4_r1(ovl),
Mark Wielaard 75fe92
+                                     RRF4_r2(ovl)); goto ok;
Mark Wielaard 75fe92
    case 0xb9f2: s390_format_RRF_U0RR(s390_irgen_LOCR, RRF3_r3(ovl),
Mark Wielaard 75fe92
                                      RRF3_r1(ovl), RRF3_r2(ovl),
Mark Wielaard 75fe92
                                      S390_XMNM_LOCR);  goto ok;
Mark Wielaard 75fe92
-- 
Mark Wielaard 75fe92
2.23.0
Mark Wielaard 75fe92
Mark Wielaard 75fe92
From 31cbd583e858f47a86ada087d21a6abc13ba04f2 Mon Sep 17 00:00:00 2001
Mark Wielaard 75fe92
From: Andreas Arnez <arnez@linux.ibm.com>
Mark Wielaard 75fe92
Date: Thu, 28 Jan 2021 19:47:00 +0100
Mark Wielaard 75fe92
Subject: [PATCH 03/13] s390x: Misc-insn-3, new POPCNT variant
Mark Wielaard 75fe92
Mark Wielaard 75fe92
Add support for the new POPCNT variant that has bit 0 of the M3 field set
Mark Wielaard 75fe92
and yields the total number of one bits in its 64-bit operand.
Mark Wielaard 75fe92
---
Mark Wielaard 75fe92
 VEX/priv/guest_s390_toIR.c | 44 ++++++++++++++++++++++++++------------
Mark Wielaard 75fe92
 1 file changed, 30 insertions(+), 14 deletions(-)
Mark Wielaard 75fe92
Mark Wielaard 75fe92
diff --git a/VEX/priv/guest_s390_toIR.c b/VEX/priv/guest_s390_toIR.c
Mark Wielaard 75fe92
index 41265631b..ca9e6dc03 100644
Mark Wielaard 75fe92
--- a/VEX/priv/guest_s390_toIR.c
Mark Wielaard 75fe92
+++ b/VEX/priv/guest_s390_toIR.c
Mark Wielaard 75fe92
@@ -3073,6 +3073,20 @@ s390_format_RRF_U0RR(const HChar *(*irgen)(UChar m3, UChar r1, UChar r2),
Mark Wielaard 75fe92
       s390_disasm(ENC3(XMNM, GPR, GPR), xmnm_kind, m3, r1, r2);
Mark Wielaard 75fe92
 }
Mark Wielaard 75fe92
 
Mark Wielaard 75fe92
+static void
Mark Wielaard 75fe92
+s390_format_RRFa_U0RR(const HChar *(*irgen)(UChar m3, UChar r1, UChar r2),
Mark Wielaard 75fe92
+                      UChar m3, UChar r1, UChar r2)
Mark Wielaard 75fe92
+{
Mark Wielaard 75fe92
+   const HChar *mnm = irgen(m3, r1, r2);
Mark Wielaard 75fe92
+
Mark Wielaard 75fe92
+   if (UNLIKELY(vex_traceflags & VEX_TRACE_FE)) {
Mark Wielaard 75fe92
+      if (m3 != 0)
Mark Wielaard 75fe92
+         s390_disasm(ENC4(MNM, GPR, GPR, UINT), mnm, r1, r2, m3);
Mark Wielaard 75fe92
+      else
Mark Wielaard 75fe92
+         s390_disasm(ENC3(MNM, GPR, GPR), mnm, r1, r2);
Mark Wielaard 75fe92
+   }
Mark Wielaard 75fe92
+}
Mark Wielaard 75fe92
+
Mark Wielaard 75fe92
 static void
Mark Wielaard 75fe92
 s390_format_RRF_F0FF2(const HChar *(*irgen)(UChar, UChar, UChar),
Mark Wielaard 75fe92
                       UChar r3, UChar r1, UChar r2)
Mark Wielaard 75fe92
@@ -15112,30 +15126,32 @@ s390_irgen_FLOGR(UChar r1, UChar r2)
Mark Wielaard 75fe92
 }
Mark Wielaard 75fe92
 
Mark Wielaard 75fe92
 static const HChar *
Mark Wielaard 75fe92
-s390_irgen_POPCNT(UChar r1, UChar r2)
Mark Wielaard 75fe92
+s390_irgen_POPCNT(UChar m3, UChar r1, UChar r2)
Mark Wielaard 75fe92
 {
Mark Wielaard 75fe92
-   Int i;
Mark Wielaard 75fe92
+   s390_insn_assert("popcnt", (m3 & 7) == 0);
Mark Wielaard 75fe92
+
Mark Wielaard 75fe92
+   static const ULong masks[] = {
Mark Wielaard 75fe92
+      0x5555555555555555, 0x3333333333333333, 0x0F0F0F0F0F0F0F0F,
Mark Wielaard 75fe92
+      0x00FF00FF00FF00FF, 0x0000FFFF0000FFFF, 0x00000000FFFFFFFF,
Mark Wielaard 75fe92
+   };
Mark Wielaard 75fe92
+   Int i, n;
Mark Wielaard 75fe92
    IRTemp val = newTemp(Ity_I64);
Mark Wielaard 75fe92
-   IRTemp mask[3];
Mark Wielaard 75fe92
 
Mark Wielaard 75fe92
    assign(val, get_gpr_dw0(r2));
Mark Wielaard 75fe92
-   for (i = 0; i < 3; i++) {
Mark Wielaard 75fe92
-      mask[i] = newTemp(Ity_I64);
Mark Wielaard 75fe92
-   }
Mark Wielaard 75fe92
-   assign(mask[0], mkU64(0x5555555555555555ULL));
Mark Wielaard 75fe92
-   assign(mask[1], mkU64(0x3333333333333333ULL));
Mark Wielaard 75fe92
-   assign(mask[2], mkU64(0x0F0F0F0F0F0F0F0FULL));
Mark Wielaard 75fe92
-   for (i = 0; i < 3; i++) {
Mark Wielaard 75fe92
+   n = (m3 & 8) ? 6 : 3;
Mark Wielaard 75fe92
+   for (i = 0; i < n; i++) {
Mark Wielaard 75fe92
+      IRTemp mask = newTemp(Ity_I64);
Mark Wielaard 75fe92
       IRTemp tmp = newTemp(Ity_I64);
Mark Wielaard 75fe92
 
Mark Wielaard 75fe92
+      assign (mask, mkU64(masks[i]));
Mark Wielaard 75fe92
       assign(tmp,
Mark Wielaard 75fe92
              binop(Iop_Add64,
Mark Wielaard 75fe92
                    binop(Iop_And64,
Mark Wielaard 75fe92
                          mkexpr(val),
Mark Wielaard 75fe92
-                         mkexpr(mask[i])),
Mark Wielaard 75fe92
+                         mkexpr(mask)),
Mark Wielaard 75fe92
                    binop(Iop_And64,
Mark Wielaard 75fe92
                          binop(Iop_Shr64, mkexpr(val), mkU8(1 << i)),
Mark Wielaard 75fe92
-                         mkexpr(mask[i]))));
Mark Wielaard 75fe92
+                         mkexpr(mask))));
Mark Wielaard 75fe92
       val = tmp;
Mark Wielaard 75fe92
    }
Mark Wielaard 75fe92
    s390_cc_thunk_putZ(S390_CC_OP_BITWISE, val);
Mark Wielaard 75fe92
@@ -20235,8 +20251,8 @@ s390_decode_4byte_and_irgen(const UChar *bytes)
Mark Wielaard 75fe92
    case 0xb9e0: s390_format_RRF_U0RR(s390_irgen_LOCFHR, RRF3_r3(ovl),
Mark Wielaard 75fe92
                                      RRF3_r1(ovl), RRF3_r2(ovl),
Mark Wielaard 75fe92
                                      S390_XMNM_LOCFHR);  goto ok;
Mark Wielaard 75fe92
-   case 0xb9e1: s390_format_RRE_RR(s390_irgen_POPCNT, RRE_r1(ovl),
Mark Wielaard 75fe92
-                                   RRE_r2(ovl));  goto ok;
Mark Wielaard 75fe92
+   case 0xb9e1: s390_format_RRFa_U0RR(s390_irgen_POPCNT, RRF3_r3(ovl),
Mark Wielaard 75fe92
+                                      RRF3_r1(ovl), RRF3_r2(ovl));  goto ok;
Mark Wielaard 75fe92
    case 0xb9e2: s390_format_RRF_U0RR(s390_irgen_LOCGR, RRF3_r3(ovl),
Mark Wielaard 75fe92
                                      RRF3_r1(ovl), RRF3_r2(ovl),
Mark Wielaard 75fe92
                                      S390_XMNM_LOCGR);  goto ok;
Mark Wielaard 75fe92
-- 
Mark Wielaard 75fe92
2.23.0
Mark Wielaard 75fe92
Mark Wielaard 75fe92
From 64352d57f93711ce76fd481558dcf6d65e26b19f Mon Sep 17 00:00:00 2001
Mark Wielaard 75fe92
From: Andreas Arnez <arnez@linux.ibm.com>
Mark Wielaard 75fe92
Date: Fri, 29 Jan 2021 20:13:05 +0100
Mark Wielaard 75fe92
Subject: [PATCH 04/13] s390x: Misc-insn-3, MVCRL
Mark Wielaard 75fe92
Mark Wielaard 75fe92
Add support for the "move right to left" instruction MVCRL.
Mark Wielaard 75fe92
---
Mark Wielaard 75fe92
 VEX/priv/guest_s390_toIR.c | 47 ++++++++++++++++++++++++++++++++++++++
Mark Wielaard 75fe92
 1 file changed, 47 insertions(+)
Mark Wielaard 75fe92
Mark Wielaard 75fe92
diff --git a/VEX/priv/guest_s390_toIR.c b/VEX/priv/guest_s390_toIR.c
Mark Wielaard 75fe92
index ca9e6dc03..9f7d98f8c 100644
Mark Wielaard 75fe92
--- a/VEX/priv/guest_s390_toIR.c
Mark Wielaard 75fe92
+++ b/VEX/priv/guest_s390_toIR.c
Mark Wielaard 75fe92
@@ -3562,6 +3562,25 @@ s390_format_SS_L0RDRD(const HChar *(*irgen)(UChar, IRTemp, IRTemp),
Mark Wielaard 75fe92
       s390_disasm(ENC3(MNM, UDLB, UDXB), mnm, d1, l, b1, d2, 0, b2);
Mark Wielaard 75fe92
 }
Mark Wielaard 75fe92
 
Mark Wielaard 75fe92
+static void
Mark Wielaard 75fe92
+s390_format_SSE_RDRD(const HChar *(*irgen)(IRTemp, IRTemp),
Mark Wielaard 75fe92
+                     UChar b1, UShort d1, UChar b2, UShort d2)
Mark Wielaard 75fe92
+{
Mark Wielaard 75fe92
+   const HChar *mnm;
Mark Wielaard 75fe92
+   IRTemp op1addr = newTemp(Ity_I64);
Mark Wielaard 75fe92
+   IRTemp op2addr = newTemp(Ity_I64);
Mark Wielaard 75fe92
+
Mark Wielaard 75fe92
+   assign(op1addr, binop(Iop_Add64, mkU64(d1), b1 != 0 ? get_gpr_dw0(b1) :
Mark Wielaard 75fe92
+          mkU64(0)));
Mark Wielaard 75fe92
+   assign(op2addr, binop(Iop_Add64, mkU64(d2), b2 != 0 ? get_gpr_dw0(b2) :
Mark Wielaard 75fe92
+          mkU64(0)));
Mark Wielaard 75fe92
+
Mark Wielaard 75fe92
+   mnm = irgen(op1addr, op2addr);
Mark Wielaard 75fe92
+
Mark Wielaard 75fe92
+   if (UNLIKELY(vex_traceflags & VEX_TRACE_FE))
Mark Wielaard 75fe92
+      s390_disasm(ENC2(UDXB, UDXB), mnm, d1, 0, b1, d2, 0, b2);
Mark Wielaard 75fe92
+}
Mark Wielaard 75fe92
+
Mark Wielaard 75fe92
 static void
Mark Wielaard 75fe92
 s390_format_SIL_RDI(const HChar *(*irgen)(UShort i2, IRTemp op1addr),
Mark Wielaard 75fe92
                     UChar b1, UShort d1, UShort i2)
Mark Wielaard 75fe92
@@ -13667,6 +13686,31 @@ s390_irgen_MVCIN(UChar length, IRTemp start1, IRTemp start2)
Mark Wielaard 75fe92
    return "mvcin";
Mark Wielaard 75fe92
 }
Mark Wielaard 75fe92
 
Mark Wielaard 75fe92
+static const HChar *
Mark Wielaard 75fe92
+s390_irgen_MVCRL(IRTemp op1addr, IRTemp op2addr)
Mark Wielaard 75fe92
+{
Mark Wielaard 75fe92
+   IRTemp counter = newTemp(Ity_I64);
Mark Wielaard 75fe92
+   IRTemp offset = newTemp(Ity_I64);
Mark Wielaard 75fe92
+
Mark Wielaard 75fe92
+   assign(counter, get_counter_dw0());
Mark Wielaard 75fe92
+   /* offset = length - 1 - counter, where length-1 is specified in r0 */
Mark Wielaard 75fe92
+   assign(offset,
Mark Wielaard 75fe92
+          binop(Iop_Sub64,
Mark Wielaard 75fe92
+                unop(Iop_16Uto64,
Mark Wielaard 75fe92
+                     binop(Iop_And16, get_gpr_hw3(0), mkU16(0xfff))),
Mark Wielaard 75fe92
+                mkexpr(counter)));
Mark Wielaard 75fe92
+
Mark Wielaard 75fe92
+   store(binop(Iop_Add64, mkexpr(op1addr), mkexpr(offset)),
Mark Wielaard 75fe92
+         load(Ity_I8, binop(Iop_Add64, mkexpr(op2addr), mkexpr(offset))));
Mark Wielaard 75fe92
+
Mark Wielaard 75fe92
+   /* Check for end of field */
Mark Wielaard 75fe92
+   put_counter_dw0(binop(Iop_Add64, mkexpr(counter), mkU64(1)));
Mark Wielaard 75fe92
+   iterate_if(binop(Iop_CmpNE64, mkexpr(offset), mkU64(0)));
Mark Wielaard 75fe92
+   put_counter_dw0(mkU64(0));
Mark Wielaard 75fe92
+
Mark Wielaard 75fe92
+   return "mvcrl";
Mark Wielaard 75fe92
+}
Mark Wielaard 75fe92
+
Mark Wielaard 75fe92
 static const HChar *
Mark Wielaard 75fe92
 s390_irgen_MVCL(UChar r1, UChar r2)
Mark Wielaard 75fe92
 {
Mark Wielaard 75fe92
@@ -22217,6 +22261,9 @@ s390_decode_6byte_and_irgen(const UChar *bytes)
Mark Wielaard 75fe92
    case 0xe500ULL: /* LASP */ goto unimplemented;
Mark Wielaard 75fe92
    case 0xe501ULL: /* TPROT */ goto unimplemented;
Mark Wielaard 75fe92
    case 0xe502ULL: /* STRAG */ goto unimplemented;
Mark Wielaard 75fe92
+   case 0xe50aULL: s390_format_SSE_RDRD(s390_irgen_MVCRL,
Mark Wielaard 75fe92
+                                        SS_b1(ovl), SS_d1(ovl),
Mark Wielaard 75fe92
+                                        SS_b2(ovl), SS_d2(ovl));  goto ok;
Mark Wielaard 75fe92
    case 0xe50eULL: /* MVCSK */ goto unimplemented;
Mark Wielaard 75fe92
    case 0xe50fULL: /* MVCDK */ goto unimplemented;
Mark Wielaard 75fe92
    case 0xe544ULL: s390_format_SIL_RDI(s390_irgen_MVHHI, SIL_b1(ovl),
Mark Wielaard 75fe92
-- 
Mark Wielaard 75fe92
2.23.0
Mark Wielaard 75fe92
Mark Wielaard 75fe92
From 6cc4d66cc3a999253d9a57e2b5c75aeb67f77918 Mon Sep 17 00:00:00 2001
Mark Wielaard 75fe92
From: Andreas Arnez <arnez@linux.ibm.com>
Mark Wielaard 75fe92
Date: Tue, 2 Feb 2021 20:15:02 +0100
Mark Wielaard 75fe92
Subject: [PATCH 05/13] s390x: Misc-insn-3, test case
Mark Wielaard 75fe92
Mark Wielaard 75fe92
Add a test case for the new instructions in the miscellaneous instruction
Mark Wielaard 75fe92
extensions facitility 3.
Mark Wielaard 75fe92
---
Mark Wielaard 75fe92
 .gitignore                        |   1 +
Mark Wielaard 75fe92
 none/tests/s390x/Makefile.am      |   3 +-
Mark Wielaard 75fe92
 none/tests/s390x/misc3.c          | 182 ++++++++++++++++++++++++++++++
Mark Wielaard 75fe92
 none/tests/s390x/misc3.stderr.exp |   2 +
Mark Wielaard 75fe92
 none/tests/s390x/misc3.stdout.exp | 103 +++++++++++++++++
Mark Wielaard 75fe92
 none/tests/s390x/misc3.vgtest     |   1 +
Mark Wielaard 75fe92
 6 files changed, 291 insertions(+), 1 deletion(-)
Mark Wielaard 75fe92
 create mode 100644 none/tests/s390x/misc3.c
Mark Wielaard 75fe92
 create mode 100644 none/tests/s390x/misc3.stderr.exp
Mark Wielaard 75fe92
 create mode 100644 none/tests/s390x/misc3.stdout.exp
Mark Wielaard 75fe92
 create mode 100644 none/tests/s390x/misc3.vgtest
Mark Wielaard 75fe92
Mark Wielaard 75fe92
diff --git a/none/tests/s390x/Makefile.am b/none/tests/s390x/Makefile.am
Mark Wielaard 75fe92
index a0fb92ef5..2fd45ec1e 100644
Mark Wielaard 75fe92
--- a/none/tests/s390x/Makefile.am
Mark Wielaard 75fe92
+++ b/none/tests/s390x/Makefile.am
Mark Wielaard 75fe92
@@ -19,7 +19,8 @@ INSN_TESTS = clc clcle cvb cvd icm lpr tcxb lam_stam xc mvst add sub mul \
Mark Wielaard 75fe92
 	     spechelper-ltr spechelper-or   \
Mark Wielaard 75fe92
 	     spechelper-icm-1  spechelper-icm-2 spechelper-tmll \
Mark Wielaard 75fe92
 	     spechelper-tm laa vector lsc2 ppno vector_string vector_integer \
Mark Wielaard 75fe92
-	     vector_float add-z14 sub-z14 mul-z14 bic
Mark Wielaard 75fe92
+	     vector_float add-z14 sub-z14 mul-z14 bic \
Mark Wielaard 75fe92
+	     misc3
Mark Wielaard 75fe92
 
Mark Wielaard 75fe92
 if BUILD_DFP_TESTS
Mark Wielaard 75fe92
   INSN_TESTS += dfp-1 dfp-2 dfp-3 dfp-4 dfptest dfpext dfpconv srnmt pfpo
Mark Wielaard 75fe92
diff --git a/none/tests/s390x/misc3.c b/none/tests/s390x/misc3.c
Mark Wielaard 75fe92
new file mode 100644
Mark Wielaard 75fe92
index 000000000..ae6e8d4c2
Mark Wielaard 75fe92
--- /dev/null
Mark Wielaard 75fe92
+++ b/none/tests/s390x/misc3.c
Mark Wielaard 75fe92
@@ -0,0 +1,182 @@
Mark Wielaard 75fe92
+#include <stdio.h>
Mark Wielaard 75fe92
+
Mark Wielaard 75fe92
+/* -- Logical instructions -- */
Mark Wielaard 75fe92
+
Mark Wielaard 75fe92
+#define TEST_GENERATE(opcode,insn)                              \
Mark Wielaard 75fe92
+   static void test_##insn(unsigned long a, unsigned long b)    \
Mark Wielaard 75fe92
+   {                                                            \
Mark Wielaard 75fe92
+      unsigned long out = 0xdecaffee42424242;                   \
Mark Wielaard 75fe92
+      int cc;                                                   \
Mark Wielaard 75fe92
+                                                                \
Mark Wielaard 75fe92
+      __asm__(                                                  \
Mark Wielaard 75fe92
+         "cr    0,0\n\t"               /* Clear CC */           \
Mark Wielaard 75fe92
+         ".insn rrf,0x" #opcode "0000,%[out],%[a],%[b],0\n\t"   \
Mark Wielaard 75fe92
+         "ipm   %[cc]\n\t"                                      \
Mark Wielaard 75fe92
+         "srl   %[cc],28\n"                                     \
Mark Wielaard 75fe92
+         : [out] "+d" (out),                                    \
Mark Wielaard 75fe92
+           [cc] "=d" (cc)                                       \
Mark Wielaard 75fe92
+         : [a] "d" (a),                                         \
Mark Wielaard 75fe92
+           [b] "d" (b)                                          \
Mark Wielaard 75fe92
+         : "cc");                                               \
Mark Wielaard 75fe92
+                                                                \
Mark Wielaard 75fe92
+      printf("\t%016lx %016lx -> %016lx cc=%d\n",               \
Mark Wielaard 75fe92
+             a, b, out, cc);                                    \
Mark Wielaard 75fe92
+   }
Mark Wielaard 75fe92
+
Mark Wielaard 75fe92
+#define TEST_EXEC(opcode,insn)                             \
Mark Wielaard 75fe92
+   do {                                                    \
Mark Wielaard 75fe92
+      puts(#insn);                                         \
Mark Wielaard 75fe92
+      test_##insn(0, 0);                                   \
Mark Wielaard 75fe92
+      test_##insn(0, -1);                                  \
Mark Wielaard 75fe92
+      test_##insn(-1, 0);                                  \
Mark Wielaard 75fe92
+      test_##insn(-1, -1);                                 \
Mark Wielaard 75fe92
+      test_##insn(0x012345678abcdef, 0);                   \
Mark Wielaard 75fe92
+      test_##insn(0x012345678abcdef, -1);                  \
Mark Wielaard 75fe92
+      test_##insn(0x55555555aaaaaaaa, 0xaaaaaaaa55555555); \
Mark Wielaard 75fe92
+   } while (0)
Mark Wielaard 75fe92
+
Mark Wielaard 75fe92
+#define INSNS                                    \
Mark Wielaard 75fe92
+   XTEST(b9f5,ncrk);                             \
Mark Wielaard 75fe92
+   XTEST(b9e5,ncgrk);                            \
Mark Wielaard 75fe92
+   XTEST(b974,nnrk);                             \
Mark Wielaard 75fe92
+   XTEST(b964,nngrk);                            \
Mark Wielaard 75fe92
+   XTEST(b976,nork);                             \
Mark Wielaard 75fe92
+   XTEST(b966,nogrk);                            \
Mark Wielaard 75fe92
+   XTEST(b977,nxrk);                             \
Mark Wielaard 75fe92
+   XTEST(b967,nxgrk);                            \
Mark Wielaard 75fe92
+   XTEST(b975,ocrk);                             \
Mark Wielaard 75fe92
+   XTEST(b965,ocgrk);
Mark Wielaard 75fe92
+
Mark Wielaard 75fe92
+#define XTEST TEST_GENERATE
Mark Wielaard 75fe92
+INSNS
Mark Wielaard 75fe92
+#undef XTEST
Mark Wielaard 75fe92
+
Mark Wielaard 75fe92
+static void test_all_logical_insns()
Mark Wielaard 75fe92
+{
Mark Wielaard 75fe92
+#define XTEST TEST_EXEC
Mark Wielaard 75fe92
+   INSNS
Mark Wielaard 75fe92
+#undef XTEST
Mark Wielaard 75fe92
+}
Mark Wielaard 75fe92
+#undef INSNS
Mark Wielaard 75fe92
+#undef TEST_GENERATE
Mark Wielaard 75fe92
+#undef TEST_EXEC
Mark Wielaard 75fe92
+
Mark Wielaard 75fe92
+
Mark Wielaard 75fe92
+/* -- Full population count -- */
Mark Wielaard 75fe92
+
Mark Wielaard 75fe92
+static void test_popcnt(unsigned long op2)
Mark Wielaard 75fe92
+{
Mark Wielaard 75fe92
+   unsigned long result;
Mark Wielaard 75fe92
+   int cc;
Mark Wielaard 75fe92
+
Mark Wielaard 75fe92
+   __asm__(".insn   rrf,0xb9e10000,%[result],%[op2],8,0\n\t"
Mark Wielaard 75fe92
+           "ipm     %[cc]\n\t"
Mark Wielaard 75fe92
+           "srl     %[cc],28\n"
Mark Wielaard 75fe92
+           : [result]"=d" (result),
Mark Wielaard 75fe92
+             [cc]"=d" (cc)
Mark Wielaard 75fe92
+           : [op2]"d" (op2)
Mark Wielaard 75fe92
+           : "cc");
Mark Wielaard 75fe92
+   printf("\t%016lx -> %2lu cc=%d\n", op2, result, cc);
Mark Wielaard 75fe92
+}
Mark Wielaard 75fe92
+
Mark Wielaard 75fe92
+static int test_all_popcnt()
Mark Wielaard 75fe92
+{
Mark Wielaard 75fe92
+   puts("popcnt");
Mark Wielaard 75fe92
+   test_popcnt(0);
Mark Wielaard 75fe92
+   test_popcnt(1);
Mark Wielaard 75fe92
+   test_popcnt(0x8000000000000000);
Mark Wielaard 75fe92
+   test_popcnt(-1UL);
Mark Wielaard 75fe92
+   test_popcnt(0xff427e3800556bcd);
Mark Wielaard 75fe92
+   return 0;
Mark Wielaard 75fe92
+}
Mark Wielaard 75fe92
+
Mark Wielaard 75fe92
+/* -- Select -- */
Mark Wielaard 75fe92
+
Mark Wielaard 75fe92
+#define TEST_GENERATE(opcode,insn)                              \
Mark Wielaard 75fe92
+   static void test_##insn(unsigned long a, unsigned long b)    \
Mark Wielaard 75fe92
+   {                                                            \
Mark Wielaard 75fe92
+      unsigned long out0 = 0x0cafebad0badcafe;                  \
Mark Wielaard 75fe92
+      unsigned long out1 = 0x0badcafe0cafebad;                  \
Mark Wielaard 75fe92
+                                                                \
Mark Wielaard 75fe92
+      __asm__(                                                  \
Mark Wielaard 75fe92
+         "cr    0,0\n\t"               /* Clear CC */           \
Mark Wielaard 75fe92
+         ".insn rrf,0x" #opcode "0000,%[out0],%[a],%[b],8\n\t"  \
Mark Wielaard 75fe92
+         ".insn rrf,0x" #opcode "0000,%[out1],%[a],%[b],7\n\t"  \
Mark Wielaard 75fe92
+         : [out0] "+d" (out0),                                  \
Mark Wielaard 75fe92
+           [out1] "+d" (out1)                                   \
Mark Wielaard 75fe92
+         : [a] "d" (a),                                         \
Mark Wielaard 75fe92
+           [b] "d" (b)                                          \
Mark Wielaard 75fe92
+         : );                                                   \
Mark Wielaard 75fe92
+                                                                \
Mark Wielaard 75fe92
+      printf("\t%016lx %016lx -> %016lx %016lx\n",              \
Mark Wielaard 75fe92
+             a, b, out0, out1);                                 \
Mark Wielaard 75fe92
+   }
Mark Wielaard 75fe92
+
Mark Wielaard 75fe92
+#define TEST_EXEC(opcode,insn)                             \
Mark Wielaard 75fe92
+   do {                                                    \
Mark Wielaard 75fe92
+      puts(#insn);                                         \
Mark Wielaard 75fe92
+      test_##insn(-1, 0);                                  \
Mark Wielaard 75fe92
+      test_##insn(0, -1);                                  \
Mark Wielaard 75fe92
+      test_##insn(0x1234567890abcdef, 0xfedcba9876543210); \
Mark Wielaard 75fe92
+   } while (0)
Mark Wielaard 75fe92
+
Mark Wielaard 75fe92
+#define INSNS                                    \
Mark Wielaard 75fe92
+   XTEST(b9f0,selr);                             \
Mark Wielaard 75fe92
+   XTEST(b9e3,selgr);                            \
Mark Wielaard 75fe92
+   XTEST(b9c0,selfhr);
Mark Wielaard 75fe92
+
Mark Wielaard 75fe92
+#define XTEST TEST_GENERATE
Mark Wielaard 75fe92
+INSNS
Mark Wielaard 75fe92
+#undef XTEST
Mark Wielaard 75fe92
+
Mark Wielaard 75fe92
+static void test_all_select()
Mark Wielaard 75fe92
+{
Mark Wielaard 75fe92
+#define XTEST TEST_EXEC
Mark Wielaard 75fe92
+   INSNS
Mark Wielaard 75fe92
+#undef XTEST
Mark Wielaard 75fe92
+}
Mark Wielaard 75fe92
+#undef INSNS
Mark Wielaard 75fe92
+#undef TEST_GENERATE
Mark Wielaard 75fe92
+#undef TEST_EXEC
Mark Wielaard 75fe92
+
Mark Wielaard 75fe92
+
Mark Wielaard 75fe92
+/* -- Move right to left -- */
Mark Wielaard 75fe92
+
Mark Wielaard 75fe92
+static void test_mvcrl(void *to, void *from, size_t len)
Mark Wielaard 75fe92
+{
Mark Wielaard 75fe92
+   len -= 1;
Mark Wielaard 75fe92
+   __asm__("lgr    0,%[len]\n\t"
Mark Wielaard 75fe92
+           ".insn  sse,0xe50a00000000,%[to],%[from]\n\t"
Mark Wielaard 75fe92
+           : [to] "+Q" (*(struct { char c[len]; } *) to)
Mark Wielaard 75fe92
+           : [from] "Q" (*(struct { char c[len]; } *) from),
Mark Wielaard 75fe92
+             [len] "d" (len)
Mark Wielaard 75fe92
+           : );
Mark Wielaard 75fe92
+}
Mark Wielaard 75fe92
+
Mark Wielaard 75fe92
+static void test_all_mvcrl()
Mark Wielaard 75fe92
+{
Mark Wielaard 75fe92
+   static const char pattern[] =
Mark Wielaard 75fe92
+      "abcdefghijklmnopqrstuvwxyz-0123456789.ABCDEFGHIJKLMNOPQRSTUVWXYZ";
Mark Wielaard 75fe92
+   char buf[4 * sizeof(pattern) - 2];
Mark Wielaard 75fe92
+
Mark Wielaard 75fe92
+   test_mvcrl(buf, (char *) pattern, sizeof(pattern));
Mark Wielaard 75fe92
+   test_mvcrl(buf + sizeof(pattern) - 1, buf, sizeof(pattern));
Mark Wielaard 75fe92
+   test_mvcrl(buf + 2 * sizeof(pattern) - 2, buf, 2 * sizeof(pattern) - 1);
Mark Wielaard 75fe92
+   test_mvcrl(buf + 32, buf + 10, 63);
Mark Wielaard 75fe92
+   test_mvcrl(buf + 2, buf + 1, 256);
Mark Wielaard 75fe92
+   test_mvcrl(buf + 254, buf + 256, 2);
Mark Wielaard 75fe92
+   puts("mvcrl");
Mark Wielaard 75fe92
+   for (int i = 0; i < 256; i += 64) {
Mark Wielaard 75fe92
+      printf("\t%.64s\n", buf + i);
Mark Wielaard 75fe92
+   }
Mark Wielaard 75fe92
+}
Mark Wielaard 75fe92
+
Mark Wielaard 75fe92
+
Mark Wielaard 75fe92
+int main()
Mark Wielaard 75fe92
+{
Mark Wielaard 75fe92
+   test_all_logical_insns();
Mark Wielaard 75fe92
+   test_all_popcnt();
Mark Wielaard 75fe92
+   test_all_select();
Mark Wielaard 75fe92
+   test_all_mvcrl();
Mark Wielaard 75fe92
+   return 0;
Mark Wielaard 75fe92
+}
Mark Wielaard 75fe92
diff --git a/none/tests/s390x/misc3.stderr.exp b/none/tests/s390x/misc3.stderr.exp
Mark Wielaard 75fe92
new file mode 100644
Mark Wielaard 75fe92
index 000000000..139597f9c
Mark Wielaard 75fe92
--- /dev/null
Mark Wielaard 75fe92
+++ b/none/tests/s390x/misc3.stderr.exp
Mark Wielaard 75fe92
@@ -0,0 +1,2 @@
Mark Wielaard 75fe92
+
Mark Wielaard 75fe92
+
Mark Wielaard 75fe92
diff --git a/none/tests/s390x/misc3.stdout.exp b/none/tests/s390x/misc3.stdout.exp
Mark Wielaard 75fe92
new file mode 100644
Mark Wielaard 75fe92
index 000000000..caaba4960
Mark Wielaard 75fe92
--- /dev/null
Mark Wielaard 75fe92
+++ b/none/tests/s390x/misc3.stdout.exp
Mark Wielaard 75fe92
@@ -0,0 +1,103 @@
Mark Wielaard 75fe92
+ncrk
Mark Wielaard 75fe92
+	0000000000000000 0000000000000000 -> decaffee00000000 cc=0
Mark Wielaard 75fe92
+	0000000000000000 ffffffffffffffff -> decaffee00000000 cc=0
Mark Wielaard 75fe92
+	ffffffffffffffff 0000000000000000 -> decaffeeffffffff cc=1
Mark Wielaard 75fe92
+	ffffffffffffffff ffffffffffffffff -> decaffee00000000 cc=0
Mark Wielaard 75fe92
+	0012345678abcdef 0000000000000000 -> decaffee78abcdef cc=1
Mark Wielaard 75fe92
+	0012345678abcdef ffffffffffffffff -> decaffee00000000 cc=0
Mark Wielaard 75fe92
+	55555555aaaaaaaa aaaaaaaa55555555 -> decaffeeaaaaaaaa cc=1
Mark Wielaard 75fe92
+ncgrk
Mark Wielaard 75fe92
+	0000000000000000 0000000000000000 -> 0000000000000000 cc=0
Mark Wielaard 75fe92
+	0000000000000000 ffffffffffffffff -> 0000000000000000 cc=0
Mark Wielaard 75fe92
+	ffffffffffffffff 0000000000000000 -> ffffffffffffffff cc=1
Mark Wielaard 75fe92
+	ffffffffffffffff ffffffffffffffff -> 0000000000000000 cc=0
Mark Wielaard 75fe92
+	0012345678abcdef 0000000000000000 -> 0012345678abcdef cc=1
Mark Wielaard 75fe92
+	0012345678abcdef ffffffffffffffff -> 0000000000000000 cc=0
Mark Wielaard 75fe92
+	55555555aaaaaaaa aaaaaaaa55555555 -> 55555555aaaaaaaa cc=1
Mark Wielaard 75fe92
+nnrk
Mark Wielaard 75fe92
+	0000000000000000 0000000000000000 -> decaffeeffffffff cc=1
Mark Wielaard 75fe92
+	0000000000000000 ffffffffffffffff -> decaffeeffffffff cc=1
Mark Wielaard 75fe92
+	ffffffffffffffff 0000000000000000 -> decaffeeffffffff cc=1
Mark Wielaard 75fe92
+	ffffffffffffffff ffffffffffffffff -> decaffee00000000 cc=0
Mark Wielaard 75fe92
+	0012345678abcdef 0000000000000000 -> decaffeeffffffff cc=1
Mark Wielaard 75fe92
+	0012345678abcdef ffffffffffffffff -> decaffee87543210 cc=1
Mark Wielaard 75fe92
+	55555555aaaaaaaa aaaaaaaa55555555 -> decaffeeffffffff cc=1
Mark Wielaard 75fe92
+nngrk
Mark Wielaard 75fe92
+	0000000000000000 0000000000000000 -> ffffffffffffffff cc=1
Mark Wielaard 75fe92
+	0000000000000000 ffffffffffffffff -> ffffffffffffffff cc=1
Mark Wielaard 75fe92
+	ffffffffffffffff 0000000000000000 -> ffffffffffffffff cc=1
Mark Wielaard 75fe92
+	ffffffffffffffff ffffffffffffffff -> 0000000000000000 cc=0
Mark Wielaard 75fe92
+	0012345678abcdef 0000000000000000 -> ffffffffffffffff cc=1
Mark Wielaard 75fe92
+	0012345678abcdef ffffffffffffffff -> ffedcba987543210 cc=1
Mark Wielaard 75fe92
+	55555555aaaaaaaa aaaaaaaa55555555 -> ffffffffffffffff cc=1
Mark Wielaard 75fe92
+nork
Mark Wielaard 75fe92
+	0000000000000000 0000000000000000 -> decaffeeffffffff cc=1
Mark Wielaard 75fe92
+	0000000000000000 ffffffffffffffff -> decaffee00000000 cc=0
Mark Wielaard 75fe92
+	ffffffffffffffff 0000000000000000 -> decaffee00000000 cc=0
Mark Wielaard 75fe92
+	ffffffffffffffff ffffffffffffffff -> decaffee00000000 cc=0
Mark Wielaard 75fe92
+	0012345678abcdef 0000000000000000 -> decaffee87543210 cc=1
Mark Wielaard 75fe92
+	0012345678abcdef ffffffffffffffff -> decaffee00000000 cc=0
Mark Wielaard 75fe92
+	55555555aaaaaaaa aaaaaaaa55555555 -> decaffee00000000 cc=0
Mark Wielaard 75fe92
+nogrk
Mark Wielaard 75fe92
+	0000000000000000 0000000000000000 -> ffffffffffffffff cc=1
Mark Wielaard 75fe92
+	0000000000000000 ffffffffffffffff -> 0000000000000000 cc=0
Mark Wielaard 75fe92
+	ffffffffffffffff 0000000000000000 -> 0000000000000000 cc=0
Mark Wielaard 75fe92
+	ffffffffffffffff ffffffffffffffff -> 0000000000000000 cc=0
Mark Wielaard 75fe92
+	0012345678abcdef 0000000000000000 -> ffedcba987543210 cc=1
Mark Wielaard 75fe92
+	0012345678abcdef ffffffffffffffff -> 0000000000000000 cc=0
Mark Wielaard 75fe92
+	55555555aaaaaaaa aaaaaaaa55555555 -> 0000000000000000 cc=0
Mark Wielaard 75fe92
+nxrk
Mark Wielaard 75fe92
+	0000000000000000 0000000000000000 -> decaffeeffffffff cc=1
Mark Wielaard 75fe92
+	0000000000000000 ffffffffffffffff -> decaffee00000000 cc=0
Mark Wielaard 75fe92
+	ffffffffffffffff 0000000000000000 -> decaffee00000000 cc=0
Mark Wielaard 75fe92
+	ffffffffffffffff ffffffffffffffff -> decaffeeffffffff cc=1
Mark Wielaard 75fe92
+	0012345678abcdef 0000000000000000 -> decaffee87543210 cc=1
Mark Wielaard 75fe92
+	0012345678abcdef ffffffffffffffff -> decaffee78abcdef cc=1
Mark Wielaard 75fe92
+	55555555aaaaaaaa aaaaaaaa55555555 -> decaffee00000000 cc=0
Mark Wielaard 75fe92
+nxgrk
Mark Wielaard 75fe92
+	0000000000000000 0000000000000000 -> ffffffffffffffff cc=1
Mark Wielaard 75fe92
+	0000000000000000 ffffffffffffffff -> 0000000000000000 cc=0
Mark Wielaard 75fe92
+	ffffffffffffffff 0000000000000000 -> 0000000000000000 cc=0
Mark Wielaard 75fe92
+	ffffffffffffffff ffffffffffffffff -> ffffffffffffffff cc=1
Mark Wielaard 75fe92
+	0012345678abcdef 0000000000000000 -> ffedcba987543210 cc=1
Mark Wielaard 75fe92
+	0012345678abcdef ffffffffffffffff -> 0012345678abcdef cc=1
Mark Wielaard 75fe92
+	55555555aaaaaaaa aaaaaaaa55555555 -> 0000000000000000 cc=0
Mark Wielaard 75fe92
+ocrk
Mark Wielaard 75fe92
+	0000000000000000 0000000000000000 -> decaffeeffffffff cc=1
Mark Wielaard 75fe92
+	0000000000000000 ffffffffffffffff -> decaffee00000000 cc=0
Mark Wielaard 75fe92
+	ffffffffffffffff 0000000000000000 -> decaffeeffffffff cc=1
Mark Wielaard 75fe92
+	ffffffffffffffff ffffffffffffffff -> decaffeeffffffff cc=1
Mark Wielaard 75fe92
+	0012345678abcdef 0000000000000000 -> decaffeeffffffff cc=1
Mark Wielaard 75fe92
+	0012345678abcdef ffffffffffffffff -> decaffee78abcdef cc=1
Mark Wielaard 75fe92
+	55555555aaaaaaaa aaaaaaaa55555555 -> decaffeeaaaaaaaa cc=1
Mark Wielaard 75fe92
+ocgrk
Mark Wielaard 75fe92
+	0000000000000000 0000000000000000 -> ffffffffffffffff cc=1
Mark Wielaard 75fe92
+	0000000000000000 ffffffffffffffff -> 0000000000000000 cc=0
Mark Wielaard 75fe92
+	ffffffffffffffff 0000000000000000 -> ffffffffffffffff cc=1
Mark Wielaard 75fe92
+	ffffffffffffffff ffffffffffffffff -> ffffffffffffffff cc=1
Mark Wielaard 75fe92
+	0012345678abcdef 0000000000000000 -> ffffffffffffffff cc=1
Mark Wielaard 75fe92
+	0012345678abcdef ffffffffffffffff -> 0012345678abcdef cc=1
Mark Wielaard 75fe92
+	55555555aaaaaaaa aaaaaaaa55555555 -> 55555555aaaaaaaa cc=1
Mark Wielaard 75fe92
+popcnt
Mark Wielaard 75fe92
+	0000000000000000 ->  0 cc=0
Mark Wielaard 75fe92
+	0000000000000001 ->  1 cc=1
Mark Wielaard 75fe92
+	8000000000000000 ->  1 cc=1
Mark Wielaard 75fe92
+	ffffffffffffffff -> 64 cc=1
Mark Wielaard 75fe92
+	ff427e3800556bcd -> 33 cc=1
Mark Wielaard 75fe92
+selr
Mark Wielaard 75fe92
+	ffffffffffffffff 0000000000000000 -> 0cafebadffffffff 0badcafe00000000
Mark Wielaard 75fe92
+	0000000000000000 ffffffffffffffff -> 0cafebad00000000 0badcafeffffffff
Mark Wielaard 75fe92
+	1234567890abcdef fedcba9876543210 -> 0cafebad90abcdef 0badcafe76543210
Mark Wielaard 75fe92
+selgr
Mark Wielaard 75fe92
+	ffffffffffffffff 0000000000000000 -> ffffffffffffffff 0000000000000000
Mark Wielaard 75fe92
+	0000000000000000 ffffffffffffffff -> 0000000000000000 ffffffffffffffff
Mark Wielaard 75fe92
+	1234567890abcdef fedcba9876543210 -> 1234567890abcdef fedcba9876543210
Mark Wielaard 75fe92
+selfhr
Mark Wielaard 75fe92
+	ffffffffffffffff 0000000000000000 -> ffffffff0badcafe 000000000cafebad
Mark Wielaard 75fe92
+	0000000000000000 ffffffffffffffff -> 000000000badcafe ffffffff0cafebad
Mark Wielaard 75fe92
+	1234567890abcdef fedcba9876543210 -> 123456780badcafe fedcba980cafebad
Mark Wielaard 75fe92
+mvcrl
Mark Wielaard 75fe92
+	abbcdefghijklmnopqrstuvwxyz-01234klmnopqrstuvwxyz-0123456789.ABC
Mark Wielaard 75fe92
+	DEFGHIJKLMNOPQRSTUVWXYZabcdefghi456789.ABCDEFGHIJKLMNOPQRSTUVWXY
Mark Wielaard 75fe92
+	Zabcdefghijklmnopqrstuvwxyz-0123456789.ABCDEFGHIJKLMNOPQRSTUVWXY
Mark Wielaard 75fe92
+	Zabcdefghijklmnopqrstuvwxyz-0123456789.ABCDEFGHIJKLMNOPQRSTUVWZ
Mark Wielaard 75fe92
diff --git a/none/tests/s390x/misc3.vgtest b/none/tests/s390x/misc3.vgtest
Mark Wielaard 75fe92
new file mode 100644
Mark Wielaard 75fe92
index 000000000..d051a06bd
Mark Wielaard 75fe92
--- /dev/null
Mark Wielaard 75fe92
+++ b/none/tests/s390x/misc3.vgtest
Mark Wielaard 75fe92
@@ -0,0 +1 @@
Mark Wielaard 75fe92
+prog: misc3
Mark Wielaard 75fe92
-- 
Mark Wielaard 75fe92
2.23.0
Mark Wielaard 75fe92
Mark Wielaard 75fe92
From 401b51d79886362d1962dc487db45ac91462eaa0 Mon Sep 17 00:00:00 2001
Mark Wielaard 75fe92
From: Andreas Arnez <arnez@linux.ibm.com>
Mark Wielaard 75fe92
Date: Wed, 7 Apr 2021 12:29:32 +0200
Mark Wielaard 75fe92
Subject: [PATCH 06/13] s390x: Vec-enh-2, extend VSL, VSRA, and VSRL
Mark Wielaard 75fe92
Mark Wielaard 75fe92
The vector-enhancements facility 2 extends the existing bitwise vector
Mark Wielaard 75fe92
shift instructions VSL, VSRA, and VSRL.  Now they allow the shift
Mark Wielaard 75fe92
vector (the third operand) to contain different shift amounts for each
Mark Wielaard 75fe92
byte.  Add support for these new forms.
Mark Wielaard 75fe92
---
Mark Wielaard 75fe92
 VEX/priv/guest_s390_toIR.c | 58 ++++++++++++++++++++++++++++++--------
Mark Wielaard 75fe92
 1 file changed, 47 insertions(+), 11 deletions(-)
Mark Wielaard 75fe92
Mark Wielaard 75fe92
diff --git a/VEX/priv/guest_s390_toIR.c b/VEX/priv/guest_s390_toIR.c
Mark Wielaard 75fe92
index 9f7d98f8c..622d5a02e 100644
Mark Wielaard 75fe92
--- a/VEX/priv/guest_s390_toIR.c
Mark Wielaard 75fe92
+++ b/VEX/priv/guest_s390_toIR.c
Mark Wielaard 75fe92
@@ -17983,30 +17983,66 @@ s390_irgen_VERLL(UChar v1, IRTemp op2addr, UChar v3, UChar m4)
Mark Wielaard 75fe92
 static const HChar *
Mark Wielaard 75fe92
 s390_irgen_VSL(UChar v1, UChar v2, UChar v3)
Mark Wielaard 75fe92
 {
Mark Wielaard 75fe92
-   IRTemp shift_amount = newTemp(Ity_I8);
Mark Wielaard 75fe92
-   assign(shift_amount, binop(Iop_And8, get_vr_b7(v3), mkU8(0b00000111)));
Mark Wielaard 75fe92
-
Mark Wielaard 75fe92
-   put_vr_qw(v1, binop(Iop_ShlV128, get_vr_qw(v2), mkexpr(shift_amount)));
Mark Wielaard 75fe92
+   IRTemp a = newTemp(Ity_V128);
Mark Wielaard 75fe92
+   IRTemp b = newTemp(Ity_V128);
Mark Wielaard 75fe92
+
Mark Wielaard 75fe92
+   assign(a, get_vr_qw(v2));
Mark Wielaard 75fe92
+   assign(b, get_vr_qw(v3));
Mark Wielaard 75fe92
+
Mark Wielaard 75fe92
+   put_vr_qw(v1,
Mark Wielaard 75fe92
+             binop(Iop_OrV128,
Mark Wielaard 75fe92
+                   binop(Iop_Shl8x16, mkexpr(a), mkexpr(b)),
Mark Wielaard 75fe92
+                   binop(Iop_Shr8x16,
Mark Wielaard 75fe92
+                         binop(Iop_Shr8x16,
Mark Wielaard 75fe92
+                               binop(Iop_ShlV128, mkexpr(a), mkU8(8)),
Mark Wielaard 75fe92
+                               unop(Iop_NotV128, mkexpr(b))),
Mark Wielaard 75fe92
+                         unop(Iop_Dup8x16, mkU8(1)))));
Mark Wielaard 75fe92
    return "vsl";
Mark Wielaard 75fe92
 }
Mark Wielaard 75fe92
 
Mark Wielaard 75fe92
 static const HChar *
Mark Wielaard 75fe92
 s390_irgen_VSRL(UChar v1, UChar v2, UChar v3)
Mark Wielaard 75fe92
 {
Mark Wielaard 75fe92
-   IRTemp shift_amount = newTemp(Ity_I8);
Mark Wielaard 75fe92
-   assign(shift_amount, binop(Iop_And8, get_vr_b7(v3), mkU8(0b00000111)));
Mark Wielaard 75fe92
+   IRTemp a = newTemp(Ity_V128);
Mark Wielaard 75fe92
+   IRTemp b = newTemp(Ity_V128);
Mark Wielaard 75fe92
 
Mark Wielaard 75fe92
-   put_vr_qw(v1, binop(Iop_ShrV128, get_vr_qw(v2), mkexpr(shift_amount)));
Mark Wielaard 75fe92
+   assign(a, get_vr_qw(v2));
Mark Wielaard 75fe92
+   assign(b, get_vr_qw(v3));
Mark Wielaard 75fe92
+
Mark Wielaard 75fe92
+   put_vr_qw(v1,
Mark Wielaard 75fe92
+             binop(Iop_OrV128,
Mark Wielaard 75fe92
+                   binop(Iop_Shr8x16, mkexpr(a), mkexpr(b)),
Mark Wielaard 75fe92
+                   binop(Iop_Shl8x16,
Mark Wielaard 75fe92
+                         binop(Iop_Shl8x16,
Mark Wielaard 75fe92
+                               binop(Iop_ShrV128, mkexpr(a), mkU8(8)),
Mark Wielaard 75fe92
+                               unop(Iop_NotV128, mkexpr(b))),
Mark Wielaard 75fe92
+                         unop(Iop_Dup8x16, mkU8(1)))));
Mark Wielaard 75fe92
    return "vsrl";
Mark Wielaard 75fe92
 }
Mark Wielaard 75fe92
 
Mark Wielaard 75fe92
 static const HChar *
Mark Wielaard 75fe92
 s390_irgen_VSRA(UChar v1, UChar v2, UChar v3)
Mark Wielaard 75fe92
 {
Mark Wielaard 75fe92
-   IRTemp shift_amount = newTemp(Ity_I8);
Mark Wielaard 75fe92
-   assign(shift_amount, binop(Iop_And8, get_vr_b7(v3), mkU8(0b00000111)));
Mark Wielaard 75fe92
-
Mark Wielaard 75fe92
-   put_vr_qw(v1, binop(Iop_SarV128, get_vr_qw(v2), mkexpr(shift_amount)));
Mark Wielaard 75fe92
+   IRTemp a = newTemp(Ity_V128);
Mark Wielaard 75fe92
+   IRTemp b = newTemp(Ity_V128);
Mark Wielaard 75fe92
+
Mark Wielaard 75fe92
+   assign(a, get_vr_qw(v2));
Mark Wielaard 75fe92
+   assign(b, get_vr_qw(v3));
Mark Wielaard 75fe92
+
Mark Wielaard 75fe92
+   /* Shift-right: first byte arithmetically, all others logically */
Mark Wielaard 75fe92
+   IRExpr* elems_shifted =
Mark Wielaard 75fe92
+      binop(Iop_Sar8x16,
Mark Wielaard 75fe92
+            binop(Iop_Shr8x16, mkexpr(a),
Mark Wielaard 75fe92
+                  binop(Iop_AndV128, mkexpr(b), mkV128(0x7fff))),
Mark Wielaard 75fe92
+            binop(Iop_AndV128, mkexpr(b), mkV128(0x8000)));
Mark Wielaard 75fe92
+   /* Then OR the appropriate bits from the byte to the left */
Mark Wielaard 75fe92
+   put_vr_qw(v1,
Mark Wielaard 75fe92
+             binop(Iop_OrV128, elems_shifted,
Mark Wielaard 75fe92
+                   binop(Iop_Shl8x16,
Mark Wielaard 75fe92
+                         binop(Iop_Shl8x16,
Mark Wielaard 75fe92
+                               binop(Iop_ShrV128, mkexpr(a), mkU8(8)),
Mark Wielaard 75fe92
+                               unop(Iop_NotV128, mkexpr(b))),
Mark Wielaard 75fe92
+                         unop(Iop_Dup8x16, mkU8(1)))));
Mark Wielaard 75fe92
    return "vsra";
Mark Wielaard 75fe92
 }
Mark Wielaard 75fe92
 
Mark Wielaard 75fe92
-- 
Mark Wielaard 75fe92
2.23.0
Mark Wielaard 75fe92
Mark Wielaard 75fe92
From 3fdf065d0bf26a02d6d93a812a6571a287379c36 Mon Sep 17 00:00:00 2001
Mark Wielaard 75fe92
From: Andreas Arnez <arnez@linux.ibm.com>
Mark Wielaard 75fe92
Date: Thu, 11 Feb 2021 20:02:03 +0100
Mark Wielaard 75fe92
Subject: [PATCH 07/13] s390x: Vec-enh-2, extend VCDG, VCDLG, VCGD, and VCLGD
Mark Wielaard 75fe92
Mark Wielaard 75fe92
The vector-enhancements facility 2 extends the vector floating-point
Mark Wielaard 75fe92
conversion instructions VCDG, VCDLG, VCGD, and VCLGD.  In addition to
Mark Wielaard 75fe92
64-bit elements, they now also handle 32-bit elements.  Add support for
Mark Wielaard 75fe92
these new forms.
Mark Wielaard 75fe92
---
Mark Wielaard 75fe92
 VEX/priv/guest_s390_toIR.c | 36 ++++++++++++++++++++----------------
Mark Wielaard 75fe92
 1 file changed, 20 insertions(+), 16 deletions(-)
Mark Wielaard 75fe92
Mark Wielaard 75fe92
diff --git a/VEX/priv/guest_s390_toIR.c b/VEX/priv/guest_s390_toIR.c
Mark Wielaard 75fe92
index 622d5a02e..11271a1c9 100644
Mark Wielaard 75fe92
--- a/VEX/priv/guest_s390_toIR.c
Mark Wielaard 75fe92
+++ b/VEX/priv/guest_s390_toIR.c
Mark Wielaard 75fe92
@@ -18794,44 +18794,48 @@ s390_vector_fp_convert(IROp op, IRType fromType, IRType toType, Bool rounding,
Mark Wielaard 75fe92
 static const HChar *
Mark Wielaard 75fe92
 s390_irgen_VCDG(UChar v1, UChar v2, UChar m3, UChar m4, UChar m5)
Mark Wielaard 75fe92
 {
Mark Wielaard 75fe92
-   s390_insn_assert("vcdg", m3 == 3);
Mark Wielaard 75fe92
-
Mark Wielaard 75fe92
-   s390_vector_fp_convert(Iop_I64StoF64, Ity_I64, Ity_F64, True,
Mark Wielaard 75fe92
-                          v1, v2, m3, m4, m5);
Mark Wielaard 75fe92
+   s390_insn_assert("vcdg", m3 == 2 || m3 == 3);
Mark Wielaard 75fe92
 
Mark Wielaard 75fe92
+   s390_vector_fp_convert(m3 == 2 ? Iop_I32StoF32 : Iop_I64StoF64,
Mark Wielaard 75fe92
+                          m3 == 2 ? Ity_I32       : Ity_I64,
Mark Wielaard 75fe92
+                          m3 == 2 ? Ity_F32       : Ity_F64,
Mark Wielaard 75fe92
+                          True, v1, v2, m3, m4, m5);
Mark Wielaard 75fe92
    return "vcdg";
Mark Wielaard 75fe92
 }
Mark Wielaard 75fe92
 
Mark Wielaard 75fe92
 static const HChar *
Mark Wielaard 75fe92
 s390_irgen_VCDLG(UChar v1, UChar v2, UChar m3, UChar m4, UChar m5)
Mark Wielaard 75fe92
 {
Mark Wielaard 75fe92
-   s390_insn_assert("vcdlg", m3 == 3);
Mark Wielaard 75fe92
-
Mark Wielaard 75fe92
-   s390_vector_fp_convert(Iop_I64UtoF64, Ity_I64, Ity_F64, True,
Mark Wielaard 75fe92
-                          v1, v2, m3, m4, m5);
Mark Wielaard 75fe92
+   s390_insn_assert("vcdlg", m3 == 2 || m3 == 3);
Mark Wielaard 75fe92
 
Mark Wielaard 75fe92
+   s390_vector_fp_convert(m3 == 2 ? Iop_I32UtoF32 : Iop_I64UtoF64,
Mark Wielaard 75fe92
+                          m3 == 2 ? Ity_I32       : Ity_I64,
Mark Wielaard 75fe92
+                          m3 == 2 ? Ity_F32       : Ity_F64,
Mark Wielaard 75fe92
+                          True, v1, v2, m3, m4, m5);
Mark Wielaard 75fe92
    return "vcdlg";
Mark Wielaard 75fe92
 }
Mark Wielaard 75fe92
 
Mark Wielaard 75fe92
 static const HChar *
Mark Wielaard 75fe92
 s390_irgen_VCGD(UChar v1, UChar v2, UChar m3, UChar m4, UChar m5)
Mark Wielaard 75fe92
 {
Mark Wielaard 75fe92
-   s390_insn_assert("vcgd", m3 == 3);
Mark Wielaard 75fe92
-
Mark Wielaard 75fe92
-   s390_vector_fp_convert(Iop_F64toI64S, Ity_F64, Ity_I64, True,
Mark Wielaard 75fe92
-                          v1, v2, m3, m4, m5);
Mark Wielaard 75fe92
+   s390_insn_assert("vcgd", m3 == 2 || m3 == 3);
Mark Wielaard 75fe92
 
Mark Wielaard 75fe92
+   s390_vector_fp_convert(m3 == 2 ? Iop_F32toI32S : Iop_F64toI64S,
Mark Wielaard 75fe92
+                          m3 == 2 ? Ity_F32       : Ity_F64,
Mark Wielaard 75fe92
+                          m3 == 2 ? Ity_I32       : Ity_I64,
Mark Wielaard 75fe92
+                          True, v1, v2, m3, m4, m5);
Mark Wielaard 75fe92
    return "vcgd";
Mark Wielaard 75fe92
 }
Mark Wielaard 75fe92
 
Mark Wielaard 75fe92
 static const HChar *
Mark Wielaard 75fe92
 s390_irgen_VCLGD(UChar v1, UChar v2, UChar m3, UChar m4, UChar m5)
Mark Wielaard 75fe92
 {
Mark Wielaard 75fe92
-   s390_insn_assert("vclgd", m3 == 3);
Mark Wielaard 75fe92
-
Mark Wielaard 75fe92
-   s390_vector_fp_convert(Iop_F64toI64U, Ity_F64, Ity_I64, True,
Mark Wielaard 75fe92
-                          v1, v2, m3, m4, m5);
Mark Wielaard 75fe92
+   s390_insn_assert("vclgd", m3 == 2 || m3 == 3);
Mark Wielaard 75fe92
 
Mark Wielaard 75fe92
+   s390_vector_fp_convert(m3 == 2 ? Iop_F32toI32U : Iop_F64toI64U,
Mark Wielaard 75fe92
+                          m3 == 2 ? Ity_F32       : Ity_F64,
Mark Wielaard 75fe92
+                          m3 == 2 ? Ity_I32       : Ity_I64,
Mark Wielaard 75fe92
+                          True, v1, v2, m3, m4, m5);
Mark Wielaard 75fe92
    return "vclgd";
Mark Wielaard 75fe92
 }
Mark Wielaard 75fe92
 
Mark Wielaard 75fe92
-- 
Mark Wielaard 75fe92
2.23.0
Mark Wielaard 75fe92
Mark Wielaard 75fe92
From d195bf17388572e85474c7ded4b5bd0e4774637d Mon Sep 17 00:00:00 2001
Mark Wielaard 75fe92
From: Andreas Arnez <arnez@linux.ibm.com>
Mark Wielaard 75fe92
Date: Tue, 16 Feb 2021 16:19:31 +0100
Mark Wielaard 75fe92
Subject: [PATCH 08/13] s390x: Vec-enh-2, VLBR and friends
Mark Wielaard 75fe92
Mark Wielaard 75fe92
Add support for the new byte- and element-swapping vector load/store
Mark Wielaard 75fe92
instructions VLEBRH, VLEBRG, VLEBRF, VLLEBRZ, VLBRREP, VLBR, VLER,
Mark Wielaard 75fe92
VSTEBRH, VSTEBRG, VSTEBRF, VSTBR, and VSTER.
Mark Wielaard 75fe92
---
Mark Wielaard 75fe92
 VEX/priv/guest_s390_toIR.c | 256 +++++++++++++++++++++++++++++++++++++
Mark Wielaard 75fe92
 VEX/priv/host_s390_isel.c  |   9 ++
Mark Wielaard 75fe92
 2 files changed, 265 insertions(+)
Mark Wielaard 75fe92
Mark Wielaard 75fe92
diff --git a/VEX/priv/guest_s390_toIR.c b/VEX/priv/guest_s390_toIR.c
Mark Wielaard 75fe92
index 11271a1c9..f65b42705 100644
Mark Wielaard 75fe92
--- a/VEX/priv/guest_s390_toIR.c
Mark Wielaard 75fe92
+++ b/VEX/priv/guest_s390_toIR.c
Mark Wielaard 75fe92
@@ -19388,6 +19388,209 @@ s390_irgen_SELFHR(UChar r3, UChar m4, UChar r1, UChar r2)
Mark Wielaard 75fe92
    return "selfhr";
Mark Wielaard 75fe92
 }
Mark Wielaard 75fe92
 
Mark Wielaard 75fe92
+/* Helper function that byte-swaps each element of its V128 input operand */
Mark Wielaard 75fe92
+static IRExpr *
Mark Wielaard 75fe92
+s390_byteswap_elements(IRExpr* v, UChar m)
Mark Wielaard 75fe92
+{
Mark Wielaard 75fe92
+   static const ULong perm[4][2] = {
Mark Wielaard 75fe92
+      { 0x0100030205040706, 0x09080b0a0d0c0f0e }, /* 2-byte elements */
Mark Wielaard 75fe92
+      { 0x0302010007060504, 0x0b0a09080f0e0d0c }, /* 4-byte elements */
Mark Wielaard 75fe92
+      { 0x0706050403020100, 0x0f0e0d0c0b0a0908 }, /* 8-byte elements */
Mark Wielaard 75fe92
+      { 0x0f0e0d0c0b0a0908, 0x0706050403020100 }, /* whole vector */
Mark Wielaard 75fe92
+   };
Mark Wielaard 75fe92
+   return binop(Iop_Perm8x16, v, binop(Iop_64HLtoV128,
Mark Wielaard 75fe92
+                                       mkU64(perm[m - 1][0]),
Mark Wielaard 75fe92
+                                       mkU64(perm[m - 1][1])));
Mark Wielaard 75fe92
+}
Mark Wielaard 75fe92
+
Mark Wielaard 75fe92
+/* Helper function that reverses the elements of its V128 input operand */
Mark Wielaard 75fe92
+static IRExpr *
Mark Wielaard 75fe92
+s390_reverse_elements(IRExpr* v, UChar m)
Mark Wielaard 75fe92
+{
Mark Wielaard 75fe92
+   static const ULong perm[3][2] = {
Mark Wielaard 75fe92
+      { 0x0e0f0c0d0a0b0809, 0x0607040502030001 }, /* 2-byte elements */
Mark Wielaard 75fe92
+      { 0x0c0d0e0f08090a0b, 0x0405060700010203 }, /* 4-byte elements */
Mark Wielaard 75fe92
+      { 0x08090a0b0c0d0e0f, 0x0001020304050607 }, /* 8-byte elements */
Mark Wielaard 75fe92
+   };
Mark Wielaard 75fe92
+   return binop(Iop_Perm8x16, v, binop(Iop_64HLtoV128,
Mark Wielaard 75fe92
+                                       mkU64(perm[m - 1][0]),
Mark Wielaard 75fe92
+                                       mkU64(perm[m - 1][1])));
Mark Wielaard 75fe92
+}
Mark Wielaard 75fe92
+
Mark Wielaard 75fe92
+static const HChar *
Mark Wielaard 75fe92
+s390_irgen_VLBR(UChar v1, IRTemp op2addr, UChar m3)
Mark Wielaard 75fe92
+{
Mark Wielaard 75fe92
+   s390_insn_assert("vlbr", m3 >= 1 && m3 <= 4);
Mark Wielaard 75fe92
+   put_vr_qw(v1, s390_byteswap_elements(load(Ity_V128, mkexpr(op2addr)), m3));
Mark Wielaard 75fe92
+   return "vlbr";
Mark Wielaard 75fe92
+}
Mark Wielaard 75fe92
+
Mark Wielaard 75fe92
+static const HChar *
Mark Wielaard 75fe92
+s390_irgen_VSTBR(UChar v1, IRTemp op2addr, UChar m3)
Mark Wielaard 75fe92
+{
Mark Wielaard 75fe92
+   s390_insn_assert("vstbr", m3 >= 1 && m3 <= 4);
Mark Wielaard 75fe92
+   store(mkexpr(op2addr), s390_byteswap_elements(get_vr_qw(v1), m3));
Mark Wielaard 75fe92
+   return "vstbr";
Mark Wielaard 75fe92
+}
Mark Wielaard 75fe92
+
Mark Wielaard 75fe92
+static const HChar *
Mark Wielaard 75fe92
+s390_irgen_VLER(UChar v1, IRTemp op2addr, UChar m3)
Mark Wielaard 75fe92
+{
Mark Wielaard 75fe92
+   s390_insn_assert("vler", m3 >= 1 && m3 <= 3);
Mark Wielaard 75fe92
+   put_vr_qw(v1, s390_reverse_elements(load(Ity_V128, mkexpr(op2addr)), m3));
Mark Wielaard 75fe92
+   return "vler";
Mark Wielaard 75fe92
+}
Mark Wielaard 75fe92
+
Mark Wielaard 75fe92
+static const HChar *
Mark Wielaard 75fe92
+s390_irgen_VSTER(UChar v1, IRTemp op2addr, UChar m3)
Mark Wielaard 75fe92
+{
Mark Wielaard 75fe92
+   s390_insn_assert("vstbr", m3 >= 1 && m3 <= 4);
Mark Wielaard 75fe92
+   store(mkexpr(op2addr), s390_reverse_elements(get_vr_qw(v1), m3));
Mark Wielaard 75fe92
+   return "vstbr";
Mark Wielaard 75fe92
+}
Mark Wielaard 75fe92
+
Mark Wielaard 75fe92
+/* Helper function that combines its two V128 operands by replacing element 'to'
Mark Wielaard 75fe92
+   in 'a' by byte-swapped element 'from' in 'b' */
Mark Wielaard 75fe92
+static IRExpr *
Mark Wielaard 75fe92
+s390_insert_byteswapped(IRExpr* a, IRExpr* b, UChar m, UChar to, UChar from)
Mark Wielaard 75fe92
+{
Mark Wielaard 75fe92
+   UInt elem_size = 1U << m;
Mark Wielaard 75fe92
+   UInt start = elem_size * to;
Mark Wielaard 75fe92
+   UInt end = start + elem_size - 1;
Mark Wielaard 75fe92
+   UInt offs = end + elem_size * from + 16;
Mark Wielaard 75fe92
+   UInt i;
Mark Wielaard 75fe92
+
Mark Wielaard 75fe92
+   ULong permH = 0;
Mark Wielaard 75fe92
+   for (i = 0; i < 8; i++) {
Mark Wielaard 75fe92
+      permH = (permH << 8) | (i >= start && i <= end ? offs - i : i);
Mark Wielaard 75fe92
+   }
Mark Wielaard 75fe92
+   ULong permL = 0;
Mark Wielaard 75fe92
+   for (i = 8; i < 16; i++) {
Mark Wielaard 75fe92
+      permL = (permL << 8) | (i >= start && i <= end ? offs - i : i);
Mark Wielaard 75fe92
+   }
Mark Wielaard 75fe92
+   return triop(Iop_Perm8x16x2, a, b, binop(Iop_64HLtoV128,
Mark Wielaard 75fe92
+                                            mkU64(permH), mkU64(permL)));
Mark Wielaard 75fe92
+}
Mark Wielaard 75fe92
+
Mark Wielaard 75fe92
+static const HChar *
Mark Wielaard 75fe92
+s390_irgen_VLEBRH(UChar v1, IRTemp op2addr, UChar m3)
Mark Wielaard 75fe92
+{
Mark Wielaard 75fe92
+   s390_insn_assert("vlebrh", m3 <= 7);
Mark Wielaard 75fe92
+   IRTemp op2 = newTemp(Ity_I16);
Mark Wielaard 75fe92
+   assign(op2, load(Ity_I16, mkexpr(op2addr)));
Mark Wielaard 75fe92
+   put_vr(v1, Ity_I16, m3, binop(Iop_Or16,
Mark Wielaard 75fe92
+                                 binop(Iop_Shl16, mkexpr(op2), mkU8(8)),
Mark Wielaard 75fe92
+                                 binop(Iop_Shr16, mkexpr(op2), mkU8(8))));
Mark Wielaard 75fe92
+   return "vlebrh";
Mark Wielaard 75fe92
+}
Mark Wielaard 75fe92
+
Mark Wielaard 75fe92
+static const HChar *
Mark Wielaard 75fe92
+s390_irgen_VLEBRF(UChar v1, IRTemp op2addr, UChar m3)
Mark Wielaard 75fe92
+{
Mark Wielaard 75fe92
+   s390_insn_assert("vlebrf", m3 <= 3);
Mark Wielaard 75fe92
+   IRTemp op1 = newTemp(Ity_V128);
Mark Wielaard 75fe92
+   assign(op1, get_vr_qw(v1));
Mark Wielaard 75fe92
+   IRTemp op2 = newTemp(Ity_I64);
Mark Wielaard 75fe92
+   assign(op2, unop(Iop_32Uto64, load(Ity_I32, mkexpr(op2addr))));
Mark Wielaard 75fe92
+   IRExpr* b = binop(Iop_64HLtoV128, mkexpr(op2), mkexpr(op2));
Mark Wielaard 75fe92
+   put_vr_qw(v1, s390_insert_byteswapped(mkexpr(op1), b, 2, m3, 3));
Mark Wielaard 75fe92
+   return "vlebrf";
Mark Wielaard 75fe92
+}
Mark Wielaard 75fe92
+
Mark Wielaard 75fe92
+static const HChar *
Mark Wielaard 75fe92
+s390_irgen_VLEBRG(UChar v1, IRTemp op2addr, UChar m3)
Mark Wielaard 75fe92
+{
Mark Wielaard 75fe92
+   s390_insn_assert("vlebrg", m3 <= 1);
Mark Wielaard 75fe92
+   IRTemp op1 = newTemp(Ity_V128);
Mark Wielaard 75fe92
+   assign(op1, get_vr_qw(v1));
Mark Wielaard 75fe92
+   IRTemp op2 = newTemp(Ity_I64);
Mark Wielaard 75fe92
+   assign(op2, load(Ity_I64, mkexpr(op2addr)));
Mark Wielaard 75fe92
+   IRExpr* b = binop(Iop_64HLtoV128, mkexpr(op2), mkexpr(op2));
Mark Wielaard 75fe92
+   put_vr_qw(v1, s390_insert_byteswapped(mkexpr(op1), b, 3, m3, 1));
Mark Wielaard 75fe92
+   return "vlebrg";
Mark Wielaard 75fe92
+}
Mark Wielaard 75fe92
+
Mark Wielaard 75fe92
+static const HChar *
Mark Wielaard 75fe92
+s390_irgen_VLBRREP(UChar v1, IRTemp op2addr, UChar m3)
Mark Wielaard 75fe92
+{
Mark Wielaard 75fe92
+   s390_insn_assert("vlbrrep", m3 >= 1 && m3 <= 3);
Mark Wielaard 75fe92
+   static const ULong perm[3] = {
Mark Wielaard 75fe92
+      0x0f0e0f0e0f0e0f0e,       /* 2-byte element */
Mark Wielaard 75fe92
+      0x0f0e0d0c0f0e0d0c,       /* 4-byte element */
Mark Wielaard 75fe92
+      0x0f0e0d0c0b0a0908        /* 8-byte element */
Mark Wielaard 75fe92
+   };
Mark Wielaard 75fe92
+   IRExpr* permHL = mkU64(perm[m3 - 1]);
Mark Wielaard 75fe92
+   IRTemp op2 = newTemp(Ity_I64);
Mark Wielaard 75fe92
+   if (m3 == 3)
Mark Wielaard 75fe92
+      assign(op2, load(Ity_I64, mkexpr(op2addr)));
Mark Wielaard 75fe92
+   else
Mark Wielaard 75fe92
+      assign(op2, unop(m3 == 2 ? Iop_32Uto64 : Iop_16Uto64,
Mark Wielaard 75fe92
+                       load(s390_vr_get_type(m3), mkexpr(op2addr))));
Mark Wielaard 75fe92
+   put_vr_qw(v1, binop(Iop_Perm8x16,
Mark Wielaard 75fe92
+                       binop(Iop_64HLtoV128, mkexpr(op2), mkexpr(op2)),
Mark Wielaard 75fe92
+                       binop(Iop_64HLtoV128, permHL, permHL)));
Mark Wielaard 75fe92
+   return "vlbrrep";
Mark Wielaard 75fe92
+}
Mark Wielaard 75fe92
+
Mark Wielaard 75fe92
+static const HChar *
Mark Wielaard 75fe92
+s390_irgen_VLLEBRZ(UChar v1, IRTemp op2addr, UChar m3)
Mark Wielaard 75fe92
+{
Mark Wielaard 75fe92
+   s390_insn_assert("vllebrz", (m3 >= 1 && m3 <= 3) || m3 == 6);
Mark Wielaard 75fe92
+   static const ULong perm[6] = {
Mark Wielaard 75fe92
+      0x0000000000000f0e,       /* 2-byte element */
Mark Wielaard 75fe92
+      0x000000000f0e0d0c,       /* 4-byte element */
Mark Wielaard 75fe92
+      0x0f0e0d0c0b0a0908,       /* 8-byte element */
Mark Wielaard 75fe92
+      0,                        /* invalid (4) */
Mark Wielaard 75fe92
+      0,                        /* invalid (5) */
Mark Wielaard 75fe92
+      0x0f0e0d0c00000000,       /* 4-byte element, left-aligned */
Mark Wielaard 75fe92
+   };
Mark Wielaard 75fe92
+   IRExpr* permH = mkU64(perm[m3 - 1]);
Mark Wielaard 75fe92
+   IRTemp op2 = newTemp(Ity_I64);
Mark Wielaard 75fe92
+   if (m3 == 3)
Mark Wielaard 75fe92
+      assign(op2, load(Ity_I64, mkexpr(op2addr)));
Mark Wielaard 75fe92
+   else
Mark Wielaard 75fe92
+      assign(op2, unop((m3 & 3) == 2 ? Iop_32Uto64 : Iop_16Uto64,
Mark Wielaard 75fe92
+                       load(s390_vr_get_type(m3 & 3), mkexpr(op2addr))));
Mark Wielaard 75fe92
+   put_vr_qw(v1, binop(Iop_Perm8x16,
Mark Wielaard 75fe92
+                       binop(Iop_64HLtoV128, mkU64(0), mkexpr(op2)),
Mark Wielaard 75fe92
+                       binop(Iop_64HLtoV128, permH, mkU64(0))));
Mark Wielaard 75fe92
+   return "vllebrz";
Mark Wielaard 75fe92
+}
Mark Wielaard 75fe92
+
Mark Wielaard 75fe92
+static const HChar *
Mark Wielaard 75fe92
+s390_irgen_VSTEBRH(UChar v1, IRTemp op2addr, UChar m3)
Mark Wielaard 75fe92
+{
Mark Wielaard 75fe92
+   s390_insn_assert("vstebrh", m3 <= 7);
Mark Wielaard 75fe92
+   IRTemp op1 = newTemp(Ity_I16);
Mark Wielaard 75fe92
+   assign(op1, get_vr(v1, Ity_I16, m3));
Mark Wielaard 75fe92
+   store(mkexpr(op2addr), binop(Iop_Or16,
Mark Wielaard 75fe92
+                                binop(Iop_Shl16, mkexpr(op1), mkU8(8)),
Mark Wielaard 75fe92
+                                binop(Iop_Shr16, mkexpr(op1), mkU8(8))));
Mark Wielaard 75fe92
+   return "vstebrh";
Mark Wielaard 75fe92
+}
Mark Wielaard 75fe92
+
Mark Wielaard 75fe92
+static const HChar *
Mark Wielaard 75fe92
+s390_irgen_VSTEBRF(UChar v1, IRTemp op2addr, UChar m3)
Mark Wielaard 75fe92
+{
Mark Wielaard 75fe92
+   s390_insn_assert("vstebrf", m3 <= 3);
Mark Wielaard 75fe92
+   IRTemp op1 = newTemp(Ity_V128);
Mark Wielaard 75fe92
+   assign(op1, get_vr_qw(v1));
Mark Wielaard 75fe92
+   IRExpr* b = s390_insert_byteswapped(mkexpr(op1), mkexpr(op1), 2, 3, m3);
Mark Wielaard 75fe92
+   store(mkexpr(op2addr), unop(Iop_V128to32, b));
Mark Wielaard 75fe92
+   return "vstebrf";
Mark Wielaard 75fe92
+}
Mark Wielaard 75fe92
+
Mark Wielaard 75fe92
+static const HChar *
Mark Wielaard 75fe92
+s390_irgen_VSTEBRG(UChar v1, IRTemp op2addr, UChar m3)
Mark Wielaard 75fe92
+{
Mark Wielaard 75fe92
+   s390_insn_assert("vstebrg", m3 <= 1);
Mark Wielaard 75fe92
+   IRTemp op1 = newTemp(Ity_V128);
Mark Wielaard 75fe92
+   assign(op1, get_vr_qw(v1));
Mark Wielaard 75fe92
+   IRExpr* b = s390_insert_byteswapped(mkexpr(op1), mkexpr(op1), 3, 1, m3);
Mark Wielaard 75fe92
+   store(mkexpr(op2addr), unop(Iop_V128to64, b));
Mark Wielaard 75fe92
+   return "vstebrg";
Mark Wielaard 75fe92
+}
Mark Wielaard 75fe92
+
Mark Wielaard 75fe92
 /* New insns are added here.
Mark Wielaard 75fe92
    If an insn is contingent on a facility being installed also
Mark Wielaard 75fe92
    check whether the list of supported facilities in function
Mark Wielaard 75fe92
@@ -21003,6 +21206,59 @@ s390_decode_6byte_and_irgen(const UChar *bytes)
Mark Wielaard 75fe92
                                                 RXY_x2(ovl), RXY_b2(ovl),
Mark Wielaard 75fe92
                                                 RXY_dl2(ovl),
Mark Wielaard 75fe92
                                                 RXY_dh2(ovl));  goto ok;
Mark Wielaard 75fe92
+   case 0xe60000000001ULL: s390_format_VRX_VRRDM(s390_irgen_VLEBRH, VRX_v1(ovl),
Mark Wielaard 75fe92
+                                                 VRX_x2(ovl), VRX_b2(ovl),
Mark Wielaard 75fe92
+                                                 VRX_d2(ovl), VRX_m3(ovl),
Mark Wielaard 75fe92
+                                                 VRX_rxb(ovl));  goto ok;
Mark Wielaard 75fe92
+   case 0xe60000000002ULL: s390_format_VRX_VRRDM(s390_irgen_VLEBRG, VRX_v1(ovl),
Mark Wielaard 75fe92
+                                                 VRX_x2(ovl), VRX_b2(ovl),
Mark Wielaard 75fe92
+                                                 VRX_d2(ovl), VRX_m3(ovl),
Mark Wielaard 75fe92
+                                                 VRX_rxb(ovl));  goto ok;
Mark Wielaard 75fe92
+   case 0xe60000000003ULL: s390_format_VRX_VRRDM(s390_irgen_VLEBRF, VRX_v1(ovl),
Mark Wielaard 75fe92
+                                                 VRX_x2(ovl), VRX_b2(ovl),
Mark Wielaard 75fe92
+                                                 VRX_d2(ovl), VRX_m3(ovl),
Mark Wielaard 75fe92
+                                                 VRX_rxb(ovl));  goto ok;
Mark Wielaard 75fe92
+   case 0xe60000000004ULL: s390_format_VRX_VRRDM(s390_irgen_VLLEBRZ,
Mark Wielaard 75fe92
+                                                 VRX_v1(ovl),
Mark Wielaard 75fe92
+                                                 VRX_x2(ovl), VRX_b2(ovl),
Mark Wielaard 75fe92
+                                                 VRX_d2(ovl), VRX_m3(ovl),
Mark Wielaard 75fe92
+                                                 VRX_rxb(ovl));  goto ok;
Mark Wielaard 75fe92
+   case 0xe60000000005ULL: s390_format_VRX_VRRDM(s390_irgen_VLBRREP,
Mark Wielaard 75fe92
+                                                 VRX_v1(ovl),
Mark Wielaard 75fe92
+                                                 VRX_x2(ovl), VRX_b2(ovl),
Mark Wielaard 75fe92
+                                                 VRX_d2(ovl), VRX_m3(ovl),
Mark Wielaard 75fe92
+                                                 VRX_rxb(ovl));  goto ok;
Mark Wielaard 75fe92
+   case 0xe60000000006ULL: s390_format_VRX_VRRDM(s390_irgen_VLBR, VRX_v1(ovl),
Mark Wielaard 75fe92
+                                                 VRX_x2(ovl), VRX_b2(ovl),
Mark Wielaard 75fe92
+                                                 VRX_d2(ovl), VRX_m3(ovl),
Mark Wielaard 75fe92
+                                                 VRX_rxb(ovl));  goto ok;
Mark Wielaard 75fe92
+   case 0xe60000000007ULL: s390_format_VRX_VRRDM(s390_irgen_VLER, VRX_v1(ovl),
Mark Wielaard 75fe92
+                                                 VRX_x2(ovl), VRX_b2(ovl),
Mark Wielaard 75fe92
+                                                 VRX_d2(ovl), VRX_m3(ovl),
Mark Wielaard 75fe92
+                                                 VRX_rxb(ovl));  goto ok;
Mark Wielaard 75fe92
+   case 0xe60000000009ULL: s390_format_VRX_VRRDM(s390_irgen_VSTEBRH,
Mark Wielaard 75fe92
+                                                 VRX_v1(ovl),
Mark Wielaard 75fe92
+                                                 VRX_x2(ovl), VRX_b2(ovl),
Mark Wielaard 75fe92
+                                                 VRX_d2(ovl), VRX_m3(ovl),
Mark Wielaard 75fe92
+                                                 VRX_rxb(ovl));  goto ok;
Mark Wielaard 75fe92
+   case 0xe6000000000aULL: s390_format_VRX_VRRDM(s390_irgen_VSTEBRG,
Mark Wielaard 75fe92
+                                                 VRX_v1(ovl),
Mark Wielaard 75fe92
+                                                 VRX_x2(ovl), VRX_b2(ovl),
Mark Wielaard 75fe92
+                                                 VRX_d2(ovl), VRX_m3(ovl),
Mark Wielaard 75fe92
+                                                 VRX_rxb(ovl));  goto ok;
Mark Wielaard 75fe92
+   case 0xe6000000000bULL: s390_format_VRX_VRRDM(s390_irgen_VSTEBRF,
Mark Wielaard 75fe92
+                                                 VRX_v1(ovl),
Mark Wielaard 75fe92
+                                                 VRX_x2(ovl), VRX_b2(ovl),
Mark Wielaard 75fe92
+                                                 VRX_d2(ovl), VRX_m3(ovl),
Mark Wielaard 75fe92
+                                                 VRX_rxb(ovl));  goto ok;
Mark Wielaard 75fe92
+   case 0xe6000000000eULL: s390_format_VRX_VRRDM(s390_irgen_VSTBR, VRX_v1(ovl),
Mark Wielaard 75fe92
+                                                 VRX_x2(ovl), VRX_b2(ovl),
Mark Wielaard 75fe92
+                                                 VRX_d2(ovl), VRX_m3(ovl),
Mark Wielaard 75fe92
+                                                 VRX_rxb(ovl));  goto ok;
Mark Wielaard 75fe92
+   case 0xe6000000000fULL: s390_format_VRX_VRRDM(s390_irgen_VSTER, VRX_v1(ovl),
Mark Wielaard 75fe92
+                                                 VRX_x2(ovl), VRX_b2(ovl),
Mark Wielaard 75fe92
+                                                 VRX_d2(ovl), VRX_m3(ovl),
Mark Wielaard 75fe92
+                                                 VRX_rxb(ovl));  goto ok;
Mark Wielaard 75fe92
    case 0xe60000000034ULL: /* VPKZ */ goto unimplemented;
Mark Wielaard 75fe92
    case 0xe60000000035ULL: s390_format_VSI_URDV(s390_irgen_VLRL, VSI_v1(ovl),
Mark Wielaard 75fe92
                                                 VSI_b2(ovl), VSI_d2(ovl),
Mark Wielaard 75fe92
diff --git a/VEX/priv/host_s390_isel.c b/VEX/priv/host_s390_isel.c
Mark Wielaard 75fe92
index ee20c6711..06e195957 100644
Mark Wielaard 75fe92
--- a/VEX/priv/host_s390_isel.c
Mark Wielaard 75fe92
+++ b/VEX/priv/host_s390_isel.c
Mark Wielaard 75fe92
@@ -4189,6 +4189,15 @@ s390_isel_vec_expr_wrk(ISelEnv *env, IRExpr *expr)
Mark Wielaard 75fe92
          return dst;
Mark Wielaard 75fe92
       }
Mark Wielaard 75fe92
 
Mark Wielaard 75fe92
+      case Iop_Perm8x16:
Mark Wielaard 75fe92
+         size = 16;
Mark Wielaard 75fe92
+         reg1 = s390_isel_vec_expr(env, arg1);
Mark Wielaard 75fe92
+         reg2 = s390_isel_vec_expr(env, arg2);
Mark Wielaard 75fe92
+
Mark Wielaard 75fe92
+         addInstr(env, s390_insn_vec_triop(size, S390_VEC_PERM,
Mark Wielaard 75fe92
+                                           dst, reg1, reg1, reg2));
Mark Wielaard 75fe92
+         return dst;
Mark Wielaard 75fe92
+
Mark Wielaard 75fe92
       case Iop_CmpEQ8x16:
Mark Wielaard 75fe92
          size = 1;
Mark Wielaard 75fe92
          vec_binop = S390_VEC_COMPARE_EQUAL;
Mark Wielaard 75fe92
-- 
Mark Wielaard 75fe92
2.23.0
Mark Wielaard 75fe92
Mark Wielaard 75fe92
From f7447f4c73b2d0fb4eb3827c3709f378f6c9c656 Mon Sep 17 00:00:00 2001
Mark Wielaard 75fe92
From: Andreas Arnez <arnez@linux.ibm.com>
Mark Wielaard 75fe92
Date: Tue, 23 Feb 2021 19:10:37 +0100
Mark Wielaard 75fe92
Subject: [PATCH 09/13] s390x: Vec-enh-2, VSLD and VSRD
Mark Wielaard 75fe92
Mark Wielaard 75fe92
Support the new "vector shift left/right double by bit" instructions VSLD
Mark Wielaard 75fe92
and VSRD.
Mark Wielaard 75fe92
---
Mark Wielaard 75fe92
 VEX/priv/guest_s390_toIR.c | 50 ++++++++++++++++++++++++++++++++++++++
Mark Wielaard 75fe92
 1 file changed, 50 insertions(+)
Mark Wielaard 75fe92
Mark Wielaard 75fe92
diff --git a/VEX/priv/guest_s390_toIR.c b/VEX/priv/guest_s390_toIR.c
Mark Wielaard 75fe92
index f65b42705..aa429d085 100644
Mark Wielaard 75fe92
--- a/VEX/priv/guest_s390_toIR.c
Mark Wielaard 75fe92
+++ b/VEX/priv/guest_s390_toIR.c
Mark Wielaard 75fe92
@@ -18228,6 +18228,48 @@ s390_irgen_VSLDB(UChar v1, UChar v2, UChar v3, UChar i4)
Mark Wielaard 75fe92
    return "vsldb";
Mark Wielaard 75fe92
 }
Mark Wielaard 75fe92
 
Mark Wielaard 75fe92
+static const HChar *
Mark Wielaard 75fe92
+s390_irgen_VSLD(UChar v1, UChar v2, UChar v3, UChar i4)
Mark Wielaard 75fe92
+{
Mark Wielaard 75fe92
+   s390_insn_assert("vsld", i4 <= 7);
Mark Wielaard 75fe92
+
Mark Wielaard 75fe92
+   if (i4 == 0) {
Mark Wielaard 75fe92
+      /* Just copy v2. */
Mark Wielaard 75fe92
+      put_vr_qw(v1, get_vr_qw(v2));
Mark Wielaard 75fe92
+   } else {
Mark Wielaard 75fe92
+      /* Concatenate v2's tail with v3's head. */
Mark Wielaard 75fe92
+      put_vr_qw(v1,
Mark Wielaard 75fe92
+                binop(Iop_OrV128,
Mark Wielaard 75fe92
+                      binop(Iop_ShlV128, get_vr_qw(v2), mkU8(i4)),
Mark Wielaard 75fe92
+                      binop(Iop_ShrV128, get_vr_qw(v3), mkU8(128 - i4))
Mark Wielaard 75fe92
+                     )
Mark Wielaard 75fe92
+               );
Mark Wielaard 75fe92
+   }
Mark Wielaard 75fe92
+
Mark Wielaard 75fe92
+   return "vsld";
Mark Wielaard 75fe92
+}
Mark Wielaard 75fe92
+
Mark Wielaard 75fe92
+static const HChar *
Mark Wielaard 75fe92
+s390_irgen_VSRD(UChar v1, UChar v2, UChar v3, UChar i4)
Mark Wielaard 75fe92
+{
Mark Wielaard 75fe92
+   s390_insn_assert("vsrd", i4 <= 7);
Mark Wielaard 75fe92
+
Mark Wielaard 75fe92
+   if (i4 == 0) {
Mark Wielaard 75fe92
+      /* Just copy v3. */
Mark Wielaard 75fe92
+      put_vr_qw(v1, get_vr_qw(v3));
Mark Wielaard 75fe92
+   } else {
Mark Wielaard 75fe92
+      /* Concatenate v2's tail with v3's head. */
Mark Wielaard 75fe92
+      put_vr_qw(v1,
Mark Wielaard 75fe92
+                binop(Iop_OrV128,
Mark Wielaard 75fe92
+                      binop(Iop_ShlV128, get_vr_qw(v2), mkU8(128 - i4)),
Mark Wielaard 75fe92
+                      binop(Iop_ShrV128, get_vr_qw(v3), mkU8(i4))
Mark Wielaard 75fe92
+                     )
Mark Wielaard 75fe92
+               );
Mark Wielaard 75fe92
+   }
Mark Wielaard 75fe92
+
Mark Wielaard 75fe92
+   return "vsrd";
Mark Wielaard 75fe92
+}
Mark Wielaard 75fe92
+
Mark Wielaard 75fe92
 static const HChar *
Mark Wielaard 75fe92
 s390_irgen_VMO(UChar v1, UChar v2, UChar v3, UChar m4)
Mark Wielaard 75fe92
 {
Mark Wielaard 75fe92
@@ -21541,6 +21583,14 @@ s390_decode_6byte_and_irgen(const UChar *bytes)
Mark Wielaard 75fe92
    case 0xe70000000085ULL: s390_format_VRR_VVV(s390_irgen_VBPERM, VRR_v1(ovl),
Mark Wielaard 75fe92
                                                VRR_v2(ovl), VRR_r3(ovl),
Mark Wielaard 75fe92
                                                VRR_rxb(ovl));  goto ok;
Mark Wielaard 75fe92
+   case 0xe70000000086ULL: s390_format_VRId_VVVI(s390_irgen_VSLD, VRId_v1(ovl),
Mark Wielaard 75fe92
+                                                 VRId_v2(ovl), VRId_v3(ovl),
Mark Wielaard 75fe92
+                                                 VRId_i4(ovl),
Mark Wielaard 75fe92
+                                                 VRId_rxb(ovl));  goto ok;
Mark Wielaard 75fe92
+   case 0xe70000000087ULL: s390_format_VRId_VVVI(s390_irgen_VSRD, VRId_v1(ovl),
Mark Wielaard 75fe92
+                                                 VRId_v2(ovl), VRId_v3(ovl),
Mark Wielaard 75fe92
+                                                 VRId_i4(ovl),
Mark Wielaard 75fe92
+                                                 VRId_rxb(ovl));  goto ok;
Mark Wielaard 75fe92
    case 0xe7000000008aULL: s390_format_VRR_VVVVMM(s390_irgen_VSTRC, VRRd_v1(ovl),
Mark Wielaard 75fe92
                                                   VRRd_v2(ovl), VRRd_v3(ovl),
Mark Wielaard 75fe92
                                                   VRRd_v4(ovl), VRRd_m5(ovl),
Mark Wielaard 75fe92
-- 
Mark Wielaard 75fe92
2.23.0
Mark Wielaard 75fe92
Mark Wielaard 75fe92
From 388082bca7146f8a15814798dbfe570af2aab2a9 Mon Sep 17 00:00:00 2001
Mark Wielaard 75fe92
From: Andreas Arnez <arnez@linux.ibm.com>
Mark Wielaard 75fe92
Date: Wed, 10 Mar 2021 19:22:51 +0100
Mark Wielaard 75fe92
Subject: [PATCH 10/13] s390x: Vec-enh-2, VSTRS
Mark Wielaard 75fe92
Mark Wielaard 75fe92
Support the new "vector string search" instruction VSTRS.  The
Mark Wielaard 75fe92
implementation is a full emulation and follows a similar approach as for
Mark Wielaard 75fe92
the other vector string instructions.
Mark Wielaard 75fe92
---
Mark Wielaard 75fe92
 VEX/priv/guest_s390_toIR.c | 104 +++++++++++++++++++++++++++++++++++++
Mark Wielaard 75fe92
 1 file changed, 104 insertions(+)
Mark Wielaard 75fe92
Mark Wielaard 75fe92
diff --git a/VEX/priv/guest_s390_toIR.c b/VEX/priv/guest_s390_toIR.c
Mark Wielaard 75fe92
index aa429d085..46a867475 100644
Mark Wielaard 75fe92
--- a/VEX/priv/guest_s390_toIR.c
Mark Wielaard 75fe92
+++ b/VEX/priv/guest_s390_toIR.c
Mark Wielaard 75fe92
@@ -17601,6 +17601,105 @@ s390_irgen_VSTRC(UChar v1, UChar v2, UChar v3, UChar v4, UChar m5, UChar m6)
Mark Wielaard 75fe92
    return "vstrc";
Mark Wielaard 75fe92
 }
Mark Wielaard 75fe92
 
Mark Wielaard 75fe92
+static const HChar *
Mark Wielaard 75fe92
+s390_irgen_VSTRS(UChar v1, UChar v2, UChar v3, UChar v4, UChar m5, UChar m6)
Mark Wielaard 75fe92
+{
Mark Wielaard 75fe92
+   s390_insn_assert("vstrs", m5 <= 2 && m6 == (m6 & 2));
Mark Wielaard 75fe92
+
Mark Wielaard 75fe92
+   IRTemp op2 = newTemp(Ity_V128);
Mark Wielaard 75fe92
+   IRTemp op3 = newTemp(Ity_V128);
Mark Wielaard 75fe92
+   IRTemp op4 = newTemp(Ity_I8);
Mark Wielaard 75fe92
+   IRTemp op2clean = newTemp(Ity_V128);
Mark Wielaard 75fe92
+   IRTemp op3mask = newTemp(Ity_V128);
Mark Wielaard 75fe92
+   IRTemp result = newTemp(Ity_V128);
Mark Wielaard 75fe92
+   IRTemp ccnomatch = newTemp(Ity_I64);
Mark Wielaard 75fe92
+   IRExpr* tmp;
Mark Wielaard 75fe92
+   IRExpr* match = NULL;
Mark Wielaard 75fe92
+   UChar elem_bits = 8 << m5;
Mark Wielaard 75fe92
+   IROp cmpeq_op = S390_VEC_OP3(m5, Iop_CmpEQ8x16,
Mark Wielaard 75fe92
+                                Iop_CmpEQ16x8, Iop_CmpEQ32x4);
Mark Wielaard 75fe92
+
Mark Wielaard 75fe92
+   assign(op2, get_vr_qw(v2));
Mark Wielaard 75fe92
+   assign(op3, get_vr_qw(v3));
Mark Wielaard 75fe92
+   assign(op4, get_vr_b7(v4));
Mark Wielaard 75fe92
+
Mark Wielaard 75fe92
+   tmp = unop(Iop_Dup32x4,
Mark Wielaard 75fe92
+              unop(Iop_1Sto32, binop(Iop_CmpNE8, mkexpr(op4), mkU8(16))));
Mark Wielaard 75fe92
+   tmp = binop(Iop_ShrV128, tmp, binop(Iop_Shl8, mkexpr(op4), mkU8(3)));
Mark Wielaard 75fe92
+
Mark Wielaard 75fe92
+   if (s390_vr_is_zs_set(m6)) {
Mark Wielaard 75fe92
+      IRTemp op2eos = newTemp(Ity_V128);
Mark Wielaard 75fe92
+      IRExpr* t;
Mark Wielaard 75fe92
+      t = binop(cmpeq_op, mkexpr(op2), mkV128(0));
Mark Wielaard 75fe92
+      for (UChar i = m5; i < 4; i++) {
Mark Wielaard 75fe92
+         IRTemp s = newTemp(Ity_V128);
Mark Wielaard 75fe92
+         assign(s, t);
Mark Wielaard 75fe92
+         t = binop(Iop_OrV128, mkexpr(s), binop(Iop_ShrV128, mkexpr(s),
Mark Wielaard 75fe92
+                                                mkU8(8 << i)));
Mark Wielaard 75fe92
+      }
Mark Wielaard 75fe92
+      assign(op2eos, t);
Mark Wielaard 75fe92
+      assign(op2clean, binop(Iop_AndV128, mkexpr(op2),
Mark Wielaard 75fe92
+                             unop(Iop_NotV128, mkexpr(op2eos))));
Mark Wielaard 75fe92
+      assign(ccnomatch, binop(Iop_And64, mkU64(1),
Mark Wielaard 75fe92
+                              unop(Iop_V128to64, mkexpr(op2eos))));
Mark Wielaard 75fe92
+
Mark Wielaard 75fe92
+      t = binop(cmpeq_op, mkexpr(op3), mkV128(0));
Mark Wielaard 75fe92
+      for (UChar i = m5; i < 4; i++) {
Mark Wielaard 75fe92
+         IRTemp s = newTemp(Ity_V128);
Mark Wielaard 75fe92
+         assign(s, t);
Mark Wielaard 75fe92
+         t = binop(Iop_OrV128, mkexpr(s), binop(Iop_ShrV128, mkexpr(s),
Mark Wielaard 75fe92
+                                                mkU8(8 << i)));
Mark Wielaard 75fe92
+      }
Mark Wielaard 75fe92
+      tmp = binop(Iop_OrV128, tmp, t);
Mark Wielaard 75fe92
+   } else {
Mark Wielaard 75fe92
+      assign(op2clean, mkexpr(op2));
Mark Wielaard 75fe92
+   }
Mark Wielaard 75fe92
+   assign(op3mask, unop(Iop_NotV128, tmp));
Mark Wielaard 75fe92
+
Mark Wielaard 75fe92
+   for (UChar shift = 0; shift < 128; shift += elem_bits) {
Mark Wielaard 75fe92
+      IRTemp s = newTemp(Ity_V128);
Mark Wielaard 75fe92
+      tmp = unop(Iop_NotV128,
Mark Wielaard 75fe92
+                 binop(cmpeq_op, mkexpr(op2clean),
Mark Wielaard 75fe92
+                       binop(Iop_ShrV128, mkexpr(op3), mkU8(shift))));
Mark Wielaard 75fe92
+      assign(s, binop(Iop_CmpEQ64x2, mkV128(0),
Mark Wielaard 75fe92
+                      binop(Iop_AndV128, mkexpr(op3mask),
Mark Wielaard 75fe92
+                            binop(Iop_ShlV128, tmp, mkU8(shift)))));
Mark Wielaard 75fe92
+      tmp = mkexpr(s);
Mark Wielaard 75fe92
+      if (shift < 64) {
Mark Wielaard 75fe92
+         tmp = binop(Iop_AndV128, tmp,
Mark Wielaard 75fe92
+                     unop(Iop_Dup16x8, binop(Iop_GetElem16x8, tmp, mkU8(4))));
Mark Wielaard 75fe92
+      }
Mark Wielaard 75fe92
+      tmp = binop(Iop_AndV128, tmp,
Mark Wielaard 75fe92
+                  unop(Iop_Dup16x8, mkU16(1 << (15 - shift / 8))));
Mark Wielaard 75fe92
+      if (shift)
Mark Wielaard 75fe92
+         match = binop(Iop_OrV128, mkexpr(mktemp(Ity_V128, match)), tmp);
Mark Wielaard 75fe92
+      else
Mark Wielaard 75fe92
+         match = tmp;
Mark Wielaard 75fe92
+   }
Mark Wielaard 75fe92
+   assign(result, unop(Iop_ClzNat64,
Mark Wielaard 75fe92
+                       binop(Iop_Or64,
Mark Wielaard 75fe92
+                             unop(Iop_V128HIto64, match),
Mark Wielaard 75fe92
+                             mkU64((1UL << 48) - 1))));
Mark Wielaard 75fe92
+   put_vr_qw(v1, binop(Iop_64HLtoV128, mkexpr(result), mkU64(0)));
Mark Wielaard 75fe92
+
Mark Wielaard 75fe92
+   /* Set condition code.
Mark Wielaard 75fe92
+      0: no match, no string terminator in op2
Mark Wielaard 75fe92
+      1: no match, string terminator found
Mark Wielaard 75fe92
+      2: full match
Mark Wielaard 75fe92
+      3: partial match */
Mark Wielaard 75fe92
+   IRTemp cc = newTemp(Ity_I64);
Mark Wielaard 75fe92
+   tmp = binop(Iop_CmpLE64U,
Mark Wielaard 75fe92
+               binop(Iop_Add64, mkexpr(result), unop(Iop_8Uto64, mkexpr(op4))),
Mark Wielaard 75fe92
+               mkU64(16));
Mark Wielaard 75fe92
+   assign(cc, mkite(binop(Iop_CmpEQ64, mkexpr(result), mkU64(16)),
Mark Wielaard 75fe92
+                    s390_vr_is_zs_set(m6) ? mkexpr(ccnomatch) : mkU64(0),
Mark Wielaard 75fe92
+                    mkite(tmp, mkU64(2), mkU64(3))));
Mark Wielaard 75fe92
+   s390_cc_set(cc);
Mark Wielaard 75fe92
+
Mark Wielaard 75fe92
+   dis_res->hint = Dis_HintVerbose;
Mark Wielaard 75fe92
+   return "vstrs";
Mark Wielaard 75fe92
+}
Mark Wielaard 75fe92
+
Mark Wielaard 75fe92
 static const HChar *
Mark Wielaard 75fe92
 s390_irgen_VNC(UChar v1, UChar v2, UChar v3)
Mark Wielaard 75fe92
 {
Mark Wielaard 75fe92
@@ -21596,6 +21695,11 @@ s390_decode_6byte_and_irgen(const UChar *bytes)
Mark Wielaard 75fe92
                                                   VRRd_v4(ovl), VRRd_m5(ovl),
Mark Wielaard 75fe92
                                                   VRRd_m6(ovl),
Mark Wielaard 75fe92
                                                   VRRd_rxb(ovl));  goto ok;
Mark Wielaard 75fe92
+   case 0xe7000000008bULL: s390_format_VRR_VVVVMM(s390_irgen_VSTRS, VRRd_v1(ovl),
Mark Wielaard 75fe92
+                                                  VRRd_v2(ovl), VRRd_v3(ovl),
Mark Wielaard 75fe92
+                                                  VRRd_v4(ovl), VRRd_m5(ovl),
Mark Wielaard 75fe92
+                                                  VRRd_m6(ovl),
Mark Wielaard 75fe92
+                                                  VRRd_rxb(ovl));  goto ok;
Mark Wielaard 75fe92
    case 0xe7000000008cULL: s390_format_VRR_VVVV(s390_irgen_VPERM, VRR_v1(ovl),
Mark Wielaard 75fe92
                                                VRR_v2(ovl), VRR_r3(ovl),
Mark Wielaard 75fe92
                                                VRR_m4(ovl), VRR_rxb(ovl));  goto ok;
Mark Wielaard 75fe92
-- 
Mark Wielaard 75fe92
2.23.0
Mark Wielaard 75fe92
Mark Wielaard 75fe92
From 8a079b405467fa127c6c311d7ae3c649e76106c6 Mon Sep 17 00:00:00 2001
Mark Wielaard 75fe92
From: Andreas Arnez <arnez@linux.ibm.com>
Mark Wielaard 75fe92
Date: Tue, 16 Feb 2021 17:52:09 +0100
Mark Wielaard 75fe92
Subject: [PATCH 11/13] s390x: Mark arch13 features as supported
Mark Wielaard 75fe92
Mark Wielaard 75fe92
Make the STFLE instruction report the miscellaneous-instruction-extensions
Mark Wielaard 75fe92
facility 3 and the vector-enhancements facility 2 as supported.  Indicate
Mark Wielaard 75fe92
support for the latter in the HWCAP vector as well.
Mark Wielaard 75fe92
---
Mark Wielaard 75fe92
 VEX/priv/guest_s390_helpers.c       | 9 +++------
Mark Wielaard 75fe92
 coregrind/m_initimg/initimg-linux.c | 3 ++-
Mark Wielaard 75fe92
 include/vki/vki-s390x-linux.h       | 1 +
Mark Wielaard 75fe92
 3 files changed, 6 insertions(+), 7 deletions(-)
Mark Wielaard 75fe92
Mark Wielaard 75fe92
diff --git a/VEX/priv/guest_s390_helpers.c b/VEX/priv/guest_s390_helpers.c
Mark Wielaard 75fe92
index 1e04f601a..804b92a29 100644
Mark Wielaard 75fe92
--- a/VEX/priv/guest_s390_helpers.c
Mark Wielaard 75fe92
+++ b/VEX/priv/guest_s390_helpers.c
Mark Wielaard 75fe92
@@ -356,9 +356,7 @@ s390x_dirtyhelper_STFLE(VexGuestS390XState *guest_state, ULong *addr)
Mark Wielaard 75fe92
        | s390_stfle_range(51, 55)
Mark Wielaard 75fe92
        /* 56: unassigned */
Mark Wielaard 75fe92
        /* 57: MSA5, not supported */
Mark Wielaard 75fe92
-       | s390_stfle_range(58, 60)
Mark Wielaard 75fe92
-       /* 61: miscellaneous-instruction 3, not supported */
Mark Wielaard 75fe92
-       | s390_stfle_range(62, 63)),
Mark Wielaard 75fe92
+       | s390_stfle_range(58, 63)),
Mark Wielaard 75fe92
 
Mark Wielaard 75fe92
       /* ===  64 .. 127  === */
Mark Wielaard 75fe92
       (s390_stfle_range(64, 72)
Mark Wielaard 75fe92
@@ -384,11 +382,10 @@ s390x_dirtyhelper_STFLE(VexGuestS390XState *guest_state, ULong *addr)
Mark Wielaard 75fe92
        /* 143: unassigned */
Mark Wielaard 75fe92
        | s390_stfle_range(144, 145)
Mark Wielaard 75fe92
        /* 146: MSA8, not supported */
Mark Wielaard 75fe92
-       | s390_stfle_range(147, 147)
Mark Wielaard 75fe92
-       /* 148: vector-enhancements 2, not supported */
Mark Wielaard 75fe92
-       | s390_stfle_range(149, 149)
Mark Wielaard 75fe92
+       | s390_stfle_range(147, 149)
Mark Wielaard 75fe92
        /* 150: unassigned */
Mark Wielaard 75fe92
        /* 151: DEFLATE-conversion, not supported */
Mark Wielaard 75fe92
+       /* 152: vector packed decimal enhancement, not supported */
Mark Wielaard 75fe92
        /* 153: unassigned */
Mark Wielaard 75fe92
        /* 154: unassigned */
Mark Wielaard 75fe92
        /* 155: MSA9, not supported */
Mark Wielaard 75fe92
diff --git a/coregrind/m_initimg/initimg-linux.c b/coregrind/m_initimg/initimg-linux.c
Mark Wielaard 75fe92
index fc1a32ecf..37d005168 100644
Mark Wielaard 75fe92
--- a/coregrind/m_initimg/initimg-linux.c
Mark Wielaard 75fe92
+++ b/coregrind/m_initimg/initimg-linux.c
Mark Wielaard 75fe92
@@ -703,7 +703,8 @@ Addr setup_client_stack( void*  init_sp,
Mark Wielaard 75fe92
                   itself, is not supported by Valgrind. */
Mark Wielaard 75fe92
                auxv->u.a_val &= ((VKI_HWCAP_S390_TE - 1)
Mark Wielaard 75fe92
                                  | VKI_HWCAP_S390_VXRS
Mark Wielaard 75fe92
-                                 | VKI_HWCAP_S390_VXRS_EXT);
Mark Wielaard 75fe92
+                                 | VKI_HWCAP_S390_VXRS_EXT
Mark Wielaard 75fe92
+                                 | VKI_HWCAP_S390_VXRS_EXT2);
Mark Wielaard 75fe92
             }
Mark Wielaard 75fe92
 #           elif defined(VGP_arm64_linux)
Mark Wielaard 75fe92
             {
Mark Wielaard 75fe92
diff --git a/include/vki/vki-s390x-linux.h b/include/vki/vki-s390x-linux.h
Mark Wielaard 75fe92
index 4ab2d3334..71b363029 100644
Mark Wielaard 75fe92
--- a/include/vki/vki-s390x-linux.h
Mark Wielaard 75fe92
+++ b/include/vki/vki-s390x-linux.h
Mark Wielaard 75fe92
@@ -807,6 +807,7 @@ typedef vki_s390_regs vki_elf_gregset_t;
Mark Wielaard 75fe92
 #define VKI_HWCAP_S390_TE           1024
Mark Wielaard 75fe92
 #define VKI_HWCAP_S390_VXRS         2048
Mark Wielaard 75fe92
 #define VKI_HWCAP_S390_VXRS_EXT     8192
Mark Wielaard 75fe92
+#define VKI_HWCAP_S390_VXRS_EXT2   32768
Mark Wielaard 75fe92
 
Mark Wielaard 75fe92
 
Mark Wielaard 75fe92
 //----------------------------------------------------------------------
Mark Wielaard 75fe92
-- 
Mark Wielaard 75fe92
2.23.0
Mark Wielaard 75fe92
Mark Wielaard 75fe92
From 1461d9b8d0b12e55b648fbf50c5dcee30785afa2 Mon Sep 17 00:00:00 2001
Mark Wielaard 75fe92
From: Andreas Arnez <arnez@linux.ibm.com>
Mark Wielaard 75fe92
Date: Mon, 17 May 2021 15:34:15 +0200
Mark Wielaard 75fe92
Subject: [PATCH 12/13] s390x: Vec-enh-2, test cases
Mark Wielaard 75fe92
Mark Wielaard 75fe92
Add test cases for verifying the new/enhanced instructions in the
Mark Wielaard 75fe92
vector-enhancements facility 2.  For "vector string search" VSTRS add a
Mark Wielaard 75fe92
memcheck test case.
Mark Wielaard 75fe92
---
Mark Wielaard 75fe92
 .gitignore                            |   2 +
Mark Wielaard 75fe92
 memcheck/tests/s390x/Makefile.am      |   3 +-
Mark Wielaard 75fe92
 memcheck/tests/s390x/vstrs.c          |  68 ++++++
Mark Wielaard 75fe92
 memcheck/tests/s390x/vstrs.stderr.exp |  16 ++
Mark Wielaard 75fe92
 memcheck/tests/s390x/vstrs.stdout.exp |   0
Mark Wielaard 75fe92
 memcheck/tests/s390x/vstrs.vgtest     |   2 +
Mark Wielaard 75fe92
 none/tests/s390x/Makefile.am          |   3 +-
Mark Wielaard 75fe92
 none/tests/s390x/vec2.c               | 314 ++++++++++++++++++++++++++
Mark Wielaard 75fe92
 none/tests/s390x/vec2.stderr.exp      |   2 +
Mark Wielaard 75fe92
 none/tests/s390x/vec2.stdout.exp      | 168 ++++++++++++++
Mark Wielaard 75fe92
 none/tests/s390x/vec2.vgtest          |   2 +
Mark Wielaard 75fe92
 tests/s390x_features.c                |   4 +
Mark Wielaard 75fe92
 12 files changed, 582 insertions(+), 2 deletions(-)
Mark Wielaard 75fe92
 create mode 100644 memcheck/tests/s390x/vstrs.c
Mark Wielaard 75fe92
 create mode 100644 memcheck/tests/s390x/vstrs.stderr.exp
Mark Wielaard 75fe92
 create mode 100644 memcheck/tests/s390x/vstrs.stdout.exp
Mark Wielaard 75fe92
 create mode 100644 memcheck/tests/s390x/vstrs.vgtest
Mark Wielaard 75fe92
 create mode 100644 none/tests/s390x/vec2.c
Mark Wielaard 75fe92
 create mode 100644 none/tests/s390x/vec2.stderr.exp
Mark Wielaard 75fe92
 create mode 100644 none/tests/s390x/vec2.stdout.exp
Mark Wielaard 75fe92
 create mode 100644 none/tests/s390x/vec2.vgtest
Mark Wielaard 75fe92
Mark Wielaard 75fe92
diff --git a/memcheck/tests/s390x/Makefile.am b/memcheck/tests/s390x/Makefile.am
Mark Wielaard 75fe92
index d183841ef..668fd9933 100644
Mark Wielaard 75fe92
--- a/memcheck/tests/s390x/Makefile.am
Mark Wielaard 75fe92
+++ b/memcheck/tests/s390x/Makefile.am
Mark Wielaard 75fe92
@@ -2,7 +2,7 @@ include $(top_srcdir)/Makefile.tool-tests.am
Mark Wielaard 75fe92
 
Mark Wielaard 75fe92
 dist_noinst_SCRIPTS = filter_stderr
Mark Wielaard 75fe92
 
Mark Wielaard 75fe92
-INSN_TESTS = cdsg cu21 cu42 ltgjhe vstrc vfae vistr
Mark Wielaard 75fe92
+INSN_TESTS = cdsg cu21 cu42 ltgjhe vstrc vfae vistr vstrs
Mark Wielaard 75fe92
 
Mark Wielaard 75fe92
 check_PROGRAMS = $(INSN_TESTS) 
Mark Wielaard 75fe92
 
Mark Wielaard 75fe92
@@ -18,3 +18,4 @@ AM_CCASFLAGS += @FLAG_M64@
Mark Wielaard 75fe92
 vstrc_CFLAGS  = $(AM_CFLAGS) -march=z13
Mark Wielaard 75fe92
 vfae_CFLAGS   = $(AM_CFLAGS) -march=z13
Mark Wielaard 75fe92
 vistr_CFLAGS  = $(AM_CFLAGS) -march=z13
Mark Wielaard 75fe92
+vstrs_CFLAGS  = $(AM_CFLAGS) -march=z13
Mark Wielaard 75fe92
diff --git a/memcheck/tests/s390x/vstrs.c b/memcheck/tests/s390x/vstrs.c
Mark Wielaard 75fe92
new file mode 100644
Mark Wielaard 75fe92
index 000000000..3354c2e53
Mark Wielaard 75fe92
--- /dev/null
Mark Wielaard 75fe92
+++ b/memcheck/tests/s390x/vstrs.c
Mark Wielaard 75fe92
@@ -0,0 +1,68 @@
Mark Wielaard 75fe92
+#include <stdio.h>
Mark Wielaard 75fe92
+#include <string.h>
Mark Wielaard 75fe92
+
Mark Wielaard 75fe92
+#define VECTOR __attribute__ ((vector_size (16)))
Mark Wielaard 75fe92
+
Mark Wielaard 75fe92
+typedef char VECTOR char_v;
Mark Wielaard 75fe92
+
Mark Wielaard 75fe92
+volatile char tmp;
Mark Wielaard 75fe92
+static const char *hex_digit = "0123456789abcdefGHIJKLMNOPQRSTUV";
Mark Wielaard 75fe92
+
Mark Wielaard 75fe92
+static char_v to_char_vec(const char *str)
Mark Wielaard 75fe92
+{
Mark Wielaard 75fe92
+   char buf[17];
Mark Wielaard 75fe92
+   char_v v;
Mark Wielaard 75fe92
+
Mark Wielaard 75fe92
+   for (int i = 0; i < sizeof(buf); i++) {
Mark Wielaard 75fe92
+      char ch = str[i];
Mark Wielaard 75fe92
+      if (ch == '\0')
Mark Wielaard 75fe92
+         break;
Mark Wielaard 75fe92
+      else if (ch == '$')
Mark Wielaard 75fe92
+         buf[i] = '\0';
Mark Wielaard 75fe92
+      else if (ch != '~')
Mark Wielaard 75fe92
+         buf[i] = ch;
Mark Wielaard 75fe92
+   }
Mark Wielaard 75fe92
+   v = *(char_v *) buf;
Mark Wielaard 75fe92
+   return v;
Mark Wielaard 75fe92
+}
Mark Wielaard 75fe92
+
Mark Wielaard 75fe92
+static void test_vstrs_char(const char *haystack, const char *needle,
Mark Wielaard 75fe92
+                            int expect_res, int expect_cc)
Mark Wielaard 75fe92
+{
Mark Wielaard 75fe92
+   int cc;
Mark Wielaard 75fe92
+   char_v v2val = to_char_vec(haystack);
Mark Wielaard 75fe92
+   char_v v3val = to_char_vec(needle);
Mark Wielaard 75fe92
+
Mark Wielaard 75fe92
+   register unsigned long VECTOR v4 __asm__("v4") = { strlen(needle), 0 };
Mark Wielaard 75fe92
+   register char_v v1 __asm__("v1");
Mark Wielaard 75fe92
+   register char_v v2 __asm__("v2") = v2val;
Mark Wielaard 75fe92
+   register char_v v3 __asm__("v3") = v3val;
Mark Wielaard 75fe92
+
Mark Wielaard 75fe92
+   __asm__(
Mark Wielaard 75fe92
+      "cr     0,0\n\t"                  /* Clear CC */
Mark Wielaard 75fe92
+      ".short 0xe712,0x3020,0x408b\n\t" /* vstrs %v1,%v2,%v3,%v4,0,2 */
Mark Wielaard 75fe92
+      "ipm    %[cc]\n\t"
Mark Wielaard 75fe92
+      "srl    %[cc],28"
Mark Wielaard 75fe92
+      : "=v" (v1), [cc] "=d" (cc)
Mark Wielaard 75fe92
+      : "v" (v2), "v" (v3), "v" (v4)
Mark Wielaard 75fe92
+      : "cc");
Mark Wielaard 75fe92
+
Mark Wielaard 75fe92
+   tmp = hex_digit[v1[7] & 0x1f];
Mark Wielaard 75fe92
+   if (expect_res >= 0  && v1[7] != expect_res)
Mark Wielaard 75fe92
+      printf("result %u != %d\n", v1[7], expect_res);
Mark Wielaard 75fe92
+
Mark Wielaard 75fe92
+   tmp = hex_digit[cc & 0xf];
Mark Wielaard 75fe92
+   if (expect_cc >= 0 && cc != expect_cc)
Mark Wielaard 75fe92
+      printf("CC %d != %d\n", cc, expect_cc);
Mark Wielaard 75fe92
+}
Mark Wielaard 75fe92
+
Mark Wielaard 75fe92
+int main()
Mark Wielaard 75fe92
+{
Mark Wielaard 75fe92
+   test_vstrs_char("haystack$needle", "needle$haystack", 16, 1);
Mark Wielaard 75fe92
+   test_vstrs_char("haystack, needle", "needle, haystack", 10, 3);
Mark Wielaard 75fe92
+   test_vstrs_char("ABCDEFGH", "DEFGHI", -1, -1);
Mark Wielaard 75fe92
+   test_vstrs_char("match in UNDEF", "UN", 9, 2);
Mark Wielaard 75fe92
+   test_vstrs_char("after ~ UNDEF", "DEF", -1, -1);
Mark Wielaard 75fe92
+   test_vstrs_char("", "", 0, 2);
Mark Wielaard 75fe92
+   return 0;
Mark Wielaard 75fe92
+}
Mark Wielaard 75fe92
diff --git a/memcheck/tests/s390x/vstrs.stderr.exp b/memcheck/tests/s390x/vstrs.stderr.exp
Mark Wielaard 75fe92
new file mode 100644
Mark Wielaard 75fe92
index 000000000..c5c3ef705
Mark Wielaard 75fe92
--- /dev/null
Mark Wielaard 75fe92
+++ b/memcheck/tests/s390x/vstrs.stderr.exp
Mark Wielaard 75fe92
@@ -0,0 +1,16 @@
Mark Wielaard 75fe92
+Use of uninitialised value of size 8
Mark Wielaard 75fe92
+   at 0x........: test_vstrs_char (vstrs.c:50)
Mark Wielaard 75fe92
+   by 0x........: main (vstrs.c:63)
Mark Wielaard 75fe92
+
Mark Wielaard 75fe92
+Use of uninitialised value of size 8
Mark Wielaard 75fe92
+   at 0x........: test_vstrs_char (vstrs.c:54)
Mark Wielaard 75fe92
+   by 0x........: main (vstrs.c:63)
Mark Wielaard 75fe92
+
Mark Wielaard 75fe92
+Use of uninitialised value of size 8
Mark Wielaard 75fe92
+   at 0x........: test_vstrs_char (vstrs.c:50)
Mark Wielaard 75fe92
+   by 0x........: main (vstrs.c:65)
Mark Wielaard 75fe92
+
Mark Wielaard 75fe92
+Use of uninitialised value of size 8
Mark Wielaard 75fe92
+   at 0x........: test_vstrs_char (vstrs.c:54)
Mark Wielaard 75fe92
+   by 0x........: main (vstrs.c:65)
Mark Wielaard 75fe92
+
Mark Wielaard 75fe92
diff --git a/memcheck/tests/s390x/vstrs.stdout.exp b/memcheck/tests/s390x/vstrs.stdout.exp
Mark Wielaard 75fe92
new file mode 100644
Mark Wielaard 75fe92
index 000000000..e69de29bb
Mark Wielaard 75fe92
diff --git a/memcheck/tests/s390x/vstrs.vgtest b/memcheck/tests/s390x/vstrs.vgtest
Mark Wielaard 75fe92
new file mode 100644
Mark Wielaard 75fe92
index 000000000..fd2a29873
Mark Wielaard 75fe92
--- /dev/null
Mark Wielaard 75fe92
+++ b/memcheck/tests/s390x/vstrs.vgtest
Mark Wielaard 75fe92
@@ -0,0 +1,2 @@
Mark Wielaard 75fe92
+prog: vstrs
Mark Wielaard 75fe92
+vgopts: -q
Mark Wielaard 75fe92
diff --git a/none/tests/s390x/Makefile.am b/none/tests/s390x/Makefile.am
Mark Wielaard 75fe92
index 2fd45ec1e..ca38db935 100644
Mark Wielaard 75fe92
--- a/none/tests/s390x/Makefile.am
Mark Wielaard 75fe92
+++ b/none/tests/s390x/Makefile.am
Mark Wielaard 75fe92
@@ -20,7 +20,7 @@ INSN_TESTS = clc clcle cvb cvd icm lpr tcxb lam_stam xc mvst add sub mul \
Mark Wielaard 75fe92
 	     spechelper-icm-1  spechelper-icm-2 spechelper-tmll \
Mark Wielaard 75fe92
 	     spechelper-tm laa vector lsc2 ppno vector_string vector_integer \
Mark Wielaard 75fe92
 	     vector_float add-z14 sub-z14 mul-z14 bic \
Mark Wielaard 75fe92
-	     misc3
Mark Wielaard 75fe92
+	     misc3 vec2
Mark Wielaard 75fe92
 
Mark Wielaard 75fe92
 if BUILD_DFP_TESTS
Mark Wielaard 75fe92
   INSN_TESTS += dfp-1 dfp-2 dfp-3 dfp-4 dfptest dfpext dfpconv srnmt pfpo
Mark Wielaard 75fe92
@@ -74,3 +74,4 @@ lsc2_CFLAGS       = -march=z13 -DS390_TESTS_NOCOLOR
Mark Wielaard 75fe92
 vector_string_CFLAGS = $(AM_CFLAGS) -march=z13 -DS390_TEST_COUNT=5
Mark Wielaard 75fe92
 vector_integer_CFLAGS    = $(AM_CFLAGS) -march=z13 -DS390_TEST_COUNT=4
Mark Wielaard 75fe92
 vector_float_CFLAGS    = $(AM_CFLAGS) -march=z13 -DS390_TEST_COUNT=4
Mark Wielaard 75fe92
+vec2_CFLAGS      = $(AM_CFLAGS) -march=z13
Mark Wielaard 75fe92
diff --git a/none/tests/s390x/vec2.c b/none/tests/s390x/vec2.c
Mark Wielaard 75fe92
new file mode 100644
Mark Wielaard 75fe92
index 000000000..73b04dee4
Mark Wielaard 75fe92
--- /dev/null
Mark Wielaard 75fe92
+++ b/none/tests/s390x/vec2.c
Mark Wielaard 75fe92
@@ -0,0 +1,314 @@
Mark Wielaard 75fe92
+#include <stdio.h>
Mark Wielaard 75fe92
+
Mark Wielaard 75fe92
+#define VECTOR __attribute__ ((vector_size (16)))
Mark Wielaard 75fe92
+
Mark Wielaard 75fe92
+typedef unsigned long VECTOR ulong_v;
Mark Wielaard 75fe92
+typedef float VECTOR float_v;
Mark Wielaard 75fe92
+
Mark Wielaard 75fe92
+static const ulong_v vec_a   = { 0x0123456789abcdef, 0xfedcba9876543210 };
Mark Wielaard 75fe92
+static const ulong_v vec_b   = { 0xfedcba9876543210, 0x0123456789abcdef };
Mark Wielaard 75fe92
+static const ulong_v vec_c   = { 0x8040201008040201, 0x7fbfdfeff7fbfdfe };
Mark Wielaard 75fe92
+static const ulong_v vec_one = { -1, -1 };
Mark Wielaard 75fe92
+static const ulong_v vec_ini = { 0x0112233445566778, 0x899aabbccddeeff0 };
Mark Wielaard 75fe92
+
Mark Wielaard 75fe92
+static const float_v vec_fa  = { 16777215., -16777215., 42.5, 10000. };
Mark Wielaard 75fe92
+static const float_v vec_fb  = { 4., 3., 2., 1. };
Mark Wielaard 75fe92
+
Mark Wielaard 75fe92
+/* -- Vector shift -- */
Mark Wielaard 75fe92
+
Mark Wielaard 75fe92
+#define TEST_GENERATE(insn)                             \
Mark Wielaard 75fe92
+   static void test_##insn(ulong_v a, ulong_v b)        \
Mark Wielaard 75fe92
+   {                                                    \
Mark Wielaard 75fe92
+      ulong_v out;                                      \
Mark Wielaard 75fe92
+      __asm__(                                          \
Mark Wielaard 75fe92
+         #insn " %[out],%[a],%[b]"                      \
Mark Wielaard 75fe92
+         : [out] "=v" (out)                             \
Mark Wielaard 75fe92
+         : [a] "v" (a),                                 \
Mark Wielaard 75fe92
+           [b] "v" (b)                                  \
Mark Wielaard 75fe92
+         : );                                           \
Mark Wielaard 75fe92
+      printf("\t%016lx %016lx\n", out[0], out[1]);      \
Mark Wielaard 75fe92
+   }
Mark Wielaard 75fe92
+
Mark Wielaard 75fe92
+#define TEST_EXEC(insn)                         \
Mark Wielaard 75fe92
+   do {                                         \
Mark Wielaard 75fe92
+      puts(#insn);                              \
Mark Wielaard 75fe92
+      test_##insn(vec_a, vec_b);                \
Mark Wielaard 75fe92
+      test_##insn(vec_b, vec_a);                \
Mark Wielaard 75fe92
+      test_##insn(vec_c, vec_a);                \
Mark Wielaard 75fe92
+      test_##insn(vec_one, vec_b);              \
Mark Wielaard 75fe92
+   } while (0)
Mark Wielaard 75fe92
+
Mark Wielaard 75fe92
+#define INSNS                                   \
Mark Wielaard 75fe92
+   XTEST(vsl);                                  \
Mark Wielaard 75fe92
+   XTEST(vsrl);                                 \
Mark Wielaard 75fe92
+   XTEST(vsra);
Mark Wielaard 75fe92
+
Mark Wielaard 75fe92
+#define XTEST TEST_GENERATE
Mark Wielaard 75fe92
+INSNS
Mark Wielaard 75fe92
+#undef XTEST
Mark Wielaard 75fe92
+
Mark Wielaard 75fe92
+static void test_all_single_bitshifts()
Mark Wielaard 75fe92
+{
Mark Wielaard 75fe92
+#define XTEST TEST_EXEC
Mark Wielaard 75fe92
+   INSNS
Mark Wielaard 75fe92
+#undef XTEST
Mark Wielaard 75fe92
+}
Mark Wielaard 75fe92
+#undef INSNS
Mark Wielaard 75fe92
+#undef TEST_EXEC
Mark Wielaard 75fe92
+#undef TEST_GENERATE
Mark Wielaard 75fe92
+
Mark Wielaard 75fe92
+/* -- Vector load element-/byte-swapped -- */
Mark Wielaard 75fe92
+
Mark Wielaard 75fe92
+#define TEST_EXEC(opc1,opc2,insn,m3)            \
Mark Wielaard 75fe92
+   do {                                         \
Mark Wielaard 75fe92
+      puts(#insn " " #m3);                      \
Mark Wielaard 75fe92
+      test_##insn##_##m3(vec_a);                \
Mark Wielaard 75fe92
+      test_##insn##_##m3(vec_b);                \
Mark Wielaard 75fe92
+   } while (0)
Mark Wielaard 75fe92
+
Mark Wielaard 75fe92
+#define TEST_GENERATE(opc1,opc2,insn,m3)                                \
Mark Wielaard 75fe92
+   static void test_##insn##_##m3(ulong_v a)                            \
Mark Wielaard 75fe92
+   {                                                                    \
Mark Wielaard 75fe92
+      ulong_v out = vec_ini;                                            \
Mark Wielaard 75fe92
+      __asm__(                                                          \
Mark Wielaard 75fe92
+         ".insn vrx,0x" #opc1 "00000000" #opc2 ",%[out],%[a]," #m3      \
Mark Wielaard 75fe92
+         : [out] "+v" (out)                                             \
Mark Wielaard 75fe92
+         : [a] "R" (a)                                                  \
Mark Wielaard 75fe92
+         : );                                                           \
Mark Wielaard 75fe92
+      printf("\t%016lx %016lx\n", out[0], out[1]);                      \
Mark Wielaard 75fe92
+   }
Mark Wielaard 75fe92
+
Mark Wielaard 75fe92
+#define INSNS                                   \
Mark Wielaard 75fe92
+   XTEST(e6,01, vlebrh, 0);                     \
Mark Wielaard 75fe92
+   XTEST(e6,01, vlebrh, 7);                     \
Mark Wielaard 75fe92
+   XTEST(e6,01, vlebrh, 2);                     \
Mark Wielaard 75fe92
+   XTEST(e6,03, vlebrf, 0);                     \
Mark Wielaard 75fe92
+   XTEST(e6,03, vlebrf, 3);                     \
Mark Wielaard 75fe92
+   XTEST(e6,03, vlebrf, 1);                     \
Mark Wielaard 75fe92
+   XTEST(e6,02, vlebrg, 0);                     \
Mark Wielaard 75fe92
+   XTEST(e6,02, vlebrg, 1);                     \
Mark Wielaard 75fe92
+   XTEST(e6,04, vllebrz, 1);                    \
Mark Wielaard 75fe92
+   XTEST(e6,04, vllebrz, 2);                    \
Mark Wielaard 75fe92
+   XTEST(e6,04, vllebrz, 3);                    \
Mark Wielaard 75fe92
+   XTEST(e6,04, vllebrz, 6);                    \
Mark Wielaard 75fe92
+   XTEST(e6,05, vlbrrep, 1);                    \
Mark Wielaard 75fe92
+   XTEST(e6,05, vlbrrep, 2);                    \
Mark Wielaard 75fe92
+   XTEST(e6,05, vlbrrep, 3);                    \
Mark Wielaard 75fe92
+   XTEST(e6,06, vlbr, 1);                       \
Mark Wielaard 75fe92
+   XTEST(e6,06, vlbr, 2);                       \
Mark Wielaard 75fe92
+   XTEST(e6,06, vlbr, 3);                       \
Mark Wielaard 75fe92
+   XTEST(e6,06, vlbr, 4);                       \
Mark Wielaard 75fe92
+   XTEST(e6,07, vler, 1);                       \
Mark Wielaard 75fe92
+   XTEST(e6,07, vler, 2);                       \
Mark Wielaard 75fe92
+   XTEST(e6,07, vler, 3);
Mark Wielaard 75fe92
+
Mark Wielaard 75fe92
+#define XTEST TEST_GENERATE
Mark Wielaard 75fe92
+INSNS
Mark Wielaard 75fe92
+#undef XTEST
Mark Wielaard 75fe92
+
Mark Wielaard 75fe92
+static void test_all_swapped_loads()
Mark Wielaard 75fe92
+{
Mark Wielaard 75fe92
+#define XTEST TEST_EXEC
Mark Wielaard 75fe92
+   INSNS
Mark Wielaard 75fe92
+#undef XTEST
Mark Wielaard 75fe92
+}
Mark Wielaard 75fe92
+
Mark Wielaard 75fe92
+#undef INSNS
Mark Wielaard 75fe92
+#undef TEST_GENERATE
Mark Wielaard 75fe92
+
Mark Wielaard 75fe92
+/* -- Vector store element-/byte-swapped -- */
Mark Wielaard 75fe92
+
Mark Wielaard 75fe92
+#define TEST_GENERATE(opc1,opc2,insn,m3)                                \
Mark Wielaard 75fe92
+   static void test_##insn##_##m3(ulong_v a)                            \
Mark Wielaard 75fe92
+   {                                                                    \
Mark Wielaard 75fe92
+      ulong_v out = vec_ini;                                            \
Mark Wielaard 75fe92
+      __asm__(                                                          \
Mark Wielaard 75fe92
+         ".insn vrx,0x" #opc1 "00000000" #opc2 ",%[a],%[out]," #m3      \
Mark Wielaard 75fe92
+         : [out] "+R" (out)                                             \
Mark Wielaard 75fe92
+         : [a] "v" (a)                                                  \
Mark Wielaard 75fe92
+         : );                                                           \
Mark Wielaard 75fe92
+      printf("\t%016lx %016lx\n", out[0], out[1]);                      \
Mark Wielaard 75fe92
+   }
Mark Wielaard 75fe92
+
Mark Wielaard 75fe92
+#define INSNS                                   \
Mark Wielaard 75fe92
+   XTEST(e6,09, vstebrh, 0);                    \
Mark Wielaard 75fe92
+   XTEST(e6,09, vstebrh, 7);                    \
Mark Wielaard 75fe92
+   XTEST(e6,09, vstebrh, 2);                    \
Mark Wielaard 75fe92
+   XTEST(e6,0b, vstebrf, 0);                    \
Mark Wielaard 75fe92
+   XTEST(e6,0b, vstebrf, 3);                    \
Mark Wielaard 75fe92
+   XTEST(e6,0b, vstebrf, 1);                    \
Mark Wielaard 75fe92
+   XTEST(e6,0a, vstebrg, 0);                    \
Mark Wielaard 75fe92
+   XTEST(e6,0a, vstebrg, 1);                    \
Mark Wielaard 75fe92
+   XTEST(e6,0e, vstbr, 1);                      \
Mark Wielaard 75fe92
+   XTEST(e6,0e, vstbr, 2);                      \
Mark Wielaard 75fe92
+   XTEST(e6,0e, vstbr, 3);                      \
Mark Wielaard 75fe92
+   XTEST(e6,0e, vstbr, 4);                      \
Mark Wielaard 75fe92
+   XTEST(e6,0f, vster, 1);                      \
Mark Wielaard 75fe92
+   XTEST(e6,0f, vster, 2);                      \
Mark Wielaard 75fe92
+   XTEST(e6,0f, vster, 3);
Mark Wielaard 75fe92
+
Mark Wielaard 75fe92
+#define XTEST TEST_GENERATE
Mark Wielaard 75fe92
+INSNS
Mark Wielaard 75fe92
+#undef XTEST
Mark Wielaard 75fe92
+
Mark Wielaard 75fe92
+static void test_all_swapped_stores()
Mark Wielaard 75fe92
+{
Mark Wielaard 75fe92
+#define XTEST TEST_EXEC
Mark Wielaard 75fe92
+   INSNS
Mark Wielaard 75fe92
+#undef XTEST
Mark Wielaard 75fe92
+}
Mark Wielaard 75fe92
+
Mark Wielaard 75fe92
+#undef INSNS
Mark Wielaard 75fe92
+#undef TEST_EXEC
Mark Wielaard 75fe92
+#undef TEST_GENERATE
Mark Wielaard 75fe92
+
Mark Wielaard 75fe92
+/* -- Vector shift double by bit -- */
Mark Wielaard 75fe92
+
Mark Wielaard 75fe92
+#define TEST_GENERATE(opc1,opc2,insn,i4)                \
Mark Wielaard 75fe92
+   static void test_##insn##_##i4(ulong_v a, ulong_v b) \
Mark Wielaard 75fe92
+   {                                                    \
Mark Wielaard 75fe92
+      ulong_v out = vec_ini;                            \
Mark Wielaard 75fe92
+      __asm__(                                          \
Mark Wielaard 75fe92
+         ".insn vrr,0x" #opc1 "00000000" #opc2          \
Mark Wielaard 75fe92
+         ",%[out],%[a],%[b],0," #i4 ",0"                \
Mark Wielaard 75fe92
+         : [out] "+v" (out)                             \
Mark Wielaard 75fe92
+         : [a] "v" (a),                                 \
Mark Wielaard 75fe92
+           [b] "v" (b)                                  \
Mark Wielaard 75fe92
+         : );                                           \
Mark Wielaard 75fe92
+      printf("\t%016lx %016lx\n", out[0], out[1]);      \
Mark Wielaard 75fe92
+   }
Mark Wielaard 75fe92
+
Mark Wielaard 75fe92
+#define TEST_EXEC(opc1,opc2,insn,i4)            \
Mark Wielaard 75fe92
+   do {                                         \
Mark Wielaard 75fe92
+      puts(#insn " " #i4);                      \
Mark Wielaard 75fe92
+      test_##insn##_##i4(vec_a, vec_one);       \
Mark Wielaard 75fe92
+      test_##insn##_##i4(vec_b, vec_a);         \
Mark Wielaard 75fe92
+   } while (0)
Mark Wielaard 75fe92
+
Mark Wielaard 75fe92
+#define INSNS                                   \
Mark Wielaard 75fe92
+   XTEST(e7,86,vsld,0);                         \
Mark Wielaard 75fe92
+   XTEST(e7,86,vsld,7);                         \
Mark Wielaard 75fe92
+   XTEST(e7,86,vsld,4);                         \
Mark Wielaard 75fe92
+   XTEST(e7,87,vsrd,0);                         \
Mark Wielaard 75fe92
+   XTEST(e7,87,vsrd,7);                         \
Mark Wielaard 75fe92
+   XTEST(e7,87,vsrd,4);
Mark Wielaard 75fe92
+
Mark Wielaard 75fe92
+#define XTEST TEST_GENERATE
Mark Wielaard 75fe92
+INSNS
Mark Wielaard 75fe92
+#undef XTEST
Mark Wielaard 75fe92
+
Mark Wielaard 75fe92
+static void test_all_double_bitshifts()
Mark Wielaard 75fe92
+{
Mark Wielaard 75fe92
+#define XTEST TEST_EXEC
Mark Wielaard 75fe92
+   INSNS
Mark Wielaard 75fe92
+#undef XTEST
Mark Wielaard 75fe92
+}
Mark Wielaard 75fe92
+
Mark Wielaard 75fe92
+#undef INSNS
Mark Wielaard 75fe92
+#undef TEST_EXEC
Mark Wielaard 75fe92
+#undef TEST_GENERATE
Mark Wielaard 75fe92
+
Mark Wielaard 75fe92
+/* -- Vector integer -> FP conversions -- */
Mark Wielaard 75fe92
+
Mark Wielaard 75fe92
+#define TEST_GENERATE(opc1,opc2,insn,m4)                                \
Mark Wielaard 75fe92
+   static void test_##insn##_##m4(ulong_v a)                            \
Mark Wielaard 75fe92
+   {                                                                    \
Mark Wielaard 75fe92
+      float_v out;                                                      \
Mark Wielaard 75fe92
+      __asm__(                                                          \
Mark Wielaard 75fe92
+         ".insn vrr,0x" #opc1 "00000000" #opc2                          \
Mark Wielaard 75fe92
+         ",%[out],%[a],0,2," #m4 ",0"                                   \
Mark Wielaard 75fe92
+         : [out] "=v" (out)                                             \
Mark Wielaard 75fe92
+         : [a] "v" (a)                                                  \
Mark Wielaard 75fe92
+         : );                                                           \
Mark Wielaard 75fe92
+      if (m4 & 8)                                                       \
Mark Wielaard 75fe92
+         printf("\t%a - - -\n", out[0]);                                \
Mark Wielaard 75fe92
+      else                                                              \
Mark Wielaard 75fe92
+         printf("\t%a %a %a %a\n", out[0], out[1], out[2], out[3]);     \
Mark Wielaard 75fe92
+   }
Mark Wielaard 75fe92
+
Mark Wielaard 75fe92
+#define TEST_EXEC(opc1,opc2,insn,m4)            \
Mark Wielaard 75fe92
+   do {                                         \
Mark Wielaard 75fe92
+      puts(#insn " " #m4);                      \
Mark Wielaard 75fe92
+      test_##insn##_##m4(vec_a);                \
Mark Wielaard 75fe92
+      test_##insn##_##m4(vec_c);                \
Mark Wielaard 75fe92
+   } while (0)
Mark Wielaard 75fe92
+
Mark Wielaard 75fe92
+#define INSNS                                   \
Mark Wielaard 75fe92
+   XTEST(e7,c1,vcfpl,0);                        \
Mark Wielaard 75fe92
+   XTEST(e7,c1,vcfpl,8);                        \
Mark Wielaard 75fe92
+   XTEST(e7,c3,vcfps,0);                        \
Mark Wielaard 75fe92
+   XTEST(e7,c3,vcfps,8);
Mark Wielaard 75fe92
+
Mark Wielaard 75fe92
+#define XTEST TEST_GENERATE
Mark Wielaard 75fe92
+INSNS
Mark Wielaard 75fe92
+#undef XTEST
Mark Wielaard 75fe92
+
Mark Wielaard 75fe92
+static void test_all_int_fp_conversions()
Mark Wielaard 75fe92
+{
Mark Wielaard 75fe92
+#define XTEST TEST_EXEC
Mark Wielaard 75fe92
+   INSNS
Mark Wielaard 75fe92
+#undef XTEST
Mark Wielaard 75fe92
+}
Mark Wielaard 75fe92
+
Mark Wielaard 75fe92
+#undef INSNS
Mark Wielaard 75fe92
+#undef TEST_EXEC
Mark Wielaard 75fe92
+#undef TEST_GENERATE
Mark Wielaard 75fe92
+
Mark Wielaard 75fe92
+/* -- Vector FP -> integer conversions -- */
Mark Wielaard 75fe92
+
Mark Wielaard 75fe92
+#define TEST_GENERATE(opc1,opc2,insn,m4)                                \
Mark Wielaard 75fe92
+   static void test_##insn##_##m4(float_v a)                            \
Mark Wielaard 75fe92
+   {                                                                    \
Mark Wielaard 75fe92
+      unsigned int VECTOR out;                                          \
Mark Wielaard 75fe92
+      __asm__(                                                          \
Mark Wielaard 75fe92
+         ".insn vrr,0x" #opc1 "00000000" #opc2                          \
Mark Wielaard 75fe92
+         ",%[out],%[a],0,2," #m4 ",0"                                   \
Mark Wielaard 75fe92
+         : [out] "=v" (out)                                             \
Mark Wielaard 75fe92
+         : [a] "v" (a)                                                  \
Mark Wielaard 75fe92
+         : );                                                           \
Mark Wielaard 75fe92
+      if (m4 & 8)                                                       \
Mark Wielaard 75fe92
+         printf("\t%08x - - -\n", out[0]);                              \
Mark Wielaard 75fe92
+      else                                                              \
Mark Wielaard 75fe92
+         printf("\t%08x %08x %08x %08x\n",                              \
Mark Wielaard 75fe92
+                out[0], out[1], out[2], out[3]);                        \
Mark Wielaard 75fe92
+   }
Mark Wielaard 75fe92
+
Mark Wielaard 75fe92
+#define TEST_EXEC(opc1,opc2,insn,m4)            \
Mark Wielaard 75fe92
+   do {                                         \
Mark Wielaard 75fe92
+      puts(#insn " " #m4);                      \
Mark Wielaard 75fe92
+      test_##insn##_##m4(vec_fa);               \
Mark Wielaard 75fe92
+      test_##insn##_##m4(vec_fb);               \
Mark Wielaard 75fe92
+   } while (0)
Mark Wielaard 75fe92
+
Mark Wielaard 75fe92
+#define INSNS                                   \
Mark Wielaard 75fe92
+   XTEST(e7,c0,vclfp,0);                        \
Mark Wielaard 75fe92
+   XTEST(e7,c0,vclfp,8);                        \
Mark Wielaard 75fe92
+   XTEST(e7,c2,vcsfp,0);                        \
Mark Wielaard 75fe92
+   XTEST(e7,c2,vcsfp,8);
Mark Wielaard 75fe92
+
Mark Wielaard 75fe92
+#define XTEST TEST_GENERATE
Mark Wielaard 75fe92
+INSNS
Mark Wielaard 75fe92
+#undef XTEST
Mark Wielaard 75fe92
+
Mark Wielaard 75fe92
+static void test_all_fp_int_conversions()
Mark Wielaard 75fe92
+{
Mark Wielaard 75fe92
+#define XTEST TEST_EXEC
Mark Wielaard 75fe92
+   INSNS
Mark Wielaard 75fe92
+#undef XTEST
Mark Wielaard 75fe92
+}
Mark Wielaard 75fe92
+
Mark Wielaard 75fe92
+#undef INSNS
Mark Wielaard 75fe92
+#undef TEST_EXEC
Mark Wielaard 75fe92
+#undef TEST_GENERATE
Mark Wielaard 75fe92
+
Mark Wielaard 75fe92
+
Mark Wielaard 75fe92
+int main()
Mark Wielaard 75fe92
+{
Mark Wielaard 75fe92
+   test_all_single_bitshifts();
Mark Wielaard 75fe92
+   test_all_swapped_loads();
Mark Wielaard 75fe92
+   test_all_swapped_stores();
Mark Wielaard 75fe92
+   test_all_double_bitshifts();
Mark Wielaard 75fe92
+   test_all_int_fp_conversions();
Mark Wielaard 75fe92
+   test_all_fp_int_conversions();
Mark Wielaard 75fe92
+   return 0;
Mark Wielaard 75fe92
+}
Mark Wielaard 75fe92
diff --git a/none/tests/s390x/vec2.stderr.exp b/none/tests/s390x/vec2.stderr.exp
Mark Wielaard 75fe92
new file mode 100644
Mark Wielaard 75fe92
index 000000000..139597f9c
Mark Wielaard 75fe92
--- /dev/null
Mark Wielaard 75fe92
+++ b/none/tests/s390x/vec2.stderr.exp
Mark Wielaard 75fe92
@@ -0,0 +1,2 @@
Mark Wielaard 75fe92
+
Mark Wielaard 75fe92
+
Mark Wielaard 75fe92
diff --git a/none/tests/s390x/vec2.stdout.exp b/none/tests/s390x/vec2.stdout.exp
Mark Wielaard 75fe92
new file mode 100644
Mark Wielaard 75fe92
index 000000000..b32cbe1bc
Mark Wielaard 75fe92
--- /dev/null
Mark Wielaard 75fe92
+++ b/none/tests/s390x/vec2.stdout.exp
Mark Wielaard 75fe92
@@ -0,0 +1,168 @@
Mark Wielaard 75fe92
+vsl
Mark Wielaard 75fe92
+	483415676abc37ef fde5533beca14200
Mark Wielaard 75fe92
+	fde5533beca14200 483415676abc37ef
Mark Wielaard 75fe92
+	00010204102040bf effd7feffebff7fe
Mark Wielaard 75fe92
+	ffffffffffffffff ffffffffffffff80
Mark Wielaard 75fe92
+vsrl
Mark Wielaard 75fe92
+	0012d1679e9af3ef ffdbe5753bcaa164
Mark Wielaard 75fe92
+	7fdbe5753bcaa164 4012d1679e9af3ef
Mark Wielaard 75fe92
+	4008014004002004 05fbf7efbf7ffffe
Mark Wielaard 75fe92
+	03ffffffffffffff ffffffffffffffff
Mark Wielaard 75fe92
+vsra
Mark Wielaard 75fe92
+	0012d1679e9af3ef ffdbe5753bcaa164
Mark Wielaard 75fe92
+	ffdbe5753bcaa164 4012d1679e9af3ef
Mark Wielaard 75fe92
+	c008014004002004 05fbf7efbf7ffffe
Mark Wielaard 75fe92
+	ffffffffffffffff ffffffffffffffff
Mark Wielaard 75fe92
+vlebrh 0
Mark Wielaard 75fe92
+	2301233445566778 899aabbccddeeff0
Mark Wielaard 75fe92
+	dcfe233445566778 899aabbccddeeff0
Mark Wielaard 75fe92
+vlebrh 7
Mark Wielaard 75fe92
+	0112233445566778 899aabbccdde2301
Mark Wielaard 75fe92
+	0112233445566778 899aabbccddedcfe
Mark Wielaard 75fe92
+vlebrh 2
Mark Wielaard 75fe92
+	0112233423016778 899aabbccddeeff0
Mark Wielaard 75fe92
+	01122334dcfe6778 899aabbccddeeff0
Mark Wielaard 75fe92
+vlebrf 0
Mark Wielaard 75fe92
+	6745230145566778 899aabbccddeeff0
Mark Wielaard 75fe92
+	98badcfe45566778 899aabbccddeeff0
Mark Wielaard 75fe92
+vlebrf 3
Mark Wielaard 75fe92
+	0112233445566778 899aabbc67452301
Mark Wielaard 75fe92
+	0112233445566778 899aabbc98badcfe
Mark Wielaard 75fe92
+vlebrf 1
Mark Wielaard 75fe92
+	0112233467452301 899aabbccddeeff0
Mark Wielaard 75fe92
+	0112233498badcfe 899aabbccddeeff0
Mark Wielaard 75fe92
+vlebrg 0
Mark Wielaard 75fe92
+	efcdab8967452301 899aabbccddeeff0
Mark Wielaard 75fe92
+	1032547698badcfe 899aabbccddeeff0
Mark Wielaard 75fe92
+vlebrg 1
Mark Wielaard 75fe92
+	0112233445566778 efcdab8967452301
Mark Wielaard 75fe92
+	0112233445566778 1032547698badcfe
Mark Wielaard 75fe92
+vllebrz 1
Mark Wielaard 75fe92
+	0000000000002301 0000000000000000
Mark Wielaard 75fe92
+	000000000000dcfe 0000000000000000
Mark Wielaard 75fe92
+vllebrz 2
Mark Wielaard 75fe92
+	0000000067452301 0000000000000000
Mark Wielaard 75fe92
+	0000000098badcfe 0000000000000000
Mark Wielaard 75fe92
+vllebrz 3
Mark Wielaard 75fe92
+	efcdab8967452301 0000000000000000
Mark Wielaard 75fe92
+	1032547698badcfe 0000000000000000
Mark Wielaard 75fe92
+vllebrz 6
Mark Wielaard 75fe92
+	6745230100000000 0000000000000000
Mark Wielaard 75fe92
+	98badcfe00000000 0000000000000000
Mark Wielaard 75fe92
+vlbrrep 1
Mark Wielaard 75fe92
+	2301230123012301 2301230123012301
Mark Wielaard 75fe92
+	dcfedcfedcfedcfe dcfedcfedcfedcfe
Mark Wielaard 75fe92
+vlbrrep 2
Mark Wielaard 75fe92
+	6745230167452301 6745230167452301
Mark Wielaard 75fe92
+	98badcfe98badcfe 98badcfe98badcfe
Mark Wielaard 75fe92
+vlbrrep 3
Mark Wielaard 75fe92
+	efcdab8967452301 efcdab8967452301
Mark Wielaard 75fe92
+	1032547698badcfe 1032547698badcfe
Mark Wielaard 75fe92
+vlbr 1
Mark Wielaard 75fe92
+	23016745ab89efcd dcfe98ba54761032
Mark Wielaard 75fe92
+	dcfe98ba54761032 23016745ab89efcd
Mark Wielaard 75fe92
+vlbr 2
Mark Wielaard 75fe92
+	67452301efcdab89 98badcfe10325476
Mark Wielaard 75fe92
+	98badcfe10325476 67452301efcdab89
Mark Wielaard 75fe92
+vlbr 3
Mark Wielaard 75fe92
+	efcdab8967452301 1032547698badcfe
Mark Wielaard 75fe92
+	1032547698badcfe efcdab8967452301
Mark Wielaard 75fe92
+vlbr 4
Mark Wielaard 75fe92
+	1032547698badcfe efcdab8967452301
Mark Wielaard 75fe92
+	efcdab8967452301 1032547698badcfe
Mark Wielaard 75fe92
+vler 1
Mark Wielaard 75fe92
+	32107654ba98fedc cdef89ab45670123
Mark Wielaard 75fe92
+	cdef89ab45670123 32107654ba98fedc
Mark Wielaard 75fe92
+vler 2
Mark Wielaard 75fe92
+	76543210fedcba98 89abcdef01234567
Mark Wielaard 75fe92
+	89abcdef01234567 76543210fedcba98
Mark Wielaard 75fe92
+vler 3
Mark Wielaard 75fe92
+	fedcba9876543210 0123456789abcdef
Mark Wielaard 75fe92
+	0123456789abcdef fedcba9876543210
Mark Wielaard 75fe92
+vstebrh 0
Mark Wielaard 75fe92
+	2301233445566778 899aabbccddeeff0
Mark Wielaard 75fe92
+	dcfe233445566778 899aabbccddeeff0
Mark Wielaard 75fe92
+vstebrh 7
Mark Wielaard 75fe92
+	1032233445566778 899aabbccddeeff0
Mark Wielaard 75fe92
+	efcd233445566778 899aabbccddeeff0
Mark Wielaard 75fe92
+vstebrh 2
Mark Wielaard 75fe92
+	ab89233445566778 899aabbccddeeff0
Mark Wielaard 75fe92
+	5476233445566778 899aabbccddeeff0
Mark Wielaard 75fe92
+vstebrf 0
Mark Wielaard 75fe92
+	6745230145566778 899aabbccddeeff0
Mark Wielaard 75fe92
+	98badcfe45566778 899aabbccddeeff0
Mark Wielaard 75fe92
+vstebrf 3
Mark Wielaard 75fe92
+	1032547645566778 899aabbccddeeff0
Mark Wielaard 75fe92
+	efcdab8945566778 899aabbccddeeff0
Mark Wielaard 75fe92
+vstebrf 1
Mark Wielaard 75fe92
+	efcdab8945566778 899aabbccddeeff0
Mark Wielaard 75fe92
+	1032547645566778 899aabbccddeeff0
Mark Wielaard 75fe92
+vstebrg 0
Mark Wielaard 75fe92
+	efcdab8967452301 899aabbccddeeff0
Mark Wielaard 75fe92
+	1032547698badcfe 899aabbccddeeff0
Mark Wielaard 75fe92
+vstebrg 1
Mark Wielaard 75fe92
+	1032547698badcfe 899aabbccddeeff0
Mark Wielaard 75fe92
+	efcdab8967452301 899aabbccddeeff0
Mark Wielaard 75fe92
+vstbr 1
Mark Wielaard 75fe92
+	23016745ab89efcd dcfe98ba54761032
Mark Wielaard 75fe92
+	dcfe98ba54761032 23016745ab89efcd
Mark Wielaard 75fe92
+vstbr 2
Mark Wielaard 75fe92
+	67452301efcdab89 98badcfe10325476
Mark Wielaard 75fe92
+	98badcfe10325476 67452301efcdab89
Mark Wielaard 75fe92
+vstbr 3
Mark Wielaard 75fe92
+	efcdab8967452301 1032547698badcfe
Mark Wielaard 75fe92
+	1032547698badcfe efcdab8967452301
Mark Wielaard 75fe92
+vstbr 4
Mark Wielaard 75fe92
+	1032547698badcfe efcdab8967452301
Mark Wielaard 75fe92
+	efcdab8967452301 1032547698badcfe
Mark Wielaard 75fe92
+vster 1
Mark Wielaard 75fe92
+	32107654ba98fedc cdef89ab45670123
Mark Wielaard 75fe92
+	cdef89ab45670123 32107654ba98fedc
Mark Wielaard 75fe92
+vster 2
Mark Wielaard 75fe92
+	76543210fedcba98 89abcdef01234567
Mark Wielaard 75fe92
+	89abcdef01234567 76543210fedcba98
Mark Wielaard 75fe92
+vster 3
Mark Wielaard 75fe92
+	fedcba9876543210 0123456789abcdef
Mark Wielaard 75fe92
+	0123456789abcdef fedcba9876543210
Mark Wielaard 75fe92
+vsld 0
Mark Wielaard 75fe92
+	0123456789abcdef fedcba9876543210
Mark Wielaard 75fe92
+	fedcba9876543210 0123456789abcdef
Mark Wielaard 75fe92
+vsld 7
Mark Wielaard 75fe92
+	91a2b3c4d5e6f7ff 6e5d4c3b2a19087f
Mark Wielaard 75fe92
+	6e5d4c3b2a190800 91a2b3c4d5e6f780
Mark Wielaard 75fe92
+vsld 4
Mark Wielaard 75fe92
+	123456789abcdeff edcba9876543210f
Mark Wielaard 75fe92
+	edcba98765432100 123456789abcdef0
Mark Wielaard 75fe92
+vsrd 0
Mark Wielaard 75fe92
+	ffffffffffffffff ffffffffffffffff
Mark Wielaard 75fe92
+	0123456789abcdef fedcba9876543210
Mark Wielaard 75fe92
+vsrd 7
Mark Wielaard 75fe92
+	21ffffffffffffff ffffffffffffffff
Mark Wielaard 75fe92
+	de02468acf13579b dffdb97530eca864
Mark Wielaard 75fe92
+vsrd 4
Mark Wielaard 75fe92
+	0fffffffffffffff ffffffffffffffff
Mark Wielaard 75fe92
+	f0123456789abcde ffedcba987654321
Mark Wielaard 75fe92
+vcfpl 0
Mark Wielaard 75fe92
+	0x1.234568p+24 0x1.13579cp+31 0x1.fdb976p+31 0x1.d950c8p+30
Mark Wielaard 75fe92
+	0x1.00804p+31 0x1.00804p+27 0x1.feff8p+30 0x1.eff7fcp+31
Mark Wielaard 75fe92
+vcfpl 8
Mark Wielaard 75fe92
+	0x1.234568p+24 - - -
Mark Wielaard 75fe92
+	0x1.00804p+31 - - -
Mark Wielaard 75fe92
+vcfps 0
Mark Wielaard 75fe92
+	0x1.234568p+24 -0x1.d950c8p+30 -0x1.234568p+24 0x1.d950c8p+30
Mark Wielaard 75fe92
+	-0x1.feff8p+30 0x1.00804p+27 0x1.feff8p+30 -0x1.00804p+27
Mark Wielaard 75fe92
+vcfps 8
Mark Wielaard 75fe92
+	0x1.234568p+24 - - -
Mark Wielaard 75fe92
+	-0x1.feff8p+30 - - -
Mark Wielaard 75fe92
+vclfp 0
Mark Wielaard 75fe92
+	00ffffff 00000000 0000002a 00002710
Mark Wielaard 75fe92
+	00000004 00000003 00000002 00000001
Mark Wielaard 75fe92
+vclfp 8
Mark Wielaard 75fe92
+	00ffffff - - -
Mark Wielaard 75fe92
+	00000004 - - -
Mark Wielaard 75fe92
+vcsfp 0
Mark Wielaard 75fe92
+	00ffffff ff000001 0000002a 00002710
Mark Wielaard 75fe92
+	00000004 00000003 00000002 00000001
Mark Wielaard 75fe92
+vcsfp 8
Mark Wielaard 75fe92
+	00ffffff - - -
Mark Wielaard 75fe92
+	00000004 - - -
Mark Wielaard 75fe92
diff --git a/none/tests/s390x/vec2.vgtest b/none/tests/s390x/vec2.vgtest
Mark Wielaard 75fe92
new file mode 100644
Mark Wielaard 75fe92
index 000000000..45e942e64
Mark Wielaard 75fe92
--- /dev/null
Mark Wielaard 75fe92
+++ b/none/tests/s390x/vec2.vgtest
Mark Wielaard 75fe92
@@ -0,0 +1,2 @@
Mark Wielaard 75fe92
+prog: vec2
Mark Wielaard 75fe92
+prereq: test -e vec2 && ../../../tests/s390x_features s390x-vx
Mark Wielaard 75fe92
diff --git a/tests/s390x_features.c b/tests/s390x_features.c
Mark Wielaard 75fe92
index 25b98f3a3..e7939c463 100644
Mark Wielaard 75fe92
--- a/tests/s390x_features.c
Mark Wielaard 75fe92
+++ b/tests/s390x_features.c
Mark Wielaard 75fe92
@@ -270,6 +270,10 @@ static int go(char *feature, char *cpu)
Mark Wielaard 75fe92
       match = facilities[0] & FAC_BIT(57); /* message security assist 5 facility */
Mark Wielaard 75fe92
    } else if (strcmp(feature, "s390x-mi2") == 0 ) {
Mark Wielaard 75fe92
       match = facilities[0] & FAC_BIT(58);
Mark Wielaard 75fe92
+   } else if (strcmp(feature, "s390x-mi3") == 0 ) {
Mark Wielaard 75fe92
+      match = facilities[0] & FAC_BIT(61);
Mark Wielaard 75fe92
+   } else if (strcmp(feature, "s390x-vx2") == 0 ) {
Mark Wielaard 75fe92
+      match = facilities[2] & FAC_BIT(20);
Mark Wielaard 75fe92
    } else {
Mark Wielaard 75fe92
       return 2;          // Unrecognised feature.
Mark Wielaard 75fe92
    }
Mark Wielaard 75fe92
-- 
Mark Wielaard 75fe92
2.23.0
Mark Wielaard 75fe92
Mark Wielaard 75fe92
From d9364bc90ee894c43ee742840f806571edc08ab3 Mon Sep 17 00:00:00 2001
Mark Wielaard 75fe92
From: Andreas Arnez <arnez@linux.ibm.com>
Mark Wielaard 75fe92
Date: Tue, 18 May 2021 19:59:32 +0200
Mark Wielaard 75fe92
Subject: [PATCH 13/13] s390x: Wrap up misc-insn-3 and vec-enh-2 support
Mark Wielaard 75fe92
Mark Wielaard 75fe92
Wrap up support for the miscellaneous-instruction-extensions facility 3
Mark Wielaard 75fe92
and the vector-enhancements facility 2: Add 'case' statements for the
Mark Wielaard 75fe92
remaining unhandled arch13 instructions to 'guest_s390_toIR.c', document
Mark Wielaard 75fe92
the new support in 's390-opcodes.csv', adjust 's390-check-opcodes.pl', and
Mark Wielaard 75fe92
announce the new feature in 'NEWS'.
Mark Wielaard 75fe92
---
Mark Wielaard 75fe92
 NEWS                            |  5 ++
Mark Wielaard 75fe92
 VEX/priv/guest_s390_toIR.c      |  5 +-
Mark Wielaard 75fe92
 auxprogs/s390-check-opcodes.pl  | 22 ++++++++-
Mark Wielaard 75fe92
 docs/internals/s390-opcodes.csv | 81 +++++++++++++++++++++++++++++++--
Mark Wielaard 75fe92
 4 files changed, 108 insertions(+), 5 deletions(-)
Mark Wielaard 75fe92
Mark Wielaard 75fe92
diff --git a/VEX/priv/guest_s390_toIR.c b/VEX/priv/guest_s390_toIR.c
Mark Wielaard 75fe92
index 46a867475..1bd18f760 100644
Mark Wielaard 75fe92
--- a/VEX/priv/guest_s390_toIR.c
Mark Wielaard 75fe92
+++ b/VEX/priv/guest_s390_toIR.c
Mark Wielaard 75fe92
@@ -8,7 +8,7 @@
Mark Wielaard 75fe92
    This file is part of Valgrind, a dynamic binary instrumentation
Mark Wielaard 75fe92
    framework.
Mark Wielaard 75fe92
 
Mark Wielaard 75fe92
-   Copyright IBM Corp. 2010-2020
Mark Wielaard 75fe92
+   Copyright IBM Corp. 2010-2021
Mark Wielaard 75fe92
 
Mark Wielaard 75fe92
    This program is free software; you can redistribute it and/or
Mark Wielaard 75fe92
    modify it under the terms of the GNU General Public License as
Mark Wielaard 75fe92
@@ -20503,6 +20503,9 @@ s390_decode_4byte_and_irgen(const UChar *bytes)
Mark Wielaard 75fe92
                                    RRE_r2(ovl));  goto ok;
Mark Wielaard 75fe92
    case 0xb931: s390_format_RRE_RR(s390_irgen_CLGFR, RRE_r1(ovl),
Mark Wielaard 75fe92
                                    RRE_r2(ovl));  goto ok;
Mark Wielaard 75fe92
+   case 0xb938: /* SORTL */ goto unimplemented;
Mark Wielaard 75fe92
+   case 0xb939: /* DFLTCC */ goto unimplemented;
Mark Wielaard 75fe92
+   case 0xb93a: /* KDSA */ goto unimplemented;
Mark Wielaard 75fe92
    case 0xb93c: s390_format_RRE_RR(s390_irgen_PPNO, RRE_r1(ovl),
Mark Wielaard 75fe92
                                    RRE_r2(ovl));  goto ok;
Mark Wielaard 75fe92
    case 0xb93e: /* KIMD */ goto unimplemented;
Mark Wielaard 75fe92
-- 
Mark Wielaard 75fe92
2.23.0
Mark Wielaard 75fe92