[PATCH] D108688: [flang] Add runtime interface for GET_COMMAND_ARGUMENT

Diana Picus via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Wed Aug 25 00:41:01 PDT 2021


rovka created this revision.
rovka added reviewers: klausler, jeanPerier.
rovka added a project: Flang.
Herald added a subscriber: jdoerfert.
rovka requested review of this revision.
Herald added a project: LLVM.
Herald added a subscriber: llvm-commits.

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

- One for getting the LENGTH of an argument.

- One for getting the VALUE of an argument. This returns the STATUS,

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

- One for getting the VALUE and the ERRMSG of an argument. This also

returns the STATUS.

We could also have another entry point for when the invocation only
tries to get the STATUS (and therefore doesn't pass in VALUE, LENGTH or
ERRMSG), but that sounds like an uncommon scenario. In that case,
lowering can just use the second entry point in the list above and
ignore the VALUE.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D108688

Files:
  flang/runtime/environment.h


Index: flang/runtime/environment.h
===================================================================
--- flang/runtime/environment.h
+++ flang/runtime/environment.h
@@ -41,12 +41,37 @@
 };
 extern ExecutionEnvironment executionEnvironment;
 
+class Descriptor;
+
 extern "C" {
 // 16.9.51 COMMAND_ARGUMENT_COUNT
 //
 // Lowering may need to cast the result to match the precision of the default
 // integer kind.
 CppTypeFor<TypeCategory::Integer, 8> RTNAME(ArgumentCount)();
+
+// 16.9.83 GET_COMMAND_ARGUMENT
+// We're breaking up the interface into several different functions, since most
+// of the parameters are optional.
+
+// Try to get the value of the n'th argument.
+// The \p value descriptor is only read/written into if it is already allocated.
+// Returns a STATUS as described in the standard.
+CppTypeFor<TypeCategory::Integer, 8> RTNAME(ArgumentValue)(
+    CppTypeFor<TypeCategory::Integer, 8> n, Descriptor &value);
+
+// Try to get the value of the n'th argument. Write up an error message
+// otherwise.
+// The \p value descriptor is only read/written into if it is already allocated.
+// Returns a STATUS as described in the standard.
+CppTypeFor<TypeCategory::Integer, 8> RTNAME(ArgumentValueVerbose)(
+    CppTypeFor<TypeCategory::Integer, 8> n, Descriptor &value,
+    Descriptor &errmsg);
+
+// Try to get the significant length of the n'th argument.
+// Returns 0 if it doesn't manage.
+CppTypeFor<TypeCategory::Integer, 8> RTNAME(ArgumentLength)(
+    CppTypeFor<TypeCategory::Integer, 8> n);
 }
 } // namespace Fortran::runtime
 


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D108688.368568.patch
Type: text/x-patch
Size: 1563 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20210825/ba52504b/attachment.bin>


More information about the llvm-commits mailing list