1 1.8 mrg /* Copyright (C) 2006-2019 Free Software Foundation, Inc. 2 1.1 mrg 3 1.1 mrg This file is free software; you can redistribute it and/or modify it under 4 1.1 mrg the terms of the GNU General Public License as published by the Free 5 1.1 mrg Software Foundation; either version 3 of the License, or (at your option) 6 1.1 mrg any later version. 7 1.1 mrg 8 1.1 mrg This file is distributed in the hope that it will be useful, but WITHOUT 9 1.1 mrg ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 10 1.1 mrg FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 11 1.1 mrg for more details. 12 1.1 mrg 13 1.1 mrg Under Section 7 of GPL version 3, you are granted additional 14 1.1 mrg permissions described in the GCC Runtime Library Exception, version 15 1.1 mrg 3.1, as published by the Free Software Foundation. 16 1.1 mrg 17 1.1 mrg You should have received a copy of the GNU General Public License and 18 1.1 mrg a copy of the GCC Runtime Library Exception along with this program; 19 1.1 mrg see the files COPYING3 and COPYING.RUNTIME respectively. If not, see 20 1.1 mrg <http://www.gnu.org/licenses/>. */ 21 1.1 mrg 22 1.1 mrg #include <spu_intrinsics.h> 23 1.1 mrg const unsigned char __didf_scale[16] __attribute__ ((__aligned__ (16))) = { 24 1.1 mrg 0x00, 0x00, 0x04, 0x3e, 25 1.1 mrg 0x00, 0x00, 0x04, 0x1e, 26 1.1 mrg 0x00, 0x00, 0x00, 0x00, 27 1.1 mrg 0x00, 0x00, 0x00, 0x00 28 1.1 mrg }; 29 1.1 mrg const unsigned char __didf_pat[16] __attribute__ ((__aligned__ (16))) = { 30 1.1 mrg 0x02, 0x03, 0x10, 0x11, 31 1.1 mrg 0x12, 0x13, 0x80, 0x80, 32 1.1 mrg 0x06, 0x07, 0x14, 0x15, 33 1.1 mrg 0x16, 0x17, 0x80, 0x80 34 1.1 mrg }; 35 1.1 mrg 36 1.1 mrg /* double __float_unsdidf (unsigned long long int) 37 1.1 mrg Construct two exact doubles representing the high and low parts (in 38 1.1 mrg parallel), then add them. */ 39 1.1 mrg qword __float_unsdidf (qword DI); 40 1.1 mrg qword 41 1.1 mrg __float_unsdidf (qword DI) 42 1.1 mrg { 43 1.1 mrg qword t0, t1, t2, t3, t4, t5, t6, t7, t8; 44 1.1 mrg t0 = si_clz (DI); 45 1.1 mrg t1 = si_shl (DI, t0); 46 1.1 mrg t2 = si_ceqi (t0, 32); 47 1.1 mrg t3 = si_sf (t0, *(const qword *) __didf_scale); 48 1.1 mrg t4 = si_a (t1, t1); 49 1.1 mrg t5 = si_andc (t3, t2); 50 1.1 mrg t6 = si_shufb (t5, t4, *(const qword *) __didf_pat); 51 1.1 mrg t7 = si_shlqbii (t6, 4); 52 1.1 mrg t8 = si_shlqbyi (t7, 8); 53 1.1 mrg return si_dfa (t7, t8); 54 1.1 mrg } 55