diff mbox

[v1,for-2.11,01/10] target/s390x: move cc_name() to cc_helper.c

Message ID 20170817092225.4264-2-david@redhat.com (mailing list archive)
State New, archived
Headers show

Commit Message

David Hildenbrand Aug. 17, 2017, 9:22 a.m. UTC
While at it, move the translations into the function.

Signed-off-by: David Hildenbrand <david@redhat.com>
---
 target/s390x/cc_helper.c | 48 ++++++++++++++++++++++++++++++++++++++++++++++++
 target/s390x/cpu.h       | 48 +-----------------------------------------------
 2 files changed, 49 insertions(+), 47 deletions(-)

Comments

Thomas Huth Aug. 17, 2017, 11:01 a.m. UTC | #1
On 17.08.2017 11:22, David Hildenbrand wrote:
> While at it, move the translations into the function.
> 
> Signed-off-by: David Hildenbrand <david@redhat.com>
> ---
>  target/s390x/cc_helper.c | 48 ++++++++++++++++++++++++++++++++++++++++++++++++
>  target/s390x/cpu.h       | 48 +-----------------------------------------------
>  2 files changed, 49 insertions(+), 47 deletions(-)

Reviewed-by: Thomas Huth <thuth@redhat.com>
Richard Henderson Aug. 18, 2017, 3:47 a.m. UTC | #2
On 08/17/2017 02:22 AM, David Hildenbrand wrote:
> +const char *cc_name(int cc_op)

While we're changing things up a tich, enum cc_op?

> +{
> +    static const char *cc_names[] = {

static const char * const cc_names[]

Otherwise,
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>


r~
David Hildenbrand Aug. 18, 2017, 9:59 a.m. UTC | #3
On 17.08.2017 11:22, David Hildenbrand wrote:
> While at it, move the translations into the function.
> 
> Signed-off-by: David Hildenbrand <david@redhat.com>
> ---
>  target/s390x/cc_helper.c | 48 ++++++++++++++++++++++++++++++++++++++++++++++++
>  target/s390x/cpu.h       | 48 +-----------------------------------------------
>  2 files changed, 49 insertions(+), 47 deletions(-)
> 
> diff --git a/target/s390x/cc_helper.c b/target/s390x/cc_helper.c
> index 1cf8551..a4562e5 100644
> --- a/target/s390x/cc_helper.c
> +++ b/target/s390x/cc_helper.c
> @@ -31,6 +31,54 @@
>  #define HELPER_LOG(x...)
>  #endif
>  
> +const char *cc_name(int cc_op)
> +{
> +    static const char *cc_names[] = {
> +        [CC_OP_CONST0]    = "CC_OP_CONST0",
> +        [CC_OP_CONST1]    = "CC_OP_CONST1",
> +        [CC_OP_CONST2]    = "CC_OP_CONST2",
> +        [CC_OP_CONST3]    = "CC_OP_CONST3",
> +        [CC_OP_DYNAMIC]   = "CC_OP_DYNAMIC",
> +        [CC_OP_STATIC]    = "CC_OP_STATIC",
> +        [CC_OP_NZ]        = "CC_OP_NZ",
> +        [CC_OP_LTGT_32]   = "CC_OP_LTGT_32",
> +        [CC_OP_LTGT_64]   = "CC_OP_LTGT_64",
> +        [CC_OP_LTUGTU_32] = "CC_OP_LTUGTU_32",
> +        [CC_OP_LTUGTU_64] = "CC_OP_LTUGTU_64",
> +        [CC_OP_LTGT0_32]  = "CC_OP_LTGT0_32",
> +        [CC_OP_LTGT0_64]  = "CC_OP_LTGT0_64",
> +        [CC_OP_ADD_64]    = "CC_OP_ADD_64",
> +        [CC_OP_ADDU_64]   = "CC_OP_ADDU_64",
> +        [CC_OP_ADDC_64]   = "CC_OP_ADDC_64",
> +        [CC_OP_SUB_64]    = "CC_OP_SUB_64",
> +        [CC_OP_SUBU_64]   = "CC_OP_SUBU_64",
> +        [CC_OP_SUBB_64]   = "CC_OP_SUBB_64",
> +        [CC_OP_ABS_64]    = "CC_OP_ABS_64",
> +        [CC_OP_NABS_64]   = "CC_OP_NABS_64",
> +        [CC_OP_ADD_32]    = "CC_OP_ADD_32",
> +        [CC_OP_ADDU_32]   = "CC_OP_ADDU_32",
> +        [CC_OP_ADDC_32]   = "CC_OP_ADDC_32",
> +        [CC_OP_SUB_32]    = "CC_OP_SUB_32",
> +        [CC_OP_SUBU_32]   = "CC_OP_SUBU_32",
> +        [CC_OP_SUBB_32]   = "CC_OP_SUBB_32",
> +        [CC_OP_ABS_32]    = "CC_OP_ABS_32",
> +        [CC_OP_NABS_32]   = "CC_OP_NABS_32",
> +        [CC_OP_COMP_32]   = "CC_OP_COMP_32",
> +        [CC_OP_COMP_64]   = "CC_OP_COMP_64",
> +        [CC_OP_TM_32]     = "CC_OP_TM_32",
> +        [CC_OP_TM_64]     = "CC_OP_TM_64",
> +        [CC_OP_NZ_F32]    = "CC_OP_NZ_F32",
> +        [CC_OP_NZ_F64]    = "CC_OP_NZ_F64",
> +        [CC_OP_NZ_F128]   = "CC_OP_NZ_F128",
> +        [CC_OP_ICM]       = "CC_OP_ICM",
> +        [CC_OP_SLA_32]    = "CC_OP_SLA_32",
> +        [CC_OP_SLA_64]    = "CC_OP_SLA_64",
> +        [CC_OP_FLOGR]     = "CC_OP_FLOGR",
> +    };
> +
> +    return cc_names[cc_op];
> +}
> +
>  static uint32_t cc_calc_ltgt_32(int32_t src, int32_t dst)
>  {
>      if (src == dst) {
> diff --git a/target/s390x/cpu.h b/target/s390x/cpu.h
> index 29fdd5d..3e798ef 100644
> --- a/target/s390x/cpu.h
> +++ b/target/s390x/cpu.h
> @@ -744,53 +744,7 @@ enum cc_op {
>      CC_OP_MAX
>  };
>  
> -static const char *cc_names[] = {
> -    [CC_OP_CONST0]    = "CC_OP_CONST0",
> -    [CC_OP_CONST1]    = "CC_OP_CONST1",
> -    [CC_OP_CONST2]    = "CC_OP_CONST2",
> -    [CC_OP_CONST3]    = "CC_OP_CONST3",
> -    [CC_OP_DYNAMIC]   = "CC_OP_DYNAMIC",
> -    [CC_OP_STATIC]    = "CC_OP_STATIC",
> -    [CC_OP_NZ]        = "CC_OP_NZ",
> -    [CC_OP_LTGT_32]   = "CC_OP_LTGT_32",
> -    [CC_OP_LTGT_64]   = "CC_OP_LTGT_64",
> -    [CC_OP_LTUGTU_32] = "CC_OP_LTUGTU_32",
> -    [CC_OP_LTUGTU_64] = "CC_OP_LTUGTU_64",
> -    [CC_OP_LTGT0_32]  = "CC_OP_LTGT0_32",
> -    [CC_OP_LTGT0_64]  = "CC_OP_LTGT0_64",
> -    [CC_OP_ADD_64]    = "CC_OP_ADD_64",
> -    [CC_OP_ADDU_64]   = "CC_OP_ADDU_64",
> -    [CC_OP_ADDC_64]   = "CC_OP_ADDC_64",
> -    [CC_OP_SUB_64]    = "CC_OP_SUB_64",
> -    [CC_OP_SUBU_64]   = "CC_OP_SUBU_64",
> -    [CC_OP_SUBB_64]   = "CC_OP_SUBB_64",
> -    [CC_OP_ABS_64]    = "CC_OP_ABS_64",
> -    [CC_OP_NABS_64]   = "CC_OP_NABS_64",
> -    [CC_OP_ADD_32]    = "CC_OP_ADD_32",
> -    [CC_OP_ADDU_32]   = "CC_OP_ADDU_32",
> -    [CC_OP_ADDC_32]   = "CC_OP_ADDC_32",
> -    [CC_OP_SUB_32]    = "CC_OP_SUB_32",
> -    [CC_OP_SUBU_32]   = "CC_OP_SUBU_32",
> -    [CC_OP_SUBB_32]   = "CC_OP_SUBB_32",
> -    [CC_OP_ABS_32]    = "CC_OP_ABS_32",
> -    [CC_OP_NABS_32]   = "CC_OP_NABS_32",
> -    [CC_OP_COMP_32]   = "CC_OP_COMP_32",
> -    [CC_OP_COMP_64]   = "CC_OP_COMP_64",
> -    [CC_OP_TM_32]     = "CC_OP_TM_32",
> -    [CC_OP_TM_64]     = "CC_OP_TM_64",
> -    [CC_OP_NZ_F32]    = "CC_OP_NZ_F32",
> -    [CC_OP_NZ_F64]    = "CC_OP_NZ_F64",
> -    [CC_OP_NZ_F128]   = "CC_OP_NZ_F128",
> -    [CC_OP_ICM]       = "CC_OP_ICM",
> -    [CC_OP_SLA_32]    = "CC_OP_SLA_32",
> -    [CC_OP_SLA_64]    = "CC_OP_SLA_64",
> -    [CC_OP_FLOGR]     = "CC_OP_FLOGR",
> -};
> -
> -static inline const char *cc_name(int cc_op)
> -{
> -    return cc_names[cc_op];
> -}
> +const char *cc_name(int cc_op);
>  
>  static inline void setcc(S390CPU *cpu, uint64_t cc)
>  {
> 

Just compiled with --disable-tcg

s390_cpu_dump_state() needs cc_name. I suggest moving it to helper.c
instead. Opinions?
Thomas Huth Aug. 18, 2017, 10:04 a.m. UTC | #4
On 18.08.2017 11:59, David Hildenbrand wrote:
> On 17.08.2017 11:22, David Hildenbrand wrote:
>> While at it, move the translations into the function.
>>
>> Signed-off-by: David Hildenbrand <david@redhat.com>
>> ---
>>  target/s390x/cc_helper.c | 48 ++++++++++++++++++++++++++++++++++++++++++++++++
>>  target/s390x/cpu.h       | 48 +-----------------------------------------------
>>  2 files changed, 49 insertions(+), 47 deletions(-)
[...]
> Just compiled with --disable-tcg
> 
> s390_cpu_dump_state() needs cc_name. I suggest moving it to helper.c
> instead. Opinions?

Sounds fine to me, too.

 Thomas
Cornelia Huck Aug. 18, 2017, 10:50 a.m. UTC | #5
On Fri, 18 Aug 2017 12:04:14 +0200
Thomas Huth <thuth@redhat.com> wrote:

> On 18.08.2017 11:59, David Hildenbrand wrote:
> > On 17.08.2017 11:22, David Hildenbrand wrote:  
> >> While at it, move the translations into the function.
> >>
> >> Signed-off-by: David Hildenbrand <david@redhat.com>
> >> ---
> >>  target/s390x/cc_helper.c | 48 ++++++++++++++++++++++++++++++++++++++++++++++++
> >>  target/s390x/cpu.h       | 48 +-----------------------------------------------
> >>  2 files changed, 49 insertions(+), 47 deletions(-)  
> [...]
> > Just compiled with --disable-tcg
> > 
> > s390_cpu_dump_state() needs cc_name. I suggest moving it to helper.c
> > instead. Opinions?  
> 
> Sounds fine to me, too.
> 
>  Thomas
> 
> 

Agreed.
diff mbox

Patch

diff --git a/target/s390x/cc_helper.c b/target/s390x/cc_helper.c
index 1cf8551..a4562e5 100644
--- a/target/s390x/cc_helper.c
+++ b/target/s390x/cc_helper.c
@@ -31,6 +31,54 @@ 
 #define HELPER_LOG(x...)
 #endif
 
+const char *cc_name(int cc_op)
+{
+    static const char *cc_names[] = {
+        [CC_OP_CONST0]    = "CC_OP_CONST0",
+        [CC_OP_CONST1]    = "CC_OP_CONST1",
+        [CC_OP_CONST2]    = "CC_OP_CONST2",
+        [CC_OP_CONST3]    = "CC_OP_CONST3",
+        [CC_OP_DYNAMIC]   = "CC_OP_DYNAMIC",
+        [CC_OP_STATIC]    = "CC_OP_STATIC",
+        [CC_OP_NZ]        = "CC_OP_NZ",
+        [CC_OP_LTGT_32]   = "CC_OP_LTGT_32",
+        [CC_OP_LTGT_64]   = "CC_OP_LTGT_64",
+        [CC_OP_LTUGTU_32] = "CC_OP_LTUGTU_32",
+        [CC_OP_LTUGTU_64] = "CC_OP_LTUGTU_64",
+        [CC_OP_LTGT0_32]  = "CC_OP_LTGT0_32",
+        [CC_OP_LTGT0_64]  = "CC_OP_LTGT0_64",
+        [CC_OP_ADD_64]    = "CC_OP_ADD_64",
+        [CC_OP_ADDU_64]   = "CC_OP_ADDU_64",
+        [CC_OP_ADDC_64]   = "CC_OP_ADDC_64",
+        [CC_OP_SUB_64]    = "CC_OP_SUB_64",
+        [CC_OP_SUBU_64]   = "CC_OP_SUBU_64",
+        [CC_OP_SUBB_64]   = "CC_OP_SUBB_64",
+        [CC_OP_ABS_64]    = "CC_OP_ABS_64",
+        [CC_OP_NABS_64]   = "CC_OP_NABS_64",
+        [CC_OP_ADD_32]    = "CC_OP_ADD_32",
+        [CC_OP_ADDU_32]   = "CC_OP_ADDU_32",
+        [CC_OP_ADDC_32]   = "CC_OP_ADDC_32",
+        [CC_OP_SUB_32]    = "CC_OP_SUB_32",
+        [CC_OP_SUBU_32]   = "CC_OP_SUBU_32",
+        [CC_OP_SUBB_32]   = "CC_OP_SUBB_32",
+        [CC_OP_ABS_32]    = "CC_OP_ABS_32",
+        [CC_OP_NABS_32]   = "CC_OP_NABS_32",
+        [CC_OP_COMP_32]   = "CC_OP_COMP_32",
+        [CC_OP_COMP_64]   = "CC_OP_COMP_64",
+        [CC_OP_TM_32]     = "CC_OP_TM_32",
+        [CC_OP_TM_64]     = "CC_OP_TM_64",
+        [CC_OP_NZ_F32]    = "CC_OP_NZ_F32",
+        [CC_OP_NZ_F64]    = "CC_OP_NZ_F64",
+        [CC_OP_NZ_F128]   = "CC_OP_NZ_F128",
+        [CC_OP_ICM]       = "CC_OP_ICM",
+        [CC_OP_SLA_32]    = "CC_OP_SLA_32",
+        [CC_OP_SLA_64]    = "CC_OP_SLA_64",
+        [CC_OP_FLOGR]     = "CC_OP_FLOGR",
+    };
+
+    return cc_names[cc_op];
+}
+
 static uint32_t cc_calc_ltgt_32(int32_t src, int32_t dst)
 {
     if (src == dst) {
diff --git a/target/s390x/cpu.h b/target/s390x/cpu.h
index 29fdd5d..3e798ef 100644
--- a/target/s390x/cpu.h
+++ b/target/s390x/cpu.h
@@ -744,53 +744,7 @@  enum cc_op {
     CC_OP_MAX
 };
 
-static const char *cc_names[] = {
-    [CC_OP_CONST0]    = "CC_OP_CONST0",
-    [CC_OP_CONST1]    = "CC_OP_CONST1",
-    [CC_OP_CONST2]    = "CC_OP_CONST2",
-    [CC_OP_CONST3]    = "CC_OP_CONST3",
-    [CC_OP_DYNAMIC]   = "CC_OP_DYNAMIC",
-    [CC_OP_STATIC]    = "CC_OP_STATIC",
-    [CC_OP_NZ]        = "CC_OP_NZ",
-    [CC_OP_LTGT_32]   = "CC_OP_LTGT_32",
-    [CC_OP_LTGT_64]   = "CC_OP_LTGT_64",
-    [CC_OP_LTUGTU_32] = "CC_OP_LTUGTU_32",
-    [CC_OP_LTUGTU_64] = "CC_OP_LTUGTU_64",
-    [CC_OP_LTGT0_32]  = "CC_OP_LTGT0_32",
-    [CC_OP_LTGT0_64]  = "CC_OP_LTGT0_64",
-    [CC_OP_ADD_64]    = "CC_OP_ADD_64",
-    [CC_OP_ADDU_64]   = "CC_OP_ADDU_64",
-    [CC_OP_ADDC_64]   = "CC_OP_ADDC_64",
-    [CC_OP_SUB_64]    = "CC_OP_SUB_64",
-    [CC_OP_SUBU_64]   = "CC_OP_SUBU_64",
-    [CC_OP_SUBB_64]   = "CC_OP_SUBB_64",
-    [CC_OP_ABS_64]    = "CC_OP_ABS_64",
-    [CC_OP_NABS_64]   = "CC_OP_NABS_64",
-    [CC_OP_ADD_32]    = "CC_OP_ADD_32",
-    [CC_OP_ADDU_32]   = "CC_OP_ADDU_32",
-    [CC_OP_ADDC_32]   = "CC_OP_ADDC_32",
-    [CC_OP_SUB_32]    = "CC_OP_SUB_32",
-    [CC_OP_SUBU_32]   = "CC_OP_SUBU_32",
-    [CC_OP_SUBB_32]   = "CC_OP_SUBB_32",
-    [CC_OP_ABS_32]    = "CC_OP_ABS_32",
-    [CC_OP_NABS_32]   = "CC_OP_NABS_32",
-    [CC_OP_COMP_32]   = "CC_OP_COMP_32",
-    [CC_OP_COMP_64]   = "CC_OP_COMP_64",
-    [CC_OP_TM_32]     = "CC_OP_TM_32",
-    [CC_OP_TM_64]     = "CC_OP_TM_64",
-    [CC_OP_NZ_F32]    = "CC_OP_NZ_F32",
-    [CC_OP_NZ_F64]    = "CC_OP_NZ_F64",
-    [CC_OP_NZ_F128]   = "CC_OP_NZ_F128",
-    [CC_OP_ICM]       = "CC_OP_ICM",
-    [CC_OP_SLA_32]    = "CC_OP_SLA_32",
-    [CC_OP_SLA_64]    = "CC_OP_SLA_64",
-    [CC_OP_FLOGR]     = "CC_OP_FLOGR",
-};
-
-static inline const char *cc_name(int cc_op)
-{
-    return cc_names[cc_op];
-}
+const char *cc_name(int cc_op);
 
 static inline void setcc(S390CPU *cpu, uint64_t cc)
 {