diff options
| author | Mike Pall <mike> | 2011-04-08 02:47:19 +0200 |
|---|---|---|
| committer | Mike Pall <mike> | 2011-04-08 02:47:19 +0200 |
| commit | 83e302938b690ac76d73937d242ebb0d5b7513c2 (patch) | |
| tree | 26e0850aa19573667465c15a1e464e59d614f383 /src | |
| parent | 1f4f805c9692a13d259d30d728e6748526f543d3 (diff) | |
| download | luajit-83e302938b690ac76d73937d242ebb0d5b7513c2.tar.gz luajit-83e302938b690ac76d73937d242ebb0d5b7513c2.tar.bz2 luajit-83e302938b690ac76d73937d242ebb0d5b7513c2.zip | |
ARM: Add math.* fast functions.
Diffstat (limited to 'src')
| -rw-r--r-- | src/buildvm_arm.dasc | 114 |
1 files changed, 95 insertions, 19 deletions
diff --git a/src/buildvm_arm.dasc b/src/buildvm_arm.dasc index bd121561..dbc31e1a 100644 --- a/src/buildvm_arm.dasc +++ b/src/buildvm_arm.dasc | |||
| @@ -679,12 +679,15 @@ static void build_subroutines(BuildCtx *ctx) | |||
| 679 | | | 679 | | |
| 680 | |.macro .ffunc_n, name | 680 | |.macro .ffunc_n, name |
| 681 | | .ffunc_1 name | 681 | | .ffunc_1 name |
| 682 | | NYI | 682 | | checktp CARG2, LJ_TISNUM |
| 683 | | bhs ->fff_fallback | ||
| 683 | |.endmacro | 684 | |.endmacro |
| 684 | | | 685 | | |
| 685 | |.macro .ffunc_nn, name | 686 | |.macro .ffunc_nn, name |
| 686 | | .ffunc_2 name | 687 | | .ffunc_2 name |
| 687 | | NYI | 688 | | checktp CARG2, LJ_TISNUM |
| 689 | | cmnlo CARG4, #-LJ_TISNUM | ||
| 690 | | bhs ->fff_fallback | ||
| 688 | |.endmacro | 691 | |.endmacro |
| 689 | | | 692 | | |
| 690 | |.macro ffgccheck | 693 | |.macro ffgccheck |
| @@ -947,8 +950,19 @@ static void build_subroutines(BuildCtx *ctx) | |||
| 947 | | | 950 | | |
| 948 | |//-- Math library ------------------------------------------------------- | 951 | |//-- Math library ------------------------------------------------------- |
| 949 | | | 952 | | |
| 950 | |.ffunc_n math_abs | 953 | |.align 8 |
| 951 | | NYI | 954 | |1: |
| 955 | | .long 0x00000000, 0x41e00000 // 2^31. | ||
| 956 | | | ||
| 957 | |.ffunc_1 math_abs | ||
| 958 | | checktp CARG2, LJ_TISNUM | ||
| 959 | | bhi ->fff_fallback | ||
| 960 | | bicne CARG2, CARG2, #0x80000000 | ||
| 961 | | bne ->fff_restv | ||
| 962 | | cmp CARG1, #0 | ||
| 963 | | rsbslt CARG1, CARG1, #0 | ||
| 964 | | ldrdvs CARG12, <1 | ||
| 965 | | // Fallthrough. | ||
| 952 | | | 966 | | |
| 953 | |->fff_restv: | 967 | |->fff_restv: |
| 954 | | // CARG12 = TValue result. | 968 | | // CARG12 = TValue result. |
| @@ -983,13 +997,15 @@ static void build_subroutines(BuildCtx *ctx) | |||
| 983 | | b <5 | 997 | | b <5 |
| 984 | | | 998 | | |
| 985 | |.macro math_extern, func | 999 | |.macro math_extern, func |
| 986 | | .ffunc math_ .. func | 1000 | | .ffunc_n math_ .. func |
| 987 | | NYI | 1001 | | bl extern func |
| 1002 | | b ->fff_restv | ||
| 988 | |.endmacro | 1003 | |.endmacro |
| 989 | | | 1004 | | |
| 990 | |.macro math_extern2, func | 1005 | |.macro math_extern2, func |
| 991 | | .ffunc math_ .. func | 1006 | | .ffunc_nn math_ .. func |
| 992 | | NYI | 1007 | | bl extern func |
| 1008 | | b ->fff_restv | ||
| 993 | |.endmacro | 1009 | |.endmacro |
| 994 | | | 1010 | | |
| 995 | |.macro math_round, func | 1011 | |.macro math_round, func |
| @@ -1019,24 +1035,84 @@ static void build_subroutines(BuildCtx *ctx) | |||
| 1019 | | | 1035 | | |
| 1020 | |->ff_math_deg: | 1036 | |->ff_math_deg: |
| 1021 | |.ffunc_n math_rad | 1037 | |.ffunc_n math_rad |
| 1022 | | NYI | 1038 | | ldrd CARG34, CFUNC:CARG3->upvalue[0] |
| 1039 | | bl extern __aeabi_dmul | ||
| 1040 | | b ->fff_restv | ||
| 1023 | | | 1041 | | |
| 1024 | |.ffunc math_ldexp | 1042 | |.ffunc_2 math_ldexp |
| 1025 | | NYI | 1043 | | checktp CARG2, LJ_TISNUM |
| 1044 | | bhs ->fff_fallback | ||
| 1045 | | checktp CARG4, LJ_TISNUM | ||
| 1046 | | bne ->fff_fallback | ||
| 1047 | | bl extern ldexp // (double x, int exp) | ||
| 1048 | | b ->fff_restv | ||
| 1026 | | | 1049 | | |
| 1027 | |.ffunc math_frexp | 1050 | |.ffunc_n math_frexp |
| 1028 | | NYI | 1051 | | mov CARG3, sp |
| 1052 | | bl extern frexp | ||
| 1053 | | ldr CARG3, [sp] | ||
| 1054 | | mvn CARG4, #~LJ_TISNUM | ||
| 1055 | | ldr PC, [BASE, FRAME_PC] | ||
| 1056 | | strd CARG12, [BASE, #-8] | ||
| 1057 | | mov RC, #(2+1)*8 | ||
| 1058 | | strd CARG34, [BASE] | ||
| 1059 | | b ->fff_res | ||
| 1029 | | | 1060 | | |
| 1030 | |.ffunc math_modf | 1061 | |.ffunc_n math_modf |
| 1031 | | NYI | 1062 | | sub CARG3, BASE, #8 |
| 1063 | | ldr PC, [BASE, FRAME_PC] | ||
| 1064 | | bl extern modf | ||
| 1065 | | mov RC, #(2+1)*8 | ||
| 1066 | | strd CARG12, [BASE] | ||
| 1067 | | b ->fff_res | ||
| 1032 | | | 1068 | | |
| 1033 | |.macro math_minmax, name, cmpop | 1069 | |.macro math_minmax, name, cond, fcond |
| 1034 | | .ffunc_1 name | 1070 | | .ffunc_1 name |
| 1035 | | NYI | 1071 | | checktp CARG2, LJ_TISNUM |
| 1072 | | mov RA, #8 | ||
| 1073 | | bne >4 | ||
| 1074 | |1: // Handle integers. | ||
| 1075 | | ldrd CARG34, [BASE, RA] | ||
| 1076 | | cmp RA, RC | ||
| 1077 | | bhs ->fff_restv | ||
| 1078 | | checktp CARG4, LJ_TISNUM | ||
| 1079 | | bne >3 | ||
| 1080 | | cmp CARG1, CARG3 | ||
| 1081 | | add RA, RA, #8 | ||
| 1082 | | mov..cond CARG1, CARG3 | ||
| 1083 | | b <1 | ||
| 1084 | |3: | ||
| 1085 | | bhi ->fff_fallback | ||
| 1086 | | // Convert intermediate result to number and continue below. | ||
| 1087 | | bl extern __aeabi_i2d | ||
| 1088 | | ldrd CARG34, [BASE, RA] | ||
| 1089 | | b >6 | ||
| 1090 | | | ||
| 1091 | |4: | ||
| 1092 | | bhi ->fff_fallback | ||
| 1093 | |5: // Handle numbers. | ||
| 1094 | | ldrd CARG34, [BASE, RA] | ||
| 1095 | | cmp RA, RC | ||
| 1096 | | bhs ->fff_restv | ||
| 1097 | | checktp CARG4, LJ_TISNUM | ||
| 1098 | | bhs >7 | ||
| 1099 | |6: | ||
| 1100 | | bl extern __aeabi_cdcmple | ||
| 1101 | | add RA, RA, #8 | ||
| 1102 | | mov..fcond CARG1, CARG3 | ||
| 1103 | | mov..fcond CARG2, CARG4 | ||
| 1104 | | b <5 | ||
| 1105 | |7: // Convert integer to number and continue above. | ||
| 1106 | | bhi ->fff_fallback | ||
| 1107 | | strd CARG12, TMPD | ||
| 1108 | | mov CARG1, CARG3 | ||
| 1109 | | bl extern __aeabi_i2d | ||
| 1110 | | ldrd CARG34, TMPD | ||
| 1111 | | b <6 | ||
| 1036 | |.endmacro | 1112 | |.endmacro |
| 1037 | | | 1113 | | |
| 1038 | | math_minmax math_min, NYI | 1114 | | math_minmax math_min, gt, hi |
| 1039 | | math_minmax math_max, NYI | 1115 | | math_minmax math_max, lt, lo |
| 1040 | | | 1116 | | |
| 1041 | |//-- String library ----------------------------------------------------- | 1117 | |//-- String library ----------------------------------------------------- |
| 1042 | | | 1118 | | |
