diff options
author | Richard Henderson <rth@twiddle.net> | 2012-08-24 14:27:42 -0700 |
---|---|---|
committer | Richard Henderson <rth@twiddle.net> | 2013-01-05 12:18:42 -0800 |
commit | 4600c994d93fc9af2b045086dd31e613d2f9d7bc (patch) | |
tree | 80c65cd48324e2547aba5ab7bd813729027a3202 | |
parent | aa31bf60312157aefb09f887e2f750c7d59a8bbc (diff) |
target-s390: Convert SRST
Signed-off-by: Richard Henderson <rth@twiddle.net>
-rw-r--r-- | target-s390x/helper.h | 2 | ||||
-rw-r--r-- | target-s390x/insn-data.def | 3 | ||||
-rw-r--r-- | target-s390x/mem_helper.c | 39 | ||||
-rw-r--r-- | target-s390x/translate.c | 31 |
4 files changed, 44 insertions, 31 deletions
diff --git a/target-s390x/helper.h b/target-s390x/helper.h index 999d5d0604..dd7479abcf 100644 --- a/target-s390x/helper.h +++ b/target-s390x/helper.h @@ -13,7 +13,7 @@ DEF_HELPER_3(divs32, s64, env, s64, s64) DEF_HELPER_3(divu32, i64, env, i64, i64) DEF_HELPER_3(divs64, s64, env, s64, s64) DEF_HELPER_4(divu64, i64, env, i64, i64, i64) -DEF_HELPER_4(srst, i32, env, i32, i32, i32) +DEF_HELPER_4(srst, i64, env, i64, i64, i64) DEF_HELPER_4(clst, i64, env, i64, i64, i64) DEF_HELPER_4(mvpg, void, env, i64, i64, i64) DEF_HELPER_4(mvst, i64, env, i64, i64, i64) diff --git a/target-s390x/insn-data.def b/target-s390x/insn-data.def index b485b85e9c..5e1f8fda9b 100644 --- a/target-s390x/insn-data.def +++ b/target-s390x/insn-data.def @@ -471,6 +471,9 @@ C(0xeb1d, RLL, RSY_a, Z, r3_o, sh32, new, r1_32, rll32, 0) C(0xeb1c, RLLG, RSY_a, Z, r3_o, sh64, r1, 0, rll64, 0) +/* SEARCH STRING */ + C(0xb25e, SRST, RRE, Z, r1_o, r2_o, 0, 0, srst, 0) + /* SET ACCESS */ C(0xb24e, SAR, RRE, Z, 0, r2_o, 0, 0, sar, 0) /* SET FPC */ diff --git a/target-s390x/mem_helper.c b/target-s390x/mem_helper.c index 7d87c746f6..59877eef96 100644 --- a/target-s390x/mem_helper.c +++ b/target-s390x/mem_helper.c @@ -331,25 +331,38 @@ static inline uint64_t get_address_31fix(CPUS390XState *env, int reg) } /* search string (c is byte to search, r2 is string, r1 end of string) */ -uint32_t HELPER(srst)(CPUS390XState *env, uint32_t c, uint32_t r1, uint32_t r2) +uint64_t HELPER(srst)(CPUS390XState *env, uint64_t r0, uint64_t end, + uint64_t str) { - uint64_t i; - uint32_t cc = 2; - uint64_t str = get_address_31fix(env, r2); - uint64_t end = get_address_31fix(env, r1); + uint32_t len; + uint8_t v, c = r0; - HELPER_LOG("%s: c %d *r1 0x%" PRIx64 " *r2 0x%" PRIx64 "\n", __func__, - c, env->regs[r1], env->regs[r2]); + str = fix_address(env, str); + end = fix_address(env, end); - for (i = str; i != end; i++) { - if (cpu_ldub_data(env, i) == c) { - env->regs[r1] = i; - cc = 1; - break; + /* Assume for now that R2 is unmodified. */ + env->retxl = str; + + /* Lest we fail to service interrupts in a timely manner, limit the + amount of work we're willing to do. For now, lets cap at 8k. */ + for (len = 0; len < 0x2000; ++len) { + if (str + len == end) { + /* Character not found. R1 & R2 are unmodified. */ + env->cc_op = 2; + return end; + } + v = cpu_ldub_data(env, str + len); + if (v == c) { + /* Character found. Set R1 to the location; R2 is unmodified. */ + env->cc_op = 1; + return str + len; } } - return cc; + /* CPU-determined bytes processed. Advance R2 to next byte to process. */ + env->retxl = str + len; + env->cc_op = 3; + return end; } /* unsigned string compare (c is string terminator) */ diff --git a/target-s390x/translate.c b/target-s390x/translate.c index f1eb4bb8da..bbbd5fe09a 100644 --- a/target-s390x/translate.c +++ b/target-s390x/translate.c @@ -1021,12 +1021,11 @@ static void free_compare(DisasCompare *c) static void disas_b2(CPUS390XState *env, DisasContext *s, int op, uint32_t insn) { +#ifndef CONFIG_USER_ONLY TCGv_i64 tmp, tmp2, tmp3; - TCGv_i32 tmp32_1, tmp32_2, tmp32_3; + TCGv_i32 tmp32_1, tmp32_2; int r1, r2; -#ifndef CONFIG_USER_ONLY int r3, d2, b2; -#endif r1 = (insn >> 4) & 0xf; r2 = insn & 0xf; @@ -1034,19 +1033,6 @@ static void disas_b2(CPUS390XState *env, DisasContext *s, int op, LOG_DISAS("disas_b2: op 0x%x r1 %d r2 %d\n", op, r1, r2); switch (op) { - case 0x5e: /* SRST R1,R2 [RRE] */ - tmp32_1 = load_reg32(0); - tmp32_2 = tcg_const_i32(r1); - tmp32_3 = tcg_const_i32(r2); - potential_page_fault(s); - gen_helper_srst(cc_op, cpu_env, tmp32_1, tmp32_2, tmp32_3); - set_cc_static(s); - tcg_temp_free_i32(tmp32_1); - tcg_temp_free_i32(tmp32_2); - tcg_temp_free_i32(tmp32_3); - break; - -#ifndef CONFIG_USER_ONLY case 0x02: /* STIDP D2(B2) [S] */ /* Store CPU ID */ check_privileged(s); @@ -1314,12 +1300,14 @@ static void disas_b2(CPUS390XState *env, DisasContext *s, int op, tcg_temp_free_i32(tmp32_1); tcg_temp_free_i64(tmp); break; -#endif default: +#endif LOG_DISAS("illegal b2 operation 0x%x\n", op); gen_illegal_opcode(s); +#ifndef CONFIG_USER_ONLY break; } +#endif } static void disas_s390_insn(CPUS390XState *env, DisasContext *s) @@ -3136,6 +3124,15 @@ static ExitStatus op_stmh(DisasContext *s, DisasOps *o) return NO_EXIT; } +static ExitStatus op_srst(DisasContext *s, DisasOps *o) +{ + potential_page_fault(s); + gen_helper_srst(o->in1, cpu_env, regs[0], o->in1, o->in2); + set_cc_static(s); + return_low128(o->in2); + return NO_EXIT; +} + static ExitStatus op_sub(DisasContext *s, DisasOps *o) { tcg_gen_sub_i64(o->out, o->in1, o->in2); |