[llvm] [NVPTX] Add intrinsics and codegen for tensormap.replace (PR #172458)
Durgadoss R via llvm-commits
llvm-commits at lists.llvm.org
Thu Dec 18 05:55:54 PST 2025
================
@@ -2746,6 +2746,64 @@ lowerTcgen05Ld(SDNode *N, SelectionDAG &DAG, bool HasOffset = false) {
return {{BuildVector, Chain}};
}
+static SDValue lowerTensormapReplaceElemtype(SDValue Op, SelectionDAG &DAG) {
+ SDNode *N = Op.getNode();
+ SDLoc DL(N);
+ unsigned Val = N->getConstantOperandVal(3);
+
+ if (!DAG.getSubtarget<NVPTXSubtarget>().hasTensormapReplaceElemtypeSupport(
+ Val)) {
+ const Function &Fn = DAG.getMachineFunction().getFunction();
+
+ unsigned AS = 0;
+ if (auto *MemN = dyn_cast<MemIntrinsicSDNode>(N)) {
+ AS = MemN->getAddressSpace();
+ }
+ Type *PtrTy = PointerType::get(*DAG.getContext(), AS);
+ Module *M = DAG.getMachineFunction().getFunction().getParent();
+
+ DAG.getContext()->diagnose(DiagnosticInfoUnsupported(
+ Fn,
+ "Intrinsic " +
+ Intrinsic::getName(N->getConstantOperandVal(1), {PtrTy}, M) +
+ " with elemtype " + Twine(Val) +
+ " is not supported on the given target.",
+ DL.getDebugLoc()));
+ return Op.getOperand(0);
+ }
+
+ return Op;
+}
+
+static SDValue lowerTensormapReplaceSwizzleMode(SDValue Op, SelectionDAG &DAG) {
+ SDNode *N = Op.getNode();
+ SDLoc DL(N);
+ unsigned Val = N->getConstantOperandVal(3);
+
+ if (!DAG.getSubtarget<NVPTXSubtarget>().hasTensormapReplaceSwizzleModeSupport(
+ Val)) {
----------------
durga4github wrote:
After this check happens, the following part seems similar across both functions.
Can we refactor them into a common function to simplify these?
Eventually, we can try and find a way to get this work within tablegen itself
(i.e. including the nice diagnostic this provides)
https://github.com/llvm/llvm-project/pull/172458
More information about the llvm-commits
mailing list