@@ -652,6 +652,15 @@ PPCTargetLowering::PPCTargetLowering(const PPCTargetMachine &TM,
652652 setOperationAction(ISD::EH_DWARF_CFA, MVT::i32, Custom);
653653 setOperationAction(ISD::EH_DWARF_CFA, MVT::i64, Custom);
654654
655+ setOperationAction(ISD::VP_STORE, MVT::v16i1, Custom);
656+ setOperationAction(ISD::VP_STORE, MVT::v8i1, Custom);
657+ setOperationAction(ISD::VP_STORE, MVT::v4i1, Custom);
658+ setOperationAction(ISD::VP_STORE, MVT::v2i1, Custom);
659+ setOperationAction(ISD::VP_LOAD, MVT::v16i1, Custom);
660+ setOperationAction(ISD::VP_LOAD, MVT::v8i1, Custom);
661+ setOperationAction(ISD::VP_LOAD, MVT::v4i1, Custom);
662+ setOperationAction(ISD::VP_LOAD, MVT::v2i1, Custom);
663+
655664 // We want to custom lower some of our intrinsics.
656665 setOperationAction(ISD::INTRINSIC_WO_CHAIN, MVT::Other, Custom);
657666 setOperationAction(ISD::INTRINSIC_WO_CHAIN, MVT::f64, Custom);
@@ -11909,6 +11918,81 @@ SDValue PPCTargetLowering::LowerIS_FPCLASS(SDValue Op,
1190911918 return getDataClassTest(LHS, Category, Dl, DAG, Subtarget);
1191011919}
1191111920
11921+ static SDValue AdjustLength(SDValue Val, unsigned Bits, bool Left,
11922+ SelectionDAG &DAG) {
11923+ SDLoc dl(Val);
11924+ EVT VT = Val->getValueType(0);
11925+ unsigned LeftAdj = Left ? VT.getSizeInBits() - 8 : 0;
11926+ unsigned TypeAdj = llvm::countr_zero<uint32_t>(Bits / 8);
11927+ // unsigned Shift = llvm::countr_zero<uint64_t>(Imm);
11928+ // EVT ShiftAmountTy = getShiftAmountTy(VT, DAG.getDataLayout());
11929+ // if (Value > 0 && isPowerOf2_64(Value))
11930+ SDValue SHLAmt = DAG.getConstant(LeftAdj + TypeAdj, dl, VT);
11931+ return DAG.getNode(ISD::SHL, dl, VT, Val, SHLAmt);
11932+ }
11933+
11934+ SDValue PPCTargetLowering::LowerVP_LOAD(SDValue Op, SelectionDAG &DAG) const {
11935+ dbgs() << "&&& Lower VP_LOAD\n";
11936+ Op.dump();
11937+ auto VPLD = cast<VPLoadSDNode>(Op);
11938+ bool Future = Subtarget.isISAFuture();
11939+ SDLoc dl(Op);
11940+ assert(ISD::isConstantSplatVectorAllOnes(Op->getOperand(3).getNode(), true) &&
11941+ "Mask predication not supported");
11942+ EVT PtrVT = getPointerTy(DAG.getDataLayout());
11943+ SDValue Len = DAG.getNode(ISD::ANY_EXTEND, dl, PtrVT, VPLD->getOperand(4));
11944+ unsigned IID = Future ? Intrinsic::ppc_vsx_lxvrl : Intrinsic::ppc_vsx_lxvl;
11945+ unsigned EltBits = Op->getValueType(0).getScalarType().getSizeInBits();
11946+ Len = AdjustLength(Len, EltBits, !Future, DAG);
11947+ SDValue Ops[] = {
11948+ VPLD->getChain(), // Chain
11949+ // DAG.getConstant(Intrinsic::ppc_vsx_lxvl, dl, MVT::i32),
11950+ DAG.getConstant(IID, dl, MVT::i32),
11951+ VPLD->getOperand(1),
11952+ // VPLD->getOperand(4),
11953+ // DAG.getNode(ISD::ANY_EXTEND, dl, PtrVT, VPLD->getOperand(4)),
11954+ Len
11955+ };
11956+ SDVTList Tys = DAG.getVTList(Op->getValueType(0), MVT::Other);
11957+ SDValue VPL = DAG.getMemIntrinsicNode(ISD::INTRINSIC_W_CHAIN, dl, Tys,
11958+ Ops, VPLD->getMemoryVT(), VPLD->getMemOperand());
11959+ VPL.dump();
11960+ return VPL;
11961+ // return SDValue();
11962+ }
11963+
11964+ SDValue PPCTargetLowering::LowerVP_STORE(SDValue Op, SelectionDAG &DAG) const {
11965+ dbgs() << "&&& Lower VP_STORE\n";
11966+ Op.dump();
11967+ auto VPST = cast<VPStoreSDNode>(Op);
11968+ assert(ISD::isConstantSplatVectorAllOnes(Op->getOperand(4).getNode(), true) &&
11969+ "Mask predication not supported");
11970+ EVT PtrVT = getPointerTy(DAG.getDataLayout());
11971+ SDLoc dl(Op);
11972+ SDValue Len = DAG.getNode(ISD::ANY_EXTEND, dl, PtrVT, VPST->getOperand(5));
11973+ unsigned EltBits = Op->getOperand(1).getValueType().getScalarType().getSizeInBits();
11974+ bool Future = Subtarget.isISAFuture();
11975+ unsigned IID = Future ? Intrinsic::ppc_vsx_stxvrl : Intrinsic::ppc_vsx_stxvl;
11976+ Len = AdjustLength(Len, EltBits, !Future, DAG);
11977+ SDValue Ops[] = {
11978+ VPST->getChain(), // Chain
11979+ // DAG.getConstant(Intrinsic::ppc_vsx_stxvl, dl, MVT::i32),
11980+ DAG.getConstant(IID, dl, MVT::i32),
11981+ // DAG.getTargetConstant(Intrinsic::ppc_vsx_stxvl, dl, MVT::i64),
11982+ DAG.getNode(ISD::BITCAST, dl, MVT::v4i32, VPST->getOperand(1)),
11983+ VPST->getOperand(2),
11984+ // DAG.getNode(ISD::ANY_EXTEND, dl, PtrVT, VPST->getOperand(5)),
11985+ Len
11986+ };
11987+ SDVTList Tys = DAG.getVTList(MVT::Other);
11988+ // SDValue VPS = DAG.getMemIntrinsicNode(ISD::INTRINSIC_W_CHAIN, dl, Tys,
11989+ SDValue VPS = DAG.getMemIntrinsicNode(ISD::INTRINSIC_VOID, dl, Tys,
11990+ Ops, VPST->getMemoryVT(), VPST->getMemOperand());
11991+ VPS.dump();
11992+ return VPS;
11993+ // return SDValue();
11994+ }
11995+
1191211996SDValue PPCTargetLowering::LowerSCALAR_TO_VECTOR(SDValue Op,
1191311997 SelectionDAG &DAG) const {
1191411998 SDLoc dl(Op);
@@ -12763,6 +12847,10 @@ SDValue PPCTargetLowering::LowerOperation(SDValue Op, SelectionDAG &DAG) const {
1276312847 if (Op->getFlags().hasNoFPExcept())
1276412848 return Op;
1276512849 return SDValue();
12850+ case ISD::VP_LOAD:
12851+ return LowerVP_LOAD(Op, DAG);
12852+ case ISD::VP_STORE:
12853+ return LowerVP_STORE(Op, DAG);
1276612854 }
1276712855}
1276812856
0 commit comments