0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013
0014
0015
0016
0017
0018
0019
0020
0021
0022
0023
0024
0025
0026
0027
0028
0029
0030
0031
0032
0033
0034
0035
0036
0037
0038
0039
0040
0041
0042
0043
0044
0045
0046
0047
0048
0049
0050
0051
0052
0053
0054
0055
0056
0057
0058
0059 #include <asm/export.h>
0060 #define halt .long 0
0061
0062
0063
0064
0065 #define mask $0
0066 #define divisor $1
0067 #define compare $28
0068 #define tmp1 $3
0069 #define tmp2 $4
0070
0071 #ifdef DIV
0072 #define DIV_ONLY(x,y...) x,##y
0073 #define MOD_ONLY(x,y...)
0074 #define func(x) __div##x
0075 #define modulus $2
0076 #define quotient $27
0077 #define GETSIGN(x) xor $24,$25,x
0078 #define STACK 48
0079 #else
0080 #define DIV_ONLY(x,y...)
0081 #define MOD_ONLY(x,y...) x,##y
0082 #define func(x) __rem##x
0083 #define modulus $27
0084 #define quotient $2
0085 #define GETSIGN(x) bis $24,$24,x
0086 #define STACK 32
0087 #endif
0088
0089
0090
0091
0092 #ifdef INTSIZE
0093 #define ufunction func(lu)
0094 #define sfunction func(l)
0095 #define LONGIFY(x) zapnot x,15,x
0096 #define SLONGIFY(x) addl x,0,x
0097 #else
0098 #define ufunction func(qu)
0099 #define sfunction func(q)
0100 #define LONGIFY(x)
0101 #define SLONGIFY(x)
0102 #endif
0103
0104 .set noat
0105 .align 4
0106 .globl ufunction
0107 .ent ufunction
0108 ufunction:
0109 subq $30,STACK,$30 # E :
0110 .frame $30,STACK,$23
0111 .prologue 0
0112
0113 7: stq $1, 0($30) # L :
0114 bis $25,$25,divisor # E :
0115 stq $2, 8($30) # L : L U L U
0116
0117 bis $24,$24,modulus # E :
0118 stq $0,16($30) # L :
0119 bis $31,$31,quotient # E :
0120 LONGIFY(divisor) # E : U L L U
0121
0122 stq tmp1,24($30) # L :
0123 LONGIFY(modulus) # E :
0124 bis $31,1,mask # E :
0125 DIV_ONLY(stq tmp2,32($30)) # L : L U U L
0126
0127 beq divisor, 9f
0128
0129
0130
0131
0132
0133
0134 .align 4
0135 #ifdef INTSIZE
0136
0137
0138
0139
0140
0141
0142
0143
0144 1: cmpult divisor,modulus,compare # E :
0145 s8addq divisor,$31,divisor # E :
0146 s8addq mask,$31,mask # E :
0147 bne compare,1b # U : U L U L
0148 #else
0149 1: cmpult divisor,modulus,compare # E :
0150 nop # E :
0151 nop # E :
0152 blt divisor, 2f # U : U L U L
0153
0154 addq divisor,divisor,divisor # E :
0155 addq mask,mask,mask # E :
0156 unop # E :
0157 bne compare,1b # U : U L U L
0158 #endif
0159
0160
0161 2:
0162
0163
0164
0165
0166 #ifdef DIV
0167 DIV_ONLY(addq quotient,mask,tmp2) # E :
0168 #else
0169 nop # E :
0170 #endif
0171 srl mask,1,mask # U :
0172 cmpule divisor,modulus,compare # E :
0173 subq modulus,divisor,tmp1 # E :
0174
0175 #ifdef DIV
0176 DIV_ONLY(cmovne compare,tmp2,quotient) # E : Latency 2, extra map slot
0177 nop # E : as part of the cmovne
0178 srl divisor,1,divisor # U :
0179 nop # E : L U L U
0180
0181 nop # E :
0182 cmovne compare,tmp1,modulus # E : Latency 2, extra map slot
0183 nop # E : as part of the cmovne
0184 bne mask,2b # U : U L U L
0185 #else
0186 srl divisor,1,divisor # U :
0187 cmovne compare,tmp1,modulus # E : Latency 2, extra map slot
0188 nop # E : as part of the cmovne
0189 bne mask,2b # U : U L L U
0190 #endif
0191
0192 9: ldq $1, 0($30) # L :
0193 ldq $2, 8($30) # L :
0194 nop # E :
0195 nop # E : U U L L
0196
0197 ldq $0,16($30) # L :
0198 ldq tmp1,24($30) # L :
0199 nop # E :
0200 nop # E :
0201
0202 #ifdef DIV
0203 DIV_ONLY(ldq tmp2,32($30)) # L :
0204 #else
0205 nop # E :
0206 #endif
0207 addq $30,STACK,$30 # E :
0208 ret $31,($23),1 # L0 : L U U L
0209 .end ufunction
0210 EXPORT_SYMBOL(ufunction)
0211
0212
0213
0214
0215
0216
0217
0218
0219
0220
0221
0222 .align 4
0223 .globl sfunction
0224 .ent sfunction
0225 sfunction:
0226 subq $30,STACK,$30 # E :
0227 .frame $30,STACK,$23
0228 .prologue 0
0229 bis $24,$25,$28 # E :
0230 SLONGIFY($28) # E :
0231 bge $28,7b # U :
0232
0233 stq $24,0($30) # L :
0234 subq $31,$24,$28 # E :
0235 stq $25,8($30) # L :
0236 nop # E : U L U L
0237
0238 cmovlt $24,$28,$24 # E : Latency 2, extra map slot
0239 nop # E : as part of the cmov
0240 stq $23,16($30) # L :
0241 subq $31,$25,$28 # E : U L U L
0242
0243 stq tmp1,24($30) # L :
0244 cmovlt $25,$28,$25 # E : Latency 2, extra map slot
0245 nop # E :
0246 bsr $23,ufunction # L0: L U L U
0247
0248 ldq $24,0($30) # L :
0249 ldq $25,8($30) # L :
0250 GETSIGN($28) # E :
0251 subq $31,$27,tmp1 # E : U U L L
0252
0253 SLONGIFY($28) # E :
0254 ldq $23,16($30) # L :
0255 cmovlt $28,tmp1,$27 # E : Latency 2, extra map slot
0256 nop # E : U L L U : as part of the cmov
0257
0258 ldq tmp1,24($30) # L :
0259 nop # E : as part of the cmov
0260 addq $30,STACK,$30 # E :
0261 ret $31,($23),1 # L0 : L U U L
0262 .end sfunction
0263 EXPORT_SYMBOL(sfunction)