[flang-commits] [flang] [Flang] Implement RENAME intrinsic (code-gen + runtime entry point) (PR #98359)
Tom Eccles via flang-commits
flang-commits at lists.llvm.org
Thu Jul 11 05:53:06 PDT 2024
================
@@ -5911,6 +5917,37 @@ IntrinsicLibrary::genReduce(mlir::Type resultType,
return readAndAddCleanUp(resultMutableBox, resultType, "REDUCE");
}
+// RENAME
+fir::ExtendedValue
+IntrinsicLibrary::genRename(std::optional<mlir::Type> resultType,
+ mlir::ArrayRef<fir::ExtendedValue> args) {
+ assert((args.size() == 3 && !resultType.has_value()) ||
+ (args.size() == 2 && resultType.has_value()));
+
+ mlir::Value path1 = fir::getBase(args[0]);
+ mlir::Value path2 = fir::getBase(args[1]);
+ if (!path1 || !path2)
+ fir::emitFatalError(loc, "Expected at least two dummy arguments");
+
+ if (resultType.has_value()) {
+ // code-gen for the function form of RENAME
+ auto statusAddr = builder.createTemporary(loc, *resultType);
+ auto statusBox = builder.createBox(loc, statusAddr);
+ fir::runtime::genRename(builder, loc, path1, path2, statusBox);
+ return builder.create<fir::LoadOp>(loc, statusAddr);
+ } else {
+ // code-gen for the procedure form of RENAME
+ mlir::Type boxNoneTy = fir::BoxType::get(builder.getNoneType());
+ auto status = args[2];
+ mlir::Value statusBox =
+ isStaticallyPresent(status)
+ ? fir::getBase(status)
+ : builder.create<fir::AbsentOp>(loc, boxNoneTy).getResult();
----------------
tblah wrote:
LGTM, sorry for the confusion
https://github.com/llvm/llvm-project/pull/98359
More information about the flang-commits
mailing list