RE: [PATCH v2 2/3] target/hexagon: fix some occurrences of -Wshadow=local

2023-10-06 Thread ltaylorsimpson



> -Original Message-
> From: Brian Cain 
> Sent: Thursday, October 5, 2023 4:22 PM
> To: qemu-devel@nongnu.org
> Cc: bc...@quicinc.com; arm...@redhat.com; richard.hender...@linaro.org;
> phi...@linaro.org; peter.mayd...@linaro.org; quic_mathb...@quicinc.com;
> stefa...@redhat.com; a...@rev.ng; a...@rev.ng;
> quic_mlie...@quicinc.com; ltaylorsimp...@gmail.com
> Subject: [PATCH v2 2/3] target/hexagon: fix some occurrences of -
> Wshadow=local
> 
> Of the changes in this commit, the changes in
> `HELPER(commit_hvx_stores)()` are less obvious.  They are required because
> of some macro invocations like SCATTER_OP_WRITE_TO_MEM().
> 
> e.g.:
> 
> In file included from ../target/hexagon/op_helper.c:31:
> ../target/hexagon/mmvec/macros.h:205:18: error: declaration of ‘i’
> shadows a previous local [-Werror=shadow=compatible-local]
>   205 | for (int i = 0; i < sizeof(MMVector); i += sizeof(TYPE)) 
> { \
>   |  ^
> ../target/hexagon/op_helper.c:157:17: note: in expansion of macro
> ‘SCATTER_OP_WRITE_TO_MEM’
>   157 | SCATTER_OP_WRITE_TO_MEM(uint16_t);
>   | ^~~
> ../target/hexagon/op_helper.c:135:9: note: shadowed declaration is here
>   135 | int i;
>   | ^
> In file included from ../target/hexagon/op_helper.c:31:
> ../target/hexagon/mmvec/macros.h:204:19: error: declaration of ‘ra’
> shadows a previous local [-Werror=shadow=compatible-local]
>   204 | uintptr_t ra = GETPC(); \
>   |   ^~
> ../target/hexagon/op_helper.c:160:17: note: in expansion of macro
> ‘SCATTER_OP_WRITE_TO_MEM’
>   160 | SCATTER_OP_WRITE_TO_MEM(uint32_t);
>   | ^~~
> ../target/hexagon/op_helper.c:134:15: note: shadowed declaration is here
>   134 | uintptr_t ra = GETPC();
>   |   ^~
> 
> Reviewed-by: Matheus Tavares Bernardino 
> Signed-off-by: Brian Cain 
> ---
>  target/hexagon/imported/alu.idef | 6 +++---
>  target/hexagon/mmvec/macros.h| 6 +++---
>  target/hexagon/op_helper.c   | 9 +++--
>  target/hexagon/translate.c   | 9 -
>  4 files changed, 13 insertions(+), 17 deletions(-)

Reviewed-by: Taylor Simpson 





Re: [PATCH v2 2/3] target/hexagon: fix some occurrences of -Wshadow=local

2023-10-05 Thread Philippe Mathieu-Daudé

On 6/10/23 00:22, Brian Cain wrote:

Of the changes in this commit, the changes in `HELPER(commit_hvx_stores)()`
are less obvious.  They are required because of some macro invocations like
SCATTER_OP_WRITE_TO_MEM().

e.g.:

 In file included from ../target/hexagon/op_helper.c:31:
 ../target/hexagon/mmvec/macros.h:205:18: error: declaration of ‘i’ shadows 
a previous local [-Werror=shadow=compatible-local]
   205 | for (int i = 0; i < sizeof(MMVector); i += sizeof(TYPE)) { 
\
   |  ^
 ../target/hexagon/op_helper.c:157:17: note: in expansion of macro 
‘SCATTER_OP_WRITE_TO_MEM’
   157 | SCATTER_OP_WRITE_TO_MEM(uint16_t);
   | ^~~
 ../target/hexagon/op_helper.c:135:9: note: shadowed declaration is here
   135 | int i;
   | ^
 In file included from ../target/hexagon/op_helper.c:31:
 ../target/hexagon/mmvec/macros.h:204:19: error: declaration of ‘ra’ 
shadows a previous local [-Werror=shadow=compatible-local]
   204 | uintptr_t ra = GETPC(); \
   |   ^~
 ../target/hexagon/op_helper.c:160:17: note: in expansion of macro 
‘SCATTER_OP_WRITE_TO_MEM’
   160 | SCATTER_OP_WRITE_TO_MEM(uint32_t);
   | ^~~
 ../target/hexagon/op_helper.c:134:15: note: shadowed declaration is here
   134 | uintptr_t ra = GETPC();
   |   ^~

Reviewed-by: Matheus Tavares Bernardino 
Signed-off-by: Brian Cain 
---
  target/hexagon/imported/alu.idef | 6 +++---
  target/hexagon/mmvec/macros.h| 6 +++---
  target/hexagon/op_helper.c   | 9 +++--
  target/hexagon/translate.c   | 9 -
  4 files changed, 13 insertions(+), 17 deletions(-)


Reviewed-by: Philippe Mathieu-Daudé 




[PATCH v2 2/3] target/hexagon: fix some occurrences of -Wshadow=local

2023-10-05 Thread Brian Cain
Of the changes in this commit, the changes in `HELPER(commit_hvx_stores)()`
are less obvious.  They are required because of some macro invocations like
SCATTER_OP_WRITE_TO_MEM().

e.g.:

In file included from ../target/hexagon/op_helper.c:31:
../target/hexagon/mmvec/macros.h:205:18: error: declaration of ‘i’ shadows 
a previous local [-Werror=shadow=compatible-local]
  205 | for (int i = 0; i < sizeof(MMVector); i += sizeof(TYPE)) { \
  |  ^
../target/hexagon/op_helper.c:157:17: note: in expansion of macro 
‘SCATTER_OP_WRITE_TO_MEM’
  157 | SCATTER_OP_WRITE_TO_MEM(uint16_t);
  | ^~~
../target/hexagon/op_helper.c:135:9: note: shadowed declaration is here
  135 | int i;
  | ^
In file included from ../target/hexagon/op_helper.c:31:
../target/hexagon/mmvec/macros.h:204:19: error: declaration of ‘ra’ shadows 
a previous local [-Werror=shadow=compatible-local]
  204 | uintptr_t ra = GETPC(); \
  |   ^~
../target/hexagon/op_helper.c:160:17: note: in expansion of macro 
‘SCATTER_OP_WRITE_TO_MEM’
  160 | SCATTER_OP_WRITE_TO_MEM(uint32_t);
  | ^~~
../target/hexagon/op_helper.c:134:15: note: shadowed declaration is here
  134 | uintptr_t ra = GETPC();
  |   ^~

Reviewed-by: Matheus Tavares Bernardino 
Signed-off-by: Brian Cain 
---
 target/hexagon/imported/alu.idef | 6 +++---
 target/hexagon/mmvec/macros.h| 6 +++---
 target/hexagon/op_helper.c   | 9 +++--
 target/hexagon/translate.c   | 9 -
 4 files changed, 13 insertions(+), 17 deletions(-)

diff --git a/target/hexagon/imported/alu.idef b/target/hexagon/imported/alu.idef
index 12d2aac5d4..b855676989 100644
--- a/target/hexagon/imported/alu.idef
+++ b/target/hexagon/imported/alu.idef
@@ -1142,9 +1142,9 @@ 
Q6INSN(A4_cround_rr,"Rd32=cround(Rs32,Rt32)",ATTRIBS(),"Convergent Round", {RdV
 tmp128 = fSHIFTR128(tmp128, SHIFT);\
 DST =  fCAST16S_8S(tmp128);\
 } else {\
-size16s_t rndbit_128 =  fCAST8S_16S((1LL << (SHIFT - 1))); \
-size16s_t src_128 =  fCAST8S_16S(SRC); \
-size16s_t tmp128 = fADD128(src_128, rndbit_128);\
+rndbit_128 =  fCAST8S_16S((1LL << (SHIFT - 1))); \
+src_128 =  fCAST8S_16S(SRC); \
+tmp128 = fADD128(src_128, rndbit_128);\
 tmp128 = fSHIFTR128(tmp128, SHIFT);\
 DST =  fCAST16S_8S(tmp128);\
 }
diff --git a/target/hexagon/mmvec/macros.h b/target/hexagon/mmvec/macros.h
index a655634fd1..728a63d35f 100644
--- a/target/hexagon/mmvec/macros.h
+++ b/target/hexagon/mmvec/macros.h
@@ -201,14 +201,14 @@
 } while (0)
 #define SCATTER_OP_WRITE_TO_MEM(TYPE) \
 do { \
-uintptr_t ra = GETPC(); \
+uintptr_t ra_ = GETPC(); \
 for (int i = 0; i < sizeof(MMVector); i += sizeof(TYPE)) { \
 if (test_bit(i, env->vtcm_log.mask)) { \
 TYPE dst = 0; \
 TYPE inc = 0; \
 for (int j = 0; j < sizeof(TYPE); j++) { \
 uint8_t val; \
-val = cpu_ldub_data_ra(env, env->vtcm_log.va[i + j], ra); \
+val = cpu_ldub_data_ra(env, env->vtcm_log.va[i + j], ra_); 
\
 dst |= val << (8 * j); \
 inc |= env->vtcm_log.data.ub[j + i] << (8 * j); \
 clear_bit(j + i, env->vtcm_log.mask); \
@@ -217,7 +217,7 @@
 dst += inc; \
 for (int j = 0; j < sizeof(TYPE); j++) { \
 cpu_stb_data_ra(env, env->vtcm_log.va[i + j], \
-(dst >> (8 * j)) & 0xFF, ra); \
+(dst >> (8 * j)) & 0xFF, ra_); \
 } \
 } \
 } \
diff --git a/target/hexagon/op_helper.c b/target/hexagon/op_helper.c
index 8ca3976a65..da10ac5847 100644
--- a/target/hexagon/op_helper.c
+++ b/target/hexagon/op_helper.c
@@ -132,10 +132,9 @@ void HELPER(gather_store)(CPUHexagonState *env, uint32_t 
addr, int slot)
 void HELPER(commit_hvx_stores)(CPUHexagonState *env)
 {
 uintptr_t ra = GETPC();
-int i;
 
 /* Normal (possibly masked) vector store */
-for (i = 0; i < VSTORES_MAX; i++) {
+for (int i = 0; i < VSTORES_MAX; i++) {
 if (env->vstore_pending[i]) {
 env->vstore_pending[i] = 0;
 target_ulong va = env->vstore[i].va;
@@ -162,7 +161,7 @@ void HELPER(commit_hvx_stores)(CPUHexagonState *env)
 g_assert_not_reached();
 }
 } else {
-for (i = 0; i < sizeof(MMVector); i++) {
+for (int i = 0; i < sizeof(MMVector); i++) {
 if (test_bit(i, env->vtcm_log.mask)) {
 cpu_stb_data_ra(env, env->vtcm_log.va[i],