diff options
author | tkoenig <tkoenig@138bc75d-0d04-0410-961f-82ee72b054a4> | 2008-04-13 20:15:58 +0000 |
---|---|---|
committer | tkoenig <tkoenig@138bc75d-0d04-0410-961f-82ee72b054a4> | 2008-04-13 20:15:58 +0000 |
commit | ed3634f6081c293b5b93fdc8a90f5e45b70445d8 (patch) | |
tree | e022b93b7ac1c858cd02bc0f837fdaae49b136ff /libgfortran/intrinsics/pack_generic.c | |
parent | 5207e7191fb89a5bc8f1a710d6a0be83bfb890ca (diff) | |
download | gcc-ed3634f6081c293b5b93fdc8a90f5e45b70445d8.tar.gz |
2008-04-13 Thomas Koenig <tkoenig@gcc.gnu.org>
Francois-Xavier Coudert <fxcoudert@gcc.gnu.org>
PR libfortran/32972
PR libfortran/32512
configure.ac: Add test for uintptr_t.
configure: Regenerated.
config.h.in: Regenerated.
* libgfortran.h: GFC_DTYPE_DERIVED_1: New macro.
GFC_DTYPE_DERIVED_2: New macro.
GFC_DTYPE_DERIVED_4: New macro.
GFC_DTYPE_DERIVED_8: New macro.
GFC_DTYPE_DERIVED_16: New macro.
GFC_UNALIGNED_2: New macro.
GFC_UNALIGNED_4: New macro.
GFC_UNALIGNED_8: New macro.
GFC_UNALIGNED_16: New macro.
intptr_t: Define if we don't have it.
uintptr_t: Likewise.
* runtime/backtrace.c (show_backtrace): Use intptr_t.
* intrinsics/signal.c (signal_sub): Likewise.
(signal_sub_int): Likewise.
(alarm_sub_int_i4): Likewise.
* intrinsics/spread_generic.c (spread): Use the integer
routines for handling derived types of sizes 1, 2, 4, 8 and 16
if the alignment of all pointers is correct.
(spread_scalar): Likewise.
* intrinsics/pack_generic.c (pack): Likewise.
Use GFD_DTYPE_TYPE_SIZE to avoid nested switch statements.
* intrinsics/unpack_generic.c (unpack1): Likewise.
(unpack0): Likewise.
* runtime/in_pack_generic.c (internal_pack): Likewise.
* runtime/in_unpack_generic.c (internal_unpack): Likewise.
2008-04-13 Thomas Koenig <tkoenig@gcc.gnu.org>
PR libfortran/32972
PR libfortran/32512
* gfortran.dg/internal_pack_1.f90: Add test for derived type.
* gfortran.dg/intrinsic_spread_1.f90: Likewise.
* gfortran.dg/intrinsic_pack_1.f90: Likewise.
* gfortran.dg/intrinsic_unpack_1.f90: Likewise.
git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@134245 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'libgfortran/intrinsics/pack_generic.c')
-rw-r--r-- | libgfortran/intrinsics/pack_generic.c | 182 |
1 files changed, 114 insertions, 68 deletions
diff --git a/libgfortran/intrinsics/pack_generic.c b/libgfortran/intrinsics/pack_generic.c index 2bd09913f00..e282c916502 100644 --- a/libgfortran/intrinsics/pack_generic.c +++ b/libgfortran/intrinsics/pack_generic.c @@ -313,101 +313,147 @@ void pack (gfc_array_char *ret, const gfc_array_char *array, const gfc_array_l1 *mask, const gfc_array_char *vector) { - int type; + index_type type_size; index_type size; - type = GFC_DESCRIPTOR_TYPE (array); - size = GFC_DESCRIPTOR_SIZE (array); + type_size = GFC_DTYPE_TYPE_SIZE(array); - switch(type) + switch(type_size) { - case GFC_DTYPE_INTEGER: - case GFC_DTYPE_LOGICAL: - switch(size) - { - case sizeof (GFC_INTEGER_1): - pack_i1 ((gfc_array_i1 *) ret, (gfc_array_i1 *) array, - (gfc_array_l1 *) mask, (gfc_array_i1 *) vector); - return; + case GFC_DTYPE_LOGICAL_1: + case GFC_DTYPE_INTEGER_1: + case GFC_DTYPE_DERIVED_1: + pack_i1 ((gfc_array_i1 *) ret, (gfc_array_i1 *) array, + (gfc_array_l1 *) mask, (gfc_array_i1 *) vector); + return; - case sizeof (GFC_INTEGER_2): - pack_i2 ((gfc_array_i2 *) ret, (gfc_array_i2 *) array, - (gfc_array_l1 *) mask, (gfc_array_i2 *) vector); - return; + case GFC_DTYPE_LOGICAL_2: + case GFC_DTYPE_INTEGER_2: + pack_i2 ((gfc_array_i2 *) ret, (gfc_array_i2 *) array, + (gfc_array_l1 *) mask, (gfc_array_i2 *) vector); + return; - case sizeof (GFC_INTEGER_4): - pack_i4 ((gfc_array_i4 *) ret, (gfc_array_i4 *) array, - (gfc_array_l1 *) mask, (gfc_array_i4 *) vector); - return; + case GFC_DTYPE_LOGICAL_4: + case GFC_DTYPE_INTEGER_4: - case sizeof (GFC_INTEGER_8): - pack_i8 ((gfc_array_i8 *) ret, (gfc_array_i8 *) array, - (gfc_array_l1 *) mask, (gfc_array_i8 *) vector); - return; + pack_i4 ((gfc_array_i4 *) ret, (gfc_array_i4 *) array, + (gfc_array_l1 *) mask, (gfc_array_i4 *) vector); + return; + + case GFC_DTYPE_LOGICAL_8: + case GFC_DTYPE_INTEGER_8: + + pack_i8 ((gfc_array_i8 *) ret, (gfc_array_i8 *) array, + (gfc_array_l1 *) mask, (gfc_array_i8 *) vector); + return; #ifdef HAVE_GFC_INTEGER_16 - case sizeof (GFC_INTEGER_16): - pack_i16 ((gfc_array_i16 *) ret, (gfc_array_i16 *) array, - (gfc_array_l1 *) mask, (gfc_array_i16 *) vector); - return; + case GFC_DTYPE_LOGICAL_16: + case GFC_DTYPE_INTEGER_16: + + pack_i16 ((gfc_array_i16 *) ret, (gfc_array_i16 *) array, + (gfc_array_l1 *) mask, (gfc_array_i16 *) vector); + return; #endif - } - case GFC_DTYPE_REAL: - switch(size) - { - case sizeof (GFC_REAL_4): - pack_r4 ((gfc_array_r4 *) ret, (gfc_array_r4 *) array, - (gfc_array_l1 *) mask, (gfc_array_r4 *) vector); - return; + case GFC_DTYPE_REAL_4: + pack_r4 ((gfc_array_r4 *) ret, (gfc_array_r4 *) array, + (gfc_array_l1 *) mask, (gfc_array_r4 *) vector); + return; - case sizeof (GFC_REAL_8): - pack_r8 ((gfc_array_r8 *) ret, (gfc_array_r8 *) array, - (gfc_array_l1 *) mask, (gfc_array_r8 *) vector); - return; + case GFC_DTYPE_REAL_8: + pack_r8 ((gfc_array_r8 *) ret, (gfc_array_r8 *) array, + (gfc_array_l1 *) mask, (gfc_array_r8 *) vector); + return; #ifdef HAVE_GFC_REAL_10 - case sizeof (GFC_REAL_10): - pack_r10 ((gfc_array_r10 *) ret, (gfc_array_r10 *) array, - (gfc_array_l1 *) mask, (gfc_array_r10 *) vector); - return; + case GFC_DTYPE_REAL_10: + pack_r10 ((gfc_array_r10 *) ret, (gfc_array_r10 *) array, + (gfc_array_l1 *) mask, (gfc_array_r10 *) vector); + return; #endif #ifdef HAVE_GFC_REAL_16 - case sizeof (GFC_REAL_16): - pack_r16 ((gfc_array_r16 *) ret, (gfc_array_r16 *) array, - (gfc_array_l1 *) mask, (gfc_array_r16 *) vector); - return; + case GFC_DTYPE_REAL_16: + pack_r16 ((gfc_array_r16 *) ret, (gfc_array_r16 *) array, + (gfc_array_l1 *) mask, (gfc_array_r16 *) vector); + return; #endif - } - case GFC_DTYPE_COMPLEX: - switch(size) - { - case sizeof (GFC_COMPLEX_4): - pack_c4 ((gfc_array_c4 *) ret, (gfc_array_c4 *) array, - (gfc_array_l1 *) mask, (gfc_array_c4 *) vector); - return; + case GFC_DTYPE_COMPLEX_4: + pack_c4 ((gfc_array_c4 *) ret, (gfc_array_c4 *) array, + (gfc_array_l1 *) mask, (gfc_array_c4 *) vector); + return; - case sizeof (GFC_COMPLEX_8): - pack_c8 ((gfc_array_c8 *) ret, (gfc_array_c8 *) array, - (gfc_array_l1 *) mask, (gfc_array_c8 *) vector); - return; + case GFC_DTYPE_COMPLEX_8: + pack_c8 ((gfc_array_c8 *) ret, (gfc_array_c8 *) array, + (gfc_array_l1 *) mask, (gfc_array_c8 *) vector); + return; #ifdef HAVE_GFC_COMPLEX_10 - case sizeof (GFC_COMPLEX_10): - pack_c10 ((gfc_array_c10 *) ret, (gfc_array_c10 *) array, - (gfc_array_l1 *) mask, (gfc_array_c10 *) vector); - return; + case GFC_DTYPE_COMPLEX_10: + pack_c10 ((gfc_array_c10 *) ret, (gfc_array_c10 *) array, + (gfc_array_l1 *) mask, (gfc_array_c10 *) vector); + return; #endif #ifdef HAVE_GFC_COMPLEX_16 - case sizeof (GFC_COMPLEX_16): - pack_c16 ((gfc_array_c16 *) ret, (gfc_array_c16 *) array, - (gfc_array_l1 *) mask, (gfc_array_c16 *) vector); - return; + case GFC_DTYPE_COMPLEX_16: + pack_c16 ((gfc_array_c16 *) ret, (gfc_array_c16 *) array, + (gfc_array_l1 *) mask, (gfc_array_c16 *) vector); + return; #endif + /* For derived types, let's check the actual alignment of the + data pointers. If they are aligned, we can safely call + the unpack functions. */ + + case GFC_DTYPE_DERIVED_2: + if (GFC_UNALIGNED_2(ret->data) || GFC_UNALIGNED_2(array->data) + || GFC_UNALIGNED_2(vector->data)) + break; + else + { + pack_i2 ((gfc_array_i2 *) ret, (gfc_array_i2 *) array, + (gfc_array_l1 *) mask, (gfc_array_i2 *) vector); + return; + } + + case GFC_DTYPE_DERIVED_4: + if (GFC_UNALIGNED_4(ret->data) || GFC_UNALIGNED_4(array->data) + || GFC_UNALIGNED_4(vector->data)) + break; + else + { + pack_i4 ((gfc_array_i4 *) ret, (gfc_array_i4 *) array, + (gfc_array_l1 *) mask, (gfc_array_i4 *) vector); + return; + } + + case GFC_DTYPE_DERIVED_8: + if (GFC_UNALIGNED_8(ret->data) || GFC_UNALIGNED_8(array->data) + || GFC_UNALIGNED_8(vector->data)) + break; + else + { + pack_i8 ((gfc_array_i8 *) ret, (gfc_array_i8 *) array, + (gfc_array_l1 *) mask, (gfc_array_i8 *) vector); } + +#ifdef HAVE_GFC_INTEGER_16 + case GFC_DTYPE_DERIVED_16: + if (GFC_UNALIGNED_16(ret->data) || GFC_UNALIGNED_16(array->data) + || GFC_UNALIGNED_16(vector->data)) + break; + else + { + pack_i16 ((gfc_array_i16 *) ret, (gfc_array_i16 *) array, + (gfc_array_l1 *) mask, (gfc_array_i16 *) vector); + return; + } +#endif + } + + size = GFC_DESCRIPTOR_SIZE (array); pack_internal (ret, array, mask, vector, size); } |