[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[qemu-s390x] [PULL 10/27] s390x/tcg: Factor out gen_addi_and_wrap_i64()
From: |
Cornelia Huck |
Subject: |
[qemu-s390x] [PULL 10/27] s390x/tcg: Factor out gen_addi_and_wrap_i64() from get_address() |
Date: |
Mon, 4 Mar 2019 13:01:53 +0100 |
From: David Hildenbrand <address@hidden>
Also properly wrap in 24bit mode. While at it, convert the comment (and
drop the comment about fundamental TCG optimizations).
Reviewed-by: Richard Henderson <address@hidden>
Signed-off-by: David Hildenbrand <address@hidden>
Message-Id: <address@hidden>
Signed-off-by: Cornelia Huck <address@hidden>
---
target/s390x/translate.c | 41 +++++++++++++++++++++++++---------------
1 file changed, 26 insertions(+), 15 deletions(-)
diff --git a/target/s390x/translate.c b/target/s390x/translate.c
index 933bf29331a2..f7de77192c7e 100644
--- a/target/s390x/translate.c
+++ b/target/s390x/translate.c
@@ -382,32 +382,43 @@ static inline void gen_trap(DisasContext *s)
gen_data_exception(0xff);
}
+static void gen_addi_and_wrap_i64(DisasContext *s, TCGv_i64 dst, TCGv_i64 src,
+ int64_t imm)
+{
+ tcg_gen_addi_i64(dst, src, imm);
+ if (!(s->base.tb->flags & FLAG_MASK_64)) {
+ if (s->base.tb->flags & FLAG_MASK_32) {
+ tcg_gen_andi_i64(dst, dst, 0x7fffffff);
+ } else {
+ tcg_gen_andi_i64(dst, dst, 0x00ffffff);
+ }
+ }
+}
+
static TCGv_i64 get_address(DisasContext *s, int x2, int b2, int d2)
{
TCGv_i64 tmp = tcg_temp_new_i64();
- bool need_31 = !(s->base.tb->flags & FLAG_MASK_64);
-
- /* Note that d2 is limited to 20 bits, signed. If we crop negative
- displacements early we create larger immedate addends. */
- /* Note that addi optimizes the imm==0 case. */
+ /*
+ * Note that d2 is limited to 20 bits, signed. If we crop negative
+ * displacements early we create larger immedate addends.
+ */
if (b2 && x2) {
tcg_gen_add_i64(tmp, regs[b2], regs[x2]);
- tcg_gen_addi_i64(tmp, tmp, d2);
+ gen_addi_and_wrap_i64(s, tmp, tmp, d2);
} else if (b2) {
- tcg_gen_addi_i64(tmp, regs[b2], d2);
+ gen_addi_and_wrap_i64(s, tmp, regs[b2], d2);
} else if (x2) {
- tcg_gen_addi_i64(tmp, regs[x2], d2);
- } else {
- if (need_31) {
- d2 &= 0x7fffffff;
- need_31 = false;
+ gen_addi_and_wrap_i64(s, tmp, regs[x2], d2);
+ } else if (!(s->base.tb->flags & FLAG_MASK_64)) {
+ if (s->base.tb->flags & FLAG_MASK_32) {
+ tcg_gen_movi_i64(tmp, d2 & 0x7fffffff);
+ } else {
+ tcg_gen_movi_i64(tmp, d2 & 0x00ffffff);
}
+ } else {
tcg_gen_movi_i64(tmp, d2);
}
- if (need_31) {
- tcg_gen_andi_i64(tmp, tmp, 0x7fffffff);
- }
return tmp;
}
--
2.17.2
- [qemu-s390x] [PULL 00/27] s390x updates, Cornelia Huck, 2019/03/04
- [qemu-s390x] [PULL 02/27] s390x: use a QEMU-style typedef + name for SIGP save area struct, Cornelia Huck, 2019/03/04
- [qemu-s390x] [PULL 01/27] s390x: Use cpu_to_be64 in SIGP STORE ADDITIONAL STATUS, Cornelia Huck, 2019/03/04
- [qemu-s390x] [PULL 05/27] s390x/vfio-ap: document hot plug/unplug of vfio-ap device, Cornelia Huck, 2019/03/04
- [qemu-s390x] [PULL 04/27] s390x/vfio-ap: Implement hot plug/unplug of vfio-ap device, Cornelia Huck, 2019/03/04
- [qemu-s390x] [PULL 08/27] s390x/tcg: Clarify terminology in vec_reg_offset(), Cornelia Huck, 2019/03/04
- [qemu-s390x] [PULL 06/27] s390x/tcg: RXE has an optional M3 field, Cornelia Huck, 2019/03/04
- [qemu-s390x] [PULL 07/27] s390x/tcg: Simplify disassembler operands initialization, Cornelia Huck, 2019/03/04
- [qemu-s390x] [PULL 10/27] s390x/tcg: Factor out gen_addi_and_wrap_i64() from get_address(),
Cornelia Huck <=
- [qemu-s390x] [PULL 09/27] s390x/tcg: Factor out vec_full_reg_offset(), Cornelia Huck, 2019/03/04
- [qemu-s390x] [PULL 11/27] s390x/tcg: Implement LOAD LENGTHENED short HFP to long HFP, Cornelia Huck, 2019/03/04
- [qemu-s390x] [PULL 12/27] s390x/tcg: Implement LOAD COUNT TO BLOCK BOUNDARY, Cornelia Huck, 2019/03/04
- [qemu-s390x] [PULL 13/27] s390x/tcg: Fix TEST DATA CLASS instructions, Cornelia Huck, 2019/03/04
- [qemu-s390x] [PULL 14/27] s390x/tcg: Fix rounding from float128 to uint64_t/uint32_t, Cornelia Huck, 2019/03/04
- [qemu-s390x] [PULL 15/27] s390x/tcg: Factor out conversion of softfloat exceptions, Cornelia Huck, 2019/03/04
- [qemu-s390x] [PULL 17/27] s390x/tcg: Hide IEEE underflows in some scenarios, Cornelia Huck, 2019/03/04
- [qemu-s390x] [PULL 16/27] s390x/tcg: Fix parts of IEEE exception handling, Cornelia Huck, 2019/03/04
- [qemu-s390x] [PULL 18/27] s390x/tcg: Refactor SET FPC AND SIGNAL handling, Cornelia Huck, 2019/03/04
- [qemu-s390x] [PULL 19/27] s390x/tcg: Fix simulated-IEEE exceptions, Cornelia Huck, 2019/03/04