summaryrefslogtreecommitdiff
path: root/lopcodes.h
diff options
context:
space:
mode:
authorRoberto Ierusalimschy <roberto@inf.puc-rio.br>2017-11-28 10:58:18 -0200
committerRoberto Ierusalimschy <roberto@inf.puc-rio.br>2017-11-28 10:58:18 -0200
commitff5fe5104413cf2a5156f86479d4b9b130bad7a6 (patch)
tree7ab4b89eafe1d39962c1aca42d47b40159416854 /lopcodes.h
parentdfd188ba12f22db8d31cb80426d568e97345e1e2 (diff)
downloadlua-github-ff5fe5104413cf2a5156f86479d4b9b130bad7a6.tar.gz
using register 'k' for conditions in tests (we only need one bit there)
Diffstat (limited to 'lopcodes.h')
-rw-r--r--lopcodes.h30
1 files changed, 18 insertions, 12 deletions
diff --git a/lopcodes.h b/lopcodes.h
index 5b955ce8..f2b67165 100644
--- a/lopcodes.h
+++ b/lopcodes.h
@@ -1,5 +1,5 @@
/*
-** $Id: lopcodes.h,v 1.170 2017/11/22 19:15:44 roberto Exp roberto $
+** $Id: lopcodes.h,v 1.171 2017/11/27 17:44:31 roberto Exp roberto $
** Opcodes for Lua virtual machine
** See Copyright Notice in lua.h
*/
@@ -114,13 +114,15 @@ enum OpMode {iABC, iABx, iAsBx, iAx, isJ}; /* basic instruction formats */
#define SETARG_A(i,v) setarg(i, v, POS_A, SIZE_A)
#define GETARG_B(i) check_exp(checkopm(i, iABC), getarg(i, POS_B, SIZE_B))
+#define GETARG_sB(i) (GETARG_B(i) - MAXARG_sC)
#define SETARG_B(i,v) setarg(i, v, POS_B, SIZE_B)
#define GETARG_C(i) check_exp(checkopm(i, iABC), getarg(i, POS_C, SIZE_C))
#define GETARG_sC(i) (GETARG_C(i) - MAXARG_sC)
#define SETARG_C(i,v) setarg(i, v, POS_C, SIZE_C)
-#define GETARG_k(i) (cast(int, ((i) & (1 << POS_k))))
+#define TESTARG_k(i) (cast(int, ((i) & (1 << POS_k))))
+#define GETARG_k(i) getarg(i, POS_k, 1)
#define SETARG_k(i,v) setarg(i, v, POS_k, 1)
#define GETARG_Bx(i) check_exp(checkopm(i, iABx), getarg(i, POS_Bx, SIZE_Bx))
@@ -236,17 +238,17 @@ OP_CONCAT,/* A B C R(A) := R(B).. ... ..R(C) */
OP_CLOSE,/* A close all upvalues >= R(A) */
OP_JMP,/* k sJ pc += sJ (k is used in code generation) */
-OP_EQ,/* A B C if ((R(A) == R(C)) ~= B) then pc++ */
-OP_LT,/* A B C if ((R(A) < R(C)) ~= B) then pc++ */
-OP_LE,/* A B C if ((R(A) <= R(C)) ~= B) then pc++ */
+OP_EQ,/* A B if ((R(A) == R(B)) ~= k) then pc++ */
+OP_LT,/* A B if ((R(A) < R(B)) ~= k) then pc++ */
+OP_LE,/* A B if ((R(A) <= R(B)) ~= k) then pc++ */
-OP_EQK,/* A B C if ((R(A) == K(C)) ~= B) then pc++ */
-OP_EQI,/* A B C if ((R(A) == C) ~= B) then pc++ */
-OP_LTI,/* A B C if ((R(A) < C) ~= B) then pc++ */
-OP_LEI,/* A B C if ((R(A) <= C) ~= B) then pc++ */
+OP_EQK,/* A B if ((R(A) == K(B)) ~= k) then pc++ */
+OP_EQI,/* A sB if ((R(A) == sB) ~= k) then pc++ */
+OP_LTI,/* A sB if ((R(A) < sB) ~= k) then pc++ */
+OP_LEI,/* A sB if ((R(A) <= sB) ~= k) then pc++ */
-OP_TEST,/* A C if not (R(A) <=> C) then pc++ */
-OP_TESTSET,/* A B C if (R(B) <=> C) then R(A) := R(B) else pc++ */
+OP_TEST,/* A if (not R(A) == k) then pc++ */
+OP_TESTSET,/* A B if (not R(B) == k) then R(A) := R(B) else pc++ */
OP_CALL,/* A B C R(A), ... ,R(A+C-2) := R(A)(R(A+1), ... ,R(A+B-1)) */
OP_TAILCALL,/* A B C return R(A)(R(A+1), ... ,R(A+B-1)) */
@@ -289,9 +291,13 @@ OP_EXTRAARG/* Ax extra (larger) argument for previous opcode */
(*) In OP_LOADKX, the next 'instruction' is always EXTRAARG.
- (*) For comparisons, A specifies what condition the test should accept
+ (*) For comparisons, k specifies what condition the test should accept
(true or false).
+ (*) For OP_LTI/OP_LEI, C indicates that the transformations
+ (A<B) => (!(B<=A)) or (A<=B) => (!(B<A)) were used to put the
+ constant operator on the right side.
+
(*) All 'skips' (pc++) assume that next instruction is a jump.
===========================================================================*/