diff options
author | tkoenig <tkoenig@138bc75d-0d04-0410-961f-82ee72b054a4> | 2009-06-21 19:24:55 +0000 |
---|---|---|
committer | tkoenig <tkoenig@138bc75d-0d04-0410-961f-82ee72b054a4> | 2009-06-21 19:24:55 +0000 |
commit | 827aef63c4ec0ed551bd722b147d88e485585eb9 (patch) | |
tree | 0f6ecc4005b1035630f9b5894ef6e31b9a0fc204 /libgfortran/m4 | |
parent | 0a77b1e6f3e1fc1bfe6379f179c3f49dcc44e626 (diff) | |
download | gcc-827aef63c4ec0ed551bd722b147d88e485585eb9.tar.gz |
2009-06-21 Thomas Koenig <tkoenig@gcc.gnu.org>
PR fortran/37577
Port from fortran-dev
* runtime/in_pack_generic (internal_pack): Remove unnecessary
test for stride == 0.
* runtime/in_unpack_generic.c (internal_unpack): Likewise.
* intrinsics/iso_c_binding.c (c_f_pointer_u0): Take care
of stride in "shape" argument. Use array access macros for
accessing array descriptors.
* libgfortran.h (struct descriptor_dimension): Change stride
to _stride, lbound to _lbound and ubound to _ubound.
(GFC_DIMENSION_LBOUND): Use new name(s) in struct
descriptor_dimension.
(GFC_DIMENSION_UBOUND): Likewise.
(GFC_DIMENSION_STRIDE): Likewise.
(GFC_DIMENSION_EXTENT): Likewise.
(GFC_DIMENSION_SET): Likewise.
(GFC_DESCRIPTOR_LBOUND): Likewise.
(GFC_DESCRIPTOR_UBOUND): Likewise.
(GFC_DESCRIPTOR_EXTENT): Likewise.
(GFC_DESCRIPTOR_STRIDE): Likewise.
* io/transfer.c (transfer_array): Use array access macros.
Use byte-sized strides.
* 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.
* 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.
* intrinsics/pack_generic.c (pack_internal): Use array access
macros for accessing array descriptors.
(pack_s_internal): Likewise.
* intrinsics/transpose_generic.c (transpose_internal): Remove
size argument, calculate from array descriptor. Use array
access macros for accessing array descriptors.
(transpose): Remove size argument from call.
(transpoe_char): Likewise.
(transpose_char4): Likewise.
* intrinsics/move_alloc.c (move_alloc): Use array access macros
for accessing array descriptors.
* intrinsics/spread_generic.c (spread_internal): Remove size
argument, calculate from array descriptor. Use array access
macros for accessing array descriptors.
(spread_internal_scalar): Likewise.
(spread): Remove size argument from call to spread_internal.
(spread_char): Mark argument source_length as unused.
Remove size argument from call to spread_internal.
(spread_char4): Likewise.
(spread_char_scalar): Likewise.
(spread_char4_scalar): Likewise.
* intrinsics/unpack_generic.c (unpack_internal): Use array access
macros for accessing array descriptors.
* intrinsics/eoshift2.c (eoshift2): Remove size argument, calculate
from array descriptor instead. Use array access macros for
accessing array descriptors.
(eoshift2_##N): Remove size argument from call to eoshift2.
(eoshift2_##N_##char): Likewise.
(eoshift2_##N_##char4): Likewise.
* intrinsics/reshape_generic.c (reshape_internal): Use array
access macross for accessing array descriptors.
* libgfortran.h: Introduce new macros GFC_DIMENSION_LBOUND,
GFC_DIMENSION_UBOUND,GFC_DIMENSION_STRIDE, GFC_DIMENSION_EXTENT,
GFC_DIMENSION_SET, GFC_DESCRIPTOR_LBOUND, GFC_DESCRIPTOR_UBOUND,
GFC_DESCRIPTOR_EXTENT, GFC_DESCRIPTOR_EXTENT_BYTES,
GFC_DESCRIPTOR_STRIDE, GFC_DESCRIPTOR_STRIDE_BYTES
* runtime/in_pack_generic.c (internal_pack): Use new macros
for array descriptor access.
* runtime/in_unpack_generic.c (internal_unpack): Likewise.
* intrinsics/dtime.c (dtime_sub): Likewise.
* intrinsics/cshift0 (cshift0): Remove argument size,
calculate directly from the array descriptor. Use new macros
for array descriptor access.
* cshift0_##N: Remove shift argument in call to cshift0.
* cshift0_##N_char: Mark array_length as unused. Remove
array_length in call to cshift0.
* cshift0_##N_char4: Likewise.
* intrisics/etime.c: Use new macros for array descriptor access.
* intrinsics/stat.c (stat_i4_sub_0): Likewise.
(stat_i8_sub_0): Likewise.
(fstat_i4_sub): Likewise.
(fstat_i8_sub): Likewise.
* intrinsics/date_and_time.c (date_and_time): Likewise.
(secnds): Likewise.
(itime_i4): Likewise.
(itime_i8): Likewise.
(idate_i4): Likewise.
(idate_i8): Likewise.
(gmtime_i4): Likewise.
(gmtime_i8): Likewise.
(ltime_i4): Likewise.
(litme_i8): Likewise.
* intrinsics/associated.c (associated): Likewise.
* intrinsics/eoshift0.c (eoshift0): Likewise.
* intriniscs/size.c (size0): Likewise.
* intrinsics/random.c (arandom_r4): Likewise.
(arandom_r8): Likewise.
(arandom_r10): Likewise.
(arandom_r16): Likewise.
(random_seed_i4): Likewise.
(random_seed_i8): Likewise.
* io/list_read.c (nml_parse_qualifier): Likewise.
(nml_touch_nodes): Likewise.
(nml_read_obj): Likewise.
(get_name): Likewise.
* io/transfer.c (transfer_array): Likewise.
(init_loop_spec): Likewise.
(st_set_nml_var_dim): Likewise.
* io/write.c (nml_write_obj): Likewise.
(obj_loop): Likewise.
* 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/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/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/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.
* 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.
git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@148769 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'libgfortran/m4')
-rw-r--r-- | libgfortran/m4/cshift0.m4 | 12 | ||||
-rw-r--r-- | libgfortran/m4/cshift1.m4 | 42 | ||||
-rw-r--r-- | libgfortran/m4/eoshift1.m4 | 43 | ||||
-rw-r--r-- | libgfortran/m4/eoshift3.m4 | 45 | ||||
-rw-r--r-- | libgfortran/m4/iforeach.m4 | 38 | ||||
-rw-r--r-- | libgfortran/m4/ifunction.m4 | 108 | ||||
-rw-r--r-- | libgfortran/m4/ifunction_logical.m4 | 34 | ||||
-rw-r--r-- | libgfortran/m4/in_pack.m4 | 4 | ||||
-rw-r--r-- | libgfortran/m4/in_unpack.m4 | 4 | ||||
-rw-r--r-- | libgfortran/m4/matmul.m4 | 67 | ||||
-rw-r--r-- | libgfortran/m4/matmull.m4 | 69 | ||||
-rw-r--r-- | libgfortran/m4/pack.m4 | 20 | ||||
-rw-r--r-- | libgfortran/m4/reshape.m4 | 32 | ||||
-rw-r--r-- | libgfortran/m4/shape.m4 | 6 | ||||
-rw-r--r-- | libgfortran/m4/spread.m4 | 46 | ||||
-rw-r--r-- | libgfortran/m4/transpose.m4 | 30 | ||||
-rw-r--r-- | libgfortran/m4/unpack.m4 | 42 |
17 files changed, 318 insertions, 324 deletions
diff --git a/libgfortran/m4/cshift0.m4 b/libgfortran/m4/cshift0.m4 index da385cbfbfe..0c5e0158eec 100644 --- a/libgfortran/m4/cshift0.m4 +++ b/libgfortran/m4/cshift0.m4 @@ -70,20 +70,20 @@ cshift0_'rtype_code` ('rtype` *ret, const 'rtype` *array, ssize_t shift, { 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++; } } diff --git a/libgfortran/m4/cshift1.m4 b/libgfortran/m4/cshift1.m4 index 3c5ff5e6618..22b61854ffe 100644 --- a/libgfortran/m4/cshift1.m4 +++ b/libgfortran/m4/cshift1.m4 @@ -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 ret, 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 ret, 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, 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 ret, { 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 * const restrict ret, 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_char * const restrict ret, 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_char * const restrict ret, 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' diff --git a/libgfortran/m4/eoshift1.m4 b/libgfortran/m4/eoshift1.m4 index 1ecf0a95421..831277cf413 100644 --- a/libgfortran/m4/eoshift1.m4 +++ b/libgfortran/m4/eoshift1.m4 @@ -38,7 +38,7 @@ eoshift1 (gfc_array_char * const restrict ret, 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 restrict ret, 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 restrict ret, soffset = 0; roffset = 0; + size = GFC_DESCRIPTOR_SIZE(array); + if (pwhich) which = *pwhich - 1; else @@ -89,13 +92,18 @@ eoshift1 (gfc_array_char * const restrict ret, 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 restrict ret, { 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 restrict ret, 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_char * const restrict ret, 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_char * const restrict ret, 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)); } diff --git a/libgfortran/m4/eoshift3.m4 b/libgfortran/m4/eoshift3.m4 index 902c3cdbffa..e6b29599ef0 100644 --- a/libgfortran/m4/eoshift3.m4 +++ b/libgfortran/m4/eoshift3.m4 @@ -38,7 +38,7 @@ eoshift3 (gfc_array_char * const restrict ret, 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 restrict ret, 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 restrict ret, soffset = 0; roffset = 0; + size = GFC_DESCRIPTOR_SIZE(array); + if (pwhich) which = *pwhich - 1; else @@ -90,13 +93,18 @@ eoshift3 (gfc_array_char * const restrict ret, 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 restrict ret, { 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 restrict ret, 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_char * const restrict ret, 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_char * const restrict ret, 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)); } diff --git a/libgfortran/m4/iforeach.m4 b/libgfortran/m4/iforeach.m4 index b620c653f1a..0960d22aeb4 100644 --- a/libgfortran/m4/iforeach.m4 +++ b/libgfortran/m4/iforeach.m4 @@ -27,9 +27,7 @@ name`'rtype_qual`_'atype_code (rtype * const restrict retarray, 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 * const restrict retarray, 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 * const restrict retarray, } } - 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 ; diff --git a/libgfortran/m4/ifunction.m4 b/libgfortran/m4/ifunction.m4 index e0c168e2e48..6785eb3c43f 100644 --- a/libgfortran/m4/ifunction.m4 +++ b/libgfortran/m4/ifunction.m4 @@ -45,24 +45,23 @@ name`'rtype_qual`_'atype_code (rtype * const restrict retarray, 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,30 +69,31 @@ name`'rtype_qual`_'atype_code (rtype * const restrict retarray, 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 retarray->data = internal_malloc_size (alloc_size); @@ -112,8 +112,7 @@ name`'rtype_qual`_'atype_code (rtype * const restrict retarray, { 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 * const restrict retarray, 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,19 +258,20 @@ 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= 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; @@ -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,29 +439,29 @@ 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 = 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 @@ -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; diff --git a/libgfortran/m4/ifunction_logical.m4 b/libgfortran/m4/ifunction_logical.m4 index da6b4ae2640..d1d2dd09c44 100644 --- a/libgfortran/m4/ifunction_logical.m4 +++ b/libgfortran/m4/ifunction_logical.m4 @@ -48,25 +48,24 @@ name`'rtype_qual`_'atype_code (rtype * const restrict retarray, 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 * const restrict retarray, 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 * const restrict retarray, { 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 * const restrict retarray, 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; } diff --git a/libgfortran/m4/in_pack.m4 b/libgfortran/m4/in_pack.m4 index b54ea04d723..a4337aad8f7 100644 --- a/libgfortran/m4/in_pack.m4 +++ b/libgfortran/m4/in_pack.m4 @@ -60,8 +60,8 @@ internal_pack_'rtype_ccode` ('rtype` * source) 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. */ diff --git a/libgfortran/m4/in_unpack.m4 b/libgfortran/m4/in_unpack.m4 index af7114501a2..661c54e1da5 100644 --- a/libgfortran/m4/in_unpack.m4 +++ b/libgfortran/m4/in_unpack.m4 @@ -55,8 +55,8 @@ internal_unpack_'rtype_ccode` ('rtype` * d, const 'rtype_name` * src) 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; diff --git a/libgfortran/m4/matmul.m4 b/libgfortran/m4/matmul.m4 index 8ad1bd117c2..bb42f2a6c47 100644 --- a/libgfortran/m4/matmul.m4 +++ b/libgfortran/m4/matmul.m4 @@ -106,25 +106,22 @@ matmul_'rtype_code` ('rtype` * const restrict retarray, { 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; + GFC_DIMENSION_SET(retarray->dim[0], 0, + GFC_DESCRIPTOR_EXTENT(a,0) - 1, 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[1], 0, + GFC_DESCRIPTOR_EXTENT(b,1) - 1, + GFC_DESCRIPTOR_EXTENT(retarray,0)); } retarray->data @@ -137,8 +134,8 @@ matmul_'rtype_code` ('rtype` * const restrict retarray, 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 restrict retarray, } 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 restrict retarray, } 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')dnl /* 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')dnl } 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; diff --git a/libgfortran/m4/matmull.m4 b/libgfortran/m4/matmull.m4 index d971d3da7b4..c5bad25f78a 100644 --- a/libgfortran/m4/matmull.m4 +++ b/libgfortran/m4/matmull.m4 @@ -70,25 +70,22 @@ matmul_'rtype_code` ('rtype` * const restrict retarray, { 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 restrict retarray, 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 restrict retarray, } 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 restrict retarray, } 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')dnl ` 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++) diff --git a/libgfortran/m4/pack.m4 b/libgfortran/m4/pack.m4 index 16b80731f76..910ffdcaac1 100644 --- a/libgfortran/m4/pack.m4 +++ b/libgfortran/m4/pack.m4 @@ -123,11 +123,11 @@ pack_'rtype_code` ('rtype` *ret, const 'rtype` *array, 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 'rtype` *array, { /* 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 'rtype` *array, 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 'rtype` *array, /* 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 'rtype` *array, } } - 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 'rtype` *array, /* 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; diff --git a/libgfortran/m4/reshape.m4 b/libgfortran/m4/reshape.m4 index 5240e386636..4052a5ecc15 100644 --- a/libgfortran/m4/reshape.m4 +++ b/libgfortran/m4/reshape.m4 @@ -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 restrict ret, 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 restrict ret, 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 restrict ret, 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 restrict ret, 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 restrict ret, 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 restrict ret, 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 restrict ret, 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 restrict ret, 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 restrict ret, 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; diff --git a/libgfortran/m4/shape.m4 b/libgfortran/m4/shape.m4 index b189f804e55..eadd3b9b945 100644 --- a/libgfortran/m4/shape.m4 +++ b/libgfortran/m4/shape.m4 @@ -43,14 +43,14 @@ shape_'rtype_kind` ('rtype` * const restrict ret, 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 ; } } 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++) { diff --git a/libgfortran/m4/transpose.m4 b/libgfortran/m4/transpose.m4 index 8c50767fc9e..34c2d6c06aa 100644 --- a/libgfortran/m4/transpose.m4 +++ b/libgfortran/m4/transpose.m4 @@ -55,13 +55,11 @@ transpose_'rtype_code` ('rtype` * const restrict ret, 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; + GFC_DIMENSION_SET(ret->dim[0], 0, GFC_DESCRIPTOR_EXTENT(source,1) - 1, + 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[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 restrict ret, { 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 restrict ret, " 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 restrict ret, } - 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; diff --git a/libgfortran/m4/unpack.m4 b/libgfortran/m4/unpack.m4 index a26128c7835..bf348aebe1f 100644 --- a/libgfortran/m4/unpack.m4 +++ b/libgfortran/m4/unpack.m4 @@ -91,13 +91,12 @@ unpack0_'rtype_code` ('rtype` *ret, const 'rtype` *vector, 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, const 'rtype` *vector, 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, const 'rtype` *vector, 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, const 'rtype` *vector, 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, const 'rtype` *vector, 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, const 'rtype` *vector, 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]; |