Skip to content

Commit 16f6dd3

Browse files
authored
Merge branch 'main' into fix-format-unused-args-invalid-spec
2 parents 0fafb04 + 983c8b6 commit 16f6dd3

File tree

3 files changed

+29
-43
lines changed

3 files changed

+29
-43
lines changed

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

Lines changed: 24 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -194,12 +194,24 @@ static DecodeStatus DecodeFPR128RegisterClass(MCInst &Inst, uint32_t RegNo,
194194
return MCDisassembler::Success;
195195
}
196196

197+
static DecodeStatus DecodeGPRX1RegisterClass(MCInst &Inst,
198+
const MCDisassembler *Decoder) {
199+
Inst.addOperand(MCOperand::createReg(RISCV::X1));
200+
return MCDisassembler::Success;
201+
}
202+
197203
static DecodeStatus DecodeSPRegisterClass(MCInst &Inst,
198204
const MCDisassembler *Decoder) {
199205
Inst.addOperand(MCOperand::createReg(RISCV::X2));
200206
return MCDisassembler::Success;
201207
}
202208

209+
static DecodeStatus DecodeGPRX5RegisterClass(MCInst &Inst,
210+
const MCDisassembler *Decoder) {
211+
Inst.addOperand(MCOperand::createReg(RISCV::X5));
212+
return MCDisassembler::Success;
213+
}
214+
203215
static DecodeStatus DecodeGPRNoX0RegisterClass(MCInst &Inst, uint32_t RegNo,
204216
uint64_t Address,
205217
const MCDisassembler *Decoder) {
@@ -408,6 +420,18 @@ static DecodeStatus decodeVMaskReg(MCInst &Inst, uint32_t RegNo,
408420
return MCDisassembler::Success;
409421
}
410422

423+
static DecodeStatus decodeImmThreeOperand(MCInst &Inst,
424+
const MCDisassembler *Decoder) {
425+
Inst.addOperand(MCOperand::createImm(3));
426+
return MCDisassembler::Success;
427+
}
428+
429+
static DecodeStatus decodeImmFourOperand(MCInst &Inst,
430+
const MCDisassembler *Decoder) {
431+
Inst.addOperand(MCOperand::createImm(4));
432+
return MCDisassembler::Success;
433+
}
434+
411435
template <unsigned N>
412436
static DecodeStatus decodeUImmOperand(MCInst &Inst, uint32_t Imm,
413437
int64_t Address,
@@ -579,46 +603,6 @@ static DecodeStatus decodeXqccmpRlistS0(MCInst &Inst, uint32_t Imm,
579603
return decodeZcmpRlist(Inst, Imm, Address, Decoder);
580604
}
581605

582-
static DecodeStatus decodeCSSPushPopchk(MCInst &Inst, uint16_t Insn,
583-
uint64_t Address,
584-
const MCDisassembler *Decoder) {
585-
uint32_t Rs1 = fieldFromInstruction(Insn, 7, 5);
586-
[[maybe_unused]] DecodeStatus Result =
587-
DecodeGPRX1X5RegisterClass(Inst, Rs1, Address, Decoder);
588-
assert(Result == MCDisassembler::Success && "Invalid register");
589-
return MCDisassembler::Success;
590-
}
591-
592-
static DecodeStatus decodeXTHeadMemPair(MCInst &Inst, uint32_t Insn,
593-
uint64_t Address,
594-
const MCDisassembler *Decoder) {
595-
DecodeStatus S = MCDisassembler::Success;
596-
uint32_t Rd1 = fieldFromInstruction(Insn, 7, 5);
597-
uint32_t Rs1 = fieldFromInstruction(Insn, 15, 5);
598-
uint32_t Rd2 = fieldFromInstruction(Insn, 20, 5);
599-
uint32_t UImm2 = fieldFromInstruction(Insn, 25, 2);
600-
if (!Check(S, DecodeGPRRegisterClass(Inst, Rd1, Address, Decoder)))
601-
return MCDisassembler::Fail;
602-
if (!Check(S, DecodeGPRRegisterClass(Inst, Rd2, Address, Decoder)))
603-
return MCDisassembler::Fail;
604-
if (!Check(S, DecodeGPRRegisterClass(Inst, Rs1, Address, Decoder)))
605-
return MCDisassembler::Fail;
606-
[[maybe_unused]] DecodeStatus Result =
607-
decodeUImmOperand<2>(Inst, UImm2, Address, Decoder);
608-
assert(Result == MCDisassembler::Success && "Invalid immediate");
609-
610-
// Disassemble the final operand which is implicit.
611-
unsigned Opcode = Inst.getOpcode();
612-
bool IsWordOp = (Opcode == RISCV::TH_LWD || Opcode == RISCV::TH_LWUD ||
613-
Opcode == RISCV::TH_SWD);
614-
if (IsWordOp)
615-
Inst.addOperand(MCOperand::createImm(3));
616-
else
617-
Inst.addOperand(MCOperand::createImm(4));
618-
619-
return S;
620-
}
621-
622606
#include "RISCVGenDisassemblerTables.inc"
623607

624608
namespace {

llvm/lib/Target/RISCV/RISCVInstrInfoXTHead.td

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@ def ImmThreeAsmOperand : AsmOperandClass {
4444
def immthree : RISCVOp {
4545
let ParserMatchClass = ImmThreeAsmOperand;
4646
let OperandType = "OPERAND_THREE";
47+
let DecoderMethod = "decodeImmThreeOperand";
4748
}
4849

4950
def ImmFourAsmOperand : AsmOperandClass {
@@ -56,6 +57,7 @@ def ImmFourAsmOperand : AsmOperandClass {
5657
def immfour : RISCVOp {
5758
let ParserMatchClass = ImmFourAsmOperand;
5859
let OperandType = "OPERAND_FOUR";
60+
let DecoderMethod = "decodeImmFourOperand";
5961
}
6062

6163
//===----------------------------------------------------------------------===//
@@ -161,9 +163,9 @@ class THLoadPair<bits<5> funct5, string opcodestr, Operand consttype>
161163
(ins GPR:$rs1, uimm2:$uimm2, consttype:$const3or4),
162164
opcodestr, "$rd, $rs2, (${rs1}), $uimm2, $const3or4"> {
163165
bits<2> uimm2;
166+
bits<0> const3or4;
164167
let Inst{31-27} = funct5;
165168
let Inst{26-25} = uimm2;
166-
let DecoderMethod = "decodeXTHeadMemPair";
167169
let Constraints = "@earlyclobber $rd,@earlyclobber $rs2";
168170
}
169171

@@ -173,9 +175,9 @@ class THStorePair<bits<5> funct5, string opcodestr, Operand consttype>
173175
(ins GPR:$rd, GPR:$rs2, GPR:$rs1, uimm2:$uimm2, consttype:$const3or4),
174176
opcodestr, "$rd, $rs2, (${rs1}), $uimm2, $const3or4"> {
175177
bits<2> uimm2;
178+
bits<0> const3or4;
176179
let Inst{31-27} = funct5;
177180
let Inst{26-25} = uimm2;
178-
let DecoderMethod = "decodeXTHeadMemPair";
179181
}
180182

181183
let hasSideEffects = 1, mayLoad = 0, mayStore = 0 in

llvm/lib/Target/RISCV/RISCVInstrInfoZicfiss.td

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,12 +12,12 @@
1212

1313
class RVC_SSInst<bits<5> rs1val, RegisterClass reg_class, string opcodestr> :
1414
RVInst16<(outs), (ins reg_class:$rs1), opcodestr, "$rs1", [], InstFormatOther> {
15+
bits<0> rs1;
1516
let Inst{15-13} = 0b011;
1617
let Inst{12} = 0;
1718
let Inst{11-7} = rs1val;
1819
let Inst{6-2} = 0b00000;
1920
let Inst{1-0} = 0b01;
20-
let DecoderMethod = "decodeCSSPushPopchk";
2121
}
2222

2323
//===----------------------------------------------------------------------===//

0 commit comments

Comments
 (0)