1 | /* |
2 | ** $Id: lopcodes.c,v 1.55.1.1 2017/04/19 17:20:42 roberto Exp $ |
3 | ** Opcodes for Lua virtual machine |
4 | ** See Copyright Notice in lua.h |
5 | */ |
6 | |
7 | #define lopcodes_c |
8 | #define LUA_CORE |
9 | |
10 | #include "lprefix.h" |
11 | |
12 | |
13 | #include <stddef.h> |
14 | |
15 | #include "lopcodes.h" |
16 | |
17 | |
18 | /* ORDER OP */ |
19 | |
20 | LUAI_DDEF const char *const luaP_opnames[NUM_OPCODES+1] = { |
21 | "MOVE" , |
22 | "LOADK" , |
23 | "LOADKX" , |
24 | "LOADBOOL" , |
25 | "LOADNIL" , |
26 | "GETUPVAL" , |
27 | "GETTABUP" , |
28 | "GETTABLE" , |
29 | "SETTABUP" , |
30 | "SETUPVAL" , |
31 | "SETTABLE" , |
32 | "NEWTABLE" , |
33 | "SELF" , |
34 | "ADD" , |
35 | "SUB" , |
36 | "MUL" , |
37 | "MOD" , |
38 | "POW" , |
39 | "DIV" , |
40 | "IDIV" , |
41 | "BAND" , |
42 | "BOR" , |
43 | "BXOR" , |
44 | "SHL" , |
45 | "SHR" , |
46 | "UNM" , |
47 | "BNOT" , |
48 | "NOT" , |
49 | "LEN" , |
50 | "CONCAT" , |
51 | "JMP" , |
52 | "EQ" , |
53 | "LT" , |
54 | "LE" , |
55 | "TEST" , |
56 | "TESTSET" , |
57 | "CALL" , |
58 | "TAILCALL" , |
59 | "RETURN" , |
60 | "FORLOOP" , |
61 | "FORPREP" , |
62 | "TFORCALL" , |
63 | "TFORLOOP" , |
64 | "SETLIST" , |
65 | "CLOSURE" , |
66 | "VARARG" , |
67 | "EXTRAARG" , |
68 | NULL |
69 | }; |
70 | |
71 | |
72 | #define opmode(t,a,b,c,m) (((t)<<7) | ((a)<<6) | ((b)<<4) | ((c)<<2) | (m)) |
73 | |
74 | LUAI_DDEF const lu_byte luaP_opmodes[NUM_OPCODES] = { |
75 | /* T A B C mode opcode */ |
76 | opmode(0, 1, OpArgR, OpArgN, iABC) /* OP_MOVE */ |
77 | ,opmode(0, 1, OpArgK, OpArgN, iABx) /* OP_LOADK */ |
78 | ,opmode(0, 1, OpArgN, OpArgN, iABx) /* OP_LOADKX */ |
79 | ,opmode(0, 1, OpArgU, OpArgU, iABC) /* OP_LOADBOOL */ |
80 | ,opmode(0, 1, OpArgU, OpArgN, iABC) /* OP_LOADNIL */ |
81 | ,opmode(0, 1, OpArgU, OpArgN, iABC) /* OP_GETUPVAL */ |
82 | ,opmode(0, 1, OpArgU, OpArgK, iABC) /* OP_GETTABUP */ |
83 | ,opmode(0, 1, OpArgR, OpArgK, iABC) /* OP_GETTABLE */ |
84 | ,opmode(0, 0, OpArgK, OpArgK, iABC) /* OP_SETTABUP */ |
85 | ,opmode(0, 0, OpArgU, OpArgN, iABC) /* OP_SETUPVAL */ |
86 | ,opmode(0, 0, OpArgK, OpArgK, iABC) /* OP_SETTABLE */ |
87 | ,opmode(0, 1, OpArgU, OpArgU, iABC) /* OP_NEWTABLE */ |
88 | ,opmode(0, 1, OpArgR, OpArgK, iABC) /* OP_SELF */ |
89 | ,opmode(0, 1, OpArgK, OpArgK, iABC) /* OP_ADD */ |
90 | ,opmode(0, 1, OpArgK, OpArgK, iABC) /* OP_SUB */ |
91 | ,opmode(0, 1, OpArgK, OpArgK, iABC) /* OP_MUL */ |
92 | ,opmode(0, 1, OpArgK, OpArgK, iABC) /* OP_MOD */ |
93 | ,opmode(0, 1, OpArgK, OpArgK, iABC) /* OP_POW */ |
94 | ,opmode(0, 1, OpArgK, OpArgK, iABC) /* OP_DIV */ |
95 | ,opmode(0, 1, OpArgK, OpArgK, iABC) /* OP_IDIV */ |
96 | ,opmode(0, 1, OpArgK, OpArgK, iABC) /* OP_BAND */ |
97 | ,opmode(0, 1, OpArgK, OpArgK, iABC) /* OP_BOR */ |
98 | ,opmode(0, 1, OpArgK, OpArgK, iABC) /* OP_BXOR */ |
99 | ,opmode(0, 1, OpArgK, OpArgK, iABC) /* OP_SHL */ |
100 | ,opmode(0, 1, OpArgK, OpArgK, iABC) /* OP_SHR */ |
101 | ,opmode(0, 1, OpArgR, OpArgN, iABC) /* OP_UNM */ |
102 | ,opmode(0, 1, OpArgR, OpArgN, iABC) /* OP_BNOT */ |
103 | ,opmode(0, 1, OpArgR, OpArgN, iABC) /* OP_NOT */ |
104 | ,opmode(0, 1, OpArgR, OpArgN, iABC) /* OP_LEN */ |
105 | ,opmode(0, 1, OpArgR, OpArgR, iABC) /* OP_CONCAT */ |
106 | ,opmode(0, 0, OpArgR, OpArgN, iAsBx) /* OP_JMP */ |
107 | ,opmode(1, 0, OpArgK, OpArgK, iABC) /* OP_EQ */ |
108 | ,opmode(1, 0, OpArgK, OpArgK, iABC) /* OP_LT */ |
109 | ,opmode(1, 0, OpArgK, OpArgK, iABC) /* OP_LE */ |
110 | ,opmode(1, 0, OpArgN, OpArgU, iABC) /* OP_TEST */ |
111 | ,opmode(1, 1, OpArgR, OpArgU, iABC) /* OP_TESTSET */ |
112 | ,opmode(0, 1, OpArgU, OpArgU, iABC) /* OP_CALL */ |
113 | ,opmode(0, 1, OpArgU, OpArgU, iABC) /* OP_TAILCALL */ |
114 | ,opmode(0, 0, OpArgU, OpArgN, iABC) /* OP_RETURN */ |
115 | ,opmode(0, 1, OpArgR, OpArgN, iAsBx) /* OP_FORLOOP */ |
116 | ,opmode(0, 1, OpArgR, OpArgN, iAsBx) /* OP_FORPREP */ |
117 | ,opmode(0, 0, OpArgN, OpArgU, iABC) /* OP_TFORCALL */ |
118 | ,opmode(0, 1, OpArgR, OpArgN, iAsBx) /* OP_TFORLOOP */ |
119 | ,opmode(0, 0, OpArgU, OpArgU, iABC) /* OP_SETLIST */ |
120 | ,opmode(0, 1, OpArgU, OpArgN, iABx) /* OP_CLOSURE */ |
121 | ,opmode(0, 1, OpArgU, OpArgN, iABC) /* OP_VARARG */ |
122 | ,opmode(0, 0, OpArgU, OpArgU, iAx) /* OP_EXTRAARG */ |
123 | }; |
124 | |
125 | |