[flang] [llvm] [flang] Implement FSEEK and FTELL (PR #133003)
Eugene Epshteyn via llvm-commits
llvm-commits at lists.llvm.org
Wed Mar 26 13:20:35 PDT 2025
================
@@ -4117,6 +4128,69 @@ void IntrinsicLibrary::genFree(llvm::ArrayRef<fir::ExtendedValue> args) {
fir::runtime::genFree(builder, loc, fir::getBase(args[0]));
}
+// FSEEK
+fir::ExtendedValue
+IntrinsicLibrary::genFseek(std::optional<mlir::Type> resultType,
+ llvm::ArrayRef<fir::ExtendedValue> args) {
+ assert((args.size() == 4 && !resultType.has_value()) ||
+ (args.size() == 3 && resultType.has_value()));
+ mlir::Value unit = fir::getBase(args[0]);
+ mlir::Value offset = fir::getBase(args[1]);
+ mlir::Value whence = fir::getBase(args[2]);
+ if (!unit)
+ fir::emitFatalError(loc, "expected UNIT argument");
+ if (!offset)
+ fir::emitFatalError(loc, "expected OFFSET argument");
+ if (!whence)
+ fir::emitFatalError(loc, "expected WHENCE argument");
+ mlir::Value statusValue =
+ fir::runtime::genFseek(builder, loc, unit, offset, whence);
+ if (resultType.has_value()) { // function
+ return statusValue;
----------------
eugeneepshteyn wrote:
FWIW, Jean had me change similar return to `return builder.createConvert(loc, *resultType, statusValue);`
https://github.com/llvm/llvm-project/pull/133003
More information about the llvm-commits
mailing list