Merge tag 'v3.14.25' into backport/v3.14.24-ltsi-rc1+v3.14.25/snapshot-merge.wip
[platform/adaptation/renesas_rcar/renesas_kernel.git] / drivers / staging / ktap / runtime / kp_opcode.c
1 /*
2  * kp_opcode.c
3  *
4  * This file is part of ktap by Jovi Zhangwei.
5  *
6  * Copyright (C) 2012-2013 Jovi Zhangwei <jovi.zhangwei@gmail.com>.
7  *
8  * Copyright (C) 1994-2013 Lua.org, PUC-Rio.
9  *  - The part of code in this file is copied from lua initially.
10  *  - lua's MIT license is compatible with GPL.
11  *
12  * ktap is free software; you can redistribute it and/or modify it
13  * under the terms and conditions of the GNU General Public License,
14  * version 2, as published by the Free Software Foundation.
15  *
16  * ktap is distributed in the hope it will be useful, but WITHOUT
17  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
18  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License for
19  * more details.
20  *
21  * You should have received a copy of the GNU General Public License along with
22  * this program; if not, write to the Free Software Foundation, Inc.,
23  * 51 Franklin St - Fifth Floor, Boston, MA 02110-1301 USA.
24  */
25
26 #include "../include/ktap_types.h"
27 #include "../include/ktap_opcodes.h"
28
29 const char *const ktap_opnames[NUM_OPCODES + 1] = {
30   "MOVE",
31   "LOADK",
32   "LOADKX",
33   "LOADBOOL",
34   "LOADNIL",
35   "GETUPVAL",
36   "GETTABUP",
37   "GETTABLE",
38   "SETTABUP",
39   "SETTABUP_INCR",
40   "SETTABUP_AGGR",
41   "SETUPVAL",
42   "SETTABLE",
43   "SETTABLE_INCR",
44   "SETTABLE_AGGR",
45   "NEWTABLE",
46   "SELF",
47   "ADD",
48   "SUB",
49   "MUL",
50   "DIV",
51   "MOD",
52   "POW",
53   "UNM",
54   "NOT",
55   "LEN",
56   "CONCAT",
57   "JMP",
58   "EQ",
59   "LT",
60   "LE",
61   "TEST",
62   "TESTSET",
63   "CALL",
64   "TAILCALL",
65   "RETURN",
66   "FORLOOP",
67   "FORPREP",
68   "TFORCALL",
69   "TFORLOOP",
70   "SETLIST",
71   "CLOSURE",
72   "VARARG",
73   "EXTRAARG",
74
75   "EVENT",
76   "EVENT_NAME",
77   "EVENT_ARG", /* arg1, arg2 .. arg9 */
78   NULL
79 };
80
81
82 #define opmode(t,a,b,c,m) (((t)<<7) | ((a)<<6) | ((b)<<4) | ((c)<<2) | (m))
83
84 const u8 ktap_opmodes[NUM_OPCODES] = {
85 /*       T  A    B       C     mode                opcode       */
86   opmode(0, 1, OpArgR, OpArgN, iABC)            /* OP_MOVE */
87  ,opmode(0, 1, OpArgK, OpArgN, iABx)            /* OP_LOADK */
88  ,opmode(0, 1, OpArgN, OpArgN, iABx)            /* OP_LOADKX */
89  ,opmode(0, 1, OpArgU, OpArgU, iABC)            /* OP_LOADBOOL */
90  ,opmode(0, 1, OpArgU, OpArgN, iABC)            /* OP_LOADNIL */
91  ,opmode(0, 1, OpArgU, OpArgN, iABC)            /* OP_GETUPVAL */
92  ,opmode(0, 1, OpArgU, OpArgK, iABC)            /* OP_GETTABUP */
93  ,opmode(0, 1, OpArgR, OpArgK, iABC)            /* OP_GETTABLE */
94  ,opmode(0, 0, OpArgK, OpArgK, iABC)            /* OP_SETTABUP */
95  ,opmode(0, 0, OpArgK, OpArgK, iABC)            /* OP_SETTABUP_INCR */
96  ,opmode(0, 0, OpArgK, OpArgK, iABC)            /* OP_SETTABUP_AGGR */
97  ,opmode(0, 0, OpArgU, OpArgN, iABC)            /* OP_SETUPVAL */
98  ,opmode(0, 0, OpArgK, OpArgK, iABC)            /* OP_SETTABLE */
99  ,opmode(0, 0, OpArgK, OpArgK, iABC)            /* OP_SETTABUP_INCR */
100  ,opmode(0, 0, OpArgK, OpArgK, iABC)            /* OP_SETTABUP_AGGR */
101  ,opmode(0, 1, OpArgU, OpArgU, iABC)            /* OP_NEWTABLE */
102  ,opmode(0, 1, OpArgR, OpArgK, iABC)            /* OP_SELF */
103  ,opmode(0, 1, OpArgK, OpArgK, iABC)            /* OP_ADD */
104  ,opmode(0, 1, OpArgK, OpArgK, iABC)            /* OP_SUB */
105  ,opmode(0, 1, OpArgK, OpArgK, iABC)            /* OP_MUL */
106  ,opmode(0, 1, OpArgK, OpArgK, iABC)            /* OP_DIV */
107  ,opmode(0, 1, OpArgK, OpArgK, iABC)            /* OP_MOD */
108  ,opmode(0, 1, OpArgK, OpArgK, iABC)            /* OP_POW */
109  ,opmode(0, 1, OpArgR, OpArgN, iABC)            /* OP_UNM */
110  ,opmode(0, 1, OpArgR, OpArgN, iABC)            /* OP_NOT */
111  ,opmode(0, 1, OpArgR, OpArgN, iABC)            /* OP_LEN */
112  ,opmode(0, 1, OpArgR, OpArgR, iABC)            /* OP_CONCAT */
113  ,opmode(0, 0, OpArgR, OpArgN, iAsBx)           /* OP_JMP */
114  ,opmode(1, 0, OpArgK, OpArgK, iABC)            /* OP_EQ */
115  ,opmode(1, 0, OpArgK, OpArgK, iABC)            /* OP_LT */
116  ,opmode(1, 0, OpArgK, OpArgK, iABC)            /* OP_LE */
117  ,opmode(1, 0, OpArgN, OpArgU, iABC)            /* OP_TEST */
118  ,opmode(1, 1, OpArgR, OpArgU, iABC)            /* OP_TESTSET */
119  ,opmode(0, 1, OpArgU, OpArgU, iABC)            /* OP_CALL */
120  ,opmode(0, 1, OpArgU, OpArgU, iABC)            /* OP_TAILCALL */
121  ,opmode(0, 0, OpArgU, OpArgN, iABC)            /* OP_RETURN */
122  ,opmode(0, 1, OpArgR, OpArgN, iAsBx)           /* OP_FORLOOP */
123  ,opmode(0, 1, OpArgR, OpArgN, iAsBx)           /* OP_FORPREP */
124  ,opmode(0, 0, OpArgN, OpArgU, iABC)            /* OP_TFORCALL */
125  ,opmode(0, 1, OpArgR, OpArgN, iAsBx)           /* OP_TFORLOOP */
126  ,opmode(0, 0, OpArgU, OpArgU, iABC)            /* OP_SETLIST */
127  ,opmode(0, 1, OpArgU, OpArgN, iABx)            /* OP_CLOSURE */
128  ,opmode(0, 1, OpArgU, OpArgN, iABC)            /* OP_VARARG */
129  ,opmode(0, 0, OpArgU, OpArgU, iAx)             /* OP_EXTRAARG */
130  ,opmode(0, 1, OpArgR, OpArgK, iABC)            /* OP_EVENT */
131  ,opmode(0, 1, OpArgR, OpArgK, iABC)            /* OP_EVENTNAME */
132  ,opmode(0, 1, OpArgR, OpArgK, iABC)            /* OP_EVENTARG */
133 };
134