@@ -469,6 +469,22 @@ static constexpr IntrinsicHandler handlers[]{
469469 {" malloc" , &I::genMalloc},
470470 {" maskl" , &I::genMask<mlir::arith::ShLIOp>},
471471 {" maskr" , &I::genMask<mlir::arith::ShRUIOp>},
472+ {" match_any_syncjd" ,
473+ &I::genMatchAnySync,
474+ {{{" mask" , asValue}, {" value" , asValue}}},
475+ /* isElemental=*/ false },
476+ {" match_any_syncjf" ,
477+ &I::genMatchAnySync,
478+ {{{" mask" , asValue}, {" value" , asValue}}},
479+ /* isElemental=*/ false },
480+ {" match_any_syncjj" ,
481+ &I::genMatchAnySync,
482+ {{{" mask" , asValue}, {" value" , asValue}}},
483+ /* isElemental=*/ false },
484+ {" match_any_syncjx" ,
485+ &I::genMatchAnySync,
486+ {{{" mask" , asValue}, {" value" , asValue}}},
487+ /* isElemental=*/ false },
472488 {" matmul" ,
473489 &I::genMatmul,
474490 {{{" matrix_a" , asAddr}, {" matrix_b" , asAddr}}},
@@ -6044,6 +6060,31 @@ mlir::Value IntrinsicLibrary::genMask(mlir::Type resultType,
60446060 return result;
60456061}
60466062
6063+ mlir::Value
6064+ IntrinsicLibrary::genMatchAnySync (mlir::Type resultType,
6065+ llvm::ArrayRef<mlir::Value> args) {
6066+ assert (args.size () == 2 );
6067+ bool is32 = args[1 ].getType ().isInteger (32 ) || args[1 ].getType ().isF32 ();
6068+
6069+ llvm::StringRef funcName =
6070+ is32 ? " llvm.nvvm.match.any.sync.i32p" : " llvm.nvvm.match.any.sync.i64p" ;
6071+ mlir::MLIRContext *context = builder.getContext ();
6072+ mlir::Type i32Ty = builder.getI32Type ();
6073+ mlir::Type i64Ty = builder.getI64Type ();
6074+ mlir::Type valTy = is32 ? i32Ty : i64Ty;
6075+
6076+ mlir::FunctionType ftype =
6077+ mlir::FunctionType::get (context, {i32Ty, valTy}, {i32Ty});
6078+ auto funcOp = builder.createFunction (loc, funcName, ftype);
6079+ llvm::SmallVector<mlir::Value> filteredArgs;
6080+ filteredArgs.push_back (args[0 ]);
6081+ if (args[1 ].getType ().isF32 () || args[1 ].getType ().isF64 ())
6082+ filteredArgs.push_back (builder.create <fir::ConvertOp>(loc, valTy, args[1 ]));
6083+ else
6084+ filteredArgs.push_back (args[1 ]);
6085+ return builder.create <fir::CallOp>(loc, funcOp, filteredArgs).getResult (0 );
6086+ }
6087+
60476088// MATMUL
60486089fir::ExtendedValue
60496090IntrinsicLibrary::genMatmul (mlir::Type resultType,
0 commit comments