]> git.ipfire.org Git - thirdparty/valgrind.git/commitdiff
s390: general-instructions-extension facility related cleanups (BZ 509562)
authorFlorian Krohm <flo2030@eich-krohm.de>
Tue, 25 Nov 2025 09:14:11 +0000 (09:14 +0000)
committerFlorian Krohm <flo2030@eich-krohm.de>
Tue, 25 Nov 2025 09:14:11 +0000 (09:14 +0000)
The general-instructions-extension facility is always present on the
supported machines.
- Remove VEX_HWCAPS_S390X_GIE and s390_host_has_gie
- Remove wrapper functions: s390_emit_MFYw, s390_emit_MHYw, s390_emit_MSFIw
- Update tests/s390x_features.c

Part of fixing https://bugs.kde.org/show_bug.cgi?id=509562

VEX/priv/host_s390_defs.c
VEX/priv/host_s390_defs.h
VEX/priv/host_s390_isel.c
VEX/priv/main_main.c
VEX/pub/libvex.h
coregrind/m_machine.c
tests/s390x_features.c

index 7b8dbe63dbbb12547a8864942a574b53346484d5..dde8d65466a62f2be8604680505e91bf84f4d558 100644 (file)
@@ -2108,8 +2108,6 @@ s390_emit_AGHI(UChar *p, UChar r1, UShort i2)
 static UChar *
 s390_emit_AGSI(UChar *p, UChar i2, UChar b1, UShort dl1, UChar dh1)
 {
-   vassert(s390_host_has_gie);
-
    if (UNLIKELY(vex_traceflags & VEX_TRACE_ASM))
       S390_DISASM(MNM("agsi"), SDXB(dh1, dl1, 0, b1), INT((Int)(Char)i2));
 
@@ -2120,8 +2118,6 @@ s390_emit_AGSI(UChar *p, UChar i2, UChar b1, UShort dl1, UChar dh1)
 static UChar *
 s390_emit_ASI(UChar *p, UChar i2, UChar b1, UShort dl1, UChar dh1)
 {
-   vassert(s390_host_has_gie);
-
    if (UNLIKELY(vex_traceflags & VEX_TRACE_ASM))
       S390_DISASM(MNM("asi"), SDXB(dh1, dl1, 0, b1), INT((Int)(Char)i2));
 
@@ -3092,8 +3088,6 @@ s390_emit_M(UChar *p, UChar r1, UChar x2, UChar b2, UShort d2)
 static UChar *
 s390_emit_MFY(UChar *p, UChar r1, UChar x2, UChar b2, UShort dl2, UChar dh2)
 {
-   vassert(s390_host_has_gie);
-
    if (UNLIKELY(vex_traceflags & VEX_TRACE_ASM))
       S390_DISASM(MNM("mfy"), GPR(r1), SDXB(dh2, dl2, x2, b2));
 
@@ -3134,8 +3128,6 @@ s390_emit_MH(UChar *p, UChar r1, UChar x2, UChar b2, UShort d2)
 static UChar *
 s390_emit_MHY(UChar *p, UChar r1, UChar x2, UChar b2, UShort dl2, UChar dh2)
 {
-   vassert(s390_host_has_gie);
-
    if (UNLIKELY(vex_traceflags & VEX_TRACE_ASM))
       S390_DISASM(MNM("mhy"), GPR(r1), SDXB(dh2, dl2, x2, b2));
 
@@ -3246,8 +3238,6 @@ s390_emit_MSG(UChar *p, UChar r1, UChar x2, UChar b2, UShort dl2, UChar dh2)
 static UChar *
 s390_emit_MSFI(UChar *p, UChar r1, UInt i2)
 {
-   vassert(s390_host_has_gie);
-
    if (UNLIKELY(vex_traceflags & VEX_TRACE_ASM))
       S390_DISASM(MNM("msfi"), GPR(r1), INT(i2));
 
@@ -3258,8 +3248,6 @@ s390_emit_MSFI(UChar *p, UChar r1, UInt i2)
 static UChar *
 s390_emit_MSGFI(UChar *p, UChar r1, UInt i2)
 {
-   vassert(s390_host_has_gie);
-
    if (UNLIKELY(vex_traceflags & VEX_TRACE_ASM))
       S390_DISASM(MNM("msgfi"), GPR(r1), INT(i2));
 
@@ -3290,8 +3278,6 @@ s390_emit_MVI(UChar *p, UChar i2, UChar b1, UShort d1)
 static UChar *
 s390_emit_MVHHI(UChar *p, UChar b1, UShort d1, UShort i2)
 {
-   vassert(s390_host_has_gie);
-
    if (UNLIKELY(vex_traceflags & VEX_TRACE_ASM))
       S390_DISASM(MNM("mvhhi"), UDXB(d1, 0, b1), INT((Int)(Short)i2));
 
@@ -3302,8 +3288,6 @@ s390_emit_MVHHI(UChar *p, UChar b1, UShort d1, UShort i2)
 static UChar *
 s390_emit_MVHI(UChar *p, UChar b1, UShort d1, UShort i2)
 {
-   vassert(s390_host_has_gie);
-
    if (UNLIKELY(vex_traceflags & VEX_TRACE_ASM))
       S390_DISASM(MNM("mvhi"), UDXB(d1, 0, b1), INT((Int)(Short)i2));
 
@@ -3314,8 +3298,6 @@ s390_emit_MVHI(UChar *p, UChar b1, UShort d1, UShort i2)
 static UChar *
 s390_emit_MVGHI(UChar *p, UChar b1, UShort d1, UShort i2)
 {
-   vassert(s390_host_has_gie);
-
    if (UNLIKELY(vex_traceflags & VEX_TRACE_ASM))
       S390_DISASM(MNM("mvghi"), UDXB(d1, 0, b1), INT((Int)(Short)i2));
 
@@ -5107,46 +5089,6 @@ s390_emit_load_32imm(UChar *p, UChar reg, UInt val)
 /*--- Wrapper functions                                    ---*/
 /*------------------------------------------------------------*/
 
-/* r1[32:63],r1+1[32:63] = r1+1[32:63] * memory[op2addr][0:31] */
-static UChar *
-s390_emit_MFYw(UChar *p, UChar r1, UChar x, UChar b,  UShort dl, UChar dh)
-{
-   if (s390_host_has_gie) {
-      return s390_emit_MFY(p, r1, x, b, dl, dh);
-   }
-
-   /* Load from memory into R0, then MULTIPLY with R1 */
-   p = s390_emit_LY(p, R0, x, b, dl, dh);
-   return s390_emit_MR(p, r1, R0);
-}
-
-/* r1[32:63] = r1[32:63] * memory[op2addr][0:15] */
-static UChar *
-s390_emit_MHYw(UChar *p, UChar r1, UChar x, UChar b,  UShort dl, UChar dh)
-{
-   if (s390_host_has_gie) {
-      return s390_emit_MHY(p, r1, x, b, dl, dh);
-   }
-
-   /* Load from memory into R0, then MULTIPLY with R1 */
-   p = s390_emit_LHY(p, R0, x, b, dl, dh);
-   return s390_emit_MSR(p, r1, R0);
-}
-
-/* r1[32:63] = r1[32:63] * i2 */
-static UChar *
-s390_emit_MSFIw(UChar *p, UChar r1, UInt i2)
-{
-   if (s390_host_has_gie) {
-      return s390_emit_MSFI(p, r1, i2);
-   }
-
-   /* Load I2 into R0; then MULTIPLY R0 with R1 */
-   p = s390_emit_load_32imm(p, R0, i2);
-   return s390_emit_MSR(p, r1, R0);
-}
-
-
 static UChar *
 s390_emit_LGDRw(UChar *p, UChar r1, UChar r2)
 {
@@ -6785,8 +6727,6 @@ s390_insn_madd(UChar size, s390_amode *dst, UChar delta, ULong value)
    /* This insn will be mapped to an ASI or AGSI so we can only allow base
       register plus 12-bit / 20-bit displacement. */
    vassert(dst->tag == S390_AMODE_B12 || dst->tag == S390_AMODE_B20);
-   /* ASI and AGSI require the GIE facility */
-   vassert(s390_host_has_gie);
 
    insn->tag  = S390_INSN_MADD;
    insn->size = size;
@@ -8173,17 +8113,8 @@ s390_insn_load_immediate_emit(UChar *buf, const s390_insn *insn)
 static UChar *
 s390_emit_ilih(UChar *buf, UChar size, UChar dst, UChar r2)
 {
-   if (s390_host_has_gie)
-      return s390_emit_RISBG(buf, dst, r2, 64 - 8 * size, 63 - 4 * size,
-                             4 * size);
-
-   /* Clear dst's upper half. */
-   buf = s390_emit_SLLG(buf, dst, dst, 0, DISP20(64 - 4 * size));
-   buf = s390_emit_SRLG(buf, dst, dst, 0, DISP20(64 - 4 * size));
-
-   /* Shift r2 by appropriate amount and OR it into dst. */
-   buf = s390_emit_SLLG(buf, R0, r2, 0, DISP20(4 * size));
-   return s390_emit_OGR(buf, dst, R0);
+   return s390_emit_RISBG(buf, dst, r2, 64 - 8 * size, 63 - 4 * size,
+                          4 * size);
 }
 
 
@@ -8366,7 +8297,7 @@ s390_insn_alu_emit(UChar *buf, const s390_insn *insn)
                return s390_emit_SHY(buf, dst, x, b, DISP20(d));
 
             case S390_ALU_MUL:
-               return s390_emit_MHYw(buf, dst, x, b, DISP20(d));
+               return s390_emit_MHY(buf, dst, x, b, DISP20(d));
 
                /* For bitwise operations: Move two bytes from memory into scratch
                   register r0; then perform operation */
@@ -8497,7 +8428,7 @@ s390_insn_alu_emit(UChar *buf, const s390_insn *insn)
             return s390_emit_AFI(buf, dst, value);
 
          case S390_ALU_SUB:  return s390_emit_SLFI(buf, dst, value);
-         case S390_ALU_MUL:  return s390_emit_MSFIw(buf, dst, value);
+         case S390_ALU_MUL:  return s390_emit_MSFI(buf, dst, value);
          case S390_ALU_AND:  return s390_emit_NILF(buf, dst, value);
          case S390_ALU_OR:   return s390_emit_OILF(buf, dst, value);
          case S390_ALU_XOR:  return s390_emit_XILF(buf, dst, value);
@@ -8530,7 +8461,7 @@ s390_insn_alu_emit(UChar *buf, const s390_insn *insn)
             return s390_emit_SGR(buf, dst, R0);
 
          case S390_ALU_MUL:
-            if (ulong_fits_signed_32bit(value) && s390_host_has_gie) {
+            if (ulong_fits_signed_32bit(value)) {
                return s390_emit_MSGFI(buf, dst, value);
             }
             /* Load constant into R0 then add */
@@ -9367,7 +9298,7 @@ s390_insn_mul_emit(UChar *buf, const s390_insn *insn)
          case S390_AMODE_B20:
          case S390_AMODE_BX20:
             if (signed_multiply)
-               return s390_emit_MFYw(buf, r1, x, b, DISP20(d));
+               return s390_emit_MFY(buf, r1, x, b, DISP20(d));
             else
                return s390_emit_ML(buf, r1, x, b, DISP20(d));
          }
@@ -10329,7 +10260,7 @@ s390_insn_mimm_emit(UChar *buf, const s390_insn *insn)
       return s390_emit_MVI(buf, value & 0xFF, b, d);
    }
 
-   if (s390_host_has_gie && ulong_fits_signed_16bit(value)) {
+   if (ulong_fits_signed_16bit(value)) {
       value &= 0xFFFF;
       switch (insn->size) {
       case 2: return s390_emit_MVHHI(buf, b, d, value);
@@ -10734,13 +10665,7 @@ s390_insn_evcheck_emit(UChar *buf, const s390_insn *insn,
    d = amode->d;
 
    /* Decrement the dispatch counter in the guest state */
-   if (s390_host_has_gie) {
-      buf = s390_emit_ASI(buf, -1, b, DISP20(d));   /* 6 bytes */
-   } else {
-      buf = s390_emit_LHI(buf, R0, -1);             /* 4 bytes */
-      buf = s390_emit_A(buf, R0, 0, b, d);          /* 4 bytes */
-      buf = s390_emit_ST(buf, R0, 0, b, d);         /* 4 bytes */
-   }
+   buf = s390_emit_ASI(buf, -1, b, DISP20(d));   /* 6 bytes */
 
    /* Jump over the next insn if >= 0 */
    buf = s390_emit_BRC(buf, S390_CC_HE, (4 + 6 + 2) / 2);  /* 4 bytes */
@@ -10771,13 +10696,7 @@ s390_insn_profinc_emit(UChar *buf,
       template will be patched once the memory location is known.
       For now we do this with address == 0. */
    buf = s390_tchain_load64(buf, S390_REGNO_TCHAIN_SCRATCH, 0);
-   if (s390_host_has_gie) {
-      buf = s390_emit_AGSI(buf, 1, S390_REGNO_TCHAIN_SCRATCH, DISP20(0));
-   } else {
-      buf = s390_emit_LGHI(buf, R0, 1);
-      buf = s390_emit_AG( buf, R0, 0, S390_REGNO_TCHAIN_SCRATCH, DISP20(0));
-      buf = s390_emit_STG(buf, R0, 0, S390_REGNO_TCHAIN_SCRATCH, DISP20(0));
-   }
+   buf = s390_emit_AGSI(buf, 1, S390_REGNO_TCHAIN_SCRATCH, DISP20(0));
 
    return buf;
 }
@@ -11223,7 +11142,7 @@ emit_S390Instr(Bool *is_profinc, UChar *buf, Int nbuf, const s390_insn *insn,
 Int
 evCheckSzB_S390(void)
 {
-   return s390_host_has_gie ? 18 : 24;
+   return 18;
 }
 
 
index 9b5e3f00ac8d737d7ac91172a82365ed2959882c..1845ccd002dd4fb222752d12bd7635b8944c7b64 100644 (file)
@@ -918,8 +918,6 @@ VexInvalRange patchProfInc_S390(VexEndness endness_host,
 extern UInt s390_host_hwcaps;
 
 /* Convenience macros to test installed facilities */
-#define s390_host_has_gie \
-                      (s390_host_hwcaps & (VEX_HWCAPS_S390X_GIE))
 #define s390_host_has_fgx \
                       (s390_host_hwcaps & (VEX_HWCAPS_S390X_FGX))
 #define s390_host_has_lsc \
index a0d9b75373bf3c29e719067de97ce4d617c7e606..9cb9b65d3b5994459d6d14b28b6b0ec01e8499a6 100644 (file)
@@ -5006,7 +5006,7 @@ s390_isel_stmt(ISelEnv *env, IRStmt *stmt)
          we can use a memory-to-memory insn */
       difference = new_value - old_value;
 
-      if (s390_host_has_gie && ulong_fits_signed_8bit(difference)) {
+      if (ulong_fits_signed_8bit(difference)) {
          am = s390_amode_for_guest_state(offset);
          addInstr(env, s390_insn_madd(sizeofIRType(tyd), am,
                                       (difference & 0xFF), new_value));
index da3ccbd8213adb1e3654f02d0f3982da2a03d35d..c1cda11038f55182ba67d5902e5c8435f873cd66 100644 (file)
@@ -1902,7 +1902,6 @@ static const HChar* show_hwcaps_s390x ( UInt hwcaps )
       UInt  hwcaps_bit;
       HChar name[6];
    } hwcaps_list[] = {
-      { VEX_HWCAPS_S390X_GIE,   "gie" },
       { VEX_HWCAPS_S390X_FGX,   "fgx" },
       { VEX_HWCAPS_S390X_LSC,   "lsc" },
       { VEX_HWCAPS_S390X_PFPO,  "pfpo" },
index cef40335ef028ecb3473e13d42ecd91b38365d31..b5ae0ebcc798372b75d9e2192e6bb05b288d8a8f 100644 (file)
@@ -162,7 +162,6 @@ typedef
 #define VEX_S390X_MODEL_UNKNOWN  19     /* always last in list */
 #define VEX_S390X_MODEL_MASK     0x3F
 
-#define VEX_HWCAPS_S390X_GIE   (1<<8)   /* General-instruction-extension facility */
 #define VEX_HWCAPS_S390X_FGX   (1<<10)  /* FPR-GR transfer facility */
 #define VEX_HWCAPS_S390X_LSC   (1<<16)  /* Conditional load/store facility */
 #define VEX_HWCAPS_S390X_PFPO  (1<<17)  /* Perform floating point ops facility */
@@ -179,8 +178,7 @@ typedef
 #define VEX_HWCAPS_S390X_MSA9  (1<<30)  /* Message-security-assist extension 9 */
 
 /* Special value representing all available s390x hwcaps */
-#define VEX_HWCAPS_S390X_ALL   (VEX_HWCAPS_S390X_GIE   | \
-                                VEX_HWCAPS_S390X_FGX   | \
+#define VEX_HWCAPS_S390X_ALL   (VEX_HWCAPS_S390X_FGX   | \
                                 VEX_HWCAPS_S390X_LSC   | \
                                 VEX_HWCAPS_S390X_PFPO  | \
                                 VEX_HWCAPS_S390X_VX    | \
index e7aca5cb32af83f1d088c564918c643e048ed587..7f794fd8732b76dc22a80d921919ca3db00b31e2 100644 (file)
@@ -1565,7 +1565,6 @@ Bool VG_(machine_get_hwcaps)( void )
         UInt hwcaps_bit;
         const HChar name[6];   // may need adjustment for new facility names
      } fac_hwcaps[] = {
-        { False,  34,  VEX_HWCAPS_S390X_GIE,   "GIE"   },
         { False,  41,  VEX_HWCAPS_S390X_FGX,   "FGX"   },
         { False,  45,  VEX_HWCAPS_S390X_LSC,   "LSC"   },
         { False,  44,  VEX_HWCAPS_S390X_PFPO,  "PFPO"  },
index 593c8c556beb2b7ab0cf2d049bf875bfa624bf6e..fa96ee8f4d075f81ce5e46dcec61ae1dee3bcc60 100644 (file)
@@ -229,8 +229,6 @@ static int go(char *feature, char *cpu)
       match = (facilities[0] & FAC_BIT(1)) && (facilities[0] & FAC_BIT(2));
    } else if (strcmp(feature, "s390x-n3") == 0 ) {
       match = facilities[0] & FAC_BIT(0);
-   } else if (strcmp(feature, "s390x-genins") == 0 ) {
-      match = facilities[0] & FAC_BIT(34);
    } else if (strcmp(feature, "s390x-exrl") == 0 ) {
       match = facilities[0] & FAC_BIT(35);
    } else if (strcmp(feature, "s390x-pfpo") == 0 ) {