aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorMike Pall <mike>2011-03-29 02:31:47 +0200
committerMike Pall <mike>2011-03-29 02:31:47 +0200
commit7b0a125cf76e67df2f1e43f8e3ac4ca08851a7b3 (patch)
tree0d4bf8a484c884329f88b45bdfd0c1d16be0a1ee /src
parentca494b72a949571f10d5d5ef415c3f4d3a09a046 (diff)
downloadluajit-7b0a125cf76e67df2f1e43f8e3ac4ca08851a7b3.tar.gz
luajit-7b0a125cf76e67df2f1e43f8e3ac4ca08851a7b3.tar.bz2
luajit-7b0a125cf76e67df2f1e43f8e3ac4ca08851a7b3.zip
ARM: Add basic unary bytecode instructions.
Diffstat (limited to 'src')
-rw-r--r--src/buildvm_arm.dasc107
1 files changed, 97 insertions, 10 deletions
diff --git a/src/buildvm_arm.dasc b/src/buildvm_arm.dasc
index 650aa31c..0389e6ce 100644
--- a/src/buildvm_arm.dasc
+++ b/src/buildvm_arm.dasc
@@ -684,7 +684,7 @@ static void build_subroutines(BuildCtx *ctx)
684 | 684 |
685 |.ffunc_bit_op band, and 685 |.ffunc_bit_op band, and
686 |.ffunc_bit_op bor, or 686 |.ffunc_bit_op bor, or
687 |.ffunc_bit_op bxor, xor 687 |.ffunc_bit_op bxor, eor
688 | 688 |
689 |.ffunc_bit bswap 689 |.ffunc_bit bswap
690 | NYI 690 | NYI
@@ -850,16 +850,67 @@ static void build_ins(BuildCtx *ctx, BCOp op, int defop)
850 /* -- Unary ops --------------------------------------------------------- */ 850 /* -- Unary ops --------------------------------------------------------- */
851 851
852 case BC_MOV: 852 case BC_MOV:
853 | NYI 853 | // RA = dst*8, RC = src
854 | lsl RC, RC, #3
855 | ins_next1
856 | ldrd CARG12, [BASE, RC]
857 | ins_next2
858 | strd CARG12, [BASE, RA]
859 | ins_next3
854 break; 860 break;
855 case BC_NOT: 861 case BC_NOT:
856 | NYI 862 | // RA = dst*8, RC = src
863 | add RC, BASE, RC, lsl #3
864 | ins_next1
865 | ldr CARG1, [RC, #4]
866 | add RA, BASE, RA
867 | ins_next2
868 | cmn CARG1, #-LJ_TTRUE
869 | mvnls CARG2, #~LJ_TFALSE
870 | mvnhi CARG2, #~LJ_TTRUE
871 | str CARG2, [RA, #4]
872 | ins_next3
857 break; 873 break;
858 case BC_UNM: 874 case BC_UNM:
859 | NYI 875 | // RA = dst*8, RC = src
876 | lsl RC, RC, #3
877 | ldrd CARG12, [BASE, RC]
878 | ins_next1
879 | ins_next2
880 | cmn CARG2, #-LJ_TISNUM
881 | bne >5
882 | rsbs CARG1, CARG1, #0
883 | bvs >4
884 |9:
885 | strd CARG12, [BASE, RA]
886 | ins_next3
887 |4:
888 | mov CARG2, #0x01e00000 // 2^31.
889 | mov CARG1, #0
890 | orr CARG2, CARG2, #0x40000000
891 | b <9
892 |5:
893 | bhi ->vmeta_unm
894 | add CARG2, CARG2, #0x80000000
895 | b <9
860 break; 896 break;
861 case BC_LEN: 897 case BC_LEN:
862 | NYI 898 | // RA = dst*8, RC = src
899 | lsl RC, RC, #3
900 | ldrd CARG12, [BASE, RC]
901 | checkstr CARG2, >2
902 | ldr CARG1, STR:CARG1->len
903 |1:
904 | mvn CARG2, #~LJ_TISNUM
905 | ins_next1
906 | ins_next2
907 | strd CARG12, [BASE, RA]
908 | ins_next3
909 |2:
910 | checktab CARG2, ->vmeta_len
911 | blx extern lj_tab_len // (GCtab *t)
912 | // Returns uint32_t (but less than 2^31).
913 | b <1
863 break; 914 break;
864 915
865 /* -- Binary ops -------------------------------------------------------- */ 916 /* -- Binary ops -------------------------------------------------------- */
@@ -893,7 +944,14 @@ static void build_ins(BuildCtx *ctx, BCOp op, int defop)
893 /* -- Constant ops ------------------------------------------------------ */ 944 /* -- Constant ops ------------------------------------------------------ */
894 945
895 case BC_KSTR: 946 case BC_KSTR:
896 | NYI 947 | // RA = dst*8, RC = str_const (~)
948 | mvn RC, RC
949 | ins_next1
950 | ldr CARG1, [KBASE, RC, lsl #2]
951 | ins_next2
952 | mvn CARG2, #~LJ_TSTR
953 | strd CARG12, [BASE, RA]
954 | ins_next3
897 break; 955 break;
898 case BC_KCDATA: 956 case BC_KCDATA:
899#if LJ_HASFFI 957#if LJ_HASFFI
@@ -901,16 +959,45 @@ static void build_ins(BuildCtx *ctx, BCOp op, int defop)
901#endif 959#endif
902 break; 960 break;
903 case BC_KSHORT: 961 case BC_KSHORT:
904 | NYI 962 | // RA = dst*8, (RC = int16_literal)
963 | mov CARG1, INS, asr #16 // Refetch sign-extended reg.
964 | mvn CARG2, #~LJ_TISNUM
965 | ins_next1
966 | ins_next2
967 | strd CARG12, [BASE, RA]
968 | ins_next3
905 break; 969 break;
906 case BC_KNUM: 970 case BC_KNUM:
907 | NYI 971 | // RA = dst*8, RC = num_const
972 | lsl RC, RC, #3
973 | ins_next1
974 | ldrd CARG12, [KBASE, RC]
975 | ins_next2
976 | strd CARG12, [BASE, RA]
977 | ins_next3
908 break; 978 break;
909 case BC_KPRI: 979 case BC_KPRI:
910 | NYI 980 | // RA = dst*8, RC = primitive_type (~)
981 | add RA, BASE, RA
982 | mvn RC, RC
983 | ins_next1
984 | ins_next2
985 | str RC, [RA, #4]
986 | ins_next3
911 break; 987 break;
912 case BC_KNIL: 988 case BC_KNIL:
913 | NYI 989 | // RA = base*8, RC = end
990 | add RA, BASE, RA
991 | add RC, BASE, RC, lsl #3
992 | mvn CARG1, #~LJ_TNIL
993 | str CARG1, [RA, #4]
994 | add RA, RA, #8
995 |1:
996 | str CARG1, [RA, #4]
997 | cmp RA, RC
998 | add RA, RA, #8
999 | blt <1
1000 | ins_next_
914 break; 1001 break;
915 1002
916 /* -- Upvalue and function ops ------------------------------------------ */ 1003 /* -- Upvalue and function ops ------------------------------------------ */