This is an archive of the discontinued LLVM Phabricator instance.

[flang] Add runtime interface for GET_COMMAND_ARGUMENT
ClosedPublic

Authored by rovka on Aug 25 2021, 12:40 AM.

Details

Summary

GET_COMMAND_ARGUMENT takes a lot of optional arguments: VALUE, LENGTH,
STATUS and ERRMSG. This patch breaks up the interface into 2 different
functions:

  • One for getting the LENGTH of an argument.
  • One for (optionally) getting the VALUE and the ERRMSG of an argument. This returns

the STATUS, which can be easily ignored by lowering if it is missing in
the invocation.

Diff Detail

Event Timeline

rovka created this revision.Aug 25 2021, 12:40 AM
rovka requested review of this revision.Aug 25 2021, 12:41 AM
Herald added a project: Restricted Project. · View Herald TranscriptAug 25 2021, 12:41 AM

environment.h is not a header for APIs.

The ERRMSG argument could be a nullable pointer argument to ArgumentValue.

environment.h is not a header for APIs.

Ok, should I move them to main.h, so they can sit next to ProgramStart? Seems like a nice place since they'd all be using executionEnvironment.

The ERRMSG argument could be a nullable pointer argument to ArgumentValue.

Why a nullable pointer and not a descriptor? I'm also wondering this about \p value, should that also be passed as a pointer + length rather than a descriptor?

environment.h is not a header for APIs.

Ok, should I move them to main.h, so they can sit next to ProgramStart? Seems like a nice place since they'd all be using executionEnvironment.

Fine.

The ERRMSG argument could be a nullable pointer argument to ArgumentValue.

Why a nullable pointer and not a descriptor? I'm also wondering this about \p value, should that also be passed as a pointer + length rather than a descriptor?

I mean the argument can be a pointer (not reference) to a descriptor, and the pointer can be null if there is no ERRMSG=.

The ERRMSG argument could be a nullable pointer argument to ArgumentValue.

Why a nullable pointer and not a descriptor? I'm also wondering this about \p value, should that also be passed as a pointer + length rather than a descriptor?

I mean the argument can be a pointer (not reference) to a descriptor, and the pointer can be null if there is no ERRMSG=.

Right, I got a bit confused there, thanks for clarifying :) I'll make both of them nullable, since it's clearer and simpler than having to check if the descriptor is allocated.

jeanPerier added inline comments.Aug 27 2021, 12:01 AM
flang/runtime/environment.h
61 ↗(On Diff #368568)

Could you make all the Descriptor& and Descriptor* const ? The runtime will modify the value described by the descriptors, but it should not modify the descriptors themselves.

In lowering, const Descriptor& and Descriptor& do not end-up being handled the same in FIR (because FIR cares if descriptors may be modified in meaningful way by a function), so it's important to make them const when they are not intended to be modified by the runtime.

rovka updated this revision to Diff 369057.Aug 27 2021, 3:13 AM
rovka edited the summary of this revision. (Show Details)

Addressed review comments:

  • Moved everything to command.h.
  • s/Descriptor &/const Descriptor */
  • Removed ArgumentValueVerbose entry point.
klausler accepted this revision.Aug 27 2021, 9:13 AM
This revision is now accepted and ready to land.Aug 27 2021, 9:13 AM
This revision was automatically updated to reflect the committed changes.