@@ -28,10 +28,34 @@ def uimm5gt3 : RISCVOp<XLenVT>, ImmLeaf<XLenVT,
2828 let OperandType = "OPERAND_UIMM5_GT3";
2929}
3030
31+ def UImm5Plus1AsmOperand : AsmOperandClass {
32+ let Name = "UImm5Plus1";
33+ let RenderMethod = "addImmOperands";
34+ let DiagnosticType = "InvalidUImm5Plus1";
35+ }
36+
37+ def uimm5_plus1 : RISCVOp, ImmLeaf<XLenVT,
38+ [{return (isUInt<5>(Imm) && (Imm != 0)) || (Imm == 32);}]> {
39+ let ParserMatchClass = UImm5Plus1AsmOperand;
40+ let EncoderMethod = "getImmOpValueMinus1";
41+ let DecoderMethod = "decodeUImmPlus1Operand<5>";
42+ let OperandType = "OPERAND_UIMM5_PLUS1";
43+ }
44+
45+ def uimm5ge6_plus1 : RISCVOp<XLenVT>, ImmLeaf<XLenVT,
46+ [{return (Imm >= 6) && (isUInt<5>(Imm) || (Imm == 32));}]> {
47+ let ParserMatchClass = UImmAsmOperand<5, "GE6Plus1">;
48+ let EncoderMethod = "getImmOpValueMinus1";
49+ let DecoderMethod = "decodeUImmPlus1OperandGE<5,6>";
50+ let OperandType = "OPERAND_UIMM5_GE6_PLUS1";
51+ }
52+
3153def uimm10 : RISCVUImmLeafOp<10>;
3254
3355def uimm11 : RISCVUImmLeafOp<11>;
3456
57+ def simm11 : RISCVSImmLeafOp<11>;
58+
3559def simm26 : RISCVSImmLeafOp<26>;
3660
3761// 32-bit Immediate, used by RV32 Instructions in 32-bit operations, so no
@@ -80,6 +104,11 @@ class QCIStore_ScaleIdx<bits<4> funct4, string opcodestr>
80104}
81105}
82106
107+ class QCIRVInstI<bits<4> funct4, string opcodestr>
108+ : RVInstIUnary<{0b000, funct4, 0b00000}, 0b011, OPC_CUSTOM_0,
109+ (outs GPRNoX0:$rd), (ins GPRNoX0:$rs1), opcodestr,
110+ "$rd, $rs1">;
111+
83112class QCIRVInstR<bits<4> funct4, string opcodestr>
84113 : RVInstR<{0b000, funct4}, 0b011, OPC_CUSTOM_0, (outs GPRNoX0:$rd),
85114 (ins GPRNoX0:$rs1), opcodestr, "$rd, $rs1"> {
@@ -90,6 +119,30 @@ class QCIRVInstRR<bits<5> funct5, DAGOperand InTyRs1, string opcodestr>
90119 : RVInstR<{0b00, funct5}, 0b011, OPC_CUSTOM_0, (outs GPRNoX0:$rd),
91120 (ins InTyRs1:$rs1, GPRNoX0:$rs2), opcodestr, "$rd, $rs1, $rs2">;
92121
122+ class QCIBitManipRII<bits<3> funct3, bits<2> funct2,
123+ DAGOperand InTyRs1, string opcodestr>
124+ : RVInstIBase<funct3, OPC_CUSTOM_0, (outs GPRNoX0:$rd),
125+ (ins InTyRs1:$rs1, uimm5_plus1:$width, uimm5:$shamt),
126+ opcodestr, "$rd, $rs1, $width, $shamt"> {
127+ bits<5> shamt;
128+ bits<5> width;
129+
130+ let Inst{31-30} = funct2;
131+ let Inst{29-25} = width;
132+ let Inst{24-20} = shamt;
133+ }
134+
135+ class QCIRVInstRI<bits<1> funct1, DAGOperand InTyImm11,
136+ string opcodestr>
137+ : RVInstIBase<0b000, OPC_CUSTOM_0, (outs GPRNoX0:$rd),
138+ (ins GPRNoX0:$rs1, InTyImm11:$imm11), opcodestr,
139+ "$rd, $rs1, $imm11"> {
140+ bits<11> imm11;
141+
142+ let Inst{31-31} = funct1;
143+ let Inst{30-20} = imm11;
144+ }
145+
93146let hasSideEffects = 0, mayLoad = 0, mayStore = 0 in
94147class QCISELECTIICC<bits<3> funct3, string opcodestr>
95148 : RVInstR4<0b00, funct3, OPC_CUSTOM_2, (outs GPRNoX0:$rd_wb),
@@ -185,6 +238,17 @@ class QCIMVCCI<bits<3> funct3, string opcodestr, DAGOperand immType>
185238 let rs2 = imm;
186239}
187240
241+ class QCI_RVInst16CB_BM<bits<2> funct2, string opcodestr>
242+ : RVInst16CB<0b100, 0b01, (outs GPRC:$rd),
243+ (ins GPRC:$rs1, uimmlog2xlennonzero:$shamt),
244+ opcodestr, "$rs1, $shamt"> {
245+ bits<5> shamt;
246+ let Constraints = "$rs1 = $rd";
247+ let Inst{12} = 0b1;
248+ let Inst{11-10} = funct2;
249+ let Inst{6-2} = shamt{4-0};
250+ }
251+
188252let hasSideEffects = 1, mayLoad = 0, mayStore = 0 in
189253class QCIRVInst16CI_RS1<bits<5> funct5, string OpcodeStr>
190254 : RVInst16CI<0b000, 0b10, (outs), (ins GPRNoX0:$rs1), OpcodeStr, "$rs1"> {
@@ -333,6 +397,59 @@ let hasSideEffects = 0, mayLoad = 0, mayStore = 0 in {
333397} // hasSideEffects = 0, mayLoad = 0, mayStore = 0
334398} // Predicates = [HasVendorXqcia, IsRV32]
335399
400+ let Predicates = [HasVendorXqcibm, IsRV32] in {
401+ let hasSideEffects = 0, mayLoad = 0, mayStore = 0 in {
402+ def QC_INSBRI : QCIRVInstRI<0b1, simm11, "qc.insbri">;
403+ def QC_INSBI : RVInstIBase<0b001, OPC_CUSTOM_0, (outs GPRNoX0:$rd),
404+ (ins simm5:$imm5, uimm5_plus1:$width,
405+ uimm5:$shamt), "qc.insbi",
406+ "$rd, $imm5, $width, $shamt"> {
407+ bits<5> imm5;
408+ bits<5> shamt;
409+ bits<5> width;
410+ let rs1 = imm5;
411+ let Inst{31-30} = 0b00;
412+ let Inst{29-25} = width;
413+ let Inst{24-20} = shamt;
414+ }
415+ def QC_INSB : QCIBitManipRII<0b001, 0b01, GPR, "qc.insb">;
416+ def QC_INSBH : QCIBitManipRII<0b001, 0b10, GPR, "qc.insbh">;
417+ def QC_INSBR : QCIRVInstRR<0b00000, GPR, "qc.insbr">;
418+ def QC_INSBHR : QCIRVInstRR<0b00001, GPR, "qc.insbhr">;
419+ def QC_INSBPR : QCIRVInstRR<0b00010, GPR, "qc.insbpr">;
420+ def QC_INSBPRH : QCIRVInstRR<0b00011, GPR, "qc.insbprh">;
421+ def QC_EXTU : QCIBitManipRII<0b010, 0b00, GPRNoX0, "qc.extu">;
422+ def QC_EXTDU : QCIBitManipRII<0b010, 0b10, GPR, "qc.extdu">;
423+ def QC_EXTDUR : QCIRVInstRR<0b00100, GPR, "qc.extdur">;
424+ def QC_EXTDUPR : QCIRVInstRR<0b00110, GPR, "qc.extdupr">;
425+ def QC_EXTDUPRH : QCIRVInstRR<0b00111, GPR, "qc.extduprh">;
426+ def QC_EXT : QCIBitManipRII<0b010, 0b01, GPRNoX0, "qc.ext">;
427+ def QC_EXTD : QCIBitManipRII<0b010, 0b11, GPR, "qc.extd">;
428+ def QC_EXTDR : QCIRVInstRR<0b00101, GPR, "qc.extdr">;
429+ def QC_EXTDPR : QCIRVInstRR<0b01000, GPR, "qc.extdpr">;
430+ def QC_EXTDPRH : QCIRVInstRR<0b01001, GPR, "qc.extdprh">;
431+ def QC_COMPRESS2 : QCIRVInstI<0b0000, "qc.compress2">;
432+ def QC_COMPRESS3 : QCIRVInstI<0b0001, "qc.compress3">;
433+ def QC_EXPAND2 : QCIRVInstI<0b0010, "qc.expand2">;
434+ def QC_EXPAND3 : QCIRVInstI<0b0011, "qc.expand3">;
435+ def QC_CLO : QCIRVInstI<0b0100, "qc.clo">;
436+ def QC_CTO : QCIRVInstI<0b0101, "qc.cto">;
437+ def QC_BREV32 : QCIRVInstI<0b0110, "qc.brev32">;
438+ def QC_C_BEXTI : QCI_RVInst16CB_BM<0b00, "qc.c.bexti">;
439+ def QC_C_BSETI : QCI_RVInst16CB_BM<0b01, "qc.c.bseti">;
440+ def QC_C_EXTU : RVInst16CI<0b000, 0b10, (outs GPRNoX0:$rd_wb),
441+ (ins GPRNoX0:$rd, uimm5ge6_plus1:$width),
442+ "qc.c.extu", "$rd, $width"> {
443+ bits<5> rd;
444+ bits<5> width;
445+ let Constraints = "$rd = $rd_wb";
446+ let Inst{6-2} = width;
447+ let Inst{11-7} = rd;
448+ let Inst{12} = 0b1;
449+ }
450+ } // hasSideEffects = 0, mayLoad = 0, mayStore = 0
451+ } // Predicates = [HasVendorXqcibm, IsRV32]
452+
336453let Predicates = [HasVendorXqciac, IsRV32] in {
337454let hasSideEffects = 0, mayLoad = 0, mayStore = 0 in {
338455 def QC_C_MULIADD : RVInst16CL<0b001, 0b10, (outs GPRC:$rd_wb),
0 commit comments