Skip to content

Conversation

@topperc
Copy link
Collaborator

@topperc topperc commented Mar 11, 2025

All of the vendor extensions should be mutex with the standard extensions based on the incompatible extension checks in RISCVISAInfo.cpp. There is one missing check that will be fixed by #130816.

I'll make a similar patch for the 32-bit table, but I need to do more auditing first.

…ssembler::getInstruction16.

All of the vendor extensions should be mutex with the standard
extensions based on the incompatible extension checks in
RISCVISAInfo.cpp. There is one missing check that will be fixed by

I'll make a similar patch for the 32-bit table, but I need to do
more auditing first.
@llvmbot
Copy link
Member

llvmbot commented Mar 11, 2025

@llvm/pr-subscribers-backend-risc-v

Author: Craig Topper (topperc)

Changes

All of the vendor extensions should be mutex with the standard extensions based on the incompatible extension checks in RISCVISAInfo.cpp. There is one missing check that will be fixed by #130816.

I'll make a similar patch for the 32-bit table, but I need to do more auditing first.


Full diff: https://github.com/llvm/llvm-project/pull/130821.diff

1 Files Affected:

  • (modified) llvm/lib/Target/RISCV/Disassembler/RISCVDisassembler.cpp (+10-8)
diff --git a/llvm/lib/Target/RISCV/Disassembler/RISCVDisassembler.cpp b/llvm/lib/Target/RISCV/Disassembler/RISCVDisassembler.cpp
index de742ac428de2..857cca31b62cd 100644
--- a/llvm/lib/Target/RISCV/Disassembler/RISCVDisassembler.cpp
+++ b/llvm/lib/Target/RISCV/Disassembler/RISCVDisassembler.cpp
@@ -736,14 +736,7 @@ DecodeStatus RISCVDisassembler::getInstruction16(MCInst &MI, uint64_t &Size,
 
   uint32_t Insn = support::endian::read16le(Bytes.data());
 
-  TRY_TO_DECODE_FEATURE_ANY(XqciFeatureGroup, DecoderTableXqci16,
-                            "Qualcomm uC 16bit");
-  TRY_TO_DECODE_FEATURE(
-      RISCV::FeatureVendorXqccmp, DecoderTableXqccmp16,
-      "Xqccmp (Qualcomm 16-bit Push/Pop & Double Move Instructions)");
-  TRY_TO_DECODE_AND_ADD_SP(STI.hasFeature(RISCV::FeatureVendorXwchc),
-                           DecoderTableXwchc16, "WCH QingKe XW");
-
+  // Standard Extensions
   // DecoderTableZicfiss16 must be checked before DecoderTable16.
   TRY_TO_DECODE(true, DecoderTableZicfiss16, "RVZicfiss (Shadow Stack)");
   TRY_TO_DECODE_AND_ADD_SP(true, DecoderTable16,
@@ -754,6 +747,15 @@ DecodeStatus RISCVDisassembler::getInstruction16(MCInst &MI, uint64_t &Size,
   TRY_TO_DECODE(true, DecoderTableZcOverlap16,
                 "ZcOverlap (16-bit Instructions overlapping with Zcf/Zcd)");
 
+  // Vendor Extensions
+  TRY_TO_DECODE_FEATURE_ANY(XqciFeatureGroup, DecoderTableXqci16,
+                            "Qualcomm uC 16bit");
+  TRY_TO_DECODE_FEATURE(
+      RISCV::FeatureVendorXqccmp, DecoderTableXqccmp16,
+      "Xqccmp (Qualcomm 16-bit Push/Pop & Double Move Instructions)");
+  TRY_TO_DECODE_AND_ADD_SP(STI.hasFeature(RISCV::FeatureVendorXwchc),
+                           DecoderTableXwchc16, "WCH QingKe XW");
+
   return MCDisassembler::Fail;
 }
 

@lenary
Copy link
Member

lenary commented Mar 11, 2025

@svs-quic has a PR that will conflict with this (behaviour-wise) - #128833 - the encoding for qc.c.ptrace is non-standard - we're working on refactoring these to aliases but were intending to do it as a follow-up.

I still think this is the right direction, if it can wait a little bit longer?

@lenary
Copy link
Member

lenary commented Jul 3, 2025

This will need a rebase, and I think the XqciFeatureGroup has to go before the standard extensions now so we decode the hints correctly.

Xqccmp overlaps with Zcmp, but I think everything in Zcmp has a guard (unlike hints), so Xqccmp doesn't need to go before the standard extensions.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants