diff mbox series

[v4,142/163] tcg/s390x: Use ADD LOGICAL WITH SIGNED IMMEDIATE

Message ID 20250415192515.232910-143-richard.henderson@linaro.org
State New
Headers show
Series tcg: Convert to TCGOutOp structures | expand

Commit Message

Richard Henderson April 15, 2025, 7:24 p.m. UTC
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
---
 tcg/s390x/tcg-target.c.inc | 22 +++++++++++++++++++++-
 1 file changed, 21 insertions(+), 1 deletion(-)

Comments

Pierrick Bouvier April 16, 2025, 7:18 p.m. UTC | #1
On 4/15/25 12:24, Richard Henderson wrote:
> Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
> ---
>   tcg/s390x/tcg-target.c.inc | 22 +++++++++++++++++++++-
>   1 file changed, 21 insertions(+), 1 deletion(-)
> 
> diff --git a/tcg/s390x/tcg-target.c.inc b/tcg/s390x/tcg-target.c.inc
> index 2b31ea1c3e..36293d0f42 100644
> --- a/tcg/s390x/tcg-target.c.inc
> +++ b/tcg/s390x/tcg-target.c.inc
> @@ -135,6 +135,9 @@ typedef enum S390Opcode {
>       RIEc_CLGIJ   = 0xec7d,
>       RIEc_CLIJ    = 0xec7f,
>   
> +    RIEd_ALHSIK  = 0xecda,
> +    RIEd_ALGHSIK = 0xecdb,
> +
>       RIEf_RISBG   = 0xec55,
>   
>       RIEg_LOCGHI  = 0xec46,
> @@ -682,8 +685,16 @@ static void tcg_out_insn_RI(TCGContext *s, S390Opcode op, TCGReg r1, int i2)
>       tcg_out32(s, (op << 16) | (r1 << 20) | (i2 & 0xffff));
>   }
>   
> +static void tcg_out_insn_RIEd(TCGContext *s, S390Opcode op,
> +                              TCGReg r1, TCGReg r3, int i2)
> +{
> +    tcg_out16(s, (op & 0xff00) | (r1 << 4) | r3);
> +    tcg_out16(s, i2);
> +    tcg_out16(s, op & 0xff);
> +}
> +
>   static void tcg_out_insn_RIEg(TCGContext *s, S390Opcode op, TCGReg r1,
> -                             int i2, int m3)
> +                              int i2, int m3)
>   {
>       tcg_out16(s, (op & 0xff00) | (r1 << 4) | m3);
>       tcg_out32(s, (i2 << 16) | (op & 0xff));
> @@ -2276,6 +2287,15 @@ static void tgen_addco_rrr(TCGContext *s, TCGType type,
>   static void tgen_addco_rri(TCGContext *s, TCGType type,
>                              TCGReg a0, TCGReg a1, tcg_target_long a2)
>   {
> +    if (a2 == (int16_t)a2) {
> +        if (type == TCG_TYPE_I32) {
> +            tcg_out_insn(s, RIEd, ALHSIK, a0, a1, a2);
> +        } else {
> +            tcg_out_insn(s, RIEd, ALGHSIK, a0, a1, a2);
> +        }
> +        return;
> +    }
> +
>       tcg_out_mov(s, type, a0, a1);
>       if (type == TCG_TYPE_I32) {
>           tcg_out_insn(s, RIL, ALFI, a0, a2);

Reviewed-by: Pierrick Bouvier <pierrick.bouvier@linaro.org>
diff mbox series

Patch

diff --git a/tcg/s390x/tcg-target.c.inc b/tcg/s390x/tcg-target.c.inc
index 2b31ea1c3e..36293d0f42 100644
--- a/tcg/s390x/tcg-target.c.inc
+++ b/tcg/s390x/tcg-target.c.inc
@@ -135,6 +135,9 @@  typedef enum S390Opcode {
     RIEc_CLGIJ   = 0xec7d,
     RIEc_CLIJ    = 0xec7f,
 
+    RIEd_ALHSIK  = 0xecda,
+    RIEd_ALGHSIK = 0xecdb,
+
     RIEf_RISBG   = 0xec55,
 
     RIEg_LOCGHI  = 0xec46,
@@ -682,8 +685,16 @@  static void tcg_out_insn_RI(TCGContext *s, S390Opcode op, TCGReg r1, int i2)
     tcg_out32(s, (op << 16) | (r1 << 20) | (i2 & 0xffff));
 }
 
+static void tcg_out_insn_RIEd(TCGContext *s, S390Opcode op,
+                              TCGReg r1, TCGReg r3, int i2)
+{
+    tcg_out16(s, (op & 0xff00) | (r1 << 4) | r3);
+    tcg_out16(s, i2);
+    tcg_out16(s, op & 0xff);
+}
+
 static void tcg_out_insn_RIEg(TCGContext *s, S390Opcode op, TCGReg r1,
-                             int i2, int m3)
+                              int i2, int m3)
 {
     tcg_out16(s, (op & 0xff00) | (r1 << 4) | m3);
     tcg_out32(s, (i2 << 16) | (op & 0xff));
@@ -2276,6 +2287,15 @@  static void tgen_addco_rrr(TCGContext *s, TCGType type,
 static void tgen_addco_rri(TCGContext *s, TCGType type,
                            TCGReg a0, TCGReg a1, tcg_target_long a2)
 {
+    if (a2 == (int16_t)a2) {
+        if (type == TCG_TYPE_I32) {
+            tcg_out_insn(s, RIEd, ALHSIK, a0, a1, a2);
+        } else {
+            tcg_out_insn(s, RIEd, ALGHSIK, a0, a1, a2);
+        }
+        return;
+    }
+
     tcg_out_mov(s, type, a0, a1);
     if (type == TCG_TYPE_I32) {
         tcg_out_insn(s, RIL, ALFI, a0, a2);