diff options
author | Aurelien Jarno <aurelien@aurel32.net> | 2017-06-01 00:01:22 +0200 |
---|---|---|
committer | Richard Henderson <rth@twiddle.net> | 2017-06-06 15:20:43 -0700 |
commit | 3bd3d6d302bd5a86a103a228b6d708025db4dcc2 (patch) | |
tree | a7c49fa4483b7b4d01c6f2e8904b9cb7486d2fcc | |
parent | 16f2e4b841799c6a25631753a495ea2c82510651 (diff) | |
download | qemu-3bd3d6d302bd5a86a103a228b6d708025db4dcc2.zip qemu-3bd3d6d302bd5a86a103a228b6d708025db4dcc2.tar.gz qemu-3bd3d6d302bd5a86a103a228b6d708025db4dcc2.tar.bz2 |
target/s390x: implement PACK ASCII
Reviewed-by: Richard Henderson <rth@twiddle.net>
Signed-off-by: Aurelien Jarno <aurelien@aurel32.net>
Message-Id: <20170531220129.27724-24-aurelien@aurel32.net>
Signed-off-by: Richard Henderson <rth@twiddle.net>
-rw-r--r-- | target/s390x/helper.h | 1 | ||||
-rw-r--r-- | target/s390x/insn-data.def | 2 | ||||
-rw-r--r-- | target/s390x/mem_helper.c | 35 | ||||
-rw-r--r-- | target/s390x/translate.c | 16 |
4 files changed, 54 insertions, 0 deletions
diff --git a/target/s390x/helper.h b/target/s390x/helper.h index 8ce5e3f..61f3ead 100644 --- a/target/s390x/helper.h +++ b/target/s390x/helper.h @@ -86,6 +86,7 @@ DEF_HELPER_FLAGS_2(sqdb, TCG_CALL_NO_WG, i64, env, i64) DEF_HELPER_FLAGS_3(sqxb, TCG_CALL_NO_WG, i64, env, i64, i64) DEF_HELPER_FLAGS_1(cvd, TCG_CALL_NO_RWG_SE, i64, s32) DEF_HELPER_FLAGS_4(pack, TCG_CALL_NO_WG, void, env, i32, i64, i64) +DEF_HELPER_FLAGS_4(pka, TCG_CALL_NO_WG, void, env, i64, i64, i32) DEF_HELPER_FLAGS_4(unpk, TCG_CALL_NO_WG, void, env, i32, i64, i64) DEF_HELPER_FLAGS_4(tr, TCG_CALL_NO_WG, void, env, i32, i64, i64) DEF_HELPER_4(tre, i64, env, i64, i64, i64) diff --git a/target/s390x/insn-data.def b/target/s390x/insn-data.def index d16857a..a5063a4 100644 --- a/target/s390x/insn-data.def +++ b/target/s390x/insn-data.def @@ -665,6 +665,8 @@ /* Really format SS_b, but we pack both lengths into one argument for the helper call, so we might as well leave one 8-bit field. */ C(0xf200, PACK, SS_a, Z, la1, a2, 0, 0, pack, 0) +/* PACK ASCII */ + C(0xe900, PKA, SS_f, E2, la1, a2, 0, 0, pka, 0) /* PREFETCH */ /* Implemented as nops of course. */ diff --git a/target/s390x/mem_helper.c b/target/s390x/mem_helper.c index 581f107..4cf96c8 100644 --- a/target/s390x/mem_helper.c +++ b/target/s390x/mem_helper.c @@ -914,6 +914,41 @@ void HELPER(pack)(CPUS390XState *env, uint32_t len, uint64_t dest, uint64_t src) } } +void HELPER(pka)(CPUS390XState *env, uint64_t dest, uint64_t src, + uint32_t srclen) +{ + uintptr_t ra = GETPC(); + int i; + /* The destination operand is always 16 bytes long. */ + const int destlen = 16; + + /* The operands are processed from right to left. */ + src += srclen - 1; + dest += destlen - 1; + + for (i = 0; i < destlen; i++) { + uint8_t b = 0; + + /* Start with a positive sign */ + if (i == 0) { + b = 0xc; + } else if (srclen > 1) { + b = cpu_ldub_data_ra(env, src, ra) & 0x0f; + src--; + srclen--; + } + + if (srclen > 1) { + b |= cpu_ldub_data_ra(env, src, ra) << 4; + src--; + srclen--; + } + + cpu_stb_data_ra(env, dest, b, ra); + dest--; + } +} + void HELPER(unpk)(CPUS390XState *env, uint32_t len, uint64_t dest, uint64_t src) { diff --git a/target/s390x/translate.c b/target/s390x/translate.c index 4f1a50e..4939311 100644 --- a/target/s390x/translate.c +++ b/target/s390x/translate.c @@ -3299,6 +3299,22 @@ static ExitStatus op_pack(DisasContext *s, DisasOps *o) return NO_EXIT; } +static ExitStatus op_pka(DisasContext *s, DisasOps *o) +{ + int l2 = get_field(s->fields, l2) + 1; + TCGv_i32 l; + + /* The length must not exceed 32 bytes. */ + if (l2 > 32) { + gen_program_exception(s, PGM_SPECIFICATION); + return EXIT_NORETURN; + } + l = tcg_const_i32(l2); + gen_helper_pka(cpu_env, o->addr1, o->in2, l); + tcg_temp_free_i32(l); + return NO_EXIT; +} + static ExitStatus op_popcnt(DisasContext *s, DisasOps *o) { gen_helper_popcnt(o->out, o->in2); |