Skip to contentSkip to conversation

target/ppc: Rename variables to avoid local variable shadowing in VUPKPX

PATCH Superseded Cédric Le Goater 3 participants 5 messages Sep 23, 2023 – Sep 29, 2023

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 target/ppc: Rename variables to avoid local variable shadowing in VUPKPX

and fix such warnings :

../target/ppc/int_helper.c: In function ‘helper_vupklpx’:
../target/ppc/int_helper.c:2025:21: warning: declaration of ‘r’ shadows a parameter [-Wshadow=local]
2025 | uint8_t r = (e >> 10) & 0x1f; \
| ^
../target/ppc/int_helper.c:2033:1: note: in expansion of macro ‘VUPKPX’
2033 | VUPKPX(lpx, UPKLO)

        | ^~~~~~
  ../target/ppc/int_helper.c:2017:41: note: shadowed declaration is here
   2017 |     void helper_vupk##suffix(ppc_avr_t *r, ppc_avr_t *b)                \
        |                              ~~~~~~~~~~~^
  ../target/ppc/int_helper.c:2033:1: note: in expansion of macro ‘VUPKPX’
   2033 | VUPKPX(lpx, UPKLO)
        | ^~~~~~
---
 target/ppc/int_helper.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)
target/ppc/int_helper.c +3 -3
index 6fd00684a5b9..8719ac6e6265 100644
@@ -2022,11 +2022,11 @@ void helper_vsum4ubs(CPUPPCState *env, ppc_avr_t *r, ppc_avr_t *a, ppc_avr_t *b)
         for (i = 0; i < ARRAY_SIZE(r->u32); i++) {                      \
             uint16_t e = b->u16[hi ? i : i + 4];                        \
             uint8_t a = (e >> 15) ? 0xff : 0;                           \
-            uint8_t r = (e >> 10) & 0x1f;                               \
+            uint8_t _r = (e >> 10) & 0x1f;                              \
             uint8_t g = (e >> 5) & 0x1f;                                \
-            uint8_t b = e & 0x1f;                                       \
+            uint8_t _b = e & 0x1f;                                      \
                                                                         \
-            result.u32[i] = (a << 24) | (r << 16) | (g << 8) | b;       \
+            result.u32[i] = (a << 24) | (_r << 16) | (g << 8) | _b;     \
         }                                                               \
         *r = result;                                                    \
     }
Signature · 1 line
2.41.0
#1 lore raw

23.09.2023 10:12, Cédric Le Goater:

target/ppc/int_helper.c void helper_vsum4ubs(CPUPPCState *env, ppc_avr_t *r, ppc_avr_t *a, ppc_avr_t *b) · line 2027

Quoted 11 lines
target/ppc/int_helper.c +2 -2
@@ -2022,11 +2022,11 @@ void helper_vsum4ubs(CPUPPCState *env, ppc_avr_t *r, ppc_avr_t *a, ppc_avr_t *b)
          for (i = 0; i < ARRAY_SIZE(r->u32); i++) {                      \
              uint16_t e = b->u16[hi ? i : i + 4];                        \
              uint8_t a = (e >> 15) ? 0xff : 0;                           \
-            uint8_t r = (e >> 10) & 0x1f;                               \
+            uint8_t _r = (e >> 10) & 0x1f;                              \
              uint8_t g = (e >> 5) & 0x1f;                                \
-            uint8_t b = e & 0x1f;                                       \
+            uint8_t _b = e & 0x1f;                                      \

I'd suggest to rename all of them here to have the same pattern. Maybe.. :)

/mjt

#2 lore raw
Quoted 15 lines · Michael Tokarev

23.09.2023 10:12, Cédric Le Goater:

target/ppc/int_helper.c void helper_vsum4ubs(CPUPPCState *env, ppc_avr_t *r, ppc_avr_t *a, ppc_avr_t *b) · line 2027

Quoted 11 lines
target/ppc/int_helper.c +2 -2
@@ -2022,11 +2022,11 @@ void helper_vsum4ubs(CPUPPCState *env, ppc_avr_t *r, ppc_avr_t *a, ppc_avr_t *b)
           for (i = 0; i < ARRAY_SIZE(r->u32); i++) {                      \
               uint16_t e = b->u16[hi ? i : i + 4];                        \
               uint8_t a = (e >> 15) ? 0xff : 0;                           \
-            uint8_t r = (e >> 10) & 0x1f;                               \
+            uint8_t _r = (e >> 10) & 0x1f;                              \
               uint8_t g = (e >> 5) & 0x1f;                                \
-            uint8_t b = e & 0x1f;                                       \
+            uint8_t _b = e & 0x1f;                                      \

I'd suggest to rename all of them here to have the same pattern.  Maybe.. :)

or maybe use the field names from the ISA : VRT,VRA,VRB ?

C.

#3 lore raw
Quoted 16 lines · Cédric Le Goater
Quoted 14 lines · Michael Tokarev

23.09.2023 10:12, Cédric Le Goater:

target/ppc/int_helper.c void helper_vsum4ubs(CPUPPCState *env, ppc_avr_t *r, ppc_avr_t *a, ppc_avr_t *b) · line 2027

Quoted 11 lines
target/ppc/int_helper.c +2 -2
@@ -2022,11 +2022,11 @@ void helper_vsum4ubs(CPUPPCState *env, ppc_avr_t *r, ppc_avr_t *a, ppc_avr_t *b)
           for (i = 0; i < ARRAY_SIZE(r->u32); i++) {                      \
               uint16_t e = b->u16[hi ? i : i + 4];                        \
               uint8_t a = (e >> 15) ? 0xff : 0;                           \
-            uint8_t r = (e >> 10) & 0x1f;                               \
+            uint8_t _r = (e >> 10) & 0x1f;                              \
               uint8_t g = (e >> 5) & 0x1f;                                \
-            uint8_t b = e & 0x1f;                                       \
+            uint8_t _b = e & 0x1f;                                      \

I'd suggest to rename all of them here to have the same pattern.  Maybe.. :)

Quoted 1 line

or maybe use the field names from the ISA : VRT,VRA,VRB ?

Should I expect a respin?

If not, anyone ready to give an R-by as is?

#4 lore raw
Quoted 18 lines · Markus Armbruster
Quoted 16 lines · Cédric Le Goater
Quoted 14 lines · Michael Tokarev

23.09.2023 10:12, Cédric Le Goater:

target/ppc/int_helper.c void helper_vsum4ubs(CPUPPCState *env, ppc_avr_t *r, ppc_avr_t *a, ppc_avr_t *b) · line 2027

Quoted 11 lines
target/ppc/int_helper.c +2 -2
@@ -2022,11 +2022,11 @@ void helper_vsum4ubs(CPUPPCState *env, ppc_avr_t *r, ppc_avr_t *a, ppc_avr_t *b)
           for (i = 0; i < ARRAY_SIZE(r->u32); i++) {                      \
               uint16_t e = b->u16[hi ? i : i + 4];                        \
               uint8_t a = (e >> 15) ? 0xff : 0;                           \
-            uint8_t r = (e >> 10) & 0x1f;                               \
+            uint8_t _r = (e >> 10) & 0x1f;                              \
               uint8_t g = (e >> 5) & 0x1f;                                \
-            uint8_t b = e & 0x1f;                                       \
+            uint8_t _b = e & 0x1f;                                      \

I'd suggest to rename all of them here to have the same pattern.  Maybe.. :)

Quoted 5 lines
Quoted 1 line

or maybe use the field names from the ISA : VRT,VRA,VRB ?

Should I expect a respin?

If not, anyone ready to give an R-by as is?

This one I can respin. I agree with Michael that some consistency is preferable. Preparing a v2 full of '_'.

Thanks,

C.