]> git.ipfire.org Git - thirdparty/valgrind.git/commitdiff
s390: Add spechelper for s390_calculate_cc.
authorFlorian Krohm <florian@eich-krohm.de>
Fri, 13 Sep 2013 21:42:14 +0000 (21:42 +0000)
committerFlorian Krohm <florian@eich-krohm.de>
Fri, 13 Sep 2013 21:42:14 +0000 (21:42 +0000)
git-svn-id: svn://svn.valgrind.org/vex/trunk@2762

VEX/priv/guest_s390_helpers.c

index f27092972a8140f7a3df05aeb5f4cb716520c6a7..610a57cd5158c82ab7ae0bc2d1316dc7af0e8df8 100644 (file)
@@ -2357,10 +2357,39 @@ guest_s390x_spechelper(const HChar *function_name, IRExpr **args,
                           mkU64(0)));
       }
 
-missed:
-      ;
+      goto missed;
    }
 
+   /* --------- Specialising "s390_calculate_cond" --------- */
+
+   if (vex_streq(function_name, "s390_calculate_cc")) {
+      IRExpr *cc_op_expr, *cc_dep1;
+      ULong cc_op;
+
+      vassert(arity == 4);
+
+      cc_op_expr = args[0];
+
+      /* The necessary requirement for all optimizations here is that
+         cc_op is constant. So check that upfront. */
+      if (! isC64(cc_op_expr)) return NULL;
+
+      cc_op   = cc_op_expr->Iex.Const.con->Ico.U64;
+      cc_dep1 = args[1];
+
+      if (cc_op == S390_CC_OP_BITWISE) {
+         return unop(Iop_1Uto32,
+                     binop(Iop_CmpNE64, cc_dep1, mkU64(0)));
+      }
+
+      if (cc_op == S390_CC_OP_SET) {
+         return unop(Iop_64to32, cc_dep1);
+      }
+
+      goto missed;
+   }
+
+missed:
    return NULL;
 }