diff options
author | Craig Topper <craig.topper@sifive.com> | 2025-02-27 14:56:54 -0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2025-02-27 14:56:54 -0800 |
commit | f3b18491e840c23dfe25e399ddf6475425481835 (patch) | |
tree | 70d362aaf6c9156e75a0588bd08de008a8830156 /llvm/lib/Target/RISCV/Disassembler/RISCVDisassembler.cpp | |
parent | 44c6616a4a9f5c8e8e68364609f018c62670d114 (diff) | |
download | llvm-f3b18491e840c23dfe25e399ddf6475425481835.zip llvm-f3b18491e840c23dfe25e399ddf6475425481835.tar.gz llvm-f3b18491e840c23dfe25e399ddf6475425481835.tar.bz2 |
[RISCV] Consolidate some DecoderNamespaces for standard extensions. (#128954)
First thing to know is that the subtarget feature checks used to block
accessing a decoder table are only a performance optimization and not
required for functionality. The tables have their own predicate checks.
I've removed them from all the standard extension tables.
-RV32 Zacas decoder namespace has been renamed to RV32GPRPair, I think
Zilsd(rv32 load/store pair) can go in here too.
-The RV32 Zdinx table has been renamed to also use RV32GPRPair.
-The Zfinx table has been renamed to remove superflous "RV" prefix.
-Zcmp and Zcmt tables have been combined into a ZcOverlap table. I think
Zclsd(rv32 compressed load/store pair) can go in here too.
-All the extra standard extension tables are checked after the main
standard extension table. This makes the common case of the main table
matching occur earlier.
-Zicfiss is the exception to this as it needs to be checked before
the main table since it overrides some encodings from Zcmop. This
can't be handled by a predicate based priority as Zicfiss only overrides
a subset of Zcmop encodings.
Diffstat (limited to 'llvm/lib/Target/RISCV/Disassembler/RISCVDisassembler.cpp')
-rw-r--r-- | llvm/lib/Target/RISCV/Disassembler/RISCVDisassembler.cpp | 32 |
1 files changed, 13 insertions, 19 deletions
diff --git a/llvm/lib/Target/RISCV/Disassembler/RISCVDisassembler.cpp b/llvm/lib/Target/RISCV/Disassembler/RISCVDisassembler.cpp index e99df34..61deaa8 100644 --- a/llvm/lib/Target/RISCV/Disassembler/RISCVDisassembler.cpp +++ b/llvm/lib/Target/RISCV/Disassembler/RISCVDisassembler.cpp @@ -657,16 +657,6 @@ DecodeStatus RISCVDisassembler::getInstruction32(MCInst &MI, uint64_t &Size, uint32_t Insn = support::endian::read32le(Bytes.data()); - TRY_TO_DECODE(STI.hasFeature(RISCV::FeatureStdExtZdinx) && - !STI.hasFeature(RISCV::Feature64Bit), - DecoderTableRV32Zdinx32, - "RV32Zdinx (Double in Integer and rv32)"); - TRY_TO_DECODE(STI.hasFeature(RISCV::FeatureStdExtZacas) && - !STI.hasFeature(RISCV::Feature64Bit), - DecoderTableRV32Zacas32, - "RV32Zacas (Compare-And-Swap and rv32)"); - TRY_TO_DECODE_FEATURE(RISCV::FeatureStdExtZfinx, DecoderTableRVZfinx32, - "RVZfinx (Float in Integer)"); TRY_TO_DECODE_FEATURE(RISCV::FeatureVendorXVentanaCondOps, DecoderTableXVentana32, "XVentanaCondOps"); TRY_TO_DECODE_FEATURE(RISCV::FeatureVendorXTHeadBa, DecoderTableXTHeadBa32, @@ -721,6 +711,11 @@ DecodeStatus RISCVDisassembler::getInstruction32(MCInst &MI, uint64_t &Size, TRY_TO_DECODE_FEATURE_ANY(XRivosFeatureGroup, DecoderTableXRivos32, "Rivos"); TRY_TO_DECODE(true, DecoderTable32, "RISCV32"); + TRY_TO_DECODE(true, DecoderTableRV32GPRPair32, + "RV32GPRPair (rv32 and GPR pairs)"); + TRY_TO_DECODE(true, DecoderTableZfinx32, "Zfinx (Float in Integer)"); + TRY_TO_DECODE(true, DecoderTableZdinxRV32GPRPair32, + "ZdinxRV32GPRPair (rv32 and Double in Integer)"); return MCDisassembler::Fail; } @@ -736,15 +731,6 @@ DecodeStatus RISCVDisassembler::getInstruction16(MCInst &MI, uint64_t &Size, Size = 2; uint32_t Insn = support::endian::read16le(Bytes.data()); - TRY_TO_DECODE_AND_ADD_SP(!STI.hasFeature(RISCV::Feature64Bit), - DecoderTableRISCV32Only_16, - "RISCV32Only_16 (16-bit Instruction)"); - TRY_TO_DECODE_FEATURE(RISCV::FeatureStdExtZicfiss, DecoderTableZicfiss16, - "RVZicfiss (Shadow Stack)"); - TRY_TO_DECODE_FEATURE(RISCV::FeatureStdExtZcmt, DecoderTableRVZcmt16, - "Zcmt (16-bit Table Jump Instructions)"); - TRY_TO_DECODE_FEATURE(RISCV::FeatureStdExtZcmp, DecoderTableRVZcmp16, - "Zcmp (16-bit Push/Pop & Double Move Instructions)"); TRY_TO_DECODE_FEATURE_ANY(XqciFeatureGroup, DecoderTableXqci16, "Qualcomm uC 16bit"); @@ -753,8 +739,16 @@ DecodeStatus RISCVDisassembler::getInstruction16(MCInst &MI, uint64_t &Size, "Xqccmp (Qualcomm 16-bit Push/Pop & Double Move Instructions)"); TRY_TO_DECODE_AND_ADD_SP(STI.hasFeature(RISCV::FeatureVendorXwchc), DecoderTableXwchc16, "WCH QingKe XW"); + + // DecoderTableZicfiss16 must be checked before DecoderTable16. + TRY_TO_DECODE(true, DecoderTableZicfiss16, "RVZicfiss (Shadow Stack)"); TRY_TO_DECODE_AND_ADD_SP(true, DecoderTable16, "RISCV_C (16-bit Instruction)"); + TRY_TO_DECODE_AND_ADD_SP(true, DecoderTableRISCV32Only_16, + "RISCV32Only_16 (16-bit Instruction)"); + // Zc* instructions incompatible with Zcf or Zcd. + TRY_TO_DECODE(true, DecoderTableZcOverlap16, + "ZcOverlap (16-bit Instructions overlapping with Zcf/Zcd)"); return MCDisassembler::Fail; } |