[binutils-gdb] RISC-V: Fix missing instruction classes in error messages

Nelson Chu nelsonc1225@sourceware.org
Thu Nov 6 00:56:27 GMT 2025


https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;h=7c4cf28243297b55976db28230bb2f02e6335fc4

commit 7c4cf28243297b55976db28230bb2f02e6335fc4
Author: Jerry Zhang Jian <jerry.zhangjian@sifive.com>
Date:   Wed Nov 5 10:18:20 2025 +0800

    RISC-V: Fix missing instruction classes in error messages
    
    Add 6 missing instruction class cases to riscv_multi_subset_supports_ext()
    to provide proper extension names in error messages instead of producing
    "internal: unreachable INSN_CLASS_*" errors.
    
    These instruction classes exist in riscv_multi_subset_supports() but were
    missing from riscv_multi_subset_supports_ext(), causing the assembler to
    produce internal errors when instructions are used without the required
    -march specification.
    
    Missing classes added:
    - INSN_CLASS_ZABHA_AND_ZACAS (zabha and zacas)
    - INSN_CLASS_XVENTANACONDOPS (xventanacondops)
    - INSN_CLASS_XSFVCP (xsfvcp)
    - INSN_CLASS_XSFVQMACCQOQ (xsfvqmaccqoq)
    - INSN_CLASS_XSFVQMACCDOD (xsfvqmaccdod)
    - INSN_CLASS_XSFVFNRCLIPXFQF (xsfvfnrclipxfqf)
    
    Before this fix:
      Error: internal: unreachable INSN_CLASS_*
      Error: unrecognized opcode `amocas.b a0,a1,(a2)'
    
    After this fix:
      Error: unrecognized opcode `amocas.b a0,a1,(a2)', extension `zabha' and `zacas' required
    
    bfd/
        * elfxx-riscv.c (riscv_multi_subset_supports_ext): Add 6
        missing instruction class cases.
    
    Signed-off-by: Jerry Zhang Jian <jerry.zhangjian@sifive.com>

Diff:
---
 bfd/elfxx-riscv.c | 19 +++++++++++++++++++
 1 file changed, 19 insertions(+)

diff --git a/bfd/elfxx-riscv.c b/bfd/elfxx-riscv.c
index 085d77923a0..3b92fbed5f0 100644
--- a/bfd/elfxx-riscv.c
+++ b/bfd/elfxx-riscv.c
@@ -3128,6 +3128,15 @@ riscv_multi_subset_supports_ext (riscv_parse_subset_t *rps,
       return "zabha";
     case INSN_CLASS_ZACAS:
       return "zacas";
+    case INSN_CLASS_ZABHA_AND_ZACAS:
+      if (!riscv_subset_supports (rps, "zabha"))
+	{
+	  if (!riscv_subset_supports (rps, "zacas"))
+	    return _ ("zabha' and `zacas");
+	  else
+	    return "zabha";
+	}
+      return "zacas";
     case INSN_CLASS_ZALRSC:
       return "zalrsc";
     case INSN_CLASS_ZAWRS:
@@ -3341,8 +3350,18 @@ riscv_multi_subset_supports_ext (riscv_parse_subset_t *rps,
       return "xtheadvdot";
     case INSN_CLASS_XTHEADZVAMO:
       return "xtheadzvamo";
+    case INSN_CLASS_XVENTANACONDOPS:
+      return "xventanacondops";
+    case INSN_CLASS_XSFVCP:
+      return "xsfvcp";
     case INSN_CLASS_XSFCEASE:
       return "xsfcease";
+    case INSN_CLASS_XSFVQMACCQOQ:
+      return "xsfvqmaccqoq";
+    case INSN_CLASS_XSFVQMACCDOD:
+      return "xsfvqmaccdod";
+    case INSN_CLASS_XSFVFNRCLIPXFQF:
+      return "xsfvfnrclipxfqf";
     default:
       rps->error_handler
         (_("internal: unreachable INSN_CLASS_*"));


More information about the Binutils-cvs mailing list