1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
|
/* Decimal Floating Point convert 64-bit to unsigned long. P6 PPC64 version.
Copyright (C) 2006 Free Software Foundation, Inc.
This file is part of the GNU C Library.
The GNU C Library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2.1 of the License, or (at your option) any later version.
The GNU C Library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public
License along with the GNU C Library; if not, write to the Free
Software Foundation, Inc., 51 Franklin St - Fifth Floor, Boston,
MA 02110-1301 USA */
#include <sysdep.h>
#include <math_ldbl_opt.h>
.section ".toc","aw"
.LC1: /* 9223372036854775808.0DD */
.tc FD_6e45237c_836973f6[TC],0x6e45237c836973f6
.LC2: /* 18446744073709551616.0DD */
.tc FD_264a4cdd_2077c2dd[TC],0x264a4cdd2077c2dd
.section ".text"
.machine "power6"
/* unsigned long __fixunsdddi (__decimal64 x) */
ENTRY (__fixunsdddi)
lfd fp10,.LC1@toc(2)
drintn. 0,fp1,fp1,1 /* Preround to toward zero. */
dcmpu cr0,fp1,fp10 /* check if > 2**63-1 */
blt cr1,L(negative)
lfd fp11,.LC2@toc(2)
blt cr0,L(poslong)
/* The return is an unsigned long, but "DFP convert to fixed" takes
signed long, so we need to pre-adjust (-18446744073709551616.0DD)
to get the final (signed) conversion result to be the correct
unsigned result. */
dsub fp1,fp1,fp11
dcmpu cr0,fp1,fp10 /* if x still > 2**63-1 */
li r3,-1 /* return max_unsigned_long */
bgelr cr0 /* else */
L(poslong):
dctfix fp0,fp1 /* Convert x to integer. */
stfd fp0,-8(r1)
ori r1,r1,0 /* Special group ending nop. */
ld r3,-8(r1)
blr
L(negative):
li r3,0 /* return 0 for negative floats. */
blr
END (__fixunsdddi)
|