1193323Sed/* Copyright (C) 2008-2022 Free Software Foundation, Inc. 2193323Sed Contributor: Joern Rennecke <joern.rennecke@embecosm.com> 3193323Sed on behalf of Synopsys Inc. 4193323Sed 5193323SedThis file is part of GCC. 6193323Sed 7193323SedGCC is free software; you can redistribute it and/or modify it under 8193323Sedthe terms of the GNU General Public License as published by the Free 9193323SedSoftware Foundation; either version 3, or (at your option) any later 10193323Sedversion. 11193323Sed 12193323SedGCC is distributed in the hope that it will be useful, but WITHOUT ANY 13193323SedWARRANTY; without even the implied warranty of MERCHANTABILITY or 14193323SedFITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 15193323Sedfor more details. 16193323Sed 17193323SedUnder Section 7 of GPL version 3, you are granted additional 18193323Sedpermissions described in the GCC Runtime Library Exception, version 19193323Sed3.1, as published by the Free Software Foundation. 20193323Sed 21193323SedYou should have received a copy of the GNU General Public License and 22249423Sdima copy of the GCC Runtime Library Exception along with this program; 23249423Sdimsee the files COPYING3 and COPYING.RUNTIME respectively. If not, see 24249423Sdim<http://www.gnu.org/licenses/>. */ 25249423Sdim 26249423Sdim#include "arc-ieee-754.h" 27193323Sed 28193323Sed#if 0 /* DEBUG */ 29198090Srdivacky FUNC(__fixdfsi) 30198090Srdivacky .global __fixdfsi 31249423Sdim .balign 4 32193323Sed__fixdfsi: 33193323Sed push_s blink 34276479Sdim push_s r0 35276479Sdim bl.d __fixdfsi_c 36199481Srdivacky push_s r1 37199481Srdivacky mov_s r2,r0 38199481Srdivacky pop_s r1 39199481Srdivacky ld r0,[sp] 40199481Srdivacky bl.d __fixdfsi_asm 41199481Srdivacky st r2,[sp] 42199481Srdivacky pop_s r1 43199481Srdivacky pop_s blink 44199481Srdivacky cmp r0,r1 45199481Srdivacky jeq_s [blink] 46199481Srdivacky bl abort 47199481Srdivacky ENDFUNC(__fixdfsi) 48199481Srdivacky#define __fixdfsi __fixdfsi_asm 49207618Srdivacky#endif /* DEBUG */ 50207618Srdivacky 51207618Srdivacky/* If the fraction has to be shifted left by a positive non-zero amount, 52199481Srdivacky we have to combine bits from DBL0L and DBL0H. If we shift right, 53199481Srdivacky or shift by zero, we only want to have the bits from DBL0H in r0. */ 54199481Srdivacky 55199481Srdivacky .global __fixdfsi 56199481Srdivacky FUNC(__fixdfsi) 57276479Sdim .balign 4 58276479Sdim__fixdfsi: 59199481Srdivacky bbit0 DBL0H,30,.Lret0or1 60199481Srdivacky asr r2,DBL0H,20 61199481Srdivacky bmsk_s DBL0H,DBL0H,19 62276479Sdim sub_s r2,r2,19; 0x3ff+20-0x400 63199481Srdivacky neg_s r3,r2 64199481Srdivacky asr.f 0,r3,11 65199481Srdivacky bset_s DBL0H,DBL0H,20 66199481Srdivacky#ifdef __LITTLE_ENDIAN__ 67276479Sdim mov.cs DBL0L,DBL0H 68199481Srdivacky asl DBL0H,DBL0H,r2 69199481Srdivacky#else 70200581Srdivacky asl.cc DBL0H,DBL0H,r2 71199481Srdivacky lsr.cs DBL0H,DBL0H,r3 72199481Srdivacky#endif 73199481Srdivacky lsr_s DBL0L,DBL0L,r3 74199481Srdivacky 75199481Srdivacky add.cc r0,r0,r1 76199481Srdivacky j_s.d [blink] 77199481Srdivacky neg.pl r0,r0 78199481Srdivacky.Lret0or1: 79199481Srdivacky add.f r0,DBL0H,0x100000 80199481Srdivacky lsr_s r0,r0,30 81199481Srdivacky 82199481Srdivacky bmsk_s r0,r0,0 83199481Srdivacky j_s.d [blink] 84199481Srdivacky neg.mi r0,r0 85199481Srdivacky ENDFUNC(__fixdfsi) 86199481Srdivacky