@@ -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
@@ -716,6 +716,13 @@ def CV_HI5: SDNodeXForm<imm, [{
716
716
N->getValueType(0));
717
717
}]>;
718
718
719
+ def powerOf2Minus1 : ImmLeaf<XLenVT, [{ return isPowerOf2_32(Imm+1); }]>;
720
+ def trailing1sPlus1 : SDNodeXForm<imm, [{
721
+ return CurDAG->getTargetConstant(
722
+ llvm::countr_one(N->getZExtValue()) + 1,
723
+ SDLoc(N), N->getValueType(0));
724
+ }]>;
725
+
719
726
multiclass PatCoreVBitManip<Intrinsic intr> {
720
727
def : PatGprGpr<intr, !cast<RVInst>("CV_" # NAME # "R")>;
721
728
def : Pat<(intr GPR:$rs1, cv_uimm10:$imm),
@@ -748,8 +755,54 @@ let Predicates = [HasVendorXCVbitmanip, IsRV32] in {
748
755
def : Pat<(bitreverse (XLenVT GPR:$rs)), (CV_BITREV GPR:$rs, 0, 0)>;
749
756
}
750
757
758
+ class PatCoreVAluGpr<string intr, string asm> :
759
+ PatGpr<!cast<Intrinsic>("int_riscv_cv_alu_" # intr),
760
+ !cast<RVInst>("CV_" # asm)>;
761
+ class PatCoreVAluGprGpr <string intr, string asm> :
762
+ PatGprGpr<!cast<Intrinsic>("int_riscv_cv_alu_" # intr),
763
+ !cast<RVInst>("CV_" # asm)>;
764
+
765
+ multiclass PatCoreVAluGprImm<Intrinsic intr> {
766
+ def : PatGprGpr<intr, !cast<RVInst>("CV_" # NAME # "R")>;
767
+ def : Pat<(intr (XLenVT GPR:$rs1), powerOf2Minus1:$upperBound),
768
+ (!cast<RVInst>("CV_" # NAME) GPR:$rs1,
769
+ (trailing1sPlus1 imm:$upperBound))>;
770
+ }
771
+
772
+ multiclass PatCoreVAluGprGprImm<Intrinsic intr> {
773
+ def : Pat<(intr GPR:$rs1, GPR:$rs2, GPR:$rs3),
774
+ (!cast<RVInst>("CV_" # NAME # "R") GPR:$rs1, GPR:$rs2, GPR:$rs3)>;
775
+ def : Pat<(intr GPR:$rs1, GPR:$rs2, uimm5:$imm),
776
+ (!cast<RVInst>("CV_" # NAME) GPR:$rs1, GPR:$rs2, uimm5:$imm)>;
777
+ }
778
+
779
+ let Predicates = [HasVendorXCValu, IsRV32], AddedComplexity = 1 in {
780
+ def : PatGpr<abs, CV_ABS>;
781
+ def : PatGprGpr<setle, CV_SLET>;
782
+ def : PatGprGpr<setule, CV_SLETU>;
783
+ def : PatGprGpr<smin, CV_MIN>;
784
+ def : PatGprGpr<umin, CV_MINU>;
785
+ def : PatGprGpr<smax, CV_MAX>;
786
+ def : PatGprGpr<umax, CV_MAXU>;
787
+
788
+ def : Pat<(sext_inreg (XLenVT GPR:$rs1), i16), (CV_EXTHS GPR:$rs1)>;
789
+ def : Pat<(sext_inreg (XLenVT GPR:$rs1), i8), (CV_EXTBS GPR:$rs1)>;
790
+ def : Pat<(and (XLenVT GPR:$rs1), 0xffff), (CV_EXTHZ GPR:$rs1)>;
791
+
792
+ defm CLIP : PatCoreVAluGprImm<int_riscv_cv_alu_clip>;
793
+ defm CLIPU : PatCoreVAluGprImm<int_riscv_cv_alu_clipu>;
794
+ defm ADDN : PatCoreVAluGprGprImm<int_riscv_cv_alu_addn>;
795
+ defm ADDUN : PatCoreVAluGprGprImm<int_riscv_cv_alu_addun>;
796
+ defm ADDRN : PatCoreVAluGprGprImm<int_riscv_cv_alu_addrn>;
797
+ defm ADDURN : PatCoreVAluGprGprImm<int_riscv_cv_alu_addurn>;
798
+ defm SUBN : PatCoreVAluGprGprImm<int_riscv_cv_alu_subn>;
799
+ defm SUBUN : PatCoreVAluGprGprImm<int_riscv_cv_alu_subun>;
800
+ defm SUBRN : PatCoreVAluGprGprImm<int_riscv_cv_alu_subrn>;
801
+ defm SUBURN : PatCoreVAluGprGprImm<int_riscv_cv_alu_suburn>;
802
+ } // Predicates = [HasVendorXCValu, IsRV32]
803
+
751
804
//===----------------------------------------------------------------------===//
752
- // Patterns for immediate branching operations
805
+ // Patterns for immediate branching operations
753
806
//===----------------------------------------------------------------------===//
754
807
755
808
let Predicates = [HasVendorXCVbi, IsRV32], AddedComplexity = 2 in {
0 commit comments