aboutsummaryrefslogtreecommitdiff
path: root/lopcodes.h
diff options
context:
space:
mode:
authorRoberto Ierusalimschy <roberto@inf.puc-rio.br>2018-01-09 09:24:12 -0200
committerRoberto Ierusalimschy <roberto@inf.puc-rio.br>2018-01-09 09:24:12 -0200
commit33e3774f447cbcfa4fe43b8b47d0306e52937428 (patch)
treedc94b4a1cc4ef596747b0c5393b62eebd9fc714a /lopcodes.h
parenta9295a2b8ebca6bb7071c4424fd318afa33ebb9e (diff)
downloadlua-33e3774f447cbcfa4fe43b8b47d0306e52937428.tar.gz
lua-33e3774f447cbcfa4fe43b8b47d0306e52937428.tar.bz2
lua-33e3774f447cbcfa4fe43b8b47d0306e52937428.zip
keep more opcode arguments byte-aligned
Diffstat (limited to 'lopcodes.h')
-rw-r--r--lopcodes.h36
1 files changed, 20 insertions, 16 deletions
diff --git a/lopcodes.h b/lopcodes.h
index eae0dfaf..22de7a71 100644
--- a/lopcodes.h
+++ b/lopcodes.h
@@ -1,5 +1,5 @@
1/* 1/*
2** $Id: lopcodes.h,v 1.180 2017/12/18 17:49:31 roberto Exp roberto $ 2** $Id: lopcodes.h,v 1.182 2018/01/09 11:21:41 roberto Exp $
3** Opcodes for Lua virtual machine 3** Opcodes for Lua virtual machine
4** See Copyright Notice in lua.h 4** See Copyright Notice in lua.h
5*/ 5*/
@@ -17,11 +17,11 @@
17 17
18 3 3 2 2 2 2 2 2 2 2 2 2 1 1 1 1 1 1 1 1 1 1 0 0 0 0 0 0 0 0 0 0 18 3 3 2 2 2 2 2 2 2 2 2 2 1 1 1 1 1 1 1 1 1 1 0 0 0 0 0 0 0 0 0 0
19 1 0 9 8 7 6 5 4 3 2 1 0 9 8 7 6 5 4 3 2 1 0 9 8 7 6 5 4 3 2 1 0 19 1 0 9 8 7 6 5 4 3 2 1 0 9 8 7 6 5 4 3 2 1 0 9 8 7 6 5 4 3 2 1 0
20iABC |k| C(8) | | B(8) | | A(8) | | Op(7) | 20iABC C(8) | B(8) |k| A(8) | Op(7) |
21iABx | Bx(17) | | A(8) | | Op(7) | 21iABx Bx(17) | A(8) | Op(7) |
22iAsBx | sBx (signed)(17) | | A(8) | | Op(7) | 22iAsB sBx (signed)(17) | A(8) | Op(7) |
23iAx | Ax(25) | | Op(7) | 23iAx Ax(25) | Op(7) |
24iksJ |k| sJ(24) | | Op(7) | 24isJ sJ(24) |m| Op(7) |
25 25
26 A signed argument is represented in excess K: the represented value is 26 A signed argument is represented in excess K: the represented value is
27 the written unsigned value minus K, where K is half the maximum for the 27 the written unsigned value minus K, where K is half the maximum for the
@@ -36,25 +36,27 @@ enum OpMode {iABC, iABx, iAsBx, iAx, isJ}; /* basic instruction formats */
36** size and position of opcode arguments. 36** size and position of opcode arguments.
37*/ 37*/
38#define SIZE_C 8 38#define SIZE_C 8
39#define SIZE_Cx (SIZE_C + 1)
40#define SIZE_B 8 39#define SIZE_B 8
41#define SIZE_Bx (SIZE_Cx + SIZE_B) 40#define SIZE_Bx (SIZE_C + SIZE_B + 1)
42#define SIZE_A 8 41#define SIZE_A 8
43#define SIZE_Ax (SIZE_Cx + SIZE_B + SIZE_A) 42#define SIZE_Ax (SIZE_Bx + SIZE_A)
44#define SIZE_sJ (SIZE_C + SIZE_B + SIZE_A) 43#define SIZE_sJ (SIZE_Bx + SIZE_A - 1)
45
46 44
47#define SIZE_OP 7 45#define SIZE_OP 7
48 46
49#define POS_OP 0 47#define POS_OP 0
48
50#define POS_A (POS_OP + SIZE_OP) 49#define POS_A (POS_OP + SIZE_OP)
51#define POS_B (POS_A + SIZE_A) 50#define POS_k (POS_A + SIZE_A)
51#define POS_B (POS_k + 1)
52#define POS_C (POS_B + SIZE_B) 52#define POS_C (POS_B + SIZE_B)
53#define POS_k (POS_C + SIZE_C) 53
54#define POS_Bx POS_B 54#define POS_Bx POS_k
55
55#define POS_Ax POS_A 56#define POS_Ax POS_A
56#define POS_sJ POS_A
57 57
58#define POS_m POS_A
59#define POS_sJ (POS_A + 1)
58 60
59/* 61/*
60** limits for opcode arguments. 62** limits for opcode arguments.
@@ -125,7 +127,7 @@ enum OpMode {iABC, iABx, iAsBx, iAx, isJ}; /* basic instruction formats */
125#define SETARG_C(i,v) setarg(i, v, POS_C, SIZE_C) 127#define SETARG_C(i,v) setarg(i, v, POS_C, SIZE_C)
126 128
127#define TESTARG_k(i) (cast(int, ((i) & (1u << POS_k)))) 129#define TESTARG_k(i) (cast(int, ((i) & (1u << POS_k))))
128#define GETARG_k(i) getarg(i, POS_k, 1) 130#define GETARG_k(i) check_exp(checkopm(i, iABC), getarg(i, POS_k, 1))
129#define SETARG_k(i,v) setarg(i, v, POS_k, 1) 131#define SETARG_k(i,v) setarg(i, v, POS_k, 1)
130 132
131#define GETARG_Bx(i) check_exp(checkopm(i, iABx), getarg(i, POS_Bx, SIZE_Bx)) 133#define GETARG_Bx(i) check_exp(checkopm(i, iABx), getarg(i, POS_Bx, SIZE_Bx))
@@ -142,6 +144,8 @@ enum OpMode {iABC, iABx, iAsBx, iAx, isJ}; /* basic instruction formats */
142 check_exp(checkopm(i, isJ), getarg(i, POS_sJ, SIZE_sJ) - OFFSET_sJ) 144 check_exp(checkopm(i, isJ), getarg(i, POS_sJ, SIZE_sJ) - OFFSET_sJ)
143#define SETARG_sJ(i,j) \ 145#define SETARG_sJ(i,j) \
144 setarg(i, cast(unsigned int, (j)+OFFSET_sJ), POS_sJ, SIZE_sJ) 146 setarg(i, cast(unsigned int, (j)+OFFSET_sJ), POS_sJ, SIZE_sJ)
147#define GETARG_m(i) check_exp(checkopm(i, isJ), getarg(i, POS_m, 1))
148#define SETARG_m(i,m) setarg(i, m, POS_m, 1)
145 149
146 150
147#define CREATE_ABCk(o,a,b,c,k) ((cast(Instruction, o)<<POS_OP) \ 151#define CREATE_ABCk(o,a,b,c,k) ((cast(Instruction, o)<<POS_OP) \