gdb/testsuite: Add gdb_test_name variable
[deliverable/binutils-gdb.git] / gas / config / atof-ieee.c
1 /* atof_ieee.c - turn a Flonum into an IEEE floating point number
2 Copyright (C) 1987-2019 Free Software Foundation, Inc.
3
4 This file is part of GAS, the GNU Assembler.
5
6 GAS is free software; you can redistribute it and/or modify
7 it under the terms of the GNU General Public License as published by
8 the Free Software Foundation; either version 3, or (at your option)
9 any later version.
10
11 GAS is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 GNU General Public License for more details.
15
16 You should have received a copy of the GNU General Public License
17 along with GAS; see the file COPYING. If not, write to the Free
18 Software Foundation, 51 Franklin Street - Fifth Floor, Boston, MA
19 02110-1301, USA. */
20
21 #include "as.h"
22
23 /* Flonums returned here. */
24 extern FLONUM_TYPE generic_floating_point_number;
25
26 /* Precision in LittleNums. */
27 /* Don't count the gap in the m68k extended precision format. */
28 #define MAX_PRECISION 5
29 #define H_PRECISION 1
30 #define F_PRECISION 2
31 #define D_PRECISION 4
32 #define X_PRECISION 5
33 #define P_PRECISION 5
34
35 /* Length in LittleNums of guard bits. */
36 #define GUARD 2
37
38 #ifndef TC_LARGEST_EXPONENT_IS_NORMAL
39 #define TC_LARGEST_EXPONENT_IS_NORMAL(PRECISION) 0
40 #endif
41
42 static const unsigned long mask[] =
43 {
44 0x00000000,
45 0x00000001,
46 0x00000003,
47 0x00000007,
48 0x0000000f,
49 0x0000001f,
50 0x0000003f,
51 0x0000007f,
52 0x000000ff,
53 0x000001ff,
54 0x000003ff,
55 0x000007ff,
56 0x00000fff,
57 0x00001fff,
58 0x00003fff,
59 0x00007fff,
60 0x0000ffff,
61 0x0001ffff,
62 0x0003ffff,
63 0x0007ffff,
64 0x000fffff,
65 0x001fffff,
66 0x003fffff,
67 0x007fffff,
68 0x00ffffff,
69 0x01ffffff,
70 0x03ffffff,
71 0x07ffffff,
72 0x0fffffff,
73 0x1fffffff,
74 0x3fffffff,
75 0x7fffffff,
76 0xffffffff,
77 };
78 \f
79 static int bits_left_in_littlenum;
80 static int littlenums_left;
81 static LITTLENUM_TYPE *littlenum_pointer;
82
83 static int
84 next_bits (int number_of_bits)
85 {
86 int return_value;
87
88 if (!littlenums_left)
89 return 0;
90
91 if (number_of_bits >= bits_left_in_littlenum)
92 {
93 return_value = mask[bits_left_in_littlenum] & *littlenum_pointer;
94 number_of_bits -= bits_left_in_littlenum;
95 return_value <<= number_of_bits;
96
97 if (--littlenums_left)
98 {
99 bits_left_in_littlenum = LITTLENUM_NUMBER_OF_BITS - number_of_bits;
100 --littlenum_pointer;
101 return_value |=
102 (*littlenum_pointer >> bits_left_in_littlenum)
103 & mask[number_of_bits];
104 }
105 }
106 else
107 {
108 bits_left_in_littlenum -= number_of_bits;
109 return_value =
110 mask[number_of_bits] & (*littlenum_pointer >> bits_left_in_littlenum);
111 }
112 return return_value;
113 }
114
115 /* Num had better be less than LITTLENUM_NUMBER_OF_BITS. */
116
117 static void
118 unget_bits (int num)
119 {
120 if (!littlenums_left)
121 {
122 ++littlenum_pointer;
123 ++littlenums_left;
124 bits_left_in_littlenum = num;
125 }
126 else if (bits_left_in_littlenum + num > LITTLENUM_NUMBER_OF_BITS)
127 {
128 bits_left_in_littlenum =
129 num - (LITTLENUM_NUMBER_OF_BITS - bits_left_in_littlenum);
130 ++littlenum_pointer;
131 ++littlenums_left;
132 }
133 else
134 bits_left_in_littlenum += num;
135 }
136
137 static void
138 make_invalid_floating_point_number (LITTLENUM_TYPE *words)
139 {
140 as_bad (_("cannot create floating-point number"));
141 /* Zero the leftmost bit. */
142 words[0] = (LITTLENUM_TYPE) ((unsigned) -1) >> 1;
143 words[1] = (LITTLENUM_TYPE) -1;
144 words[2] = (LITTLENUM_TYPE) -1;
145 words[3] = (LITTLENUM_TYPE) -1;
146 words[4] = (LITTLENUM_TYPE) -1;
147 words[5] = (LITTLENUM_TYPE) -1;
148 }
149 \f
150 /* Warning: This returns 16-bit LITTLENUMs. It is up to the caller to
151 figure out any alignment problems and to conspire for the
152 bytes/word to be emitted in the right order. Bigendians beware! */
153
154 /* Note that atof-ieee always has X and P precisions enabled. it is up
155 to md_atof to filter them out if the target machine does not support
156 them. */
157
158 /* Returns pointer past text consumed. */
159
160 char *
161 atof_ieee (char *str, /* Text to convert to binary. */
162 int what_kind, /* 'd', 'f', 'x', 'p'. */
163 LITTLENUM_TYPE *words) /* Build the binary here. */
164 {
165 /* Extra bits for zeroed low-order bits.
166 The 1st MAX_PRECISION are zeroed, the last contain flonum bits. */
167 static LITTLENUM_TYPE bits[MAX_PRECISION + MAX_PRECISION + GUARD];
168 char *return_value;
169 /* Number of 16-bit words in the format. */
170 int precision;
171 long exponent_bits;
172 FLONUM_TYPE save_gen_flonum;
173
174 /* We have to save the generic_floating_point_number because it
175 contains storage allocation about the array of LITTLENUMs where
176 the value is actually stored. We will allocate our own array of
177 littlenums below, but have to restore the global one on exit. */
178 save_gen_flonum = generic_floating_point_number;
179
180 return_value = str;
181 generic_floating_point_number.low = bits + MAX_PRECISION;
182 generic_floating_point_number.high = NULL;
183 generic_floating_point_number.leader = NULL;
184 generic_floating_point_number.exponent = 0;
185 generic_floating_point_number.sign = '\0';
186
187 /* Use more LittleNums than seems necessary: the highest flonum may
188 have 15 leading 0 bits, so could be useless. */
189
190 memset (bits, '\0', sizeof (LITTLENUM_TYPE) * MAX_PRECISION);
191
192 switch (what_kind)
193 {
194 case 'h':
195 case 'H':
196 precision = H_PRECISION;
197 exponent_bits = 5;
198 break;
199
200 case 'f':
201 case 'F':
202 case 's':
203 case 'S':
204 precision = F_PRECISION;
205 exponent_bits = 8;
206 break;
207
208 case 'd':
209 case 'D':
210 case 'r':
211 case 'R':
212 precision = D_PRECISION;
213 exponent_bits = 11;
214 break;
215
216 case 'x':
217 case 'X':
218 case 'e':
219 case 'E':
220 precision = X_PRECISION;
221 exponent_bits = 15;
222 break;
223
224 case 'p':
225 case 'P':
226 precision = P_PRECISION;
227 exponent_bits = -1;
228 break;
229
230 default:
231 make_invalid_floating_point_number (words);
232 return (NULL);
233 }
234
235 generic_floating_point_number.high
236 = generic_floating_point_number.low + precision - 1 + GUARD;
237
238 if (atof_generic (&return_value, ".", EXP_CHARS,
239 &generic_floating_point_number))
240 {
241 make_invalid_floating_point_number (words);
242 return NULL;
243 }
244 gen_to_words (words, precision, exponent_bits);
245
246 /* Restore the generic_floating_point_number's storage alloc (and
247 everything else). */
248 generic_floating_point_number = save_gen_flonum;
249
250 return return_value;
251 }
252
253 /* Turn generic_floating_point_number into a real float/double/extended. */
254
255 int
256 gen_to_words (LITTLENUM_TYPE *words, int precision, long exponent_bits)
257 {
258 int return_value = 0;
259
260 long exponent_1;
261 long exponent_2;
262 long exponent_3;
263 long exponent_4;
264 int exponent_skippage;
265 LITTLENUM_TYPE word1;
266 LITTLENUM_TYPE *lp;
267 LITTLENUM_TYPE *words_end;
268
269 words_end = words + precision;
270 #ifdef TC_M68K
271 if (precision == X_PRECISION)
272 /* On the m68k the extended precision format has a gap of 16 bits
273 between the exponent and the mantissa. */
274 words_end++;
275 #endif
276
277 if (generic_floating_point_number.low > generic_floating_point_number.leader)
278 {
279 /* 0.0e0 seen. */
280 if (generic_floating_point_number.sign == '+')
281 words[0] = 0x0000;
282 else
283 words[0] = 0x8000;
284 memset (&words[1], '\0',
285 (words_end - words - 1) * sizeof (LITTLENUM_TYPE));
286 return return_value;
287 }
288
289 /* NaN: Do the right thing. */
290 if (generic_floating_point_number.sign == 0)
291 {
292 if (TC_LARGEST_EXPONENT_IS_NORMAL (precision))
293 as_warn (_("NaNs are not supported by this target"));
294
295 if (precision == H_PRECISION)
296 {
297 words[0] = 0x7fff;
298 }
299 else if (precision == F_PRECISION)
300 {
301 words[0] = 0x7fff;
302 words[1] = 0xffff;
303 }
304 else if (precision == X_PRECISION)
305 {
306 #ifdef TC_M68K
307 words[0] = 0x7fff;
308 words[1] = 0;
309 words[2] = 0xffff;
310 words[3] = 0xffff;
311 words[4] = 0xffff;
312 words[5] = 0xffff;
313 #else /* ! TC_M68K */
314 #ifdef TC_I386
315 words[0] = 0xffff;
316 words[1] = 0xc000;
317 words[2] = 0;
318 words[3] = 0;
319 words[4] = 0;
320 #else /* ! TC_I386 */
321 abort ();
322 #endif /* ! TC_I386 */
323 #endif /* ! TC_M68K */
324 }
325 else
326 {
327 words[0] = 0x7fff;
328 words[1] = 0xffff;
329 words[2] = 0xffff;
330 words[3] = 0xffff;
331 }
332 return return_value;
333 }
334 else if (generic_floating_point_number.sign == 'P')
335 {
336 if (TC_LARGEST_EXPONENT_IS_NORMAL (precision))
337 as_warn (_("Infinities are not supported by this target"));
338
339 /* +INF: Do the right thing. */
340 if (precision == H_PRECISION)
341 {
342 words[0] = 0x7c00;
343 }
344 else if (precision == F_PRECISION)
345 {
346 words[0] = 0x7f80;
347 words[1] = 0;
348 }
349 else if (precision == X_PRECISION)
350 {
351 #ifdef TC_M68K
352 words[0] = 0x7fff;
353 words[1] = 0;
354 words[2] = 0;
355 words[3] = 0;
356 words[4] = 0;
357 words[5] = 0;
358 #else /* ! TC_M68K */
359 #ifdef TC_I386
360 words[0] = 0x7fff;
361 words[1] = 0x8000;
362 words[2] = 0;
363 words[3] = 0;
364 words[4] = 0;
365 #else /* ! TC_I386 */
366 abort ();
367 #endif /* ! TC_I386 */
368 #endif /* ! TC_M68K */
369 }
370 else
371 {
372 words[0] = 0x7ff0;
373 words[1] = 0;
374 words[2] = 0;
375 words[3] = 0;
376 }
377 return return_value;
378 }
379 else if (generic_floating_point_number.sign == 'N')
380 {
381 if (TC_LARGEST_EXPONENT_IS_NORMAL (precision))
382 as_warn (_("Infinities are not supported by this target"));
383
384 /* Negative INF. */
385 if (precision == H_PRECISION)
386 {
387 words[0] = 0xfc00;
388 }
389 else if (precision == F_PRECISION)
390 {
391 words[0] = 0xff80;
392 words[1] = 0x0;
393 }
394 else if (precision == X_PRECISION)
395 {
396 #ifdef TC_M68K
397 words[0] = 0xffff;
398 words[1] = 0;
399 words[2] = 0;
400 words[3] = 0;
401 words[4] = 0;
402 words[5] = 0;
403 #else /* ! TC_M68K */
404 #ifdef TC_I386
405 words[0] = 0xffff;
406 words[1] = 0x8000;
407 words[2] = 0;
408 words[3] = 0;
409 words[4] = 0;
410 #else /* ! TC_I386 */
411 abort ();
412 #endif /* ! TC_I386 */
413 #endif /* ! TC_M68K */
414 }
415 else
416 {
417 words[0] = 0xfff0;
418 words[1] = 0x0;
419 words[2] = 0x0;
420 words[3] = 0x0;
421 }
422 return return_value;
423 }
424
425 /* The floating point formats we support have:
426 Bit 15 is sign bit.
427 Bits 14:n are excess-whatever exponent.
428 Bits n-1:0 (if any) are most significant bits of fraction.
429 Bits 15:0 of the next word(s) are the next most significant bits.
430
431 So we need: number of bits of exponent, number of bits of
432 mantissa. */
433 bits_left_in_littlenum = LITTLENUM_NUMBER_OF_BITS;
434 littlenum_pointer = generic_floating_point_number.leader;
435 littlenums_left = (1
436 + generic_floating_point_number.leader
437 - generic_floating_point_number.low);
438
439 /* Seek (and forget) 1st significant bit. */
440 for (exponent_skippage = 0; !next_bits (1); ++exponent_skippage);
441 exponent_1 = (generic_floating_point_number.exponent
442 + generic_floating_point_number.leader
443 + 1
444 - generic_floating_point_number.low);
445
446 /* Radix LITTLENUM_RADIX, point just higher than
447 generic_floating_point_number.leader. */
448 exponent_2 = exponent_1 * LITTLENUM_NUMBER_OF_BITS;
449
450 /* Radix 2. */
451 exponent_3 = exponent_2 - exponent_skippage;
452
453 /* Forget leading zeros, forget 1st bit. */
454 exponent_4 = exponent_3 + ((1 << (exponent_bits - 1)) - 2);
455
456 /* Offset exponent. */
457 lp = words;
458
459 /* Word 1. Sign, exponent and perhaps high bits. */
460 word1 = ((generic_floating_point_number.sign == '+')
461 ? 0
462 : (1 << (LITTLENUM_NUMBER_OF_BITS - 1)));
463
464 /* Assume 2's complement integers. */
465 if (exponent_4 <= 0)
466 {
467 int prec_bits;
468 int num_bits;
469
470 unget_bits (1);
471 num_bits = -exponent_4;
472 prec_bits =
473 LITTLENUM_NUMBER_OF_BITS * precision - (exponent_bits + 1 + num_bits);
474 #ifdef TC_I386
475 if (precision == X_PRECISION && exponent_bits == 15)
476 {
477 /* On the i386 a denormalized extended precision float is
478 shifted down by one, effectively decreasing the exponent
479 bias by one. */
480 prec_bits -= 1;
481 num_bits += 1;
482 }
483 #endif
484
485 if (num_bits >= LITTLENUM_NUMBER_OF_BITS - exponent_bits)
486 {
487 /* Bigger than one littlenum. */
488 num_bits -= (LITTLENUM_NUMBER_OF_BITS - 1) - exponent_bits;
489 *lp++ = word1;
490 if (num_bits + exponent_bits + 1
491 > precision * LITTLENUM_NUMBER_OF_BITS)
492 {
493 /* Exponent overflow. */
494 make_invalid_floating_point_number (words);
495 return return_value;
496 }
497 #ifdef TC_M68K
498 if (precision == X_PRECISION && exponent_bits == 15)
499 *lp++ = 0;
500 #endif
501 while (num_bits >= LITTLENUM_NUMBER_OF_BITS)
502 {
503 num_bits -= LITTLENUM_NUMBER_OF_BITS;
504 *lp++ = 0;
505 }
506 if (num_bits)
507 *lp++ = next_bits (LITTLENUM_NUMBER_OF_BITS - (num_bits));
508 }
509 else
510 {
511 if (precision == X_PRECISION && exponent_bits == 15)
512 {
513 *lp++ = word1;
514 #ifdef TC_M68K
515 *lp++ = 0;
516 #endif
517 *lp++ = next_bits (LITTLENUM_NUMBER_OF_BITS - num_bits);
518 }
519 else
520 {
521 word1 |= next_bits ((LITTLENUM_NUMBER_OF_BITS - 1)
522 - (exponent_bits + num_bits));
523 *lp++ = word1;
524 }
525 }
526 while (lp < words_end)
527 *lp++ = next_bits (LITTLENUM_NUMBER_OF_BITS);
528
529 /* Round the mantissa up, but don't change the number. */
530 if (next_bits (1))
531 {
532 --lp;
533 if (prec_bits >= LITTLENUM_NUMBER_OF_BITS)
534 {
535 int n = 0;
536 int tmp_bits;
537
538 n = 0;
539 tmp_bits = prec_bits;
540 while (tmp_bits > LITTLENUM_NUMBER_OF_BITS)
541 {
542 if (lp[n] != (LITTLENUM_TYPE) - 1)
543 break;
544 --n;
545 tmp_bits -= LITTLENUM_NUMBER_OF_BITS;
546 }
547 if (tmp_bits > LITTLENUM_NUMBER_OF_BITS
548 || (lp[n] & mask[tmp_bits]) != mask[tmp_bits]
549 || (prec_bits != (precision * LITTLENUM_NUMBER_OF_BITS
550 - exponent_bits - 1)
551 #ifdef TC_I386
552 /* An extended precision float with only the integer
553 bit set would be invalid. That must be converted
554 to the smallest normalized number. */
555 && !(precision == X_PRECISION
556 && prec_bits == (precision * LITTLENUM_NUMBER_OF_BITS
557 - exponent_bits - 2))
558 #endif
559 ))
560 {
561 unsigned long carry;
562
563 for (carry = 1; carry && (lp >= words); lp--)
564 {
565 carry = *lp + carry;
566 *lp = carry;
567 carry >>= LITTLENUM_NUMBER_OF_BITS;
568 }
569 }
570 else
571 {
572 /* This is an overflow of the denormal numbers. We
573 need to forget what we have produced, and instead
574 generate the smallest normalized number. */
575 lp = words;
576 word1 = ((generic_floating_point_number.sign == '+')
577 ? 0
578 : (1 << (LITTLENUM_NUMBER_OF_BITS - 1)));
579 word1 |= (1
580 << ((LITTLENUM_NUMBER_OF_BITS - 1)
581 - exponent_bits));
582 *lp++ = word1;
583 #ifdef TC_I386
584 /* Set the integer bit in the extended precision format.
585 This cannot happen on the m68k where the mantissa
586 just overflows into the integer bit above. */
587 if (precision == X_PRECISION)
588 *lp++ = 1 << (LITTLENUM_NUMBER_OF_BITS - 1);
589 #endif
590 while (lp < words_end)
591 *lp++ = 0;
592 }
593 }
594 else
595 *lp += 1;
596 }
597
598 return return_value;
599 }
600 else if ((unsigned long) exponent_4 > mask[exponent_bits]
601 || (! TC_LARGEST_EXPONENT_IS_NORMAL (precision)
602 && (unsigned long) exponent_4 == mask[exponent_bits]))
603 {
604 /* Exponent overflow. Lose immediately. */
605
606 /* We leave return_value alone: admit we read the
607 number, but return a floating exception
608 because we can't encode the number. */
609 make_invalid_floating_point_number (words);
610 return return_value;
611 }
612 else
613 {
614 word1 |= (exponent_4 << ((LITTLENUM_NUMBER_OF_BITS - 1) - exponent_bits))
615 | next_bits ((LITTLENUM_NUMBER_OF_BITS - 1) - exponent_bits);
616 }
617
618 *lp++ = word1;
619
620 /* X_PRECISION is special: on the 68k, it has 16 bits of zero in the
621 middle. Either way, it is then followed by a 1 bit. */
622 if (exponent_bits == 15 && precision == X_PRECISION)
623 {
624 #ifdef TC_M68K
625 *lp++ = 0;
626 #endif
627 *lp++ = (1 << (LITTLENUM_NUMBER_OF_BITS - 1)
628 | next_bits (LITTLENUM_NUMBER_OF_BITS - 1));
629 }
630
631 /* The rest of the words are just mantissa bits. */
632 while (lp < words_end)
633 *lp++ = next_bits (LITTLENUM_NUMBER_OF_BITS);
634
635 if (next_bits (1))
636 {
637 unsigned long carry;
638 /* Since the NEXT bit is a 1, round UP the mantissa.
639 The cunning design of these hidden-1 floats permits
640 us to let the mantissa overflow into the exponent, and
641 it 'does the right thing'. However, we lose if the
642 highest-order bit of the lowest-order word flips.
643 Is that clear? */
644
645 /* #if (sizeof(carry)) < ((sizeof(bits[0]) * BITS_PER_CHAR) + 2)
646 Please allow at least 1 more bit in carry than is in a LITTLENUM.
647 We need that extra bit to hold a carry during a LITTLENUM carry
648 propagation. Another extra bit (kept 0) will assure us that we
649 don't get a sticky sign bit after shifting right, and that
650 permits us to propagate the carry without any masking of bits.
651 #endif */
652 for (carry = 1, lp--; carry; lp--)
653 {
654 carry = *lp + carry;
655 *lp = carry;
656 carry >>= LITTLENUM_NUMBER_OF_BITS;
657 if (lp == words)
658 break;
659 }
660 if (precision == X_PRECISION && exponent_bits == 15)
661 {
662 /* Extended precision numbers have an explicit integer bit
663 that we may have to restore. */
664 if (lp == words)
665 {
666 #ifdef TC_M68K
667 /* On the m68k there is a gap of 16 bits. We must
668 explicitly propagate the carry into the exponent. */
669 words[0] += words[1];
670 words[1] = 0;
671 lp++;
672 #endif
673 /* Put back the integer bit. */
674 lp[1] |= 1 << (LITTLENUM_NUMBER_OF_BITS - 1);
675 }
676 }
677 if ((word1 ^ *words) & (1 << (LITTLENUM_NUMBER_OF_BITS - 1)))
678 {
679 /* We leave return_value alone: admit we read the number,
680 but return a floating exception because we can't encode
681 the number. */
682 *words &= ~(1 << (LITTLENUM_NUMBER_OF_BITS - 1));
683 }
684 }
685 return return_value;
686 }
687
688 #ifdef TEST
689 char *
690 print_gen (gen)
691 FLONUM_TYPE *gen;
692 {
693 FLONUM_TYPE f;
694 LITTLENUM_TYPE arr[10];
695 double dv;
696 float fv;
697 static char sbuf[40];
698
699 if (gen)
700 {
701 f = generic_floating_point_number;
702 generic_floating_point_number = *gen;
703 }
704 gen_to_words (&arr[0], 4, 11);
705 memcpy (&dv, &arr[0], sizeof (double));
706 sprintf (sbuf, "%x %x %x %x %.14G ", arr[0], arr[1], arr[2], arr[3], dv);
707 gen_to_words (&arr[0], 2, 8);
708 memcpy (&fv, &arr[0], sizeof (float));
709 sprintf (sbuf + strlen (sbuf), "%x %x %.12g\n", arr[0], arr[1], fv);
710
711 if (gen)
712 generic_floating_point_number = f;
713
714 return (sbuf);
715 }
716 #endif
717
718 /* This is a utility function called from various tc-*.c files. It
719 is here in order to reduce code duplication.
720
721 Turn a string at input_line_pointer into a floating point constant
722 of type TYPE (a character found in the FLT_CHARS macro), and store
723 it as LITTLENUMS in the bytes buffer LITP. The number of chars
724 emitted is stored in *SIZEP. BIG_WORDIAN is TRUE if the littlenums
725 should be emitted most significant littlenum first.
726
727 An error message is returned, or a NULL pointer if everything went OK. */
728
729 const char *
730 ieee_md_atof (int type,
731 char *litP,
732 int *sizeP,
733 bfd_boolean big_wordian)
734 {
735 LITTLENUM_TYPE words[MAX_LITTLENUMS];
736 LITTLENUM_TYPE *wordP;
737 char *t;
738 int prec = 0;
739
740 if (strchr (FLT_CHARS, type) != NULL)
741 {
742 switch (type)
743 {
744 case 'H':
745 case 'h':
746 prec = H_PRECISION;
747 break;
748
749 case 'f':
750 case 'F':
751 case 's':
752 case 'S':
753 prec = F_PRECISION;
754 break;
755
756 case 'd':
757 case 'D':
758 case 'r':
759 case 'R':
760 prec = D_PRECISION;
761 break;
762
763 case 't':
764 case 'T':
765 prec = X_PRECISION;
766 type = 'x'; /* This is what atof_ieee() understands. */
767 break;
768
769 case 'x':
770 case 'X':
771 case 'p':
772 case 'P':
773 #ifdef TC_M68K
774 /* Note: on the m68k there is a gap of 16 bits (one littlenum)
775 between the exponent and mantissa. Hence the precision is
776 6 and not 5. */
777 prec = P_PRECISION + 1;
778 #else
779 prec = P_PRECISION;
780 #endif
781 break;
782
783 default:
784 break;
785 }
786 }
787 /* The 'f' and 'd' types are always recognised, even if the target has
788 not put them into the FLT_CHARS macro. This is because the 'f' type
789 can come from the .dc.s, .dcb.s, .float or .single pseudo-ops and the
790 'd' type from the .dc.d, .dbc.d or .double pseudo-ops.
791
792 The 'x' type is not implicitly recognised however, even though it can
793 be generated by the .dc.x and .dbc.x pseudo-ops because not all targets
794 can support floating point values that big. ie the target has to
795 explicitly allow them by putting them into FLT_CHARS. */
796 else if (type == 'f')
797 prec = F_PRECISION;
798 else if (type == 'd')
799 prec = D_PRECISION;
800
801 if (prec == 0)
802 {
803 *sizeP = 0;
804 return _("Unrecognized or unsupported floating point constant");
805 }
806
807 gas_assert (prec <= MAX_LITTLENUMS);
808
809 t = atof_ieee (input_line_pointer, type, words);
810 if (t)
811 input_line_pointer = t;
812
813 *sizeP = prec * sizeof (LITTLENUM_TYPE);
814
815 if (big_wordian)
816 {
817 for (wordP = words; prec --;)
818 {
819 md_number_to_chars (litP, (valueT) (* wordP ++), sizeof (LITTLENUM_TYPE));
820 litP += sizeof (LITTLENUM_TYPE);
821 }
822 }
823 else
824 {
825 for (wordP = words + prec; prec --;)
826 {
827 md_number_to_chars (litP, (valueT) (* -- wordP), sizeof (LITTLENUM_TYPE));
828 litP += sizeof (LITTLENUM_TYPE);
829 }
830 }
831
832 return NULL;
833 }
This page took 0.046911 seconds and 4 git commands to generate.