1 /* SPDX-License-Identifier: GPL-2.0-or-later * << 2 /* Copyright (C) 1989, 1992, 1993, 1994, 1995 1 /* Copyright (C) 1989, 1992, 1993, 1994, 1995 Free Software Foundation, Inc. 3 2 4 This file is part of GNU CC. 3 This file is part of GNU CC. 5 4 6 */ !! 5 GNU CC is free software; you can redistribute it and/or modify >> 6 it under the terms of the GNU General Public License as published by >> 7 the Free Software Foundation; either version 2, or (at your option) >> 8 any later version. >> 9 >> 10 GNU CC is distributed in the hope that it will be useful, >> 11 but WITHOUT ANY WARRANTY; without even the implied warranty of >> 12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the >> 13 GNU General Public License for more details. >> 14 >> 15 You should have received a copy of the GNU General Public License >> 16 along with GNU CC; see the file COPYING. If not, write to >> 17 the Free Software Foundation, 59 Temple Place - Suite 330, >> 18 Boston, MA 02111-1307, USA. */ >> 19 >> 20 .data >> 21 .align 8 >> 22 .globl __clz_tab >> 23 __clz_tab: >> 24 .byte 0,1,2,2,3,3,3,3,4,4,4,4,4,4,4,4,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5 >> 25 .byte 6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6 >> 26 .byte 7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7 >> 27 .byte 7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7 >> 28 .byte 8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8 >> 29 .byte 8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8 >> 30 .byte 8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8 >> 31 .byte 8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8 >> 32 .size __clz_tab,256 >> 33 .global .udiv 7 34 8 #include <linux/export.h> << 9 .text 35 .text 10 .align 4 36 .align 4 11 .globl __divdi3 37 .globl __divdi3 12 __divdi3: 38 __divdi3: 13 save %sp,-104,%sp 39 save %sp,-104,%sp 14 cmp %i0,0 40 cmp %i0,0 15 bge .LL40 41 bge .LL40 16 mov 0,%l4 42 mov 0,%l4 17 mov -1,%l4 43 mov -1,%l4 18 sub %g0,%i1,%o0 44 sub %g0,%i1,%o0 19 mov %o0,%o5 45 mov %o0,%o5 20 subcc %g0,%o0,%g0 46 subcc %g0,%o0,%g0 21 sub %g0,%i0,%o0 47 sub %g0,%i0,%o0 22 subx %o0,0,%o4 48 subx %o0,0,%o4 23 mov %o4,%i0 49 mov %o4,%i0 24 mov %o5,%i1 50 mov %o5,%i1 25 .LL40: 51 .LL40: 26 cmp %i2,0 52 cmp %i2,0 27 bge .LL84 53 bge .LL84 28 mov %i3,%o4 54 mov %i3,%o4 29 xnor %g0,%l4,%l4 55 xnor %g0,%l4,%l4 30 sub %g0,%i3,%o0 56 sub %g0,%i3,%o0 31 mov %o0,%o3 57 mov %o0,%o3 32 subcc %g0,%o0,%g0 58 subcc %g0,%o0,%g0 33 sub %g0,%i2,%o0 59 sub %g0,%i2,%o0 34 subx %o0,0,%o2 60 subx %o0,0,%o2 35 mov %o2,%i2 61 mov %o2,%i2 36 mov %o3,%i3 62 mov %o3,%i3 37 mov %i3,%o4 63 mov %i3,%o4 38 .LL84: 64 .LL84: 39 cmp %i2,0 65 cmp %i2,0 40 bne .LL45 66 bne .LL45 41 mov %i1,%i3 67 mov %i1,%i3 42 cmp %o4,%i0 68 cmp %o4,%i0 43 bleu .LL46 69 bleu .LL46 44 mov %i3,%o1 70 mov %i3,%o1 45 mov 32,%g1 71 mov 32,%g1 46 subcc %i0,%o4,%g0 72 subcc %i0,%o4,%g0 47 1: bcs 5f 73 1: bcs 5f 48 addxcc %o1,%o1,%o1 ! shift n1n0 a 74 addxcc %o1,%o1,%o1 ! shift n1n0 and a q-bit in lsb 49 sub %i0,%o4,%i0 ! this kills m 75 sub %i0,%o4,%i0 ! this kills msb of n 50 addx %i0,%i0,%i0 ! so this cann 76 addx %i0,%i0,%i0 ! so this cannot give carry 51 subcc %g1,1,%g1 77 subcc %g1,1,%g1 52 2: bne 1b 78 2: bne 1b 53 subcc %i0,%o4,%g0 79 subcc %i0,%o4,%g0 54 bcs 3f 80 bcs 3f 55 addxcc %o1,%o1,%o1 ! shift n1n0 a 81 addxcc %o1,%o1,%o1 ! shift n1n0 and a q-bit in lsb 56 b 3f 82 b 3f 57 sub %i0,%o4,%i0 ! this kills m 83 sub %i0,%o4,%i0 ! this kills msb of n 58 4: sub %i0,%o4,%i0 84 4: sub %i0,%o4,%i0 59 5: addxcc %i0,%i0,%i0 85 5: addxcc %i0,%i0,%i0 60 bcc 2b 86 bcc 2b 61 subcc %g1,1,%g1 87 subcc %g1,1,%g1 62 ! Got carry from n. Subtract next step to can 88 ! Got carry from n. Subtract next step to cancel this carry. 63 bne 4b 89 bne 4b 64 addcc %o1,%o1,%o1 ! shift n1n0 a 90 addcc %o1,%o1,%o1 ! shift n1n0 and a 0-bit in lsb 65 sub %i0,%o4,%i0 91 sub %i0,%o4,%i0 66 3: xnor %o1,0,%o1 92 3: xnor %o1,0,%o1 67 b .LL50 93 b .LL50 68 mov 0,%o2 94 mov 0,%o2 69 .LL46: 95 .LL46: 70 cmp %o4,0 96 cmp %o4,0 71 bne .LL85 97 bne .LL85 72 mov %i0,%o2 98 mov %i0,%o2 73 mov 1,%o0 99 mov 1,%o0 >> 100 call .udiv,0 74 mov 0,%o1 101 mov 0,%o1 75 wr %g0, 0, %y << 76 udiv %o0, %o1, %o0 << 77 mov %o0,%o4 102 mov %o0,%o4 78 mov %i0,%o2 103 mov %i0,%o2 79 .LL85: 104 .LL85: 80 mov 0,%g3 105 mov 0,%g3 81 mov 32,%g1 106 mov 32,%g1 82 subcc %g3,%o4,%g0 107 subcc %g3,%o4,%g0 83 1: bcs 5f 108 1: bcs 5f 84 addxcc %o2,%o2,%o2 ! shift n1n0 a 109 addxcc %o2,%o2,%o2 ! shift n1n0 and a q-bit in lsb 85 sub %g3,%o4,%g3 ! this kills m 110 sub %g3,%o4,%g3 ! this kills msb of n 86 addx %g3,%g3,%g3 ! so this cann 111 addx %g3,%g3,%g3 ! so this cannot give carry 87 subcc %g1,1,%g1 112 subcc %g1,1,%g1 88 2: bne 1b 113 2: bne 1b 89 subcc %g3,%o4,%g0 114 subcc %g3,%o4,%g0 90 bcs 3f 115 bcs 3f 91 addxcc %o2,%o2,%o2 ! shift n1n0 a 116 addxcc %o2,%o2,%o2 ! shift n1n0 and a q-bit in lsb 92 b 3f 117 b 3f 93 sub %g3,%o4,%g3 ! this kills m 118 sub %g3,%o4,%g3 ! this kills msb of n 94 4: sub %g3,%o4,%g3 119 4: sub %g3,%o4,%g3 95 5: addxcc %g3,%g3,%g3 120 5: addxcc %g3,%g3,%g3 96 bcc 2b 121 bcc 2b 97 subcc %g1,1,%g1 122 subcc %g1,1,%g1 98 ! Got carry from n. Subtract next step to can 123 ! Got carry from n. Subtract next step to cancel this carry. 99 bne 4b 124 bne 4b 100 addcc %o2,%o2,%o2 ! shift n1n0 a 125 addcc %o2,%o2,%o2 ! shift n1n0 and a 0-bit in lsb 101 sub %g3,%o4,%g3 126 sub %g3,%o4,%g3 102 3: xnor %o2,0,%o2 127 3: xnor %o2,0,%o2 103 mov %g3,%i0 128 mov %g3,%i0 104 mov %i3,%o1 129 mov %i3,%o1 105 mov 32,%g1 130 mov 32,%g1 106 subcc %i0,%o4,%g0 131 subcc %i0,%o4,%g0 107 1: bcs 5f 132 1: bcs 5f 108 addxcc %o1,%o1,%o1 ! shift n1n0 a 133 addxcc %o1,%o1,%o1 ! shift n1n0 and a q-bit in lsb 109 sub %i0,%o4,%i0 ! this kills m 134 sub %i0,%o4,%i0 ! this kills msb of n 110 addx %i0,%i0,%i0 ! so this cann 135 addx %i0,%i0,%i0 ! so this cannot give carry 111 subcc %g1,1,%g1 136 subcc %g1,1,%g1 112 2: bne 1b 137 2: bne 1b 113 subcc %i0,%o4,%g0 138 subcc %i0,%o4,%g0 114 bcs 3f 139 bcs 3f 115 addxcc %o1,%o1,%o1 ! shift n1n0 a 140 addxcc %o1,%o1,%o1 ! shift n1n0 and a q-bit in lsb 116 b 3f 141 b 3f 117 sub %i0,%o4,%i0 ! this kills m 142 sub %i0,%o4,%i0 ! this kills msb of n 118 4: sub %i0,%o4,%i0 143 4: sub %i0,%o4,%i0 119 5: addxcc %i0,%i0,%i0 144 5: addxcc %i0,%i0,%i0 120 bcc 2b 145 bcc 2b 121 subcc %g1,1,%g1 146 subcc %g1,1,%g1 122 ! Got carry from n. Subtract next step to can 147 ! Got carry from n. Subtract next step to cancel this carry. 123 bne 4b 148 bne 4b 124 addcc %o1,%o1,%o1 ! shift n1n0 a 149 addcc %o1,%o1,%o1 ! shift n1n0 and a 0-bit in lsb 125 sub %i0,%o4,%i0 150 sub %i0,%o4,%i0 126 3: xnor %o1,0,%o1 151 3: xnor %o1,0,%o1 127 b .LL86 152 b .LL86 128 mov %o1,%l1 153 mov %o1,%l1 129 .LL45: 154 .LL45: 130 cmp %i2,%i0 155 cmp %i2,%i0 131 bleu .LL51 156 bleu .LL51 132 sethi %hi(65535),%o0 157 sethi %hi(65535),%o0 133 b .LL78 158 b .LL78 134 mov 0,%o1 159 mov 0,%o1 135 .LL51: 160 .LL51: 136 or %o0,%lo(65535),%o0 161 or %o0,%lo(65535),%o0 137 cmp %i2,%o0 162 cmp %i2,%o0 138 bgu .LL58 163 bgu .LL58 139 mov %i2,%o1 164 mov %i2,%o1 140 cmp %i2,256 165 cmp %i2,256 141 addx %g0,-1,%o0 166 addx %g0,-1,%o0 142 b .LL64 167 b .LL64 143 and %o0,8,%o2 168 and %o0,8,%o2 144 .LL58: 169 .LL58: 145 sethi %hi(16777215),%o0 170 sethi %hi(16777215),%o0 146 or %o0,%lo(16777215),%o0 171 or %o0,%lo(16777215),%o0 147 cmp %i2,%o0 172 cmp %i2,%o0 148 bgu .LL64 173 bgu .LL64 149 mov 24,%o2 174 mov 24,%o2 150 mov 16,%o2 175 mov 16,%o2 151 .LL64: 176 .LL64: 152 srl %o1,%o2,%o0 177 srl %o1,%o2,%o0 153 sethi %hi(__clz_tab),%o1 178 sethi %hi(__clz_tab),%o1 154 or %o1,%lo(__clz_tab),%o1 179 or %o1,%lo(__clz_tab),%o1 155 ldub [%o0+%o1],%o0 180 ldub [%o0+%o1],%o0 156 add %o0,%o2,%o0 181 add %o0,%o2,%o0 157 mov 32,%o1 182 mov 32,%o1 158 subcc %o1,%o0,%o3 183 subcc %o1,%o0,%o3 159 bne,a .LL72 184 bne,a .LL72 160 sub %o1,%o3,%o1 185 sub %o1,%o3,%o1 161 cmp %i0,%i2 186 cmp %i0,%i2 162 bgu .LL74 187 bgu .LL74 163 cmp %i3,%o4 188 cmp %i3,%o4 164 blu .LL78 189 blu .LL78 165 mov 0,%o1 190 mov 0,%o1 166 .LL74: 191 .LL74: 167 b .LL78 192 b .LL78 168 mov 1,%o1 193 mov 1,%o1 169 .LL72: 194 .LL72: 170 sll %i2,%o3,%o2 195 sll %i2,%o3,%o2 171 srl %o4,%o1,%o0 196 srl %o4,%o1,%o0 172 or %o2,%o0,%i2 197 or %o2,%o0,%i2 173 sll %o4,%o3,%o4 198 sll %o4,%o3,%o4 174 srl %i0,%o1,%o2 199 srl %i0,%o1,%o2 175 sll %i0,%o3,%o0 200 sll %i0,%o3,%o0 176 srl %i3,%o1,%o1 201 srl %i3,%o1,%o1 177 or %o0,%o1,%i0 202 or %o0,%o1,%i0 178 sll %i3,%o3,%i3 203 sll %i3,%o3,%i3 179 mov %i0,%o1 204 mov %i0,%o1 180 mov 32,%g1 205 mov 32,%g1 181 subcc %o2,%i2,%g0 206 subcc %o2,%i2,%g0 182 1: bcs 5f 207 1: bcs 5f 183 addxcc %o1,%o1,%o1 ! shift n1n0 a 208 addxcc %o1,%o1,%o1 ! shift n1n0 and a q-bit in lsb 184 sub %o2,%i2,%o2 ! this kills m 209 sub %o2,%i2,%o2 ! this kills msb of n 185 addx %o2,%o2,%o2 ! so this cann 210 addx %o2,%o2,%o2 ! so this cannot give carry 186 subcc %g1,1,%g1 211 subcc %g1,1,%g1 187 2: bne 1b 212 2: bne 1b 188 subcc %o2,%i2,%g0 213 subcc %o2,%i2,%g0 189 bcs 3f 214 bcs 3f 190 addxcc %o1,%o1,%o1 ! shift n1n0 a 215 addxcc %o1,%o1,%o1 ! shift n1n0 and a q-bit in lsb 191 b 3f 216 b 3f 192 sub %o2,%i2,%o2 ! this kills m 217 sub %o2,%i2,%o2 ! this kills msb of n 193 4: sub %o2,%i2,%o2 218 4: sub %o2,%i2,%o2 194 5: addxcc %o2,%o2,%o2 219 5: addxcc %o2,%o2,%o2 195 bcc 2b 220 bcc 2b 196 subcc %g1,1,%g1 221 subcc %g1,1,%g1 197 ! Got carry from n. Subtract next step to can 222 ! Got carry from n. Subtract next step to cancel this carry. 198 bne 4b 223 bne 4b 199 addcc %o1,%o1,%o1 ! shift n1n0 a 224 addcc %o1,%o1,%o1 ! shift n1n0 and a 0-bit in lsb 200 sub %o2,%i2,%o2 225 sub %o2,%i2,%o2 201 3: xnor %o1,0,%o1 226 3: xnor %o1,0,%o1 202 mov %o2,%i0 227 mov %o2,%i0 203 wr %g0,%o1,%y ! SPARC has 0- 228 wr %g0,%o1,%y ! SPARC has 0-3 delay insn after a wr 204 sra %o4,31,%g2 ! Do not move 229 sra %o4,31,%g2 ! Do not move this insn 205 and %o1,%g2,%g2 ! Do not move 230 and %o1,%g2,%g2 ! Do not move this insn 206 andcc %g0,0,%g1 ! Do not move 231 andcc %g0,0,%g1 ! Do not move this insn 207 mulscc %g1,%o4,%g1 232 mulscc %g1,%o4,%g1 208 mulscc %g1,%o4,%g1 233 mulscc %g1,%o4,%g1 209 mulscc %g1,%o4,%g1 234 mulscc %g1,%o4,%g1 210 mulscc %g1,%o4,%g1 235 mulscc %g1,%o4,%g1 211 mulscc %g1,%o4,%g1 236 mulscc %g1,%o4,%g1 212 mulscc %g1,%o4,%g1 237 mulscc %g1,%o4,%g1 213 mulscc %g1,%o4,%g1 238 mulscc %g1,%o4,%g1 214 mulscc %g1,%o4,%g1 239 mulscc %g1,%o4,%g1 215 mulscc %g1,%o4,%g1 240 mulscc %g1,%o4,%g1 216 mulscc %g1,%o4,%g1 241 mulscc %g1,%o4,%g1 217 mulscc %g1,%o4,%g1 242 mulscc %g1,%o4,%g1 218 mulscc %g1,%o4,%g1 243 mulscc %g1,%o4,%g1 219 mulscc %g1,%o4,%g1 244 mulscc %g1,%o4,%g1 220 mulscc %g1,%o4,%g1 245 mulscc %g1,%o4,%g1 221 mulscc %g1,%o4,%g1 246 mulscc %g1,%o4,%g1 222 mulscc %g1,%o4,%g1 247 mulscc %g1,%o4,%g1 223 mulscc %g1,%o4,%g1 248 mulscc %g1,%o4,%g1 224 mulscc %g1,%o4,%g1 249 mulscc %g1,%o4,%g1 225 mulscc %g1,%o4,%g1 250 mulscc %g1,%o4,%g1 226 mulscc %g1,%o4,%g1 251 mulscc %g1,%o4,%g1 227 mulscc %g1,%o4,%g1 252 mulscc %g1,%o4,%g1 228 mulscc %g1,%o4,%g1 253 mulscc %g1,%o4,%g1 229 mulscc %g1,%o4,%g1 254 mulscc %g1,%o4,%g1 230 mulscc %g1,%o4,%g1 255 mulscc %g1,%o4,%g1 231 mulscc %g1,%o4,%g1 256 mulscc %g1,%o4,%g1 232 mulscc %g1,%o4,%g1 257 mulscc %g1,%o4,%g1 233 mulscc %g1,%o4,%g1 258 mulscc %g1,%o4,%g1 234 mulscc %g1,%o4,%g1 259 mulscc %g1,%o4,%g1 235 mulscc %g1,%o4,%g1 260 mulscc %g1,%o4,%g1 236 mulscc %g1,%o4,%g1 261 mulscc %g1,%o4,%g1 237 mulscc %g1,%o4,%g1 262 mulscc %g1,%o4,%g1 238 mulscc %g1,%o4,%g1 263 mulscc %g1,%o4,%g1 239 mulscc %g1,0,%g1 264 mulscc %g1,0,%g1 240 add %g1,%g2,%o0 265 add %g1,%g2,%o0 241 rd %y,%o2 266 rd %y,%o2 242 cmp %o0,%i0 267 cmp %o0,%i0 243 bgu,a .LL78 268 bgu,a .LL78 244 add %o1,-1,%o1 269 add %o1,-1,%o1 245 bne,a .LL50 270 bne,a .LL50 246 mov 0,%o2 271 mov 0,%o2 247 cmp %o2,%i3 272 cmp %o2,%i3 248 bleu .LL50 273 bleu .LL50 249 mov 0,%o2 274 mov 0,%o2 250 add %o1,-1,%o1 275 add %o1,-1,%o1 251 .LL78: 276 .LL78: 252 mov 0,%o2 277 mov 0,%o2 253 .LL50: 278 .LL50: 254 mov %o1,%l1 279 mov %o1,%l1 255 .LL86: 280 .LL86: 256 mov %o2,%l0 281 mov %o2,%l0 257 mov %l0,%i0 282 mov %l0,%i0 258 mov %l1,%i1 283 mov %l1,%i1 259 cmp %l4,0 284 cmp %l4,0 260 be .LL81 285 be .LL81 261 sub %g0,%i1,%o0 286 sub %g0,%i1,%o0 262 mov %o0,%l3 287 mov %o0,%l3 263 subcc %g0,%o0,%g0 288 subcc %g0,%o0,%g0 264 sub %g0,%i0,%o0 289 sub %g0,%i0,%o0 265 subx %o0,0,%l2 290 subx %o0,0,%l2 266 mov %l2,%i0 291 mov %l2,%i0 267 mov %l3,%i1 292 mov %l3,%i1 268 .LL81: 293 .LL81: 269 ret 294 ret 270 restore 295 restore 271 EXPORT_SYMBOL(__divdi3) <<
Linux® is a registered trademark of Linus Torvalds in the United States and other countries.
TOMOYO® is a registered trademark of NTT DATA CORPORATION.