• Home
  • History
  • Annotate
  • Raw
  • Download
  • only in /asuswrt-rt-n18u-9.0.0.4.380.2695/release/src-rt/router/pcre-8.31/sljit/

Lines Matching refs:compiler

2  *    Stack-less Just-In-Time compiler
179 static int push_inst16(struct sljit_compiler *compiler, sljit_ins inst)
184 ptr = (sljit_uh*)ensure_buf(compiler, sizeof(sljit_uh));
187 compiler->size++;
191 static int push_inst32(struct sljit_compiler *compiler, sljit_ins inst)
193 sljit_uh *ptr = (sljit_uh*)ensure_buf(compiler, sizeof(sljit_ins));
197 compiler->size += 2;
201 static SLJIT_INLINE int emit_imm32_const(struct sljit_compiler *compiler, int dst, sljit_uw imm)
203 FAIL_IF(push_inst32(compiler, MOVW | RD4(dst) |
205 return push_inst32(compiler, MOVT | RD4(dst) |
346 SLJIT_API_FUNC_ATTRIBUTE void* sljit_generate_code(struct sljit_compiler *compiler)
360 check_sljit_generate_code(compiler);
361 reverse_buf(compiler);
363 code = (sljit_uh*)SLJIT_MALLOC_EXEC(compiler->size * sizeof(sljit_uh));
365 buf = compiler->buf;
369 label = compiler->labels;
370 jump = compiler->jumps;
371 const_ = compiler->consts;
412 SLJIT_ASSERT(code_ptr - code <= (int)compiler->size);
414 jump = compiler->jumps;
421 compiler->error = SLJIT_ERR_COMPILED;
422 compiler->executable_size = compiler->size * sizeof(sljit_uh);
477 static int load_immediate(struct sljit_compiler *compiler, int dst, sljit_uw imm)
484 return push_inst32(compiler, MOV_WI | RD4(dst) | tmp);
487 return push_inst32(compiler, MVN_WI | RD4(dst) | tmp);
491 FAIL_IF(push_inst32(compiler, MOVW | RD4(dst) |
496 return push_inst32(compiler, MOVT | RD4(dst) |
512 static int emit_op_imm(struct sljit_compiler *compiler, int flags, int dst, sljit_uw arg1, sljit_uw arg2)
523 FAIL_IF(load_immediate(compiler, TMP_REG1, arg1));
534 return load_immediate(compiler, dst, imm);
537 return load_immediate(compiler, dst, ~imm);
548 return push_inst16(compiler, ADDSI3 | IMM3(imm) | RD3(dst) | RN3(reg));
550 return push_inst16(compiler, SUBSI3 | IMM3(negated_imm) | RD3(dst) | RN3(reg));
553 return push_inst16(compiler, ADDSI8 | IMM8(imm) | RDN3(dst));
555 return push_inst16(compiler, SUBSI8 | IMM8(negated_imm) | RDN3(dst));
560 return push_inst32(compiler, ADDWI | RD4(dst) | RN4(reg) | IMM12(imm));
562 return push_inst32(compiler, SUBWI | RD4(dst) | RN4(reg) | IMM12(negated_imm));
566 return push_inst32(compiler, ADD_WI | (flags & SET_FLAGS) | RD4(dst) | RN4(reg) | imm);
571 return push_inst32(compiler, ADCI | (flags & SET_FLAGS) | RD4(dst) | RN4(reg) | imm);
578 return push_inst16(compiler, SUBSI3 | IMM3(imm) | RD3(dst) | RN3(reg));
580 return push_inst16(compiler, ADDSI3 | IMM3(negated_imm) | RD3(dst) | RN3(reg));
583 return push_inst16(compiler, SUBSI8 | IMM8(imm) | RDN3(dst));
585 return push_inst16(compiler, ADDSI8 | IMM8(negated_imm) | RDN3(dst));
588 return push_inst16(compiler, CMPI | IMM8(imm) | RDN3(reg));
592 return push_inst32(compiler, SUBWI | RD4(dst) | RN4(reg) | IMM12(imm));
594 return push_inst32(compiler, ADDWI | RD4(dst) | RN4(reg) | IMM12(negated_imm));
598 return push_inst32(compiler, SUB_WI | (flags & SET_FLAGS) | RD4(dst) | RN4(reg) | imm);
602 return push_inst16(compiler, RSBSI | RD3(dst) | RN3(reg));
605 return push_inst32(compiler, RSB_WI | (flags & SET_FLAGS) | RD4(dst) | RN4(reg) | imm);
612 return push_inst32(compiler, SBCI | (flags & SET_FLAGS) | RD4(dst) | RN4(reg) | imm);
621 return push_inst32(compiler, ANDI | (flags & SET_FLAGS) | RD4(dst) | RN4(reg) | imm);
624 return push_inst32(compiler, BICI | (flags & SET_FLAGS) | RD4(dst) | RN4(reg) | imm);
629 return push_inst32(compiler, ORRI | (flags & SET_FLAGS) | RD4(dst) | RN4(reg) | imm);
632 return push_inst32(compiler, ORNI | (flags & SET_FLAGS) | RD4(dst) | RN4(reg) | imm);
637 return push_inst32(compiler, EORI | (flags & SET_FLAGS) | RD4(dst) | RN4(reg) | imm);
644 return push_inst16(compiler, MOV | SET_REGS44(dst, reg));
646 return push_inst16(compiler, MOVS | RD3(dst) | RN3(reg));
647 return push_inst32(compiler, MOV_W | SET_FLAGS | RD4(dst) | RM4(reg));
650 return push_inst16(compiler, LSLSI | RD3(dst) | RN3(reg) | (imm << 6));
651 return push_inst32(compiler, LSL_WI | (flags & SET_FLAGS) | RD4(dst) | RM4(reg) | IMM5(imm));
659 return push_inst16(compiler, MOV | SET_REGS44(dst, reg));
661 return push_inst16(compiler, MOVS | RD3(dst) | RN3(reg));
662 return push_inst32(compiler, MOV_W | SET_FLAGS | RD4(dst) | RM4(reg));
665 return push_inst16(compiler, LSRSI | RD3(dst) | RN3(reg) | (imm << 6));
666 return push_inst32(compiler, LSR_WI | (flags & SET_FLAGS) | RD4(dst) | RM4(reg) | IMM5(imm));
674 return push_inst16(compiler, MOV | SET_REGS44(dst, reg));
676 return push_inst16(compiler, MOVS | RD3(dst) | RN3(reg));
677 return push_inst32(compiler, MOV_W | SET_FLAGS | RD4(dst) | RM4(reg));
680 return push_inst16(compiler, ASRSI | RD3(dst) | RN3(reg) | (imm << 6));
681 return push_inst32(compiler, ASR_WI | (flags & SET_FLAGS) | RD4(dst) | RM4(reg) | IMM5(imm));
690 FAIL_IF(load_immediate(compiler, TMP_REG2, arg2));
694 FAIL_IF(load_immediate(compiler, TMP_REG1, arg1));
708 return push_inst16(compiler, MOV | SET_REGS44(dst, arg2));
713 return push_inst16(compiler, UXTB | RD3(dst) | RN3(arg2));
714 return push_inst32(compiler, UXTB_W | RD4(dst) | RM4(arg2));
719 return push_inst16(compiler, SXTB | RD3(dst) | RN3(arg2));
720 return push_inst32(compiler, SXTB_W | RD4(dst) | RM4(arg2));
725 return push_inst16(compiler, UXTH | RD3(dst) | RN3(arg2));
726 return push_inst32(compiler, UXTH_W | RD4(dst) | RM4(arg2));
731 return push_inst16(compiler, SXTH | RD3(dst) | RN3(arg2));
732 return push_inst32(compiler, SXTH_W | RD4(dst) | RM4(arg2));
736 return push_inst16(compiler, MVNS | RD3(dst) | RN3(arg2));
737 return push_inst32(compiler, MVN_W | (flags & SET_FLAGS) | RD4(dst) | RM4(arg2));
740 FAIL_IF(push_inst32(compiler, CLZ | RN4(arg2) | RD4(dst) | RM4(arg2)));
743 return push_inst16(compiler, CMPI | RDN3(dst));
744 return push_inst32(compiler, ADD_WI | SET_FLAGS | RN4(dst) | RD4(dst));
749 return push_inst16(compiler, ADDS | RD3(dst) | RN3(arg1) | RM3(arg2));
751 return push_inst16(compiler, ADD | SET_REGS44(dst, arg2));
752 return push_inst32(compiler, ADD_W | (flags & SET_FLAGS) | RD4(dst) | RN4(arg1) | RM4(arg2));
755 return push_inst16(compiler, ADCS | RD3(dst) | RN3(arg2));
756 return push_inst32(compiler, ADC_W | (flags & SET_FLAGS) | RD4(dst) | RN4(arg1) | RM4(arg2));
759 return push_inst16(compiler, SUBS | RD3(dst) | RN3(arg1) | RM3(arg2));
760 return push_inst32(compiler, SUB_W | (flags & SET_FLAGS) | RD4(dst) | RN4(arg1) | RM4(arg2));
763 return push_inst16(compiler, SBCS | RD3(dst) | RN3(arg2));
764 return push_inst32(compiler, SBC_W | (flags & SET_FLAGS) | RD4(dst) | RN4(arg1) | RM4(arg2));
767 return push_inst32(compiler, MUL | RD4(dst) | RN4(arg1) | RM4(arg2));
769 FAIL_IF(push_inst32(compiler, SMULL | RT4(dst) | RD4(TMP_REG2) | RN4(arg1) | RM4(arg2)));
771 return push_inst32(compiler, CMP_W | RN4(TMP_REG2) | 0x70e0 | RM4(dst));
775 return push_inst16(compiler, ANDS | RD3(dst) | RN3(arg2));
777 return push_inst16(compiler, TST | RD3(arg1) | RN3(arg2));
779 return push_inst32(compiler, AND_W | (flags & SET_FLAGS) | RD4(dst) | RN4(arg1) | RM4(arg2));
782 return push_inst16(compiler, ORRS | RD3(dst) | RN3(arg2));
783 return push_inst32(compiler, ORR_W | (flags & SET_FLAGS) | RD4(dst) | RN4(arg1) | RM4(arg2));
786 return push_inst16(compiler, EORS | RD3(dst) | RN3(arg2));
787 return push_inst32(compiler, EOR_W | (flags & SET_FLAGS) | RD4(dst) | RN4(arg1) | RM4(arg2));
790 return push_inst16(compiler, LSLS | RD3(dst) | RN3(arg2));
791 return push_inst32(compiler, LSL_W | (flags & SET_FLAGS) | RD4(dst) | RN4(arg1) | RM4(arg2));
794 return push_inst16(compiler, LSRS | RD3(dst) | RN3(arg2));
795 return push_inst32(compiler, LSR_W | (flags & SET_FLAGS) | RD4(dst) | RN4(arg1) | RM4(arg2));
798 return push_inst16(compiler, ASRS | RD3(dst) | RN3(arg2));
799 return push_inst32(compiler, ASR_W | (flags & SET_FLAGS) | RD4(dst) | RN4(arg1) | RM4(arg2));
888 static int emit_set_delta(struct sljit_compiler *compiler, int dst, int reg, sljit_w value)
892 return push_inst32(compiler, ADDWI | RD4(dst) | RN4(reg) | IMM12(value));
895 return push_inst32(compiler, ADD_WI | RD4(dst) | RN4(reg) | value);
900 return push_inst32(compiler, SUBWI | RD4(dst) | RN4(reg) | IMM12(value));
903 return push_inst32(compiler, SUB_WI | RD4(dst) | RN4(reg) | value);
909 static int getput_arg_fast(struct sljit_compiler *compiler, int flags, int reg, int arg, sljit_w argw)
928 FAIL_IF(push_inst32(compiler, sljit_mem32[flags] | MEM_IMM8 | RT4(reg) | RN4(arg) | 0x100 | argw));
942 FAIL_IF(push_inst16(compiler, sljit_mem16[flags] | RD3(reg) | RN3(arg) | RM3(tmp)));
944 FAIL_IF(push_inst32(compiler, sljit_mem32[flags] | RT4(reg) | RN4(arg) | RM4(tmp) | (argw << 4)));
973 FAIL_IF(push_inst16(compiler, sljit_mem16_imm5[flags] | RD3(reg) | RN3(arg) | (argw << (6 - tmp))));
980 FAIL_IF(push_inst16(compiler, STR_SP | ((flags & STORE) ? 0 : 0x800) | RDN3(reg) | (argw >> 2)));
985 FAIL_IF(push_inst32(compiler, sljit_mem32[flags] | MEM_IMM12 | RT4(reg) | RN4(arg) | argw));
987 FAIL_IF(push_inst32(compiler, sljit_mem32[flags] | MEM_IMM8 | RT4(reg) | RN4(arg) | -argw));
1016 static int getput_arg(struct sljit_compiler *compiler, int flags, int reg, int arg, sljit_w argw, int next_arg, sljit_w next_argw)
1039 FAIL_IF(push_inst32(compiler, sljit_mem32[flags] | MEM_IMM12 | RT4(reg) | RN4(arg) | argw));
1040 return push_inst32(compiler, ADDWI | RD4(arg) | RN4(arg) | IMM12(argw));
1043 if (compiler->cache_arg == SLJIT_MEM) {
1044 if (argw == compiler->cache_argw) {
1048 else if (emit_set_delta(compiler, TMP_REG3, TMP_REG3, argw - compiler->cache_argw) != SLJIT_ERR_UNSUPPORTED) {
1049 FAIL_IF(compiler->error);
1050 compiler->cache_argw = argw;
1057 FAIL_IF(load_immediate(compiler, TMP_REG3, argw));
1058 compiler->cache_arg = SLJIT_MEM;
1059 compiler->cache_argw = argw;
1067 FAIL_IF(push_inst16(compiler, sljit_mem16[flags] | RD3(reg) | RN3(arg) | RM3(tmp)));
1068 return push_inst16(compiler, ADD | SET_REGS44(arg, tmp));
1070 FAIL_IF(push_inst32(compiler, sljit_mem32[flags] | RT4(reg) | RN4(arg) | RM4(tmp) | (argw << 4)));
1071 return push_inst32(compiler, ADD_W | RD4(arg) | RN4(arg) | RM4(tmp) | (argw << 6));
1077 if (compiler->cache_arg == arg) {
1078 if (!((argw - compiler->cache_argw) & ~0xfff))
1079 return push_inst32(compiler, sljit_mem32[flags] | MEM_IMM12 | RT4(reg) | RN4(TMP_REG3) | (argw - compiler->cache_argw));
1080 if (!((compiler->cache_argw - argw) & ~0xff))
1081 return push_inst32(compiler, sljit_mem32[flags] | MEM_IMM8 | RT4(reg) | RN4(TMP_REG3) | (compiler->cache_argw - argw));
1082 if (emit_set_delta(compiler, TMP_REG3, TMP_REG3, argw - compiler->cache_argw) != SLJIT_ERR_UNSUPPORTED) {
1083 FAIL_IF(compiler->error);
1084 return push_inst32(compiler, sljit_mem32[flags] | MEM_IMM12 | RT4(reg) | RN4(TMP_REG3) | 0);
1090 if (arg && compiler->cache_arg == SLJIT_MEM && compiler->cache_argw == argw)
1091 return push_inst32(compiler, sljit_mem32[flags] | RT4(reg) | RN4(arg) | RM4(TMP_REG3));
1093 compiler->cache_argw = argw;
1094 if (next_arg && emit_set_delta(compiler, TMP_REG3, arg, argw) != SLJIT_ERR_UNSUPPORTED) {
1095 FAIL_IF(compiler->error);
1096 compiler->cache_arg = SLJIT_MEM | arg;
1100 FAIL_IF(load_immediate(compiler, TMP_REG3, argw));
1101 compiler->cache_arg = SLJIT_MEM;
1104 FAIL_IF(push_inst16(compiler, ADD | SET_REGS44(TMP_REG3, arg)));
1105 compiler->cache_arg = SLJIT_MEM | arg;
1111 return push_inst32(compiler, sljit_mem32[flags] | RT4(reg) | RN4(arg) | RM4(TMP_REG3));
1112 return push_inst32(compiler, sljit_mem32[flags] | MEM_IMM12 | RT4(reg) | RN4(TMP_REG3) | 0);
1115 static SLJIT_INLINE int emit_op_mem(struct sljit_compiler *compiler, int flags, int reg, int arg, sljit_w argw)
1117 if (getput_arg_fast(compiler, flags, reg, arg, argw))
1118 return compiler->error;
1119 compiler->cache_arg = 0;
1120 compiler->cache_argw = 0;
1121 return getput_arg(compiler, flags, reg, arg, argw, 0, 0);
1124 SLJIT_API_FUNC_ATTRIBUTE int sljit_emit_enter(struct sljit_compiler *compiler, int args, int temporaries, int saveds, int local_size)
1130 check_sljit_emit_enter(compiler, args, temporaries, saveds, local_size);
1132 compiler->temporaries = temporaries;
1133 compiler->saveds = saveds;
1135 compiler->logical_local_size = local_size;
1152 ? push_inst32(compiler, PUSH_W | (1 << 14) | push)
1153 : push_inst16(compiler, PUSH | push));
1160 compiler->local_size = local_size;
1163 FAIL_IF(push_inst16(compiler, SUB_SP | (local_size >> 2)));
1165 FAIL_IF(emit_op_imm(compiler, SLJIT_SUB | ARG2_IMM, SLJIT_LOCALS_REG, SLJIT_LOCALS_REG, local_size));
1169 FAIL_IF(push_inst16(compiler, MOV | SET_REGS44(SLJIT_SAVED_REG1, SLJIT_TEMPORARY_REG1)));
1171 FAIL_IF(push_inst16(compiler, MOV | SET_REGS44(SLJIT_SAVED_REG2, SLJIT_TEMPORARY_REG2)));
1173 FAIL_IF(push_inst16(compiler, MOV | SET_REGS44(SLJIT_SAVED_REG3, SLJIT_TEMPORARY_REG3)));
1178 SLJIT_API_FUNC_ATTRIBUTE void sljit_set_context(struct sljit_compiler *compiler, int args, int temporaries, int saveds, int local_size)
1183 check_sljit_set_context(compiler, args, temporaries, saveds, local_size);
1185 compiler->temporaries = temporaries;
1186 compiler->saveds = saveds;
1188 compiler->logical_local_size = local_size;
1195 compiler->local_size = local_size;
1198 SLJIT_API_FUNC_ATTRIBUTE int sljit_emit_return(struct sljit_compiler *compiler, int op, int src, sljit_w srcw)
1203 check_sljit_emit_return(compiler, op, src, srcw);
1206 FAIL_IF(emit_mov_before_return(compiler, op, src, srcw));
1208 if (compiler->local_size > 0) {
1209 if (compiler->local_size <= (127 << 2))
1210 FAIL_IF(push_inst16(compiler, ADD_SP | (compiler->local_size >> 2)));
1212 FAIL_IF(emit_op_imm(compiler, SLJIT_ADD | ARG2_IMM, SLJIT_LOCALS_REG, SLJIT_LOCALS_REG, compiler->local_size));
1216 if (compiler->saveds >= 5)
1218 if (compiler->saveds >= 4)
1220 if (compiler->saveds >= 3)
1222 if (compiler->saveds >= 2)
1224 if (compiler->saveds >= 1)
1226 if (compiler->temporaries >= 5)
1228 return compiler->saveds >= 3
1229 ? push_inst32(compiler, POP_W | (1 << 15) | pop)
1230 : push_inst16(compiler, POP | pop);
1252 SLJIT_API_FUNC_ATTRIBUTE int sljit_emit_op0(struct sljit_compiler *compiler, int op)
1255 check_sljit_emit_op0(compiler, op);
1260 push_inst16(compiler, BKPT);
1263 push_inst16(compiler, NOP);
1267 return push_inst32(compiler, (op == SLJIT_UMUL ? UMULL : SMULL)
1274 if (compiler->temporaries >= 4) {
1275 FAIL_IF(push_inst32(compiler, 0xf84d2d04 /* str r2, [sp, #-4]! */));
1276 FAIL_IF(push_inst32(compiler, 0xf84dcd04 /* str ip, [sp, #-4]! */));
1277 } else if (compiler->temporaries >= 3)
1278 FAIL_IF(push_inst32(compiler, 0xf84d2d08 /* str r2, [sp, #-8]! */));
1280 FAIL_IF(sljit_emit_ijump(compiler, SLJIT_FAST_CALL, SLJIT_IMM,
1285 if (compiler->temporaries >= 4) {
1286 FAIL_IF(push_inst32(compiler, 0xf85dcb04 /* ldr ip, [sp], #4 */));
1287 return push_inst32(compiler, 0xf85d2b04 /* ldr r2, [sp], #4 */);
1288 } else if (compiler->temporaries >= 3)
1289 return push_inst32(compiler, 0xf85d2b08 /* ldr r2, [sp], #8 */);
1296 SLJIT_API_FUNC_ATTRIBUTE int sljit_emit_op1(struct sljit_compiler *compiler, int op,
1303 check_sljit_emit_op1(compiler, op, dst, dstw, src, srcw);
1307 compiler->cache_arg = 0;
1308 compiler->cache_argw = 0;
1372 FAIL_IF(emit_op_imm(compiler, SLJIT_MOV | ARG2_IMM, dst_r, TMP_REG1, srcw));
1374 if (getput_arg_fast(compiler, flags, dst_r, src, srcw))
1375 FAIL_IF(compiler->error);
1377 FAIL_IF(getput_arg(compiler, flags, dst_r, src, srcw, dst, dstw));
1380 return emit_op_imm(compiler, op_type, dst_r, TMP_REG1, src);
1385 if (getput_arg_fast(compiler, flags | STORE, dst_r, dst, dstw))
1386 return compiler->error;
1388 return getput_arg(compiler, flags | STORE, dst_r, dst, dstw, 0, 0);
1395 compiler->skip_checks = 1;
1397 return sljit_emit_op2(compiler, GET_FLAGS(op) | SLJIT_SUB, dst, dstw, SLJIT_IMM, 0, src, srcw);
1402 if (getput_arg_fast(compiler, WORD_SIZE, TMP_REG2, src, srcw))
1403 FAIL_IF(compiler->error);
1405 FAIL_IF(getput_arg(compiler, WORD_SIZE, TMP_REG2, src, srcw, dst, dstw));
1414 emit_op_imm(compiler, flags | op_type, dst_r, TMP_REG1, srcw);
1417 if (getput_arg_fast(compiler, flags | STORE, dst_r, dst, dstw))
1418 return compiler->error;
1420 return getput_arg(compiler, flags | STORE, dst_r, dst, dstw, 0, 0);
1425 SLJIT_API_FUNC_ATTRIBUTE int sljit_emit_op2(struct sljit_compiler *compiler, int op,
1433 check_sljit_emit_op2(compiler, op, dst, dstw, src1, src1w, src2, src2w);
1438 compiler->cache_arg = 0;
1439 compiler->cache_argw = 0;
1444 if ((dst & SLJIT_MEM) && !getput_arg_fast(compiler, WORD_SIZE | STORE | ARG_TEST, TMP_REG1, dst, dstw))
1448 if (getput_arg_fast(compiler, WORD_SIZE, TMP_REG1, src1, src1w))
1449 FAIL_IF(compiler->error);
1454 if (getput_arg_fast(compiler, WORD_SIZE, TMP_REG2, src2, src2w))
1455 FAIL_IF(compiler->error);
1462 FAIL_IF(getput_arg(compiler, WORD_SIZE, TMP_REG2, src2, src2w, src1, src1w));
1463 FAIL_IF(getput_arg(compiler, WORD_SIZE, TMP_REG1, src1, src1w, dst, dstw));
1466 FAIL_IF(getput_arg(compiler, WORD_SIZE, TMP_REG1, src1, src1w, src2, src2w));
1467 FAIL_IF(getput_arg(compiler, WORD_SIZE, TMP_REG2, src2, src2w, dst, dstw));
1471 FAIL_IF(getput_arg(compiler, WORD_SIZE, TMP_REG1, src1, src1w, dst, dstw));
1473 FAIL_IF(getput_arg(compiler, WORD_SIZE, TMP_REG2, src2, src2w, dst, dstw));
1495 emit_op_imm(compiler, flags | GET_OPCODE(op), dst_r, src1w, src2w);
1499 getput_arg_fast(compiler, WORD_SIZE | STORE, dst_r, dst, dstw);
1500 return compiler->error;
1502 return getput_arg(compiler, WORD_SIZE | STORE, TMP_REG1, dst, dstw, 0, 0);
1513 SLJIT_API_FUNC_ATTRIBUTE int sljit_emit_op_custom(struct sljit_compiler *compiler,
1517 check_sljit_emit_op_custom(compiler, instruction, size);
1521 return push_inst16(compiler, *(sljit_uh*)instruction);
1522 return push_inst32(compiler, *(sljit_ins*)instruction);
1534 static int emit_fop_mem(struct sljit_compiler *compiler, int flags, int reg, int arg, sljit_w argw)
1543 FAIL_IF(push_inst32(compiler, ADD_W | RD4(TMP_REG2) | RN4(arg & 0xf) | RM4((arg & 0xf0) >> 4) | ((argw & 0x3) << 6)));
1550 return push_inst32(compiler, inst | 0x800000 | RN4(arg & 0xf) | DD4(reg) | (argw >> 2));
1552 return push_inst32(compiler, inst | RN4(arg & 0xf) | DD4(reg) | (-argw >> 2));
1556 if (compiler->cache_arg == arg) {
1557 tmp = argw - compiler->cache_argw;
1559 return push_inst32(compiler, inst | 0x800000 | RN4(TMP_REG3) | DD4(reg) | (tmp >> 2));
1561 return push_inst32(compiler, inst | RN4(TMP_REG3) | DD4(reg) | (-tmp >> 2));
1562 if (emit_set_delta(compiler, TMP_REG3, TMP_REG3, tmp) != SLJIT_ERR_UNSUPPORTED) {
1563 FAIL_IF(compiler->error);
1564 compiler->cache_argw = argw;
1565 return push_inst32(compiler, inst | 0x800000 | RN4(TMP_REG3) | DD4(reg));
1569 compiler->cache_arg = arg;
1570 compiler->cache_argw = argw;
1573 FAIL_IF(load_immediate(compiler, TMP_REG3, argw));
1574 else if (emit_set_delta(compiler, TMP_REG3, arg & 0xf, argw) != SLJIT_ERR_UNSUPPORTED)
1575 FAIL_IF(compiler->error);
1577 FAIL_IF(load_immediate(compiler, TMP_REG3, argw));
1579 FAIL_IF(push_inst16(compiler, ADD | SET_REGS44(TMP_REG3, (arg & 0xf))));
1581 return push_inst32(compiler, inst | 0x800000 | RN4(TMP_REG3) | DD4(reg));
1584 SLJIT_API_FUNC_ATTRIBUTE int sljit_emit_fop1(struct sljit_compiler *compiler, int op,
1591 check_sljit_emit_fop1(compiler, op, dst, dstw, src, srcw);
1593 compiler->cache_arg = 0;
1594 compiler->cache_argw = 0;
1598 emit_fop_mem(compiler, 0, TMP_FREG1, dst, dstw);
1602 emit_fop_mem(compiler, 0, TMP_FREG2, src, srcw);
1605 FAIL_IF(push_inst32(compiler, VCMP_F64 | DD4(dst) | DM4(src)));
1606 return push_inst32(compiler, VMRS);
1611 emit_fop_mem(compiler, 0, dst_r, src, srcw);
1618 FAIL_IF(push_inst32(compiler, VMOV_F64 | DD4(dst_r) | DM4(src)));
1621 FAIL_IF(push_inst32(compiler, VNEG_F64 | DD4(dst_r) | DM4(src)));
1624 FAIL_IF(push_inst32(compiler, VABS_F64 | DD4(dst_r) | DM4(src)));
1629 return emit_fop_mem(compiler, STORE, TMP_FREG1, dst, dstw);
1633 SLJIT_API_FUNC_ATTRIBUTE int sljit_emit_fop2(struct sljit_compiler *compiler, int op,
1641 check_sljit_emit_fop2(compiler, op, dst, dstw, src1, src1w, src2, src2w);
1643 compiler->cache_arg = 0;
1644 compiler->cache_argw = 0;
1648 emit_fop_mem(compiler, 0, TMP_FREG1, src1, src1w);
1652 emit_fop_mem(compiler, 0, TMP_FREG2, src2, src2w);
1658 FAIL_IF(push_inst32(compiler, VADD_F64 | DD4(dst_r) | DN4(src1) | DM4(src2)));
1661 FAIL_IF(push_inst32(compiler, VSUB_F64 | DD4(dst_r) | DN4(src1) | DM4(src2)));
1664 FAIL_IF(push_inst32(compiler, VMUL_F64 | DD4(dst_r) | DN4(src1) | DM4(src2)));
1667 FAIL_IF(push_inst32(compiler, VDIV_F64 | DD4(dst_r) | DN4(src1) | DM4(src2)));
1672 return emit_fop_mem(compiler, STORE, TMP_FREG1, dst, dstw);
1680 SLJIT_API_FUNC_ATTRIBUTE int sljit_emit_fast_enter(struct sljit_compiler *compiler, int dst, sljit_w dstw)
1683 check_sljit_emit_fast_enter(compiler, dst, dstw);
1687 return push_inst16(compiler, MOV | SET_REGS44(dst, TMP_REG3));
1689 if (getput_arg_fast(compiler, WORD_SIZE | STORE, TMP_REG3, dst, dstw))
1690 return compiler->error;
1691 FAIL_IF(push_inst16(compiler, MOV | SET_REGS44(TMP_REG2, TMP_REG3)));
1692 compiler->cache_arg = 0;
1693 compiler->cache_argw = 0;
1694 return getput_arg(compiler, WORD_SIZE | STORE, TMP_REG2, dst, dstw, 0, 0);
1700 SLJIT_API_FUNC_ATTRIBUTE int sljit_emit_fast_return(struct sljit_compiler *compiler, int src, sljit_w srcw)
1703 check_sljit_emit_fast_return(compiler, src, srcw);
1707 FAIL_IF(push_inst16(compiler, MOV | SET_REGS44(TMP_REG3, src)));
1709 if (getput_arg_fast(compiler, WORD_SIZE, TMP_REG3, src, srcw))
1710 FAIL_IF(compiler->error);
1712 compiler->cache_arg = 0;
1713 compiler->cache_argw = 0;
1714 FAIL_IF(getput_arg(compiler, WORD_SIZE, TMP_REG2, src, srcw, 0, 0));
1715 FAIL_IF(push_inst16(compiler, MOV | SET_REGS44(TMP_REG3, TMP_REG2)));
1719 FAIL_IF(load_immediate(compiler, TMP_REG3, srcw));
1720 return push_inst16(compiler, BLX | RN3(TMP_REG3));
1781 SLJIT_API_FUNC_ATTRIBUTE struct sljit_label* sljit_emit_label(struct sljit_compiler *compiler)
1786 check_sljit_emit_label(compiler);
1788 if (compiler->last_label && compiler->last_label->size == compiler->size)
1789 return compiler->last_label;
1791 label = (struct sljit_label*)ensure_abuf(compiler, sizeof(struct sljit_label));
1793 set_label(label, compiler);
1797 SLJIT_API_FUNC_ATTRIBUTE struct sljit_jump* sljit_emit_jump(struct sljit_compiler *compiler, int type)
1803 check_sljit_emit_jump(compiler, type);
1805 jump = (struct sljit_jump*)ensure_abuf(compiler, sizeof(struct sljit_jump));
1807 set_jump(jump, compiler, type & SLJIT_REWRITABLE_JUMP);
1811 PTR_FAIL_IF(emit_imm32_const(compiler, TMP_REG1, 0));
1816 PTR_FAIL_IF(push_inst16(compiler, IT | (cc << 4) | 0x8));
1819 jump->addr = compiler->size;
1821 PTR_FAIL_IF(push_inst16(compiler, BX | RN3(TMP_REG1)));
1824 PTR_FAIL_IF(push_inst16(compiler, BLX | RN3(TMP_REG1)));
1830 SLJIT_API_FUNC_ATTRIBUTE int sljit_emit_ijump(struct sljit_compiler *compiler, int type, int src, sljit_w srcw)
1835 check_sljit_emit_ijump(compiler, type, src, srcw);
1840 jump = (struct sljit_jump*)ensure_abuf(compiler, sizeof(struct sljit_jump));
1842 set_jump(jump, compiler, JUMP_ADDR | ((type >= SLJIT_FAST_CALL) ? IS_BL : 0));
1845 FAIL_IF(emit_imm32_const(compiler, TMP_REG1, 0));
1846 jump->addr = compiler->size;
1847 FAIL_IF(push_inst16(compiler, (type <= SLJIT_JUMP ? BX : BLX) | RN3(TMP_REG1)));
1851 return push_inst16(compiler, (type <= SLJIT_JUMP ? BX : BLX) | RN3(src));
1853 FAIL_IF(emit_op_mem(compiler, WORD_SIZE, type <= SLJIT_JUMP ? TMP_PC : TMP_REG1, src, srcw));
1855 return push_inst16(compiler, BLX | RN3(TMP_REG1));
1860 SLJIT_API_FUNC_ATTRIBUTE int sljit_emit_cond_value(struct sljit_compiler *compiler, int op, int dst, sljit_w dstw, int type)
1866 check_sljit_emit_cond_value(compiler, op, dst, dstw, type);
1874 FAIL_IF(push_inst16(compiler, IT | (cc << 4) | 0x8));
1875 FAIL_IF(push_inst32(compiler, ORRI | RN4(dst) | RD4(dst) | 0x1));
1878 return push_inst16(compiler, ORRS | RD3(dst) | RN3(dst));
1879 return push_inst32(compiler, ORR_W | SET_FLAGS | RD4(TMP_REG1) | RN4(dst) | RM4(dst));
1888 FAIL_IF(push_inst16(compiler, IT | (cc << 4) | (((cc & 0x1) ^ 0x1) << 3) | 0x4));
1889 FAIL_IF(push_inst16(compiler, MOVSI | 0x1 | RDN3(dst_r)));
1890 FAIL_IF(push_inst16(compiler, MOVSI | 0x0 | RDN3(dst_r)));
1895 compiler->skip_checks = 1;
1897 return sljit_emit_op2(compiler, op, dst, dstw, dst, dstw, TMP_REG2, 0);
1900 return emit_op_mem(compiler, WORD_SIZE | STORE, TMP_REG2, dst, dstw);
1902 return push_inst16(compiler, MOV | SET_REGS44(dst, TMP_REG2));
1908 SLJIT_API_FUNC_ATTRIBUTE struct sljit_const* sljit_emit_const(struct sljit_compiler *compiler, int dst, sljit_w dstw, sljit_w init_value)
1914 check_sljit_emit_const(compiler, dst, dstw, init_value);
1917 const_ = (struct sljit_const*)ensure_abuf(compiler, sizeof(struct sljit_const));
1919 set_const(const_, compiler);
1922 PTR_FAIL_IF(emit_imm32_const(compiler, dst_r, init_value));
1925 PTR_FAIL_IF(emit_op_mem(compiler, WORD_SIZE | STORE, dst_r, dst, dstw));