-
Notifications
You must be signed in to change notification settings - Fork 14.1k
[flang] Implement FSEEK and FTELL #133003
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -545,6 +545,12 @@ static const IntrinsicInterface genericIntrinsicFunction[]{ | |
KINDInt, Rank::vector, IntrinsicClass::transformationalFunction}, | ||
{"floor", {{"a", AnyReal}, DefaultingKIND}, KINDInt}, | ||
{"fraction", {{"x", SameReal}}, SameReal}, | ||
{"fseek", | ||
{{"unit", AnyInt, Rank::scalar}, {"offset", AnyInt, Rank::scalar}, | ||
{"whence", AnyInt, Rank::scalar}}, | ||
DefaultInt, Rank::scalar}, | ||
{"ftell", {{"unit", AnyInt, Rank::scalar}}, | ||
TypePattern{IntType, KindCode::exactKind, 8}, Rank::scalar}, | ||
{"gamma", {{"x", SameReal}}, SameReal}, | ||
{"get_team", {{"level", DefaultInt, Rank::scalar, Optionality::optional}}, | ||
TeamType, Rank::scalar, IntrinsicClass::transformationalFunction}, | ||
|
@@ -1083,11 +1089,16 @@ static const IntrinsicInterface genericIntrinsicFunction[]{ | |
// LOC, probably others | ||
// TODO: Optionally warn on operand promotion extension | ||
|
||
// Aliases for a few generic intrinsic functions for legacy | ||
// compatibility and builtins. | ||
// Aliases for a few generic procedures for legacy compatibility and builtins. | ||
static const std::pair<const char *, const char *> genericAlias[]{ | ||
{"and", "iand"}, | ||
{"getenv", "get_environment_variable"}, | ||
{"fseek64", "fseek"}, | ||
{"fseeko64", "fseek"}, // SUN | ||
{"fseeki8", "fseek"}, // Intel | ||
{"ftell64", "ftell"}, | ||
{"ftello64", "ftell"}, // SUN | ||
{"ftelli8", "ftell"}, // Intel | ||
{"imag", "aimag"}, | ||
{"lshift", "shiftl"}, | ||
{"or", "ior"}, | ||
|
@@ -1524,6 +1535,17 @@ static const IntrinsicInterface intrinsicSubroutine[]{ | |
{"exit", {{"status", DefaultInt, Rank::scalar, Optionality::optional}}, {}, | ||
Rank::elemental, IntrinsicClass::impureSubroutine}, | ||
{"free", {{"ptr", Addressable}}, {}}, | ||
{"fseek", | ||
{{"unit", AnyInt, Rank::scalar}, {"offset", AnyInt, Rank::scalar}, | ||
{"whence", AnyInt, Rank::scalar}, | ||
{"status", AnyInt, Rank::scalar, Optionality::optional, | ||
common::Intent::InOut}}, | ||
{}, Rank::elemental, IntrinsicClass::impureSubroutine}, | ||
{"ftell", | ||
{{"unit", AnyInt, Rank::scalar}, | ||
{"offset", AnyInt, Rank::scalar, Optionality::required, | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Well, if the function form of There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I've implemented it in a generic form that will work with any kind of integer variable that is associated with the dummy argument, which seemed to me to be the best for portability. |
||
common::Intent::Out}}, | ||
{}, Rank::elemental, IntrinsicClass::impureSubroutine}, | ||
{"get_command", | ||
{{"command", DefaultChar, Rank::scalar, Optionality::optional, | ||
common::Intent::Out}, | ||
|
@@ -2811,9 +2833,9 @@ bool IntrinsicProcTable::Implementation::IsDualIntrinsic( | |
const std::string &name) const { | ||
// Collection for some intrinsics with function and subroutine form, | ||
// in order to pass the semantic check. | ||
static const std::string dualIntrinsic[]{{"chdir"s}, {"etime"s}, {"getcwd"s}, | ||
{"hostnm"s}, {"rename"s}, {"second"s}, {"system"s}, {"unlink"s}}; | ||
|
||
static const std::string dualIntrinsic[]{{"chdir"}, {"etime"}, {"fseek"}, | ||
{"ftell"}, {"getcwd"}, {"hostnm"}, {"rename"}, {"second"}, {"system"}, | ||
{"unlink"}}; | ||
return llvm::is_contained(dualIntrinsic, name); | ||
} | ||
|
||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm ok with it being
INTEGER(8)
, but please note that both GNU and nvfortran documentation have it as default INTEGER.