1 Star 1 Fork 1

life/RISC-V-math-library

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
克隆/下载
fmod.S 11.50 KB
一键复制 编辑 原始数据 按行查看 历史
life 提交于 2022-07-06 09:25 . function
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736
.section .text, "ax", "progbits"
.align 4
.section .text
.align 4
.globl _rv_fmod
_rv_fmod:
fmv.x.d a0,fa0
fmv.x.d t1,fa1
addi t0,zero,2047
li t2,0x1
addi t4,zero,1023
fabs.d ft0,fa0
slli t0,t0,0x34
slli t2,t2,0x34
fmv.x.d a7,fa0
addi a3,zero,1023
and a0,a0,t0
slli a3,a3,52
and t1,t1,t0
fmv.d.x fa7,a3
slli t4,t4,0x35
sub t3,a0,t2
sub t2,t1,t2
addi sp,sp,-224
fabs.d fs1,fa1
bgtu t4,t3,TYPH_1
li t3,0x1
j TYPH_2
TYPH_1: li t3,0x0
TYPH_2:
bgtu t4,t2,TYPH_3
li t2,0x1
j TYPH_4
TYPH_3: li t2,0x0
TYPH_4:
sd ra,0(sp)
fsd ft5,48(sp)
fsd ft4,64(sp)
li t5,0x0
or t2,t3,t2
li t6,0x0
and a2,a7,t0
srli a1,a7,0x3f
fsgnj.d fs2,fa7,fa0
beqz t2,L$284
addi a4,zero,-1
addi a3,a1,4
beqz a2,L$b0
srli a4,a4,0xc
sltu a2,a2,t0
addi a1,a1,2
and a7,a7,a4
bnez a2,L$c8
srli a5,a7,0x33
beqz a7,TYPH_5
mv a5,a5
j TYPH_6
TYPH_5: mv a5,a1
TYPH_6:
mv a3,a5
j L$c8
L$b0:
addi a6,zero,-1
li s7,0x6
srli a6,a6,0xc
and a7,a7,a6
beqz a7,TYPH_7
mv s7,s7
j TYPH_8
TYPH_7: li s7,0x8
TYPH_8:
add a3,a1,s7
L$c8:
fmv.x.d s8,fa1
and s10,s8,t0
srli s9,s8,0x3f
addi s11,zero,-1
srli s11,s11,0xc
beqz s10,L$110
and s8,s8,s11
srli t4,s8,0x33
sltu s10,s10,t0
addi s9,s9,2
addi a2,s9,2
beqz s8,TYPH_9
mv t4,t4
j TYPH_10
TYPH_9: mv t4,s9
TYPH_10:
bnez s10,L$128
mv a2,t4
j L$128
L$110:
addi t3,zero,-1
li t1,0x6
srli t3,t3,0xc
and s8,s8,t3
beqz s8,TYPH_11
mv t1,t1
j TYPH_12
TYPH_11: li t1,0x8
TYPH_12:
add a2,s9,t1
L$128:
srli a3,a3,0x1
slli a3,a3,0x2
add a3,a3,a3
srli a2,a2,0x1
add a3,a3,a2
li a5,0x18
bgtu a3,a5,TYPH_13
li t2,0x1
j TYPH_14
TYPH_13:li t2,0x0
TYPH_14:
beqz t2,L$720
li a5,18
sub s9,a3,a5
seqz s9,s9
bnez s9,L$806
li a5,13
sub s9,a3,a5
seqz s9,s9
.align 4
bnez s9,L$807
addi s9,a3,-6
li a5,2
bgtu s9,a5,TYPH_15
li s9,0x1
j TYPH_16
TYPH_15:li s9,0x0
TYPH_16:
bnez s9,L$801
li a5,9
sub t0,a3,a5
seqz t0,t0
li a5,14
sub t1,a3,a5
seqz t1,t1
or s9,t0,t1
bnez s9,L$803
li a5,19
sub t0,a3,a5
seqz t0,t0
li a5,24
sub t1,a3,a5
seqz t1,t1
or s9,t0,t1
bnez s9,L$803
li a5,5
sub t0,a3,a5
seqz t0,t0
li a5,10
sub t1,a3,a5
seqz t1,t1
or s9,t0,t1
bnez s9,L$800
li a5,15
sub t0,a3,a5
seqz t0,t0
li a5,20
sub t1,a3,a5
seqz t1,t1
or s9,t0,t1
bnez s9,L$800
addi sp,sp,224
ret
L$800:
fmv.d fa0,fa1
addi sp,sp,224
ret
L$801:
addi s9,zero,1
sd ra,0(sp)
slli s9,s9,63
li a5,17666
add s10,zero,a5
or s9,s10,s9
addi a1,sp,8
sd s9,8(sp)
L$1d0:
ld ra,0(sp)
fld fa0,40(sp)
addi sp,sp,224
ret
L$803:
addi s9,zero,1
addi s10,zero,1282
slli s9,s9,63
or s9,s10,s9
sd ra,0(sp)
sd s9,8(sp)
addi a1,sp,8
L$220:
ld ra,0(sp)
fld fa0,40(sp)
addi sp,sp,224
ret
L$806:
addi a3,zero,1075
slli a3,a3,52
li t5,0x1
fmv.d.x fs3,a3
fmv.d fa7,fa0
fmv.x.d a4,fs3
li a5,0xFFF0000000000000
and a4,a4,a5
li t1,0x000FFFFFFFFFFFFF
fmv.x.d t2,ft0
and a5,t2,t1
or a4,a4,a5
fmv.d.x fs4,a4
fmv.x.d a4,fs3
li a5,0xFFF0000000000000
and a4,a4,a5
li t1,0x000FFFFFFFFFFFFF
fmv.x.d t2,fs1
and a5,t2,t1
or a4,a4,a5
fmv.d.x fs5,a4
fsub.d ft0,fs4,fs3
fsub.d fs1,fs5,fs3
fmv.x.d t1,ft0
fmv.x.d t2,fs1
and a0,t1,t0
and t1,t2,t0
sub t3,t1,a0
sltz t3,t3
bnez t3,L$280
fmv.d fa0,fa7
addi sp,sp,224
ret
L$280:
addi t6,zero,1074
L$284:
li t4,0x1b
sub a0,a0,t1
slli t4,t4,0x35
srai a7,a0,0x34
fmv.d fa7,fa0
sltu t4,t4,t1
bgtz a7,L$330
beqz a7,L$2d0
fmv.d fa0,fa7
addi sp,sp,224
ret
L$2d0:
addi a3,zero,1036
bnez t4,L$300
slli a3,a3,52
fmv.d.x fs6,a3
addi t6,t6,52
fmul.d ft0,ft0,fs6
fmul.d fs1,fs1,fs6
fmul.d ft0,ft0,fs6
fmul.d fs1,fs1,fs6
fmul.d ft0,ft0,fs6
fmul.d fs1,fs1,fs6
fmul.d ft0,ft0,fs6
fmul.d fs1,fs1,fs6
L$300:
fmv.d fa2,ft0
flt.d a5,ft0,fs1
beqz a5,TYPH_17
li a5,0x4000000000000000
fmv.d.x fa1,a5
j TYPH_18
TYPH_17:fmv.d.x fa1,a5
TYPH_18:
li a5,0x0
fmv.d.x ft3,a5
feq.d a5,fa1,ft3
beqz a5,L$5dc
fsub.d fa2,ft0,fs1
bnez t6,L$600
fmul.d fa0,fa2,fs2
addi sp,sp,224
ret
L$330:
slti a1,a7,0x34
sltu t4,zero,t4
fmv.x.d a3,fs1
li a5,-1024
slli a5,a5,16
add a2,a5,zero
and t4,a1,t4
beqz t4,L$41c
csrrs a5,fcsr,x0
fmv.d.x ft11,a5
csrrs a5,fcsr,x0
fmv.d.x ft10,a5
fmv.x.d t3,ft10
addi s8,zero,3
slli s8,s8,58
not s8,s8
and t3,t3,s8
fmv.d.x ft10,t3
fmv.x.d a5,ft10
csrrw x0,fcsr,a5
fdiv.d fa3,ft0,fs1,rtz
fmv.x.d a5,ft11
csrrw x0,fcsr,a5
fsd fs1,8(sp)
slti a7,a7,0x1a
and a2,a3,a2
fmv.d.x fa4,a2
sd a2,8(sp)
addi a3,zero,1101
fsub.d fs1,fs1,fa4
slli a3,a3,52
csrrs a5,fcsr,x0
fmv.d.x ft11,a5
csrrs a5,fcsr,x0
fmv.d.x ft10,a5
fmv.x.d t3,ft10
addi s8,zero,3
slli s8,s8,58
not s8,s8
and t3,t3,s8
fmv.d.x ft10,t3
fmv.x.d a5,ft10
csrrw x0,fcsr,a5
fcvt.l.d a5,fa3,rtz
fmv.d.x fa3,a5
fmv.x.d a5,ft11
csrrw x0,fcsr,a5
fmv.x.d a5,fa3
fcvt.d.l fa3,a5
beqz a7,L$3a0
fneg.d ft3,fa3
fmadd.d fa5,ft3,fa4,ft0
fmul.d fs1,fa3,fs1
fsub.d fa2,fa5,fs1
bnez t6,L$600
fmul.d fa0,fa2,fs2
addi sp,sp,224
ret
L$3a0:
fmv.d.x ft8,a3
csrrs a5,fcsr,x0
fmv.d.x ft11,a5
csrrs a5,fcsr,x0
fmv.d.x ft10,a5
fmv.x.d t3,ft10
addi s8,zero,3
slli s8,s8,58
not s8,s8
and t3,t3,s8
fmv.d.x ft10,t3
fmv.x.d a5,ft10
csrrw x0,fcsr,a5
fadd.d ft9,fa3,ft8
fmv.x.d a5,ft11
csrrw x0,fcsr,a5
fsub.d ft8,ft9,ft8
fneg.d ft3,ft8
fmadd.d ft0,ft3,fa4,ft0
fsub.d fa3,fa3,ft8
fmadd.d ft0,ft3,fs1,ft0
fneg.d ft3,fa3
fmadd.d ft0,ft3,fa4,ft0
fmadd.d fa2,ft3,fs1,ft0
bnez t6,L$600
fmul.d fa0,fa2,fs2
addi sp,sp,224
ret
L$807:
addi a3,zero,1075
slli a3,a3,52
li t5,0x1
fmv.d.x ft11,a3
addi t6,zero,1074
fmv.x.d a4,ft11
li a5,0xFFF0000000000000
and a4,a4,a5
li t1,0x000FFFFFFFFFFFFF
fmv.x.d a7,fs1
and a5,a7,t1
or a4,a4,a5
fmv.d.x fa6,a4
fsub.d fs1,fa6,ft11
fmv.x.d a5,fs1
and t1,a5,t0
sub a0,a0,t1
srai a0,a0,0x34
addi a7,a0,1074
L$41c:
addi a3,zero,1075
slli a3,a3,52
fmv.d.x fs7,a3
fmv.x.d a4,fs7
li a5,0xFFF0000000000000
and a4,a4,a5
li t4,0x000FFFFFFFFFFFFF
fmv.x.d s2,ft0
and a5,s2,t4
or a4,a4,a5
fmv.d.x fa2,a4
fmv.x.d a4,fs7
li a5,0xFFF0000000000000
and a4,a4,a5
li t4,0x000FFFFFFFFFFFFF
fmv.x.d s2,fs1
and a5,s2,t4
or a4,a4,a5
fmv.d.x fs8,a4
flt.d a5,fa2,fs8
beqz a5,TYPH_19
li a5,0x4000000000000000
fmv.d.x fs9,a5
j TYPH_20
TYPH_19:fmv.d.x fs9,a5
TYPH_20:
li a5,0x0
fmv.d.x ft3,a5
feq.d a5,fs9,ft3
beqz a5,L$444
fsub.d fa2,fa2,fs8
li a5,0x0
fmv.d.x ft3,a5
feq.d a5,fa2,ft3
bnez a5,L$5dc
L$444:
fmv.x.d s7,fs8
addi a3,zero,1101
li a5,-1024
slli a5,a5,16
add a6,a5,zero
slli a3,a3,52
and a6,s7,a6
fmv.d.x fs10,a6
fmv.d.x fs3,a3
fsd fs8,24(sp)
sd a6,24(sp)
fsub.d fs4,fs8,fs10
L$470:
addi a7,a7,-52
blt a7,zero,L$540
fmul.d fa2,fa2,fs7
addi a7,a7,-52
csrrs a5,fcsr,x0
fmv.d.x ft4,a5
csrrs a5,fcsr,x0
fmv.d.x ft5,a5
fmv.x.d t3,ft5
addi s8,zero,3
slli s8,s8,58
not s8,s8
and t3,t3,s8
fmv.d.x ft5,t3
fmv.x.d a5,ft5
csrrw x0,fcsr,a5
fdiv.d fs5,fa2,fs8,rtz
fmv.x.d a5,ft4
csrrw x0,fcsr,a5
csrrs a5,fcsr,x0
fmv.d.x ft4,a5
csrrs a5,fcsr,x0
fmv.d.x ft5,a5
fmv.x.d t3,ft5
addi s8,zero,3
slli s8,s8,58
not s8,s8
and t3,t3,s8
fmv.d.x ft5,t3
fmv.x.d a5,ft5
csrrw x0,fcsr,a5
fcvt.l.d a5,fs5,rtz
fmv.d.x fs5,a5
fmv.x.d a5,ft4
csrrw x0,fcsr,a5
fmv.x.d a5,fs5
fcvt.d.l fs5,a5
csrrs a5,fcsr,x0
fmv.d.x ft4,a5
csrrs a5,fcsr,x0
fmv.d.x ft5,a5
fmv.x.d t3,ft5
addi s8,zero,3
slli s8,s8,58
not s8,s8
and t3,t3,s8
fmv.d.x ft5,t3
fmv.x.d a5,ft5
csrrw x0,fcsr,a5
fadd.d fa0,fs5,fs3
fmv.x.d a5,ft4
csrrw x0,fcsr,a5
fsub.d fa0,fa0,fs3
fsub.d fs5,fs5,fa0
fneg.d ft3,fs10
fmadd.d fa7,ft3,fa0,fa2
fmadd.d fa7,ft3,fs5,fa7
fneg.d ft3,fs4
fmadd.d fa7,ft3,fa0,fa7
fmadd.d fa2,ft3,fs5,fa7
li a5,0x0
fmv.d.x ft3,a5
feq.d a5,fa2,ft3
bnez a5,L$5dc
blt a7,zero,L$540
fmul.d fa2,fa2,fs7
csrrs a5,fcsr,x0
fmv.d.x ft4,a5
csrrs a5,fcsr,x0
fmv.d.x ft5,a5
fmv.x.d t3,ft5
addi s8,zero,3
slli s8,s8,58
not s8,s8
and t3,t3,s8
fmv.d.x ft5,t3
fmv.x.d a5,ft5
csrrw x0,fcsr,a5
fdiv.d fa1,fa2,fs8,rtz
fmv.x.d a5,ft4
csrrw x0,fcsr,a5
csrrs a5,fcsr,x0
fmv.d.x ft4,a5
csrrs a5,fcsr,x0
fmv.d.x ft5,a5
fmv.x.d t3,ft5
addi s8,zero,3
slli s8,s8,58
not s8,s8
and t3,t3,s8
fmv.d.x ft5,t3
fmv.x.d a5,ft5
csrrw x0,fcsr,a5
fcvt.l.d a5,fa1,rtz
fmv.d.x fa1,a5
fmv.x.d a5,ft4
csrrw x0,fcsr,a5
fmv.x.d a5,fa1
fcvt.d.l fa1,a5
csrrs a5,fcsr,x0
fmv.d.x ft4,a5
csrrs a5,fcsr,x0
fmv.d.x ft5,a5
fmv.x.d t3,ft5
addi s8,zero,3
slli s8,s8,58
not s8,s8
and t3,t3,s8
fmv.d.x ft5,t3
fmv.x.d a5,ft5
csrrw x0,fcsr,a5
fadd.d fa5,fa1,fs3
fmv.x.d a5,ft4
csrrw x0,fcsr,a5
fsub.d fa5,fa5,fs3
fsub.d fa1,fa1,fa5
fneg.d ft3,fs10
fmadd.d fa2,ft3,fa5,fa2
fmadd.d fa2,ft3,fa1,fa2
fneg.d ft3,fs4
fmadd.d fa2,ft3,fa5,fa2
fmadd.d fa2,ft3,fa1,fa2
li a5,0x0
fmv.d.x ft3,a5
feq.d a5,fa2,ft3
beqz a5,L$470
bnez t6,L$600
fmul.d fa0,fa2,fs2
addi sp,sp,224
ret
L$540:
fmv.x.d s10,fa2
addi a7,a7,52
beqz a7,L$59c
slli a7,a7,0x34
fsd fa2,16(sp)
add a7,s10,a7
fmv.d.x ft8,a7
sd a7,16(sp)
csrrs a5,fcsr,x0
fmv.d.x ft4,a5
csrrs a5,fcsr,x0
fmv.d.x ft5,a5
fmv.x.d t3,ft5
addi s8,zero,3
slli s8,s8,58
not s8,s8
and t3,t3,s8
fmv.d.x ft5,t3
fmv.x.d a5,ft5
csrrw x0,fcsr,a5
fdiv.d fa3,ft8,fs8,rtz
fmv.x.d a5,ft4
csrrw x0,fcsr,a5
csrrs a5,fcsr,x0
fmv.d.x ft4,a5
csrrs a5,fcsr,x0
fmv.d.x ft5,a5
fmv.x.d t3,ft5
addi s8,zero,3
slli s8,s8,58
not s8,s8
and t3,t3,s8
fmv.d.x ft5,t3
fmv.x.d a5,ft5
csrrw x0,fcsr,a5
fcvt.l.d a5,fa3,rtz
fmv.d.x fa3,a5
fmv.x.d a5,ft4
csrrw x0,fcsr,a5
fmv.x.d a5,fa3
fcvt.d.l fa3,a5
csrrs a5,fcsr,x0
fmv.d.x ft4,a5
csrrs a5,fcsr,x0
fmv.d.x ft5,a5
fmv.x.d t3,ft5
addi s8,zero,3
slli s8,s8,58
not s8,s8
and t3,t3,s8
fmv.d.x ft5,t3
fmv.x.d a5,ft5
csrrw x0,fcsr,a5
fadd.d fa4,fa3,fs3
fmv.x.d a5,ft4
csrrw x0,fcsr,a5
fsub.d fs3,fa4,fs3
fsub.d fa3,fa3,fs3
fneg.d ft3,fs10
fmadd.d ft8,ft3,fs3,ft8
fmadd.d ft8,ft3,fa3,ft8
fneg.d ft3,fs4
fmadd.d fs3,ft3,fs3,ft8
fmadd.d fa2,ft3,fa3,fs3
li a5,0x0
fmv.d.x ft3,a5
feq.d a5,fa2,ft3
bnez a5,L$5dc
L$59c:
fmv.x.d s11,fa2
and s11,s11,t0
add t1,s11,t1
srli t1,t1,0x34
addi t1,t1,-1075
li a5,0x36
sub t2,t1,a5
sltz t2,t2
beqz t2,L$5c0
addi t1,t1,52
addi t6,t6,52
L$5c0:
addi a2,zero,1
addi a3,zero,-1
slli a2,a2,63
srl a3,a3,12
or a1,a2,a3
fmv.x.d t3,fa2
slli t1,t1,0x34
and t3,t3,a1
or t3,t3,t1
fmv.d.x fa2,t3
L$5dc:
bnez t6,L$600
fmul.d fa0,fa2,fs2
addi sp,sp,224
ret
L$600:
fmul.d fa7,fa2,fs2
slli t4,t6,0x34
fmv.x.d a2,fa7
fsd fa7,32(sp)
and t0,a2,t0
bgtu t0,t4,TYPH_21
li a4,0x1
j TYPH_22
TYPH_21:li a4,0x0
TYPH_22:nop
sub t4,a2,t4
bnez a4,L$640
sd t4,32(sp)
fmv.d.x fa0,t4
addi sp,sp,224
ret
L$640:
srli t0,t0,0x34
li a5,0x0
fmv.d.x ft8,a5
feq.d a5,fa7,ft3
bnez a5,L$720
fmv.x.d a6,fa7
li s9,0x1
sub t0,t0,t6
slli s9,s9,0x3f
li s10,0x1b
addi t2,zero,-1
slli s10,s10,0x35
addi t0,t0,53
addi a2,zero,1
addi a3,zero,-1
slli a2,a2,63
srl a3,a3,12
blez t0,L$6f0
or s7,a2,a3
slli t0,t0,0x34
and a6,a6,s7
add t0,a6,t0
fmv.d.x fa6,t0
and t0,t0,s9
add t0,t0,s10
fmv.d.x ft0,t0
fadd.d ft0,ft0,fa6
fmv.x.d s11,ft0
and s7,s11,s7
sd s7,32(sp)
bnez t5,L$6e0
sd t2,8(sp)
addi a1,sp,8
sd ra,0(sp)
ld ra,0(sp)
li a0,0x0
bnez a0,L$6f0
L$6e0:
fld fa0,32(sp)
addi sp,sp,224
ret
L$6f0:
addi s9,zero,1
slli s9,s9,63
addi s10,zero,1297
or s9,s9,s10
sd s9,8(sp)
addi a1,sp,8
sd ra,0(sp)
ld ra,0(sp)
fld fa0,40(sp)
L$720:
addi sp,sp,224
ret
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
Assembly
1
https://gitee.com/li-fei-abc/risc-v-math-library.git
git@gitee.com:li-fei-abc/risc-v-math-library.git
li-fei-abc
risc-v-math-library
RISC-V-math-library
master

搜索帮助

0d507c66 1850385 C8b1a773 1850385