[llvm] [PowerPC] Intrinsics and tests for dmr insert/extract (PR #135653)
via llvm-commits
llvm-commits at lists.llvm.org
Mon Apr 21 13:52:46 PDT 2025
================
@@ -11146,6 +11146,116 @@ SDValue PPCTargetLowering::LowerINTRINSIC_WO_CHAIN(SDValue Op,
return DAG.getMergeValues(RetOps, dl);
}
+ case Intrinsic::ppc_mma_dmxxextfdmr512: {
+ assert(Subtarget.isISAFuture() && "dmxxextfdmr512 requires ISA Future");
+ auto *Idx = dyn_cast<ConstantSDNode>(Op.getOperand(2));
+ assert(Idx && (Idx->getSExtValue() == 0 || Idx->getSExtValue() == 1) &&
+ "Specify P of 0 or 1 for lower or upper 512 bytes");
+ unsigned HiLo = Idx->getSExtValue();
+ unsigned Opcode;
+ unsigned Subx;
+ if (HiLo == 0) {
+ Opcode = PPC::DMXXEXTFDMR512;
+ Subx = PPC::sub_wacc_lo;
+ } else {
+ Opcode = PPC::DMXXEXTFDMR512_HI;
+ Subx = PPC::sub_wacc_hi;
+ }
+ SDValue Subreg(
+ DAG.getMachineNode(TargetOpcode::EXTRACT_SUBREG, dl, MVT::v512i1,
+ Op.getOperand(1),
+ DAG.getTargetConstant(Subx, dl, MVT::i32)),
+ 0);
+ EVT ReturnTypes[] = {MVT::v256i1, MVT::v256i1};
+ return SDValue(DAG.getMachineNode(Opcode, dl, ReturnTypes, Subreg), 0);
+ }
+
+ case Intrinsic::ppc_mma_dmxxextfdmr256: {
+ assert(Subtarget.isISAFuture() && "dmxxextfdmr256 requires ISA Future");
+ auto *Idx = dyn_cast<ConstantSDNode>(Op.getOperand(2));
+ assert(Idx && (Idx->getSExtValue() >= 0 || Idx->getSExtValue() <= 3) &&
+ "Specify a dmr row pair 0-3");
+ unsigned IdxVal = Idx->getSExtValue();
+ unsigned Subx;
+ switch (IdxVal) {
+ case 0:
+ Subx = PPC::sub_dmrrowp0;
+ break;
+ case 1:
+ Subx = PPC::sub_dmrrowp1;
+ break;
+ case 2:
+ Subx = PPC::sub_wacc_hi_then_sub_dmrrowp0;
+ break;
+ case 3:
+ Subx = PPC::sub_wacc_hi_then_sub_dmrrowp1;
+ break;
+ }
+ SDValue Subreg(
+ DAG.getMachineNode(TargetOpcode::EXTRACT_SUBREG, dl, MVT::v256i1,
+ Op.getOperand(1),
+ DAG.getTargetConstant(Subx, dl, MVT::i32)),
+ 0);
+ SDValue P = DAG.getTargetConstant(IdxVal, dl, MVT::i32);
+ return SDValue(
+ DAG.getMachineNode(PPC::DMXXEXTFDMR256, dl, MVT::v256i1, {Subreg, P}),
+ 0);
+ }
+
+ case Intrinsic::ppc_mma_dmxxinstdmr512: {
+ assert(Subtarget.isISAFuture() && "dmxxinstdmr512 requires ISA Future");
+ auto *Idx = dyn_cast<ConstantSDNode>(Op.getOperand(4));
+ assert(Idx && (Idx->getSExtValue() == 0 || Idx->getSExtValue() == 1) &&
+ "Specify P of 0 or 1 for lower or upper 512 bytes");
+ unsigned HiLo = Idx->getSExtValue();
+ unsigned Opcode;
+ unsigned Subx;
+ if (HiLo == 0) {
+ Opcode = PPC::DMXXINSTDMR512;
+ Subx = PPC::sub_wacc_lo;
+ } else {
+ Opcode = PPC::DMXXINSTDMR512_HI;
+ Subx = PPC::sub_wacc_hi;
+ }
+ SDValue Ops[] = {Op.getOperand(2), Op.getOperand(3)};
+ SDValue Wacc = SDValue(DAG.getMachineNode(Opcode, dl, MVT::v512i1, Ops), 0);
+ SDValue SubReg = DAG.getTargetConstant(Subx, dl, MVT::i32);
+ return SDValue(DAG.getMachineNode(PPC::INSERT_SUBREG, dl, MVT::v1024i1,
+ Op.getOperand(1), Wacc, SubReg),
----------------
RolandF77 wrote:
We want to be able to insert both the top half and bottom half of the same object. Without an input parameter for the object, we would create two different objects when we set the upper and lower halves, with no obvious way to put them together.
https://github.com/llvm/llvm-project/pull/135653
More information about the llvm-commits
mailing list