STOP managed by external library when coarrays are used
authorAlessandro Fanfarillo <fanfarillo.gcc@gmail.com>
Mon, 28 Mar 2016 09:05:01 +0000 (03:05 -0600)
committerAlessandro Fanfarillo <afanfa@gcc.gnu.org>
Mon, 28 Mar 2016 09:05:01 +0000 (03:05 -0600)
From-SVN: r234502

gcc/fortran/ChangeLog
gcc/fortran/trans-decl.c
gcc/fortran/trans-stmt.c
gcc/fortran/trans.h
libgfortran/ChangeLog
libgfortran/caf/libcaf.h
libgfortran/caf/single.c

index dac67d1fc845c88d9870aa52c735a65b5bc01b38..cf95d6ffc95949caa6a4154bfaf98fff39be5f0c 100644 (file)
@@ -1,3 +1,11 @@
+2016-03-28  Alessandro Fanfarillo  <fanfarillo.gcc@gmail.com>
+
+       * trans-decl.c (gfc_build_builtin_function_decls):
+       caf_stop_numeric and caf_stop_str definition.
+       * trans-stmt.c (gfc_trans_stop): invoke external functions
+       for stop and stop_str when coarrays are used.
+       * trans.h: extern for new functions.
+
 2016-03-19  Jerry DeLisle  <jvdelisle@gcc.gnu.org>
 
        PR fortran/69043
index 4bd7dc4e85313b9d08eef62f2b1173b72692c0c2..309baf1c69ecbab9d34b9fa86a1a9cd5e1bfaa1f 100644 (file)
@@ -137,6 +137,8 @@ tree gfor_fndecl_caf_sendget;
 tree gfor_fndecl_caf_sync_all;
 tree gfor_fndecl_caf_sync_memory;
 tree gfor_fndecl_caf_sync_images;
+tree gfor_fndecl_caf_stop_str;
+tree gfor_fndecl_caf_stop_numeric;
 tree gfor_fndecl_caf_error_stop;
 tree gfor_fndecl_caf_error_stop_str;
 tree gfor_fndecl_caf_atomic_def;
@@ -3550,6 +3552,18 @@ gfc_build_builtin_function_decls (void)
       /* CAF's ERROR STOP doesn't return.  */
       TREE_THIS_VOLATILE (gfor_fndecl_caf_error_stop_str) = 1;
 
+      gfor_fndecl_caf_stop_numeric = gfc_build_library_function_decl_with_spec (
+        get_identifier (PREFIX("caf_stop_numeric")), ".R.",
+        void_type_node, 1, gfc_int4_type_node);
+      /* CAF's STOP doesn't return.  */
+      TREE_THIS_VOLATILE (gfor_fndecl_caf_stop_numeric) = 1;
+
+      gfor_fndecl_caf_stop_str = gfc_build_library_function_decl_with_spec (
+        get_identifier (PREFIX("caf_stop_str")), ".R.",
+        void_type_node, 2, pchar_type_node, gfc_int4_type_node);
+      /* CAF's STOP doesn't return.  */
+      TREE_THIS_VOLATILE (gfor_fndecl_caf_stop_str) = 1;
+
       gfor_fndecl_caf_atomic_def = gfc_build_library_function_decl_with_spec (
        get_identifier (PREFIX("caf_atomic_define")), "R..RW",
        void_type_node, 7, pvoid_type_node, size_type_node, integer_type_node,
index cb54499ec39d7138fe9f06348951acaf0a6800f7..2fc43eddbe5f86d3cf203ba11107011e7850b817 100644 (file)
@@ -635,7 +635,9 @@ gfc_trans_stop (gfc_code *code, bool error_stop)
                                 ? (flag_coarray == GFC_FCOARRAY_LIB
                                    ? gfor_fndecl_caf_error_stop_str
                                    : gfor_fndecl_error_stop_string)
-                                : gfor_fndecl_stop_string,
+                                : (flag_coarray == GFC_FCOARRAY_LIB
+                                   ? gfor_fndecl_caf_stop_str
+                                   : gfor_fndecl_stop_string),
                                 2, build_int_cst (pchar_type_node, 0), tmp);
     }
   else if (code->expr1->ts.type == BT_INTEGER)
@@ -646,7 +648,9 @@ gfc_trans_stop (gfc_code *code, bool error_stop)
                                 ? (flag_coarray == GFC_FCOARRAY_LIB
                                    ? gfor_fndecl_caf_error_stop
                                    : gfor_fndecl_error_stop_numeric)
-                                : gfor_fndecl_stop_numeric_f08, 1,
+                                : (flag_coarray == GFC_FCOARRAY_LIB
+                                   ? gfor_fndecl_caf_stop_numeric
+                                   : gfor_fndecl_stop_numeric_f08), 1,
                                 fold_convert (gfc_int4_type_node, se.expr));
     }
   else
@@ -657,7 +661,9 @@ gfc_trans_stop (gfc_code *code, bool error_stop)
                                 ? (flag_coarray == GFC_FCOARRAY_LIB
                                    ? gfor_fndecl_caf_error_stop_str
                                    : gfor_fndecl_error_stop_string)
-                                : gfor_fndecl_stop_string,
+                                : (flag_coarray == GFC_FCOARRAY_LIB
+                                   ? gfor_fndecl_caf_stop_str
+                                   : gfor_fndecl_stop_string),
                                 2, se.expr, se.string_length);
     }
 
index 316ee9b540f5cec6d1e152f417c821d889d6686c..add0ceaa3db93e264ea6a3139eb86414a04d45a0 100644 (file)
@@ -762,6 +762,8 @@ extern GTY(()) tree gfor_fndecl_caf_sendget;
 extern GTY(()) tree gfor_fndecl_caf_sync_all;
 extern GTY(()) tree gfor_fndecl_caf_sync_memory;
 extern GTY(()) tree gfor_fndecl_caf_sync_images;
+extern GTY(()) tree gfor_fndecl_caf_stop_numeric;
+extern GTY(()) tree gfor_fndecl_caf_stop_str;
 extern GTY(()) tree gfor_fndecl_caf_error_stop;
 extern GTY(()) tree gfor_fndecl_caf_error_stop_str;
 extern GTY(()) tree gfor_fndecl_caf_atomic_def;
index 4d10b2779e431df5cca25d9836b01363d8ca179a..6a742b505971999f59606a9bdf036e8612b43b85 100644 (file)
@@ -1,3 +1,9 @@
+2016-03-28  Alessandro Fanfarillo  <fanfarillo.gcc@gmail.com>
+
+       * caf/libcaf.h: caf_stop_numeric and caf_stop_str prototype.
+       * caf/single.c: _gfortran_caf_stop_numeric and
+       _gfortran_caf_stop_str implementation.
+
 2016-02-23  Jerry DeLisle  <jvdelisle@gcc.gnu.org>
 
        PR libgfortran/69456
index 427c8bf3f74ce8c4d6a85e7a32f8f6ffebd6d672..01a33f9d0ee9f88727f52be86f914047a7068502 100644 (file)
@@ -105,6 +105,10 @@ void _gfortran_caf_sync_all (int *, char *, int);
 void _gfortran_caf_sync_memory (int *, char *, int);
 void _gfortran_caf_sync_images (int, int[], int *, char *, int);
 
+void _gfortran_caf_stop_numeric (int32_t)
+     __attribute__ ((noreturn));
+void _gfortran_caf_stop_str (const char *, int32_t)
+     __attribute__ ((noreturn));
 void _gfortran_caf_error_stop_str (const char *, int32_t)
      __attribute__ ((noreturn));
 void _gfortran_caf_error_stop (int32_t) __attribute__ ((noreturn));
index 23278dc5c9053aff9cab109f50b39147e4f9a8f5..f726537e7884ee19f52e3f0c83fdbbfb65cc0e3c 100644 (file)
@@ -204,6 +204,23 @@ _gfortran_caf_sync_images (int count __attribute__ ((unused)),
     *stat = 0;
 }
 
+void
+_gfortran_caf_stop_numeric(int32_t stop_code)
+{
+  fprintf (stderr, "STOP %d\n", stop_code);
+  exit (0);
+}
+
+void
+_gfortran_caf_stop_str(const char *string, int32_t len)
+{
+  fputs ("STOP ", stderr);
+  while (len--)
+    fputc (*(string++), stderr);
+  fputs ("\n", stderr);
+
+  exit (0);
+}
 
 void
 _gfortran_caf_error_stop_str (const char *string, int32_t len)