issue #157 more opcode renaming

pull/159/head
Dibyendu Majumdar 6 years ago
parent f66b38dc99
commit fc6929aa58

@ -190,8 +190,8 @@ OP_CLOSURE,/* A Bx R(A) := closure(KPROTO[Bx]) */
OP_VARARG,/* A B R(A), R(A+1), ..., R(A+B-2) = vararg */
OP_EXTRAARG,/* Ax extra (larger) argument for previous opcode */
OP_RAVI_NEWARRAYI, /* A R(A) := array of int */
OP_RAVI_NEWARRAYF, /* A R(A) := array of float */
OP_RAVI_NEW_IARRAY, /* A R(A) := array of int */
OP_RAVI_NEW_FARRAY, /* A R(A) := array of float */
OP_RAVI_LOADIZ, /* A R(A) := tointeger(0) */
OP_RAVI_LOADFZ, /* A R(A) := tonumber(0) */

@ -53,8 +53,8 @@ opcodes_coverage.SETLIST = 0
opcodes_coverage.CLOSURE = 0
opcodes_coverage.VARARG = 0
opcodes_coverage.EXTRAARG = 0
opcodes_coverage.NEWARRAYI = 0
opcodes_coverage.NEWARRAYF = 0
opcodes_coverage.NEW_IARRAY = 0
opcodes_coverage.NEW_FARRAY = 0
opcodes_coverage.LOADIZ = 0
opcodes_coverage.LOADFZ = 0
opcodes_coverage.UNMF = 0
@ -482,7 +482,7 @@ function x()
return j
end
assert(x() == 55.0)
check(x, 'NEWARRAYF', 'LOADNIL', 'LOADFZ',
check(x, 'NEW_FARRAY', 'LOADNIL', 'LOADFZ',
'LOADK', 'LOADK', 'LOADK', 'FORPREP_I1',
'FARRAY_SET', 'FARRAY_GET', 'ADDFF',
'FORLOOP_I1', 'RETURN', 'RETURN')

@ -55,8 +55,8 @@ opcodes_coverage.SETLIST = 0
opcodes_coverage.CLOSURE = 0
opcodes_coverage.VARARG = 0
opcodes_coverage.EXTRAARG = 0
opcodes_coverage.NEWARRAYI = 0
opcodes_coverage.NEWARRAYF = 0
opcodes_coverage.NEW_IARRAY = 0
opcodes_coverage.NEW_FARRAY = 0
opcodes_coverage.LOADIZ = 0
opcodes_coverage.LOADFZ = 0
opcodes_coverage.UNMF = 0
@ -220,19 +220,19 @@ check(x, {'LOADK', 'LOADK', 'LOADK', 'GETTABUP_SK',
'SUBFF', 'MOVE', 'MOVE', 'RETURN', 'RETURN'})
x=load 'local t: number[] = {}'
check(x, {'NEWARRAYF', 'RETURN'})
check(x, {'NEW_FARRAY', 'RETURN'})
x=load 'local t = @number[] {}'
check(x, {'NEWARRAYF', 'RETURN'})
check(x, {'NEW_FARRAY', 'RETURN'})
x=load 'local t: number[] = @number[] ( @number[] {} )'
check(x, {'NEWARRAYF', 'RETURN'})
check(x, {'NEW_FARRAY', 'RETURN'})
function x()
return { @integer[] {1,2}, @number[] {42} }
end
check(x, {'NEWTABLE', 'NEWARRAYI', 'LOADK', 'LOADK',
'SETLIST', 'NEWARRAYF', 'LOADK', 'SETLIST',
check(x, {'NEWTABLE', 'NEW_IARRAY', 'LOADK', 'LOADK',
'SETLIST', 'NEW_FARRAY', 'LOADK', 'SETLIST',
'SETLIST', 'RETURN', 'RETURN'})
y = x()
assert(ravitype(y[1]) == 'integer[]')
@ -241,20 +241,20 @@ assert(ravitype(y[2]) == 'number[]')
function x()
return @integer[] @integer[] @integer[]{1}
end
check(x, {'NEWARRAYI', 'LOADK', 'SETLIST', 'RETURN', 'RETURN'})
check(x, {'NEW_IARRAY', 'LOADK', 'SETLIST', 'RETURN', 'RETURN'})
assert(ravitype(x()) == 'integer[]')
function x()
return nil or @integer[] {1}
end
assert(ravitype(x()) == 'integer[]')
check(x, {'NEWARRAYI', 'LOADK', 'SETLIST', 'RETURN', 'RETURN'})
check(x, {'NEW_IARRAY', 'LOADK', 'SETLIST', 'RETURN', 'RETURN'})
function x()
return @number[]( @integer[] {1} and @number[] {42} )
end
assert(ravitype(x()) == 'number[]')
assert(x()[1] == 42.0)
check(x, {'NEWARRAYI', 'LOADK', 'SETLIST', 'TEST',
'JMP', 'NEWARRAYF', 'LOADK', 'SETLIST', 'TOARRAYF',
check(x, {'NEW_IARRAY', 'LOADK', 'SETLIST', 'TEST',
'JMP', 'NEW_FARRAY', 'LOADK', 'SETLIST', 'TOARRAYF',
'RETURN', 'RETURN'})

@ -34,7 +34,7 @@ The Architecture of Ravi's JIT Compilation
* The decision to call a JIT compiled version is made in the Lua Infrastructure (specifically in ``luaD_precall()`` function in ``ldo.c``)
* The JIT compiler translates Lua/Ravi bytecode to LLVM IR - i.e. it does not translate Lua source code.
* There is no inlining of Lua functions.
* Generally the JIT compiler implements the same instructions as in ``lvm.c`` - however for some bytecodes the code calls a C function rather than generating inline IR. These opcodes are OP_LOADNIL, OP_NEWTABLE, OP_RAVI_NEWARRAYINT, OP_RAVI_NEWARRAYFLT, OP_SETLIST, OP_CONCAT, OP_CLOSURE, OP_VARARG, OP_RAVI_SHL_II, OP_RAVI_SHR_II.
* Generally the JIT compiler implements the same instructions as in ``lvm.c`` - however for some bytecodes the code calls a C function rather than generating inline IR. These opcodes are OP_LOADNIL, OP_NEWTABLE, OP_RAVI_NEW_IARRAYNT, OP_RAVI_NEW_FARRAYLT, OP_SETLIST, OP_CONCAT, OP_CLOSURE, OP_VARARG, OP_RAVI_SHL_II, OP_RAVI_SHR_II.
* Ravi represents Lua values as done by Lua 5.3 - i.e. in a 16 byte structure.
* Ravi compiler generates type specifc opcodes which result in simpler and higher performance LLVM IR.
@ -154,9 +154,9 @@ Note that if a Lua functions contains a bytecode that cannot be be JITed then th
+-------------------------+----------+--------------------------------------------------+
| OP_EXTRAARG | N/A | extra (larger) argument for previous opcode |
+-------------------------+----------+--------------------------------------------------+
| OP_RAVI_NEWARRAYI | YES | R(A) := array of int |
| OP_RAVI_NEW_IARRAY | YES | R(A) := array of int |
+-------------------------+----------+--------------------------------------------------+
| OP_RAVI_NEWARRAYF | YES | R(A) := array of float |
| OP_RAVI_NEW_FARRAY | YES | R(A) := array of float |
+-------------------------+----------+--------------------------------------------------+
| OP_RAVI_LOADIZ | YES | R(A) := tointeger(0) |
+-------------------------+----------+--------------------------------------------------+

@ -1499,9 +1499,9 @@ static void code_type_assertion(FuncState *fs, UnOpr op, expdesc *e, TString *us
if (e->ravi_type == RAVI_TTABLE && e->pc >= 0) {
Instruction *i = &fs->f->code[e->pc];
if (GET_OPCODE(*i) == OP_NEWTABLE) {
SET_OPCODE(*i, OP_RAVI_NEWARRAYI);
SET_OPCODE(*i, OP_RAVI_NEW_IARRAY);
e->ravi_type = RAVI_TARRAYINT;
DEBUG_EXPR(raviY_printf(fs, "code_type_assertion (OP_NEWTABLE to OP_RAVI_NEWARRAYI) %e\n", e));
DEBUG_EXPR(raviY_printf(fs, "code_type_assertion (OP_NEWTABLE to OP_RAVI_NEW_IARRAY) %e\n", e));
}
return;
}
@ -1512,9 +1512,9 @@ static void code_type_assertion(FuncState *fs, UnOpr op, expdesc *e, TString *us
if (e->ravi_type == RAVI_TTABLE && e->pc >= 0) {
Instruction *i = &fs->f->code[e->pc];
if (GET_OPCODE(*i) == OP_NEWTABLE) {
SET_OPCODE(*i, OP_RAVI_NEWARRAYF);
SET_OPCODE(*i, OP_RAVI_NEW_FARRAY);
e->ravi_type = RAVI_TARRAYFLT;
DEBUG_EXPR(raviY_printf(fs, "code_type_assertion (OP_NEWTABLE to OP_RAVI_NEWARRAYI) %e\n", e));
DEBUG_EXPR(raviY_printf(fs, "code_type_assertion (OP_NEWTABLE to OP_RAVI_NEW_IARRAY) %e\n", e));
}
return;
}

@ -78,8 +78,8 @@ LUAI_DDEF const char *const luaP_opnames[NUM_OPCODES+1] = {
"VARARG",
"EXTRAARG",
"NEWARRAYI", /* A R(A) := array of int */
"NEWARRAYF", /* A R(A) := array of float */
"NEW_IARRAY", /* A R(A) := array of int */
"NEW_FARRAY", /* A R(A) := array of float */
"LOADIZ", /* A R(A) := tointeger(0) */
"LOADFZ", /* A R(A) := tonumber(0) */
@ -219,8 +219,8 @@ LUAI_DDEF const lu_byte luaP_opmodes[NUM_OPCODES] = {
,opmode(0, 1, OpArgU, OpArgN, iABC) /* OP_VARARG */
,opmode(0, 0, OpArgU, OpArgU, iAx) /* OP_EXTRAARG */
,opmode(0, 1, OpArgN, OpArgN, iABC) /* OP_RAVI_NEWARRAYI A R(A) := array of int */
,opmode(0, 1, OpArgN, OpArgN, iABC) /* OP_RAVI_NEWARRAYF A R(A) := array of float */
,opmode(0, 1, OpArgN, OpArgN, iABC) /* OP_RAVI_NEW_IARRAY A R(A) := array of int */
,opmode(0, 1, OpArgN, OpArgN, iABC) /* OP_RAVI_NEW_FARRAY A R(A) := array of float */
,opmode(0, 1, OpArgN, OpArgN, iABC) /* OP_RAVI_LOADIZ A R(A) := tointeger(0) */
,opmode(0, 1, OpArgN, OpArgN, iABC) /* OP_RAVI_LOADFZ A R(A) := tonumber(0) */

@ -1348,8 +1348,8 @@ static void ravi_typecheck(LexState *ls, expdesc *v, int *var_types,
int reg = GETARG_A(*pc);
if (reg ==
v->u.info) { /* double check that register is as expected */
op = (vartype == RAVI_TARRAYINT) ? OP_RAVI_NEWARRAYI
: OP_RAVI_NEWARRAYF;
op = (vartype == RAVI_TARRAYINT) ? OP_RAVI_NEW_IARRAY
: OP_RAVI_NEW_FARRAY;
SET_OPCODE(*pc, op); /* modify opcode */
DEBUG_CODEGEN(
raviY_printf(ls->fs, "[%d]* %o ; modify opcode\n", v->pc, *pc));

@ -342,6 +342,7 @@ static const luaL_Reg stringmetamethods[] = {
{NULL, NULL}
};
/* }====================================================== */
/*

@ -1189,8 +1189,8 @@ int luaV_execute (lua_State *L) {
&&vmlabel(OP_CLOSURE),
&&vmlabel(OP_VARARG),
&&vmlabel(OP_EXTRAARG),
&&vmlabel(OP_RAVI_NEWARRAYI),
&&vmlabel(OP_RAVI_NEWARRAYF),
&&vmlabel(OP_RAVI_NEW_IARRAY),
&&vmlabel(OP_RAVI_NEW_FARRAY),
&&vmlabel(OP_RAVI_LOADIZ),
&&vmlabel(OP_RAVI_LOADFZ),
&&vmlabel(OP_RAVI_UNMF),
@ -2062,7 +2062,7 @@ int luaV_execute (lua_State *L) {
pc += GETARG_sBx(i);
vmbreak;
}
vmcase(OP_RAVI_NEWARRAYI) {
vmcase(OP_RAVI_NEW_IARRAY) {
Table *t;
savepc(L); /* in case of allocation errors */
t = raviH_new(L, RAVI_TARRAYINT, 0);
@ -2070,7 +2070,7 @@ int luaV_execute (lua_State *L) {
checkGC(L, ra + 1);
vmbreak;
}
vmcase(OP_RAVI_NEWARRAYF) {
vmcase(OP_RAVI_NEW_FARRAY) {
Table *t;
savepc(L); /* in case of allocation errors */
t = raviH_new(L, RAVI_TARRAYFLT, 0);

@ -684,8 +684,8 @@ bool raviJ_cancompile(Proto *p) {
case OP_RAVI_TOARRAYI:
case OP_RAVI_TOARRAYF:
case OP_RAVI_TOTAB:
case OP_RAVI_NEWARRAYI:
case OP_RAVI_NEWARRAYF:
case OP_RAVI_NEW_IARRAY:
case OP_RAVI_NEW_FARRAY:
case OP_VARARG:
case OP_CONCAT:
case OP_CLOSURE:
@ -2155,10 +2155,10 @@ bool raviJ_codegen(struct lua_State *L, struct Proto *p,
int B = GETARG_B(i);
emit_op_movetab(&fn, A, B, pc);
} break;
case OP_RAVI_NEWARRAYI: {
case OP_RAVI_NEW_IARRAY: {
emit_op_newarrayint(&fn, A, pc);
} break;
case OP_RAVI_NEWARRAYF: {
case OP_RAVI_NEW_FARRAY: {
emit_op_newarrayfloat(&fn, A, pc);
} break;
case OP_CONCAT: {

@ -1443,10 +1443,10 @@ bool RaviCodeGenerator::compile(lua_State *L, Proto *p,
case OP_RAVI_TOFLT: {
emit_TOFLT(def, A, pc);
} break;
case OP_RAVI_NEWARRAYI: {
case OP_RAVI_NEW_IARRAY: {
emit_NEWARRAYINT(def, A, pc);
} break;
case OP_RAVI_NEWARRAYF: {
case OP_RAVI_NEW_FARRAY: {
emit_NEWARRAYFLOAT(def, A, pc);
} break;
case OP_NEWTABLE: {

@ -866,7 +866,7 @@ void RaviCodeGenerator::emit_SETTABUP_SK(RaviFunctionDef *def, int A, int B,
}
void RaviCodeGenerator::emit_NEWARRAYINT(RaviFunctionDef *def, int A, int pc) {
emit_debug_trace(def, OP_RAVI_NEWARRAYI, pc);
emit_debug_trace(def, OP_RAVI_NEW_IARRAY, pc);
emit_load_base(def);
llvm::Value *ra = emit_gep_register(def, A);
CreateCall3(def->builder, def->raviV_op_newarrayintF, def->L, def->ci_val,
@ -875,7 +875,7 @@ void RaviCodeGenerator::emit_NEWARRAYINT(RaviFunctionDef *def, int A, int pc) {
void RaviCodeGenerator::emit_NEWARRAYFLOAT(RaviFunctionDef *def, int A,
int pc) {
emit_debug_trace(def, OP_RAVI_NEWARRAYF, pc);
emit_debug_trace(def, OP_RAVI_NEW_FARRAY, pc);
emit_load_base(def);
llvm::Value *ra = emit_gep_register(def, A);
CreateCall3(def->builder, def->raviV_op_newarrayfloatF, def->L, def->ci_val,

@ -456,8 +456,8 @@ LUAI_DDEF const char *const luaP_opnames[NUM_OPCODES + 1] =
"VARARG",
"EXTRAARG",
"NEWARRAYI", /* A R(A) := array of int */
"NEWARRAYF", /* A R(A) := array of float */
"NEW_IARRAY", /* A R(A) := array of int */
"NEW_FARRAY", /* A R(A) := array of float */
"LOADIZ", /* A R(A) := tointeger(0) */
"LOADFZ", /* A R(A) := tonumber(0) */

Loading…
Cancel
Save