Skip to content

Commit 6b0a9e4

Browse files
author
Yeting Kuo
committed
Fix decoder conflict.
1 parent 76d827e commit 6b0a9e4

File tree

4 files changed

+13
-15
lines changed

4 files changed

+13
-15
lines changed

llvm/lib/Target/RISCV/Disassembler/RISCVDisassembler.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -623,6 +623,8 @@ DecodeStatus RISCVDisassembler::getInstruction(MCInst &MI, uint64_t &Size,
623623
TRY_TO_DECODE_AND_ADD_SP(!STI.hasFeature(RISCV::Feature64Bit),
624624
DecoderTableRISCV32Only_16,
625625
"RISCV32Only_16 table (16-bit Instruction)");
626+
TRY_TO_DECODE_FEATURE(RISCV::FeatureStdExtZicfiss, DecoderTableZicfiss16,
627+
"RVZicfiss table (Shadow Stack)");
626628
TRY_TO_DECODE_FEATURE(RISCV::FeatureStdExtZcmt, DecoderTableRVZcmt16,
627629
"Zcmt table (16-bit Table Jump Instructions)");
628630
TRY_TO_DECODE_FEATURE(

llvm/lib/Target/RISCV/RISCVFeatures.td

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -707,6 +707,7 @@ def FeatureStdExtZicfiss
707707
def HasStdExtZicfiss : Predicate<"Subtarget->hasStdExtZicfiss()">,
708708
AssemblerPredicate<(all_of FeatureStdExtZicfiss),
709709
"'Zicfiss' (Shadow stack)">;
710+
def NoHasStdExtZicfiss : Predicate<"!Subtarget->hasStdExtZicfiss()">;
710711

711712
def FeatureStdExtSmaia
712713
: SubtargetFeature<"smaia", "HasStdExtSmaia", "true",

llvm/lib/Target/RISCV/RISCVInstrInfoZcmop.td

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -22,9 +22,13 @@ class CMOPInst<bits<3> imm3, string opcodestr>
2222
let Inst{12-11} = 0;
2323
}
2424

25-
foreach i = 0...7 in {
26-
let Predicates = [HasStdExtZcmop] in {
27-
defvar n = !add(!mul(i, 2), 1);
28-
def CMOP # n : CMOPInst<i, "cmop." # n>, Sched<[]>;
29-
} // Predicates = [HasStdExtZcmop]
25+
// CMOP1, CMOP5 is used by Zicfiss.
26+
let Predicates = [HasStdExtZcmop, NoHasStdExtZicfiss] in {
27+
def CMOP1 : CMOPInst<0, "cmop.1">, Sched<[]>;
28+
def CMOP5 : CMOPInst<2, "cmop.5">, Sched<[]>;
29+
}
30+
31+
foreach n = [3, 7, 9, 11, 13, 15] in {
32+
let Predicates = [HasStdExtZcmop] in
33+
def CMOP # n : CMOPInst<!srl(n, 1), "cmop." # n>, Sched<[]>;
3034
}

llvm/lib/Target/RISCV/RISCVInstrInfoZicfiss.td

Lines changed: 1 addition & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ def SSPUSH : RVInstR<0b1100111, 0b100, OPC_SYSTEM, (outs), (ins GPRX1X5:$rs2),
4747
}
4848
} // Predicates = [HasStdExtZicfiss]
4949

50-
let Predicates = [HasStdExtZicfiss, HasStdExtCOrZca] in {
50+
let Predicates = [HasStdExtZicfiss], DecoderNamespace = "Zicfiss" in {
5151
let Uses = [SSP], Defs = [SSP], hasSideEffects = 0, mayLoad = 0, mayStore = 1 in
5252
def C_SSPUSH : RVC_SSInst<0b00001, GPRX1, "c.sspush">;
5353

@@ -60,12 +60,3 @@ defm SSAMOSWAP_W : AMO_rr_aq_rl<0b01001, 0b010, "ssamoswap.w">;
6060

6161
let Predicates = [HasStdExtZicfiss, IsRV64] in
6262
defm SSAMOSWAP_D : AMO_rr_aq_rl<0b01001, 0b011, "ssamoswap.d">;
63-
64-
//===----------------------------------------------------------------------===/
65-
// Compress Instruction tablegen backend.
66-
//===----------------------------------------------------------------------===//
67-
68-
let Predicates = [HasStdExtZicfiss, HasStdExtCOrZca] in {
69-
def : CompressPat<(SSPUSH X1), (C_SSPUSH X1)>;
70-
def : CompressPat<(SSPOPCHK X5), (C_SSPOPCHK X5)>;
71-
} // Predicates = [HasStdExtZicfiss, HasStdExtCOrZca]

0 commit comments

Comments
 (0)