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] most array access macros


Hello,

this is the last-but-one installment of the array access macros for the
fortran-dev branch.  Regression-tested on i686-pc-linux-gnu.

The last remainging file is iso_c_binding.c, which I'll do after fixing
PR 40187.

OK for the branch?

	Thomas

2008-05-21  Thomas Koenig  <tkoenig@gcc.gnu.org>

	PR fortran/37577
	* intrinsics/eoshift0.c (eoshift0):  Use array access
	macros everywhere.
	* m4/in_pack.m4 (internal_pack_'rtype_ccode`):  Use
	array access macros for accessing array descriptors.
	* m4/in_unpack.m4 (internal_unpack_'rtype_ccode`):
	Likewise.
	* m4/matmull.m4 (matmul_'rtype_code`):  Likewise.
	* m4/matmul.m4 (matmul_'rtype_code`):  Likewise.
	* m4/unpack.m4 (unpack0_'rtype_code`):  Likewise.
	(unpack1_'rtype_code`):  Likewise.
	* m4/ifunction_logical.m4 (name`'rtype_qual`_'atype_code): Likewise.
	* m4/ifunction.m4 (name`'rtype_qual`_'atype_code): Use array access
	macros everywhere.
	* generated/all_l1.c: Regenerated.
	* generated/all_l16.c: Regenerated.
	* generated/all_l2.c: Regenerated.
	* generated/all_l4.c: Regenerated.
	* generated/all_l8.c: Regenerated.
	* generated/any_l1.c: Regenerated.
	* generated/any_l16.c: Regenerated.
	* generated/any_l2.c: Regenerated.
	* generated/any_l4.c: Regenerated.
	* generated/any_l8.c: Regenerated.
	* generated/count_16_l.c: Regenerated.
	* generated/count_1_l.c: Regenerated.
	* generated/count_2_l.c: Regenerated.
	* generated/count_4_l.c: Regenerated.
	* generated/count_8_l.c: Regenerated.
	* generated/in_pack_c10.c: Regenerated.
	* generated/in_pack_c16.c: Regenerated.
	* generated/in_pack_c4.c: Regenerated.
	* generated/in_pack_c8.c: Regenerated.
	* generated/in_pack_i1.c: Regenerated.
	* generated/in_pack_i16.c: Regenerated.
	* generated/in_pack_i2.c: Regenerated.
	* generated/in_pack_i4.c: Regenerated.
	* generated/in_pack_i8.c: Regenerated.
	* generated/in_pack_r10.c: Regenerated.
	* generated/in_pack_r16.c: Regenerated.
	* generated/in_pack_r4.c: Regenerated.
	* generated/in_pack_r8.c: Regenerated.
	* generated/in_unpack_c10.c: Regenerated.
	* generated/in_unpack_c16.c: Regenerated.
	* generated/in_unpack_c4.c: Regenerated.
	* generated/in_unpack_c8.c: Regenerated.
	* generated/in_unpack_i1.c: Regenerated.
	* generated/in_unpack_i16.c: Regenerated.
	* generated/in_unpack_i2.c: Regenerated.
	* generated/in_unpack_i4.c: Regenerated.
	* generated/in_unpack_i8.c: Regenerated.
	* generated/in_unpack_r10.c: Regenerated.
	* generated/in_unpack_r16.c: Regenerated.
	* generated/in_unpack_r4.c: Regenerated.
	* generated/in_unpack_r8.c: Regenerated.
	* generated/matmul_c10.c: Regenerated.
	* generated/matmul_c16.c: Regenerated.
	* generated/matmul_c4.c: Regenerated.
	* generated/matmul_c8.c: Regenerated.
	* generated/matmul_i1.c: Regenerated.
	* generated/matmul_i16.c: Regenerated.
	* generated/matmul_i2.c: Regenerated.
	* generated/matmul_i4.c: Regenerated.
	* generated/matmul_i8.c: Regenerated.
	* generated/matmul_l16.c: Regenerated.
	* generated/matmul_l4.c: Regenerated.
	* generated/matmul_l8.c: Regenerated.
	* generated/matmul_r10.c: Regenerated.
	* generated/matmul_r16.c: Regenerated.
	* generated/matmul_r4.c: Regenerated.
	* generated/matmul_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/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/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/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/unpack_c10.c: Regenerated.
	* generated/unpack_c16.c: Regenerated.
	* generated/unpack_c4.c: Regenerated.
	* generated/unpack_c8.c: Regenerated.
	* generated/unpack_i1.c: Regenerated.
	* generated/unpack_i16.c: Regenerated.
	* generated/unpack_i2.c: Regenerated.
	* generated/unpack_i4.c: Regenerated.
	* generated/unpack_i8.c: Regenerated.
	* generated/unpack_r10.c: Regenerated.
	* generated/unpack_r16.c: Regenerated.
	* generated/unpack_r4.c: Regenerated.
	* generated/unpack_r8.c: Regenerated.


Index: intrinsics/eoshift0.c
===================================================================
--- intrinsics/eoshift0.c	(revision 147329)
+++ intrinsics/eoshift0.c	(working copy)
@@ -101,10 +101,10 @@ eoshift0 (gfc_array_char * ret, const gf
     {
       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 = GFC_DESCRIPTOR_EXTENT(array,dim);
Index: m4/in_pack.m4
===================================================================
--- m4/in_pack.m4	(revision 147329)
+++ m4/in_pack.m4	(working copy)
@@ -60,8 +60,8 @@ internal_pack_'rtype_ccode` ('rtype` * s
   for (n = 0; n < dim; n++)
     {
       count[n] = 0;
-      stride[n] = source->dim[n].stride;
-      extent[n] = source->dim[n].ubound + 1 - source->dim[n].lbound;
+      stride[n] = GFC_DESCRIPTOR_STRIDE(source,n);
+      extent[n] = GFC_DESCRIPTOR_EXTENT(source,n);
       if (extent[n] <= 0)
         {
           /* Do nothing.  */
Index: m4/in_unpack.m4
===================================================================
--- m4/in_unpack.m4	(revision 147329)
+++ m4/in_unpack.m4	(working copy)
@@ -55,8 +55,8 @@ internal_unpack_'rtype_ccode` ('rtype` *
   for (n = 0; n < dim; n++)
     {
       count[n] = 0;
-      stride[n] = d->dim[n].stride;
-      extent[n] = d->dim[n].ubound + 1 - d->dim[n].lbound;
+      stride[n] = GFC_DESCRIPTOR_STRIDE(d,n);
+      extent[n] = GFC_DESCRIPTOR_EXTENT(d,n);
       if (extent[n] <= 0)
 	return;
 
Index: m4/matmull.m4
===================================================================
--- m4/matmull.m4	(revision 147329)
+++ m4/matmull.m4	(working copy)
@@ -70,25 +70,22 @@ matmul_'rtype_code` ('rtype` * const res
     {
       if (GFC_DESCRIPTOR_RANK (a) == 1)
         {
-          retarray->dim[0].lbound = 0;
-          retarray->dim[0].ubound = b->dim[1].ubound - b->dim[1].lbound;
-          retarray->dim[0].stride = 1;
+	  GFC_DIMENSION_SET(retarray->dim[0], 0,
+	                    GFC_DESCRIPTOR_EXTENT(b,1) - 1, 1);
         }
       else if (GFC_DESCRIPTOR_RANK (b) == 1)
         {
-          retarray->dim[0].lbound = 0;
-          retarray->dim[0].ubound = a->dim[0].ubound - a->dim[0].lbound;
-          retarray->dim[0].stride = 1;
+	  GFC_DIMENSION_SET(retarray->dim[0], 0,
+	                    GFC_DESCRIPTOR_EXTENT(a,0) - 1, 1);
         }
       else
         {
-          retarray->dim[0].lbound = 0;
-          retarray->dim[0].ubound = a->dim[0].ubound - a->dim[0].lbound;
-          retarray->dim[0].stride = 1;
-          
-          retarray->dim[1].lbound = 0;
-          retarray->dim[1].ubound = b->dim[1].ubound - b->dim[1].lbound;
-          retarray->dim[1].stride = retarray->dim[0].ubound+1;
+	  GFC_DIMENSION_SET(retarray->dim[0], 0,
+	                    GFC_DESCRIPTOR_EXTENT(a,0) - 1, 1);
+
+          GFC_DIMENSION_SET(retarray->dim[1], 0,
+	                    GFC_DESCRIPTOR_EXTENT(b,1) - 1,
+			    GFC_DESCRIPTOR_EXTENT(retarray,0));
         }
           
       retarray->data
@@ -101,8 +98,8 @@ matmul_'rtype_code` ('rtype` * const res
 
 	if (GFC_DESCRIPTOR_RANK (a) == 1)
 	  {
-	    arg_extent = b->dim[1].ubound + 1 - b->dim[1].lbound;
-	    ret_extent = retarray->dim[0].ubound + 1 - retarray->dim[0].lbound;
+	    arg_extent = GFC_DESCRIPTOR_EXTENT(b,1);
+	    ret_extent = GFC_DESCRIPTOR_EXTENT(retarray,0);
 	    if (arg_extent != ret_extent)
 	      runtime_error ("Incorrect extent in return array in"
 			     " MATMUL intrinsic: is %ld, should be %ld",
@@ -110,8 +107,8 @@ matmul_'rtype_code` ('rtype` * const res
 	  }
 	else if (GFC_DESCRIPTOR_RANK (b) == 1)
 	  {
-	    arg_extent = a->dim[0].ubound + 1 - a->dim[0].lbound;
-	    ret_extent = retarray->dim[0].ubound + 1 - retarray->dim[0].lbound;
+	    arg_extent = GFC_DESCRIPTOR_EXTENT(a,0);
+	    ret_extent = GFC_DESCRIPTOR_EXTENT(retarray,0);
 	    if (arg_extent != ret_extent)
 	      runtime_error ("Incorrect extent in return array in"
 			     " MATMUL intrinsic: is %ld, should be %ld",
@@ -119,16 +116,16 @@ matmul_'rtype_code` ('rtype` * const res
 	  }
 	else
 	  {
-	    arg_extent = a->dim[0].ubound + 1 - a->dim[0].lbound;
-	    ret_extent = retarray->dim[0].ubound + 1 - retarray->dim[0].lbound;
+	    arg_extent = GFC_DESCRIPTOR_EXTENT(a,0);
+	    ret_extent = GFC_DESCRIPTOR_EXTENT(retarray,0);
 	    if (arg_extent != ret_extent)
 	      runtime_error ("Incorrect extent in return array in"
 			     " MATMUL intrinsic for dimension 1:"
 			     " is %ld, should be %ld",
 			     (long int) ret_extent, (long int) arg_extent);
 
-	    arg_extent = b->dim[1].ubound + 1 - b->dim[1].lbound;
-	    ret_extent = retarray->dim[1].ubound + 1 - retarray->dim[1].lbound;
+	    arg_extent = GFC_DESCRIPTOR_EXTENT(b,1);
+	    ret_extent = GFC_DESCRIPTOR_EXTENT(retarray,1);
 	    if (arg_extent != ret_extent)
 	      runtime_error ("Incorrect extent in return array in"
 			     " MATMUL intrinsic for dimension 2:"
@@ -167,46 +164,46 @@ sinclude(`matmul_asm_'rtype_code`.m4')dn
 `
   if (GFC_DESCRIPTOR_RANK (retarray) == 1)
     {
-      rxstride = retarray->dim[0].stride;
+      rxstride = GFC_DESCRIPTOR_STRIDE(retarray,0);
       rystride = rxstride;
     }
   else
     {
-      rxstride = retarray->dim[0].stride;
-      rystride = retarray->dim[1].stride;
+      rxstride = GFC_DESCRIPTOR_STRIDE(retarray,0);
+      rystride = GFC_DESCRIPTOR_STRIDE(retarray,1);
     }
 
   /* If we have rank 1 parameters, zero the absent stride, and set the size to
      one.  */
   if (GFC_DESCRIPTOR_RANK (a) == 1)
     {
-      astride = a->dim[0].stride * a_kind;
-      count = a->dim[0].ubound + 1 - a->dim[0].lbound;
+      astride = GFC_DESCRIPTOR_STRIDE_BYTES(a,0);
+      count = GFC_DESCRIPTOR_EXTENT(a,0);
       xstride = 0;
       rxstride = 0;
       xcount = 1;
     }
   else
     {
-      astride = a->dim[1].stride * a_kind;
-      count = a->dim[1].ubound + 1 - a->dim[1].lbound;
-      xstride = a->dim[0].stride * a_kind;
-      xcount = a->dim[0].ubound + 1 - a->dim[0].lbound;
+      astride = GFC_DESCRIPTOR_STRIDE_BYTES(a,1);
+      count = GFC_DESCRIPTOR_EXTENT(a,1);
+      xstride = GFC_DESCRIPTOR_STRIDE_BYTES(a,0);
+      xcount = GFC_DESCRIPTOR_EXTENT(a,0);
     }
   if (GFC_DESCRIPTOR_RANK (b) == 1)
     {
-      bstride = b->dim[0].stride * b_kind;
-      assert(count == b->dim[0].ubound + 1 - b->dim[0].lbound);
+      bstride = GFC_DESCRIPTOR_STRIDE_BYTES(b,0);
+      assert(count == GFC_DESCRIPTOR_EXTENT(b,0));
       ystride = 0;
       rystride = 0;
       ycount = 1;
     }
   else
     {
-      bstride = b->dim[0].stride * b_kind;
-      assert(count == b->dim[0].ubound + 1 - b->dim[0].lbound);
-      ystride = b->dim[1].stride * b_kind;
-      ycount = b->dim[1].ubound + 1 - b->dim[1].lbound;
+      bstride = GFC_DESCRIPTOR_STRIDE_BYTES(b,0);
+      assert(count == GFC_DESCRIPTOR_EXTENT(b,0));
+      ystride = GFC_DESCRIPTOR_STRIDE_BYTES(b,1);
+      ycount = GFC_DESCRIPTOR_EXTENT(b,1);
     }
 
   for (y = 0; y < ycount; y++)
Index: m4/unpack.m4
===================================================================
--- m4/unpack.m4	(revision 147329)
+++ m4/unpack.m4	(working copy)
@@ -91,13 +91,12 @@ unpack0_'rtype_code` ('rtype` *ret, cons
       for (n = 0; n < dim; n++)
 	{
 	  count[n] = 0;
-	  ret->dim[n].stride = rs;
-	  ret->dim[n].lbound = 0;
-	  ret->dim[n].ubound = mask->dim[n].ubound - mask->dim[n].lbound;
-	  extent[n] = ret->dim[n].ubound + 1;
+	  GFC_DIMENSION_SET(ret->dim[n], 0,
+			    GFC_DESCRIPTOR_EXTENT(mask,n) - 1, rs);
+	  extent[n] = GFC_DESCRIPTOR_EXTENT(ret,n);
 	  empty = empty || extent[n] <= 0;
-	  rstride[n] = ret->dim[n].stride;
-	  mstride[n] = mask->dim[n].stride * mask_kind;
+	  rstride[n] = GFC_DESCRIPTOR_STRIDE(ret,n);
+	  mstride[n] = GFC_DESCRIPTOR_STRIDE_BYTES(mask,n);
 	  rs *= extent[n];
 	}
       ret->offset = 0;
@@ -109,10 +108,10 @@ unpack0_'rtype_code` ('rtype` *ret, cons
       for (n = 0; n < dim; n++)
 	{
 	  count[n] = 0;
-	  extent[n] = ret->dim[n].ubound + 1 - ret->dim[n].lbound;
+	  extent[n] = GFC_DESCRIPTOR_EXTENT(ret,n);
 	  empty = empty || extent[n] <= 0;
-	  rstride[n] = ret->dim[n].stride;
-	  mstride[n] = mask->dim[n].stride * mask_kind;
+	  rstride[n] = GFC_DESCRIPTOR_STRIDE(ret,n);
+	  mstride[n] = GFC_DESCRIPTOR_STRIDE_BYTES(mask,n);
 	}
       if (rstride[0] == 0)
 	rstride[0] = 1;
@@ -124,7 +123,7 @@ unpack0_'rtype_code` ('rtype` *ret, cons
   if (mstride[0] == 0)
     mstride[0] = 1;
 
-  vstride0 = vector->dim[0].stride;
+  vstride0 = GFC_DESCRIPTOR_STRIDE(vector,0);
   if (vstride0 == 0)
     vstride0 = 1;
   rstride0 = rstride[0];
@@ -236,14 +235,13 @@ unpack1_'rtype_code` ('rtype` *ret, cons
       for (n = 0; n < dim; n++)
 	{
 	  count[n] = 0;
-	  ret->dim[n].stride = rs;
-	  ret->dim[n].lbound = 0;
-	  ret->dim[n].ubound = mask->dim[n].ubound - mask->dim[n].lbound;
-	  extent[n] = ret->dim[n].ubound + 1;
+	  GFC_DIMENSION_SET(ret->dim[n], 0,
+			    GFC_DESCRIPTOR_EXTENT(mask,n) - 1, rs);
+	  extent[n] = GFC_DESCRIPTOR_EXTENT(ret,n);
 	  empty = empty || extent[n] <= 0;
-	  rstride[n] = ret->dim[n].stride;
-	  fstride[n] = field->dim[n].stride;
-	  mstride[n] = mask->dim[n].stride * mask_kind;
+	  rstride[n] = GFC_DESCRIPTOR_STRIDE(ret,n);
+	  fstride[n] = GFC_DESCRIPTOR_STRIDE(field,n);
+	  mstride[n] = GFC_DESCRIPTOR_STRIDE_BYTES(mask,n);
 	  rs *= extent[n];
 	}
       ret->offset = 0;
@@ -255,11 +253,11 @@ unpack1_'rtype_code` ('rtype` *ret, cons
       for (n = 0; n < dim; n++)
 	{
 	  count[n] = 0;
-	  extent[n] = ret->dim[n].ubound + 1 - ret->dim[n].lbound;
+	  extent[n] = GFC_DESCRIPTOR_EXTENT(ret,n);
 	  empty = empty || extent[n] <= 0;
-	  rstride[n] = ret->dim[n].stride;
-	  fstride[n] = field->dim[n].stride;
-	  mstride[n] = mask->dim[n].stride * mask_kind;
+	  rstride[n] = GFC_DESCRIPTOR_STRIDE(ret,n);
+	  fstride[n] = GFC_DESCRIPTOR_STRIDE(field,n);
+	  mstride[n] = GFC_DESCRIPTOR_STRIDE_BYTES(mask,n);
 	}
       if (rstride[0] == 0)
 	rstride[0] = 1;
@@ -273,7 +271,7 @@ unpack1_'rtype_code` ('rtype` *ret, cons
   if (mstride[0] == 0)
     mstride[0] = 1;
 
-  vstride0 = vector->dim[0].stride;
+  vstride0 = GFC_DESCRIPTOR_STRIDE(vector,0);
   if (vstride0 == 0)
     vstride0 = 1;
   rstride0 = rstride[0];
Index: m4/ifunction_logical.m4
===================================================================
--- m4/ifunction_logical.m4	(revision 147329)
+++ m4/ifunction_logical.m4	(working copy)
@@ -48,25 +48,24 @@ name`'rtype_qual`_'atype_code (rtype * c
 
   src_kind = GFC_DESCRIPTOR_SIZE (array);
 
-  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 * src_kind;
+  delta = GFC_DESCRIPTOR_STRIDE_BYTES(array,dim);
 
   for (n = 0; n < dim; n++)
     {
-      sstride[n] = array->dim[n].stride * src_kind;
-      extent[n] = array->dim[n].ubound + 1 - array->dim[n].lbound;
+      sstride[n] = GFC_DESCRIPTOR_STRIDE_BYTES(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 * src_kind;
-      extent[n] =
-        array->dim[n + 1].ubound + 1 - array->dim[n + 1].lbound;
+      sstride[n] = GFC_DESCRIPTOR_STRIDE_BYTES(array,n + 1);
+      extent[n] = GFC_DESCRIPTOR_EXTENT(array,n + 1);
 
       if (extent[n] < 0)
 	extent[n] = 0;
@@ -74,29 +73,29 @@ 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 = GFC_DESCRIPTOR_STRIDE(retarray,n-1) * extent[n-1];
+
+	  GFC_DIMENSION_SET(retarray->dim[n], 0, extent[n] - 1, str);
+
         }
 
       retarray->offset = 0;
       retarray->dtype = (array->dtype & ~GFC_DTYPE_RANK_MASK) | rank;
 
-      alloc_size = sizeof (rtype_name) * retarray->dim[rank-1].stride
+      alloc_size = sizeof (rtype_name) * GFC_DESCRIPTOR_STRIDE(retarray,rank-1)
     		   * extent[rank-1];
 
       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
@@ -116,8 +115,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 %d:"
@@ -130,7 +128,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;
     }
Index: m4/ifunction.m4
===================================================================
--- m4/ifunction.m4	(revision 147618)
+++ m4/ifunction.m4	(working copy)
@@ -76,7 +76,7 @@ name`'rtype_qual`_'atype_code (rtype * c
           if (n == 0)
 	    str = 1;
           else
-            str = retarray->dim[n-1].stride * extent[n-1];
+            str = GFC_DESCRIPTOR_STRIDE(retarray,n-1) * extent[n-1];
 
 	  GFC_DIMENSION_SET(retarray->dim[n], 0, extent[n] - 1, str);
 
@@ -85,7 +85,7 @@ name`'rtype_qual`_'atype_code (rtype * c
       retarray->offset = 0;
       retarray->dtype = (array->dtype & ~GFC_DTYPE_RANK_MASK) | rank;
 
-      alloc_size = sizeof (rtype_name) * retarray->dim[rank-1].stride
+      alloc_size = sizeof (rtype_name) * GFC_DESCRIPTOR_STRIDE(retarray,rank-1)
     		   * extent[rank-1];
 
       if (alloc_size == 0)
@@ -265,13 +265,13 @@ void
           if (n == 0)
             str = 1;
           else
-            str= retarray->dim[n-1].stride * extent[n-1];
+            str= GFC_DESCRIPTOR_STRIDE(retarray,n-1) * extent[n-1];
 
 	  GFC_DIMENSION_SET(retarray->dim[n], 0, extent[n] - 1, str);
 
         }
 
-      alloc_size = sizeof (rtype_name) * retarray->dim[rank-1].stride
+      alloc_size = sizeof (rtype_name) * GFC_DESCRIPTOR_STRIDE(retarray,rank-1)
     		   * extent[rank-1];
 
       retarray->offset = 0;
@@ -446,7 +446,7 @@ void
           if (n == 0)
             str = 1;
           else
-            str = retarray->dim[n-1].stride * extent[n-1];
+            str = GFC_DESCRIPTOR_STRIDE(retarray,n-1) * extent[n-1];
 
 	  GFC_DIMENSION_SET(retarray->dim[n], 0, extent[n] - 1, str);
 
@@ -455,7 +455,7 @@ void
       retarray->offset = 0;
       retarray->dtype = (array->dtype & ~GFC_DTYPE_RANK_MASK) | rank;
 
-      alloc_size = sizeof (rtype_name) * retarray->dim[rank-1].stride
+      alloc_size = sizeof (rtype_name) * GFC_DESCRIPTOR_STRIDE(retarray,rank-1)
     		   * extent[rank-1];
 
       if (alloc_size == 0)
Index: m4/matmul.m4
===================================================================
--- m4/matmul.m4	(revision 147329)
+++ m4/matmul.m4	(working copy)
@@ -106,25 +106,22 @@ matmul_'rtype_code` ('rtype` * const res
     {
       if (GFC_DESCRIPTOR_RANK (a) == 1)
         {
-          retarray->dim[0].lbound = 0;
-          retarray->dim[0].ubound = b->dim[1].ubound - b->dim[1].lbound;
-          retarray->dim[0].stride = 1;
+	  GFC_DIMENSION_SET(retarray->dim[0], 0,
+	                    GFC_DESCRIPTOR_EXTENT(b,1) - 1, 1);
         }
       else if (GFC_DESCRIPTOR_RANK (b) == 1)
         {
-          retarray->dim[0].lbound = 0;
-          retarray->dim[0].ubound = a->dim[0].ubound - a->dim[0].lbound;
-          retarray->dim[0].stride = 1;
+	  GFC_DIMENSION_SET(retarray->dim[0], 0,
+	                    GFC_DESCRIPTOR_EXTENT(a,0) - 1, 1);
         }
       else
         {
-          retarray->dim[0].lbound = 0;
-          retarray->dim[0].ubound = a->dim[0].ubound - a->dim[0].lbound;
-          retarray->dim[0].stride = 1;
-
-          retarray->dim[1].lbound = 0;
-          retarray->dim[1].ubound = b->dim[1].ubound - b->dim[1].lbound;
-          retarray->dim[1].stride = retarray->dim[0].ubound+1;
+	  GFC_DIMENSION_SET(retarray->dim[0], 0,
+	                    GFC_DESCRIPTOR_EXTENT(a,0) - 1, 1);
+
+          GFC_DIMENSION_SET(retarray->dim[1], 0,
+	                    GFC_DESCRIPTOR_EXTENT(b,1) - 1,
+			    GFC_DESCRIPTOR_EXTENT(retarray,0));
         }
 
       retarray->data
@@ -137,8 +134,8 @@ matmul_'rtype_code` ('rtype` * const res
 
 	if (GFC_DESCRIPTOR_RANK (a) == 1)
 	  {
-	    arg_extent = b->dim[1].ubound + 1 - b->dim[1].lbound;
-	    ret_extent = retarray->dim[0].ubound + 1 - retarray->dim[0].lbound;
+	    arg_extent = GFC_DESCRIPTOR_EXTENT(b,1);
+	    ret_extent = GFC_DESCRIPTOR_EXTENT(retarray,0);
 	    if (arg_extent != ret_extent)
 	      runtime_error ("Incorrect extent in return array in"
 			     " MATMUL intrinsic: is %ld, should be %ld",
@@ -146,8 +143,8 @@ matmul_'rtype_code` ('rtype` * const res
 	  }
 	else if (GFC_DESCRIPTOR_RANK (b) == 1)
 	  {
-	    arg_extent = a->dim[0].ubound + 1 - a->dim[0].lbound;
-	    ret_extent = retarray->dim[0].ubound + 1 - retarray->dim[0].lbound;
+	    arg_extent = GFC_DESCRIPTOR_EXTENT(a,0);
+	    ret_extent = GFC_DESCRIPTOR_EXTENT(retarray,0);
 	    if (arg_extent != ret_extent)
 	      runtime_error ("Incorrect extent in return array in"
 			     " MATMUL intrinsic: is %ld, should be %ld",
@@ -155,16 +152,16 @@ matmul_'rtype_code` ('rtype` * const res
 	  }
 	else
 	  {
-	    arg_extent = a->dim[0].ubound + 1 - a->dim[0].lbound;
-	    ret_extent = retarray->dim[0].ubound + 1 - retarray->dim[0].lbound;
+	    arg_extent = GFC_DESCRIPTOR_EXTENT(a,0);
+	    ret_extent = GFC_DESCRIPTOR_EXTENT(retarray,0);
 	    if (arg_extent != ret_extent)
 	      runtime_error ("Incorrect extent in return array in"
 			     " MATMUL intrinsic for dimension 1:"
 			     " is %ld, should be %ld",
 			     (long int) ret_extent, (long int) arg_extent);
 
-	    arg_extent = b->dim[1].ubound + 1 - b->dim[1].lbound;
-	    ret_extent = retarray->dim[1].ubound + 1 - retarray->dim[1].lbound;
+	    arg_extent = GFC_DESCRIPTOR_EXTENT(b,1);
+	    ret_extent = GFC_DESCRIPTOR_EXTENT(retarray,1);
 	    if (arg_extent != ret_extent)
 	      runtime_error ("Incorrect extent in return array in"
 			     " MATMUL intrinsic for dimension 2:"
@@ -180,43 +177,43 @@ sinclude(`matmul_asm_'rtype_code`.m4')dn
       /* One-dimensional result may be addressed in the code below
 	 either as a row or a column matrix. We want both cases to
 	 work. */
-      rxstride = rystride = retarray->dim[0].stride;
+      rxstride = rystride = GFC_DESCRIPTOR_STRIDE(retarray,0);
     }
   else
     {
-      rxstride = retarray->dim[0].stride;
-      rystride = retarray->dim[1].stride;
+      rxstride = GFC_DESCRIPTOR_STRIDE(retarray,0);
+      rystride = GFC_DESCRIPTOR_STRIDE(retarray,1);
     }
 
 
   if (GFC_DESCRIPTOR_RANK (a) == 1)
     {
       /* Treat it as a a row matrix A[1,count]. */
-      axstride = a->dim[0].stride;
+      axstride = GFC_DESCRIPTOR_STRIDE(a,0);
       aystride = 1;
 
       xcount = 1;
-      count = a->dim[0].ubound + 1 - a->dim[0].lbound;
+      count = GFC_DESCRIPTOR_EXTENT(a,0);
     }
   else
     {
-      axstride = a->dim[0].stride;
-      aystride = a->dim[1].stride;
+      axstride = GFC_DESCRIPTOR_STRIDE(a,0);
+      aystride = GFC_DESCRIPTOR_STRIDE(a,1);
 
-      count = a->dim[1].ubound + 1 - a->dim[1].lbound;
-      xcount = a->dim[0].ubound + 1 - a->dim[0].lbound;
+      count = GFC_DESCRIPTOR_EXTENT(a,1);
+      xcount = GFC_DESCRIPTOR_EXTENT(a,0);
     }
 
-  if (count != b->dim[0].ubound + 1 - b->dim[0].lbound)
+  if (count != GFC_DESCRIPTOR_EXTENT(b,0))
     {
-      if (count > 0 || b->dim[0].ubound + 1 - b->dim[0].lbound > 0)
+      if (count > 0 || GFC_DESCRIPTOR_EXTENT(b,0) > 0)
 	runtime_error ("dimension of array B incorrect in MATMUL intrinsic");
     }
 
   if (GFC_DESCRIPTOR_RANK (b) == 1)
     {
       /* Treat it as a column matrix B[count,1] */
-      bxstride = b->dim[0].stride;
+      bxstride = GFC_DESCRIPTOR_STRIDE(b,0);
 
       /* bystride should never be used for 1-dimensional b.
 	 in case it is we want it to cause a segfault, rather than
@@ -226,9 +223,9 @@ sinclude(`matmul_asm_'rtype_code`.m4')dn
     }
   else
     {
-      bxstride = b->dim[0].stride;
-      bystride = b->dim[1].stride;
-      ycount = b->dim[1].ubound + 1 - b->dim[1].lbound;
+      bxstride = GFC_DESCRIPTOR_STRIDE(b,0);
+      bystride = GFC_DESCRIPTOR_STRIDE(b,1);
+      ycount = GFC_DESCRIPTOR_EXTENT(b,1);
     }
 
   abase = a->data;

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