[flang-commits] [flang] 4b9b64d - [flang] Added missing runtime I/O definitions

Tim Keith via flang-commits flang-commits at lists.llvm.org
Tue Jul 7 12:34:12 PDT 2020


Author: Zachary Selk
Date: 2020-07-07T12:33:51-07:00
New Revision: 4b9b64d561e952e64288cdec3bae1952269c1bcf

URL: https://github.com/llvm/llvm-project/commit/4b9b64d561e952e64288cdec3bae1952269c1bcf
DIFF: https://github.com/llvm/llvm-project/commit/4b9b64d561e952e64288cdec3bae1952269c1bcf.diff

LOG: [flang] Added missing runtime I/O definitions

Added runtime function definitions for 32-bit real I/O and 32-bit complex output

Differential Revision: https://reviews.llvm.org/D83112

Added: 
    

Modified: 
    flang/runtime/io-api.cpp

Removed: 
    


################################################################################
diff  --git a/flang/runtime/io-api.cpp b/flang/runtime/io-api.cpp
index 77b32ca6bc1c..4710a590ccab 100644
--- a/flang/runtime/io-api.cpp
+++ b/flang/runtime/io-api.cpp
@@ -843,6 +843,35 @@ bool IONAME(InputInteger)(Cookie cookie, std::int64_t &n, int kind) {
   return false;
 }
 
+bool IONAME(OutputReal32)(Cookie cookie, float x) {
+  IoStatementState &io{*cookie};
+  if (!io.get_if<OutputStatementState>()) {
+    io.GetIoErrorHandler().Crash(
+        "OutputReal32() called for a non-output I/O statement");
+    return false;
+  }
+  if (auto edit{io.GetNextDataEdit()}) {
+    return RealOutputEditing<24>{io, x}.Edit(*edit);
+  }
+  return false;
+}
+
+bool IONAME(InputReal32)(Cookie cookie, float &x) {
+  IoStatementState &io{*cookie};
+  if (!io.get_if<InputStatementState>()) {
+    io.GetIoErrorHandler().Crash(
+        "InputReal32() called for a non-input I/O statement");
+    return false;
+  }
+  if (auto edit{io.GetNextDataEdit()}) {
+    if (edit->descriptor == DataEdit::ListDirectedNullValue) {
+      return true;
+    }
+    return EditRealInput<24>(io, *edit, reinterpret_cast<void *>(&x));
+  }
+  return false;
+}
+
 bool IONAME(OutputReal64)(Cookie cookie, double x) {
   IoStatementState &io{*cookie};
   if (!io.get_if<OutputStatementState>()) {
@@ -872,6 +901,18 @@ bool IONAME(InputReal64)(Cookie cookie, double &x) {
   return false;
 }
 
+bool IONAME(OutputComplex32)(Cookie cookie, float r, float z) {
+  IoStatementState &io{*cookie};
+  if (io.get_if<ListDirectedStatementState<Direction::Output>>()) {
+    DataEdit real, imaginary;
+    real.descriptor = DataEdit::ListDirectedRealPart;
+    imaginary.descriptor = DataEdit::ListDirectedImaginaryPart;
+    return RealOutputEditing<24>{io, r}.Edit(real) &&
+        RealOutputEditing<24>{io, z}.Edit(imaginary);
+  }
+  return IONAME(OutputReal32)(cookie, r) && IONAME(OutputReal32)(cookie, z);
+}
+
 bool IONAME(OutputComplex64)(Cookie cookie, double r, double z) {
   IoStatementState &io{*cookie};
   if (io.get_if<ListDirectedStatementState<Direction::Output>>()) {


        


More information about the flang-commits mailing list