Skip to content

Commit d701195

Browse files
committed
Update RISCVInstrInfoXqci.td and RISCVDisassembler.cpp
Change-Id: I4b8f1435ea575ab30ab3d7af5a7a37dd86b7766d
1 parent 85bac48 commit d701195

File tree

2 files changed

+20
-8
lines changed

2 files changed

+20
-8
lines changed

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

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -341,6 +341,19 @@ static DecodeStatus decodeUImmOperandGE(MCInst &Inst, uint32_t Imm,
341341
return MCDisassembler::Success;
342342
}
343343

344+
template <unsigned Width, unsigned LowerBound>
345+
static DecodeStatus decodeUImmPlus1OperandGE(MCInst &Inst, uint32_t Imm,
346+
int64_t Address,
347+
const MCDisassembler *Decoder) {
348+
assert(isUInt<Width>(Imm) && "Invalid immediate");
349+
350+
if (Imm < LowerBound)
351+
return MCDisassembler::Fail;
352+
353+
Inst.addOperand(MCOperand::createImm(Imm + 1));
354+
return MCDisassembler::Success;
355+
}
356+
344357
static DecodeStatus decodeUImmLog2XLenOperand(MCInst &Inst, uint32_t Imm,
345358
int64_t Address,
346359
const MCDisassembler *Decoder) {

llvm/lib/Target/RISCV/RISCVInstrInfoXqci.td

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ def uimm5ge6_plus1 : RISCVOp<XLenVT>, ImmLeaf<XLenVT,
4646
[{return (Imm >= 6) && (isUInt<5>(Imm) || (Imm == 32));}]> {
4747
let ParserMatchClass = UImmAsmOperand<5, "GE6Plus1">;
4848
let EncoderMethod = "getImmOpValueMinus1";
49-
let DecoderMethod = "decodeUImmPlus1Operand<5>";
49+
let DecoderMethod = "decodeUImmPlus1OperandGE<5,6>";
5050
let OperandType = "OPERAND_UIMM5_GE6_PLUS1";
5151
}
5252

@@ -105,10 +105,9 @@ class QCIStore_ScaleIdx<bits<4> funct4, string opcodestr>
105105
}
106106

107107
class QCIRVInstI<bits<4> funct4, string opcodestr>
108-
: RVInstI<0b011, OPC_CUSTOM_0, (outs GPRNoX0:$rd),
109-
(ins GPRNoX0:$rs1), opcodestr, "$rd, $rs1"> {
110-
let imm12 = {0b000, funct4, 0b00000};
111-
}
108+
: RVInstIUnary<{0b000, funct4, 0b00000}, 0b011, OPC_CUSTOM_0,
109+
(outs GPRNoX0:$rd), (ins GPRNoX0:$rs1), opcodestr,
110+
"$rd, $rs1">;
112111

113112
class QCIRVInstR<bits<4> funct4, string opcodestr>
114113
: RVInstR<{0b000, funct4}, 0b011, OPC_CUSTOM_0, (outs GPRNoX0:$rd),
@@ -123,7 +122,7 @@ class QCIRVInstRR<bits<5> funct5, DAGOperand InTyRs1, string opcodestr>
123122
class QCIBitManipRII<bits<3> funct3, bits<2> funct2,
124123
DAGOperand InTyRs1, string opcodestr>
125124
: RVInstIBase<funct3, OPC_CUSTOM_0, (outs GPRNoX0:$rd),
126-
(ins InTyRs1:$rs1, uimm5:$shamt, uimm5_plus1:$width),
125+
(ins InTyRs1:$rs1, uimm5_plus1:$width, uimm5:$shamt),
127126
opcodestr, "$rd, $rs1, $width, $shamt"> {
128127
bits<5> shamt;
129128
bits<6> width;
@@ -402,8 +401,8 @@ let Predicates = [HasVendorXqcibm, IsRV32] in {
402401
let hasSideEffects = 0, mayLoad = 0, mayStore = 0 in {
403402
def QC_INSBRI : QCIRVInstRI<0b1, simm11, "qc.insbri">;
404403
def QC_INSBI : RVInstIBase<0b001, OPC_CUSTOM_0, (outs GPRNoX0:$rd),
405-
(ins simm5:$imm5, uimm5:$shamt,
406-
uimm5_plus1:$width), "qc.insbi",
404+
(ins simm5:$imm5, uimm5_plus1:$width,
405+
uimm5:$shamt), "qc.insbi",
407406
"$rd, $imm5, $width, $shamt"> {
408407
bits<5> imm5;
409408
bits<5> shamt;

0 commit comments

Comments
 (0)