@@ -675,49 +675,15 @@ def CV_HI5: SDNodeXForm<imm, [{
675
675
N->getValueType(0));
676
676
}]>;
677
677
678
- def between : PatFrags<(ops node:$lowerBound, node:$upperBound, node:$value),
679
- [(smin (smax node:$value, node:$lowerBound), node:$upperBound),
680
- (smax (smin node:$value, node:$upperBound), node:$lowerBound)]>;
681
-
682
- def betweenu : PatFrags<(ops node:$upperBound, node:$value),
683
- [(smin (smax node:$value, 0), node:$upperBound),
684
- (smax (smin node:$value, node:$upperBound), 0)]>;
685
678
def powerOf2 : ImmLeaf<XLenVT, [{ return isPowerOf2_32(Imm); }]>;
686
679
def powerOf2Minus1 : ImmLeaf<XLenVT, [{ return isPowerOf2_32(Imm+1); }]>;
687
680
def negativePowerOf2 : ImmLeaf<XLenVT, [{ return isPowerOf2_32(-Imm); }]>;
688
- def roundBit : PatFrag<(ops node:$shiftAmount),
689
- (srl (shl 1, node:$shiftAmount), (XLenVT 1))>;
690
681
def trailing1sPlus1 : SDNodeXForm<imm, [{
691
682
return CurDAG->getTargetConstant(
692
683
llvm::countr_one(N->getZExtValue()) + 1,
693
684
SDLoc(N), N->getValueType(0));
694
685
}]>;
695
686
696
- def shiftRound : PatFrag<(ops node:$value, node:$shiftAmount),
697
- (sra (add node:$value, powerOf2), node:$shiftAmount), [{
698
- if (auto powerOf2 = dyn_cast<ConstantSDNode>(N->getOperand(0)->getOperand(1)))
699
- return (powerOf2->getZExtValue() << 1) == (1U << N->getConstantOperandVal(1));
700
- return false;
701
- }]>;
702
-
703
- def ushiftRound : PatFrag<(ops node:$value, node:$shiftAmount),
704
- (srl (add node:$value, powerOf2), node:$shiftAmount), [{
705
- if (auto powerOf2 = dyn_cast<ConstantSDNode>(N->getOperand(0)->getOperand(1)))
706
- return (powerOf2->getZExtValue() << 1) == (1U << N->getConstantOperandVal(1));
707
- return false;
708
- }]>;
709
-
710
- def clip : PatFrag<(ops node:$upperBound, node:$value),
711
- (between negativePowerOf2, node:$upperBound, node:$value), [{
712
- // Checking lower & upper bound for the clip instruction
713
- if (auto bound1 = dyn_cast<ConstantSDNode>(N->getOperand(0)->getOperand(1))) {
714
- if (auto bound2 = dyn_cast<ConstantSDNode>(N->getOperand(1))) {
715
- return (bound1->getSExtValue() == ~bound2->getSExtValue());
716
- }
717
- }
718
- return false;
719
- }]>;
720
-
721
687
multiclass PatCoreVBitManip<Intrinsic intr> {
722
688
def : PatGprGpr<intr, !cast<RVInst>("CV_" # NAME # "R")>;
723
689
def : Pat<(intr GPR:$rs1, cv_uimm10:$imm),
@@ -750,29 +716,28 @@ let Predicates = [HasVendorXCVbitmanip, IsRV32] in {
750
716
def : Pat<(bitreverse (XLenVT GPR:$rs)), (CV_BITREV GPR:$rs, 0, 0)>;
751
717
}
752
718
753
- class PatCoreVAluGpr <string intr, string asm> :
719
+ class PatCoreVAluGpr<string intr, string asm> :
754
720
PatGpr<!cast<Intrinsic>("int_riscv_cv_alu_" # intr),
755
721
!cast<RVInst>("CV_" # asm)>;
756
722
class PatCoreVAluGprGpr <string intr, string asm> :
757
723
PatGprGpr<!cast<Intrinsic>("int_riscv_cv_alu_" # intr),
758
724
!cast<RVInst>("CV_" # asm)>;
759
725
760
- multiclass PatCoreVAluGprImm <Intrinsic intr> {
726
+ multiclass PatCoreVAluGprImm<Intrinsic intr> {
761
727
def : PatGprGpr<intr, !cast<RVInst>("CV_" # NAME # "R")>;
762
728
def : Pat<(intr (XLenVT GPR:$rs1), powerOf2Minus1:$upperBound),
763
729
(!cast<RVInst>("CV_" # NAME) GPR:$rs1,
764
730
(trailing1sPlus1 imm:$upperBound))>;
765
731
}
766
732
767
- multiclass PatCoreVAluGprGprImm <Intrinsic intr> {
733
+ multiclass PatCoreVAluGprGprImm<Intrinsic intr> {
768
734
def : Pat<(intr GPR:$rs1, GPR:$rs2, GPR:$rs3),
769
735
(!cast<RVInst>("CV_" # NAME # "R") GPR:$rs1, GPR:$rs2, GPR:$rs3)>;
770
736
def : Pat<(intr GPR:$rs1, GPR:$rs2, uimm5:$imm),
771
737
(!cast<RVInst>("CV_" # NAME) GPR:$rs1, GPR:$rs2, uimm5:$imm)>;
772
738
}
773
739
774
740
let Predicates = [HasVendorXCValu, IsRV32], AddedComplexity = 1 in {
775
- def : PatGpr<abs, CV_ABS>;
776
741
def : PatGprGpr<setle, CV_SLET>;
777
742
def : PatGprGpr<setule, CV_SLETU>;
778
743
def : PatGprGpr<smin, CV_MIN>;
@@ -783,9 +748,6 @@ let Predicates = [HasVendorXCValu, IsRV32], AddedComplexity = 1 in {
783
748
def : Pat<(sext_inreg (XLenVT GPR:$rs1), i16), (CV_EXTHS GPR:$rs1)>;
784
749
def : Pat<(sext_inreg (XLenVT GPR:$rs1), i8), (CV_EXTBS GPR:$rs1)>;
785
750
786
- def : Pat<(and (XLenVT GPR:$rs1), 0xffff), (CV_EXTHZ GPR:$rs1)>;
787
- def : Pat<(and (XLenVT GPR:$rs1), 0xff), (CV_EXTBZ GPR:$rs1)>;
788
-
789
751
defm CLIP : PatCoreVAluGprImm<int_riscv_cv_alu_clip>;
790
752
defm CLIPU : PatCoreVAluGprImm<int_riscv_cv_alu_clipu>;
791
753
defm ADDN : PatCoreVAluGprGprImm<int_riscv_cv_alu_addn>;
0 commit comments