Skip to contentSkip to conversation

tcg: Implement tcg_gen_shri2_i64()

PATCH In review David Hildenbrand 2 participants 5 messages Feb 25, 2019

lore
Share & tools
lore
#0 lore raw

PATCH v2 1/1 tcg: Implement tcg_gen_shri2_i64()

Will be helpful for s390x. Input 128 bit and output 64 bit only, which is sufficient for now.

---

v1 -> v2:
- Use one output (lower part) only
- Shield off big shifts by an assert

 tcg/tcg-op.c | 15 +++++++++++++++
 tcg/tcg-op.h |  1 +
 2 files changed, 16 insertions(+)
tcg/tcg-op.c +15 -0
index 1bd7ef24af..e4fa75c074 100644
@@ -2381,6 +2381,21 @@ void tcg_gen_sub2_i64(TCGv_i64 rl, TCGv_i64 rh, TCGv_i64 al,
     }
 }
 
+void tcg_gen_shri2_i64(TCGv_i64 ret, TCGv_i64 al, TCGv_i64 ah, int64_t count)
+{
+    tcg_debug_assert(count >= 0 && count <= 64);
+    if (count == 0) {
+        tcg_gen_mov_i64(ret, al);
+    } else if (count == 64) {
+        tcg_gen_mov_i64(ret, ah);
+    } else {
+        TCGv_i64 t0 = tcg_temp_new_i64();
+        tcg_gen_shri_i64(t0, al, count);
+        tcg_gen_deposit_i64(ret, t0, ah, 64 - count, count);
+        tcg_temp_free_i64(t0);
+    }
+}
+
 void tcg_gen_mulu2_i64(TCGv_i64 rl, TCGv_i64 rh, TCGv_i64 arg1, TCGv_i64 arg2)
 {
     if (TCG_TARGET_HAS_mulu2_i64) {
tcg/tcg-op.h +1 -0
index d3e51b15af..1ffe689276 100644
@@ -513,6 +513,7 @@ void tcg_gen_add2_i64(TCGv_i64 rl, TCGv_i64 rh, TCGv_i64 al,
                       TCGv_i64 ah, TCGv_i64 bl, TCGv_i64 bh);
 void tcg_gen_sub2_i64(TCGv_i64 rl, TCGv_i64 rh, TCGv_i64 al,
                       TCGv_i64 ah, TCGv_i64 bl, TCGv_i64 bh);
+void tcg_gen_shri2_i64(TCGv_i64 ret, TCGv_i64 al, TCGv_i64 ah, int64_t count);
 void tcg_gen_mulu2_i64(TCGv_i64 rl, TCGv_i64 rh, TCGv_i64 arg1, TCGv_i64 arg2);
 void tcg_gen_muls2_i64(TCGv_i64 rl, TCGv_i64 rh, TCGv_i64 arg1, TCGv_i64 arg2);
 void tcg_gen_mulsu2_i64(TCGv_i64 rl, TCGv_i64 rh, TCGv_i64 arg1, TCGv_i64 arg2);
Signature · 1 line
2.17.2
#2 lore raw
In reply to David Hildenbrand
Quoted 1 line · David Hildenbrand

+void tcg_gen_shri2_i64(TCGv_i64 ret, TCGv_i64 al, TCGv_i64 ah, int64_t count)

Actually, I now wonder if a better name might be tcg_gen_extract2_i64 (no other change to arguments, i.e. the "len" parameter that extract has is fixed at 64).

Thoughts?

r~

#3 lore raw
Quoted 8 lines · Richard Henderson
Quoted 1 line · David Hildenbrand

+void tcg_gen_shri2_i64(TCGv_i64 ret, TCGv_i64 al, TCGv_i64 ah, int64_t count)

Actually, I now wonder if a better name might be tcg_gen_extract2_i64 (no other change to arguments, i.e. the "len" parameter that extract has is fixed at 64).

Thoughts?

That is actually a good idea. Maybe add a comment regarding len fixed to 64.

Shall I resend or do you want to fix it up?

Quoted 4 lines

r~

Signature · 3 lines
Thanks,

David / dhildenb
#4 lore raw
Quoted 8 lines · David Hildenbrand
Quoted 7 lines · Richard Henderson
Quoted 1 line · David Hildenbrand

+void tcg_gen_shri2_i64(TCGv_i64 ret, TCGv_i64 al, TCGv_i64 ah, int64_t count)

Actually, I now wonder if a better name might be tcg_gen_extract2_i64 (no other change to arguments, i.e. the "len" parameter that extract has is fixed at 64).

Quoted 5 lines
Quoted 1 line

Thoughts?

That is actually a good idea. Maybe add a comment regarding len fixed to 64.

Shall I resend or do you want to fix it up?

I'll fix it up.

r~