Skip to content

Commit aa16f8a

Browse files
committed
[RISCV] Remove post-decoding instruction adjustments
1 parent 0068373 commit aa16f8a

File tree

5 files changed

+17
-22
lines changed

5 files changed

+17
-22
lines changed

llvm/lib/Target/RISCV/CMakeLists.txt

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,7 @@ tablegen(LLVM RISCVGenCompressInstEmitter.inc -gen-compress-inst-emitter)
88
tablegen(LLVM RISCVGenMacroFusion.inc -gen-macro-fusion-pred)
99
tablegen(LLVM RISCVGenDAGISel.inc -gen-dag-isel)
1010
tablegen(LLVM RISCVGenDisassemblerTables.inc -gen-disassembler
11-
--specialize-decoders-per-bitwidth
12-
-ignore-non-decodable-operands)
11+
--specialize-decoders-per-bitwidth)
1312
tablegen(LLVM RISCVGenInstrInfo.inc -gen-instr-info)
1413
tablegen(LLVM RISCVGenMCCodeEmitter.inc -gen-emitter)
1514
tablegen(LLVM RISCVGenMCPseudoLowering.inc -gen-pseudo-lowering)

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

Lines changed: 6 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -46,8 +46,6 @@ class RISCVDisassembler : public MCDisassembler {
4646
raw_ostream &CStream) const override;
4747

4848
private:
49-
void addSPOperands(MCInst &MI) const;
50-
5149
DecodeStatus getInstruction48(MCInst &Instr, uint64_t &Size,
5250
ArrayRef<uint8_t> Bytes, uint64_t Address,
5351
raw_ostream &CStream) const;
@@ -196,6 +194,10 @@ static DecodeStatus DecodeFPR128RegisterClass(MCInst &Inst, uint32_t RegNo,
196194
return MCDisassembler::Success;
197195
}
198196

197+
static void DecodeSPRegisterClass(MCInst &Inst, const MCDisassembler *Decoder) {
198+
Inst.addOperand(MCOperand::createReg(RISCV::X2));
199+
}
200+
199201
static DecodeStatus DecodeGPRNoX0RegisterClass(MCInst &Inst, uint32_t RegNo,
200202
uint64_t Address,
201203
const MCDisassembler *Decoder) {
@@ -600,15 +602,6 @@ static DecodeStatus decodeXTHeadMemPair(MCInst &Inst, uint32_t Insn,
600602

601603
#include "RISCVGenDisassemblerTables.inc"
602604

603-
// Add implied SP operand for C.*SP compressed instructions. The SP operand
604-
// isn't explicitly encoded in the instruction.
605-
void RISCVDisassembler::addSPOperands(MCInst &MI) const {
606-
const MCInstrDesc &MCID = MCII->get(MI.getOpcode());
607-
for (unsigned i = 0; i < MCID.getNumOperands(); i++)
608-
if (MCID.operands()[i].RegClass == RISCV::SPRegClassID)
609-
MI.insert(MI.begin() + i, MCOperand::createReg(RISCV::X2));
610-
}
611-
612605
namespace {
613606

614607
struct DecoderListEntry {
@@ -772,12 +765,8 @@ DecodeStatus RISCVDisassembler::getInstruction16(MCInst &MI, uint64_t &Size,
772765
LLVM_DEBUG(dbgs() << "Trying " << Entry.Desc << " table:\n");
773766
DecodeStatus Result =
774767
decodeInstruction(Entry.Table, MI, Insn, Address, this, STI);
775-
if (Result == MCDisassembler::Fail)
776-
continue;
777-
778-
addSPOperands(MI);
779-
780-
return Result;
768+
if (Result != MCDisassembler::Fail)
769+
return Result;
781770
}
782771

783772
return MCDisassembler::Fail;

llvm/lib/Target/RISCV/RISCVInstrFormatsC.td

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,6 @@ class RVInst16CSS<bits<3> funct3, bits<2> opcode, dag outs, dag ins,
5454
: RVInst16<outs, ins, opcodestr, argstr, [], InstFormatCSS> {
5555
bits<10> imm;
5656
bits<5> rs2;
57-
bits<5> rs1;
5857

5958
let Inst{15-13} = funct3;
6059
let Inst{12-7} = imm{5-0};

llvm/lib/Target/RISCV/RISCVInstrInfoC.td

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -230,13 +230,17 @@ let hasSideEffects = 0, mayLoad = 1, mayStore = 0 in
230230
class CStackLoad<bits<3> funct3, string OpcodeStr,
231231
DAGOperand cls, DAGOperand opnd>
232232
: RVInst16CI<funct3, 0b10, (outs cls:$rd), (ins SPMem:$rs1, opnd:$imm),
233-
OpcodeStr, "$rd, ${imm}(${rs1})">;
233+
OpcodeStr, "$rd, ${imm}(${rs1})"> {
234+
bits<0> rs1;
235+
}
234236

235237
let hasSideEffects = 0, mayLoad = 0, mayStore = 1 in
236238
class CStackStore<bits<3> funct3, string OpcodeStr,
237239
DAGOperand cls, DAGOperand opnd>
238240
: RVInst16CSS<funct3, 0b10, (outs), (ins cls:$rs2, SPMem:$rs1, opnd:$imm),
239-
OpcodeStr, "$rs2, ${imm}(${rs1})">;
241+
OpcodeStr, "$rs2, ${imm}(${rs1})"> {
242+
bits<0> rs1;
243+
}
240244

241245
let hasSideEffects = 0, mayLoad = 1, mayStore = 0 in
242246
class CLoad_ri<bits<3> funct3, string OpcodeStr,

llvm/lib/Target/RISCV/RISCVInstrInfoXwch.td

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -106,6 +106,7 @@ def QK_C_LBUSP : QKStackInst<0b00, (outs GPRC:$rd_rs2),
106106
(ins SPMem:$rs1, uimm4:$imm),
107107
"qk.c.lbusp", "$rd_rs2, ${imm}(${rs1})">,
108108
Sched<[WriteLDB, ReadMemBase]> {
109+
bits<0> rs1;
109110
bits<4> imm;
110111
let Inst{10-7} = imm;
111112
}
@@ -115,6 +116,7 @@ def QK_C_SBSP : QKStackInst<0b10, (outs),
115116
uimm4:$imm),
116117
"qk.c.sbsp", "$rd_rs2, ${imm}(${rs1})">,
117118
Sched<[WriteSTB, ReadStoreData, ReadMemBase]> {
119+
bits<0> rs1;
118120
bits<4> imm;
119121
let Inst{10-7} = imm;
120122
}
@@ -124,6 +126,7 @@ def QK_C_LHUSP : QKStackInst<0b01, (outs GPRC:$rd_rs2),
124126
(ins SPMem:$rs1, uimm5_lsb0:$imm),
125127
"qk.c.lhusp", "$rd_rs2, ${imm}(${rs1})">,
126128
Sched<[WriteLDH, ReadMemBase]> {
129+
bits<0> rs1;
127130
bits<5> imm;
128131
let Inst{10-8} = imm{3-1};
129132
let Inst{7} = imm{4};
@@ -133,6 +136,7 @@ def QK_C_SHSP : QKStackInst<0b11, (outs),
133136
(ins GPRC:$rd_rs2, SPMem:$rs1, uimm5_lsb0:$imm),
134137
"qk.c.shsp", "$rd_rs2, ${imm}(${rs1})">,
135138
Sched<[WriteSTH, ReadStoreData, ReadMemBase]> {
139+
bits<0> rs1;
136140
bits<5> imm;
137141
let Inst{10-8} = imm{3-1};
138142
let Inst{7} = imm{4};

0 commit comments

Comments
 (0)