[llvm] [NVPTX] Add asynchronous store intrinsics (PR #200768)

Srinivasa Ravi via llvm-commits llvm-commits at lists.llvm.org
Thu Jun 4 09:06:48 PDT 2026


================
@@ -2640,6 +2643,124 @@ static SDValue lowerBSWAP(SDValue Op, SelectionDAG &DAG) {
   }
 }
 
+static SDValue lowerStAsyncWithMbarrier(SDValue Op, SelectionDAG &DAG) {
+  const Function &Fn = DAG.getMachineFunction().getFunction();
+  SDNode *N = Op.getNode();
+  SDLoc DL(N);
+  Intrinsic::ID IntrinsicID = N->getConstantOperandVal(1);
+  SDValue DestAddr = N->getOperand(2);
+  SDValue Value = N->getOperand(3);
+  SDValue MbarAddr = N->getOperand(4);
+
+  MVT ValueVT = Value.getSimpleValueType();
+
+  if (ValueVT == MVT::i32 || ValueVT == MVT::i64)
+    return Op;
+
+  if (ValueVT == MVT::i128) {
+    SDValue Cast = DAG.getNode(ISD::BITCAST, DL, MVT::v2i64, Value);
+    SDValue ValueLo = DAG.getNode(ISD::EXTRACT_VECTOR_ELT, DL, MVT::i64, Cast,
+                                  DAG.getIntPtrConstant(0, DL));
+    SDValue ValueHi = DAG.getNode(ISD::EXTRACT_VECTOR_ELT, DL, MVT::i64, Cast,
+                                  DAG.getIntPtrConstant(1, DL));
+    SDValue Ops[] = {N->getOperand(0), DestAddr, ValueLo, ValueHi, MbarAddr};
+    return DAG.getNode(NVPTXISD::ST_ASYNC_MBARRIER_B128, DL, MVT::Other, Ops);
+  }
+
+  DAG.getContext()->diagnose(DiagnosticInfoUnsupported(
+      Fn,
+      Twine("unsupported argument type ") + llvm::EVT(ValueVT).getEVTString() +
+          " for " + llvm::Intrinsic::getName(IntrinsicID) + " intrinsic",
+      DiagnosticLocation(DL.getDebugLoc())));
+  return Op.getOperand(0); // Return only the chain
+}
+
+static SDValue lowerStAsyncRelease(SDValue Op, SelectionDAG &DAG) {
+  const Function &Fn = DAG.getMachineFunction().getFunction();
+  SDNode *N = Op.getNode();
+  SDLoc DL(N);
+  Intrinsic::ID IntrinsicID = N->getConstantOperandVal(1);
+  SDValue DestAddr = N->getOperand(2);
+  SDValue Value = N->getOperand(3);
+
+  MVT ValueVT = Value.getSimpleValueType();
+
+  auto OpCode = [&]() -> std::optional<unsigned> {
+    switch (IntrinsicID) {
+    case Intrinsic::nvvm_st_async_scope_sys_space_global:
+      switch (ValueVT.SimpleTy) {
+      case MVT::i8:
+        return NVPTXISD::ST_ASYNC_SYS_B8;
+      case MVT::i16:
+        return NVPTXISD::ST_ASYNC_SYS_B16;
+      case MVT::i32:
+        return NVPTXISD::ST_ASYNC_SYS_B32;
+      case MVT::i64:
+        return NVPTXISD::ST_ASYNC_SYS_B64;
----------------
Wolfram70 wrote:

I think I'd initially done this to make lowering easier to support some additional generic addressing intrinsics but forgot to remove them later on. Removed them now, thanks!

https://github.com/llvm/llvm-project/pull/200768


More information about the llvm-commits mailing list