13 changes: 3 additions & 10 deletions llvm/lib/Target/RISCV/RISCVInstrInfoV.td
Original file line number Diff line number Diff line change
Expand Up @@ -24,12 +24,11 @@ class VTypeIAsmOperand<int VTypeINum> : AsmOperandClass {
let RenderMethod = "addVTypeIOperands";
}

class VTypeIOp<int VTypeINum> : Operand<XLenVT> {
class VTypeIOp<int VTypeINum> : RISCVOp {
let ParserMatchClass = VTypeIAsmOperand<VTypeINum>;
let PrintMethod = "printVTypeI";
let DecoderMethod = "decodeUImmOperand<"#VTypeINum#">";
let OperandType = "OPERAND_VTYPEI" # VTypeINum;
let OperandNamespace = "RISCVOp";
let MCOperandPredicate = [{
int64_t Imm;
if (MCOp.evaluateAsConstantImm(Imm))
Expand Down Expand Up @@ -58,12 +57,7 @@ def VMaskOp : RegisterOperand<VMV0> {
let DecoderMethod = "decodeVMaskReg";
}

def simm5 : Operand<XLenVT>, ImmLeaf<XLenVT, [{return isInt<5>(Imm);}]> {
let ParserMatchClass = SImmAsmOperand<5>;
let EncoderMethod = "getImmOpValue";
let DecoderMethod = "decodeSImmOperand<5>";
let OperandType = "OPERAND_SIMM5";
let OperandNamespace = "RISCVOp";
def simm5 : RISCVSImmLeafOp<5> {
let MCOperandPredicate = [{
int64_t Imm;
if (MCOp.evaluateAsConstantImm(Imm))
Expand All @@ -78,11 +72,10 @@ def SImm5Plus1AsmOperand : AsmOperandClass {
let DiagnosticType = "InvalidSImm5Plus1";
}

def simm5_plus1 : Operand<XLenVT>, ImmLeaf<XLenVT,
def simm5_plus1 : RISCVOp, ImmLeaf<XLenVT,
[{return (isInt<5>(Imm) && Imm != -16) || Imm == 16;}]> {
let ParserMatchClass = SImm5Plus1AsmOperand;
let OperandType = "OPERAND_SIMM5_PLUS1";
let OperandNamespace = "RISCVOp";
let MCOperandPredicate = [{
int64_t Imm;
if (MCOp.evaluateAsConstantImm(Imm))
Expand Down
25 changes: 7 additions & 18 deletions llvm/lib/Target/RISCV/RISCVInstrInfoXSf.td
Original file line number Diff line number Diff line change
Expand Up @@ -29,26 +29,15 @@ def VCIX_XVW : VCIXType<0b1111>;

// The payload and tsimm5 operands are all marked as ImmArg in the IR
// intrinsic and will be target constant, so use TImmLeaf rather than ImmLeaf.
def payload1 : Operand<XLenVT>, TImmLeaf<XLenVT, [{return isUInt<1>(Imm);}]> {
let ParserMatchClass = UImmAsmOperand<1>;
let DecoderMethod = "decodeUImmOperand<1>";
let OperandType = "OPERAND_UIMM1";
let OperandNamespace = "RISCVOp";
class PayloadOp<int bitsNum> : RISCVOp, TImmLeaf<XLenVT, "return isUInt<" # bitsNum # ">(Imm);"> {
let ParserMatchClass = UImmAsmOperand<bitsNum>;
let DecoderMethod = "decodeUImmOperand<"# bitsNum # ">";
let OperandType = "OPERAND_UIMM" # bitsNum;
}

def payload2 : Operand<XLenVT>, TImmLeaf<XLenVT, [{return isUInt<2>(Imm);}]> {
let ParserMatchClass = UImmAsmOperand<2>;
let DecoderMethod = "decodeUImmOperand<2>";
let OperandType = "OPERAND_UIMM2";
let OperandNamespace = "RISCVOp";
}

def payload5 : Operand<XLenVT>, TImmLeaf<XLenVT, [{return isUInt<5>(Imm);}]> {
let ParserMatchClass = UImmAsmOperand<5>;
let DecoderMethod = "decodeUImmOperand<5>";
let OperandType = "OPERAND_UIMM5";
let OperandNamespace = "RISCVOp";
}
def payload1 : PayloadOp<1>;
def payload2 : PayloadOp<2>;
def payload5 : PayloadOp<5>;

def tsimm5 : Operand<XLenVT>, TImmLeaf<XLenVT, [{return isInt<5>(Imm);}]> {
let ParserMatchClass = SImmAsmOperand<5>;
Expand Down
3 changes: 1 addition & 2 deletions llvm/lib/Target/RISCV/RISCVInstrInfoZb.td
Original file line number Diff line number Diff line change
Expand Up @@ -48,15 +48,14 @@ def UImmLog2XLenHalfAsmOperand : AsmOperandClass {
let DiagnosticType = "InvalidUImmLog2XLenHalf";
}

def shfl_uimm : Operand<XLenVT>, ImmLeaf<XLenVT, [{
def shfl_uimm : RISCVOp, ImmLeaf<XLenVT, [{
if (Subtarget->is64Bit())
return isUInt<5>(Imm);
return isUInt<4>(Imm);
}]> {
let ParserMatchClass = UImmLog2XLenHalfAsmOperand;
let DecoderMethod = "decodeUImmOperand<5>";
let OperandType = "OPERAND_UIMM_SHFL";
let OperandNamespace = "RISCVOp";
let MCOperandPredicate = [{
int64_t Imm;
if (!MCOp.evaluateAsConstantImm(Imm))
Expand Down
6 changes: 2 additions & 4 deletions llvm/lib/Target/RISCV/RISCVInstrInfoZc.td
Original file line number Diff line number Diff line change
Expand Up @@ -17,13 +17,12 @@
// Operand and SDNode transformation definitions.
//===----------------------------------------------------------------------===//

def uimm2_lsb0 : Operand<XLenVT>,
def uimm2_lsb0 : RISCVOp,
ImmLeaf<XLenVT, [{return isShiftedUInt<1, 1>(Imm);}]> {
let ParserMatchClass = UImmAsmOperand<2, "Lsb0">;
let EncoderMethod = "getImmOpValue";
let DecoderMethod = "decodeUImmOperand<2>";
let OperandType = "OPERAND_UIMM2_LSB0";
let OperandNamespace = "RISCVOp";
let MCOperandPredicate = [{
int64_t Imm;
if (!MCOp.evaluateAsConstantImm(Imm))
Expand All @@ -32,11 +31,10 @@ def uimm2_lsb0 : Operand<XLenVT>,
}];
}

def uimm8ge32 : Operand<XLenVT> {
def uimm8ge32 : RISCVOp {
let ParserMatchClass = UImmAsmOperand<8, "GE32">;
let DecoderMethod = "decodeUImmOperand<8>";
let OperandType = "OPERAND_UIMM8_GE32";
let OperandNamespace = "RISCVOp";
}

def RlistAsmOperand : AsmOperandClass {
Expand Down
3 changes: 1 addition & 2 deletions llvm/lib/Target/RISCV/RISCVInstrInfoZicbo.td
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
//===----------------------------------------------------------------------===//

// A 12-bit signed immediate where the least significant five bits are zero.
def simm12_lsb00000 : Operand<XLenVT>,
def simm12_lsb00000 : RISCVOp,
ImmLeaf<XLenVT, [{return isShiftedInt<7, 5>(Imm);}]> {
let ParserMatchClass = SImmAsmOperand<12, "Lsb00000">;
let EncoderMethod = "getImmOpValue";
Expand All @@ -28,7 +28,6 @@ def simm12_lsb00000 : Operand<XLenVT>,
return MCOp.isBareSymbolRef();
}];
let OperandType = "OPERAND_SIMM12_LSB00000";
let OperandNamespace = "RISCVOp";
}

//===----------------------------------------------------------------------===//
Expand Down
6 changes: 2 additions & 4 deletions llvm/lib/Target/RISCV/RISCVInstrInfoZk.td
Original file line number Diff line number Diff line change
Expand Up @@ -36,19 +36,17 @@ def RnumArg : AsmOperandClass {
let DiagnosticType = "InvalidRnumArg";
}

def rnum : Operand<i32>, TImmLeaf<i32, [{return (Imm >= 0 && Imm <= 10);}]> {
def rnum : RISCVOp<i32>, TImmLeaf<i32, [{return (Imm >= 0 && Imm <= 10);}]> {
let ParserMatchClass = RnumArg;
let EncoderMethod = "getImmOpValue";
let DecoderMethod = "decodeUImmOperand<4>";
let OperandType = "OPERAND_RVKRNUM";
let OperandNamespace = "RISCVOp";
}

def byteselect : Operand<i32>, TImmLeaf<i32, [{return isUInt<2>(Imm);}]> {
def byteselect : RISCVOp<i32>, TImmLeaf<i32, [{return isUInt<2>(Imm);}]> {
let ParserMatchClass = UImmAsmOperand<2>;
let DecoderMethod = "decodeUImmOperand<2>";
let OperandType = "OPERAND_UIMM2";
let OperandNamespace = "RISCVOp";
}

//===----------------------------------------------------------------------===//
Expand Down