[llvm] [RISCV][NFC] Add base classes of Operand and uimm/simm (PR #68472)
Zi Xuan Wu via llvm-commits
llvm-commits at lists.llvm.org
Tue Oct 10 22:52:42 PDT 2023
================
@@ -186,97 +208,40 @@ def uimmlog2xlen : Operand<XLenVT>, ImmLeaf<XLenVT, [{
return isUInt<5>(Imm);
}];
let OperandType = "OPERAND_UIMMLOG2XLEN";
- let OperandNamespace = "RISCVOp";
}
-def uimm1 : Operand<XLenVT>, ImmLeaf<XLenVT, [{return isUInt<1>(Imm);}]> {
- let ParserMatchClass = UImmAsmOperand<1>;
- let DecoderMethod = "decodeUImmOperand<1>";
- let OperandType = "OPERAND_UIMM1";
- let OperandNamespace = "RISCVOp";
+def InsnDirectiveOpcode : AsmOperandClass {
+ let Name = "InsnDirectiveOpcode";
+ let ParserMethod = "parseInsnDirectiveOpcode";
+ let RenderMethod = "addImmOperands";
+ let PredicateMethod = "isImm";
}
-def uimm2 : Operand<XLenVT>, ImmLeaf<XLenVT, [{return isUInt<2>(Imm);}]> {
- let ParserMatchClass = UImmAsmOperand<2>;
- let DecoderMethod = "decodeUImmOperand<2>";
- let OperandType = "OPERAND_UIMM2";
- let OperandNamespace = "RISCVOp";
+def uimm1 : RISCVUImmLeafOp<1>;
+def uimm2 : RISCVUImmLeafOp<2> {
let MCOperandPredicate = [{
int64_t Imm;
if (!MCOp.evaluateAsConstantImm(Imm))
return false;
return isUInt<2>(Imm);
}];
}
-
-def uimm3 : Operand<XLenVT> {
- let ParserMatchClass = UImmAsmOperand<3>;
- let DecoderMethod = "decodeUImmOperand<3>";
- let OperandType = "OPERAND_UIMM3";
- let OperandNamespace = "RISCVOp";
-}
-
-def uimm4 : Operand<XLenVT> {
- let ParserMatchClass = UImmAsmOperand<4>;
- let DecoderMethod = "decodeUImmOperand<4>";
- let OperandType = "OPERAND_UIMM4";
- let OperandNamespace = "RISCVOp";
-}
-
-def uimm5 : Operand<XLenVT>, ImmLeaf<XLenVT, [{return isUInt<5>(Imm);}]> {
- let ParserMatchClass = UImmAsmOperand<5>;
- let DecoderMethod = "decodeUImmOperand<5>";
- let OperandType = "OPERAND_UIMM5";
- let OperandNamespace = "RISCVOp";
-}
-
-def InsnDirectiveOpcode : AsmOperandClass {
- let Name = "InsnDirectiveOpcode";
- let ParserMethod = "parseInsnDirectiveOpcode";
- let RenderMethod = "addImmOperands";
- let PredicateMethod = "isImm";
-}
-
-def uimm6 : Operand<XLenVT>, ImmLeaf<XLenVT, [{return isUInt<6>(Imm);}]> {
- let ParserMatchClass = UImmAsmOperand<6>;
- let DecoderMethod = "decodeUImmOperand<6>";
- let OperandType = "OPERAND_UIMM6";
- let OperandNamespace = "RISCVOp";
-}
-
-def uimm7_opcode : Operand<XLenVT> {
+def uimm3 : RISCVUImmOp<3>;
----------------
zixuan-wu wrote:
why not make all these uimm node as RISCVUImmLeafOp because these nodes may be used in downstream patterns? I think there is no harm than RISCVUImmOp
https://github.com/llvm/llvm-project/pull/68472
More information about the llvm-commits
mailing list