diff options
author | bstarynk <bstarynk@138bc75d-0d04-0410-961f-82ee72b054a4> | 2009-06-22 08:25:43 +0000 |
---|---|---|
committer | bstarynk <bstarynk@138bc75d-0d04-0410-961f-82ee72b054a4> | 2009-06-22 08:25:43 +0000 |
commit | e9a597fe457cc2062847d037eff33da8eed5dbc7 (patch) | |
tree | 44d4b4d401a22261e056fbd78171ceccf1ac25c5 /libgfortran/m4/spread.m4 | |
parent | e6f9d301a4a6085a086530c7b54414d03ceff5dd (diff) | |
download | gcc-e9a597fe457cc2062847d037eff33da8eed5dbc7.tar.gz |
2009-06-22 Basile Starynkevitch <basile@starynkevitch.net>
MELT branch merged with trunk r148777
git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/branches/melt-branch@148778 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'libgfortran/m4/spread.m4')
-rw-r--r-- | libgfortran/m4/spread.m4 | 46 |
1 files changed, 22 insertions, 24 deletions
diff --git a/libgfortran/m4/spread.m4 b/libgfortran/m4/spread.m4 index 84ea00c3301..5e73d97423a 100644 --- a/libgfortran/m4/spread.m4 +++ b/libgfortran/m4/spread.m4 @@ -70,6 +70,9 @@ spread_'rtype_code` ('rtype` *ret, const 'rtype` *source, 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 'rtype` *source, 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 'rtype` *source, { 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 'rtype` *source, 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 'rtype` *source, 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 'rtype` *source, { 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, const 'rtype_name` *source, { 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++) { |