Patchwork [Fortran-dev,committed] Add version field, rename "size" to "elem_len"

login
register
mail settings
Submitter Tobias Burnus
Date March 31, 2013, 10:35 a.m.
Message ID <51581166.6070108@net-b.de>
Download mbox | patch
Permalink /patch/232597/
State New
Headers show

Comments

Tobias Burnus - March 31, 2013, 10:35 a.m.
I have committed (Rev.197282) the attached patch as obvious to the 
Fortran-dev branch.

It add the "int version" field to the array constructor and moved "size" 
up, renaming it to "elem_len" and changing its type to size_t (which is 
effectively the same). This brings the array descriptor a bit closer to 
the one of TS29113.

Additionally, the patch now sets version to 1 in some (few) cases, e.g. 
allocatables with SAVE attribute.

Tobias

PS: The next step is to fix a bunch of test-suite failures; some old, 
some due to the merge. The next bigger step is to remove "offset", to 
split the dtype - and set version, elem_len, rank and type fields.

Patch

Index: gcc/fortran/ChangeLog.fortran-dev
===================================================================
--- gcc/fortran/ChangeLog.fortran-dev	(Revision 197281)
+++ gcc/fortran/ChangeLog.fortran-dev	(Arbeitskopie)
@@ -1,3 +1,11 @@ 
+2013-03-31  Tobias Burnus  <burnus@net-b.de>
+
+	* trans-array.c (VERSION_FIELD): New define.
+	(ELEM_LEN_FIELD): Renamed from SIZE_FIELD, reordered the fields.
+	(gfc_build_null_descriptor): Also set version field (to 1).
+	* trans-types.c (gfc_get_array_descriptor_base): Rename "size" to
+	"elem_len" and move up, add "version" field.
+
 2012-07-20  Tobias Burnus  <burnus@net-b.de>
 
 	* trans-expr.c (conv_isocbinding_procedure): For C_F_Pointer,
Index: gcc/fortran/trans-array.c
===================================================================
--- gcc/fortran/trans-array.c	(Revision 197281)
+++ gcc/fortran/trans-array.c	(Arbeitskopie)
@@ -124,11 +124,12 @@ 
    Don't forget to #undef these!  */
 
 #define DATA_FIELD 0
-#define OFFSET_FIELD 1
-#define DTYPE_FIELD 2
-#define SIZE_FIELD 3
-#define DIMENSION_FIELD 4
-#define CAF_TOKEN_FIELD 5
+#define ELEM_LEN_FIELD 1
+#define VERSION_FIELD 2
+#define OFFSET_FIELD 3
+#define DTYPE_FIELD 4
+#define DIMENSION_FIELD 5
+#define CAF_TOKEN_FIELD 6
 
 #define LBOUND_SUBFIELD 0
 #define EXTENT_SUBFIELD 1
@@ -487,15 +488,23 @@ 
 {
   tree field;
   tree tmp;
+  vec<constructor_elt, va_gc> *init = NULL;
 
   gcc_assert (GFC_DESCRIPTOR_TYPE_P (type));
   gcc_assert (DATA_FIELD == 0);
+
+  /* Set a NULL data pointer.  */
   field = TYPE_FIELDS (type);
+  CONSTRUCTOR_APPEND_ELT (init, field, null_pointer_node);
 
-  /* Set a NULL data pointer.  */
-  tmp = build_constructor_single (type, field, null_pointer_node);
+  /* Set version to 1. */
+  field = gfc_advance_chain (field, VERSION_FIELD);
+  CONSTRUCTOR_APPEND_ELT (init, field,
+			  build_int_cst (integer_type_node, 1));
+
+  /* All other fields are ignored.  */
+  tmp = build_constructor (type, init);
   TREE_CONSTANT (tmp) = 1;
-  /* All other fields are ignored.  */
 
   return tmp;
 }
@@ -535,9 +544,10 @@ 
 /* Cleanup those #defines.  */
 
 #undef DATA_FIELD
+#undef ELEM_LEN_FIELD
+#undef VERSION_FIELD
 #undef OFFSET_FIELD
 #undef DTYPE_FIELD
-#undef SIZE_FIELD
 #undef DIMENSION_FIELD
 #undef CAF_TOKEN_FIELD
 #undef STRIDE_SUBFIELD
Index: gcc/fortran/trans-types.c
===================================================================
--- gcc/fortran/trans-types.c	(Revision 197281)
+++ gcc/fortran/trans-types.c	(Arbeitskopie)
@@ -1725,8 +1725,20 @@ 
 				     ? prvoid_type_node
 				     : ptr_type_node), &chain);
 
-  /* Add the base component.  */
+  /* Add the elem_len component.  */
   decl = gfc_add_field_to_struct_1 (fat_type,
+				    get_identifier ("elem_len"),
+				    size_type_node, &chain);
+  TREE_NO_WARNING (decl) = 1;
+
+  /* Add the version component.  */
+  decl = gfc_add_field_to_struct_1 (fat_type,
+				    get_identifier ("version"),
+				    integer_type_node, &chain);
+  TREE_NO_WARNING (decl) = 1;
+
+  /* Add the offset component.  */
+  decl = gfc_add_field_to_struct_1 (fat_type,
 				    get_identifier ("offset"),
 				    gfc_array_index_type, &chain);
   TREE_NO_WARNING (decl) = 1;
@@ -1737,11 +1749,6 @@ 
 				    gfc_array_index_type, &chain);
   TREE_NO_WARNING (decl) = 1;
 
-  /* Add the size component.  */
-  decl = gfc_add_field_to_struct_1 (fat_type,
-				    get_identifier ("size"),
-				    gfc_array_index_type, &chain);
-  TREE_NO_WARNING (decl) = 1;
 
 
   /* Build the array type for the stride and bound components.  */
Index: libgfortran/ChangeLog.fortran-dev
===================================================================
--- libgfortran/ChangeLog.fortran-dev	(Revision 197281)
+++ libgfortran/ChangeLog.fortran-dev	(Arbeitskopie)
@@ -1,3 +1,8 @@ 
+2013-03-31  Tobias Burnus  <burnus@net-b.de>
+
+	* ISO_Fortran_binding.h (CFI_cdesc_t): Change size to elem_len
+	and move up, add version field.
+
 2012-07-15  Tobias Burnus  <burnus@net-b.de>
 
 	* m4/cshift1.m4 (cshift1): Correctly set stride multiplier.
Index: libgfortran/ISO_Fortran_binding.h
===================================================================
--- libgfortran/ISO_Fortran_binding.h	(Revision 197281)
+++ libgfortran/ISO_Fortran_binding.h	(Arbeitskopie)
@@ -1,5 +1,5 @@ 
 /* ISO_Fortran_binding.h of GCC's GNU Fortran compiler.
-   Copyright (C) 2012 Free Software Foundation, Inc.
+   Copyright (C) 2013 Free Software Foundation, Inc.
 
 This file is part of the GNU Fortran runtime library (libgfortran)
 Libgfortran is free software; you can redistribute it and/or
@@ -18,7 +18,7 @@ 
 Boston, MA 02110-1301, USA.  */
 
 
-/* Definitions as defined by ISO/IEC Technical Specification TS 29113
+/* Definitions as defined by ISO/IEC Technical Specification TS 29113:2012
    on Further Interoperability of Fortran with C.
    Note: The technical specification only mandates the presence of certain
    members; there might be additional compiler-specific fields.  */
@@ -139,9 +139,10 @@ 
 #define CFI_GFC_CDESC_T(r, type) \
 struct {\
   type *base_addr;\
+  size_t elem_len;\
+  int version; \
   size_t offset;\
   CFI_index_t dtype;\
-  CFI_index_t size;\
   CFI_dim_t dim[r];\
 }