Skip to contentSkip to conversation

s390x: Add laa and laag instructions

PATCH In review Alexander Graf 2 participants 6 messages May 12, 2015

lore
Share & tools
lore
#0 lore raw

PATCH v2 1/1 s390x: Add laa and laag instructions

We're currently missing the laa and laag instructions in our emulation. In fact, we're missing the complete "interlocked-access facility 1" which is part of zEC12. However, I really only needed the laa instruction for now.

---

This really should implement all the other atomic load&modify instructions, but I'd like to make sure we have a smart scheme to implement them first.

v1 -> v2:

- move atomic specific bits into load/store helpers, leave actual op as normal op we can reuse

---
 target-s390x/insn-data.def |  3 +++
 target-s390x/translate.c   | 48 ++++++++++++++++++++++++++++++++++++++++++++--
 2 files changed, 49 insertions(+), 2 deletions(-)
target-s390x/insn-data.def +3 -0
index 48e979e..cd95035 100644
@@ -359,6 +359,9 @@
     C(0xe371, LAY,     RXY_a, LD,  0, a2, 0, r1, mov2, 0)
 /* LOAD ADDRESS RELATIVE LONG */
     C(0xc000, LARL,    RIL_b, Z,   0, ri2, 0, r1, mov2, 0)
+/* LOAD AND ADD */
+    C(0xebf8, LAA,     RSY_a, ILA, r3_32s, m2_32s_atomic, new, m2_32_r1_atomic, add, adds32)
+    C(0xebe8, LAAG,    RSY_a, ILA, r3, m2_64_atomic, new, m2_64_r1_atomic, add, adds64)
 /* LOAD AND TEST */
     C(0x1200, LTR,     RR_a,  Z,   0, r2_o, 0, cond_r1r2_32, mov2, s32)
     C(0xb902, LTGR,    RRE,   Z,   0, r2_o, 0, r1, mov2, s64)
target-s390x/translate.c +46 -2

78 lines not on this page · raw message

Signature · 1 line
1.7.12.4
#1 lore raw
Quoted 4 lines · Alexander Graf
target-s390x/translate.c +4 -0
+static void in2_m2_32s_atomic(DisasContext *s, DisasFields *f, DisasOps *o)
+{
+    /* XXX should reserve the address */
+    in2_m2_32s(s, f, o);

target-s390x/translate.c static void in2_mri2_64(DisasContext *s, DisasFields *f, DisasOps *o) · line 4532

Quoted 10 lines
target-s390x/translate.c +10 -0
+}
+#define SPEC_in2_m2_32s_atomic 0
+
+static void in2_m2_64_atomic(DisasContext *s, DisasFields *f, DisasOps *o)
+{
+    /* XXX should reserve the address */
+    in2_m2_64(s, f, o);
+}
+#define SPEC_in2_m2_64_atomic 0
+

I think these should save the address in o->addr1 so that you don't have to recompute it in the wout functions.

Otherwise I think this is a great scheme, making it easy to implement this whole family of instructions.

r~

#2 lore raw
Quoted 17 lines · Richard Henderson
Quoted 4 lines · Alexander Graf
target-s390x/translate.c +4 -0
+static void in2_m2_32s_atomic(DisasContext *s, DisasFields *f, DisasOps *o)
+{
+    /* XXX should reserve the address */
+    in2_m2_32s(s, f, o);

target-s390x/translate.c static void in2_mri2_64(DisasContext *s, DisasFields *f, DisasOps *o) · line 4532

Quoted 10 lines
target-s390x/translate.c +10 -0
+}
+#define SPEC_in2_m2_32s_atomic 0
+
+static void in2_m2_64_atomic(DisasContext *s, DisasFields *f, DisasOps *o)
+{
+    /* XXX should reserve the address */
+    in2_m2_64(s, f, o);
+}
+#define SPEC_in2_m2_64_atomic 0
+

I think these should save the address in o->addr1 so that you don't have to recompute it in the wout functions.

But wouldn't it really be "addr2"? This is the address source for the second argument after all.

Alex

Quoted 6 lines

Otherwise I think this is a great scheme, making it easy to implement this whole family of instructions.

r~

#3 lore raw
Quoted 3 lines · Alexander Graf

But wouldn't it really be "addr2"? This is the address source for the second argument after all.

Yes, but we already abuse the name.

r~

#4 lore raw
In reply to Richard Henderson
Quoted 17 lines · Richard Henderson
Quoted 4 lines · Alexander Graf
(quoted diff) +4 -0
+static void in2_m2_32s_atomic(DisasContext *s, DisasFields *f, DisasOps *o)
+{
+    /* XXX should reserve the address */
+    in2_m2_32s(s, f, o);

Review

Quoted 10 lines
(quoted diff) +10 -0
+}
+#define SPEC_in2_m2_32s_atomic 0
+
+static void in2_m2_64_atomic(DisasContext *s, DisasFields *f, DisasOps *o)
+{
+    /* XXX should reserve the address */
+    in2_m2_64(s, f, o);
+}
+#define SPEC_in2_m2_64_atomic 0
+

I think these should save the address in o->addr1 so that you don't have to recompute it in the wout functions.

But I suppose you basically mean something like this?

Alex

target-s390x/translate.c +0 -0
index 73f2de3..8a30c8f 100644
@@ -4074,25 +4074,17 @@ static void wout_m2_32(DisasContext *s, DisasFields *f, DisasOps *o)
 
 static void wout_m2_32_r1_atomic(DisasContext *s, DisasFields *f, 

DisasOps *o)
{
- TCGv_i64 a2 = get_a2(s, f);
-

     /* XXX release reservation */
-    tcg_gen_qemu_st32(o->out, a2, get_mem_index(s));
+    tcg_gen_qemu_st32(o->out, o->addr1, get_mem_index(s));
     store_reg32_i64(get_field(f, r1), o->in2);

-
- tcg_temp_free_i64(a2);
}
#define SPEC_wout_m2_32_r1_atomic 0

static void wout_m2_64_r1_atomic(DisasContext *s, DisasFields *f,
DisasOps *o)
{
- TCGv_i64 a2 = get_a2(s, f);
-

     /* XXX release reservation */
-    tcg_gen_qemu_st64(o->out, a2, get_mem_index(s));
+    tcg_gen_qemu_st64(o->out, o->addr1, get_mem_index(s));
     store_reg(get_field(f, r1), o->in2);

-
- tcg_temp_free_i64(a2);
}
#define SPEC_wout_m2_64_r1_atomic 0

@@ -4519,14 +4511,18 @@ static void in2_mri2_64(DisasContext *s, DisasFields *f, DisasOps *o)
static void in2_m2_32s_atomic(DisasContext *s, DisasFields *f,
DisasOps *o)

 {
     /* XXX should reserve the address */
-    in2_m2_32s(s, f, o);
+    o->addr1 = get_a2(s, f);
+    o->in2 = tcg_temp_new_i64();
+    tcg_gen_qemu_ld32s(o->in2, o->addr1, get_mem_index(s));

}
#define SPEC_in2_m2_32s_atomic 0

static void in2_m2_64_atomic(DisasContext *s, DisasFields *f, DisasOps *o)

 {
     /* XXX should reserve the address */
-    in2_m2_64(s, f, o);
+    o->addr1 = get_a2(s, f);
+    o->in2 = tcg_temp_new_i64();
+    tcg_gen_qemu_ld64(o->in2, o->addr1, get_mem_index(s));

}
#define SPEC_in2_m2_64_atomic 0

#5 lore raw
Quoted 19 lines · Alexander Graf
Quoted 17 lines · Richard Henderson
Quoted 4 lines · Alexander Graf
(quoted diff) +4 -0
+static void in2_m2_32s_atomic(DisasContext *s, DisasFields *f, DisasOps *o)
+{
+    /* XXX should reserve the address */
+    in2_m2_32s(s, f, o);

Review

Quoted 10 lines
(quoted diff) +10 -0
+}
+#define SPEC_in2_m2_32s_atomic 0
+
+static void in2_m2_64_atomic(DisasContext *s, DisasFields *f, DisasOps *o)
+{
+    /* XXX should reserve the address */
+    in2_m2_64(s, f, o);
+}
+#define SPEC_in2_m2_64_atomic 0
+

I think these should save the address in o->addr1 so that you don't have to recompute it in the wout functions.

Quoted 1 line

But I suppose you basically mean something like this?

Yes.

There's an in1_la2 that does what your get_a2 does.
Again, slightly misnamed, but that's the beauty of these atomic ops -- same fields have gotten renamed.

r~