| 75 |
|
|
| 76 |
/* Instruction bit sections. |
/* Instruction bit sections. |
| 77 |
OE and Rc flag (see ALT_SET_FLAGS). */ |
OE and Rc flag (see ALT_SET_FLAGS). */ |
| 78 |
#define OERC(flags) (((flags & ALT_SET_FLAGS) >> 15) | ((flags & ALT_SET_FLAGS) >> 5)) |
#define OERC(flags) (((flags & ALT_SET_FLAGS) >> 10) | (flags & ALT_SET_FLAGS)) |
| 79 |
/* Rc flag (see ALT_SET_FLAGS). */ |
/* Rc flag (see ALT_SET_FLAGS). */ |
| 80 |
#define RC(flags) ((flags & ALT_SET_FLAGS) >> 15) |
#define RC(flags) ((flags & ALT_SET_FLAGS) >> 10) |
| 81 |
#define HI(opcode) ((opcode) << 26) |
#define HI(opcode) ((opcode) << 26) |
| 82 |
#define LO(opcode) ((opcode) << 1) |
#define LO(opcode) ((opcode) << 1) |
| 83 |
|
|
| 97 |
#define BLR (HI(19) | LO(16) | (0x14 << 21)) |
#define BLR (HI(19) | LO(16) | (0x14 << 21)) |
| 98 |
#define CNTLZD (HI(31) | LO(58)) |
#define CNTLZD (HI(31) | LO(58)) |
| 99 |
#define CNTLZW (HI(31) | LO(26)) |
#define CNTLZW (HI(31) | LO(26)) |
| 100 |
|
#define CMP (HI(31) | LO(0)) |
| 101 |
#define CMPI (HI(11)) |
#define CMPI (HI(11)) |
| 102 |
#define CMPL (HI(31) | LO(32)) |
#define CMPL (HI(31) | LO(32)) |
| 103 |
#define CMPLI (HI(10)) |
#define CMPLI (HI(10)) |
| 391 |
|
|
| 392 |
/* Other inp_flags. */ |
/* Other inp_flags. */ |
| 393 |
|
|
| 394 |
#define ARG_TEST 0x0100 |
#define ARG_TEST 0x000100 |
|
#define ALT_FORM1 0x0200 |
|
|
#define ALT_FORM2 0x0400 |
|
|
#define ALT_FORM3 0x0800 |
|
|
#define ALT_FORM4 0x1000 |
|
|
#define ALT_FORM5 0x2000 |
|
| 395 |
/* Integer opertion and set flags -> requires exts on 64 bit systems. */ |
/* Integer opertion and set flags -> requires exts on 64 bit systems. */ |
| 396 |
#define ALT_SIGN_EXT 0x4000 |
#define ALT_SIGN_EXT 0x000200 |
| 397 |
/* This flag affects the RC() and OERC() macros. */ |
/* This flag affects the RC() and OERC() macros. */ |
| 398 |
#define ALT_SET_FLAGS 0x8000 |
#define ALT_SET_FLAGS 0x000400 |
| 399 |
|
#define ALT_FORM1 0x010000 |
| 400 |
/* Source and destination is register. */ |
#define ALT_FORM2 0x020000 |
| 401 |
#define REG_DEST 0x0001 |
#define ALT_FORM3 0x040000 |
| 402 |
#define REG1_SOURCE 0x0002 |
#define ALT_FORM4 0x080000 |
| 403 |
#define REG2_SOURCE 0x0004 |
#define ALT_FORM5 0x100000 |
| 404 |
/* getput_arg_fast returned true. */ |
#define ALT_FORM6 0x200000 |
| 405 |
#define FAST_DEST 0x0008 |
|
| 406 |
/* Multiple instructions are required. */ |
/* Source and destination is register. */ |
| 407 |
#define SLOW_DEST 0x0010 |
#define REG_DEST 0x000001 |
| 408 |
/* ALT_FORM1 0x0200 |
#define REG1_SOURCE 0x000002 |
| 409 |
ALT_FORM2 0x0400 |
#define REG2_SOURCE 0x000004 |
| 410 |
ALT_FORM3 0x0800 |
/* getput_arg_fast returned true. */ |
| 411 |
ALT_FORM4 0x1000 |
#define FAST_DEST 0x000008 |
| 412 |
ALT_FORM5 0x2000 |
/* Multiple instructions are required. */ |
| 413 |
ALT_SIGN_EXT 0x4000 |
#define SLOW_DEST 0x000010 |
| 414 |
ALT_SET_FLAGS 0x8000 */ |
/* |
| 415 |
|
ALT_SIGN_EXT 0x000200 |
| 416 |
|
ALT_SET_FLAGS 0x000400 |
| 417 |
|
ALT_FORM1 0x010000 |
| 418 |
|
... |
| 419 |
|
ALT_FORM6 0x200000 */ |
| 420 |
|
|
| 421 |
#if (defined SLJIT_CONFIG_PPC_32 && SLJIT_CONFIG_PPC_32) |
#if (defined SLJIT_CONFIG_PPC_32 && SLJIT_CONFIG_PPC_32) |
| 422 |
#include "sljitNativePPC_32.c" |
#include "sljitNativePPC_32.c" |
| 500 |
return SLJIT_SUCCESS; |
return SLJIT_SUCCESS; |
| 501 |
} |
} |
| 502 |
|
|
| 503 |
SLJIT_API_FUNC_ATTRIBUTE void sljit_fake_enter(struct sljit_compiler *compiler, int args, int temporaries, int generals, int local_size) |
SLJIT_API_FUNC_ATTRIBUTE void sljit_set_context(struct sljit_compiler *compiler, int args, int temporaries, int generals, int local_size) |
| 504 |
{ |
{ |
| 505 |
CHECK_ERROR_VOID(); |
CHECK_ERROR_VOID(); |
| 506 |
check_sljit_fake_enter(compiler, args, temporaries, generals, local_size); |
check_sljit_set_context(compiler, args, temporaries, generals, local_size); |
| 507 |
|
|
| 508 |
compiler->temporaries = temporaries; |
compiler->temporaries = temporaries; |
| 509 |
compiler->generals = generals; |
compiler->generals = generals; |
| 902 |
int src1_r; |
int src1_r; |
| 903 |
int src2_r; |
int src2_r; |
| 904 |
int sugg_src2_r = TMP_REG2; |
int sugg_src2_r = TMP_REG2; |
| 905 |
int flags = inp_flags & (ALT_FORM1 | ALT_FORM2 | ALT_FORM3 | ALT_FORM4 | ALT_FORM5 | ALT_SIGN_EXT | ALT_SET_FLAGS); |
int flags = inp_flags & (ALT_FORM1 | ALT_FORM2 | ALT_FORM3 | ALT_FORM4 | ALT_FORM5 | ALT_FORM6 | ALT_SIGN_EXT | ALT_SET_FLAGS); |
| 906 |
|
|
| 907 |
compiler->cache_arg = 0; |
compiler->cache_arg = 0; |
| 908 |
compiler->cache_argw = 0; |
compiler->cache_argw = 0; |
| 1174 |
(((src) & SLJIT_IMM) && !((srcw) & ~0xffff0000)) |
(((src) & SLJIT_IMM) && !((srcw) & ~0xffff0000)) |
| 1175 |
|
|
| 1176 |
#if (defined SLJIT_CONFIG_PPC_64 && SLJIT_CONFIG_PPC_64) |
#if (defined SLJIT_CONFIG_PPC_64 && SLJIT_CONFIG_PPC_64) |
| 1177 |
|
#define TEST_ADD_IMM(src, srcw) \ |
| 1178 |
|
(((src) & SLJIT_IMM) && (srcw) <= SLJIT_W(0x7fff7fff) && (srcw) >= SLJIT_W(-0x80000000)) |
| 1179 |
|
#else |
| 1180 |
|
#define TEST_ADD_IMM(src, srcw) \ |
| 1181 |
|
((src) & SLJIT_IMM) |
| 1182 |
|
#endif |
| 1183 |
|
|
| 1184 |
|
#if (defined SLJIT_CONFIG_PPC_64 && SLJIT_CONFIG_PPC_64) |
| 1185 |
#define TEST_UI_IMM(src, srcw) \ |
#define TEST_UI_IMM(src, srcw) \ |
| 1186 |
(((src) & SLJIT_IMM) && !((srcw) & ~0xffffffff)) |
(((src) & SLJIT_IMM) && !((srcw) & ~0xffffffff)) |
| 1187 |
#else |
#else |
| 1220 |
|
|
| 1221 |
switch (GET_OPCODE(op)) { |
switch (GET_OPCODE(op)) { |
| 1222 |
case SLJIT_ADD: |
case SLJIT_ADD: |
| 1223 |
if (!GET_FLAGS(op)) { |
if (!GET_FLAGS(op) && ((src1 | src2) & SLJIT_IMM)) { |
| 1224 |
if (TEST_SL_IMM(src2, src2w)) { |
if (TEST_SL_IMM(src2, src2w)) { |
| 1225 |
compiler->imm = src2w & 0xffff; |
compiler->imm = src2w & 0xffff; |
| 1226 |
return emit_op(compiler, SLJIT_ADD, inp_flags | ALT_FORM1, dst, dstw, src1, src1w, TMP_REG2, 0); |
return emit_op(compiler, SLJIT_ADD, inp_flags | ALT_FORM1, dst, dstw, src1, src1w, TMP_REG2, 0); |
| 1237 |
compiler->imm = (src1w >> 16) & 0xffff; |
compiler->imm = (src1w >> 16) & 0xffff; |
| 1238 |
return emit_op(compiler, SLJIT_ADD, inp_flags | ALT_FORM2, dst, dstw, src2, src2w, TMP_REG2, 0); |
return emit_op(compiler, SLJIT_ADD, inp_flags | ALT_FORM2, dst, dstw, src2, src2w, TMP_REG2, 0); |
| 1239 |
} |
} |
| 1240 |
|
/* Range between -1 and -32768 is covered above. */ |
| 1241 |
|
if (TEST_ADD_IMM(src2, src2w)) { |
| 1242 |
|
compiler->imm = src2w & 0xffffffff; |
| 1243 |
|
return emit_op(compiler, SLJIT_ADD, inp_flags | ALT_FORM4, dst, dstw, src1, src1w, TMP_REG2, 0); |
| 1244 |
|
} |
| 1245 |
|
if (TEST_ADD_IMM(src1, src1w)) { |
| 1246 |
|
compiler->imm = src1w & 0xffffffff; |
| 1247 |
|
return emit_op(compiler, SLJIT_ADD, inp_flags | ALT_FORM4, dst, dstw, src2, src2w, TMP_REG2, 0); |
| 1248 |
|
} |
| 1249 |
} |
} |
| 1250 |
if (!(GET_FLAGS(op) & (SLJIT_SET_E | SLJIT_SET_O))) { |
if (!(GET_FLAGS(op) & (SLJIT_SET_E | SLJIT_SET_O))) { |
| 1251 |
if (TEST_SL_IMM(src2, src2w)) { |
if (TEST_SL_IMM(src2, src2w)) { |
| 1263 |
return emit_op(compiler, SLJIT_ADDC, inp_flags | (!(op & SLJIT_KEEP_FLAGS) ? 0 : ALT_FORM1), dst, dstw, src1, src1w, src2, src2w); |
return emit_op(compiler, SLJIT_ADDC, inp_flags | (!(op & SLJIT_KEEP_FLAGS) ? 0 : ALT_FORM1), dst, dstw, src1, src1w, src2, src2w); |
| 1264 |
|
|
| 1265 |
case SLJIT_SUB: |
case SLJIT_SUB: |
| 1266 |
if (!GET_FLAGS(op)) { |
if (!GET_FLAGS(op) && ((src1 | src2) & SLJIT_IMM)) { |
| 1267 |
if (TEST_SL_IMM(src2, -src2w)) { |
if (TEST_SL_IMM(src2, -src2w)) { |
| 1268 |
compiler->imm = (-src2w) & 0xffff; |
compiler->imm = (-src2w) & 0xffff; |
| 1269 |
return emit_op(compiler, SLJIT_ADD, inp_flags | ALT_FORM1, dst, dstw, src1, src1w, TMP_REG2, 0); |
return emit_op(compiler, SLJIT_ADD, inp_flags | ALT_FORM1, dst, dstw, src1, src1w, TMP_REG2, 0); |
| 1276 |
compiler->imm = ((-src2w) >> 16) & 0xffff; |
compiler->imm = ((-src2w) >> 16) & 0xffff; |
| 1277 |
return emit_op(compiler, SLJIT_ADD, inp_flags | ALT_FORM2, dst, dstw, src1, src1w, TMP_REG2, 0); |
return emit_op(compiler, SLJIT_ADD, inp_flags | ALT_FORM2, dst, dstw, src1, src1w, TMP_REG2, 0); |
| 1278 |
} |
} |
| 1279 |
|
/* Range between -1 and -32768 is covered above. */ |
| 1280 |
|
if (TEST_ADD_IMM(src2, -src2w)) { |
| 1281 |
|
compiler->imm = -src2w & 0xffffffff; |
| 1282 |
|
return emit_op(compiler, SLJIT_ADD, inp_flags | ALT_FORM4, dst, dstw, src1, src1w, TMP_REG2, 0); |
| 1283 |
|
} |
| 1284 |
} |
} |
| 1285 |
if (dst == SLJIT_UNUSED && !(GET_FLAGS(op) & ~(SLJIT_SET_E | SLJIT_SET_S))) { |
if (dst == SLJIT_UNUSED && (op & (SLJIT_SET_E | SLJIT_SET_S | SLJIT_SET_U)) && !(op & (SLJIT_SET_O | SLJIT_SET_C))) { |
| 1286 |
/* We know ALT_SIGN_EXT is set if it is an SLJIT_INT_OP on 64 bit systems. */ |
if (!(op & SLJIT_SET_U)) { |
| 1287 |
if (TEST_SL_IMM(src2, src2w)) { |
/* We know ALT_SIGN_EXT is set if it is an SLJIT_INT_OP on 64 bit systems. */ |
| 1288 |
compiler->imm = src2w & 0xffff; |
if (TEST_SL_IMM(src2, src2w)) { |
| 1289 |
return emit_op(compiler, SLJIT_SUB, inp_flags | ALT_FORM2, dst, dstw, src1, src1w, TMP_REG2, 0); |
compiler->imm = src2w & 0xffff; |
| 1290 |
|
return emit_op(compiler, SLJIT_SUB, inp_flags | ALT_FORM2, dst, dstw, src1, src1w, TMP_REG2, 0); |
| 1291 |
|
} |
| 1292 |
|
if (GET_FLAGS(op) == SLJIT_SET_E && TEST_SL_IMM(src1, src1w)) { |
| 1293 |
|
compiler->imm = src1w & 0xffff; |
| 1294 |
|
return emit_op(compiler, SLJIT_SUB, inp_flags | ALT_FORM2, dst, dstw, src2, src2w, TMP_REG2, 0); |
| 1295 |
|
} |
| 1296 |
} |
} |
| 1297 |
if (GET_FLAGS(op) == SLJIT_SET_E && TEST_SL_IMM(src1, src1w)) { |
if (!(op & (SLJIT_SET_E | SLJIT_SET_S))) { |
| 1298 |
compiler->imm = src1w & 0xffff; |
/* We know ALT_SIGN_EXT is set if it is an SLJIT_INT_OP on 64 bit systems. */ |
| 1299 |
return emit_op(compiler, SLJIT_SUB, inp_flags | ALT_FORM2, dst, dstw, src2, src2w, TMP_REG2, 0); |
if (TEST_UL_IMM(src2, src2w)) { |
| 1300 |
|
compiler->imm = src2w & 0xffff; |
| 1301 |
|
return emit_op(compiler, SLJIT_SUB, inp_flags | ALT_FORM3, dst, dstw, src1, src1w, TMP_REG2, 0); |
| 1302 |
|
} |
| 1303 |
|
return emit_op(compiler, SLJIT_SUB, inp_flags | ALT_FORM4, dst, dstw, src1, src1w, src2, src2w); |
| 1304 |
} |
} |
| 1305 |
} |
if ((src2 & SLJIT_IMM) && src2w >= 0 && src2w <= 0x7fff) { |
| 1306 |
if (dst == SLJIT_UNUSED && GET_FLAGS(op) == SLJIT_SET_U) { |
compiler->imm = src2w; |
| 1307 |
/* We know ALT_SIGN_EXT is set if it is an SLJIT_INT_OP on 64 bit systems. */ |
return emit_op(compiler, SLJIT_SUB, inp_flags | ALT_FORM2 | ALT_FORM3, dst, dstw, src1, src1w, TMP_REG2, 0); |
|
if (TEST_UL_IMM(src2, src2w)) { |
|
|
compiler->imm = src2w & 0xffff; |
|
|
return emit_op(compiler, SLJIT_SUB, inp_flags | ALT_FORM3, dst, dstw, src1, src1w, TMP_REG2, 0); |
|
| 1308 |
} |
} |
| 1309 |
return emit_op(compiler, SLJIT_SUB, inp_flags | ALT_FORM4, dst, dstw, src1, src1w, src2, src2w); |
return emit_op(compiler, SLJIT_SUB, inp_flags | ((op & SLJIT_SET_U) ? ALT_FORM4 : 0) | ((op & (SLJIT_SET_E | SLJIT_SET_S)) ? ALT_FORM5 : 0), dst, dstw, src1, src1w, src2, src2w); |
| 1310 |
} |
} |
| 1311 |
if (!(op & (SLJIT_SET_E | SLJIT_SET_S | SLJIT_SET_U | SLJIT_SET_O))) { |
if (!(op & (SLJIT_SET_E | SLJIT_SET_S | SLJIT_SET_U | SLJIT_SET_O))) { |
| 1312 |
if (TEST_SL_IMM(src2, -src2w)) { |
if (TEST_SL_IMM(src2, -src2w)) { |
| 1315 |
} |
} |
| 1316 |
} |
} |
| 1317 |
/* We know ALT_SIGN_EXT is set if it is an SLJIT_INT_OP on 64 bit systems. */ |
/* We know ALT_SIGN_EXT is set if it is an SLJIT_INT_OP on 64 bit systems. */ |
| 1318 |
return emit_op(compiler, SLJIT_SUB, inp_flags | (!(op & SLJIT_SET_U) ? 0 : ALT_FORM5), dst, dstw, src1, src1w, src2, src2w); |
return emit_op(compiler, SLJIT_SUB, inp_flags | (!(op & SLJIT_SET_U) ? 0 : ALT_FORM6), dst, dstw, src1, src1w, src2, src2w); |
| 1319 |
|
|
| 1320 |
case SLJIT_SUBC: |
case SLJIT_SUBC: |
| 1321 |
return emit_op(compiler, SLJIT_SUBC, inp_flags | (!(op & SLJIT_KEEP_FLAGS) ? 0 : ALT_FORM1), dst, dstw, src1, src1w, src2, src2w); |
return emit_op(compiler, SLJIT_SUBC, inp_flags | (!(op & SLJIT_KEEP_FLAGS) ? 0 : ALT_FORM1), dst, dstw, src1, src1w, src2, src2w); |