Back to home page

OSCL-LXR

 
 

    


0001 /* SPDX-License-Identifier: GPL-2.0-or-later */
0002 /* Copyright (C) 1989, 1992, 1993, 1994, 1995 Free Software Foundation, Inc.
0003 
0004 This file is part of GNU CC.
0005 
0006  */
0007 
0008     .text
0009     .align 4
0010     .globl __udivdi3
0011 __udivdi3:
0012     save %sp,-104,%sp
0013     mov %i3,%o3
0014     cmp %i2,0
0015     bne .LL40
0016     mov %i1,%i3
0017     cmp %o3,%i0
0018     bleu .LL41
0019     mov %i3,%o1
0020     ! Inlined udiv_qrnnd
0021     mov 32,%g1
0022     subcc   %i0,%o3,%g0
0023 1:  bcs 5f
0024      addxcc %o1,%o1,%o1 ! shift n1n0 and a q-bit in lsb
0025     sub %i0,%o3,%i0 ! this kills msb of n
0026     addx    %i0,%i0,%i0 ! so this cannot give carry
0027     subcc   %g1,1,%g1
0028 2:  bne 1b
0029      subcc  %i0,%o3,%g0
0030     bcs 3f
0031      addxcc %o1,%o1,%o1 ! shift n1n0 and a q-bit in lsb
0032     b   3f
0033      sub    %i0,%o3,%i0 ! this kills msb of n
0034 4:  sub %i0,%o3,%i0
0035 5:  addxcc  %i0,%i0,%i0
0036     bcc 2b
0037      subcc  %g1,1,%g1
0038 ! Got carry from n.  Subtract next step to cancel this carry.
0039     bne 4b
0040      addcc  %o1,%o1,%o1 ! shift n1n0 and a 0-bit in lsb
0041     sub %i0,%o3,%i0
0042 3:  xnor    %o1,0,%o1
0043     ! End of inline udiv_qrnnd
0044     b .LL45
0045     mov 0,%o2
0046 .LL41:
0047     cmp %o3,0
0048     bne .LL77
0049     mov %i0,%o2
0050     mov 1,%o0
0051     mov 0,%o1
0052     wr %g0, 0, %y
0053     udiv %o0, %o1, %o0
0054     mov %o0,%o3
0055     mov %i0,%o2
0056 .LL77:
0057     mov 0,%o4
0058     ! Inlined udiv_qrnnd
0059     mov 32,%g1
0060     subcc   %o4,%o3,%g0
0061 1:  bcs 5f
0062      addxcc %o2,%o2,%o2 ! shift n1n0 and a q-bit in lsb
0063     sub %o4,%o3,%o4 ! this kills msb of n
0064     addx    %o4,%o4,%o4 ! so this cannot give carry
0065     subcc   %g1,1,%g1
0066 2:  bne 1b
0067      subcc  %o4,%o3,%g0
0068     bcs 3f
0069      addxcc %o2,%o2,%o2 ! shift n1n0 and a q-bit in lsb
0070     b   3f
0071      sub    %o4,%o3,%o4 ! this kills msb of n
0072 4:  sub %o4,%o3,%o4
0073 5:  addxcc  %o4,%o4,%o4
0074     bcc 2b
0075      subcc  %g1,1,%g1
0076 ! Got carry from n.  Subtract next step to cancel this carry.
0077     bne 4b
0078      addcc  %o2,%o2,%o2 ! shift n1n0 and a 0-bit in lsb
0079     sub %o4,%o3,%o4
0080 3:  xnor    %o2,0,%o2
0081     ! End of inline udiv_qrnnd
0082     mov %o4,%i0
0083     mov %i3,%o1
0084     ! Inlined udiv_qrnnd
0085     mov 32,%g1
0086     subcc   %i0,%o3,%g0
0087 1:  bcs 5f
0088      addxcc %o1,%o1,%o1 ! shift n1n0 and a q-bit in lsb
0089     sub %i0,%o3,%i0 ! this kills msb of n
0090     addx    %i0,%i0,%i0 ! so this cannot give carry
0091     subcc   %g1,1,%g1
0092 2:  bne 1b
0093      subcc  %i0,%o3,%g0
0094     bcs 3f
0095      addxcc %o1,%o1,%o1 ! shift n1n0 and a q-bit in lsb
0096     b   3f
0097      sub    %i0,%o3,%i0 ! this kills msb of n
0098 4:  sub %i0,%o3,%i0
0099 5:  addxcc  %i0,%i0,%i0
0100     bcc 2b
0101      subcc  %g1,1,%g1
0102 ! Got carry from n.  Subtract next step to cancel this carry.
0103     bne 4b
0104      addcc  %o1,%o1,%o1 ! shift n1n0 and a 0-bit in lsb
0105     sub %i0,%o3,%i0
0106 3:  xnor    %o1,0,%o1
0107     ! End of inline udiv_qrnnd
0108     b .LL78
0109     mov %o1,%l1
0110 .LL40:
0111     cmp %i2,%i0
0112     bleu .LL46
0113     sethi %hi(65535),%o0
0114     b .LL73
0115     mov 0,%o1
0116 .LL46:
0117     or %o0,%lo(65535),%o0
0118     cmp %i2,%o0
0119     bgu .LL53
0120     mov %i2,%o1
0121     cmp %i2,256
0122     addx %g0,-1,%o0
0123     b .LL59
0124     and %o0,8,%o2
0125 .LL53:
0126     sethi %hi(16777215),%o0
0127     or %o0,%lo(16777215),%o0
0128     cmp %o1,%o0
0129     bgu .LL59
0130     mov 24,%o2
0131     mov 16,%o2
0132 .LL59:
0133     srl %o1,%o2,%o1
0134     sethi %hi(__clz_tab),%o0
0135     or %o0,%lo(__clz_tab),%o0
0136     ldub [%o1+%o0],%o0
0137     add %o0,%o2,%o0
0138     mov 32,%o1
0139     subcc %o1,%o0,%o2
0140     bne,a .LL67
0141     mov 32,%o0
0142     cmp %i0,%i2
0143     bgu .LL69
0144     cmp %i3,%o3
0145     blu .LL73
0146     mov 0,%o1
0147 .LL69:
0148     b .LL73
0149     mov 1,%o1
0150 .LL67:
0151     sub %o0,%o2,%o0
0152     sll %i2,%o2,%i2
0153     srl %o3,%o0,%o1
0154     or %i2,%o1,%i2
0155     sll %o3,%o2,%o3
0156     srl %i0,%o0,%o1
0157     sll %i0,%o2,%i0
0158     srl %i3,%o0,%o0
0159     or %i0,%o0,%i0
0160     sll %i3,%o2,%i3
0161     mov %i0,%o5
0162     mov %o1,%o4
0163     ! Inlined udiv_qrnnd
0164     mov 32,%g1
0165     subcc   %o4,%i2,%g0
0166 1:  bcs 5f
0167      addxcc %o5,%o5,%o5 ! shift n1n0 and a q-bit in lsb
0168     sub %o4,%i2,%o4 ! this kills msb of n
0169     addx    %o4,%o4,%o4 ! so this cannot give carry
0170     subcc   %g1,1,%g1
0171 2:  bne 1b
0172      subcc  %o4,%i2,%g0
0173     bcs 3f
0174      addxcc %o5,%o5,%o5 ! shift n1n0 and a q-bit in lsb
0175     b   3f
0176      sub    %o4,%i2,%o4 ! this kills msb of n
0177 4:  sub %o4,%i2,%o4
0178 5:  addxcc  %o4,%o4,%o4
0179     bcc 2b
0180      subcc  %g1,1,%g1
0181 ! Got carry from n.  Subtract next step to cancel this carry.
0182     bne 4b
0183      addcc  %o5,%o5,%o5 ! shift n1n0 and a 0-bit in lsb
0184     sub %o4,%i2,%o4
0185 3:  xnor    %o5,0,%o5
0186     ! End of inline udiv_qrnnd
0187     mov %o4,%i0
0188     mov %o5,%o1
0189     ! Inlined umul_ppmm
0190     wr  %g0,%o1,%y  ! SPARC has 0-3 delay insn after a wr
0191     sra %o3,31,%g2  ! Do not move this insn
0192     and %o1,%g2,%g2 ! Do not move this insn
0193     andcc   %g0,0,%g1   ! Do not move this insn
0194     mulscc  %g1,%o3,%g1
0195     mulscc  %g1,%o3,%g1
0196     mulscc  %g1,%o3,%g1
0197     mulscc  %g1,%o3,%g1
0198     mulscc  %g1,%o3,%g1
0199     mulscc  %g1,%o3,%g1
0200     mulscc  %g1,%o3,%g1
0201     mulscc  %g1,%o3,%g1
0202     mulscc  %g1,%o3,%g1
0203     mulscc  %g1,%o3,%g1
0204     mulscc  %g1,%o3,%g1
0205     mulscc  %g1,%o3,%g1
0206     mulscc  %g1,%o3,%g1
0207     mulscc  %g1,%o3,%g1
0208     mulscc  %g1,%o3,%g1
0209     mulscc  %g1,%o3,%g1
0210     mulscc  %g1,%o3,%g1
0211     mulscc  %g1,%o3,%g1
0212     mulscc  %g1,%o3,%g1
0213     mulscc  %g1,%o3,%g1
0214     mulscc  %g1,%o3,%g1
0215     mulscc  %g1,%o3,%g1
0216     mulscc  %g1,%o3,%g1
0217     mulscc  %g1,%o3,%g1
0218     mulscc  %g1,%o3,%g1
0219     mulscc  %g1,%o3,%g1
0220     mulscc  %g1,%o3,%g1
0221     mulscc  %g1,%o3,%g1
0222     mulscc  %g1,%o3,%g1
0223     mulscc  %g1,%o3,%g1
0224     mulscc  %g1,%o3,%g1
0225     mulscc  %g1,%o3,%g1
0226     mulscc  %g1,0,%g1
0227     add %g1,%g2,%o0
0228     rd  %y,%o2
0229     cmp %o0,%i0
0230     bgu,a .LL73
0231     add %o1,-1,%o1
0232     bne,a .LL45
0233     mov 0,%o2
0234     cmp %o2,%i3
0235     bleu .LL45
0236     mov 0,%o2
0237     add %o1,-1,%o1
0238 .LL73:
0239     mov 0,%o2
0240 .LL45:
0241     mov %o1,%l1
0242 .LL78:
0243     mov %o2,%l0
0244     mov %l0,%i0
0245     mov %l1,%i1
0246     ret
0247     restore