Patchwork [13/35] tcg-s390: Tidy regset initialization; use R14 as temporary.

login
register
mail settings
Submitter Richard Henderson
Date June 4, 2010, 7:14 p.m.
Message ID <1275678883-7082-14-git-send-email-rth@twiddle.net>
Download mbox | patch
Permalink /patch/54677/
State New
Headers show

Comments

Richard Henderson - June 4, 2010, 7:14 p.m.
Signed-off-by: Richard Henderson <rth@twiddle.net>
---
 tcg/s390/tcg-target.c |   26 ++++++++++++--------------
 1 files changed, 12 insertions(+), 14 deletions(-)
Aurelien Jarno - June 10, 2010, 10:26 a.m.
On Fri, Jun 04, 2010 at 12:14:21PM -0700, Richard Henderson wrote:
> Signed-off-by: Richard Henderson <rth@twiddle.net>
> ---
>  tcg/s390/tcg-target.c |   26 ++++++++++++--------------
>  1 files changed, 12 insertions(+), 14 deletions(-)

This patch looks fine.

> diff --git a/tcg/s390/tcg-target.c b/tcg/s390/tcg-target.c
> index 2b80c02..95ea3c8 100644
> --- a/tcg/s390/tcg-target.c
> +++ b/tcg/s390/tcg-target.c
> @@ -41,7 +41,7 @@
>  #define TCG_REG_NONE    0
>  
>  /* A scratch register that may be be used throughout the backend.  */
> -#define TCG_TMP0        TCG_REG_R13
> +#define TCG_TMP0        TCG_REG_R14
>  
>  
>  /* All of the following instructions are prefixed with their instruction
> @@ -1185,24 +1185,22 @@ void tcg_target_init(TCGContext *s)
>  
>      tcg_regset_set32(tcg_target_available_regs[TCG_TYPE_I32], 0, 0xffff);
>      tcg_regset_set32(tcg_target_available_regs[TCG_TYPE_I64], 0, 0xffff);
> -    tcg_regset_set32(tcg_target_call_clobber_regs, 0,
> -                     (1 << TCG_REG_R0) |
> -                     (1 << TCG_REG_R1) |
> -                     (1 << TCG_REG_R2) |
> -                     (1 << TCG_REG_R3) |
> -                     (1 << TCG_REG_R4) |
> -                     (1 << TCG_REG_R5) |
> -                     (1 << TCG_REG_R14)); /* link register */
> +
> +    tcg_regset_clear(tcg_target_call_clobber_regs);
> +    tcg_regset_set_reg(tcg_target_call_clobber_regs, TCG_REG_R0);
> +    tcg_regset_set_reg(tcg_target_call_clobber_regs, TCG_REG_R1);
> +    tcg_regset_set_reg(tcg_target_call_clobber_regs, TCG_REG_R2);
> +    tcg_regset_set_reg(tcg_target_call_clobber_regs, TCG_REG_R3);
> +    tcg_regset_set_reg(tcg_target_call_clobber_regs, TCG_REG_R4);
> +    tcg_regset_set_reg(tcg_target_call_clobber_regs, TCG_REG_R5);
> +    /* The return register can be considered call-clobbered.  */
> +    tcg_regset_set_reg(tcg_target_call_clobber_regs, TCG_REG_R14);
>  
>      tcg_regset_clear(s->reserved_regs);
> -    /* frequently used as a temporary */
>      tcg_regset_set_reg(s->reserved_regs, TCG_TMP0);
> -    /* another temporary */
> -    tcg_regset_set_reg(s->reserved_regs, TCG_REG_R12);
>      /* XXX many insns can't be used with R0, so we better avoid it for now */
>      tcg_regset_set_reg(s->reserved_regs, TCG_REG_R0);
> -    /* The stack pointer.  */
> -    tcg_regset_set_reg(s->reserved_regs, TCG_REG_R15);
> +    tcg_regset_set_reg(s->reserved_regs, TCG_REG_CALL_STACK);
>  
>      tcg_add_target_add_op_defs(s390_op_defs);
>  }
> -- 
> 1.7.0.1
> 
> 
>

Patch

diff --git a/tcg/s390/tcg-target.c b/tcg/s390/tcg-target.c
index 2b80c02..95ea3c8 100644
--- a/tcg/s390/tcg-target.c
+++ b/tcg/s390/tcg-target.c
@@ -41,7 +41,7 @@ 
 #define TCG_REG_NONE    0
 
 /* A scratch register that may be be used throughout the backend.  */
-#define TCG_TMP0        TCG_REG_R13
+#define TCG_TMP0        TCG_REG_R14
 
 
 /* All of the following instructions are prefixed with their instruction
@@ -1185,24 +1185,22 @@  void tcg_target_init(TCGContext *s)
 
     tcg_regset_set32(tcg_target_available_regs[TCG_TYPE_I32], 0, 0xffff);
     tcg_regset_set32(tcg_target_available_regs[TCG_TYPE_I64], 0, 0xffff);
-    tcg_regset_set32(tcg_target_call_clobber_regs, 0,
-                     (1 << TCG_REG_R0) |
-                     (1 << TCG_REG_R1) |
-                     (1 << TCG_REG_R2) |
-                     (1 << TCG_REG_R3) |
-                     (1 << TCG_REG_R4) |
-                     (1 << TCG_REG_R5) |
-                     (1 << TCG_REG_R14)); /* link register */
+
+    tcg_regset_clear(tcg_target_call_clobber_regs);
+    tcg_regset_set_reg(tcg_target_call_clobber_regs, TCG_REG_R0);
+    tcg_regset_set_reg(tcg_target_call_clobber_regs, TCG_REG_R1);
+    tcg_regset_set_reg(tcg_target_call_clobber_regs, TCG_REG_R2);
+    tcg_regset_set_reg(tcg_target_call_clobber_regs, TCG_REG_R3);
+    tcg_regset_set_reg(tcg_target_call_clobber_regs, TCG_REG_R4);
+    tcg_regset_set_reg(tcg_target_call_clobber_regs, TCG_REG_R5);
+    /* The return register can be considered call-clobbered.  */
+    tcg_regset_set_reg(tcg_target_call_clobber_regs, TCG_REG_R14);
 
     tcg_regset_clear(s->reserved_regs);
-    /* frequently used as a temporary */
     tcg_regset_set_reg(s->reserved_regs, TCG_TMP0);
-    /* another temporary */
-    tcg_regset_set_reg(s->reserved_regs, TCG_REG_R12);
     /* XXX many insns can't be used with R0, so we better avoid it for now */
     tcg_regset_set_reg(s->reserved_regs, TCG_REG_R0);
-    /* The stack pointer.  */
-    tcg_regset_set_reg(s->reserved_regs, TCG_REG_R15);
+    tcg_regset_set_reg(s->reserved_regs, TCG_REG_CALL_STACK);
 
     tcg_add_target_add_op_defs(s390_op_defs);
 }