1/* Copyright (C) 2008-2020 Free Software Foundation, Inc. 2 Contributor: Joern Rennecke <joern.rennecke@embecosm.com> 3 on behalf of Synopsys Inc. 4 5This file is part of GCC. 6 7GCC is free software; you can redistribute it and/or modify it under 8the terms of the GNU General Public License as published by the Free 9Software Foundation; either version 3, or (at your option) any later 10version. 11 12GCC is distributed in the hope that it will be useful, but WITHOUT ANY 13WARRANTY; without even the implied warranty of MERCHANTABILITY or 14FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 15for more details. 16 17Under Section 7 of GPL version 3, you are granted additional 18permissions described in the GCC Runtime Library Exception, version 193.1, as published by the Free Software Foundation. 20 21You should have received a copy of the GNU General Public License and 22a copy of the GCC Runtime Library Exception along with this program; 23see the files COPYING3 and COPYING.RUNTIME respectively. If not, see 24<http://www.gnu.org/licenses/>. */ 25 26#include "../arc-ieee-754.h" 27 28#if 0 /* DEBUG */ 29 .global __mulsf3 30 FUNC(__mulsf3) 31 .balign 4 32__mulsf3: 33 push_s blink 34 push_s r1 35 bl.d __mulsf3_c 36 push_s r0 37 ld_s r1,[sp,4] 38 st_s r0,[sp,4] 39 bl.d __mulsf3_asm 40 pop_s r0 41 pop_s r1 42 pop_s blink 43 cmp r0,r1 44 jeq_s [blink] 45 and r12,r0,r1 46 bic.f 0,0x7f800000,r12 47 bne 0f 48 bmsk.f 0,r0,22 49 bmsk.ne.f r1,r1,22 50 jne_s [blink] ; both NaN -> OK 510: bl abort 52 ENDFUNC(__mulsf3) 53#define __mulsf3 __mulsf3_asm 54#endif /* DEBUG */ 55 56 .balign 4 57 .global __mulsf3 58 FUNC(__mulsf3) 59__mulsf3: 60 ld.as r9,[pcl,76]; [pcl,((.L7f800000-.+2)/4)] 61 bmsk r4,r1,22 62 bset r3,r4,23 63 bmsk r2,r0,22 64 and r11,r0,r9 65 breq.d r11,0,.Ldenorm_dbl0 66 and r12,r1,r9 67 xor_s r0,r0,r1 68 breq.d r11,r9,.Linf_nan_dbl0 69 bset_s r2,r2,23 70 breq r12,0,.Ldenorm_dbl1 71 breq r12,r9,.Linf_nan_dbl1 72.Lpast_denorm: 73 mov r6,0 74 lsr.f r7,r2 75; We could so this a bit faster here with a 32 bit shift register and 76; inserting the r2 factor / retrieving the low result a byte at a time, 77; but that'd increase code size. 78 mov lp_count,24 79 .balign 4 80 lp 0f 81 add.cs r6,r6,r3 82 lsr.f r6,r6 83 rrc.f r7,r7 840: 85 ld.as r4,[pcl,59]; [pcl,((.L7fffffff-.+2)/4)] 86 asl.f 0,r6,8 87 add.pl r6,r6,r6 88 bclr.pl r6,r6,23 89 add.pl.f r7,r7,r7 90 add.cs r6,r6,1 91 lsr.f 0,r6,1 92 add_s r12,r12,r11 93 adc.f 0,r7,r4 94 add_s r12,r12, \ 95 -0x3f800000 96 adc.f r8,r6,r12 97 tst.pl r8,r9 98 bic r0,r0,r4 99 min r3,r8,r9 100 jpnz.d [blink] 101 add.pnz r0,r0,r3 102; infinity or denormal number 103 add.ne.f r3,r3,r3 104 asr_s r3,r3,23+1 105 bset r6,r6,23 106 bpnz.d .Linfinity 107 sub_s r3,r3,1 108 neg_s r2,r3 109 brhi.d r2,24,.Lret_r0 ; right shift shift > 24 -> return +-0 110 lsr r2,r6,r2 111 asl r9,r6,r3 112 lsr.f 0,r2,1 113 tst r7,r7 114 add_s r0,r0,r2 115 bset.ne r9,r9,0 116 adc.f 0,r9,r4 117 j_s.d [blink] 118 add.cs r0,r0,1 119.Linfinity: 120 j_s.d [blink] 121 add_s r0,r0,r9 122 123.Lret_r0: j_s [blink] 124 125 .balign 4 126.Ldenorm_dbl0: 127 asl_s r2,r2,8 128 norm.f r4,r2 129 lsr_s r2,r2,7 130 asl r2,r2,r4 131 breq.d r12,r9,.Ldenorm_dbl0_inf_nan_dbl1 132 asl r4,r4,23 133 sub.ne.f r12,r12,r4 134 bhi.d .Lpast_denorm 135 xor_s r0,r0,r1 136 bmsk r1,r0,30 137 j_s.d [blink] 138 bic_s r0,r0,r1 139 140 .balign 4 141.Ldenorm_dbl0_inf_nan_dbl1: 142 bmsk.f 0,r0,30 143 beq_s .Lretnan 144 xor_s r0,r0,r1 145.Linf_nan_dbl1: 146 xor_s r1,r1,r0 147 bclr_s r1,r1,31 148 j_s.d [blink] 149 xor_s r0,r0,r1 150.Linf_nan_dbl0: 151 sub_s r2,r1,1 ; inf/nan * 0 -> nan; inf * nan -> nan (use |r2| >= inf) 152 bic.f 0,r9,r2 153 xor_s r0,r0,r1 154 bclr_s r1,r1,31 155 xor_s r0,r0,r1 156 jne_s [blink] 157.Lretnan: 158 j_s.d [blink] 159 mov r0,-1 160 .balign 4 161.Ldenorm_dbl1: 162 norm.f r3,r4 163 sub_s r3,r3,7 164 asl r4,r4,r3 165 sub_s r3,r3,1 166 asl_s r3,r3,23 167 sub.ne.f r11,r11,r3 168 bhi.d .Lpast_denorm 169 mov_s r3,r4 170 bmsk r3,r0,30 171 j_s.d [blink] 172 bic_s r0,r0,r3 173 174 .balign 4 175.L7f800000: 176 .long 0x7f800000 177.L7fffffff: 178 .long 0x7fffffff 179 ENDFUNC(__mulsf3) 180