Patchwork [RFC,2/4] target-i386: Move feature word array outside get_register_name_32()

login
register
mail settings
Submitter Eduardo Habkost
Date April 1, 2013, 7:46 p.m.
Message ID <1364845609-10543-3-git-send-email-ehabkost@redhat.com>
Download mbox | patch
Permalink /patch/232794/
State New
Headers show

Comments

Eduardo Habkost - April 1, 2013, 7:46 p.m.
The array will be used by the "feature-words" properties to output the
register enum value.

Signed-off-by: Eduardo Habkost <ehabkost@redhat.com>
---
 target-i386/cpu.c | 25 +++++++++++++------------
 1 file changed, 13 insertions(+), 12 deletions(-)
Eduardo Habkost - April 2, 2013, 6:54 p.m.
On Mon, Apr 01, 2013 at 04:46:47PM -0300, Eduardo Habkost wrote:
> The array will be used by the "feature-words" properties to output the
> register enum value.

Oops, the patch subject line is wrong: it was supposed to say "Move
register name array".

> 
> Signed-off-by: Eduardo Habkost <ehabkost@redhat.com>
> ---
>  target-i386/cpu.c | 25 +++++++++++++------------
>  1 file changed, 13 insertions(+), 12 deletions(-)
> 
> diff --git a/target-i386/cpu.c b/target-i386/cpu.c
> index 974a8c6..2020147 100644
> --- a/target-i386/cpu.c
> +++ b/target-i386/cpu.c
> @@ -194,23 +194,24 @@ static FeatureWordInfo feature_word_info[FEATURE_WORDS] = {
>      },
>  };
>  
> +static const char *reg_names_32[CPU_NB_REGS32] = {
> +    [R_EAX] = "EAX",
> +    [R_ECX] = "ECX",
> +    [R_EDX] = "EDX",
> +    [R_EBX] = "EBX",
> +    [R_ESP] = "ESP",
> +    [R_EBP] = "EBP",
> +    [R_ESI] = "ESI",
> +    [R_EDI] = "EDI",
> +};
> +
> +
>  const char *get_register_name_32(unsigned int reg)
>  {
> -    static const char *reg_names[CPU_NB_REGS32] = {
> -        [R_EAX] = "EAX",
> -        [R_ECX] = "ECX",
> -        [R_EDX] = "EDX",
> -        [R_EBX] = "EBX",
> -        [R_ESP] = "ESP",
> -        [R_EBP] = "EBP",
> -        [R_ESI] = "ESI",
> -        [R_EDI] = "EDI",
> -    };
> -
>      if (reg > CPU_NB_REGS32) {
>          return NULL;
>      }
> -    return reg_names[reg];
> +    return reg_names_32[reg];
>  }
>  
>  /* collects per-function cpuid data
> -- 
> 1.8.1.4
> 
>

Patch

diff --git a/target-i386/cpu.c b/target-i386/cpu.c
index 974a8c6..2020147 100644
--- a/target-i386/cpu.c
+++ b/target-i386/cpu.c
@@ -194,23 +194,24 @@  static FeatureWordInfo feature_word_info[FEATURE_WORDS] = {
     },
 };
 
+static const char *reg_names_32[CPU_NB_REGS32] = {
+    [R_EAX] = "EAX",
+    [R_ECX] = "ECX",
+    [R_EDX] = "EDX",
+    [R_EBX] = "EBX",
+    [R_ESP] = "ESP",
+    [R_EBP] = "EBP",
+    [R_ESI] = "ESI",
+    [R_EDI] = "EDI",
+};
+
+
 const char *get_register_name_32(unsigned int reg)
 {
-    static const char *reg_names[CPU_NB_REGS32] = {
-        [R_EAX] = "EAX",
-        [R_ECX] = "ECX",
-        [R_EDX] = "EDX",
-        [R_EBX] = "EBX",
-        [R_ESP] = "ESP",
-        [R_EBP] = "EBP",
-        [R_ESI] = "ESI",
-        [R_EDI] = "EDI",
-    };
-
     if (reg > CPU_NB_REGS32) {
         return NULL;
     }
-    return reg_names[reg];
+    return reg_names_32[reg];
 }
 
 /* collects per-function cpuid data