unpack_generic.c 18 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635
  1. /* Generic implementation of the UNPACK intrinsic
  2. Copyright (C) 2002-2015 Free Software Foundation, Inc.
  3. Contributed by Paul Brook <paul@nowt.org>
  4. This file is part of the GNU Fortran runtime library (libgfortran).
  5. Libgfortran is free software; you can redistribute it and/or
  6. modify it under the terms of the GNU General Public
  7. License as published by the Free Software Foundation; either
  8. version 3 of the License, or (at your option) any later version.
  9. Ligbfortran is distributed in the hope that it will be useful,
  10. but WITHOUT ANY WARRANTY; without even the implied warranty of
  11. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  12. GNU General Public License for more details.
  13. Under Section 7 of GPL version 3, you are granted additional
  14. permissions described in the GCC Runtime Library Exception, version
  15. 3.1, as published by the Free Software Foundation.
  16. You should have received a copy of the GNU General Public License and
  17. a copy of the GCC Runtime Library Exception along with this program;
  18. see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
  19. <http://www.gnu.org/licenses/>. */
  20. #include "libgfortran.h"
  21. #include <stdlib.h>
  22. #include <assert.h>
  23. #include <string.h>
  24. /* All the bounds checking for unpack in one function. If field is NULL,
  25. we don't check it, for the unpack0 functions. */
  26. static void
  27. unpack_bounds (gfc_array_char *ret, const gfc_array_char *vector,
  28. const gfc_array_l1 *mask, const gfc_array_char *field)
  29. {
  30. index_type vec_size, mask_count;
  31. vec_size = size0 ((array_t *) vector);
  32. mask_count = count_0 (mask);
  33. if (vec_size < mask_count)
  34. runtime_error ("Incorrect size of return value in UNPACK"
  35. " intrinsic: should be at least %ld, is"
  36. " %ld", (long int) mask_count,
  37. (long int) vec_size);
  38. if (field != NULL)
  39. bounds_equal_extents ((array_t *) field, (array_t *) mask,
  40. "FIELD", "UNPACK");
  41. if (ret->base_addr != NULL)
  42. bounds_equal_extents ((array_t *) ret, (array_t *) mask,
  43. "return value", "UNPACK");
  44. }
  45. static void
  46. unpack_internal (gfc_array_char *ret, const gfc_array_char *vector,
  47. const gfc_array_l1 *mask, const gfc_array_char *field,
  48. index_type size)
  49. {
  50. /* r.* indicates the return array. */
  51. index_type rstride[GFC_MAX_DIMENSIONS];
  52. index_type rstride0;
  53. index_type rs;
  54. char * restrict rptr;
  55. /* v.* indicates the vector array. */
  56. index_type vstride0;
  57. char *vptr;
  58. /* f.* indicates the field array. */
  59. index_type fstride[GFC_MAX_DIMENSIONS];
  60. index_type fstride0;
  61. const char *fptr;
  62. /* m.* indicates the mask array. */
  63. index_type mstride[GFC_MAX_DIMENSIONS];
  64. index_type mstride0;
  65. const GFC_LOGICAL_1 *mptr;
  66. index_type count[GFC_MAX_DIMENSIONS];
  67. index_type extent[GFC_MAX_DIMENSIONS];
  68. index_type n;
  69. index_type dim;
  70. int empty;
  71. int mask_kind;
  72. empty = 0;
  73. mptr = mask->base_addr;
  74. /* Use the same loop for all logical types, by using GFC_LOGICAL_1
  75. and using shifting to address size and endian issues. */
  76. mask_kind = GFC_DESCRIPTOR_SIZE (mask);
  77. if (mask_kind == 1 || mask_kind == 2 || mask_kind == 4 || mask_kind == 8
  78. #ifdef HAVE_GFC_LOGICAL_16
  79. || mask_kind == 16
  80. #endif
  81. )
  82. {
  83. /* Don't convert a NULL pointer as we use test for NULL below. */
  84. if (mptr)
  85. mptr = GFOR_POINTER_TO_L1 (mptr, mask_kind);
  86. }
  87. else
  88. runtime_error ("Funny sized logical array");
  89. if (ret->base_addr == NULL)
  90. {
  91. /* The front end has signalled that we need to populate the
  92. return array descriptor. */
  93. dim = GFC_DESCRIPTOR_RANK (mask);
  94. rs = 1;
  95. for (n = 0; n < dim; n++)
  96. {
  97. count[n] = 0;
  98. GFC_DIMENSION_SET(ret->dim[n], 0,
  99. GFC_DESCRIPTOR_EXTENT(mask,n) - 1, rs);
  100. extent[n] = GFC_DESCRIPTOR_EXTENT(ret,n);
  101. empty = empty || extent[n] <= 0;
  102. rstride[n] = GFC_DESCRIPTOR_STRIDE_BYTES(ret, n);
  103. fstride[n] = GFC_DESCRIPTOR_STRIDE_BYTES(field, n);
  104. mstride[n] = GFC_DESCRIPTOR_STRIDE_BYTES(mask, n);
  105. rs *= extent[n];
  106. }
  107. ret->offset = 0;
  108. ret->base_addr = xmallocarray (rs, size);
  109. }
  110. else
  111. {
  112. dim = GFC_DESCRIPTOR_RANK (ret);
  113. for (n = 0; n < dim; n++)
  114. {
  115. count[n] = 0;
  116. extent[n] = GFC_DESCRIPTOR_EXTENT(ret,n);
  117. empty = empty || extent[n] <= 0;
  118. rstride[n] = GFC_DESCRIPTOR_STRIDE_BYTES(ret, n);
  119. fstride[n] = GFC_DESCRIPTOR_STRIDE_BYTES(field, n);
  120. mstride[n] = GFC_DESCRIPTOR_STRIDE_BYTES(mask, n);
  121. }
  122. }
  123. if (empty)
  124. return;
  125. /* This assert makes sure GCC knows we can access *stride[0] later. */
  126. assert (dim > 0);
  127. vstride0 = GFC_DESCRIPTOR_STRIDE_BYTES(vector,0);
  128. rstride0 = rstride[0];
  129. fstride0 = fstride[0];
  130. mstride0 = mstride[0];
  131. rptr = ret->base_addr;
  132. fptr = field->base_addr;
  133. vptr = vector->base_addr;
  134. while (rptr)
  135. {
  136. if (*mptr)
  137. {
  138. /* From vector. */
  139. memcpy (rptr, vptr, size);
  140. vptr += vstride0;
  141. }
  142. else
  143. {
  144. /* From field. */
  145. memcpy (rptr, fptr, size);
  146. }
  147. /* Advance to the next element. */
  148. rptr += rstride0;
  149. fptr += fstride0;
  150. mptr += mstride0;
  151. count[0]++;
  152. n = 0;
  153. while (count[n] == extent[n])
  154. {
  155. /* When we get to the end of a dimension, reset it and increment
  156. the next dimension. */
  157. count[n] = 0;
  158. /* We could precalculate these products, but this is a less
  159. frequently used path so probably not worth it. */
  160. rptr -= rstride[n] * extent[n];
  161. fptr -= fstride[n] * extent[n];
  162. mptr -= mstride[n] * extent[n];
  163. n++;
  164. if (n >= dim)
  165. {
  166. /* Break out of the loop. */
  167. rptr = NULL;
  168. break;
  169. }
  170. else
  171. {
  172. count[n]++;
  173. rptr += rstride[n];
  174. fptr += fstride[n];
  175. mptr += mstride[n];
  176. }
  177. }
  178. }
  179. }
  180. extern void unpack1 (gfc_array_char *, const gfc_array_char *,
  181. const gfc_array_l1 *, const gfc_array_char *);
  182. export_proto(unpack1);
  183. void
  184. unpack1 (gfc_array_char *ret, const gfc_array_char *vector,
  185. const gfc_array_l1 *mask, const gfc_array_char *field)
  186. {
  187. index_type type_size;
  188. index_type size;
  189. if (unlikely(compile_options.bounds_check))
  190. unpack_bounds (ret, vector, mask, field);
  191. type_size = GFC_DTYPE_TYPE_SIZE (vector);
  192. size = GFC_DESCRIPTOR_SIZE (vector);
  193. switch(type_size)
  194. {
  195. case GFC_DTYPE_LOGICAL_1:
  196. case GFC_DTYPE_INTEGER_1:
  197. case GFC_DTYPE_DERIVED_1:
  198. unpack1_i1 ((gfc_array_i1 *) ret, (gfc_array_i1 *) vector,
  199. mask, (gfc_array_i1 *) field);
  200. return;
  201. case GFC_DTYPE_LOGICAL_2:
  202. case GFC_DTYPE_INTEGER_2:
  203. unpack1_i2 ((gfc_array_i2 *) ret, (gfc_array_i2 *) vector,
  204. mask, (gfc_array_i2 *) field);
  205. return;
  206. case GFC_DTYPE_LOGICAL_4:
  207. case GFC_DTYPE_INTEGER_4:
  208. unpack1_i4 ((gfc_array_i4 *) ret, (gfc_array_i4 *) vector,
  209. mask, (gfc_array_i4 *) field);
  210. return;
  211. case GFC_DTYPE_LOGICAL_8:
  212. case GFC_DTYPE_INTEGER_8:
  213. unpack1_i8 ((gfc_array_i8 *) ret, (gfc_array_i8 *) vector,
  214. mask, (gfc_array_i8 *) field);
  215. return;
  216. #ifdef HAVE_GFC_INTEGER_16
  217. case GFC_DTYPE_LOGICAL_16:
  218. case GFC_DTYPE_INTEGER_16:
  219. unpack1_i16 ((gfc_array_i16 *) ret, (gfc_array_i16 *) vector,
  220. mask, (gfc_array_i16 *) field);
  221. return;
  222. #endif
  223. case GFC_DTYPE_REAL_4:
  224. unpack1_r4 ((gfc_array_r4 *) ret, (gfc_array_r4 *) vector,
  225. mask, (gfc_array_r4 *) field);
  226. return;
  227. case GFC_DTYPE_REAL_8:
  228. unpack1_r8 ((gfc_array_r8 *) ret, (gfc_array_r8 *) vector,
  229. mask, (gfc_array_r8 *) field);
  230. return;
  231. /* FIXME: This here is a hack, which will have to be removed when
  232. the array descriptor is reworked. Currently, we don't store the
  233. kind value for the type, but only the size. Because on targets with
  234. __float128, we have sizeof(logn double) == sizeof(__float128),
  235. we cannot discriminate here and have to fall back to the generic
  236. handling (which is suboptimal). */
  237. #if !defined(GFC_REAL_16_IS_FLOAT128)
  238. # ifdef HAVE_GFC_REAL_10
  239. case GFC_DTYPE_REAL_10:
  240. unpack1_r10 ((gfc_array_r10 *) ret, (gfc_array_r10 *) vector,
  241. mask, (gfc_array_r10 *) field);
  242. return;
  243. # endif
  244. # ifdef HAVE_GFC_REAL_16
  245. case GFC_DTYPE_REAL_16:
  246. unpack1_r16 ((gfc_array_r16 *) ret, (gfc_array_r16 *) vector,
  247. mask, (gfc_array_r16 *) field);
  248. return;
  249. # endif
  250. #endif
  251. case GFC_DTYPE_COMPLEX_4:
  252. unpack1_c4 ((gfc_array_c4 *) ret, (gfc_array_c4 *) vector,
  253. mask, (gfc_array_c4 *) field);
  254. return;
  255. case GFC_DTYPE_COMPLEX_8:
  256. unpack1_c8 ((gfc_array_c8 *) ret, (gfc_array_c8 *) vector,
  257. mask, (gfc_array_c8 *) field);
  258. return;
  259. /* FIXME: This here is a hack, which will have to be removed when
  260. the array descriptor is reworked. Currently, we don't store the
  261. kind value for the type, but only the size. Because on targets with
  262. __float128, we have sizeof(logn double) == sizeof(__float128),
  263. we cannot discriminate here and have to fall back to the generic
  264. handling (which is suboptimal). */
  265. #if !defined(GFC_REAL_16_IS_FLOAT128)
  266. # ifdef HAVE_GFC_COMPLEX_10
  267. case GFC_DTYPE_COMPLEX_10:
  268. unpack1_c10 ((gfc_array_c10 *) ret, (gfc_array_c10 *) vector,
  269. mask, (gfc_array_c10 *) field);
  270. return;
  271. # endif
  272. # ifdef HAVE_GFC_COMPLEX_16
  273. case GFC_DTYPE_COMPLEX_16:
  274. unpack1_c16 ((gfc_array_c16 *) ret, (gfc_array_c16 *) vector,
  275. mask, (gfc_array_c16 *) field);
  276. return;
  277. # endif
  278. #endif
  279. case GFC_DTYPE_DERIVED_2:
  280. if (GFC_UNALIGNED_2(ret->base_addr) || GFC_UNALIGNED_2(vector->base_addr)
  281. || GFC_UNALIGNED_2(field->base_addr))
  282. break;
  283. else
  284. {
  285. unpack1_i2 ((gfc_array_i2 *) ret, (gfc_array_i2 *) vector,
  286. mask, (gfc_array_i2 *) field);
  287. return;
  288. }
  289. case GFC_DTYPE_DERIVED_4:
  290. if (GFC_UNALIGNED_4(ret->base_addr) || GFC_UNALIGNED_4(vector->base_addr)
  291. || GFC_UNALIGNED_4(field->base_addr))
  292. break;
  293. else
  294. {
  295. unpack1_i4 ((gfc_array_i4 *) ret, (gfc_array_i4 *) vector,
  296. mask, (gfc_array_i4 *) field);
  297. return;
  298. }
  299. case GFC_DTYPE_DERIVED_8:
  300. if (GFC_UNALIGNED_8(ret->base_addr) || GFC_UNALIGNED_8(vector->base_addr)
  301. || GFC_UNALIGNED_8(field->base_addr))
  302. break;
  303. else
  304. {
  305. unpack1_i8 ((gfc_array_i8 *) ret, (gfc_array_i8 *) vector,
  306. mask, (gfc_array_i8 *) field);
  307. return;
  308. }
  309. #ifdef HAVE_GFC_INTEGER_16
  310. case GFC_DTYPE_DERIVED_16:
  311. if (GFC_UNALIGNED_16(ret->base_addr)
  312. || GFC_UNALIGNED_16(vector->base_addr)
  313. || GFC_UNALIGNED_16(field->base_addr))
  314. break;
  315. else
  316. {
  317. unpack1_i16 ((gfc_array_i16 *) ret, (gfc_array_i16 *) vector,
  318. mask, (gfc_array_i16 *) field);
  319. return;
  320. }
  321. #endif
  322. }
  323. unpack_internal (ret, vector, mask, field, size);
  324. }
  325. extern void unpack1_char (gfc_array_char *, GFC_INTEGER_4,
  326. const gfc_array_char *, const gfc_array_l1 *,
  327. const gfc_array_char *, GFC_INTEGER_4,
  328. GFC_INTEGER_4);
  329. export_proto(unpack1_char);
  330. void
  331. unpack1_char (gfc_array_char *ret,
  332. GFC_INTEGER_4 ret_length __attribute__((unused)),
  333. const gfc_array_char *vector, const gfc_array_l1 *mask,
  334. const gfc_array_char *field, GFC_INTEGER_4 vector_length,
  335. GFC_INTEGER_4 field_length __attribute__((unused)))
  336. {
  337. if (unlikely(compile_options.bounds_check))
  338. unpack_bounds (ret, vector, mask, field);
  339. unpack_internal (ret, vector, mask, field, vector_length);
  340. }
  341. extern void unpack1_char4 (gfc_array_char *, GFC_INTEGER_4,
  342. const gfc_array_char *, const gfc_array_l1 *,
  343. const gfc_array_char *, GFC_INTEGER_4,
  344. GFC_INTEGER_4);
  345. export_proto(unpack1_char4);
  346. void
  347. unpack1_char4 (gfc_array_char *ret,
  348. GFC_INTEGER_4 ret_length __attribute__((unused)),
  349. const gfc_array_char *vector, const gfc_array_l1 *mask,
  350. const gfc_array_char *field, GFC_INTEGER_4 vector_length,
  351. GFC_INTEGER_4 field_length __attribute__((unused)))
  352. {
  353. if (unlikely(compile_options.bounds_check))
  354. unpack_bounds (ret, vector, mask, field);
  355. unpack_internal (ret, vector, mask, field,
  356. vector_length * sizeof (gfc_char4_t));
  357. }
  358. extern void unpack0 (gfc_array_char *, const gfc_array_char *,
  359. const gfc_array_l1 *, char *);
  360. export_proto(unpack0);
  361. void
  362. unpack0 (gfc_array_char *ret, const gfc_array_char *vector,
  363. const gfc_array_l1 *mask, char *field)
  364. {
  365. gfc_array_char tmp;
  366. index_type type_size;
  367. if (unlikely(compile_options.bounds_check))
  368. unpack_bounds (ret, vector, mask, NULL);
  369. type_size = GFC_DTYPE_TYPE_SIZE (vector);
  370. switch (type_size)
  371. {
  372. case GFC_DTYPE_LOGICAL_1:
  373. case GFC_DTYPE_INTEGER_1:
  374. case GFC_DTYPE_DERIVED_1:
  375. unpack0_i1 ((gfc_array_i1 *) ret, (gfc_array_i1 *) vector,
  376. mask, (GFC_INTEGER_1 *) field);
  377. return;
  378. case GFC_DTYPE_LOGICAL_2:
  379. case GFC_DTYPE_INTEGER_2:
  380. unpack0_i2 ((gfc_array_i2 *) ret, (gfc_array_i2 *) vector,
  381. mask, (GFC_INTEGER_2 *) field);
  382. return;
  383. case GFC_DTYPE_LOGICAL_4:
  384. case GFC_DTYPE_INTEGER_4:
  385. unpack0_i4 ((gfc_array_i4 *) ret, (gfc_array_i4 *) vector,
  386. mask, (GFC_INTEGER_4 *) field);
  387. return;
  388. case GFC_DTYPE_LOGICAL_8:
  389. case GFC_DTYPE_INTEGER_8:
  390. unpack0_i8 ((gfc_array_i8 *) ret, (gfc_array_i8 *) vector,
  391. mask, (GFC_INTEGER_8 *) field);
  392. return;
  393. #ifdef HAVE_GFC_INTEGER_16
  394. case GFC_DTYPE_LOGICAL_16:
  395. case GFC_DTYPE_INTEGER_16:
  396. unpack0_i16 ((gfc_array_i16 *) ret, (gfc_array_i16 *) vector,
  397. mask, (GFC_INTEGER_16 *) field);
  398. return;
  399. #endif
  400. case GFC_DTYPE_REAL_4:
  401. unpack0_r4 ((gfc_array_r4 *) ret, (gfc_array_r4 *) vector,
  402. mask, (GFC_REAL_4 *) field);
  403. return;
  404. case GFC_DTYPE_REAL_8:
  405. unpack0_r8 ((gfc_array_r8 *) ret, (gfc_array_r8*) vector,
  406. mask, (GFC_REAL_8 *) field);
  407. return;
  408. /* FIXME: This here is a hack, which will have to be removed when
  409. the array descriptor is reworked. Currently, we don't store the
  410. kind value for the type, but only the size. Because on targets with
  411. __float128, we have sizeof(logn double) == sizeof(__float128),
  412. we cannot discriminate here and have to fall back to the generic
  413. handling (which is suboptimal). */
  414. #if !defined(GFC_REAL_16_IS_FLOAT128)
  415. # ifdef HAVE_GFC_REAL_10
  416. case GFC_DTYPE_REAL_10:
  417. unpack0_r10 ((gfc_array_r10 *) ret, (gfc_array_r10 *) vector,
  418. mask, (GFC_REAL_10 *) field);
  419. return;
  420. # endif
  421. # ifdef HAVE_GFC_REAL_16
  422. case GFC_DTYPE_REAL_16:
  423. unpack0_r16 ((gfc_array_r16 *) ret, (gfc_array_r16 *) vector,
  424. mask, (GFC_REAL_16 *) field);
  425. return;
  426. # endif
  427. #endif
  428. case GFC_DTYPE_COMPLEX_4:
  429. unpack0_c4 ((gfc_array_c4 *) ret, (gfc_array_c4 *) vector,
  430. mask, (GFC_COMPLEX_4 *) field);
  431. return;
  432. case GFC_DTYPE_COMPLEX_8:
  433. unpack0_c8 ((gfc_array_c8 *) ret, (gfc_array_c8 *) vector,
  434. mask, (GFC_COMPLEX_8 *) field);
  435. return;
  436. /* FIXME: This here is a hack, which will have to be removed when
  437. the array descriptor is reworked. Currently, we don't store the
  438. kind value for the type, but only the size. Because on targets with
  439. __float128, we have sizeof(logn double) == sizeof(__float128),
  440. we cannot discriminate here and have to fall back to the generic
  441. handling (which is suboptimal). */
  442. #if !defined(GFC_REAL_16_IS_FLOAT128)
  443. # ifdef HAVE_GFC_COMPLEX_10
  444. case GFC_DTYPE_COMPLEX_10:
  445. unpack0_c10 ((gfc_array_c10 *) ret, (gfc_array_c10 *) vector,
  446. mask, (GFC_COMPLEX_10 *) field);
  447. return;
  448. # endif
  449. # ifdef HAVE_GFC_COMPLEX_16
  450. case GFC_DTYPE_COMPLEX_16:
  451. unpack0_c16 ((gfc_array_c16 *) ret, (gfc_array_c16 *) vector,
  452. mask, (GFC_COMPLEX_16 *) field);
  453. return;
  454. # endif
  455. #endif
  456. case GFC_DTYPE_DERIVED_2:
  457. if (GFC_UNALIGNED_2(ret->base_addr) || GFC_UNALIGNED_2(vector->base_addr)
  458. || GFC_UNALIGNED_2(field))
  459. break;
  460. else
  461. {
  462. unpack0_i2 ((gfc_array_i2 *) ret, (gfc_array_i2 *) vector,
  463. mask, (GFC_INTEGER_2 *) field);
  464. return;
  465. }
  466. case GFC_DTYPE_DERIVED_4:
  467. if (GFC_UNALIGNED_4(ret->base_addr) || GFC_UNALIGNED_4(vector->base_addr)
  468. || GFC_UNALIGNED_4(field))
  469. break;
  470. else
  471. {
  472. unpack0_i4 ((gfc_array_i4 *) ret, (gfc_array_i4 *) vector,
  473. mask, (GFC_INTEGER_4 *) field);
  474. return;
  475. }
  476. case GFC_DTYPE_DERIVED_8:
  477. if (GFC_UNALIGNED_8(ret->base_addr) || GFC_UNALIGNED_8(vector->base_addr)
  478. || GFC_UNALIGNED_8(field))
  479. break;
  480. else
  481. {
  482. unpack0_i8 ((gfc_array_i8 *) ret, (gfc_array_i8 *) vector,
  483. mask, (GFC_INTEGER_8 *) field);
  484. return;
  485. }
  486. #ifdef HAVE_GFC_INTEGER_16
  487. case GFC_DTYPE_DERIVED_16:
  488. if (GFC_UNALIGNED_16(ret->base_addr)
  489. || GFC_UNALIGNED_16(vector->base_addr)
  490. || GFC_UNALIGNED_16(field))
  491. break;
  492. else
  493. {
  494. unpack0_i16 ((gfc_array_i16 *) ret, (gfc_array_i16 *) vector,
  495. mask, (GFC_INTEGER_16 *) field);
  496. return;
  497. }
  498. #endif
  499. }
  500. memset (&tmp, 0, sizeof (tmp));
  501. tmp.dtype = 0;
  502. tmp.base_addr = field;
  503. unpack_internal (ret, vector, mask, &tmp, GFC_DESCRIPTOR_SIZE (vector));
  504. }
  505. extern void unpack0_char (gfc_array_char *, GFC_INTEGER_4,
  506. const gfc_array_char *, const gfc_array_l1 *,
  507. char *, GFC_INTEGER_4, GFC_INTEGER_4);
  508. export_proto(unpack0_char);
  509. void
  510. unpack0_char (gfc_array_char *ret,
  511. GFC_INTEGER_4 ret_length __attribute__((unused)),
  512. const gfc_array_char *vector, const gfc_array_l1 *mask,
  513. char *field, GFC_INTEGER_4 vector_length,
  514. GFC_INTEGER_4 field_length __attribute__((unused)))
  515. {
  516. gfc_array_char tmp;
  517. if (unlikely(compile_options.bounds_check))
  518. unpack_bounds (ret, vector, mask, NULL);
  519. memset (&tmp, 0, sizeof (tmp));
  520. tmp.dtype = 0;
  521. tmp.base_addr = field;
  522. unpack_internal (ret, vector, mask, &tmp, vector_length);
  523. }
  524. extern void unpack0_char4 (gfc_array_char *, GFC_INTEGER_4,
  525. const gfc_array_char *, const gfc_array_l1 *,
  526. char *, GFC_INTEGER_4, GFC_INTEGER_4);
  527. export_proto(unpack0_char4);
  528. void
  529. unpack0_char4 (gfc_array_char *ret,
  530. GFC_INTEGER_4 ret_length __attribute__((unused)),
  531. const gfc_array_char *vector, const gfc_array_l1 *mask,
  532. char *field, GFC_INTEGER_4 vector_length,
  533. GFC_INTEGER_4 field_length __attribute__((unused)))
  534. {
  535. gfc_array_char tmp;
  536. if (unlikely(compile_options.bounds_check))
  537. unpack_bounds (ret, vector, mask, NULL);
  538. memset (&tmp, 0, sizeof (tmp));
  539. tmp.dtype = 0;
  540. tmp.base_addr = field;
  541. unpack_internal (ret, vector, mask, &tmp,
  542. vector_length * sizeof (gfc_char4_t));
  543. }