@@ -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_all_syncjd" ,
473+ &I::genMatchAllSync,
474+ {{{" mask" , asValue}, {" value" , asValue}, {" pred" , asAddr}}},
475+ /* isElemental=*/ false },
476+ {" match_all_syncjf" ,
477+ &I::genMatchAllSync,
478+ {{{" mask" , asValue}, {" value" , asValue}, {" pred" , asAddr}}},
479+ /* isElemental=*/ false },
480+ {" match_all_syncjj" ,
481+ &I::genMatchAllSync,
482+ {{{" mask" , asValue}, {" value" , asValue}, {" pred" , asAddr}}},
483+ /* isElemental=*/ false },
484+ {" match_all_syncjx" ,
485+ &I::genMatchAllSync,
486+ {{{" mask" , asValue}, {" value" , asValue}, {" pred" , asAddr}}},
487+ /* isElemental=*/ false },
472488 {" matmul" ,
473489 &I::genMatmul,
474490 {{{" matrix_a" , asAddr}, {" matrix_b" , asAddr}}},
@@ -6044,6 +6060,42 @@ mlir::Value IntrinsicLibrary::genMask(mlir::Type resultType,
60446060 return result;
60456061}
60466062
6063+ mlir::Value
6064+ IntrinsicLibrary::genMatchAllSync (mlir::Type resultType,
6065+ llvm::ArrayRef<mlir::Value> args) {
6066+ assert (args.size () == 3 );
6067+ bool is32 = args[1 ].getType ().isInteger (32 ) || args[1 ].getType ().isF32 ();
6068+
6069+ llvm::StringRef funcName =
6070+ is32 ? " llvm.nvvm.match.all.sync.i32p" : " llvm.nvvm.match.all.sync.i64p" ;
6071+ mlir::MLIRContext *context = builder.getContext ();
6072+ mlir::Type i32Ty = builder.getI32Type ();
6073+ mlir::Type i64Ty = builder.getI64Type ();
6074+ mlir::Type i1Ty = builder.getI1Type ();
6075+ mlir::Type retTy = mlir::TupleType::get (context, {resultType, i1Ty});
6076+ mlir::Type valTy = is32 ? i32Ty : i64Ty;
6077+
6078+ mlir::FunctionType ftype =
6079+ mlir::FunctionType::get (context, {i32Ty, valTy}, {retTy});
6080+ auto funcOp = builder.createFunction (loc, funcName, ftype);
6081+ llvm::SmallVector<mlir::Value> filteredArgs;
6082+ filteredArgs.push_back (args[0 ]);
6083+ if (args[1 ].getType ().isF32 () || args[1 ].getType ().isF64 ())
6084+ filteredArgs.push_back (builder.create <fir::ConvertOp>(loc, valTy, args[1 ]));
6085+ else
6086+ filteredArgs.push_back (args[1 ]);
6087+ auto call = builder.create <fir::CallOp>(loc, funcOp, filteredArgs);
6088+ auto zero = builder.getIntegerAttr (builder.getIndexType (), 0 );
6089+ auto value = builder.create <fir::ExtractValueOp>(
6090+ loc, resultType, call.getResult (0 ), builder.getArrayAttr (zero));
6091+ auto one = builder.getIntegerAttr (builder.getIndexType (), 1 );
6092+ auto pred = builder.create <fir::ExtractValueOp>(loc, i1Ty, call.getResult (0 ),
6093+ builder.getArrayAttr (one));
6094+ auto conv = builder.create <mlir::LLVM::ZExtOp>(loc, resultType, pred);
6095+ builder.create <fir::StoreOp>(loc, conv, args[2 ]);
6096+ return value;
6097+ }
6098+
60476099// MATMUL
60486100fir::ExtendedValue
60496101IntrinsicLibrary::genMatmul (mlir::Type resultType,
0 commit comments