Lines Matching refs:compiler

127 static sljit_si push_inst(struct sljit_compiler *compiler, sljit_ins ins)  in push_inst()  argument
129 sljit_ins *ptr = (sljit_ins*)ensure_buf(compiler, sizeof(sljit_ins)); in push_inst()
132 compiler->size++; in push_inst()
136 static SLJIT_INLINE sljit_si emit_imm64_const(struct sljit_compiler *compiler, sljit_si dst, sljit_… in emit_imm64_const() argument
138 FAIL_IF(push_inst(compiler, MOVZ | RD(dst) | ((imm & 0xffff) << 5))); in emit_imm64_const()
139 FAIL_IF(push_inst(compiler, MOVK | RD(dst) | (((imm >> 16) & 0xffff) << 5) | (1 << 21))); in emit_imm64_const()
140 FAIL_IF(push_inst(compiler, MOVK | RD(dst) | (((imm >> 32) & 0xffff) << 5) | (2 << 21))); in emit_imm64_const()
141 return push_inst(compiler, MOVK | RD(dst) | ((imm >> 48) << 5) | (3 << 21)); in emit_imm64_const()
206 SLJIT_API_FUNC_ATTRIBUTE void* sljit_generate_code(struct sljit_compiler *compiler) in sljit_generate_code() argument
222 CHECK_PTR(check_sljit_generate_code(compiler)); in sljit_generate_code()
223 reverse_buf(compiler); in sljit_generate_code()
225 code = (sljit_ins*)SLJIT_MALLOC_EXEC(compiler->size * sizeof(sljit_ins)); in sljit_generate_code()
227 buf = compiler->buf; in sljit_generate_code()
231 label = compiler->labels; in sljit_generate_code()
232 jump = compiler->jumps; in sljit_generate_code()
233 const_ = compiler->consts; in sljit_generate_code()
274 SLJIT_ASSERT(code_ptr - code <= (sljit_sw)compiler->size); in sljit_generate_code()
276 jump = compiler->jumps; in sljit_generate_code()
310 compiler->error = SLJIT_ERR_COMPILED; in sljit_generate_code()
311 compiler->executable_size = (code_ptr - code) * sizeof(sljit_ins); in sljit_generate_code()
413 static sljit_si load_immediate(struct sljit_compiler *compiler, sljit_si dst, sljit_sw simm) in load_immediate() argument
420 return push_inst(compiler, MOVZ | RD(dst) | (imm << 5)); in load_immediate()
423 return push_inst(compiler, MOVN | RD(dst) | ((~imm & 0xffff) << 5)); in load_immediate()
427 return push_inst(compiler, (MOVN ^ W_OP) | RD(dst) | ((~imm & 0xffff) << 5)); in load_immediate()
429 …return push_inst(compiler, (MOVN ^ W_OP) | RD(dst) | ((~imm & 0xffff0000l) >> (16 - 5)) | (1 << 21… in load_immediate()
432 return push_inst(compiler, (ORRI ^ W_OP) | RD(dst) | RN(TMP_ZERO) | bitmask); in load_immediate()
437 return push_inst(compiler, ORRI | RD(dst) | RN(TMP_ZERO) | bitmask); in load_immediate()
441 FAIL_IF(push_inst(compiler, MOVZ | RD(dst) | ((imm & 0xffff) << 5))); in load_immediate()
442 return push_inst(compiler, MOVK | RD(dst) | ((imm & 0xffff0000l) >> (16 - 5)) | (1 << 21)); in load_immediate()
446 FAIL_IF(push_inst(compiler, MOVN | RD(dst) | ((~imm & 0xffff) << 5))); in load_immediate()
447 return push_inst(compiler, MOVK | RD(dst) | ((imm & 0xffff0000l) >> (16 - 5)) | (1 << 21)); in load_immediate()
474 FAIL_IF(push_inst(compiler, MOVN | RD(dst) | ((simm & 0xffff) << 5) | (i << 21))); in load_immediate()
477 FAIL_IF(push_inst(compiler, MOVK | RD(dst) | ((~simm & 0xffff) << 5) | (i << 21))); in load_immediate()
490 FAIL_IF(push_inst(compiler, MOVZ | RD(dst) | ((simm & 0xffff) << 5) | (i << 21))); in load_immediate()
493 FAIL_IF(push_inst(compiler, MOVK | RD(dst) | ((simm & 0xffff) << 5) | (i << 21))); in load_immediate()
515 static sljit_si emit_op_imm(struct sljit_compiler *compiler, sljit_si flags, sljit_si dst, sljit_sw… in emit_op_imm() argument
532 FAIL_IF(load_immediate(compiler, TMP_REG1, arg1)); in emit_op_imm()
552 return load_immediate(compiler, dst, imm); in emit_op_imm()
555 FAIL_IF(load_immediate(compiler, dst, (flags & INT_OP) ? (~imm & 0xffffffff) : ~imm)); in emit_op_imm()
565 return push_inst(compiler, ((op == SLJIT_ADD ? ADDI : SUBI) ^ inv_bits) | RD(dst) | RN(reg)); in emit_op_imm()
569 return push_inst(compiler, (ADDI ^ inv_bits) | RD(dst) | RN(reg) | (imm << 10)); in emit_op_imm()
574 return push_inst(compiler, (SUBI ^ inv_bits) | RD(dst) | RN(reg) | (nimm << 10)); in emit_op_imm()
578 …return push_inst(compiler, (ADDI ^ inv_bits) | RD(dst) | RN(reg) | ((imm >> 12) << 10) | (1 << 22)… in emit_op_imm()
582 …return push_inst(compiler, (SUBI ^ inv_bits) | RD(dst) | RN(reg) | ((nimm >> 12) << 10) | (1 << 22… in emit_op_imm()
585 …FAIL_IF(push_inst(compiler, (ADDI ^ inv_bits) | RD(dst) | RN(reg) | ((imm >> 12) << 10) | (1 << 22… in emit_op_imm()
586 return push_inst(compiler, (ADDI ^ inv_bits) | RD(dst) | RN(dst) | ((imm & 0xfff) << 10)); in emit_op_imm()
589 …FAIL_IF(push_inst(compiler, (SUBI ^ inv_bits) | RD(dst) | RN(reg) | ((nimm >> 12) << 10) | (1 << 2… in emit_op_imm()
590 return push_inst(compiler, (SUBI ^ inv_bits) | RD(dst) | RN(dst) | ((nimm & 0xfff) << 10)); in emit_op_imm()
598 return push_inst(compiler, (ANDI ^ inv_bits) | RD(dst) | RN(reg) | inst_bits); in emit_op_imm()
608 FAIL_IF(push_inst(compiler, (inst_bits ^ inv_bits) | RD(dst) | RN(reg))); in emit_op_imm()
615 …FAIL_IF(push_inst(compiler, (UBFM ^ inv_bits) | RD(dst) | RN(arg1) | ((-imm & 0x1f) << 16) | ((31 … in emit_op_imm()
619 …FAIL_IF(push_inst(compiler, (UBFM ^ inv_bits) | RD(dst) | RN(arg1) | (1 << 22) | ((-imm & 0x3f) <<… in emit_op_imm()
630 FAIL_IF(push_inst(compiler, (UBFM ^ inv_bits) | RD(dst) | RN(arg1) | (imm << 16) | (31 << 10))); in emit_op_imm()
634 …FAIL_IF(push_inst(compiler, (UBFM ^ inv_bits) | RD(dst) | RN(arg1) | (1 << 22) | (imm << 16) | (63… in emit_op_imm()
646 FAIL_IF(load_immediate(compiler, TMP_REG2, arg2)); in emit_op_imm()
654 FAIL_IF(load_immediate(compiler, TMP_REG1, arg1)); in emit_op_imm()
669 return push_inst(compiler, ORR | RD(dst) | RN(TMP_ZERO) | RM(arg2)); in emit_op_imm()
673 return push_inst(compiler, (UBFM ^ (1 << 31)) | RD(dst) | RN(arg2) | (7 << 10)); in emit_op_imm()
679 return push_inst(compiler, (SBFM ^ inv_bits) | RD(dst) | RN(arg2) | (7 << 10)); in emit_op_imm()
683 return push_inst(compiler, (UBFM ^ (1 << 31)) | RD(dst) | RN(arg2) | (15 << 10)); in emit_op_imm()
689 return push_inst(compiler, (SBFM ^ inv_bits) | RD(dst) | RN(arg2) | (15 << 10)); in emit_op_imm()
695 return push_inst(compiler, (ORR ^ (1 << 31)) | RD(dst) | RN(TMP_ZERO) | RM(arg2)); in emit_op_imm()
701 return push_inst(compiler, SBFM | (1 << 22) | RD(dst) | RN(arg2) | (31 << 10)); in emit_op_imm()
704 FAIL_IF(push_inst(compiler, (ORN ^ inv_bits) | RD(dst) | RN(TMP_ZERO) | RM(arg2))); in emit_op_imm()
710 return push_inst(compiler, (SUB ^ inv_bits) | RD(dst) | RN(TMP_ZERO) | RM(arg2)); in emit_op_imm()
713 FAIL_IF(push_inst(compiler, (CLZ ^ inv_bits) | RD(dst) | RN(arg2))); in emit_op_imm()
717 return push_inst(compiler, (ADD ^ inv_bits) | RD(dst) | RN(arg1) | RM(arg2)); in emit_op_imm()
720 return push_inst(compiler, (ADC ^ inv_bits) | RD(dst) | RN(arg1) | RM(arg2)); in emit_op_imm()
723 return push_inst(compiler, (SUB ^ inv_bits) | RD(dst) | RN(arg1) | RM(arg2)); in emit_op_imm()
726 return push_inst(compiler, (SBC ^ inv_bits) | RD(dst) | RN(arg1) | RM(arg2)); in emit_op_imm()
729 return push_inst(compiler, (MADD ^ inv_bits) | RD(dst) | RN(arg1) | RM(arg2) | RT2(TMP_ZERO)); in emit_op_imm()
731 FAIL_IF(push_inst(compiler, SMADDL | RD(dst) | RN(arg1) | RM(arg2) | (31 << 10))); in emit_op_imm()
732 FAIL_IF(push_inst(compiler, ADD | RD(TMP_LR) | RN(TMP_ZERO) | RM(dst) | (2 << 22) | (31 << 10))); in emit_op_imm()
733 return push_inst(compiler, SUBS | RD(TMP_ZERO) | RN(TMP_LR) | RM(dst) | (2 << 22) | (63 << 10)); in emit_op_imm()
735 FAIL_IF(push_inst(compiler, SMULH | RD(TMP_LR) | RN(arg1) | RM(arg2))); in emit_op_imm()
736 FAIL_IF(push_inst(compiler, MADD | RD(dst) | RN(arg1) | RM(arg2) | RT2(TMP_ZERO))); in emit_op_imm()
737 return push_inst(compiler, SUBS | RD(TMP_ZERO) | RN(TMP_LR) | RM(dst) | (2 << 22) | (63 << 10)); in emit_op_imm()
740 return push_inst(compiler, (AND ^ inv_bits) | RD(dst) | RN(arg1) | RM(arg2)); in emit_op_imm()
742 FAIL_IF(push_inst(compiler, (ORR ^ inv_bits) | RD(dst) | RN(arg1) | RM(arg2))); in emit_op_imm()
745 FAIL_IF(push_inst(compiler, (EOR ^ inv_bits) | RD(dst) | RN(arg1) | RM(arg2))); in emit_op_imm()
748 FAIL_IF(push_inst(compiler, (LSLV ^ inv_bits) | RD(dst) | RN(arg1) | RM(arg2))); in emit_op_imm()
751 FAIL_IF(push_inst(compiler, (LSRV ^ inv_bits) | RD(dst) | RN(arg1) | RM(arg2))); in emit_op_imm()
754 FAIL_IF(push_inst(compiler, (ASRV ^ inv_bits) | RD(dst) | RN(arg1) | RM(arg2))); in emit_op_imm()
763 return push_inst(compiler, (SUBS ^ inv_bits) | RD(TMP_ZERO) | RN(dst) | RM(TMP_ZERO)); in emit_op_imm()
809 static sljit_si emit_set_delta(struct sljit_compiler *compiler, sljit_si dst, sljit_si reg, sljit_s… in emit_set_delta() argument
813 return push_inst(compiler, ADDI | RD(dst) | RN(reg) | (value << 10)); in emit_set_delta()
815 return push_inst(compiler, ADDI | (1 << 22) | RD(dst) | RN(reg) | (value >> 2)); in emit_set_delta()
820 return push_inst(compiler, SUBI | RD(dst) | RN(reg) | (value << 10)); in emit_set_delta()
822 return push_inst(compiler, SUBI | (1 << 22) | RD(dst) | RN(reg) | (value >> 2)); in emit_set_delta()
828 static sljit_si getput_arg_fast(struct sljit_compiler *compiler, sljit_si flags, sljit_si reg, slji… in getput_arg_fast() argument
841 FAIL_IF(push_inst(compiler, sljit_mem_pre_simm[flags & 0x3] in getput_arg_fast()
856 FAIL_IF(push_inst(compiler, sljit_mem_reg[flags & 0x3] | (shift << 30) | RT(reg) in getput_arg_fast()
866 FAIL_IF(push_inst(compiler, sljit_mem_imm[flags & 0x3] | (shift << 30) in getput_arg_fast()
877 FAIL_IF(push_inst(compiler, sljit_mem_simm[flags & 0x3] | (shift << 30) in getput_arg_fast()
909 static sljit_si getput_arg(struct sljit_compiler *compiler, sljit_si flags, sljit_si reg, in getput_arg() argument
931 FAIL_IF(push_inst(compiler, ADDI | RD(other_r) | RN(other_r) | ((argw & 0xfff) << 10))); in getput_arg()
933 … FAIL_IF(push_inst(compiler, ADDI | (1 << 22) | RD(other_r) | RN(other_r) | ((argw >> 12) << 10))); in getput_arg()
934 return push_inst(compiler, sljit_mem_imm[flags & 0x3] | (shift << 30) | RT(reg) | RN(other_r)); in getput_arg()
939 FAIL_IF(push_inst(compiler, SUBI | RD(other_r) | RN(other_r) | ((argw & 0xfff) << 10))); in getput_arg()
941 … FAIL_IF(push_inst(compiler, SUBI | (1 << 22) | RD(other_r) | RN(other_r) | ((argw >> 12) << 10))); in getput_arg()
942 return push_inst(compiler, sljit_mem_imm[flags & 0x3] | (shift << 30) | RT(reg) | RN(other_r)); in getput_arg()
945 if (compiler->cache_arg == SLJIT_MEM) { in getput_arg()
946 if (argw == compiler->cache_argw) { in getput_arg()
950 …else if (emit_set_delta(compiler, TMP_REG3, TMP_REG3, argw - compiler->cache_argw) != SLJIT_ERR_UN… in getput_arg()
951 FAIL_IF(compiler->error); in getput_arg()
952 compiler->cache_argw = argw; in getput_arg()
959 FAIL_IF(load_immediate(compiler, TMP_REG3, argw)); in getput_arg()
960 compiler->cache_arg = SLJIT_MEM; in getput_arg()
961 compiler->cache_argw = argw; in getput_arg()
971 …FAIL_IF(push_inst(compiler, sljit_mem_reg[flags & 0x3] | (shift << 30) | RT(reg) | RN(arg) | RM(ot… in getput_arg()
972 return push_inst(compiler, ADD | RD(arg) | RN(arg) | RM(other_r) | (argw << 10)); in getput_arg()
975 FAIL_IF(push_inst(compiler, ADD | RD(arg) | RN(arg) | RM(other_r) | (argw << 10))); in getput_arg()
976 return push_inst(compiler, sljit_mem_imm[flags & 0x3] | (shift << 30) | RT(reg) | RN(arg)); in getput_arg()
978 FAIL_IF(push_inst(compiler, ADD | RD(TMP_LR) | RN(arg) | RM(other_r) | (argw << 10))); in getput_arg()
979 FAIL_IF(push_inst(compiler, sljit_mem_imm[flags & 0x3] | (shift << 30) | RT(reg) | RN(TMP_LR))); in getput_arg()
980 return push_inst(compiler, ORR | RD(arg) | RN(TMP_ZERO) | RM(TMP_LR)); in getput_arg()
986 FAIL_IF(push_inst(compiler, ADD | RD(tmp_r) | RN(arg) | RM(other_r) | ((argw & 0x3) << 10))); in getput_arg()
987 return push_inst(compiler, sljit_mem_imm[flags & 0x3] | (shift << 30) | RT(reg) | RN(tmp_r)); in getput_arg()
990 if (compiler->cache_arg == arg) { in getput_arg()
991 diff = argw - compiler->cache_argw; in getput_arg()
993 return push_inst(compiler, sljit_mem_simm[flags & 0x3] | (shift << 30) in getput_arg()
995 if (emit_set_delta(compiler, TMP_REG3, TMP_REG3, diff) != SLJIT_ERR_UNSUPPORTED) { in getput_arg()
996 FAIL_IF(compiler->error); in getput_arg()
997 return push_inst(compiler, sljit_mem_imm[flags & 0x3] | (shift << 30) | RT(reg) | RN(arg)); in getput_arg()
1002 …FAIL_IF(push_inst(compiler, ADDI | (1 << 22) | RD(tmp_r) | RN(arg & REG_MASK) | ((argw >> 12) << 1… in getput_arg()
1003 return push_inst(compiler, sljit_mem_imm[flags & 0x3] | (shift << 30) in getput_arg()
1011 if (arg && compiler->cache_arg == SLJIT_MEM) { in getput_arg()
1012 if (compiler->cache_argw == argw) in getput_arg()
1013 …return push_inst(compiler, sljit_mem_reg[flags & 0x3] | (shift << 30) | RT(reg) | RN(arg) | RM(TMP… in getput_arg()
1014 …if (emit_set_delta(compiler, TMP_REG3, TMP_REG3, argw - compiler->cache_argw) != SLJIT_ERR_UNSUPPO… in getput_arg()
1015 FAIL_IF(compiler->error); in getput_arg()
1016 compiler->cache_argw = argw; in getput_arg()
1017 …return push_inst(compiler, sljit_mem_reg[flags & 0x3] | (shift << 30) | RT(reg) | RN(arg) | RM(TMP… in getput_arg()
1021 compiler->cache_argw = argw; in getput_arg()
1022 if (next_arg && emit_set_delta(compiler, TMP_REG3, arg, argw) != SLJIT_ERR_UNSUPPORTED) { in getput_arg()
1023 FAIL_IF(compiler->error); in getput_arg()
1024 compiler->cache_arg = SLJIT_MEM | arg; in getput_arg()
1028 FAIL_IF(load_immediate(compiler, TMP_REG3, argw)); in getput_arg()
1029 compiler->cache_arg = SLJIT_MEM; in getput_arg()
1032 FAIL_IF(push_inst(compiler, ADD | RD(TMP_REG3) | RN(TMP_REG3) | RM(arg))); in getput_arg()
1033 compiler->cache_arg = SLJIT_MEM | arg; in getput_arg()
1039 …return push_inst(compiler, sljit_mem_reg[flags & 0x3] | (shift << 30) | RT(reg) | RN(arg) | RM(TMP… in getput_arg()
1040 return push_inst(compiler, sljit_mem_imm[flags & 0x3] | (shift << 30) | RT(reg) | RN(TMP_REG3)); in getput_arg()
1043 static SLJIT_INLINE sljit_si emit_op_mem(struct sljit_compiler *compiler, sljit_si flags, sljit_si … in emit_op_mem() argument
1045 if (getput_arg_fast(compiler, flags, reg, arg, argw)) in emit_op_mem()
1046 return compiler->error; in emit_op_mem()
1047 compiler->cache_arg = 0; in emit_op_mem()
1048 compiler->cache_argw = 0; in emit_op_mem()
1049 return getput_arg(compiler, flags, reg, arg, argw, 0, 0); in emit_op_mem()
1052 static SLJIT_INLINE sljit_si emit_op_mem2(struct sljit_compiler *compiler, sljit_si flags, sljit_si… in emit_op_mem2() argument
1054 if (getput_arg_fast(compiler, flags, reg, arg1, arg1w)) in emit_op_mem2()
1055 return compiler->error; in emit_op_mem2()
1056 return getput_arg(compiler, flags, reg, arg1, arg1w, arg2, arg2w); in emit_op_mem2()
1063 SLJIT_API_FUNC_ATTRIBUTE sljit_si sljit_emit_enter(struct sljit_compiler *compiler, in sljit_emit_enter() argument
1070 …CHECK(check_sljit_emit_enter(compiler, options, args, scratches, saveds, fscratches, fsaveds, loca… in sljit_emit_enter()
1071 set_emit_enter(compiler, options, args, scratches, saveds, fscratches, fsaveds, local_size); in sljit_emit_enter()
1076 compiler->local_size = local_size; in sljit_emit_enter()
1079 FAIL_IF(push_inst(compiler, STP_PRE | 29 | RT2(TMP_LR) in sljit_emit_enter()
1081 FAIL_IF(push_inst(compiler, ADDI | RD(SLJIT_SP) | RN(TMP_SP) | (0 << 10))); in sljit_emit_enter()
1091 FAIL_IF(push_inst(compiler, SUBI | RD(TMP_SP) | RN(TMP_SP) | (saved_regs_size << 10))); in sljit_emit_enter()
1102 FAIL_IF(push_inst(compiler, STRI | RT(i) | RN(TMP_SP) | (offs >> 5))); in sljit_emit_enter()
1106 FAIL_IF(push_inst(compiler, STP | RT(prev) | RT2(i) | RN(TMP_SP) | offs)); in sljit_emit_enter()
1117 FAIL_IF(push_inst(compiler, STRI | RT(i) | RN(TMP_SP) | (offs >> 5))); in sljit_emit_enter()
1121 FAIL_IF(push_inst(compiler, STP | RT(prev) | RT2(i) | RN(TMP_SP) | offs)); in sljit_emit_enter()
1128 if (compiler->local_size > (63 * sizeof(sljit_sw))) { in sljit_emit_enter()
1131 …FAIL_IF(push_inst(compiler, SUBI | RD(TMP_SP) | RN(TMP_SP) | ((local_size >> 12) << 10) | (1 << 22… in sljit_emit_enter()
1135 FAIL_IF(push_inst(compiler, SUBI | RD(TMP_SP) | RN(TMP_SP) | (local_size << 10))); in sljit_emit_enter()
1136 FAIL_IF(push_inst(compiler, STP_PRE | 29 | RT2(TMP_LR) in sljit_emit_enter()
1138 FAIL_IF(push_inst(compiler, ADDI | RD(SLJIT_SP) | RN(TMP_SP) | (0 << 10))); in sljit_emit_enter()
1142 FAIL_IF(push_inst(compiler, ORR | RD(SLJIT_S0) | RN(TMP_ZERO) | RM(SLJIT_R0))); in sljit_emit_enter()
1144 FAIL_IF(push_inst(compiler, ORR | RD(SLJIT_S1) | RN(TMP_ZERO) | RM(SLJIT_R1))); in sljit_emit_enter()
1146 FAIL_IF(push_inst(compiler, ORR | RD(SLJIT_S2) | RN(TMP_ZERO) | RM(SLJIT_R2))); in sljit_emit_enter()
1151 SLJIT_API_FUNC_ATTRIBUTE sljit_si sljit_set_context(struct sljit_compiler *compiler, in sljit_set_context() argument
1156 …CHECK(check_sljit_set_context(compiler, options, args, scratches, saveds, fscratches, fsaveds, loc… in sljit_set_context()
1157 set_set_context(compiler, options, args, scratches, saveds, fscratches, fsaveds, local_size); in sljit_set_context()
1161 compiler->local_size = local_size; in sljit_set_context()
1165 SLJIT_API_FUNC_ATTRIBUTE sljit_si sljit_emit_return(struct sljit_compiler *compiler, sljit_si op, s… in sljit_emit_return() argument
1171 CHECK(check_sljit_emit_return(compiler, op, src, srcw)); in sljit_emit_return()
1173 FAIL_IF(emit_mov_before_return(compiler, op, src, srcw)); in sljit_emit_return()
1175 local_size = compiler->local_size; in sljit_emit_return()
1177 saved_regs_size = GET_SAVED_REGISTERS_SIZE(compiler->scratches, compiler->saveds, 0); in sljit_emit_return()
1181 FAIL_IF(push_inst(compiler, LDP_PST | 29 | RT2(TMP_LR) in sljit_emit_return()
1190 …FAIL_IF(push_inst(compiler, ADDI | RD(TMP_SP) | RN(TMP_SP) | ((local_size >> 12) << 10) | (1 << 22… in sljit_emit_return()
1194 FAIL_IF(push_inst(compiler, ADDI | RD(TMP_SP) | RN(TMP_SP) | (local_size << 10))); in sljit_emit_return()
1197 …tmp = compiler->saveds < SLJIT_NUMBER_OF_SAVED_REGISTERS ? (SLJIT_S0 + 1 - compiler->saveds) : SLJ… in sljit_emit_return()
1205 FAIL_IF(push_inst(compiler, LDRI | RT(i) | RN(TMP_SP) | (offs >> 5))); in sljit_emit_return()
1209 FAIL_IF(push_inst(compiler, LDP | RT(prev) | RT2(i) | RN(TMP_SP) | offs)); in sljit_emit_return()
1214 for (i = compiler->scratches; i >= SLJIT_FIRST_SAVED_REG; i--) { in sljit_emit_return()
1220 FAIL_IF(push_inst(compiler, LDRI | RT(i) | RN(TMP_SP) | (offs >> 5))); in sljit_emit_return()
1224 FAIL_IF(push_inst(compiler, LDP | RT(prev) | RT2(i) | RN(TMP_SP) | offs)); in sljit_emit_return()
1231 if (compiler->local_size <= (63 * sizeof(sljit_sw))) { in sljit_emit_return()
1232 FAIL_IF(push_inst(compiler, LDP_PST | 29 | RT2(TMP_LR) in sljit_emit_return()
1235 FAIL_IF(push_inst(compiler, ADDI | RD(TMP_SP) | RN(TMP_SP) | (saved_regs_size << 10))); in sljit_emit_return()
1238 FAIL_IF(push_inst(compiler, RET | RN(TMP_LR))); in sljit_emit_return()
1246 SLJIT_API_FUNC_ATTRIBUTE sljit_si sljit_emit_op0(struct sljit_compiler *compiler, sljit_si op) in sljit_emit_op0() argument
1251 CHECK(check_sljit_emit_op0(compiler, op)); in sljit_emit_op0()
1256 return push_inst(compiler, BRK); in sljit_emit_op0()
1258 return push_inst(compiler, NOP); in sljit_emit_op0()
1261 FAIL_IF(push_inst(compiler, ORR | RD(TMP_REG1) | RN(TMP_ZERO) | RM(SLJIT_R0))); in sljit_emit_op0()
1262 FAIL_IF(push_inst(compiler, MADD | RD(SLJIT_R0) | RN(SLJIT_R0) | RM(SLJIT_R1) | RT2(TMP_ZERO))); in sljit_emit_op0()
1263 …return push_inst(compiler, (op == SLJIT_LUMUL ? UMULH : SMULH) | RD(SLJIT_R1) | RN(TMP_REG1) | RM(… in sljit_emit_op0()
1266 FAIL_IF(push_inst(compiler, (ORR ^ inv_bits) | RD(TMP_REG1) | RN(TMP_ZERO) | RM(SLJIT_R0))); in sljit_emit_op0()
1267 …FAIL_IF(push_inst(compiler, ((op == SLJIT_UDIVMOD ? UDIV : SDIV) ^ inv_bits) | RD(SLJIT_R0) | RN(S… in sljit_emit_op0()
1268 …FAIL_IF(push_inst(compiler, (MADD ^ inv_bits) | RD(SLJIT_R1) | RN(SLJIT_R0) | RM(SLJIT_R1) | RT2(T… in sljit_emit_op0()
1269 return push_inst(compiler, (SUB ^ inv_bits) | RD(SLJIT_R1) | RN(TMP_REG1) | RM(SLJIT_R1)); in sljit_emit_op0()
1272 …return push_inst(compiler, ((op == SLJIT_UDIVI ? UDIV : SDIV) ^ inv_bits) | RD(SLJIT_R0) | RN(SLJI… in sljit_emit_op0()
1278 SLJIT_API_FUNC_ATTRIBUTE sljit_si sljit_emit_op1(struct sljit_compiler *compiler, sljit_si op, in sljit_emit_op1() argument
1286 CHECK(check_sljit_emit_op1(compiler, op, dst, dstw, src, srcw)); in sljit_emit_op1()
1290 compiler->cache_arg = 0; in sljit_emit_op1()
1291 compiler->cache_argw = 0; in sljit_emit_op1()
1373 FAIL_IF(emit_op_imm(compiler, SLJIT_MOV | ARG2_IMM, dst_r, TMP_REG1, srcw)); in sljit_emit_op1()
1375 if (getput_arg_fast(compiler, flags, dst_r, src, srcw)) in sljit_emit_op1()
1376 FAIL_IF(compiler->error); in sljit_emit_op1()
1378 FAIL_IF(getput_arg(compiler, flags, dst_r, src, srcw, dst, dstw)); in sljit_emit_op1()
1381 … return emit_op_imm(compiler, op | ((op_flags & SLJIT_INT_OP) ? INT_OP : 0), dst_r, TMP_REG1, src); in sljit_emit_op1()
1386 if (getput_arg_fast(compiler, flags | STORE, dst_r, dst, dstw)) in sljit_emit_op1()
1387 return compiler->error; in sljit_emit_op1()
1389 return getput_arg(compiler, flags | STORE, dst_r, dst, dstw, 0, 0); in sljit_emit_op1()
1405 if (getput_arg_fast(compiler, mem_flags, TMP_REG2, src, srcw)) in sljit_emit_op1()
1406 FAIL_IF(compiler->error); in sljit_emit_op1()
1408 FAIL_IF(getput_arg(compiler, mem_flags, TMP_REG2, src, srcw, dst, dstw)); in sljit_emit_op1()
1419 emit_op_imm(compiler, flags | op, dst_r, TMP_REG1, srcw); in sljit_emit_op1()
1422 if (getput_arg_fast(compiler, mem_flags | STORE, dst_r, dst, dstw)) in sljit_emit_op1()
1423 return compiler->error; in sljit_emit_op1()
1425 return getput_arg(compiler, mem_flags | STORE, dst_r, dst, dstw, 0, 0); in sljit_emit_op1()
1430 SLJIT_API_FUNC_ATTRIBUTE sljit_si sljit_emit_op2(struct sljit_compiler *compiler, sljit_si op, in sljit_emit_op2() argument
1438 CHECK(check_sljit_emit_op2(compiler, op, dst, dstw, src1, src1w, src2, src2w)); in sljit_emit_op2()
1443 compiler->cache_arg = 0; in sljit_emit_op2()
1444 compiler->cache_argw = 0; in sljit_emit_op2()
1457 …if ((dst & SLJIT_MEM) && !getput_arg_fast(compiler, mem_flags | STORE | ARG_TEST, TMP_REG1, dst, d… in sljit_emit_op2()
1461 if (getput_arg_fast(compiler, mem_flags, TMP_REG1, src1, src1w)) in sljit_emit_op2()
1462 FAIL_IF(compiler->error); in sljit_emit_op2()
1467 if (getput_arg_fast(compiler, mem_flags, TMP_REG2, src2, src2w)) in sljit_emit_op2()
1468 FAIL_IF(compiler->error); in sljit_emit_op2()
1475 FAIL_IF(getput_arg(compiler, mem_flags, TMP_REG2, src2, src2w, src1, src1w)); in sljit_emit_op2()
1476 FAIL_IF(getput_arg(compiler, mem_flags, TMP_REG1, src1, src1w, dst, dstw)); in sljit_emit_op2()
1479 FAIL_IF(getput_arg(compiler, mem_flags, TMP_REG1, src1, src1w, src2, src2w)); in sljit_emit_op2()
1480 FAIL_IF(getput_arg(compiler, mem_flags, TMP_REG2, src2, src2w, dst, dstw)); in sljit_emit_op2()
1484 FAIL_IF(getput_arg(compiler, mem_flags, TMP_REG1, src1, src1w, dst, dstw)); in sljit_emit_op2()
1486 FAIL_IF(getput_arg(compiler, mem_flags, TMP_REG2, src2, src2w, dst, dstw)); in sljit_emit_op2()
1502 emit_op_imm(compiler, flags | GET_OPCODE(op), dst_r, src1w, src2w); in sljit_emit_op2()
1506 getput_arg_fast(compiler, mem_flags | STORE, dst_r, dst, dstw); in sljit_emit_op2()
1507 return compiler->error; in sljit_emit_op2()
1509 return getput_arg(compiler, mem_flags | STORE, TMP_REG1, dst, dstw, 0, 0); in sljit_emit_op2()
1527 SLJIT_API_FUNC_ATTRIBUTE sljit_si sljit_emit_op_custom(struct sljit_compiler *compiler, in sljit_emit_op_custom() argument
1531 CHECK(check_sljit_emit_op_custom(compiler, instruction, size)); in sljit_emit_op_custom()
1533 return push_inst(compiler, *(sljit_ins*)instruction); in sljit_emit_op_custom()
1550 static sljit_si emit_fop_mem(struct sljit_compiler *compiler, sljit_si flags, sljit_si reg, sljit_s… in emit_fop_mem() argument
1565 return push_inst(compiler, STR_FR | ins_bits | VT(reg) in emit_fop_mem()
1569 FAIL_IF(push_inst(compiler, ADD | RD(TMP_REG1) | RN(arg) | RM(other_r) | (argw << 10))); in emit_fop_mem()
1576 return push_inst(compiler, STR_FI | ins_bits | VT(reg) | RN(arg) | (argw << (10 - shift))); in emit_fop_mem()
1579 return push_inst(compiler, STUR_FI | ins_bits | VT(reg) | RN(arg) | ((argw & 0x1ff) << 12)); in emit_fop_mem()
1582 if (compiler->cache_arg == SLJIT_MEM && argw != compiler->cache_argw) { in emit_fop_mem()
1583 diff = argw - compiler->cache_argw; in emit_fop_mem()
1585 return push_inst(compiler, STUR_FI | ins_bits | VT(reg) | RN(TMP_REG3) | ((diff & 0x1ff) << 12)); in emit_fop_mem()
1586 …if (emit_set_delta(compiler, TMP_REG3, TMP_REG3, argw - compiler->cache_argw) != SLJIT_ERR_UNSUPPO… in emit_fop_mem()
1587 FAIL_IF(compiler->error); in emit_fop_mem()
1588 compiler->cache_argw = argw; in emit_fop_mem()
1592 if (compiler->cache_arg != SLJIT_MEM || argw != compiler->cache_argw) { in emit_fop_mem()
1593 compiler->cache_arg = SLJIT_MEM; in emit_fop_mem()
1594 compiler->cache_argw = argw; in emit_fop_mem()
1595 FAIL_IF(load_immediate(compiler, TMP_REG3, argw)); in emit_fop_mem()
1599 return push_inst(compiler, STR_FR | ins_bits | VT(reg) | RN(arg) | RM(TMP_REG3)); in emit_fop_mem()
1600 return push_inst(compiler, STR_FI | ins_bits | VT(reg) | RN(TMP_REG3)); in emit_fop_mem()
1603 static SLJIT_INLINE sljit_si sljit_emit_fop1_convw_fromd(struct sljit_compiler *compiler, sljit_si … in sljit_emit_fop1_convw_fromd() argument
1614 emit_fop_mem(compiler, (op & SLJIT_SINGLE_OP) ? INT_SIZE : WORD_SIZE, TMP_FREG1, src, srcw); in sljit_emit_fop1_convw_fromd()
1618 FAIL_IF(push_inst(compiler, (FCVTZS ^ inv_bits) | RD(dst_r) | VN(src))); in sljit_emit_fop1_convw_fromd()
1621 …return emit_op_mem(compiler, ((GET_OPCODE(op) == SLJIT_CONVI_FROMD) ? INT_SIZE : WORD_SIZE) | STOR… in sljit_emit_fop1_convw_fromd()
1625 static SLJIT_INLINE sljit_si sljit_emit_fop1_convd_fromw(struct sljit_compiler *compiler, sljit_si … in sljit_emit_fop1_convd_fromw() argument
1636 …emit_op_mem(compiler, ((GET_OPCODE(op) == SLJIT_CONVD_FROMI) ? INT_SIZE : WORD_SIZE), TMP_REG1, sr… in sljit_emit_fop1_convd_fromw()
1643 FAIL_IF(load_immediate(compiler, TMP_REG1, srcw)); in sljit_emit_fop1_convd_fromw()
1647 FAIL_IF(push_inst(compiler, (SCVTF ^ inv_bits) | VD(dst_r) | RN(src))); in sljit_emit_fop1_convd_fromw()
1650 …return emit_fop_mem(compiler, ((op & SLJIT_SINGLE_OP) ? INT_SIZE : WORD_SIZE) | STORE, TMP_FREG1, … in sljit_emit_fop1_convd_fromw()
1654 static SLJIT_INLINE sljit_si sljit_emit_fop1_cmp(struct sljit_compiler *compiler, sljit_si op, in sljit_emit_fop1_cmp() argument
1662 emit_fop_mem(compiler, mem_flags, TMP_FREG1, src1, src1w); in sljit_emit_fop1_cmp()
1667 emit_fop_mem(compiler, mem_flags, TMP_FREG2, src2, src2w); in sljit_emit_fop1_cmp()
1671 return push_inst(compiler, (FCMP ^ inv_bits) | VN(src1) | VM(src2)); in sljit_emit_fop1_cmp()
1674 SLJIT_API_FUNC_ATTRIBUTE sljit_si sljit_emit_fop1(struct sljit_compiler *compiler, sljit_si op, in sljit_emit_fop1() argument
1682 compiler->cache_arg = 0; in sljit_emit_fop1()
1683 compiler->cache_argw = 0; in sljit_emit_fop1()
1686 SELECT_FOP1_OPERATION_WITH_CHECKS(compiler, op, dst, dstw, src, srcw); in sljit_emit_fop1()
1692 …emit_fop_mem(compiler, (GET_OPCODE(op) == SLJIT_CONVD_FROMS) ? (mem_flags ^ 0x100) : mem_flags, ds… in sljit_emit_fop1()
1700 FAIL_IF(push_inst(compiler, (FMOV ^ inv_bits) | VD(dst_r) | VN(src))); in sljit_emit_fop1()
1706 FAIL_IF(push_inst(compiler, (FNEG ^ inv_bits) | VD(dst_r) | VN(src))); in sljit_emit_fop1()
1709 FAIL_IF(push_inst(compiler, (FABS ^ inv_bits) | VD(dst_r) | VN(src))); in sljit_emit_fop1()
1712 …FAIL_IF(push_inst(compiler, FCVT | ((op & SLJIT_SINGLE_OP) ? (1 << 22) : (1 << 15)) | VD(dst_r) | … in sljit_emit_fop1()
1717 return emit_fop_mem(compiler, mem_flags | STORE, dst_r, dst, dstw); in sljit_emit_fop1()
1721 SLJIT_API_FUNC_ATTRIBUTE sljit_si sljit_emit_fop2(struct sljit_compiler *compiler, sljit_si op, in sljit_emit_fop2() argument
1730 CHECK(check_sljit_emit_fop2(compiler, op, dst, dstw, src1, src1w, src2, src2w)); in sljit_emit_fop2()
1735 compiler->cache_arg = 0; in sljit_emit_fop2()
1736 compiler->cache_argw = 0; in sljit_emit_fop2()
1740 emit_fop_mem(compiler, mem_flags, TMP_FREG1, src1, src1w); in sljit_emit_fop2()
1744 emit_fop_mem(compiler, mem_flags, TMP_FREG2, src2, src2w); in sljit_emit_fop2()
1750 FAIL_IF(push_inst(compiler, (FADD ^ inv_bits) | VD(dst_r) | VN(src1) | VM(src2))); in sljit_emit_fop2()
1753 FAIL_IF(push_inst(compiler, (FSUB ^ inv_bits) | VD(dst_r) | VN(src1) | VM(src2))); in sljit_emit_fop2()
1756 FAIL_IF(push_inst(compiler, (FMUL ^ inv_bits) | VD(dst_r) | VN(src1) | VM(src2))); in sljit_emit_fop2()
1759 FAIL_IF(push_inst(compiler, (FDIV ^ inv_bits) | VD(dst_r) | VN(src1) | VM(src2))); in sljit_emit_fop2()
1765 return emit_fop_mem(compiler, mem_flags | STORE, TMP_FREG1, dst, dstw); in sljit_emit_fop2()
1772 SLJIT_API_FUNC_ATTRIBUTE sljit_si sljit_emit_fast_enter(struct sljit_compiler *compiler, sljit_si d… in sljit_emit_fast_enter() argument
1775 CHECK(check_sljit_emit_fast_enter(compiler, dst, dstw)); in sljit_emit_fast_enter()
1783 return push_inst(compiler, ORR | RD(dst) | RN(TMP_ZERO) | RM(TMP_LR)); in sljit_emit_fast_enter()
1786 return emit_op_mem(compiler, WORD_SIZE | STORE, TMP_LR, dst, dstw); in sljit_emit_fast_enter()
1789 SLJIT_API_FUNC_ATTRIBUTE sljit_si sljit_emit_fast_return(struct sljit_compiler *compiler, sljit_si … in sljit_emit_fast_return() argument
1792 CHECK(check_sljit_emit_fast_return(compiler, src, srcw)); in sljit_emit_fast_return()
1796 FAIL_IF(push_inst(compiler, ORR | RD(TMP_LR) | RN(TMP_ZERO) | RM(src))); in sljit_emit_fast_return()
1798 FAIL_IF(emit_op_mem(compiler, WORD_SIZE, TMP_LR, src, srcw)); in sljit_emit_fast_return()
1800 FAIL_IF(load_immediate(compiler, TMP_LR, srcw)); in sljit_emit_fast_return()
1802 return push_inst(compiler, RET | RN(TMP_LR)); in sljit_emit_fast_return()
1864 SLJIT_API_FUNC_ATTRIBUTE struct sljit_label* sljit_emit_label(struct sljit_compiler *compiler) in sljit_emit_label() argument
1869 CHECK_PTR(check_sljit_emit_label(compiler)); in sljit_emit_label()
1871 if (compiler->last_label && compiler->last_label->size == compiler->size) in sljit_emit_label()
1872 return compiler->last_label; in sljit_emit_label()
1874 label = (struct sljit_label*)ensure_abuf(compiler, sizeof(struct sljit_label)); in sljit_emit_label()
1876 set_label(label, compiler); in sljit_emit_label()
1880 SLJIT_API_FUNC_ATTRIBUTE struct sljit_jump* sljit_emit_jump(struct sljit_compiler *compiler, sljit_… in sljit_emit_jump() argument
1885 CHECK_PTR(check_sljit_emit_jump(compiler, type)); in sljit_emit_jump()
1887 jump = (struct sljit_jump*)ensure_abuf(compiler, sizeof(struct sljit_jump)); in sljit_emit_jump()
1889 set_jump(jump, compiler, type & SLJIT_REWRITABLE_JUMP); in sljit_emit_jump()
1894 PTR_FAIL_IF(push_inst(compiler, B_CC | (6 << 5) | get_cc(type))); in sljit_emit_jump()
1899 PTR_FAIL_IF(emit_imm64_const(compiler, TMP_REG1, 0)); in sljit_emit_jump()
1900 jump->addr = compiler->size; in sljit_emit_jump()
1901 PTR_FAIL_IF(push_inst(compiler, ((type >= SLJIT_FAST_CALL) ? BLR : BR) | RN(TMP_REG1))); in sljit_emit_jump()
1906 static SLJIT_INLINE struct sljit_jump* emit_cmp_to0(struct sljit_compiler *compiler, sljit_si type, in emit_cmp_to0() argument
1915 jump = (struct sljit_jump*)ensure_abuf(compiler, sizeof(struct sljit_jump)); in emit_cmp_to0()
1917 set_jump(jump, compiler, type & SLJIT_REWRITABLE_JUMP); in emit_cmp_to0()
1921 PTR_FAIL_IF(emit_op_mem(compiler, inv_bits ? INT_SIZE : WORD_SIZE, TMP_REG1, src, srcw)); in emit_cmp_to0()
1925 PTR_FAIL_IF(load_immediate(compiler, TMP_REG1, srcw)); in emit_cmp_to0()
1933 PTR_FAIL_IF(push_inst(compiler, (CBZ ^ inv_bits) | (6 << 5) | RT(src))); in emit_cmp_to0()
1934 PTR_FAIL_IF(emit_imm64_const(compiler, TMP_REG1, 0)); in emit_cmp_to0()
1935 jump->addr = compiler->size; in emit_cmp_to0()
1936 PTR_FAIL_IF(push_inst(compiler, BR | RN(TMP_REG1))); in emit_cmp_to0()
1940 SLJIT_API_FUNC_ATTRIBUTE sljit_si sljit_emit_ijump(struct sljit_compiler *compiler, sljit_si type, … in sljit_emit_ijump() argument
1945 CHECK(check_sljit_emit_ijump(compiler, type, src, srcw)); in sljit_emit_ijump()
1951 FAIL_IF(emit_op_mem(compiler, WORD_SIZE, TMP_REG1, src, srcw)); in sljit_emit_ijump()
1954 return push_inst(compiler, ((type >= SLJIT_FAST_CALL) ? BLR : BR) | RN(src)); in sljit_emit_ijump()
1957 jump = (struct sljit_jump*)ensure_abuf(compiler, sizeof(struct sljit_jump)); in sljit_emit_ijump()
1959 set_jump(jump, compiler, JUMP_ADDR | ((type >= SLJIT_FAST_CALL) ? IS_BL : 0)); in sljit_emit_ijump()
1962 FAIL_IF(emit_imm64_const(compiler, TMP_REG1, 0)); in sljit_emit_ijump()
1963 jump->addr = compiler->size; in sljit_emit_ijump()
1964 return push_inst(compiler, ((type >= SLJIT_FAST_CALL) ? BLR : BR) | RN(TMP_REG1)); in sljit_emit_ijump()
1967 SLJIT_API_FUNC_ATTRIBUTE sljit_si sljit_emit_op_flags(struct sljit_compiler *compiler, sljit_si op, in sljit_emit_op_flags() argument
1976 CHECK(check_sljit_emit_op_flags(compiler, op, dst, dstw, src, srcw, type)); in sljit_emit_op_flags()
1987 FAIL_IF(push_inst(compiler, CSINC | (cc << 12) | RD(dst_r) | RN(TMP_ZERO) | RM(TMP_ZERO))); in sljit_emit_op_flags()
1990 …return emit_op_mem(compiler, (GET_OPCODE(op) == SLJIT_MOV ? WORD_SIZE : INT_SIZE) | STORE, TMP_REG… in sljit_emit_op_flags()
1993 compiler->cache_arg = 0; in sljit_emit_op_flags()
1994 compiler->cache_argw = 0; in sljit_emit_op_flags()
2003 FAIL_IF(emit_op_mem2(compiler, mem_flags, TMP_REG1, src, srcw, dst, dstw)); in sljit_emit_op_flags()
2009 FAIL_IF(push_inst(compiler, CSINC | (cc << 12) | RD(TMP_REG2) | RN(TMP_ZERO) | RM(TMP_ZERO))); in sljit_emit_op_flags()
2010 emit_op_imm(compiler, flags | GET_OPCODE(op), dst_r, src, TMP_REG2); in sljit_emit_op_flags()
2014 return emit_op_mem2(compiler, mem_flags | STORE, TMP_REG1, dst, dstw, 0, 0); in sljit_emit_op_flags()
2017 SLJIT_API_FUNC_ATTRIBUTE struct sljit_const* sljit_emit_const(struct sljit_compiler *compiler, slji… in sljit_emit_const() argument
2023 CHECK_PTR(check_sljit_emit_const(compiler, dst, dstw, init_value)); in sljit_emit_const()
2026 const_ = (struct sljit_const*)ensure_abuf(compiler, sizeof(struct sljit_const)); in sljit_emit_const()
2028 set_const(const_, compiler); in sljit_emit_const()
2031 PTR_FAIL_IF(emit_imm64_const(compiler, dst_r, init_value)); in sljit_emit_const()
2034 PTR_FAIL_IF(emit_op_mem(compiler, WORD_SIZE | STORE, dst_r, dst, dstw)); in sljit_emit_const()