public inbox for gdb-cvs@sourceware.org help / color / mirror / Atom feed
From: Michael Frysinger <vapier@sourceware.org> To: gdb-cvs@sourceware.org Subject: [binutils-gdb] sim: erc32: fix -Wshadow=local warnings Date: Sat, 23 Dec 2023 04:31:20 +0000 (GMT) [thread overview] Message-ID: <20231223043120.3E38B3858C54@sourceware.org> (raw) https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;h=a4531a4010a95555cd41b7bd492f2e441f6c69fe commit a4531a4010a95555cd41b7bd492f2e441f6c69fe Author: Mike Frysinger <vapier@gentoo.org> Date: Thu Dec 21 20:09:00 2023 -0500 sim: erc32: fix -Wshadow=local warnings Rename shadowed vars with different types to avoid confusion. Diff: --- sim/erc32/exec.c | 63 ++++++++++++++++++++++++++++---------------------------- 1 file changed, 31 insertions(+), 32 deletions(-) diff --git a/sim/erc32/exec.c b/sim/erc32/exec.c index 10a9dae603c..c8186df02f1 100644 --- a/sim/erc32/exec.c +++ b/sim/erc32/exec.c @@ -707,7 +707,7 @@ dispatch_instruction(struct pstate *sregs) case DIVScc: { int sign; - uint32_t result, remainder; + uint32_t uresult, remainder; int c0, y31; if (!sparclite) { @@ -723,7 +723,7 @@ dispatch_instruction(struct pstate *sregs) Otherwise, calculate remainder + divisor. */ if (sign == 0) operand2 = ~operand2 + 1; - result = remainder + operand2; + uresult = remainder + operand2; /* The SPARClite User's Manual is not clear on how the "carry out" of the above ALU operation is to @@ -733,24 +733,23 @@ dispatch_instruction(struct pstate *sregs) even in cases where the divisor is subtracted from the remainder. FIXME: get the true story from Fujitsu. */ - c0 = result < (uint32_t) remainder - || result < (uint32_t) operand2; + c0 = uresult < remainder || uresult < (uint32_t) operand2; - if (result & 0x80000000) + if (uresult & 0x80000000) sregs->psr |= PSR_N; else sregs->psr &= ~PSR_N; y31 = (sregs->y & 0x80000000) == 0x80000000; - if (result == 0 && sign == y31) + if (uresult == 0 && sign == y31) sregs->psr |= PSR_Z; else sregs->psr &= ~PSR_Z; sign = (sign && !y31) || (!c0 && (sign || !y31)); - if (sign ^ (result >> 31)) + if (sign ^ (uresult >> 31)) sregs->psr |= PSR_V; else sregs->psr &= ~PSR_V; @@ -760,7 +759,7 @@ dispatch_instruction(struct pstate *sregs) else sregs->psr &= ~PSR_C; - sregs->y = result; + sregs->y = uresult; if (rd != 0) *rdd = (rs1 << 1) | !sign; @@ -773,21 +772,21 @@ dispatch_instruction(struct pstate *sregs) break; case SMULCC: { - uint32_t result; + uint32_t uresult; - mul64 (rs1, operand2, &sregs->y, &result, 1); + mul64 (rs1, operand2, &sregs->y, &uresult, 1); - if (result & 0x80000000) + if (uresult & 0x80000000) sregs->psr |= PSR_N; else sregs->psr &= ~PSR_N; - if (result == 0) + if (uresult == 0) sregs->psr |= PSR_Z; else sregs->psr &= ~PSR_Z; - *rdd = result; + *rdd = uresult; } break; case UMUL: @@ -797,21 +796,21 @@ dispatch_instruction(struct pstate *sregs) break; case UMULCC: { - uint32_t result; + uint32_t uresult; - mul64 (rs1, operand2, &sregs->y, &result, 0); + mul64 (rs1, operand2, &sregs->y, &uresult, 0); - if (result & 0x80000000) + if (uresult & 0x80000000) sregs->psr |= PSR_N; else sregs->psr &= ~PSR_N; - if (result == 0) + if (uresult == 0) sregs->psr |= PSR_Z; else sregs->psr &= ~PSR_Z; - *rdd = result; + *rdd = uresult; } break; case SDIV: @@ -831,7 +830,7 @@ dispatch_instruction(struct pstate *sregs) break; case SDIVCC: { - uint32_t result; + uint32_t uresult; if (sparclite) { sregs->trap = TRAP_UNIMP; @@ -843,14 +842,14 @@ dispatch_instruction(struct pstate *sregs) break; } - div64 (sregs->y, rs1, operand2, &result, 1); + div64 (sregs->y, rs1, operand2, &uresult, 1); - if (result & 0x80000000) + if (uresult & 0x80000000) sregs->psr |= PSR_N; else sregs->psr &= ~PSR_N; - if (result == 0) + if (uresult == 0) sregs->psr |= PSR_Z; else sregs->psr &= ~PSR_Z; @@ -858,7 +857,7 @@ dispatch_instruction(struct pstate *sregs) /* FIXME: should set overflow flag correctly. */ sregs->psr &= ~(PSR_C | PSR_V); - *rdd = result; + *rdd = uresult; } break; case UDIV: @@ -878,7 +877,7 @@ dispatch_instruction(struct pstate *sregs) break; case UDIVCC: { - uint32_t result; + uint32_t uresult; if (sparclite) { sregs->trap = TRAP_UNIMP; @@ -890,14 +889,14 @@ dispatch_instruction(struct pstate *sregs) break; } - div64 (sregs->y, rs1, operand2, &result, 0); + div64 (sregs->y, rs1, operand2, &uresult, 0); - if (result & 0x80000000) + if (uresult & 0x80000000) sregs->psr |= PSR_N; else sregs->psr &= ~PSR_N; - if (result == 0) + if (uresult == 0) sregs->psr |= PSR_Z; else sregs->psr &= ~PSR_Z; @@ -905,7 +904,7 @@ dispatch_instruction(struct pstate *sregs) /* FIXME: should set overflow flag correctly. */ sregs->psr &= ~(PSR_C | PSR_V); - *rdd = result; + *rdd = uresult; } break; case IXNOR: @@ -1168,7 +1167,7 @@ dispatch_instruction(struct pstate *sregs) case SCAN: { - uint32_t result, mask; + uint32_t uresult, mask; int i; if (!sparclite) { @@ -1176,12 +1175,12 @@ dispatch_instruction(struct pstate *sregs) break; } mask = (operand2 & 0x80000000) | (operand2 >> 1); - result = rs1 ^ mask; + uresult = rs1 ^ mask; for (i = 0; i < 32; i++) { - if (result & 0x80000000) + if (uresult & 0x80000000) break; - result <<= 1; + uresult <<= 1; } *rdd = i == 32 ? 63 : i;
reply other threads:[~2023-12-23 4:31 UTC|newest] Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
Reply instructions: You may reply publicly to this message via plain-text email using any one of the following methods: * Save the following mbox file, import it into your mail client, and reply-to-all from there: mbox Avoid top-posting and favor interleaved quoting: https://en.wikipedia.org/wiki/Posting_style#Interleaved_style * Reply using the --to, --cc, and --in-reply-to switches of git-send-email(1): git send-email \ --in-reply-to=20231223043120.3E38B3858C54@sourceware.org \ --to=vapier@sourceware.org \ --cc=gdb-cvs@sourceware.org \ /path/to/YOUR_REPLY https://kernel.org/pub/software/scm/git/docs/git-send-email.html * If your mail client supports setting the In-Reply-To header via mailto: links, try the mailto: linkBe sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox; as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).