Skip to content

Commit 3b086c3

Browse files
committed
change uimm5_zibi to imm5_zibi
1 parent c72b686 commit 3b086c3

File tree

4 files changed

+23
-23
lines changed

4 files changed

+23
-23
lines changed

llvm/lib/Target/RISCV/AsmParser/RISCVAsmParser.cpp

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -745,11 +745,6 @@ struct RISCVOperand final : public MCParsedAsmOperand {
745745
return isUImmPred([](int64_t Imm) { return Imm != 0 && isUInt<5>(Imm); });
746746
}
747747

748-
bool isUImm5Zibi() const {
749-
return isUImmPred(
750-
[](int64_t Imm) { return (Imm != 0 && isUInt<5>(Imm)) || Imm == -1; });
751-
}
752-
753748
bool isUImm5GT3() const {
754749
return isUImmPred([](int64_t Imm) { return isUInt<5>(Imm) && Imm > 3; });
755750
}
@@ -951,6 +946,11 @@ struct RISCVOperand final : public MCParsedAsmOperand {
951946
return isUImmPred([](int64_t Imm) { return 4 == Imm; });
952947
}
953948

949+
bool isImm5Zibi() const {
950+
return isUImmPred(
951+
[](int64_t Imm) { return (Imm != 0 && isUInt<5>(Imm)) || Imm == -1; });
952+
}
953+
954954
bool isSImm5Plus1() const {
955955
return isSImmPred(
956956
[](int64_t Imm) { return Imm != INT64_MIN && isInt<5>(Imm - 1); });
@@ -1493,10 +1493,6 @@ bool RISCVAsmParser::matchAndEmitInstruction(SMLoc IDLoc, unsigned &Opcode,
14931493
return generateImmOutOfRangeError(Operands, ErrorInfo, 0, (1 << 5) - 1);
14941494
case Match_InvalidUImm5NonZero:
14951495
return generateImmOutOfRangeError(Operands, ErrorInfo, 1, (1 << 5) - 1);
1496-
case Match_InvalidUImm5Zibi:
1497-
return generateImmOutOfRangeError(
1498-
Operands, ErrorInfo, -1, (1 << 5) - 1,
1499-
"immediate must be non-zero in the range");
15001496
case Match_InvalidUImm5GT3:
15011497
return generateImmOutOfRangeError(Operands, ErrorInfo, 4, (1 << 5) - 1);
15021498
case Match_InvalidUImm5Plus1:
@@ -1652,6 +1648,10 @@ bool RISCVAsmParser::matchAndEmitInstruction(SMLoc IDLoc, unsigned &Opcode,
16521648
"operand must be a valid system register "
16531649
"name or an integer in the range");
16541650
}
1651+
case Match_InvalidImm5Zibi:
1652+
return generateImmOutOfRangeError(
1653+
Operands, ErrorInfo, -1, (1 << 5) - 1,
1654+
"immediate must be non-zero in the range");
16551655
case Match_InvalidVTypeI: {
16561656
SMLoc ErrorLoc = ((RISCVOperand &)*Operands[ErrorInfo]).getStartLoc();
16571657
return generateVTypeError(ErrorLoc);

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

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -461,14 +461,6 @@ static DecodeStatus decodeUImmNonZeroOperand(MCInst &Inst, uint32_t Imm,
461461
return decodeUImmOperand<N>(Inst, Imm, Address, Decoder);
462462
}
463463

464-
static DecodeStatus decodeUImmZibiOperand(MCInst &Inst, uint32_t Imm,
465-
int64_t Address,
466-
const MCDisassembler *Decoder) {
467-
assert(isUInt<5>(Imm) && "Invalid immediate");
468-
Inst.addOperand(MCOperand::createImm(Imm ? Imm : -1LL));
469-
return MCDisassembler::Success;
470-
}
471-
472464
static DecodeStatus
473465
decodeUImmLog2XLenNonZeroOperand(MCInst &Inst, uint32_t Imm, int64_t Address,
474466
const MCDisassembler *Decoder) {
@@ -486,6 +478,14 @@ static DecodeStatus decodeUImmPlus1Operand(MCInst &Inst, uint32_t Imm,
486478
return MCDisassembler::Success;
487479
}
488480

481+
static DecodeStatus decodeImmZibiOperand(MCInst &Inst, uint32_t Imm,
482+
int64_t Address,
483+
const MCDisassembler *Decoder) {
484+
assert(isUInt<5>(Imm) && "Invalid immediate");
485+
Inst.addOperand(MCOperand::createImm(Imm ? Imm : -1LL));
486+
return MCDisassembler::Success;
487+
}
488+
489489
template <unsigned N>
490490
static DecodeStatus decodeSImmOperand(MCInst &Inst, uint32_t Imm,
491491
int64_t Address,

llvm/lib/Target/RISCV/MCTargetDesc/RISCVBaseInfo.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -310,7 +310,6 @@ enum OperandType : unsigned {
310310
OPERAND_UIMM4,
311311
OPERAND_UIMM5,
312312
OPERAND_UIMM5_NONZERO,
313-
OPERAND_UIMM5_ZIBI,
314313
OPERAND_UIMM5_GT3,
315314
OPERAND_UIMM5_PLUS1,
316315
OPERAND_UIMM5_GE6_PLUS1,
@@ -342,6 +341,7 @@ enum OperandType : unsigned {
342341
OPERAND_UIMM64,
343342
OPERAND_THREE,
344343
OPERAND_FOUR,
344+
OPERAND_IMM5_ZIBI,
345345
OPERAND_SIMM5,
346346
OPERAND_SIMM5_NONZERO,
347347
OPERAND_SIMM5_PLUS1,

llvm/lib/Target/RISCV/RISCVInstrInfoZibi.td

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -11,24 +11,24 @@
1111
//===----------------------------------------------------------------------===//
1212

1313
// A 5-bit unsigned immediate representing 1-31 and -1. 00000 represents -1.
14-
def uimm5_zibi : RISCVOp<XLenVT>, ImmLeaf<XLenVT, [{
14+
def imm5_zibi : RISCVOp<XLenVT>, ImmLeaf<XLenVT, [{
1515
return (Imm != 0 && isUInt<5>(Imm)) || Imm == -1;
1616
}]> {
17-
let ParserMatchClass = UImmAsmOperand<5, "Zibi">;
17+
let ParserMatchClass = ImmAsmOperand<"", 5, "Zibi">;
1818
let EncoderMethod = "getImmOpValueZibi";
19-
let DecoderMethod = "decodeUImmZibiOperand";
19+
let DecoderMethod = "decodeImmZibiOperand";
2020
let MCOperandPredicate = [{
2121
int64_t Imm;
2222
if (!MCOp.evaluateAsConstantImm(Imm))
2323
return false;
2424
return (Imm >= 1 && Imm <= 31) || Imm == -1;
2525
}];
26-
let OperandType = "OPERAND_UIMM5_ZIBI";
26+
let OperandType = "OPERAND_IMM5_ZIBI";
2727
}
2828

2929
class Branch_imm<bits<3> funct3, string opcodestr>
3030
: RVInstBIMM<funct3, OPC_BRANCH, (outs),
31-
(ins GPR:$rs1, uimm5_zibi:$cimm, bare_simm13_lsb0:$imm12),
31+
(ins GPR:$rs1, imm5_zibi:$cimm, bare_simm13_lsb0:$imm12),
3232
opcodestr, "$rs1, $cimm, $imm12">,
3333
Sched<[WriteJmp, ReadJmp]> {
3434
let isBranch = 1;

0 commit comments

Comments
 (0)