[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PULL 39/55] disas/mips: Fix branch displacement for BEQZC and BNEZC
From: |
Philippe Mathieu-Daudé |
Subject: |
[PULL 39/55] disas/mips: Fix branch displacement for BEQZC and BNEZC |
Date: |
Sun, 30 Oct 2022 23:28:25 +0100 |
From: David Daney <david.daney@fungible.com>
disas/mips.c got added in commit 6643d27ea0 ("MIPS disas support")
apparently based on binutils tag 'gdb_6_1-branchpoint' [1].
Back then, MIPSr6 was not supported (added in binutils commit
7361da2c952 during 2014 [2]).
Binutils codebase diverged so much over the last 18 years, it is
not possible to simply cherry-pick their changes, so fix it BEQZC /
BNEZC 21-bit signed branch displacement locally.
[1]
https://sourceware.org/git/?p=binutils-gdb.git;a=blob;f=opcodes/mips-dis.c;hb=refs/tags/gdb_6_1-branchpoint
[2] https://sourceware.org/git/?p=binutils-gdb.git;a=commit;h=7361da2c952
Fixes: 31837be3ee ("target-mips: add compact and CP1 branches")
Signed-off-by: David Daney <david.daney@fungible.com>
Reviewed-by: Marcin Nowakowski <marcin.nowakowski@fungible.com>
[PMD: Added commit description]
Signed-off-by: Philippe Mathieu-Daudé <philmd@fungible.com>
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
Message-Id: <20221014112322.61119-1-philmd@fungible.com>
Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
---
disas/mips.c | 12 ++++++++++--
1 file changed, 10 insertions(+), 2 deletions(-)
diff --git a/disas/mips.c b/disas/mips.c
index b9a5204304..5aacacb2c8 100644
--- a/disas/mips.c
+++ b/disas/mips.c
@@ -20,6 +20,7 @@ You should have received a copy of the GNU General Public
License
along with this program; if not, see <http://www.gnu.org/licenses/>. */
#include "qemu/osdep.h"
+#include "qemu/bitops.h"
#include "disas/dis-asm.h"
/* mips.h. Mips opcode list for GDB, the GNU debugger.
@@ -1334,9 +1335,9 @@ const struct mips_opcode mips_builtin_opcodes[] =
{"balc", "+p", 0xe8000000, 0xfc000000, UBD|WR_31, 0,
I32R6},
{"bc", "+p", 0xc8000000, 0xfc000000, UBD|WR_31, 0,
I32R6},
{"jic", "t,o", 0xd8000000, 0xffe00000, UBD|RD_t, 0,
I32R6},
-{"beqzc", "s,+p", 0xd8000000, 0xfc000000, CBD|RD_s, 0,
I32R6},
+{"beqzc", "s,+q", 0xd8000000, 0xfc000000, CBD|RD_s, 0,
I32R6},
{"jialc", "t,o", 0xf8000000, 0xffe00000, UBD|RD_t, 0,
I32R6},
-{"bnezc", "s,+p", 0xf8000000, 0xfc000000, CBD|RD_s, 0,
I32R6},
+{"bnezc", "s,+q", 0xf8000000, 0xfc000000, CBD|RD_s, 0,
I32R6},
{"beqzalc", "s,t,p", 0x20000000, 0xffe00000, CBD|RD_s|RD_t, 0,
I32R6},
{"bovc", "s,t,p", 0x20000000, 0xfc000000, CBD|RD_s|RD_t, 0,
I32R6},
{"beqc", "s,t,p", 0x20000000, 0xfc000000, CBD|RD_s|RD_t, 0,
I32R6},
@@ -4462,6 +4463,13 @@ print_insn_args (const char *d,
(*info->print_address_func) (info->target, info);
break;
+ case 'q':
+ /* Sign extend the displacement with 21 bits. */
+ delta = sextract32(l, OP_SH_DELTA, 21);
+ info->target = (delta << 2) + pc + INSNLEN;
+ (*info->print_address_func) (info->target, info);
+ break;
+
case 't': /* Coprocessor 0 reg name */
(*info->fprintf_func) (info->stream, "%s",
mips_cp0_names[(l >> OP_SH_RT) &
--
2.37.3
- [PULL 30/55] disas/nanomips: Remove IMMEDIATE functions, (continued)
- [PULL 30/55] disas/nanomips: Remove IMMEDIATE functions, Philippe Mathieu-Daudé, 2022/10/30
- [PULL 29/55] disas/nanomips: Replace std::string type, Philippe Mathieu-Daudé, 2022/10/30
- [PULL 31/55] disas/nanomips: Remove CPR function, Philippe Mathieu-Daudé, 2022/10/30
- [PULL 32/55] disas/nanomips: Prevent memory leaking, Philippe Mathieu-Daudé, 2022/10/30
- [PULL 33/55] disas/nanomips: Remove function overloading, Philippe Mathieu-Daudé, 2022/10/30
- [PULL 34/55] disas/nanomips: Expand Dis_info struct, Philippe Mathieu-Daudé, 2022/10/30
- [PULL 35/55] disas/nanomips: Replace exception handling, Philippe Mathieu-Daudé, 2022/10/30
- [PULL 36/55] disas/nanomips: Replace Cpp enums for C enums, Philippe Mathieu-Daudé, 2022/10/30
- [PULL 37/55] disas/nanomips: Remove argument passing by ref, Philippe Mathieu-Daudé, 2022/10/30
- [PULL 38/55] disas/nanomips: Rename nanomips.cpp to nanomips.c, Philippe Mathieu-Daudé, 2022/10/30
- [PULL 39/55] disas/mips: Fix branch displacement for BEQZC and BNEZC,
Philippe Mathieu-Daudé <=
- [PULL 40/55] hw/i386/pc: Create DMA controllers in south bridges, Philippe Mathieu-Daudé, 2022/10/30
- [PULL 41/55] hw/isa/piix3: Remove extra ';' outside of functions, Philippe Mathieu-Daudé, 2022/10/30
- [PULL 42/55] hw/isa/piix3: Add size constraints to rcr_ops, Philippe Mathieu-Daudé, 2022/10/30
- [PULL 44/55] hw/isa/piix3: Prefer pci_address_space() over get_system_memory(), Philippe Mathieu-Daudé, 2022/10/30
- [PULL 45/55] hw/isa/piix4: Rename wrongly named method, Philippe Mathieu-Daudé, 2022/10/30
- [PULL 46/55] hw/ide/piix: Introduce TYPE_ macros for PIIX IDE controllers, Philippe Mathieu-Daudé, 2022/10/30
- [PULL 43/55] hw/isa/piix3: Modernize reset handling, Philippe Mathieu-Daudé, 2022/10/30
- [PULL 47/55] hw/isa/piix3: Remove unused include, Philippe Mathieu-Daudé, 2022/10/30
- [PULL 48/55] hw/mips/malta: Reuse dev variable, Philippe Mathieu-Daudé, 2022/10/30
- [PULL 49/55] hw/isa/Kconfig: Fix dependencies of piix4 southbridge, Philippe Mathieu-Daudé, 2022/10/30