This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[patch, fortran-dev] Even more array access macros


Hello world,

subject says all... this is another part of the array access macro
changeover.  One more to go, then work on the descriptor change can
start in earnest.

Regression-tested on i686-pc-linux-gnu.  OK for trunk?

	Thomas

2009-05-16  Thomas Koenig  <tkoenig@gcc.gnu.org>

	PR fortran/37577
	* intrinsics/dtime.c (dtime_sub):  Use array access macros
	for accessing array descriptors.
	* intrinsics/cshift0 (cshift0):  Likewise.
	* intrinsics/etime.c:  Likewise.  Remove redundant calculation
	of rdim.
	* m4/cshift0.m4 (cshift0_'rtype_code`):  Use array access macros
	for accessing array descriptors.
	* m4/pack.m4 (pack_'rtype_code`):  Likewise.
	* m4/spread.m4 (spread_'rtype_code`):  Likewise.
	(spread_scalar_'rtype_code`):  Likewise.
	* m4/transpose.m4 (transpose_'rtype_code`):  Likewise.
	* m4/iforeach.m4 (name`'rtype_qual`_'atype_code):  Likewise.
	* m4/eoshift1.m4 (eoshift1):  Likewise.  Remove size argument,
	calculate within function.
	(eoshift1_'atype_kind`):  Remove size argument from call
	to eoshift1.
	(eoshift1_'atype_kind`_char):  Likewise.
	(eoshift1_'atype_kind`_char4):  Likewise.
	* m4/eoshift3.m4 (eoshift3):  Remove size argument, calculate
	within function. Use array access macros for accessing array
	descriptors.
	(eoshift3_'atype_kind`):  Remove size argument from call
	to eoshift1.
	(eoshift3_'atype_kind`_char):  Likewise.
	(eoshift3_'atype_kind`_char4):  Likewise.
	* m4/shape.m4 (shape_'rtype_kind`):  Use array access macros
	for accessing array descriptors.
	* m4/cshift1.m4 (cshift1): Remove size argument, calculate
	within function. Use array access macros for accessing array
	descriptors.
	(cshift1_'atype_kind`):  Remove size argument from call to
	cshift1.
	(cshift1_'atype_kind`_char):  Remove size argument from call to
	cshift1.
	(cshift1_'atype_kind`_char4):  Remove size argument from call to
	cshift1.
	* m4/reshape.m4 (reshape_'rtype_ccode`):  Use array access macros
	for accessing array descriptors.
	* m4/ifunction.m4 (name`'rtype_qual`_'atype_code):  Likewise.
	* generated/cshift0_c10.c: Regenerated.
	* generated/cshift0_c16.c: Regenerated.
	* generated/cshift0_c4.c: Regenerated.
	* generated/cshift0_c8.c: Regenerated.
	* generated/cshift0_i1.c: Regenerated.
	* generated/cshift0_i16.c: Regenerated.
	* generated/cshift0_i2.c: Regenerated.
	* generated/cshift0_i4.c: Regenerated.
	* generated/cshift0_i8.c: Regenerated.
	* generated/cshift0_r10.c: Regenerated.
	* generated/cshift0_r16.c: Regenerated.
	* generated/cshift0_r4.c: Regenerated.
	* generated/cshift0_r8.c: Regenerated.
	* generated/cshift1_16.c: Regenerated.
	* generated/cshift1_4.c: Regenerated.
	* generated/cshift1_8.c: Regenerated.
	* generated/eoshift1_16.c: Regenerated.
	* generated/eoshift1_4.c: Regenerated.
	* generated/eoshift1_8.c: Regenerated.
	* generated/eoshift3_16.c: Regenerated.
	* generated/eoshift3_4.c: Regenerated.
	* generated/eoshift3_8.c: Regenerated.
	* generated/maxloc0_16_i1.c: Regenerated.
	* generated/maxloc0_16_i16.c: Regenerated.
	* generated/maxloc0_16_i2.c: Regenerated.
	* generated/maxloc0_16_i4.c: Regenerated.
	* generated/maxloc0_16_i8.c: Regenerated.
	* generated/maxloc0_16_r10.c: Regenerated.
	* generated/maxloc0_16_r16.c: Regenerated.
	* generated/maxloc0_16_r4.c: Regenerated.
	* generated/maxloc0_16_r8.c: Regenerated.
	* generated/maxloc0_4_i1.c: Regenerated.
	* generated/maxloc0_4_i16.c: Regenerated.
	* generated/maxloc0_4_i2.c: Regenerated.
	* generated/maxloc0_4_i4.c: Regenerated.
	* generated/maxloc0_4_i8.c: Regenerated.
	* generated/maxloc0_4_r10.c: Regenerated.
	* generated/maxloc0_4_r16.c: Regenerated.
	* generated/maxloc0_4_r4.c: Regenerated.
	* generated/maxloc0_4_r8.c: Regenerated.
	* generated/maxloc0_8_i1.c: Regenerated.
	* generated/maxloc0_8_i16.c: Regenerated.
	* generated/maxloc0_8_i2.c: Regenerated.
	* generated/maxloc0_8_i4.c: Regenerated.
	* generated/maxloc0_8_i8.c: Regenerated.
	* generated/maxloc0_8_r10.c: Regenerated.
	* generated/maxloc0_8_r16.c: Regenerated.
	* generated/maxloc0_8_r4.c: Regenerated.
	* generated/maxloc0_8_r8.c: Regenerated.
	* generated/maxloc1_16_i1.c: Regenerated.
	* generated/maxloc1_16_i16.c: Regenerated.
	* generated/maxloc1_16_i2.c: Regenerated.
	* generated/maxloc1_16_i4.c: Regenerated.
	* generated/maxloc1_16_i8.c: Regenerated.
	* generated/maxloc1_16_r10.c: Regenerated.
	* generated/maxloc1_16_r16.c: Regenerated.
	* generated/maxloc1_16_r4.c: Regenerated.
	* generated/maxloc1_16_r8.c: Regenerated.
	* generated/maxloc1_4_i1.c: Regenerated.
	* generated/maxloc1_4_i16.c: Regenerated.
	* generated/maxloc1_4_i2.c: Regenerated.
	* generated/maxloc1_4_i4.c: Regenerated.
	* generated/maxloc1_4_i8.c: Regenerated.
	* generated/maxloc1_4_r10.c: Regenerated.
	* generated/maxloc1_4_r16.c: Regenerated.
	* generated/maxloc1_4_r4.c: Regenerated.
	* generated/maxloc1_4_r8.c: Regenerated.
	* generated/maxloc1_8_i1.c: Regenerated.
	* generated/maxloc1_8_i16.c: Regenerated.
	* generated/maxloc1_8_i2.c: Regenerated.
	* generated/maxloc1_8_i4.c: Regenerated.
	* generated/maxloc1_8_i8.c: Regenerated.
	* generated/maxloc1_8_r10.c: Regenerated.
	* generated/maxloc1_8_r16.c: Regenerated.
	* generated/maxloc1_8_r4.c: Regenerated.
	* generated/maxloc1_8_r8.c: Regenerated.
	* generated/maxval_i1.c: Regenerated.
	* generated/maxval_i16.c: Regenerated.
	* generated/maxval_i2.c: Regenerated.
	* generated/maxval_i4.c: Regenerated.
	* generated/maxval_i8.c: Regenerated.
	* generated/maxval_r10.c: Regenerated.
	* generated/maxval_r16.c: Regenerated.
	* generated/maxval_r4.c: Regenerated.
	* generated/maxval_r8.c: Regenerated.
	* generated/minloc0_16_i1.c: Regenerated.
	* generated/minloc0_16_i16.c: Regenerated.
	* generated/minloc0_16_i2.c: Regenerated.
	* generated/minloc0_16_i4.c: Regenerated.
	* generated/minloc0_16_i8.c: Regenerated.
	* generated/minloc0_16_r10.c: Regenerated.
	* generated/minloc0_16_r16.c: Regenerated.
	* generated/minloc0_16_r4.c: Regenerated.
	* generated/minloc0_16_r8.c: Regenerated.
	* generated/minloc0_4_i1.c: Regenerated.
	* generated/minloc0_4_i16.c: Regenerated.
	* generated/minloc0_4_i2.c: Regenerated.
	* generated/minloc0_4_i4.c: Regenerated.
	* generated/minloc0_4_i8.c: Regenerated.
	* generated/minloc0_4_r10.c: Regenerated.
	* generated/minloc0_4_r16.c: Regenerated.
	* generated/minloc0_4_r4.c: Regenerated.
	* generated/minloc0_4_r8.c: Regenerated.
	* generated/minloc0_8_i1.c: Regenerated.
	* generated/minloc0_8_i16.c: Regenerated.
	* generated/minloc0_8_i2.c: Regenerated.
	* generated/minloc0_8_i4.c: Regenerated.
	* generated/minloc0_8_i8.c: Regenerated.
	* generated/minloc0_8_r10.c: Regenerated.
	* generated/minloc0_8_r16.c: Regenerated.
	* generated/minloc0_8_r4.c: Regenerated.
	* generated/minloc0_8_r8.c: Regenerated.
	* generated/minloc1_16_i1.c: Regenerated.
	* generated/minloc1_16_i16.c: Regenerated.
	* generated/minloc1_16_i2.c: Regenerated.
	* generated/minloc1_16_i4.c: Regenerated.
	* generated/minloc1_16_i8.c: Regenerated.
	* generated/minloc1_16_r10.c: Regenerated.
	* generated/minloc1_16_r16.c: Regenerated.
	* generated/minloc1_16_r4.c: Regenerated.
	* generated/minloc1_16_r8.c: Regenerated.
	* generated/minloc1_4_i1.c: Regenerated.
	* generated/minloc1_4_i16.c: Regenerated.
	* generated/minloc1_4_i2.c: Regenerated.
	* generated/minloc1_4_i4.c: Regenerated.
	* generated/minloc1_4_i8.c: Regenerated.
	* generated/minloc1_4_r10.c: Regenerated.
	* generated/minloc1_4_r16.c: Regenerated.
	* generated/minloc1_4_r4.c: Regenerated.
	* generated/minloc1_4_r8.c: Regenerated.
	* generated/minloc1_8_i1.c: Regenerated.
	* generated/minloc1_8_i16.c: Regenerated.
	* generated/minloc1_8_i2.c: Regenerated.
	* generated/minloc1_8_i4.c: Regenerated.
	* generated/minloc1_8_i8.c: Regenerated.
	* generated/minloc1_8_r10.c: Regenerated.
	* generated/minloc1_8_r16.c: Regenerated.
	* generated/minloc1_8_r4.c: Regenerated.
	* generated/minloc1_8_r8.c: Regenerated.
	* generated/minval_i1.c: Regenerated.
	* generated/minval_i16.c: Regenerated.
	* generated/minval_i2.c: Regenerated.
	* generated/minval_i4.c: Regenerated.
	* generated/minval_i8.c: Regenerated.
	* generated/minval_r10.c: Regenerated.
	* generated/minval_r16.c: Regenerated.
	* generated/minval_r4.c: Regenerated.
	* generated/minval_r8.c: Regenerated.
	* generated/pack_c10.c: Regenerated.
	* generated/pack_c16.c: Regenerated.
	* generated/pack_c4.c: Regenerated.
	* generated/pack_c8.c: Regenerated.
	* generated/pack_i1.c: Regenerated.
	* generated/pack_i16.c: Regenerated.
	* generated/pack_i2.c: Regenerated.
	* generated/pack_i4.c: Regenerated.
	* generated/pack_i8.c: Regenerated.
	* generated/pack_r10.c: Regenerated.
	* generated/pack_r16.c: Regenerated.
	* generated/pack_r4.c: Regenerated.
	* generated/pack_r8.c: Regenerated.
	* generated/product_c10.c: Regenerated.
	* generated/product_c16.c: Regenerated.
	* generated/product_c4.c: Regenerated.
	* generated/product_c8.c: Regenerated.
	* generated/product_i1.c: Regenerated.
	* generated/product_i16.c: Regenerated.
	* generated/product_i2.c: Regenerated.
	* generated/product_i4.c: Regenerated.
	* generated/product_i8.c: Regenerated.
	* generated/product_r10.c: Regenerated.
	* generated/product_r16.c: Regenerated.
	* generated/product_r4.c: Regenerated.
	* generated/product_r8.c: Regenerated.
	* generated/reshape_c10.c: Regenerated.
	* generated/reshape_c16.c: Regenerated.
	* generated/reshape_c4.c: Regenerated.
	* generated/reshape_c8.c: Regenerated.
	* generated/reshape_i16.c: Regenerated.
	* generated/reshape_i4.c: Regenerated.
	* generated/reshape_i8.c: Regenerated.
	* generated/reshape_r10.c: Regenerated.
	* generated/reshape_r16.c: Regenerated.
	* generated/reshape_r4.c: Regenerated.
	* generated/reshape_r8.c: Regenerated.
	* generated/shape_i16.c: Regenerated.
	* generated/shape_i4.c: Regenerated.
	* generated/shape_i8.c: Regenerated.
	* generated/spread_c10.c: Regenerated.
	* generated/spread_c16.c: Regenerated.
	* generated/spread_c4.c: Regenerated.
	* generated/spread_c8.c: Regenerated.
	* generated/spread_i1.c: Regenerated.
	* generated/spread_i16.c: Regenerated.
	* generated/spread_i2.c: Regenerated.
	* generated/spread_i4.c: Regenerated.
	* generated/spread_i8.c: Regenerated.
	* generated/spread_r10.c: Regenerated.
	* generated/spread_r16.c: Regenerated.
	* generated/spread_r4.c: Regenerated.
	* generated/spread_r8.c: Regenerated.
	* generated/sum_c10.c: Regenerated.
	* generated/sum_c16.c: Regenerated.
	* generated/sum_c4.c: Regenerated.
	* generated/sum_c8.c: Regenerated.
	* generated/sum_i1.c: Regenerated.
	* generated/sum_i16.c: Regenerated.
	* generated/sum_i2.c: Regenerated.
	* generated/sum_i4.c: Regenerated.
	* generated/sum_i8.c: Regenerated.
	* generated/sum_r10.c: Regenerated.
	* generated/sum_r16.c: Regenerated.
	* generated/sum_r4.c: Regenerated.
	* generated/sum_r8.c: Regenerated.
	* generated/transpose_c10.c: Regenerated.
	* generated/transpose_c16.c: Regenerated.
	* generated/transpose_c4.c: Regenerated.
	* generated/transpose_c8.c: Regenerated.
	* generated/transpose_i16.c: Regenerated.
	* generated/transpose_i4.c: Regenerated.
	* generated/transpose_i8.c: Regenerated.
	* generated/transpose_r10.c: Regenerated.
	* generated/transpose_r16.c: Regenerated.
	* generated/transpose_r4.c: Regenerated.
	* generated/transpose_r8.c: Regenerated.



Index: intrinsics/dtime.c
===================================================================
--- intrinsics/dtime.c	(revision 147329)
+++ intrinsics/dtime.c	(working copy)
@@ -42,7 +42,7 @@ dtime_sub (gfc_array_r4 *t, GFC_REAL_4 *
   GFC_REAL_4 *tp;
   long user_sec, user_usec, system_sec, system_usec;
 
-  if (((t->dim[0].ubound + 1 - t->dim[0].lbound)) < 2)
+  if (((GFC_DESCRIPTOR_EXTENT(t,0))) < 2)
     runtime_error ("Insufficient number of elements in TARRAY.");
 
   __gthread_mutex_lock (&dtime_update_lock);
@@ -62,7 +62,7 @@ dtime_sub (gfc_array_r4 *t, GFC_REAL_4 *
   tp = t->data;
 
   *tp = tu;
-  tp += t->dim[0].stride;
+  tp += GFC_DESCRIPTOR_STRIDE(t,0);
   *tp = ts;
   *result = tt;
   __gthread_mutex_unlock (&dtime_update_lock);
Index: intrinsics/cshift0.c
===================================================================
--- intrinsics/cshift0.c	(revision 147329)
+++ intrinsics/cshift0.c	(working copy)
@@ -71,14 +71,17 @@ cshift0 (gfc_array_char * ret, const gfc
       ret->dtype = array->dtype;
       for (i = 0; i < GFC_DESCRIPTOR_RANK (array); i++)
         {
-          ret->dim[i].lbound = 0;
-          ret->dim[i].ubound = array->dim[i].ubound - array->dim[i].lbound;
+	  index_type ub, str;
+
+          ub = GFC_DESCRIPTOR_EXTENT(array,i) - 1;
 
           if (i == 0)
-            ret->dim[i].stride = 1;
+            str = 1;
           else
-            ret->dim[i].stride = (ret->dim[i-1].ubound + 1)
-				 * ret->dim[i-1].stride;
+            str = GFC_DESCRIPTOR_EXTENT(ret,i-1) *
+	      GFC_DESCRIPTOR_STRIDE(ret,i-1);
+
+	  GFC_DIMENSION_SET(ret->dim[i], 0, ub, str);
         }
 
       if (arraysize > 0)
@@ -283,20 +286,20 @@ cshift0 (gfc_array_char * ret, const gfc
     {
       if (dim == which)
         {
-          roffset = ret->dim[dim].stride * size;
+          roffset = GFC_DESCRIPTOR_STRIDE_BYTES(ret,dim);
           if (roffset == 0)
             roffset = size;
-          soffset = array->dim[dim].stride * size;
+          soffset = GFC_DESCRIPTOR_STRIDE_BYTES(array,dim);
           if (soffset == 0)
             soffset = size;
-          len = array->dim[dim].ubound + 1 - array->dim[dim].lbound;
+          len = GFC_DESCRIPTOR_EXTENT(array,dim);
         }
       else
         {
           count[n] = 0;
-          extent[n] = array->dim[dim].ubound + 1 - array->dim[dim].lbound;
-          rstride[n] = ret->dim[dim].stride * size;
-          sstride[n] = array->dim[dim].stride * size;
+          extent[n] = GFC_DESCRIPTOR_EXTENT(array,dim);
+          rstride[n] = GFC_DESCRIPTOR_STRIDE_BYTES(ret,dim);
+          sstride[n] = GFC_DESCRIPTOR_STRIDE_BYTES(array,dim);
           n++;
         }
     }
Index: intrinsics/etime.c
===================================================================
--- intrinsics/etime.c	(revision 147329)
+++ intrinsics/etime.c	(working copy)
@@ -35,7 +35,7 @@ etime_sub (gfc_array_r4 *t, GFC_REAL_4 *
   GFC_REAL_4 tu, ts, tt, *tp;
   long user_sec, user_usec, system_sec, system_usec;
 
-  if (((t->dim[0].ubound + 1 - t->dim[0].lbound)) < 2)
+  if (((GFC_DESCRIPTOR_EXTENT(t,0))) < 2)
     runtime_error ("Insufficient number of elements in TARRAY.");
 
   if (__time_1 (&user_sec, &user_usec, &system_sec, &system_usec) == 0)
@@ -54,7 +54,7 @@ etime_sub (gfc_array_r4 *t, GFC_REAL_4 *
   tp = t->data;
 
   *tp = tu;
-  tp += t->dim[0].stride;
+  tp += GFC_DESCRIPTOR_STRIDE(t,0);
   *tp = ts;
   *result = tt;
 }
Index: intrinsics/reshape_generic.c
===================================================================
--- intrinsics/reshape_generic.c	(revision 147329)
+++ intrinsics/reshape_generic.c	(working copy)
@@ -85,7 +85,6 @@ reshape_internal (parray *ret, parray *s
 
   if (ret->data == NULL)
     {
-      rdim = GFC_DESCRIPTOR_EXTENT(shape,0);
       rs = 1;
       for (n = 0; n < rdim; n++)
 	{
Index: m4/cshift0.m4
===================================================================
--- m4/cshift0.m4	(revision 147329)
+++ m4/cshift0.m4	(working copy)
@@ -70,20 +70,20 @@ cshift0_'rtype_code` ('rtype` *ret, cons
     {
       if (dim == which)
         {
-          roffset = ret->dim[dim].stride;
+          roffset = GFC_DESCRIPTOR_STRIDE(ret,dim);
           if (roffset == 0)
             roffset = 1;
-          soffset = array->dim[dim].stride;
+          soffset = GFC_DESCRIPTOR_STRIDE(array,dim);
           if (soffset == 0)
             soffset = 1;
-          len = array->dim[dim].ubound + 1 - array->dim[dim].lbound;
+          len = GFC_DESCRIPTOR_EXTENT(array,dim);
         }
       else
         {
           count[n] = 0;
-          extent[n] = array->dim[dim].ubound + 1 - array->dim[dim].lbound;
-          rstride[n] = ret->dim[dim].stride;
-          sstride[n] = array->dim[dim].stride;
+          extent[n] = GFC_DESCRIPTOR_EXTENT(array,dim);
+          rstride[n] = GFC_DESCRIPTOR_STRIDE(ret,dim);
+          sstride[n] = GFC_DESCRIPTOR_STRIDE(array,dim);
           n++;
         }
     }
Index: m4/pack.m4
===================================================================
--- m4/pack.m4	(revision 147329)
+++ m4/pack.m4	(working copy)
@@ -123,11 +123,11 @@ pack_'rtype_code` ('rtype` *ret, const '
   for (n = 0; n < dim; n++)
     {
       count[n] = 0;
-      extent[n] = array->dim[n].ubound + 1 - array->dim[n].lbound;
+      extent[n] = GFC_DESCRIPTOR_EXTENT(array,n);
       if (extent[n] <= 0)
        zero_sized = 1;
-      sstride[n] = array->dim[n].stride;
-      mstride[n] = mask->dim[n].stride * mask_kind;
+      sstride[n] = GFC_DESCRIPTOR_STRIDE(array,n);
+      mstride[n] = GFC_DESCRIPTOR_STRIDE_BYTES(mask,n);
     }
   if (sstride[0] == 0)
     sstride[0] = 1;
@@ -148,7 +148,7 @@ pack_'rtype_code` ('rtype` *ret, const '
 	{
 	  /* The return array will have as many
 	     elements as there are in VECTOR.  */
-	  total = vector->dim[0].ubound + 1 - vector->dim[0].lbound;
+	  total = GFC_DESCRIPTOR_EXTENT(vector,0);
 	  if (total < 0)
 	    {
 	      total = 0;
@@ -216,9 +216,7 @@ pack_'rtype_code` ('rtype` *ret, const '
       if (ret->data == NULL)
 	{
 	  /* Setup the array descriptor.  */
-	  ret->dim[0].lbound = 0;
-	  ret->dim[0].ubound = total - 1;
-	  ret->dim[0].stride = 1;
+	  GFC_DIMENSION_SET(ret->dim[0], 0, total-1, 1);
 
 	  ret->offset = 0;
 	  if (total == 0)
@@ -235,7 +233,7 @@ pack_'rtype_code` ('rtype` *ret, const '
 	  /* We come here because of range checking.  */
 	  index_type ret_extent;
 
-	  ret_extent = ret->dim[0].ubound + 1 - ret->dim[0].lbound;
+	  ret_extent = GFC_DESCRIPTOR_EXTENT(ret,0);
 	  if (total != ret_extent)
 	    runtime_error ("Incorrect extent in return value of PACK intrinsic;"
 			   " is %ld, should be %ld", (long int) total,
@@ -243,7 +241,7 @@ pack_'rtype_code` ('rtype` *ret, const '
 	}
     }
 
-  rstride0 = ret->dim[0].stride;
+  rstride0 = GFC_DESCRIPTOR_STRIDE(ret,0);
   if (rstride0 == 0)
     rstride0 = 1;
   sstride0 = sstride[0];
@@ -292,11 +290,11 @@ pack_'rtype_code` ('rtype` *ret, const '
   /* Add any remaining elements from VECTOR.  */
   if (vector)
     {
-      n = vector->dim[0].ubound + 1 - vector->dim[0].lbound;
+      n = GFC_DESCRIPTOR_EXTENT(vector,0);
       nelem = ((rptr - ret->data) / rstride0);
       if (n > nelem)
         {
-          sstride0 = vector->dim[0].stride;
+          sstride0 = GFC_DESCRIPTOR_STRIDE(vector,0);
           if (sstride0 == 0)
             sstride0 = 1;
 
Index: m4/spread.m4
===================================================================
--- m4/spread.m4	(revision 147329)
+++ m4/spread.m4	(working copy)
@@ -70,6 +70,9 @@ spread_'rtype_code` ('rtype` *ret, const
 
   if (ret->data == NULL)
     {
+
+      size_t ub, stride;
+
       /* The front end has signalled that we need to populate the
 	 return array descriptor.  */
       ret->dtype = (source->dtype & ~GFC_DTYPE_RANK_MASK) | rrank;
@@ -77,26 +80,25 @@ spread_'rtype_code` ('rtype` *ret, const
       rs = 1;
       for (n = 0; n < rrank; n++)
 	{
-	  ret->dim[n].stride = rs;
-	  ret->dim[n].lbound = 0;
+	  stride = rs;
 	  if (n == along - 1)
 	    {
-	      ret->dim[n].ubound = ncopies - 1;
+	      ub = ncopies - 1;
 	      rdelta = rs;
 	      rs *= ncopies;
 	    }
 	  else
 	    {
 	      count[dim] = 0;
-	      extent[dim] = source->dim[dim].ubound + 1
-		- source->dim[dim].lbound;
-	      sstride[dim] = source->dim[dim].stride;
+	      extent[dim] = GFC_DESCRIPTOR_EXTENT(source,dim);
+	      sstride[dim] = GFC_DESCRIPTOR_STRIDE(source,dim);
 	      rstride[dim] = rs;
 
-	      ret->dim[n].ubound = extent[dim]-1;
+	      ub = extent[dim] - 1;
 	      rs *= extent[dim];
 	      dim++;
 	    }
+	  GFC_DIMENSION_SET(ret->dim[n], 0, ub, stride);
 	}
       ret->offset = 0;
       if (rs > 0)
@@ -123,10 +125,10 @@ spread_'rtype_code` ('rtype` *ret, const
 	    {
 	      index_type ret_extent;
 
-	      ret_extent = ret->dim[n].ubound + 1 - ret->dim[n].lbound;
+	      ret_extent = GFC_DESCRIPTOR_EXTENT(ret,n);
 	      if (n == along - 1)
 		{
-		  rdelta = ret->dim[n].stride;
+		  rdelta = GFC_DESCRIPTOR_STRIDE(ret,n);
 
 		  if (ret_extent != ncopies)
 		    runtime_error("Incorrect extent in return value of SPREAD"
@@ -137,8 +139,7 @@ spread_'rtype_code` ('rtype` *ret, const
 	      else
 		{
 		  count[dim] = 0;
-		  extent[dim] = source->dim[dim].ubound + 1
-		    - source->dim[dim].lbound;
+		  extent[dim] = GFC_DESCRIPTOR_EXTENT(source,dim);
 		  if (ret_extent != extent[dim])
 		    runtime_error("Incorrect extent in return value of SPREAD"
 				  " intrinsic in dimension %ld: is %ld,"
@@ -148,8 +149,8 @@ spread_'rtype_code` ('rtype` *ret, const
 		    
 		  if (extent[dim] <= 0)
 		    zero_sized = 1;
-		  sstride[dim] = source->dim[dim].stride;
-		  rstride[dim] = ret->dim[n].stride;
+		  sstride[dim] = GFC_DESCRIPTOR_STRIDE(source,dim);
+		  rstride[dim] = GFC_DESCRIPTOR_STRIDE(ret,n);
 		  dim++;
 		}
 	    }
@@ -160,17 +161,16 @@ spread_'rtype_code` ('rtype` *ret, const
 	    {
 	      if (n == along - 1)
 		{
-		  rdelta = ret->dim[n].stride;
+		  rdelta = GFC_DESCRIPTOR_STRIDE(ret,n);
 		}
 	      else
 		{
 		  count[dim] = 0;
-		  extent[dim] = source->dim[dim].ubound + 1
-		    - source->dim[dim].lbound;
+		  extent[dim] = GFC_DESCRIPTOR_EXTENT(source,dim);
 		  if (extent[dim] <= 0)
 		    zero_sized = 1;
-		  sstride[dim] = source->dim[dim].stride;
-		  rstride[dim] = ret->dim[n].stride;
+		  sstride[dim] = GFC_DESCRIPTOR_STRIDE(source,dim);
+		  rstride[dim] = GFC_DESCRIPTOR_STRIDE(ret,n);
 		  dim++;
 		}
 	    }
@@ -249,19 +249,17 @@ spread_scalar_'rtype_code` ('rtype` *ret
     {
       ret->data = internal_malloc_size (ncopies * sizeof ('rtype_name`));
       ret->offset = 0;
-      ret->dim[0].stride = 1;
-      ret->dim[0].lbound = 0;
-      ret->dim[0].ubound = ncopies - 1;
+      GFC_DIMENSION_SET(ret->dim[0], 0, ncopies - 1, 1);
     }
   else
     {
-      if (ncopies - 1 > (ret->dim[0].ubound - ret->dim[0].lbound)
-			   / ret->dim[0].stride)
+      if (ncopies - 1 > (GFC_DESCRIPTOR_EXTENT(ret,0) - 1)
+			   / GFC_DESCRIPTOR_STRIDE(ret,0))
 	runtime_error ("dim too large in spread()");
     }
 
   dest = ret->data;
-  stride = ret->dim[0].stride;
+  stride = GFC_DESCRIPTOR_STRIDE(ret,0);
 
   for (n = 0; n < ncopies; n++)
     {
Index: m4/transpose.m4
===================================================================
--- m4/transpose.m4	(revision 147329)
+++ m4/transpose.m4	(working copy)
@@ -55,13 +55,11 @@ transpose_'rtype_code` ('rtype` * const 
       assert (GFC_DESCRIPTOR_RANK (ret) == 2);
       assert (ret->dtype == source->dtype);
 
-      ret->dim[0].lbound = 0;
-      ret->dim[0].ubound = source->dim[1].ubound - source->dim[1].lbound;
-      ret->dim[0].stride = 1;
-
-      ret->dim[1].lbound = 0;
-      ret->dim[1].ubound = source->dim[0].ubound - source->dim[0].lbound;
-      ret->dim[1].stride = ret->dim[0].ubound+1;
+      GFC_DIMENSION_SET(ret->dim[0], 0, GFC_DESCRIPTOR_EXTENT(source,1) - 1,
+			1);
+
+      GFC_DIMENSION_SET(ret->dim[1], 0, GFC_DESCRIPTOR_EXTENT(source,0) - 1,
+			GFC_DESCRIPTOR_EXTENT(source, 1));
 
       ret->data = internal_malloc_size (sizeof ('rtype_name`) * size0 ((array_t *) ret));
       ret->offset = 0;
@@ -69,8 +67,8 @@ transpose_'rtype_code` ('rtype` * const 
     {
       index_type ret_extent, src_extent;
 
-      ret_extent = ret->dim[0].ubound + 1 - ret->dim[0].lbound;
-      src_extent = source->dim[1].ubound + 1 - source->dim[1].lbound;
+      ret_extent = GFC_DESCRIPTOR_EXTENT(ret,0);
+      src_extent = GFC_DESCRIPTOR_EXTENT(source,1);
 
       if (src_extent != ret_extent)
 	runtime_error ("Incorrect extent in return value of TRANSPOSE"
@@ -78,8 +76,8 @@ transpose_'rtype_code` ('rtype` * const 
 		       " should be %ld", (long int) src_extent,
 		       (long int) ret_extent);
 
-      ret_extent = ret->dim[1].ubound + 1 - ret->dim[1].lbound;
-      src_extent = source->dim[0].ubound + 1 - source->dim[0].lbound;
+      ret_extent = GFC_DESCRIPTOR_EXTENT(ret,1);
+      src_extent = GFC_DESCRIPTOR_EXTENT(source,0);
 
       if (src_extent != ret_extent)
 	runtime_error ("Incorrect extent in return value of TRANSPOSE"
@@ -89,13 +87,13 @@ transpose_'rtype_code` ('rtype` * const 
 
     }
 
-  sxstride = source->dim[0].stride;
-  systride = source->dim[1].stride;
-  xcount = source->dim[0].ubound + 1 - source->dim[0].lbound;
-  ycount = source->dim[1].ubound + 1 - source->dim[1].lbound;
+  sxstride = GFC_DESCRIPTOR_STRIDE(source,0);
+  systride = GFC_DESCRIPTOR_STRIDE(source,1);
+  xcount = GFC_DESCRIPTOR_EXTENT(source,0);
+  ycount = GFC_DESCRIPTOR_EXTENT(source,1);
 
-  rxstride = ret->dim[0].stride;
-  rystride = ret->dim[1].stride;
+  rxstride = GFC_DESCRIPTOR_STRIDE(ret,0);
+  rystride = GFC_DESCRIPTOR_STRIDE(ret,1);
 
   rptr = ret->data;
   sptr = source->data;
Index: m4/iforeach.m4
===================================================================
--- m4/iforeach.m4	(revision 147329)
+++ m4/iforeach.m4	(working copy)
@@ -27,9 +27,7 @@ name`'rtype_qual`_'atype_code (rtype * c
 
   if (retarray->data == NULL)
     {
-      retarray->dim[0].lbound = 0;
-      retarray->dim[0].ubound = rank-1;
-      retarray->dim[0].stride = 1;
+      GFC_DIMENSION_SET(retarray->dim[0], 0, rank-1, 1);
       retarray->dtype = (retarray->dtype & ~GFC_DTYPE_RANK_MASK) | 1;
       retarray->offset = 0;
       retarray->data = internal_malloc_size (sizeof (rtype_name) * rank);
@@ -46,7 +44,7 @@ name`'rtype_qual`_'atype_code (rtype * c
 	    runtime_error ("rank of return array in u_name intrinsic"
 			   " should be 1, is %ld", (long int) ret_rank);
 
-	  ret_extent = retarray->dim[0].ubound + 1 - retarray->dim[0].lbound;
+	  ret_extent = GFC_DESCRIPTOR_EXTENT(retarray,0);
 	  if (ret_extent != rank)
 	    runtime_error ("Incorrect extent in return value of"
 			   " u_name intrnisic: is %ld, should be %ld",
@@ -54,12 +52,12 @@ name`'rtype_qual`_'atype_code (rtype * c
 	}
     }
 
-  dstride = retarray->dim[0].stride;
+  dstride = GFC_DESCRIPTOR_STRIDE(retarray,0);
   dest = retarray->data;
   for (n = 0; n < rank; n++)
     {
-      sstride[n] = array->dim[n].stride;
-      extent[n] = array->dim[n].ubound + 1 - array->dim[n].lbound;
+      sstride[n] = GFC_DESCRIPTOR_STRIDE(array,n);
+      extent[n] = GFC_DESCRIPTOR_EXTENT(array,n);
       count[n] = 0;
       if (extent[n] <= 0)
 	{
@@ -143,9 +141,7 @@ void
 
   if (retarray->data == NULL)
     {
-      retarray->dim[0].lbound = 0;
-      retarray->dim[0].ubound = rank-1;
-      retarray->dim[0].stride = 1;
+      GFC_DIMENSION_SET(retarray->dim[0], 0, rank - 1, 1);
       retarray->dtype = (retarray->dtype & ~GFC_DTYPE_RANK_MASK) | 1;
       retarray->offset = 0;
       retarray->data = internal_malloc_size (sizeof (rtype_name) * rank);
@@ -164,7 +160,7 @@ void
 	    runtime_error ("rank of return array in u_name intrinsic"
 			   " should be 1, is %ld", (long int) ret_rank);
 
-	  ret_extent = retarray->dim[0].ubound + 1 - retarray->dim[0].lbound;
+	  ret_extent = GFC_DESCRIPTOR_EXTENT(retarray,0);
 	  if (ret_extent != rank)
 	    runtime_error ("Incorrect extent in return value of"
 			   " u_name intrnisic: is %ld, should be %ld",
@@ -178,8 +174,8 @@ void
 
 	  for (n=0; n<rank; n++)
 	    {
-	      array_extent = array->dim[n].ubound + 1 - array->dim[n].lbound;
-	      mask_extent = mask->dim[n].ubound + 1 - mask->dim[n].lbound;
+	      array_extent = GFC_DESCRIPTOR_EXTENT(array,n);
+	      mask_extent = GFC_DESCRIPTOR_EXTENT(mask,n);
 	      if (array_extent != mask_extent)
 		runtime_error ("Incorrect extent in MASK argument of"
 			       " u_name intrinsic in dimension %ld:"
@@ -202,13 +198,13 @@ void
   else
     runtime_error ("Funny sized logical array");
 
-  dstride = retarray->dim[0].stride;
+  dstride = GFC_DESCRIPTOR_STRIDE(retarray,0);
   dest = retarray->data;
   for (n = 0; n < rank; n++)
     {
-      sstride[n] = array->dim[n].stride;
-      mstride[n] = mask->dim[n].stride * mask_kind;
-      extent[n] = array->dim[n].ubound + 1 - array->dim[n].lbound;
+      sstride[n] = GFC_DESCRIPTOR_STRIDE(array,n);
+      mstride[n] = GFC_DESCRIPTOR_STRIDE_BYTES(mask,n);
+      extent[n] = GFC_DESCRIPTOR_EXTENT(array,n);
       count[n] = 0;
       if (extent[n] <= 0)
 	{
@@ -302,9 +298,7 @@ void
 
   if (retarray->data == NULL)
     {
-      retarray->dim[0].lbound = 0;
-      retarray->dim[0].ubound = rank-1;
-      retarray->dim[0].stride = 1;
+      GFC_DIMENSION_SET(retarray->dim[0], 0, rank-1, 1);
       retarray->dtype = (retarray->dtype & ~GFC_DTYPE_RANK_MASK) | 1;
       retarray->offset = 0;
       retarray->data = internal_malloc_size (sizeof (rtype_name) * rank);
@@ -321,13 +315,13 @@ void
 	    runtime_error ("rank of return array in u_name intrinsic"
 			   " should be 1, is %ld", (long int) ret_rank);
 
-	  ret_extent = retarray->dim[0].ubound + 1 - retarray->dim[0].lbound;
+	  ret_extent = GFC_DESCRIPTOR_EXTENT(retarray,0);
 	    if (ret_extent != rank)
 	      runtime_error ("dimension of return array incorrect");
 	}
     }
 
-  dstride = retarray->dim[0].stride;
+  dstride = GFC_DESCRIPTOR_STRIDE(retarray,0);
   dest = retarray->data;
   for (n = 0; n<rank; n++)
     dest[n * dstride] = $1 ;
Index: m4/eoshift1.m4
===================================================================
--- m4/eoshift1.m4	(revision 147329)
+++ m4/eoshift1.m4	(working copy)
@@ -38,7 +38,7 @@ eoshift1 (gfc_array_char * const restric
 	const 'atype` * const restrict h,
 	const char * const restrict pbound, 
 	const 'atype_name` * const restrict pwhich, 
-	index_type size, const char * filler, index_type filler_len)
+	const char * filler, index_type filler_len)
 {
   /* r.* indicates the return array.  */
   index_type rstride[GFC_MAX_DIMENSIONS];
@@ -62,6 +62,7 @@ eoshift1 (gfc_array_char * const restric
   index_type dim;
   index_type len;
   index_type n;
+  index_type size;
   int which;
   'atype_name` sh;
   'atype_name` delta;
@@ -72,6 +73,8 @@ eoshift1 (gfc_array_char * const restric
   soffset = 0;
   roffset = 0;
 
+  size = GFC_DESCRIPTOR_SIZE(array);
+
   if (pwhich)
     which = *pwhich - 1;
   else
@@ -89,13 +92,18 @@ eoshift1 (gfc_array_char * const restric
       ret->dtype = array->dtype;
       for (i = 0; i < GFC_DESCRIPTOR_RANK (array); i++)
         {
-          ret->dim[i].lbound = 0;
-          ret->dim[i].ubound = array->dim[i].ubound - array->dim[i].lbound;
+	  index_type ub, str;
+
+	  ub = GFC_DESCRIPTOR_EXTENT(array,i) - 1;
 
           if (i == 0)
-            ret->dim[i].stride = 1;
+            str = 1;
           else
-            ret->dim[i].stride = (ret->dim[i-1].ubound + 1) * ret->dim[i-1].stride;
+            str = GFC_DESCRIPTOR_EXTENT(ret,i-1)
+	      * GFC_DESCRIPTOR_STRIDE(ret,i-1);
+
+	  GFC_DIMENSION_SET(ret->dim[i], 0, ub, str);
+
         }
     }
   else
@@ -109,22 +117,22 @@ eoshift1 (gfc_array_char * const restric
     {
       if (dim == which)
         {
-          roffset = ret->dim[dim].stride * size;
+          roffset = GFC_DESCRIPTOR_STRIDE_BYTES(ret,dim);
           if (roffset == 0)
             roffset = size;
-          soffset = array->dim[dim].stride * size;
+          soffset = GFC_DESCRIPTOR_STRIDE_BYTES(array,dim);
           if (soffset == 0)
             soffset = size;
-          len = array->dim[dim].ubound + 1 - array->dim[dim].lbound;
+          len = GFC_DESCRIPTOR_EXTENT(array,dim);
         }
       else
         {
           count[n] = 0;
-          extent[n] = array->dim[dim].ubound + 1 - array->dim[dim].lbound;
-          rstride[n] = ret->dim[dim].stride * size;
-          sstride[n] = array->dim[dim].stride * size;
+          extent[n] = GFC_DESCRIPTOR_EXTENT(array,dim);
+          rstride[n] = GFC_DESCRIPTOR_STRIDE_BYTES(ret,dim);
+          sstride[n] = GFC_DESCRIPTOR_STRIDE_BYTES(array,dim);
 
-          hstride[n] = h->dim[n].stride;
+          hstride[n] = GFC_DESCRIPTOR_STRIDE(h,n);
           n++;
         }
     }
@@ -242,8 +250,7 @@ eoshift1_'atype_kind` (gfc_array_char * 
 	const char * const restrict pbound,
 	const 'atype_name` * const restrict pwhich)
 {
-  eoshift1 (ret, array, h, pbound, pwhich, GFC_DESCRIPTOR_SIZE (array),
-	    "\0", 1);
+  eoshift1 (ret, array, h, pbound, pwhich, "\0", 1);
 }
 
 
@@ -263,10 +270,10 @@ eoshift1_'atype_kind`_char (gfc_array_ch
 	const 'atype` * const restrict h,
 	const char *  const restrict pbound, 
 	const 'atype_name` * const restrict pwhich,
-	GFC_INTEGER_4 array_length,
+	GFC_INTEGER_4 array_length __attribute__((unused)),
 	GFC_INTEGER_4 bound_length __attribute__((unused)))
 {
-  eoshift1 (ret, array, h, pbound, pwhich, array_length, " ", 1);
+  eoshift1 (ret, array, h, pbound, pwhich, " ", 1);
 }
 
 
@@ -286,11 +293,11 @@ eoshift1_'atype_kind`_char4 (gfc_array_c
 	const 'atype` * const restrict h,
 	const char *  const restrict pbound, 
 	const 'atype_name` * const restrict pwhich,
-	GFC_INTEGER_4 array_length,
+	GFC_INTEGER_4 array_length __attribute__((unused)),
 	GFC_INTEGER_4 bound_length __attribute__((unused)))
 {
   static const gfc_char4_t space = (unsigned char) ''` ''`;
-  eoshift1 (ret, array, h, pbound, pwhich, array_length * sizeof (gfc_char4_t),
+  eoshift1 (ret, array, h, pbound, pwhich,
 	    (const char *) &space, sizeof (gfc_char4_t));
 }
 
Index: m4/eoshift3.m4
===================================================================
--- m4/eoshift3.m4	(revision 147329)
+++ m4/eoshift3.m4	(working copy)
@@ -38,7 +38,7 @@ eoshift3 (gfc_array_char * const restric
 	const 'atype` * const restrict h,
 	const gfc_array_char * const restrict bound, 
 	const 'atype_name` * const restrict pwhich,
-	index_type size, const char * filler, index_type filler_len)
+	const char * filler, index_type filler_len)
 {
   /* r.* indicates the return array.  */
   index_type rstride[GFC_MAX_DIMENSIONS];
@@ -66,6 +66,7 @@ eoshift3 (gfc_array_char * const restric
   index_type dim;
   index_type len;
   index_type n;
+  index_type size;
   int which;
   'atype_name` sh;
   'atype_name` delta;
@@ -76,6 +77,8 @@ eoshift3 (gfc_array_char * const restric
   soffset = 0;
   roffset = 0;
 
+  size = GFC_DESCRIPTOR_SIZE(array);
+
   if (pwhich)
     which = *pwhich - 1;
   else
@@ -90,13 +93,18 @@ eoshift3 (gfc_array_char * const restric
       ret->dtype = array->dtype;
       for (i = 0; i < GFC_DESCRIPTOR_RANK (array); i++)
         {
-          ret->dim[i].lbound = 0;
-          ret->dim[i].ubound = array->dim[i].ubound - array->dim[i].lbound;
+	  index_type ub, str;
+
+	  ub = GFC_DESCRIPTOR_EXTENT(array,i) - 1;
 
           if (i == 0)
-            ret->dim[i].stride = 1;
+            str = 1;
           else
-            ret->dim[i].stride = (ret->dim[i-1].ubound + 1) * ret->dim[i-1].stride;
+            str = GFC_DESCRIPTOR_EXTENT(ret,i-1)
+	      * GFC_DESCRIPTOR_STRIDE(ret,i-1);
+
+	  GFC_DIMENSION_SET(ret->dim[i], 0, ub, str);
+
         }
     }
   else
@@ -113,24 +121,24 @@ eoshift3 (gfc_array_char * const restric
     {
       if (dim == which)
         {
-          roffset = ret->dim[dim].stride * size;
+          roffset = GFC_DESCRIPTOR_STRIDE_BYTES(ret,dim);
           if (roffset == 0)
             roffset = size;
-          soffset = array->dim[dim].stride * size;
+          soffset = GFC_DESCRIPTOR_STRIDE_BYTES(array,dim);
           if (soffset == 0)
             soffset = size;
-          len = array->dim[dim].ubound + 1 - array->dim[dim].lbound;
+          len = GFC_DESCRIPTOR_EXTENT(array,dim);
         }
       else
         {
           count[n] = 0;
-          extent[n] = array->dim[dim].ubound + 1 - array->dim[dim].lbound;
-          rstride[n] = ret->dim[dim].stride * size;
-          sstride[n] = array->dim[dim].stride * size;
+          extent[n] = GFC_DESCRIPTOR_EXTENT(array,dim);
+          rstride[n] = GFC_DESCRIPTOR_STRIDE_BYTES(ret,dim);
+          sstride[n] = GFC_DESCRIPTOR_STRIDE_BYTES(array,dim);
 
-          hstride[n] = h->dim[n].stride;
+          hstride[n] = GFC_DESCRIPTOR_STRIDE(h,n);
           if (bound)
-            bstride[n] = bound->dim[n].stride * size;
+            bstride[n] = GFC_DESCRIPTOR_STRIDE_BYTES(bound,n);
           else
             bstride[n] = 0;
           n++;
@@ -261,8 +269,7 @@ eoshift3_'atype_kind` (gfc_array_char * 
 	const gfc_array_char * const restrict bound,
 	const 'atype_name` * const restrict pwhich)
 {
-  eoshift3 (ret, array, h, bound, pwhich, GFC_DESCRIPTOR_SIZE (array),
-	    "\0", 1);
+  eoshift3 (ret, array, h, bound, pwhich, "\0", 1);
 }
 
 
@@ -282,10 +289,10 @@ eoshift3_'atype_kind`_char (gfc_array_ch
 	const 'atype` *  const restrict h,
 	const gfc_array_char * const restrict bound,
 	const 'atype_name` * const restrict pwhich,
-	GFC_INTEGER_4 array_length,
+	GFC_INTEGER_4 array_length __attribute__((unused)),
 	GFC_INTEGER_4 bound_length __attribute__((unused)))
 {
-  eoshift3 (ret, array, h, bound, pwhich, array_length, " ", 1);
+  eoshift3 (ret, array, h, bound, pwhich, " ", 1);
 }
 
 
@@ -305,11 +312,11 @@ eoshift3_'atype_kind`_char4 (gfc_array_c
 	const 'atype` *  const restrict h,
 	const gfc_array_char * const restrict bound,
 	const 'atype_name` * const restrict pwhich,
-	GFC_INTEGER_4 array_length,
+	GFC_INTEGER_4 array_length __attribute__((unused)),
 	GFC_INTEGER_4 bound_length __attribute__((unused)))
 {
   static const gfc_char4_t space = (unsigned char) ''` ''`;
-  eoshift3 (ret, array, h, bound, pwhich, array_length * sizeof (gfc_char4_t),
+  eoshift3 (ret, array, h, bound, pwhich,
 	    (const char *) &space, sizeof (gfc_char4_t));
 }
 
Index: m4/shape.m4
===================================================================
--- m4/shape.m4	(revision 147329)
+++ m4/shape.m4	(working copy)
@@ -43,14 +43,14 @@ shape_'rtype_kind` ('rtype` * const rest
   index_type stride;
   index_type extent;
 
-  stride = ret->dim[0].stride;
+  stride = GFC_DESCRIPTOR_STRIDE(ret,0);
 
-  if (ret->dim[0].ubound < ret->dim[0].lbound)
+  if (GFC_DESCRIPTOR_EXTENT(ret,0) < 1)
     return;
 
   for (n = 0; n < GFC_DESCRIPTOR_RANK (array); n++)
     {
-      extent = array->dim[n].ubound + 1 - array->dim[n].lbound;
+      extent = GFC_DESCRIPTOR_EXTENT(array,n);
       ret->data[n * stride] = extent > 0 ? extent : 0 ;
     }
 }
Index: m4/cshift1.m4
===================================================================
--- m4/cshift1.m4	(revision 147329)
+++ m4/cshift1.m4	(working copy)
@@ -36,8 +36,7 @@ static void
 cshift1 (gfc_array_char * const restrict ret, 
 	const gfc_array_char * const restrict array,
 	const 'atype` * const restrict h, 
-	const 'atype_name` * const restrict pwhich, 
-	index_type size)
+	const 'atype_name` * const restrict pwhich)
 {
   /* r.* indicates the return array.  */
   index_type rstride[GFC_MAX_DIMENSIONS];
@@ -64,6 +63,7 @@ cshift1 (gfc_array_char * const restrict
   int which;
   'atype_name` sh;
   index_type arraysize;
+  index_type size;
 
   if (pwhich)
     which = *pwhich - 1;
@@ -73,6 +73,8 @@ cshift1 (gfc_array_char * const restrict
   if (which < 0 || (which + 1) > GFC_DESCRIPTOR_RANK (array))
     runtime_error ("Argument ''`DIM''` is out of range in call to ''`CSHIFT''`");
 
+  size = GFC_DESCRIPTOR_SIZE(array);
+
   arraysize = size0 ((array_t *)array);
 
   if (ret->data == NULL)
@@ -84,13 +86,17 @@ cshift1 (gfc_array_char * const restrict
       ret->dtype = array->dtype;
       for (i = 0; i < GFC_DESCRIPTOR_RANK (array); i++)
         {
-          ret->dim[i].lbound = 0;
-          ret->dim[i].ubound = array->dim[i].ubound - array->dim[i].lbound;
+	  index_type ub, str;
+
+          ub = GFC_DESCRIPTOR_EXTENT(array,i) - 1;
 
           if (i == 0)
-            ret->dim[i].stride = 1;
+            str = 1;
           else
-            ret->dim[i].stride = (ret->dim[i-1].ubound + 1) * ret->dim[i-1].stride;
+	    str = GFC_DESCRIPTOR_EXTENT(ret,i-1) *
+	      GFC_DESCRIPTOR_STRIDE(ret,i-1);
+
+	  GFC_DIMENSION_SET(ret->dim[i], 0, ub, str);
         }
     }
 
@@ -110,22 +116,22 @@ cshift1 (gfc_array_char * const restrict
     {
       if (dim == which)
         {
-          roffset = ret->dim[dim].stride * size;
+          roffset = GFC_DESCRIPTOR_STRIDE_BYTES(ret,dim);
           if (roffset == 0)
             roffset = size;
-          soffset = array->dim[dim].stride * size;
+          soffset = GFC_DESCRIPTOR_STRIDE_BYTES(array,dim);
           if (soffset == 0)
             soffset = size;
-          len = array->dim[dim].ubound + 1 - array->dim[dim].lbound;
+          len = GFC_DESCRIPTOR_EXTENT(array,dim);
         }
       else
         {
           count[n] = 0;
-          extent[n] = array->dim[dim].ubound + 1 - array->dim[dim].lbound;
-          rstride[n] = ret->dim[dim].stride * size;
-          sstride[n] = array->dim[dim].stride * size;
+          extent[n] = GFC_DESCRIPTOR_EXTENT(array,dim);
+          rstride[n] = GFC_DESCRIPTOR_STRIDE_BYTES(ret,dim);
+          sstride[n] = GFC_DESCRIPTOR_STRIDE_BYTES(array,dim);
 
-          hstride[n] = h->dim[n].stride;
+          hstride[n] = GFC_DESCRIPTOR_STRIDE(h,n);
           n++;
         }
     }
@@ -211,7 +217,7 @@ cshift1_'atype_kind` (gfc_array_char * c
 	const 'atype` * const restrict h, 
 	const 'atype_name` * const restrict pwhich)
 {
-  cshift1 (ret, array, h, pwhich, GFC_DESCRIPTOR_SIZE (array));
+  cshift1 (ret, array, h, pwhich);
 }
 
 
@@ -229,9 +235,9 @@ cshift1_'atype_kind`_char (gfc_array_cha
 	const gfc_array_char * const restrict array,
 	const 'atype` * const restrict h, 
 	const 'atype_name` * const restrict pwhich,
-	GFC_INTEGER_4 array_length)
+	GFC_INTEGER_4 array_length __attribute__((unused)))
 {
-  cshift1 (ret, array, h, pwhich, array_length);
+  cshift1 (ret, array, h, pwhich);
 }
 
 
@@ -249,9 +255,9 @@ cshift1_'atype_kind`_char4 (gfc_array_ch
 	const gfc_array_char * const restrict array,
 	const 'atype` * const restrict h, 
 	const 'atype_name` * const restrict pwhich,
-	GFC_INTEGER_4 array_length)
+	GFC_INTEGER_4 array_length __attribute__((unused)))
 {
-  cshift1 (ret, array, h, pwhich, array_length * sizeof (gfc_char4_t));
+  cshift1 (ret, array, h, pwhich);
 }
 
 #endif'
Index: m4/reshape.m4
===================================================================
--- m4/reshape.m4	(revision 147329)
+++ m4/reshape.m4	(working copy)
@@ -1,4 +1,4 @@
-`/* Implementation of the RESHAPE
+`/* Implementation of the RESHAPE intrinsic
    Copyright 2002, 2006, 2007, 2009 Free Software Foundation, Inc.
    Contributed by Paul Brook <paul@nowt.org>
 
@@ -83,7 +83,7 @@ reshape_'rtype_ccode` ('rtype` * const r
   int sempty, pempty, shape_empty;
   index_type shape_data[GFC_MAX_DIMENSIONS];
 
-  rdim = shape->dim[0].ubound - shape->dim[0].lbound + 1;
+  rdim = GFC_DESCRIPTOR_EXTENT(shape,0);
   if (rdim != GFC_DESCRIPTOR_RANK(ret))
     runtime_error("rank of return array incorrect in RESHAPE intrinsic");
 
@@ -91,7 +91,7 @@ reshape_'rtype_ccode` ('rtype` * const r
 
   for (n = 0; n < rdim; n++)
     {
-      shape_data[n] = shape->data[n * shape->dim[0].stride];
+      shape_data[n] = shape->data[n * GFC_DESCRIPTOR_STRIDE(shape,0)];
       if (shape_data[n] <= 0)
       {
         shape_data[n] = 0;
@@ -104,10 +104,10 @@ reshape_'rtype_ccode` ('rtype` * const r
       rs = 1;
       for (n = 0; n < rdim; n++)
 	{
-	  ret->dim[n].lbound = 0;
 	  rex = shape_data[n];
-	  ret->dim[n].ubound =  rex - 1;
-	  ret->dim[n].stride = rs;
+
+	  GFC_DIMENSION_SET(ret->dim[n], 0, rex - 1, rs);
+
 	  rs *= rex;
 	}
       ret->offset = 0;
@@ -126,8 +126,8 @@ reshape_'rtype_ccode` ('rtype` * const r
       for (n = 0; n < pdim; n++)
         {
           pcount[n] = 0;
-          pstride[n] = pad->dim[n].stride;
-          pextent[n] = pad->dim[n].ubound + 1 - pad->dim[n].lbound;
+          pstride[n] = GFC_DESCRIPTOR_STRIDE(pad,n);
+          pextent[n] = GFC_DESCRIPTOR_EXTENT(pad,n);
           if (pextent[n] <= 0)
 	    {
 	      pempty = 1;
@@ -157,7 +157,7 @@ reshape_'rtype_ccode` ('rtype` * const r
       for (n = 0; n < rdim; n++)
 	{
 	  rs *= shape_data[n];
-	  ret_extent = ret->dim[n].ubound + 1 - ret->dim[n].lbound;
+	  ret_extent = GFC_DESCRIPTOR_EXTENT(ret,n);
 	  if (ret_extent != shape_data[n])
 	    runtime_error("Incorrect extent in return value of RESHAPE"
 			  " intrinsic in dimension %ld: is %ld,"
@@ -170,7 +170,7 @@ reshape_'rtype_ccode` ('rtype` * const r
       for (n = 0; n < sdim; n++)
 	{
 	  index_type se;
-	  se = source->dim[n].ubound + 1 - source->dim[0].lbound;
+	  se = GFC_DESCRIPTOR_EXTENT(source,n);
 	  source_extent *= se > 0 ? se : 0;
 	}
 
@@ -189,7 +189,7 @@ reshape_'rtype_ccode` ('rtype` * const r
 
 	  for (n = 0; n < rdim; n++)
 	    {
-	      v = order->data[n * order->dim[0].stride] - 1;
+	      v = order->data[n * GFC_DESCRIPTOR_STRIDE(order,0)] - 1;
 
 	      if (v < 0 || v >= rdim)
 		runtime_error("Value %ld out of range in ORDER argument"
@@ -208,13 +208,13 @@ reshape_'rtype_ccode` ('rtype` * const r
   for (n = 0; n < rdim; n++)
     {
       if (order)
-        dim = order->data[n * order->dim[0].stride] - 1;
+        dim = order->data[n * GFC_DESCRIPTOR_STRIDE(order,0)] - 1;
       else
         dim = n;
 
       rcount[n] = 0;
-      rstride[n] = ret->dim[dim].stride;
-      rextent[n] = ret->dim[dim].ubound + 1 - ret->dim[dim].lbound;
+      rstride[n] = GFC_DESCRIPTOR_STRIDE(ret,dim);
+      rextent[n] = GFC_DESCRIPTOR_EXTENT(ret,dim);
       if (rextent[n] < 0)
         rextent[n] = 0;
 
@@ -235,8 +235,8 @@ reshape_'rtype_ccode` ('rtype` * const r
   for (n = 0; n < sdim; n++)
     {
       scount[n] = 0;
-      sstride[n] = source->dim[n].stride;
-      sextent[n] = source->dim[n].ubound + 1 - source->dim[n].lbound;
+      sstride[n] = GFC_DESCRIPTOR_STRIDE(source,n);
+      sextent[n] = GFC_DESCRIPTOR_EXTENT(source,n);
       if (sextent[n] <= 0)
 	{
 	  sempty = 1;
Index: m4/ifunction.m4
===================================================================
--- m4/ifunction.m4	(revision 147329)
+++ m4/ifunction.m4	(working copy)
@@ -45,24 +45,23 @@ name`'rtype_qual`_'atype_code (rtype * c
   dim = (*pdim) - 1;
   rank = GFC_DESCRIPTOR_RANK (array) - 1;
 
-  len = array->dim[dim].ubound + 1 - array->dim[dim].lbound;
+  len = GFC_DESCRIPTOR_EXTENT(array,dim);
   if (len < 0)
     len = 0;
-  delta = array->dim[dim].stride;
+  delta = GFC_DESCRIPTOR_STRIDE(array,dim);
 
   for (n = 0; n < dim; n++)
     {
-      sstride[n] = array->dim[n].stride;
-      extent[n] = array->dim[n].ubound + 1 - array->dim[n].lbound;
+      sstride[n] = GFC_DESCRIPTOR_STRIDE(array,n);
+      extent[n] = GFC_DESCRIPTOR_EXTENT(array,n);
 
       if (extent[n] < 0)
 	extent[n] = 0;
     }
   for (n = dim; n < rank; n++)
     {
-      sstride[n] = array->dim[n + 1].stride;
-      extent[n] =
-        array->dim[n + 1].ubound + 1 - array->dim[n + 1].lbound;
+      sstride[n] = GFC_DESCRIPTOR_STRIDE(array, n + 1);
+      extent[n] = GFC_DESCRIPTOR_EXTENT(array, n + 1);
 
       if (extent[n] < 0)
 	extent[n] = 0;
@@ -70,16 +69,17 @@ name`'rtype_qual`_'atype_code (rtype * c
 
   if (retarray->data == NULL)
     {
-      size_t alloc_size;
+      size_t alloc_size, str;
 
       for (n = 0; n < rank; n++)
         {
-          retarray->dim[n].lbound = 0;
-          retarray->dim[n].ubound = extent[n]-1;
           if (n == 0)
-            retarray->dim[n].stride = 1;
+	    str = 1;
           else
-            retarray->dim[n].stride = retarray->dim[n-1].stride * extent[n-1];
+            str = retarray->dim[n-1].stride * extent[n-1];
+
+	  GFC_DIMENSION_SET(retarray->dim[n], 0, extent[n] - 1, str);
+
         }
 
       retarray->offset = 0;
@@ -91,9 +91,9 @@ name`'rtype_qual`_'atype_code (rtype * c
       if (alloc_size == 0)
 	{
 	  /* Make sure we have a zero-sized array.  */
-	  retarray->dim[0].lbound = 0;
-	  retarray->dim[0].ubound = -1;
+	  GFC_DIMENSION_SET(retarray->dim[0], 0, -1, 1);
 	  return;
+
 	}
       else
 	retarray->data = internal_malloc_size (alloc_size);
@@ -112,8 +112,7 @@ name`'rtype_qual`_'atype_code (rtype * c
 	    {
 	      index_type ret_extent;
 
-	      ret_extent = retarray->dim[n].ubound + 1
-		- retarray->dim[n].lbound;
+	      ret_extent = GFC_DESCRIPTOR_EXTENT(retarray,n);
 	      if (extent[n] != ret_extent)
 		runtime_error ("Incorrect extent in return value of"
 			       " u_name intrinsic in dimension %ld:"
@@ -126,7 +125,7 @@ name`'rtype_qual`_'atype_code (rtype * c
   for (n = 0; n < rank; n++)
     {
       count[n] = 0;
-      dstride[n] = retarray->dim[n].stride;
+      dstride[n] = GFC_DESCRIPTOR_STRIDE(retarray,n);
       if (extent[n] <= 0)
         len = 0;
     }
@@ -217,7 +216,7 @@ void
   dim = (*pdim) - 1;
   rank = GFC_DESCRIPTOR_RANK (array) - 1;
 
-  len = array->dim[dim].ubound + 1 - array->dim[dim].lbound;
+  len = GFC_DESCRIPTOR_EXTENT(array,dim);
   if (len <= 0)
     return;
 
@@ -234,14 +233,14 @@ void
   else
     runtime_error ("Funny sized logical array");
 
-  delta = array->dim[dim].stride;
-  mdelta = mask->dim[dim].stride * mask_kind;
+  delta = GFC_DESCRIPTOR_STRIDE(array,dim);
+  mdelta = GFC_DESCRIPTOR_STRIDE_BYTES(mask,dim);
 
   for (n = 0; n < dim; n++)
     {
-      sstride[n] = array->dim[n].stride;
-      mstride[n] = mask->dim[n].stride * mask_kind;
-      extent[n] = array->dim[n].ubound + 1 - array->dim[n].lbound;
+      sstride[n] = GFC_DESCRIPTOR_STRIDE(array,n);
+      mstride[n] = GFC_DESCRIPTOR_STRIDE_BYTES(mask,n);
+      extent[n] = GFC_DESCRIPTOR_EXTENT(array,n);
 
       if (extent[n] < 0)
 	extent[n] = 0;
@@ -249,10 +248,9 @@ void
     }
   for (n = dim; n < rank; n++)
     {
-      sstride[n] = array->dim[n + 1].stride;
-      mstride[n] = mask->dim[n + 1].stride * mask_kind;
-      extent[n] =
-        array->dim[n + 1].ubound + 1 - array->dim[n + 1].lbound;
+      sstride[n] = GFC_DESCRIPTOR_STRIDE(array,n + 1);
+      mstride[n] = GFC_DESCRIPTOR_STRIDE_BYTES(mask, n + 1);
+      extent[n] = GFC_DESCRIPTOR_EXTENT(array, n + 1);
 
       if (extent[n] < 0)
 	extent[n] = 0;
@@ -260,16 +258,17 @@ void
 
   if (retarray->data == NULL)
     {
-      size_t alloc_size;
+      size_t alloc_size, str;
 
       for (n = 0; n < rank; n++)
         {
-          retarray->dim[n].lbound = 0;
-          retarray->dim[n].ubound = extent[n]-1;
           if (n == 0)
-            retarray->dim[n].stride = 1;
+            str = 1;
           else
-            retarray->dim[n].stride = retarray->dim[n-1].stride * extent[n-1];
+            str= retarray->dim[n-1].stride * extent[n-1];
+
+	  GFC_DIMENSION_SET(retarray->dim[n], 0, extent[n] - 1, str);
+
         }
 
       alloc_size = sizeof (rtype_name) * retarray->dim[rank-1].stride
@@ -281,8 +280,7 @@ void
       if (alloc_size == 0)
 	{
 	  /* Make sure we have a zero-sized array.  */
-	  retarray->dim[0].lbound = 0;
-	  retarray->dim[0].ubound = -1;
+	  GFC_DIMENSION_SET(retarray->dim[0], 0, -1, 1);
 	  return;
 	}
       else
@@ -300,8 +298,7 @@ void
 	    {
 	      index_type ret_extent;
 
-	      ret_extent = retarray->dim[n].ubound + 1
-		- retarray->dim[n].lbound;
+	      ret_extent = GFC_DESCRIPTOR_EXTENT(retarray,n);
 	      if (extent[n] != ret_extent)
 		runtime_error ("Incorrect extent in return value of"
 			       " u_name intrinsic in dimension %ld:"
@@ -312,8 +309,8 @@ void
             {
               index_type mask_extent, array_extent;
 
-	      array_extent = array->dim[n].ubound + 1 - array->dim[n].lbound;
-	      mask_extent = mask->dim[n].ubound + 1 - mask->dim[n].lbound;
+	      array_extent = GFC_DESCRIPTOR_EXTENT(array,n);
+	      mask_extent = GFC_DESCRIPTOR_EXTENT(mask,n);
 	      if (array_extent != mask_extent)
 		runtime_error ("Incorrect extent in MASK argument of"
 			       " u_name intrinsic in dimension %ld:"
@@ -326,7 +323,7 @@ void
   for (n = 0; n < rank; n++)
     {
       count[n] = 0;
-      dstride[n] = retarray->dim[n].stride;
+      dstride[n] = GFC_DESCRIPTOR_STRIDE(retarray,n);
       if (extent[n] <= 0)
         return;
     }
@@ -423,8 +420,8 @@ void
 
   for (n = 0; n < dim; n++)
     {
-      sstride[n] = array->dim[n].stride;
-      extent[n] = array->dim[n].ubound + 1 - array->dim[n].lbound;
+      sstride[n] = GFC_DESCRIPTOR_STRIDE(array,n);
+      extent[n] = GFC_DESCRIPTOR_EXTENT(array,n);
 
       if (extent[n] <= 0)
 	extent[n] = 0;
@@ -432,9 +429,9 @@ void
 
   for (n = dim; n < rank; n++)
     {
-      sstride[n] = array->dim[n + 1].stride;
+      sstride[n] = GFC_DESCRIPTOR_STRIDE(array,n + 1);
       extent[n] =
-        array->dim[n + 1].ubound + 1 - array->dim[n + 1].lbound;
+        GFC_DESCRIPTOR_EXTENT(array,n + 1);
 
       if (extent[n] <= 0)
         extent[n] = 0;
@@ -442,16 +439,17 @@ void
 
   if (retarray->data == NULL)
     {
-      size_t alloc_size;
+      size_t alloc_size, str;
 
       for (n = 0; n < rank; n++)
         {
-          retarray->dim[n].lbound = 0;
-          retarray->dim[n].ubound = extent[n]-1;
           if (n == 0)
-            retarray->dim[n].stride = 1;
+            str = 1;
           else
-            retarray->dim[n].stride = retarray->dim[n-1].stride * extent[n-1];
+            str = retarray->dim[n-1].stride * extent[n-1];
+
+	  GFC_DIMENSION_SET(retarray->dim[n], 0, extent[n] - 1, str);
+
         }
 
       retarray->offset = 0;
@@ -463,8 +461,7 @@ void
       if (alloc_size == 0)
 	{
 	  /* Make sure we have a zero-sized array.  */
-	  retarray->dim[0].lbound = 0;
-	  retarray->dim[0].ubound = -1;
+	  GFC_DIMENSION_SET(retarray->dim[0], 0, -1, 1);
 	  return;
 	}
       else
@@ -484,8 +481,7 @@ void
 	    {
 	      index_type ret_extent;
 
-	      ret_extent = retarray->dim[n].ubound + 1
-		- retarray->dim[n].lbound;
+	      ret_extent = GFC_DESCRIPTOR_EXTENT(retarray,n);
 	      if (extent[n] != ret_extent)
 		runtime_error ("Incorrect extent in return value of"
 			       " u_name intrinsic in dimension %ld:"
@@ -498,7 +494,7 @@ void
   for (n = 0; n < rank; n++)
     {
       count[n] = 0;
-      dstride[n] = retarray->dim[n].stride;
+      dstride[n] = GFC_DESCRIPTOR_STRIDE(retarray,n);
     }
 
   dest = retarray->data;

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]