mirror of
https://github.com/LuaJIT/LuaJIT.git
synced 2025-02-08 15:34:09 +00:00
Implement more math functions.
Everything apart from min/max should now be working.
This commit is contained in:
parent
8e747c5406
commit
65af21e2ed
@ -22,6 +22,8 @@
|
|||||||
|// clfi (compare logical immediate) [requires z9-109]
|
|// clfi (compare logical immediate) [requires z9-109]
|
||||||
|// ldgr (load FPR from GPR) [requires z9-109 GA3]
|
|// ldgr (load FPR from GPR) [requires z9-109 GA3]
|
||||||
|// lgdr (load GPR from FPR) [requires z9-109 GA3]
|
|// lgdr (load GPR from FPR) [requires z9-109 GA3]
|
||||||
|
|// ldy (load (long bfp)) [requires z900 GA2]
|
||||||
|
|// stdy (store (long bfp)) [requires z900 GA2]
|
||||||
|// TODO: alternative instructions?
|
|// TODO: alternative instructions?
|
||||||
|
|
|
|
||||||
|.arch s390x
|
|.arch s390x
|
||||||
@ -180,7 +182,7 @@
|
|||||||
|.else
|
|.else
|
||||||
| // Common dispatch. Lower I-Cache use, only one (very) unpredictable branch.
|
| // Common dispatch. Lower I-Cache use, only one (very) unpredictable branch.
|
||||||
| .macro ins_next
|
| .macro ins_next
|
||||||
| jmp ->ins_next
|
| j ->ins_next
|
||||||
| .endmacro
|
| .endmacro
|
||||||
| .macro ins_next_
|
| .macro ins_next_
|
||||||
| ->ins_next:
|
| ->ins_next:
|
||||||
@ -1034,14 +1036,23 @@ static void build_subroutines(BuildCtx *ctx)
|
|||||||
|
|
|
|
||||||
|.macro .ffunc_n, name, op
|
|.macro .ffunc_n, name, op
|
||||||
| .ffunc_1 name
|
| .ffunc_1 name
|
||||||
|
| lg TMPR2, 0(BASE)
|
||||||
|
| checknumtp TMPR2, ->fff_fallback
|
||||||
|
| op f0, 0(BASE) // TODO: might be better to unconditionally load into f1.
|
||||||
|.endmacro
|
|.endmacro
|
||||||
|
|
|
|
||||||
|.macro .ffunc_n, name
|
|.macro .ffunc_n, name
|
||||||
| .ffunc_n name, mvc
|
| .ffunc_n name, ld
|
||||||
|.endmacro
|
|.endmacro
|
||||||
|
|
|
|
||||||
|.macro .ffunc_nn, name
|
|.macro .ffunc_nn, name
|
||||||
| .ffunc_2 name
|
| .ffunc_2 name
|
||||||
|
| lg TMPR1, 0(BASE)
|
||||||
|
| lg TMPR2, 8(BASE)
|
||||||
|
| ld f0, 0(BASE)
|
||||||
|
| ld f1, 8(BASE)
|
||||||
|
| checknumtp TMPR1, ->fff_fallback
|
||||||
|
| checknumtp TMPR2, ->fff_fallback
|
||||||
|.endmacro
|
|.endmacro
|
||||||
|
|
|
|
||||||
|// Inlined GC threshold check. Caveat: uses label 1.
|
|// Inlined GC threshold check. Caveat: uses label 1.
|
||||||
@ -1377,8 +1388,11 @@ static void build_subroutines(BuildCtx *ctx)
|
|||||||
| stg RB, -16(BASE)
|
| stg RB, -16(BASE)
|
||||||
| j ->fff_res1
|
| j ->fff_res1
|
||||||
|
|
|
|
||||||
|.ffunc_n math_sqrt, sqrtsd
|
|.ffunc_n math_sqrt, sqdb
|
||||||
|->fff_resxmm0:
|
|->fff_resf0:
|
||||||
|
| lg PC, -8(BASE)
|
||||||
|
| stdy f0, -16(BASE)
|
||||||
|
| // fallthrough
|
||||||
|
|
|
|
||||||
|->fff_res1:
|
|->fff_res1:
|
||||||
| lghi RD, 1+1
|
| lghi RD, 1+1
|
||||||
@ -1417,13 +1431,29 @@ static void build_subroutines(BuildCtx *ctx)
|
|||||||
| math_round ceil
|
| math_round ceil
|
||||||
|
|
|
|
||||||
|.ffunc math_log
|
|.ffunc math_log
|
||||||
|
| chi NARGS:RD, 1+1; jne ->fff_fallback // Exactly one argument.
|
||||||
|
| lg TMPR2, 0(BASE)
|
||||||
|
| ld f0, 0(BASE)
|
||||||
|
| checknumtp TMPR2, ->fff_fallback
|
||||||
|
| lgr RB, BASE
|
||||||
|
| brasl r14, extern log
|
||||||
|
| lgr BASE, RB
|
||||||
|
| j ->fff_resf0
|
||||||
|
|
|
|
||||||
|.macro math_extern, func
|
|.macro math_extern, func
|
||||||
| .ffunc_n math_ .. func
|
| .ffunc_n math_ .. func
|
||||||
|
| lgr RB, BASE
|
||||||
|
| brasl r14, extern func
|
||||||
|
| lgr BASE, RB
|
||||||
|
| j ->fff_resf0
|
||||||
|.endmacro
|
|.endmacro
|
||||||
|
|
|
|
||||||
|.macro math_extern2, func
|
|.macro math_extern2, func
|
||||||
| .ffunc_nn math_ .. func
|
| .ffunc_nn math_ .. func
|
||||||
|
| lgr RB, BASE
|
||||||
|
| brasl r14, extern func
|
||||||
|
| lgr BASE, RB
|
||||||
|
| j ->fff_resf0
|
||||||
|.endmacro
|
|.endmacro
|
||||||
|
|
|
|
||||||
| math_extern log10
|
| math_extern log10
|
||||||
@ -1442,10 +1472,40 @@ static void build_subroutines(BuildCtx *ctx)
|
|||||||
| math_extern2 fmod
|
| math_extern2 fmod
|
||||||
|
|
|
|
||||||
|.ffunc_2 math_ldexp
|
|.ffunc_2 math_ldexp
|
||||||
|
| lg TMPR2, 0(BASE)
|
||||||
|
| ld f0, 0(BASE)
|
||||||
|
| lg CARG1, 8(BASE)
|
||||||
|
| checknumtp TMPR2, ->fff_fallback
|
||||||
|
| checkinttp CARG1, ->fff_fallback
|
||||||
|
| lgfr CARG1, CARG1
|
||||||
|
| lgr RB, BASE
|
||||||
|
| brasl r14, extern ldexp // (double, int)
|
||||||
|
| lgr BASE, RB
|
||||||
|
| j ->fff_resf0
|
||||||
|
|
|
|
||||||
|.ffunc_n math_frexp
|
|.ffunc_n math_frexp
|
||||||
|
| lgr RB, BASE
|
||||||
|
| la CARG1, TMP_STACK
|
||||||
|
| brasl r14, extern frexp
|
||||||
|
| lgr BASE, RB
|
||||||
|
| llgf RB, TMP_STACK
|
||||||
|
| lg PC, -8(BASE)
|
||||||
|
| stdy f0, -16(BASE)
|
||||||
|
| setint RB
|
||||||
|
| stg RB, -8(BASE)
|
||||||
|
| lghi RD, 1+2
|
||||||
|
| j ->fff_res
|
||||||
|
|
|
|
||||||
|.ffunc_n math_modf
|
|.ffunc_n math_modf
|
||||||
|
| lgr RB, BASE
|
||||||
|
| lay CARG1, -16(BASE)
|
||||||
|
| brasl r14, extern modf // (double, double*)
|
||||||
|
| lgr BASE, RB
|
||||||
|
| lg PC, -8(BASE)
|
||||||
|
| stdy f0, -8(BASE)
|
||||||
|
| lghi RD, 1+2
|
||||||
|
| j ->fff_res
|
||||||
|
|
|
||||||
|.macro math_minmax, name, cmovop, sseop
|
|.macro math_minmax, name, cmovop, sseop
|
||||||
| .ffunc name
|
| .ffunc name
|
||||||
|.endmacro
|
|.endmacro
|
||||||
|
Loading…
Reference in New Issue
Block a user