Skip to content

[RISCV] Move vendor extensions after standard extensions in RISCVDisassembler::getInstruction16. #130821

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

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?

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