]> git.ipfire.org Git - thirdparty/valgrind.git/commitdiff
Consolidate guest state offset computation. There is only
authorFlorian Krohm <florian@eich-krohm.de>
Tue, 27 Mar 2012 03:09:49 +0000 (03:09 +0000)
committerFlorian Krohm <florian@eich-krohm.de>
Tue, 27 Mar 2012 03:09:49 +0000 (03:09 +0000)
one way. No need to precompute them and have them named in
three different ways.... Get rid of libvex_guest_offsets.h
dependency.

git-svn-id: svn://svn.valgrind.org/vex/trunk@2269

VEX/priv/guest_s390_toIR.c
VEX/priv/host_s390_defs.c
VEX/priv/host_s390_isel.c

index a34b3ab6c2cf201068c3d79f41348455c9934b8b..d0dc00e744f3e25bff52ce605f4dcf5c583a34aa 100644 (file)
@@ -34,9 +34,7 @@
 
 #include "libvex_basictypes.h"
 #include "libvex_ir.h"
-#include "libvex_guest_s390x.h"      /* VexGuestS390XState */
 #include "libvex.h"                  /* needed for bb_to_IR.h */
-#include "libvex_guest_offsets.h"    /* OFFSET_s390x_SYSNO */
 #include "libvex_s390x_common.h"
 #include "main_util.h"               /* vassert */
 #include "main_globals.h"            /* vex_traceflags */
@@ -85,6 +83,7 @@ typedef enum {
    S390_DECODE_ERROR
 } s390_decode_t;
 
+
 /*------------------------------------------------------------*/
 /*--- Helpers for constructing IR.                         ---*/
 /*------------------------------------------------------------*/
@@ -338,10 +337,11 @@ static void
 system_call(IRExpr *sysno)
 {
    /* Store the system call number in the pseudo register. */
-   stmt(IRStmt_Put(OFFSET_s390x_SYSNO, sysno));
+   stmt(IRStmt_Put(S390X_GUEST_OFFSET(guest_SYSNO), sysno));
 
    /* Store the current IA into guest_IP_AT_SYSCALL. libvex_ir.h says so. */
-   stmt(IRStmt_Put(OFFSET_s390x_IP_AT_SYSCALL, mkU64(guest_IA_curr_instr)));
+   stmt(IRStmt_Put(S390X_GUEST_OFFSET(guest_IP_AT_SYSCALL),
+                   mkU64(guest_IA_curr_instr)));
 
    /* It's important that all ArchRegs carry their up-to-date value
       at this point.  So we declare an end-of-block here, which
@@ -393,12 +393,6 @@ put_fpr_pair(UInt archreg, IRExpr *expr)
 }
 
 
-/* Flags thunk offsets */
-#define S390X_GUEST_OFFSET_CC_OP    S390X_GUEST_OFFSET(guest_CC_OP)
-#define S390X_GUEST_OFFSET_CC_DEP1  S390X_GUEST_OFFSET(guest_CC_DEP1)
-#define S390X_GUEST_OFFSET_CC_DEP2  S390X_GUEST_OFFSET(guest_CC_DEP2)
-#define S390X_GUEST_OFFSET_CC_NDEP  S390X_GUEST_OFFSET(guest_CC_NDEP)
-
 /*------------------------------------------------------------*/
 /*--- Build the flags thunk.                               ---*/
 /*------------------------------------------------------------*/
@@ -410,10 +404,10 @@ s390_cc_thunk_fill(IRExpr *op, IRExpr *dep1, IRExpr *dep2, IRExpr *ndep)
 {
    UInt op_off, dep1_off, dep2_off, ndep_off;
 
-   op_off   = S390X_GUEST_OFFSET_CC_OP;
-   dep1_off = S390X_GUEST_OFFSET_CC_DEP1;
-   dep2_off = S390X_GUEST_OFFSET_CC_DEP2;
-   ndep_off = S390X_GUEST_OFFSET_CC_NDEP;
+   op_off   = S390X_GUEST_OFFSET(guest_CC_OP);
+   dep1_off = S390X_GUEST_OFFSET(guest_CC_DEP1);
+   dep2_off = S390X_GUEST_OFFSET(guest_CC_DEP2);
+   ndep_off = S390X_GUEST_OFFSET(guest_CC_NDEP);
 
    stmt(IRStmt_Put(op_off,   op));
    stmt(IRStmt_Put(dep1_off, dep1));
@@ -583,10 +577,10 @@ s390_call_calculate_cc(void)
 {
    IRExpr **args, *call, *op, *dep1, *dep2, *ndep;
 
-   op   = IRExpr_Get(S390X_GUEST_OFFSET_CC_OP,   Ity_I64);
-   dep1 = IRExpr_Get(S390X_GUEST_OFFSET_CC_DEP1, Ity_I64);
-   dep2 = IRExpr_Get(S390X_GUEST_OFFSET_CC_DEP2, Ity_I64);
-   ndep = IRExpr_Get(S390X_GUEST_OFFSET_CC_NDEP, Ity_I64);
+   op   = IRExpr_Get(S390X_GUEST_OFFSET(guest_CC_OP),   Ity_I64);
+   dep1 = IRExpr_Get(S390X_GUEST_OFFSET(guest_CC_DEP1), Ity_I64);
+   dep2 = IRExpr_Get(S390X_GUEST_OFFSET(guest_CC_DEP2), Ity_I64);
+   ndep = IRExpr_Get(S390X_GUEST_OFFSET(guest_CC_NDEP), Ity_I64);
 
    args = mkIRExprVec_4(op, dep1, dep2, ndep);
    call = mkIRExprCCall(Ity_I32, 0 /*regparm*/,
@@ -629,10 +623,10 @@ s390_call_calculate_cond(UInt m)
    IRExpr **args, *call, *op, *dep1, *dep2, *ndep, *mask;
 
    mask = mkU64(m);
-   op   = IRExpr_Get(S390X_GUEST_OFFSET_CC_OP,   Ity_I64);
-   dep1 = IRExpr_Get(S390X_GUEST_OFFSET_CC_DEP1, Ity_I64);
-   dep2 = IRExpr_Get(S390X_GUEST_OFFSET_CC_DEP2, Ity_I64);
-   ndep = IRExpr_Get(S390X_GUEST_OFFSET_CC_NDEP, Ity_I64);
+   op   = IRExpr_Get(S390X_GUEST_OFFSET(guest_CC_OP),   Ity_I64);
+   dep1 = IRExpr_Get(S390X_GUEST_OFFSET(guest_CC_DEP1), Ity_I64);
+   dep2 = IRExpr_Get(S390X_GUEST_OFFSET(guest_CC_DEP2), Ity_I64);
+   ndep = IRExpr_Get(S390X_GUEST_OFFSET(guest_CC_NDEP), Ity_I64);
 
    args = mkIRExprVec_5(mask, op, dep1, dep2, ndep);
    call = mkIRExprCCall(Ity_I32, 0 /*regparm*/,
@@ -661,8 +655,6 @@ s390_call_calculate_cond(UInt m)
         s390_call_calculate_icc(op,dep1,dep2,True)
 
 
-#define OFFB_TISTART   S390X_GUEST_OFFSET(guest_TISTART)
-#define OFFB_TILEN     S390X_GUEST_OFFSET(guest_TILEN)
 
 
 /*------------------------------------------------------------*/
@@ -8874,8 +8866,9 @@ void (*irgen)(IRTemp length, IRTemp start1, IRTemp start2), int lensize)
    stmt(IRStmt_Dirty(d));
 
    /* and restart */
-   stmt(IRStmt_Put(OFFB_TISTART, mkU64(guest_IA_curr_instr)));
-   stmt(IRStmt_Put(OFFB_TILEN, mkU64(4)));
+   stmt(IRStmt_Put(S390X_GUEST_OFFSET(guest_TISTART),
+                   mkU64(guest_IA_curr_instr)));
+   stmt(IRStmt_Put(S390X_GUEST_OFFSET(guest_TILEN), mkU64(4)));
    stmt(IRStmt_Exit(mkexpr(cond), Ijk_TInval,
         IRConst_U64(guest_IA_curr_instr)));
 
@@ -8904,8 +8897,9 @@ s390_irgen_EX(UChar r1, IRTemp addr2)
                              mkIRExprVec_1(load(Ity_I64, mkexpr(addr2))));
       stmt(IRStmt_Dirty(d));
       /* and restart */
-      stmt(IRStmt_Put(OFFB_TISTART, mkU64(guest_IA_curr_instr)));
-      stmt(IRStmt_Put(OFFB_TILEN, mkU64(4)));
+      stmt(IRStmt_Put(S390X_GUEST_OFFSET(guest_TISTART),
+                      mkU64(guest_IA_curr_instr)));
+      stmt(IRStmt_Put(S390X_GUEST_OFFSET(guest_TILEN), mkU64(4)));
       stmt(IRStmt_Exit(IRExpr_Const(IRConst_U1(True)), Ijk_TInval,
            IRConst_U64(guest_IA_curr_instr)));
       /* we know that this will be invalidated */
@@ -8962,8 +8956,8 @@ s390_irgen_EX(UChar r1, IRTemp addr2)
       stmt(IRStmt_Dirty(d));
 
       /* and restart */
-      stmt(IRStmt_Put(OFFB_TISTART, mkU64(guest_IA_curr_instr)));
-      stmt(IRStmt_Put(OFFB_TILEN, mkU64(4)));
+      stmt(IRStmt_Put(S390X_GUEST_OFFSET(guest_TISTART), mkU64(guest_IA_curr_instr)));
+      stmt(IRStmt_Put(S390X_GUEST_OFFSET(guest_TILEN), mkU64(4)));
       stmt(IRStmt_Exit(mkexpr(cond), Ijk_TInval,
            IRConst_U64(guest_IA_curr_instr)));
 
@@ -13571,8 +13565,8 @@ disInstr_S390_WRK(UChar *insn)
          IA should be up-to-date since it made so at the start of each
          insn, but nevertheless be paranoid and update it again right
          now. */
-      addStmtToIRSB(irsb, IRStmt_Put(S390X_GUEST_OFFSET(guest_IA),
-                                     mkaddr_expr(guest_IA_curr_instr)));
+      stmt(IRStmt_Put(S390X_GUEST_OFFSET(guest_IA),
+                      mkaddr_expr(guest_IA_curr_instr)));
 
       irsb->next = mkaddr_expr(guest_IA_next_instr);
       irsb->jumpkind = Ijk_NoDecode;
@@ -13617,8 +13611,8 @@ disInstr_S390(IRSB        *irsb_IN,
    resteer_data = callback_opaque;
 
    /* Always update the guest IA. See comment in s390_isel_stmt for Ist_Put. */
-   addStmtToIRSB(irsb, IRStmt_Put(S390X_GUEST_OFFSET(guest_IA),
-                                  mkaddr_expr(guest_IA_curr_instr)));
+   stmt(IRStmt_Put(S390X_GUEST_OFFSET(guest_IA),
+                   mkaddr_expr(guest_IA_curr_instr)));
 
    return disInstr_S390_WRK(guest_code + delta);
 }
index cf6d82affe516fe58bf437ee5eb1523bec56e910..2de126d94a286cac6a00b2f0ddcfa4c22fb45876 100644 (file)
@@ -33,7 +33,6 @@
 #include "libvex_basictypes.h"
 #include "libvex.h"
 #include "libvex_trc_values.h"
-#include "libvex_guest_offsets.h"
 #include "libvex_s390x_common.h"
 
 #include "main_util.h"
@@ -41,6 +40,7 @@
 #include "host_generic_regs.h"
 #include "host_s390_defs.h"
 #include "host_s390_disasm.h"
+#include "guest_s390_defs.h"    /* S390X_GUEST_OFFSET */
 #include <stdarg.h>
 
 /* KLUDGE: We need to know the hwcaps of the host when generating
@@ -6756,7 +6756,7 @@ s390_set_fpc_rounding_mode(UChar *buf, s390_round_t rounding_mode)
 
    /* Copy FPC from guest state to R0 and OR in the new rounding mode */
    buf = s390_emit_L(buf, R0, 0, S390_REGNO_GUEST_STATE_POINTER,
-                     OFFSET_s390x_fpc);   // r0 = guest_fpc
+                     S390X_GUEST_OFFSET(guest_fpc));   // r0 = guest_fpc
 
    buf = s390_emit_NILL(buf, R0, 0xFFFC); /* Clear out right-most 2 bits */
    buf = s390_emit_OILL(buf, R0, bits);   /* OR in the new rounding mode */
@@ -6801,7 +6801,7 @@ s390_insn_bfp_triop_emit(UChar *buf, const s390_insn *insn)
    if (rounding_mode != S390_ROUND_NEAREST_EVEN) {
       /* Restore FPC register from guest state */
       buf = s390_emit_LFPC(buf, S390_REGNO_GUEST_STATE_POINTER,
-                           OFFSET_s390x_fpc);   // fpc = guest_fpc
+                           S390X_GUEST_OFFSET(guest_fpc));   // fpc = guest_fpc
    }
    return buf;
 
@@ -6848,7 +6848,7 @@ s390_insn_bfp_binop_emit(UChar *buf, const s390_insn *insn)
    if (rounding_mode != S390_ROUND_NEAREST_EVEN) {
       /* Restore FPC register from guest state */
       buf = s390_emit_LFPC(buf, S390_REGNO_GUEST_STATE_POINTER,
-                           OFFSET_s390x_fpc);
+                           S390X_GUEST_OFFSET(guest_fpc));
    }
    return buf;
 
@@ -6937,7 +6937,7 @@ s390_insn_bfp_unop_emit(UChar *buf, const s390_insn *insn)
    if (rounding_mode != S390_ROUND_NEAREST_EVEN) {
       /* Restore FPC register from guest state */
       buf = s390_emit_LFPC(buf, S390_REGNO_GUEST_STATE_POINTER,
-                           OFFSET_s390x_fpc);   // fpc = guest_fpc
+                           S390X_GUEST_OFFSET(guest_fpc));   // fpc = guest_fpc
    }
    return buf;
 
@@ -7003,7 +7003,7 @@ s390_insn_bfp128_binop_emit(UChar *buf, const s390_insn *insn)
    if (rounding_mode != S390_ROUND_NEAREST_EVEN) {
       /* Restore FPC register from guest state */
       buf = s390_emit_LFPC(buf, S390_REGNO_GUEST_STATE_POINTER,
-                           OFFSET_s390x_fpc);   // fpc = guest_fpc
+                           S390X_GUEST_OFFSET(guest_fpc));   // fpc = guest_fpc
    }
    return buf;
 
@@ -7068,7 +7068,7 @@ s390_insn_bfp128_unop_emit(UChar *buf, const s390_insn *insn)
    if (rounding_mode != S390_ROUND_NEAREST_EVEN) {
       /* Restore FPC register from guest state */
       buf = s390_emit_LFPC(buf, S390_REGNO_GUEST_STATE_POINTER,
-                           OFFSET_s390x_fpc);   // fpc = guest_fpc
+                           S390X_GUEST_OFFSET(guest_fpc));   // fpc = guest_fpc
    }
    return buf;
 
index f86301f04da7a6f16366335cf251c19d1894c9ec..a2217d4b8a12d647bef2dd8fe1cc6ba761a1dc2b 100644 (file)
@@ -34,7 +34,6 @@
 #include "libvex_ir.h"
 #include "libvex.h"
 #include "libvex_s390x_common.h"
-#include "libvex_guest_offsets.h"
 
 #include "main_util.h"
 #include "main_globals.h"
@@ -122,20 +121,20 @@ static Int
 get_guest_reg(Int offset)
 {
    switch (offset) {
-   case OFFSET_s390x_IA:        return GUEST_IA;
-   case OFFSET_s390x_CC_OP:     return GUEST_CC_OP;
-   case OFFSET_s390x_CC_DEP1:   return GUEST_CC_DEP1;
-   case OFFSET_s390x_CC_DEP2:   return GUEST_CC_DEP2;
-   case OFFSET_s390x_CC_NDEP:   return GUEST_CC_NDEP;
-   case OFFSET_s390x_SYSNO:     return GUEST_SYSNO;
+   case S390X_GUEST_OFFSET(guest_IA):        return GUEST_IA;
+   case S390X_GUEST_OFFSET(guest_CC_OP):     return GUEST_CC_OP;
+   case S390X_GUEST_OFFSET(guest_CC_DEP1):   return GUEST_CC_DEP1;
+   case S390X_GUEST_OFFSET(guest_CC_DEP2):   return GUEST_CC_DEP2;
+   case S390X_GUEST_OFFSET(guest_CC_NDEP):   return GUEST_CC_NDEP;
+   case S390X_GUEST_OFFSET(guest_SYSNO):     return GUEST_SYSNO;
 
       /* Also make sure there is never a partial write to one of
          these registers. That would complicate matters. */
-   case OFFSET_s390x_IA+1      ... OFFSET_s390x_IA+7:
-   case OFFSET_s390x_CC_OP+1   ... OFFSET_s390x_CC_OP+7:
-   case OFFSET_s390x_CC_DEP1+1 ... OFFSET_s390x_CC_DEP1+7:
-   case OFFSET_s390x_CC_DEP2+1 ... OFFSET_s390x_CC_DEP2+7:
-   case OFFSET_s390x_CC_NDEP+1 ... OFFSET_s390x_CC_NDEP+7:
+   case S390X_GUEST_OFFSET(guest_IA)+1      ... S390X_GUEST_OFFSET(guest_IA)+7:
+   case S390X_GUEST_OFFSET(guest_CC_OP)+1   ... S390X_GUEST_OFFSET(guest_CC_OP)+7:
+   case S390X_GUEST_OFFSET(guest_CC_DEP1)+1 ... S390X_GUEST_OFFSET(guest_CC_DEP1)+7:
+   case S390X_GUEST_OFFSET(guest_CC_DEP2)+1 ... S390X_GUEST_OFFSET(guest_CC_DEP2)+7:
+   case S390X_GUEST_OFFSET(guest_CC_NDEP)+1 ... S390X_GUEST_OFFSET(guest_CC_NDEP)+7:
       vassert("partial update of this guest state register is not allowed");
       break;