From 2e64acd5fdf28b47294aa7be87d9f555ff14eb87 Mon Sep 17 00:00:00 2001 From: Florian Krohm Date: Fri, 13 Sep 2013 21:42:14 +0000 Subject: [PATCH] s390: Add spechelper for s390_calculate_cc. git-svn-id: svn://svn.valgrind.org/vex/trunk@2762 --- VEX/priv/guest_s390_helpers.c | 33 +++++++++++++++++++++++++++++++-- 1 file changed, 31 insertions(+), 2 deletions(-) diff --git a/VEX/priv/guest_s390_helpers.c b/VEX/priv/guest_s390_helpers.c index f27092972a..610a57cd51 100644 --- a/VEX/priv/guest_s390_helpers.c +++ b/VEX/priv/guest_s390_helpers.c @@ -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; } -- 2.47.2