@@ -198,7 +198,7 @@ let DecoderNamespace = "XCValu" in {
198
198
199
199
} // DecoderNamespace = "XCValu"
200
200
201
- let Predicates = [HasVendorXCValu],
201
+ let Predicates = [HasVendorXCValu, IsRV32 ],
202
202
hasSideEffects = 0, mayLoad = 0, mayStore = 0 in {
203
203
// General ALU Operations
204
204
def CV_ABS : CVInstAluR<0b0101000, 0b011, "cv.abs">,
@@ -249,10 +249,10 @@ let Predicates = [HasVendorXCValu],
249
249
Sched<[]>;
250
250
def CV_SUBURN : CVInstAluRRI<0b11, 0b011, "cv.suburn">,
251
251
Sched<[]>;
252
- } // Predicates = [HasVendorXCValu],
252
+ } // Predicates = [HasVendorXCValu, IsRV32 ],
253
253
// hasSideEffects = 0, mayLoad = 0, mayStore = 0
254
254
255
- let Predicates = [HasVendorXCValu],
255
+ let Predicates = [HasVendorXCValu, IsRV32 ],
256
256
hasSideEffects = 0, mayLoad = 0, mayStore = 0,
257
257
Constraints = "$rd = $rd_wb" in {
258
258
def CV_ADDNR : CVInstAluRRNR<0b1000000, 0b011, "cv.addnr">,
@@ -272,7 +272,7 @@ let Predicates = [HasVendorXCValu],
272
272
def CV_SUBURNR : CVInstAluRRNR<0b1000111, 0b011, "cv.suburnr">,
273
273
Sched<[]>;
274
274
275
- } // Predicates = [HasVendorXCValu],
275
+ } // Predicates = [HasVendorXCValu, IsRV32 ],
276
276
// hasSideEffects = 0, mayLoad = 0, mayStore = 0,
277
277
// Constraints = "$rd = $rd_wb"
278
278
@@ -512,13 +512,11 @@ def CVrrAsmOperand : AsmOperandClass {
512
512
let DiagnosticType = "InvalidRegReg";
513
513
}
514
514
515
- def CVrr : Operand<i32>,
516
- ComplexPattern<i32, 2, "SelectAddrRegReg",[]> {
515
+ def CVrr : Operand<OtherVT> {
517
516
let ParserMatchClass = CVrrAsmOperand;
518
517
let EncoderMethod = "getRegReg";
519
518
let DecoderMethod = "decodeRegReg";
520
519
let PrintMethod = "printRegReg";
521
- let MIOperandInfo = (ops GPR:$base, GPR:$offset);
522
520
}
523
521
524
522
class CVLoad_ri_inc<bits<3> funct3, string opcodestr>
@@ -705,6 +703,8 @@ let Predicates = [HasVendorXCVmem, IsRV32], AddedComplexity = 1 in {
705
703
def cv_tuimm2 : TImmLeaf<XLenVT, [{return isUInt<2>(Imm);}]>;
706
704
def cv_tuimm5 : TImmLeaf<XLenVT, [{return isUInt<5>(Imm);}]>;
707
705
def cv_uimm10 : ImmLeaf<XLenVT, [{return isUInt<10>(Imm);}]>;
706
+ def cv_uimm_pow2: Operand<XLenVT>,
707
+ ImmLeaf<XLenVT, [{return isPowerOf2_32(Imm + 1);}]>;
708
708
709
709
def CV_LO5: SDNodeXForm<imm, [{
710
710
return CurDAG->getTargetConstant(N->getZExtValue() & 0x1f, SDLoc(N),
@@ -716,6 +716,15 @@ def CV_HI5: SDNodeXForm<imm, [{
716
716
N->getValueType(0));
717
717
}]>;
718
718
719
+ def powerOf2 : ImmLeaf<XLenVT, [{ return isPowerOf2_32(Imm); }]>;
720
+ def powerOf2Minus1 : ImmLeaf<XLenVT, [{ return isPowerOf2_32(Imm+1); }]>;
721
+ def negativePowerOf2 : ImmLeaf<XLenVT, [{ return isPowerOf2_32(-Imm); }]>;
722
+ def trailing1sPlus1 : SDNodeXForm<imm, [{
723
+ return CurDAG->getTargetConstant(
724
+ llvm::countr_one(N->getZExtValue()) + 1,
725
+ SDLoc(N), N->getValueType(0));
726
+ }]>;
727
+
719
728
multiclass PatCoreVBitManip<Intrinsic intr> {
720
729
def : PatGprGpr<intr, !cast<RVInst>("CV_" # NAME # "R")>;
721
730
def : Pat<(intr GPR:$rs1, cv_uimm10:$imm),
@@ -748,8 +757,54 @@ let Predicates = [HasVendorXCVbitmanip, IsRV32] in {
748
757
def : Pat<(bitreverse (XLenVT GPR:$rs)), (CV_BITREV GPR:$rs, 0, 0)>;
749
758
}
750
759
760
+ class PatCoreVAluGpr<string intr, string asm> :
761
+ PatGpr<!cast<Intrinsic>("int_riscv_cv_alu_" # intr),
762
+ !cast<RVInst>("CV_" # asm)>;
763
+ class PatCoreVAluGprGpr <string intr, string asm> :
764
+ PatGprGpr<!cast<Intrinsic>("int_riscv_cv_alu_" # intr),
765
+ !cast<RVInst>("CV_" # asm)>;
766
+
767
+ multiclass PatCoreVAluGprImm<Intrinsic intr> {
768
+ def : PatGprGpr<intr, !cast<RVInst>("CV_" # NAME # "R")>;
769
+ def : Pat<(intr (XLenVT GPR:$rs1), powerOf2Minus1:$upperBound),
770
+ (!cast<RVInst>("CV_" # NAME) GPR:$rs1,
771
+ (trailing1sPlus1 imm:$upperBound))>;
772
+ }
773
+
774
+ multiclass PatCoreVAluGprGprImm<Intrinsic intr> {
775
+ def : Pat<(intr GPR:$rs1, GPR:$rs2, GPR:$rs3),
776
+ (!cast<RVInst>("CV_" # NAME # "R") GPR:$rs1, GPR:$rs2, GPR:$rs3)>;
777
+ def : Pat<(intr GPR:$rs1, GPR:$rs2, uimm5:$imm),
778
+ (!cast<RVInst>("CV_" # NAME) GPR:$rs1, GPR:$rs2, uimm5:$imm)>;
779
+ }
780
+
781
+ let Predicates = [HasVendorXCValu, IsRV32], AddedComplexity = 1 in {
782
+ def : PatGpr<abs, CV_ABS>;
783
+ def : PatGprGpr<setle, CV_SLET>;
784
+ def : PatGprGpr<setule, CV_SLETU>;
785
+ def : PatGprGpr<smin, CV_MIN>;
786
+ def : PatGprGpr<umin, CV_MINU>;
787
+ def : PatGprGpr<smax, CV_MAX>;
788
+ def : PatGprGpr<umax, CV_MAXU>;
789
+
790
+ def : Pat<(sext_inreg (XLenVT GPR:$rs1), i16), (CV_EXTHS GPR:$rs1)>;
791
+ def : Pat<(sext_inreg (XLenVT GPR:$rs1), i8), (CV_EXTBS GPR:$rs1)>;
792
+ def : Pat<(and (XLenVT GPR:$rs1), 0xffff), (CV_EXTHZ GPR:$rs1)>;
793
+
794
+ defm CLIP : PatCoreVAluGprImm<int_riscv_cv_alu_clip>;
795
+ defm CLIPU : PatCoreVAluGprImm<int_riscv_cv_alu_clipu>;
796
+ defm ADDN : PatCoreVAluGprGprImm<int_riscv_cv_alu_addn>;
797
+ defm ADDUN : PatCoreVAluGprGprImm<int_riscv_cv_alu_addun>;
798
+ defm ADDRN : PatCoreVAluGprGprImm<int_riscv_cv_alu_addrn>;
799
+ defm ADDURN : PatCoreVAluGprGprImm<int_riscv_cv_alu_addurn>;
800
+ defm SUBN : PatCoreVAluGprGprImm<int_riscv_cv_alu_subn>;
801
+ defm SUBUN : PatCoreVAluGprGprImm<int_riscv_cv_alu_subun>;
802
+ defm SUBRN : PatCoreVAluGprGprImm<int_riscv_cv_alu_subrn>;
803
+ defm SUBURN : PatCoreVAluGprGprImm<int_riscv_cv_alu_suburn>;
804
+ } // Predicates = [HasVendorXCValu, IsRV32]
805
+
751
806
//===----------------------------------------------------------------------===//
752
- // Patterns for immediate branching operations
807
+ // Patterns for immediate branching operations
753
808
//===----------------------------------------------------------------------===//
754
809
755
810
let Predicates = [HasVendorXCVbi, IsRV32], AddedComplexity = 2 in {
0 commit comments