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 #include <asm/export.h>
0009     .text
0010     .align 4
0011     .globl __divdi3
0012 __divdi3:
0013     save %sp,-104,%sp
0014     cmp %i0,0
0015     bge .LL40
0016     mov 0,%l4
0017     mov -1,%l4
0018     sub %g0,%i1,%o0
0019     mov %o0,%o5
0020     subcc %g0,%o0,%g0
0021     sub %g0,%i0,%o0
0022     subx %o0,0,%o4
0023     mov %o4,%i0
0024     mov %o5,%i1
0025 .LL40:
0026     cmp %i2,0
0027     bge .LL84
0028     mov %i3,%o4
0029     xnor %g0,%l4,%l4
0030     sub %g0,%i3,%o0
0031     mov %o0,%o3
0032     subcc %g0,%o0,%g0
0033     sub %g0,%i2,%o0
0034     subx %o0,0,%o2
0035     mov %o2,%i2
0036     mov %o3,%i3
0037     mov %i3,%o4
0038 .LL84:
0039     cmp %i2,0
0040     bne .LL45
0041     mov %i1,%i3
0042     cmp %o4,%i0
0043     bleu .LL46
0044     mov %i3,%o1
0045     mov 32,%g1
0046     subcc   %i0,%o4,%g0
0047 1:  bcs 5f
0048      addxcc %o1,%o1,%o1 ! shift n1n0 and a q-bit in lsb
0049     sub %i0,%o4,%i0 ! this kills msb of n
0050     addx    %i0,%i0,%i0 ! so this cannot give carry
0051     subcc   %g1,1,%g1
0052 2:  bne 1b
0053      subcc  %i0,%o4,%g0
0054     bcs 3f
0055      addxcc %o1,%o1,%o1 ! shift n1n0 and a q-bit in lsb
0056     b   3f
0057      sub    %i0,%o4,%i0 ! this kills msb of n
0058 4:  sub %i0,%o4,%i0
0059 5:  addxcc  %i0,%i0,%i0
0060     bcc 2b
0061      subcc  %g1,1,%g1
0062 ! Got carry from n.  Subtract next step to cancel this carry.
0063     bne 4b
0064      addcc  %o1,%o1,%o1 ! shift n1n0 and a 0-bit in lsb
0065     sub %i0,%o4,%i0
0066 3:  xnor    %o1,0,%o1
0067     b .LL50
0068     mov 0,%o2
0069 .LL46:
0070     cmp %o4,0
0071     bne .LL85
0072     mov %i0,%o2
0073     mov 1,%o0
0074     mov 0,%o1
0075     wr %g0, 0, %y
0076     udiv %o0, %o1, %o0
0077     mov %o0,%o4
0078     mov %i0,%o2
0079 .LL85:
0080     mov 0,%g3
0081     mov 32,%g1
0082     subcc   %g3,%o4,%g0
0083 1:  bcs 5f
0084      addxcc %o2,%o2,%o2 ! shift n1n0 and a q-bit in lsb
0085     sub %g3,%o4,%g3 ! this kills msb of n
0086     addx    %g3,%g3,%g3 ! so this cannot give carry
0087     subcc   %g1,1,%g1
0088 2:  bne 1b
0089      subcc  %g3,%o4,%g0
0090     bcs 3f
0091      addxcc %o2,%o2,%o2 ! shift n1n0 and a q-bit in lsb
0092     b   3f
0093      sub    %g3,%o4,%g3 ! this kills msb of n
0094 4:  sub %g3,%o4,%g3
0095 5:  addxcc  %g3,%g3,%g3
0096     bcc 2b
0097      subcc  %g1,1,%g1
0098 ! Got carry from n.  Subtract next step to cancel this carry.
0099     bne 4b
0100      addcc  %o2,%o2,%o2 ! shift n1n0 and a 0-bit in lsb
0101     sub %g3,%o4,%g3
0102 3:  xnor    %o2,0,%o2
0103     mov %g3,%i0
0104     mov %i3,%o1
0105     mov 32,%g1
0106     subcc   %i0,%o4,%g0
0107 1:  bcs 5f
0108      addxcc %o1,%o1,%o1 ! shift n1n0 and a q-bit in lsb
0109     sub %i0,%o4,%i0 ! this kills msb of n
0110     addx    %i0,%i0,%i0 ! so this cannot give carry
0111     subcc   %g1,1,%g1
0112 2:  bne 1b
0113      subcc  %i0,%o4,%g0
0114     bcs 3f
0115      addxcc %o1,%o1,%o1 ! shift n1n0 and a q-bit in lsb
0116     b   3f
0117      sub    %i0,%o4,%i0 ! this kills msb of n
0118 4:  sub %i0,%o4,%i0
0119 5:  addxcc  %i0,%i0,%i0
0120     bcc 2b
0121      subcc  %g1,1,%g1
0122 ! Got carry from n.  Subtract next step to cancel this carry.
0123     bne 4b
0124      addcc  %o1,%o1,%o1 ! shift n1n0 and a 0-bit in lsb
0125     sub %i0,%o4,%i0
0126 3:  xnor    %o1,0,%o1
0127     b .LL86
0128     mov %o1,%l1
0129 .LL45:
0130     cmp %i2,%i0
0131     bleu .LL51
0132     sethi %hi(65535),%o0
0133     b .LL78
0134     mov 0,%o1
0135 .LL51:
0136     or %o0,%lo(65535),%o0
0137     cmp %i2,%o0
0138     bgu .LL58
0139     mov %i2,%o1
0140     cmp %i2,256
0141     addx %g0,-1,%o0
0142     b .LL64
0143     and %o0,8,%o2
0144 .LL58:
0145     sethi %hi(16777215),%o0
0146     or %o0,%lo(16777215),%o0
0147     cmp %i2,%o0
0148     bgu .LL64
0149     mov 24,%o2
0150     mov 16,%o2
0151 .LL64:
0152     srl %o1,%o2,%o0
0153     sethi %hi(__clz_tab),%o1
0154     or %o1,%lo(__clz_tab),%o1
0155     ldub [%o0+%o1],%o0
0156     add %o0,%o2,%o0
0157     mov 32,%o1
0158     subcc %o1,%o0,%o3
0159     bne,a .LL72
0160     sub %o1,%o3,%o1
0161     cmp %i0,%i2
0162     bgu .LL74
0163     cmp %i3,%o4
0164     blu .LL78
0165     mov 0,%o1
0166 .LL74:
0167     b .LL78
0168     mov 1,%o1
0169 .LL72:
0170     sll %i2,%o3,%o2
0171     srl %o4,%o1,%o0
0172     or %o2,%o0,%i2
0173     sll %o4,%o3,%o4
0174     srl %i0,%o1,%o2
0175     sll %i0,%o3,%o0
0176     srl %i3,%o1,%o1
0177     or %o0,%o1,%i0
0178     sll %i3,%o3,%i3
0179     mov %i0,%o1
0180     mov 32,%g1
0181     subcc   %o2,%i2,%g0
0182 1:  bcs 5f
0183      addxcc %o1,%o1,%o1 ! shift n1n0 and a q-bit in lsb
0184     sub %o2,%i2,%o2 ! this kills msb of n
0185     addx    %o2,%o2,%o2 ! so this cannot give carry
0186     subcc   %g1,1,%g1
0187 2:  bne 1b
0188      subcc  %o2,%i2,%g0
0189     bcs 3f
0190      addxcc %o1,%o1,%o1 ! shift n1n0 and a q-bit in lsb
0191     b   3f
0192      sub    %o2,%i2,%o2 ! this kills msb of n
0193 4:  sub %o2,%i2,%o2
0194 5:  addxcc  %o2,%o2,%o2
0195     bcc 2b
0196      subcc  %g1,1,%g1
0197 ! Got carry from n.  Subtract next step to cancel this carry.
0198     bne 4b
0199      addcc  %o1,%o1,%o1 ! shift n1n0 and a 0-bit in lsb
0200     sub %o2,%i2,%o2
0201 3:  xnor    %o1,0,%o1
0202     mov %o2,%i0
0203     wr  %g0,%o1,%y  ! SPARC has 0-3 delay insn after a wr
0204     sra %o4,31,%g2  ! Do not move this insn
0205     and %o1,%g2,%g2 ! Do not move this insn
0206     andcc   %g0,0,%g1   ! Do not move this insn
0207     mulscc  %g1,%o4,%g1
0208     mulscc  %g1,%o4,%g1
0209     mulscc  %g1,%o4,%g1
0210     mulscc  %g1,%o4,%g1
0211     mulscc  %g1,%o4,%g1
0212     mulscc  %g1,%o4,%g1
0213     mulscc  %g1,%o4,%g1
0214     mulscc  %g1,%o4,%g1
0215     mulscc  %g1,%o4,%g1
0216     mulscc  %g1,%o4,%g1
0217     mulscc  %g1,%o4,%g1
0218     mulscc  %g1,%o4,%g1
0219     mulscc  %g1,%o4,%g1
0220     mulscc  %g1,%o4,%g1
0221     mulscc  %g1,%o4,%g1
0222     mulscc  %g1,%o4,%g1
0223     mulscc  %g1,%o4,%g1
0224     mulscc  %g1,%o4,%g1
0225     mulscc  %g1,%o4,%g1
0226     mulscc  %g1,%o4,%g1
0227     mulscc  %g1,%o4,%g1
0228     mulscc  %g1,%o4,%g1
0229     mulscc  %g1,%o4,%g1
0230     mulscc  %g1,%o4,%g1
0231     mulscc  %g1,%o4,%g1
0232     mulscc  %g1,%o4,%g1
0233     mulscc  %g1,%o4,%g1
0234     mulscc  %g1,%o4,%g1
0235     mulscc  %g1,%o4,%g1
0236     mulscc  %g1,%o4,%g1
0237     mulscc  %g1,%o4,%g1
0238     mulscc  %g1,%o4,%g1
0239     mulscc  %g1,0,%g1
0240     add %g1,%g2,%o0
0241     rd  %y,%o2
0242     cmp %o0,%i0
0243     bgu,a .LL78
0244     add %o1,-1,%o1
0245     bne,a .LL50
0246     mov 0,%o2
0247     cmp %o2,%i3
0248     bleu .LL50
0249     mov 0,%o2
0250     add %o1,-1,%o1
0251 .LL78:
0252     mov 0,%o2
0253 .LL50:
0254     mov %o1,%l1
0255 .LL86:
0256     mov %o2,%l0
0257     mov %l0,%i0
0258     mov %l1,%i1
0259     cmp %l4,0
0260     be .LL81
0261     sub %g0,%i1,%o0
0262     mov %o0,%l3
0263     subcc %g0,%o0,%g0
0264     sub %g0,%i0,%o0
0265     subx %o0,0,%l2
0266     mov %l2,%i0
0267     mov %l3,%i1
0268 .LL81:
0269     ret
0270     restore
0271 EXPORT_SYMBOL(__divdi3)