18c2ecf20Sopenharmony_ci/* SPDX-License-Identifier: GPL-2.0-or-later */ 28c2ecf20Sopenharmony_ci/* Copyright (C) 1989, 1992, 1993, 1994, 1995 Free Software Foundation, Inc. 38c2ecf20Sopenharmony_ci 48c2ecf20Sopenharmony_ciThis file is part of GNU CC. 58c2ecf20Sopenharmony_ci 68c2ecf20Sopenharmony_ci */ 78c2ecf20Sopenharmony_ci 88c2ecf20Sopenharmony_ci .text 98c2ecf20Sopenharmony_ci .align 4 108c2ecf20Sopenharmony_ci .globl __udivdi3 118c2ecf20Sopenharmony_ci__udivdi3: 128c2ecf20Sopenharmony_ci save %sp,-104,%sp 138c2ecf20Sopenharmony_ci mov %i3,%o3 148c2ecf20Sopenharmony_ci cmp %i2,0 158c2ecf20Sopenharmony_ci bne .LL40 168c2ecf20Sopenharmony_ci mov %i1,%i3 178c2ecf20Sopenharmony_ci cmp %o3,%i0 188c2ecf20Sopenharmony_ci bleu .LL41 198c2ecf20Sopenharmony_ci mov %i3,%o1 208c2ecf20Sopenharmony_ci ! Inlined udiv_qrnnd 218c2ecf20Sopenharmony_ci mov 32,%g1 228c2ecf20Sopenharmony_ci subcc %i0,%o3,%g0 238c2ecf20Sopenharmony_ci1: bcs 5f 248c2ecf20Sopenharmony_ci addxcc %o1,%o1,%o1 ! shift n1n0 and a q-bit in lsb 258c2ecf20Sopenharmony_ci sub %i0,%o3,%i0 ! this kills msb of n 268c2ecf20Sopenharmony_ci addx %i0,%i0,%i0 ! so this cannot give carry 278c2ecf20Sopenharmony_ci subcc %g1,1,%g1 288c2ecf20Sopenharmony_ci2: bne 1b 298c2ecf20Sopenharmony_ci subcc %i0,%o3,%g0 308c2ecf20Sopenharmony_ci bcs 3f 318c2ecf20Sopenharmony_ci addxcc %o1,%o1,%o1 ! shift n1n0 and a q-bit in lsb 328c2ecf20Sopenharmony_ci b 3f 338c2ecf20Sopenharmony_ci sub %i0,%o3,%i0 ! this kills msb of n 348c2ecf20Sopenharmony_ci4: sub %i0,%o3,%i0 358c2ecf20Sopenharmony_ci5: addxcc %i0,%i0,%i0 368c2ecf20Sopenharmony_ci bcc 2b 378c2ecf20Sopenharmony_ci subcc %g1,1,%g1 388c2ecf20Sopenharmony_ci! Got carry from n. Subtract next step to cancel this carry. 398c2ecf20Sopenharmony_ci bne 4b 408c2ecf20Sopenharmony_ci addcc %o1,%o1,%o1 ! shift n1n0 and a 0-bit in lsb 418c2ecf20Sopenharmony_ci sub %i0,%o3,%i0 428c2ecf20Sopenharmony_ci3: xnor %o1,0,%o1 438c2ecf20Sopenharmony_ci ! End of inline udiv_qrnnd 448c2ecf20Sopenharmony_ci b .LL45 458c2ecf20Sopenharmony_ci mov 0,%o2 468c2ecf20Sopenharmony_ci.LL41: 478c2ecf20Sopenharmony_ci cmp %o3,0 488c2ecf20Sopenharmony_ci bne .LL77 498c2ecf20Sopenharmony_ci mov %i0,%o2 508c2ecf20Sopenharmony_ci mov 1,%o0 518c2ecf20Sopenharmony_ci mov 0,%o1 528c2ecf20Sopenharmony_ci wr %g0, 0, %y 538c2ecf20Sopenharmony_ci udiv %o0, %o1, %o0 548c2ecf20Sopenharmony_ci mov %o0,%o3 558c2ecf20Sopenharmony_ci mov %i0,%o2 568c2ecf20Sopenharmony_ci.LL77: 578c2ecf20Sopenharmony_ci mov 0,%o4 588c2ecf20Sopenharmony_ci ! Inlined udiv_qrnnd 598c2ecf20Sopenharmony_ci mov 32,%g1 608c2ecf20Sopenharmony_ci subcc %o4,%o3,%g0 618c2ecf20Sopenharmony_ci1: bcs 5f 628c2ecf20Sopenharmony_ci addxcc %o2,%o2,%o2 ! shift n1n0 and a q-bit in lsb 638c2ecf20Sopenharmony_ci sub %o4,%o3,%o4 ! this kills msb of n 648c2ecf20Sopenharmony_ci addx %o4,%o4,%o4 ! so this cannot give carry 658c2ecf20Sopenharmony_ci subcc %g1,1,%g1 668c2ecf20Sopenharmony_ci2: bne 1b 678c2ecf20Sopenharmony_ci subcc %o4,%o3,%g0 688c2ecf20Sopenharmony_ci bcs 3f 698c2ecf20Sopenharmony_ci addxcc %o2,%o2,%o2 ! shift n1n0 and a q-bit in lsb 708c2ecf20Sopenharmony_ci b 3f 718c2ecf20Sopenharmony_ci sub %o4,%o3,%o4 ! this kills msb of n 728c2ecf20Sopenharmony_ci4: sub %o4,%o3,%o4 738c2ecf20Sopenharmony_ci5: addxcc %o4,%o4,%o4 748c2ecf20Sopenharmony_ci bcc 2b 758c2ecf20Sopenharmony_ci subcc %g1,1,%g1 768c2ecf20Sopenharmony_ci! Got carry from n. Subtract next step to cancel this carry. 778c2ecf20Sopenharmony_ci bne 4b 788c2ecf20Sopenharmony_ci addcc %o2,%o2,%o2 ! shift n1n0 and a 0-bit in lsb 798c2ecf20Sopenharmony_ci sub %o4,%o3,%o4 808c2ecf20Sopenharmony_ci3: xnor %o2,0,%o2 818c2ecf20Sopenharmony_ci ! End of inline udiv_qrnnd 828c2ecf20Sopenharmony_ci mov %o4,%i0 838c2ecf20Sopenharmony_ci mov %i3,%o1 848c2ecf20Sopenharmony_ci ! Inlined udiv_qrnnd 858c2ecf20Sopenharmony_ci mov 32,%g1 868c2ecf20Sopenharmony_ci subcc %i0,%o3,%g0 878c2ecf20Sopenharmony_ci1: bcs 5f 888c2ecf20Sopenharmony_ci addxcc %o1,%o1,%o1 ! shift n1n0 and a q-bit in lsb 898c2ecf20Sopenharmony_ci sub %i0,%o3,%i0 ! this kills msb of n 908c2ecf20Sopenharmony_ci addx %i0,%i0,%i0 ! so this cannot give carry 918c2ecf20Sopenharmony_ci subcc %g1,1,%g1 928c2ecf20Sopenharmony_ci2: bne 1b 938c2ecf20Sopenharmony_ci subcc %i0,%o3,%g0 948c2ecf20Sopenharmony_ci bcs 3f 958c2ecf20Sopenharmony_ci addxcc %o1,%o1,%o1 ! shift n1n0 and a q-bit in lsb 968c2ecf20Sopenharmony_ci b 3f 978c2ecf20Sopenharmony_ci sub %i0,%o3,%i0 ! this kills msb of n 988c2ecf20Sopenharmony_ci4: sub %i0,%o3,%i0 998c2ecf20Sopenharmony_ci5: addxcc %i0,%i0,%i0 1008c2ecf20Sopenharmony_ci bcc 2b 1018c2ecf20Sopenharmony_ci subcc %g1,1,%g1 1028c2ecf20Sopenharmony_ci! Got carry from n. Subtract next step to cancel this carry. 1038c2ecf20Sopenharmony_ci bne 4b 1048c2ecf20Sopenharmony_ci addcc %o1,%o1,%o1 ! shift n1n0 and a 0-bit in lsb 1058c2ecf20Sopenharmony_ci sub %i0,%o3,%i0 1068c2ecf20Sopenharmony_ci3: xnor %o1,0,%o1 1078c2ecf20Sopenharmony_ci ! End of inline udiv_qrnnd 1088c2ecf20Sopenharmony_ci b .LL78 1098c2ecf20Sopenharmony_ci mov %o1,%l1 1108c2ecf20Sopenharmony_ci.LL40: 1118c2ecf20Sopenharmony_ci cmp %i2,%i0 1128c2ecf20Sopenharmony_ci bleu .LL46 1138c2ecf20Sopenharmony_ci sethi %hi(65535),%o0 1148c2ecf20Sopenharmony_ci b .LL73 1158c2ecf20Sopenharmony_ci mov 0,%o1 1168c2ecf20Sopenharmony_ci.LL46: 1178c2ecf20Sopenharmony_ci or %o0,%lo(65535),%o0 1188c2ecf20Sopenharmony_ci cmp %i2,%o0 1198c2ecf20Sopenharmony_ci bgu .LL53 1208c2ecf20Sopenharmony_ci mov %i2,%o1 1218c2ecf20Sopenharmony_ci cmp %i2,256 1228c2ecf20Sopenharmony_ci addx %g0,-1,%o0 1238c2ecf20Sopenharmony_ci b .LL59 1248c2ecf20Sopenharmony_ci and %o0,8,%o2 1258c2ecf20Sopenharmony_ci.LL53: 1268c2ecf20Sopenharmony_ci sethi %hi(16777215),%o0 1278c2ecf20Sopenharmony_ci or %o0,%lo(16777215),%o0 1288c2ecf20Sopenharmony_ci cmp %o1,%o0 1298c2ecf20Sopenharmony_ci bgu .LL59 1308c2ecf20Sopenharmony_ci mov 24,%o2 1318c2ecf20Sopenharmony_ci mov 16,%o2 1328c2ecf20Sopenharmony_ci.LL59: 1338c2ecf20Sopenharmony_ci srl %o1,%o2,%o1 1348c2ecf20Sopenharmony_ci sethi %hi(__clz_tab),%o0 1358c2ecf20Sopenharmony_ci or %o0,%lo(__clz_tab),%o0 1368c2ecf20Sopenharmony_ci ldub [%o1+%o0],%o0 1378c2ecf20Sopenharmony_ci add %o0,%o2,%o0 1388c2ecf20Sopenharmony_ci mov 32,%o1 1398c2ecf20Sopenharmony_ci subcc %o1,%o0,%o2 1408c2ecf20Sopenharmony_ci bne,a .LL67 1418c2ecf20Sopenharmony_ci mov 32,%o0 1428c2ecf20Sopenharmony_ci cmp %i0,%i2 1438c2ecf20Sopenharmony_ci bgu .LL69 1448c2ecf20Sopenharmony_ci cmp %i3,%o3 1458c2ecf20Sopenharmony_ci blu .LL73 1468c2ecf20Sopenharmony_ci mov 0,%o1 1478c2ecf20Sopenharmony_ci.LL69: 1488c2ecf20Sopenharmony_ci b .LL73 1498c2ecf20Sopenharmony_ci mov 1,%o1 1508c2ecf20Sopenharmony_ci.LL67: 1518c2ecf20Sopenharmony_ci sub %o0,%o2,%o0 1528c2ecf20Sopenharmony_ci sll %i2,%o2,%i2 1538c2ecf20Sopenharmony_ci srl %o3,%o0,%o1 1548c2ecf20Sopenharmony_ci or %i2,%o1,%i2 1558c2ecf20Sopenharmony_ci sll %o3,%o2,%o3 1568c2ecf20Sopenharmony_ci srl %i0,%o0,%o1 1578c2ecf20Sopenharmony_ci sll %i0,%o2,%i0 1588c2ecf20Sopenharmony_ci srl %i3,%o0,%o0 1598c2ecf20Sopenharmony_ci or %i0,%o0,%i0 1608c2ecf20Sopenharmony_ci sll %i3,%o2,%i3 1618c2ecf20Sopenharmony_ci mov %i0,%o5 1628c2ecf20Sopenharmony_ci mov %o1,%o4 1638c2ecf20Sopenharmony_ci ! Inlined udiv_qrnnd 1648c2ecf20Sopenharmony_ci mov 32,%g1 1658c2ecf20Sopenharmony_ci subcc %o4,%i2,%g0 1668c2ecf20Sopenharmony_ci1: bcs 5f 1678c2ecf20Sopenharmony_ci addxcc %o5,%o5,%o5 ! shift n1n0 and a q-bit in lsb 1688c2ecf20Sopenharmony_ci sub %o4,%i2,%o4 ! this kills msb of n 1698c2ecf20Sopenharmony_ci addx %o4,%o4,%o4 ! so this cannot give carry 1708c2ecf20Sopenharmony_ci subcc %g1,1,%g1 1718c2ecf20Sopenharmony_ci2: bne 1b 1728c2ecf20Sopenharmony_ci subcc %o4,%i2,%g0 1738c2ecf20Sopenharmony_ci bcs 3f 1748c2ecf20Sopenharmony_ci addxcc %o5,%o5,%o5 ! shift n1n0 and a q-bit in lsb 1758c2ecf20Sopenharmony_ci b 3f 1768c2ecf20Sopenharmony_ci sub %o4,%i2,%o4 ! this kills msb of n 1778c2ecf20Sopenharmony_ci4: sub %o4,%i2,%o4 1788c2ecf20Sopenharmony_ci5: addxcc %o4,%o4,%o4 1798c2ecf20Sopenharmony_ci bcc 2b 1808c2ecf20Sopenharmony_ci subcc %g1,1,%g1 1818c2ecf20Sopenharmony_ci! Got carry from n. Subtract next step to cancel this carry. 1828c2ecf20Sopenharmony_ci bne 4b 1838c2ecf20Sopenharmony_ci addcc %o5,%o5,%o5 ! shift n1n0 and a 0-bit in lsb 1848c2ecf20Sopenharmony_ci sub %o4,%i2,%o4 1858c2ecf20Sopenharmony_ci3: xnor %o5,0,%o5 1868c2ecf20Sopenharmony_ci ! End of inline udiv_qrnnd 1878c2ecf20Sopenharmony_ci mov %o4,%i0 1888c2ecf20Sopenharmony_ci mov %o5,%o1 1898c2ecf20Sopenharmony_ci ! Inlined umul_ppmm 1908c2ecf20Sopenharmony_ci wr %g0,%o1,%y ! SPARC has 0-3 delay insn after a wr 1918c2ecf20Sopenharmony_ci sra %o3,31,%g2 ! Do not move this insn 1928c2ecf20Sopenharmony_ci and %o1,%g2,%g2 ! Do not move this insn 1938c2ecf20Sopenharmony_ci andcc %g0,0,%g1 ! Do not move this insn 1948c2ecf20Sopenharmony_ci mulscc %g1,%o3,%g1 1958c2ecf20Sopenharmony_ci mulscc %g1,%o3,%g1 1968c2ecf20Sopenharmony_ci mulscc %g1,%o3,%g1 1978c2ecf20Sopenharmony_ci mulscc %g1,%o3,%g1 1988c2ecf20Sopenharmony_ci mulscc %g1,%o3,%g1 1998c2ecf20Sopenharmony_ci mulscc %g1,%o3,%g1 2008c2ecf20Sopenharmony_ci mulscc %g1,%o3,%g1 2018c2ecf20Sopenharmony_ci mulscc %g1,%o3,%g1 2028c2ecf20Sopenharmony_ci mulscc %g1,%o3,%g1 2038c2ecf20Sopenharmony_ci mulscc %g1,%o3,%g1 2048c2ecf20Sopenharmony_ci mulscc %g1,%o3,%g1 2058c2ecf20Sopenharmony_ci mulscc %g1,%o3,%g1 2068c2ecf20Sopenharmony_ci mulscc %g1,%o3,%g1 2078c2ecf20Sopenharmony_ci mulscc %g1,%o3,%g1 2088c2ecf20Sopenharmony_ci mulscc %g1,%o3,%g1 2098c2ecf20Sopenharmony_ci mulscc %g1,%o3,%g1 2108c2ecf20Sopenharmony_ci mulscc %g1,%o3,%g1 2118c2ecf20Sopenharmony_ci mulscc %g1,%o3,%g1 2128c2ecf20Sopenharmony_ci mulscc %g1,%o3,%g1 2138c2ecf20Sopenharmony_ci mulscc %g1,%o3,%g1 2148c2ecf20Sopenharmony_ci mulscc %g1,%o3,%g1 2158c2ecf20Sopenharmony_ci mulscc %g1,%o3,%g1 2168c2ecf20Sopenharmony_ci mulscc %g1,%o3,%g1 2178c2ecf20Sopenharmony_ci mulscc %g1,%o3,%g1 2188c2ecf20Sopenharmony_ci mulscc %g1,%o3,%g1 2198c2ecf20Sopenharmony_ci mulscc %g1,%o3,%g1 2208c2ecf20Sopenharmony_ci mulscc %g1,%o3,%g1 2218c2ecf20Sopenharmony_ci mulscc %g1,%o3,%g1 2228c2ecf20Sopenharmony_ci mulscc %g1,%o3,%g1 2238c2ecf20Sopenharmony_ci mulscc %g1,%o3,%g1 2248c2ecf20Sopenharmony_ci mulscc %g1,%o3,%g1 2258c2ecf20Sopenharmony_ci mulscc %g1,%o3,%g1 2268c2ecf20Sopenharmony_ci mulscc %g1,0,%g1 2278c2ecf20Sopenharmony_ci add %g1,%g2,%o0 2288c2ecf20Sopenharmony_ci rd %y,%o2 2298c2ecf20Sopenharmony_ci cmp %o0,%i0 2308c2ecf20Sopenharmony_ci bgu,a .LL73 2318c2ecf20Sopenharmony_ci add %o1,-1,%o1 2328c2ecf20Sopenharmony_ci bne,a .LL45 2338c2ecf20Sopenharmony_ci mov 0,%o2 2348c2ecf20Sopenharmony_ci cmp %o2,%i3 2358c2ecf20Sopenharmony_ci bleu .LL45 2368c2ecf20Sopenharmony_ci mov 0,%o2 2378c2ecf20Sopenharmony_ci add %o1,-1,%o1 2388c2ecf20Sopenharmony_ci.LL73: 2398c2ecf20Sopenharmony_ci mov 0,%o2 2408c2ecf20Sopenharmony_ci.LL45: 2418c2ecf20Sopenharmony_ci mov %o1,%l1 2428c2ecf20Sopenharmony_ci.LL78: 2438c2ecf20Sopenharmony_ci mov %o2,%l0 2448c2ecf20Sopenharmony_ci mov %l0,%i0 2458c2ecf20Sopenharmony_ci mov %l1,%i1 2468c2ecf20Sopenharmony_ci ret 2478c2ecf20Sopenharmony_ci restore 248