@@ -499,6 +499,10 @@ static constexpr IntrinsicHandler handlers[]{
499499 {" dim" , asValue},
500500 {" mask" , asBox, handleDynamicOptional}}},
501501 /* isElemental=*/ false },
502+ {" irand" ,
503+ &I::genIrand,
504+ {{{" i" , asAddr, handleDynamicOptional}}},
505+ /* isElemental=*/ false },
502506 {" is_contiguous" ,
503507 &I::genIsContiguous,
504508 {{{" array" , asBox}}},
@@ -625,6 +629,10 @@ static constexpr IntrinsicHandler handlers[]{
625629 &I::genPutenv,
626630 {{{" str" , asAddr}, {" status" , asAddr, handleDynamicOptional}}},
627631 /* isElemental=*/ false },
632+ {" rand" ,
633+ &I::genRand,
634+ {{{" i" , asAddr, handleDynamicOptional}}},
635+ /* isElemental=*/ false },
628636 {" random_init" ,
629637 &I::genRandomInit,
630638 {{{" repeatable" , asValue}, {" image_distinct" , asValue}}},
@@ -6162,6 +6170,20 @@ IntrinsicLibrary::genIparity(mlir::Type resultType,
61626170 " IPARITY" , resultType, args);
61636171}
61646172
6173+ // IRAND
6174+ fir::ExtendedValue
6175+ IntrinsicLibrary::genIrand (mlir::Type resultType,
6176+ llvm::ArrayRef<fir::ExtendedValue> args) {
6177+ assert (args.size () == 1 );
6178+ mlir::Value i =
6179+ isStaticallyPresent (args[0 ])
6180+ ? fir::getBase (args[0 ])
6181+ : fir::AbsentOp::create (builder, loc,
6182+ builder.getRefType (builder.getI32Type ()))
6183+ .getResult ();
6184+ return fir::runtime::genIrand (builder, loc, i);
6185+ }
6186+
61656187// IS_CONTIGUOUS
61666188fir::ExtendedValue
61676189IntrinsicLibrary::genIsContiguous (mlir::Type resultType,
@@ -7188,6 +7210,19 @@ IntrinsicLibrary::genPutenv(std::optional<mlir::Type> resultType,
71887210 return {};
71897211}
71907212
7213+ // RAND
7214+ fir::ExtendedValue
7215+ IntrinsicLibrary::genRand (mlir::Type, llvm::ArrayRef<fir::ExtendedValue> args) {
7216+ assert (args.size () == 1 );
7217+ mlir::Value i =
7218+ isStaticallyPresent (args[0 ])
7219+ ? fir::getBase (args[0 ])
7220+ : fir::AbsentOp::create (builder, loc,
7221+ builder.getRefType (builder.getI32Type ()))
7222+ .getResult ();
7223+ return fir::runtime::genRand (builder, loc, i);
7224+ }
7225+
71917226// RANDOM_INIT
71927227void IntrinsicLibrary::genRandomInit (llvm::ArrayRef<fir::ExtendedValue> args) {
71937228 assert (args.size () == 2 );
0 commit comments