Lines Matching refs:compiler
129 static sljit_s32 push_inst(struct sljit_compiler *compiler, sljit_ins ins) in push_inst() argument
131 sljit_ins *ptr = (sljit_ins*)ensure_buf(compiler, sizeof(sljit_ins)); in push_inst()
134 compiler->size++; in push_inst()
138 static SLJIT_INLINE sljit_s32 emit_imm64_const(struct sljit_compiler *compiler, sljit_s32 dst, slji… in emit_imm64_const() argument
140 FAIL_IF(push_inst(compiler, MOVZ | RD(dst) | ((imm & 0xffff) << 5))); in emit_imm64_const()
141 FAIL_IF(push_inst(compiler, MOVK | RD(dst) | (((imm >> 16) & 0xffff) << 5) | (1 << 21))); in emit_imm64_const()
142 FAIL_IF(push_inst(compiler, MOVK | RD(dst) | (((imm >> 32) & 0xffff) << 5) | (2 << 21))); in emit_imm64_const()
143 return push_inst(compiler, MOVK | RD(dst) | ((imm >> 48) << 5) | (3 << 21)); in emit_imm64_const()
209 SLJIT_API_FUNC_ATTRIBUTE void* sljit_generate_code(struct sljit_compiler *compiler) in sljit_generate_code() argument
226 CHECK_PTR(check_sljit_generate_code(compiler)); in sljit_generate_code()
227 reverse_buf(compiler); in sljit_generate_code()
229 code = (sljit_ins*)SLJIT_MALLOC_EXEC(compiler->size * sizeof(sljit_ins)); in sljit_generate_code()
231 buf = compiler->buf; in sljit_generate_code()
237 label = compiler->labels; in sljit_generate_code()
238 jump = compiler->jumps; in sljit_generate_code()
239 const_ = compiler->consts; in sljit_generate_code()
280 SLJIT_ASSERT(code_ptr - code <= (sljit_sw)compiler->size); in sljit_generate_code()
282 jump = compiler->jumps; in sljit_generate_code()
317 compiler->error = SLJIT_ERR_COMPILED; in sljit_generate_code()
318 compiler->executable_offset = executable_offset; in sljit_generate_code()
319 compiler->executable_size = (code_ptr - code) * sizeof(sljit_ins); in sljit_generate_code()
425 static sljit_s32 load_immediate(struct sljit_compiler *compiler, sljit_s32 dst, sljit_sw simm) in load_immediate() argument
432 return push_inst(compiler, MOVZ | RD(dst) | (imm << 5)); in load_immediate()
435 return push_inst(compiler, MOVN | RD(dst) | ((~imm & 0xffff) << 5)); in load_immediate()
439 return push_inst(compiler, (MOVN ^ W_OP) | RD(dst) | ((~imm & 0xffff) << 5)); in load_immediate()
441 …return push_inst(compiler, (MOVN ^ W_OP) | RD(dst) | ((~imm & 0xffff0000l) >> (16 - 5)) | (1 << 21… in load_immediate()
444 return push_inst(compiler, (ORRI ^ W_OP) | RD(dst) | RN(TMP_ZERO) | bitmask); in load_immediate()
449 return push_inst(compiler, ORRI | RD(dst) | RN(TMP_ZERO) | bitmask); in load_immediate()
453 FAIL_IF(push_inst(compiler, MOVZ | RD(dst) | ((imm & 0xffff) << 5))); in load_immediate()
454 return push_inst(compiler, MOVK | RD(dst) | ((imm & 0xffff0000l) >> (16 - 5)) | (1 << 21)); in load_immediate()
458 FAIL_IF(push_inst(compiler, MOVN | RD(dst) | ((~imm & 0xffff) << 5))); in load_immediate()
459 return push_inst(compiler, MOVK | RD(dst) | ((imm & 0xffff0000l) >> (16 - 5)) | (1 << 21)); in load_immediate()
486 FAIL_IF(push_inst(compiler, MOVN | RD(dst) | ((simm & 0xffff) << 5) | (i << 21))); in load_immediate()
489 FAIL_IF(push_inst(compiler, MOVK | RD(dst) | ((~simm & 0xffff) << 5) | (i << 21))); in load_immediate()
502 FAIL_IF(push_inst(compiler, MOVZ | RD(dst) | ((simm & 0xffff) << 5) | (i << 21))); in load_immediate()
505 FAIL_IF(push_inst(compiler, MOVK | RD(dst) | ((simm & 0xffff) << 5) | (i << 21))); in load_immediate()
527 static sljit_s32 emit_op_imm(struct sljit_compiler *compiler, sljit_s32 flags, sljit_s32 dst, sljit… in emit_op_imm() argument
544 FAIL_IF(load_immediate(compiler, TMP_REG1, arg1)); in emit_op_imm()
564 return load_immediate(compiler, dst, imm); in emit_op_imm()
567 FAIL_IF(load_immediate(compiler, dst, (flags & INT_OP) ? (~imm & 0xffffffff) : ~imm)); in emit_op_imm()
577 return push_inst(compiler, ((op == SLJIT_ADD ? ADDI : SUBI) ^ inv_bits) | RD(dst) | RN(reg)); in emit_op_imm()
581 return push_inst(compiler, (ADDI ^ inv_bits) | RD(dst) | RN(reg) | (imm << 10)); in emit_op_imm()
586 return push_inst(compiler, (SUBI ^ inv_bits) | RD(dst) | RN(reg) | (nimm << 10)); in emit_op_imm()
590 …return push_inst(compiler, (ADDI ^ inv_bits) | RD(dst) | RN(reg) | ((imm >> 12) << 10) | (1 << 22)… in emit_op_imm()
594 …return push_inst(compiler, (SUBI ^ inv_bits) | RD(dst) | RN(reg) | ((nimm >> 12) << 10) | (1 << 22… in emit_op_imm()
597 …FAIL_IF(push_inst(compiler, (ADDI ^ inv_bits) | RD(dst) | RN(reg) | ((imm >> 12) << 10) | (1 << 22… in emit_op_imm()
598 return push_inst(compiler, (ADDI ^ inv_bits) | RD(dst) | RN(dst) | ((imm & 0xfff) << 10)); in emit_op_imm()
601 …FAIL_IF(push_inst(compiler, (SUBI ^ inv_bits) | RD(dst) | RN(reg) | ((nimm >> 12) << 10) | (1 << 2… in emit_op_imm()
602 return push_inst(compiler, (SUBI ^ inv_bits) | RD(dst) | RN(dst) | ((nimm & 0xfff) << 10)); in emit_op_imm()
610 return push_inst(compiler, (ANDI ^ inv_bits) | RD(dst) | RN(reg) | inst_bits); in emit_op_imm()
620 FAIL_IF(push_inst(compiler, (inst_bits ^ inv_bits) | RD(dst) | RN(reg))); in emit_op_imm()
627 …FAIL_IF(push_inst(compiler, (UBFM ^ inv_bits) | RD(dst) | RN(arg1) | ((-imm & 0x1f) << 16) | ((31 … in emit_op_imm()
631 …FAIL_IF(push_inst(compiler, (UBFM ^ inv_bits) | RD(dst) | RN(arg1) | (1 << 22) | ((-imm & 0x3f) <<… in emit_op_imm()
642 FAIL_IF(push_inst(compiler, (UBFM ^ inv_bits) | RD(dst) | RN(arg1) | (imm << 16) | (31 << 10))); in emit_op_imm()
646 …FAIL_IF(push_inst(compiler, (UBFM ^ inv_bits) | RD(dst) | RN(arg1) | (1 << 22) | (imm << 16) | (63… in emit_op_imm()
658 FAIL_IF(load_immediate(compiler, TMP_REG2, arg2)); in emit_op_imm()
666 FAIL_IF(load_immediate(compiler, TMP_REG1, arg1)); in emit_op_imm()
681 return push_inst(compiler, ORR | RD(dst) | RN(TMP_ZERO) | RM(arg2)); in emit_op_imm()
685 return push_inst(compiler, (UBFM ^ (1 << 31)) | RD(dst) | RN(arg2) | (7 << 10)); in emit_op_imm()
691 return push_inst(compiler, (SBFM ^ inv_bits) | RD(dst) | RN(arg2) | (7 << 10)); in emit_op_imm()
695 return push_inst(compiler, (UBFM ^ (1 << 31)) | RD(dst) | RN(arg2) | (15 << 10)); in emit_op_imm()
701 return push_inst(compiler, (SBFM ^ inv_bits) | RD(dst) | RN(arg2) | (15 << 10)); in emit_op_imm()
707 return push_inst(compiler, (ORR ^ (1 << 31)) | RD(dst) | RN(TMP_ZERO) | RM(arg2)); in emit_op_imm()
713 return push_inst(compiler, SBFM | (1 << 22) | RD(dst) | RN(arg2) | (31 << 10)); in emit_op_imm()
716 FAIL_IF(push_inst(compiler, (ORN ^ inv_bits) | RD(dst) | RN(TMP_ZERO) | RM(arg2))); in emit_op_imm()
722 return push_inst(compiler, (SUB ^ inv_bits) | RD(dst) | RN(TMP_ZERO) | RM(arg2)); in emit_op_imm()
725 FAIL_IF(push_inst(compiler, (CLZ ^ inv_bits) | RD(dst) | RN(arg2))); in emit_op_imm()
729 return push_inst(compiler, (ADD ^ inv_bits) | RD(dst) | RN(arg1) | RM(arg2)); in emit_op_imm()
732 return push_inst(compiler, (ADC ^ inv_bits) | RD(dst) | RN(arg1) | RM(arg2)); in emit_op_imm()
735 return push_inst(compiler, (SUB ^ inv_bits) | RD(dst) | RN(arg1) | RM(arg2)); in emit_op_imm()
738 return push_inst(compiler, (SBC ^ inv_bits) | RD(dst) | RN(arg1) | RM(arg2)); in emit_op_imm()
741 return push_inst(compiler, (MADD ^ inv_bits) | RD(dst) | RN(arg1) | RM(arg2) | RT2(TMP_ZERO)); in emit_op_imm()
743 FAIL_IF(push_inst(compiler, SMADDL | RD(dst) | RN(arg1) | RM(arg2) | (31 << 10))); in emit_op_imm()
744 FAIL_IF(push_inst(compiler, ADD | RD(TMP_LR) | RN(TMP_ZERO) | RM(dst) | (2 << 22) | (31 << 10))); in emit_op_imm()
745 return push_inst(compiler, SUBS | RD(TMP_ZERO) | RN(TMP_LR) | RM(dst) | (2 << 22) | (63 << 10)); in emit_op_imm()
747 FAIL_IF(push_inst(compiler, SMULH | RD(TMP_LR) | RN(arg1) | RM(arg2))); in emit_op_imm()
748 FAIL_IF(push_inst(compiler, MADD | RD(dst) | RN(arg1) | RM(arg2) | RT2(TMP_ZERO))); in emit_op_imm()
749 return push_inst(compiler, SUBS | RD(TMP_ZERO) | RN(TMP_LR) | RM(dst) | (2 << 22) | (63 << 10)); in emit_op_imm()
752 return push_inst(compiler, (AND ^ inv_bits) | RD(dst) | RN(arg1) | RM(arg2)); in emit_op_imm()
754 FAIL_IF(push_inst(compiler, (ORR ^ inv_bits) | RD(dst) | RN(arg1) | RM(arg2))); in emit_op_imm()
757 FAIL_IF(push_inst(compiler, (EOR ^ inv_bits) | RD(dst) | RN(arg1) | RM(arg2))); in emit_op_imm()
760 FAIL_IF(push_inst(compiler, (LSLV ^ inv_bits) | RD(dst) | RN(arg1) | RM(arg2))); in emit_op_imm()
763 FAIL_IF(push_inst(compiler, (LSRV ^ inv_bits) | RD(dst) | RN(arg1) | RM(arg2))); in emit_op_imm()
766 FAIL_IF(push_inst(compiler, (ASRV ^ inv_bits) | RD(dst) | RN(arg1) | RM(arg2))); in emit_op_imm()
775 return push_inst(compiler, (SUBS ^ inv_bits) | RD(TMP_ZERO) | RN(dst) | RM(TMP_ZERO)); in emit_op_imm()
821 static sljit_s32 emit_set_delta(struct sljit_compiler *compiler, sljit_s32 dst, sljit_s32 reg, slji… in emit_set_delta() argument
825 return push_inst(compiler, ADDI | RD(dst) | RN(reg) | (value << 10)); in emit_set_delta()
827 return push_inst(compiler, ADDI | (1 << 22) | RD(dst) | RN(reg) | (value >> 2)); in emit_set_delta()
832 return push_inst(compiler, SUBI | RD(dst) | RN(reg) | (value << 10)); in emit_set_delta()
834 return push_inst(compiler, SUBI | (1 << 22) | RD(dst) | RN(reg) | (value >> 2)); in emit_set_delta()
840 static sljit_s32 getput_arg_fast(struct sljit_compiler *compiler, sljit_s32 flags, sljit_s32 reg, s… in getput_arg_fast() argument
853 FAIL_IF(push_inst(compiler, sljit_mem_pre_simm[flags & 0x3] in getput_arg_fast()
868 FAIL_IF(push_inst(compiler, sljit_mem_reg[flags & 0x3] | (shift << 30) | RT(reg) in getput_arg_fast()
878 FAIL_IF(push_inst(compiler, sljit_mem_imm[flags & 0x3] | (shift << 30) in getput_arg_fast()
889 FAIL_IF(push_inst(compiler, sljit_mem_simm[flags & 0x3] | (shift << 30) in getput_arg_fast()
921 static sljit_s32 getput_arg(struct sljit_compiler *compiler, sljit_s32 flags, sljit_s32 reg, in getput_arg() argument
945 FAIL_IF(push_inst(compiler, ADDI | RD(other_r) | RN(other_r) | ((argw & 0xfff) << 10))); in getput_arg()
947 … FAIL_IF(push_inst(compiler, ADDI | (1 << 22) | RD(other_r) | RN(other_r) | ((argw >> 12) << 10))); in getput_arg()
948 return push_inst(compiler, sljit_mem_imm[flags & 0x3] | (shift << 30) | RT(reg) | RN(other_r)); in getput_arg()
953 FAIL_IF(push_inst(compiler, SUBI | RD(other_r) | RN(other_r) | ((argw & 0xfff) << 10))); in getput_arg()
955 … FAIL_IF(push_inst(compiler, SUBI | (1 << 22) | RD(other_r) | RN(other_r) | ((argw >> 12) << 10))); in getput_arg()
956 return push_inst(compiler, sljit_mem_imm[flags & 0x3] | (shift << 30) | RT(reg) | RN(other_r)); in getput_arg()
959 if (compiler->cache_arg == SLJIT_MEM) { in getput_arg()
960 if (argw == compiler->cache_argw) { in getput_arg()
964 …else if (emit_set_delta(compiler, TMP_REG3, TMP_REG3, argw - compiler->cache_argw) != SLJIT_ERR_UN… in getput_arg()
965 FAIL_IF(compiler->error); in getput_arg()
966 compiler->cache_argw = argw; in getput_arg()
973 FAIL_IF(load_immediate(compiler, TMP_REG3, argw)); in getput_arg()
974 compiler->cache_arg = SLJIT_MEM; in getput_arg()
975 compiler->cache_argw = argw; in getput_arg()
983 …FAIL_IF(push_inst(compiler, sljit_mem_reg[flags & 0x3] | (shift << 30) | RT(reg) | RN(arg) | RM(ot… in getput_arg()
984 return push_inst(compiler, ADD | RD(arg) | RN(arg) | RM(other_r)); in getput_arg()
990 FAIL_IF(push_inst(compiler, ADD | RD(tmp_r) | RN(arg) | RM(other_r) | ((argw & 0x3) << 10))); in getput_arg()
991 return push_inst(compiler, sljit_mem_imm[flags & 0x3] | (shift << 30) | RT(reg) | RN(tmp_r)); in getput_arg()
994 if (compiler->cache_arg == arg) { in getput_arg()
995 diff = argw - compiler->cache_argw; in getput_arg()
997 return push_inst(compiler, sljit_mem_simm[flags & 0x3] | (shift << 30) in getput_arg()
999 if (emit_set_delta(compiler, TMP_REG3, TMP_REG3, diff) != SLJIT_ERR_UNSUPPORTED) { in getput_arg()
1000 FAIL_IF(compiler->error); in getput_arg()
1001 return push_inst(compiler, sljit_mem_imm[flags & 0x3] | (shift << 30) | RT(reg) | RN(arg)); in getput_arg()
1006 …FAIL_IF(push_inst(compiler, ADDI | (1 << 22) | RD(tmp_r) | RN(arg & REG_MASK) | ((argw >> 12) << 1… in getput_arg()
1007 return push_inst(compiler, sljit_mem_imm[flags & 0x3] | (shift << 30) in getput_arg()
1015 if (arg && compiler->cache_arg == SLJIT_MEM) { in getput_arg()
1016 if (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()
1018 …if (emit_set_delta(compiler, TMP_REG3, TMP_REG3, argw - compiler->cache_argw) != SLJIT_ERR_UNSUPPO… in getput_arg()
1019 FAIL_IF(compiler->error); in getput_arg()
1020 compiler->cache_argw = argw; in getput_arg()
1021 …return push_inst(compiler, sljit_mem_reg[flags & 0x3] | (shift << 30) | RT(reg) | RN(arg) | RM(TMP… in getput_arg()
1025 compiler->cache_argw = argw; in getput_arg()
1026 if (next_arg && emit_set_delta(compiler, TMP_REG3, arg, argw) != SLJIT_ERR_UNSUPPORTED) { in getput_arg()
1027 FAIL_IF(compiler->error); in getput_arg()
1028 compiler->cache_arg = SLJIT_MEM | arg; in getput_arg()
1032 FAIL_IF(load_immediate(compiler, TMP_REG3, argw)); in getput_arg()
1033 compiler->cache_arg = SLJIT_MEM; in getput_arg()
1036 FAIL_IF(push_inst(compiler, ADD | RD(TMP_REG3) | RN(TMP_REG3) | RM(arg))); in getput_arg()
1037 compiler->cache_arg = SLJIT_MEM | arg; in getput_arg()
1043 …return push_inst(compiler, sljit_mem_reg[flags & 0x3] | (shift << 30) | RT(reg) | RN(arg) | RM(TMP… in getput_arg()
1044 return push_inst(compiler, sljit_mem_imm[flags & 0x3] | (shift << 30) | RT(reg) | RN(TMP_REG3)); in getput_arg()
1047 static SLJIT_INLINE sljit_s32 emit_op_mem(struct sljit_compiler *compiler, sljit_s32 flags, sljit_s… in emit_op_mem() argument
1049 if (getput_arg_fast(compiler, flags, reg, arg, argw)) in emit_op_mem()
1050 return compiler->error; in emit_op_mem()
1051 compiler->cache_arg = 0; in emit_op_mem()
1052 compiler->cache_argw = 0; in emit_op_mem()
1053 return getput_arg(compiler, flags, reg, arg, argw, 0, 0); in emit_op_mem()
1056 static SLJIT_INLINE sljit_s32 emit_op_mem2(struct sljit_compiler *compiler, sljit_s32 flags, sljit_… in emit_op_mem2() argument
1058 if (getput_arg_fast(compiler, flags, reg, arg1, arg1w)) in emit_op_mem2()
1059 return compiler->error; in emit_op_mem2()
1060 return getput_arg(compiler, flags, reg, arg1, arg1w, arg2, arg2w); in emit_op_mem2()
1067 SLJIT_API_FUNC_ATTRIBUTE sljit_s32 sljit_emit_enter(struct sljit_compiler *compiler, in sljit_emit_enter() argument
1074 …CHECK(check_sljit_emit_enter(compiler, options, args, scratches, saveds, fscratches, fsaveds, loca… in sljit_emit_enter()
1075 set_emit_enter(compiler, options, args, scratches, saveds, fscratches, fsaveds, local_size); in sljit_emit_enter()
1080 compiler->local_size = local_size; in sljit_emit_enter()
1084 FAIL_IF(push_inst(compiler, STP_PRE | 29 | RT2(TMP_LR) in sljit_emit_enter()
1086 FAIL_IF(push_inst(compiler, ADDI | RD(SLJIT_SP) | RN(TMP_SP) | (0 << 10))); in sljit_emit_enter()
1096 FAIL_IF(push_inst(compiler, SUBI | RD(TMP_SP) | RN(TMP_SP) | (saved_regs_size << 10))); in sljit_emit_enter()
1107 FAIL_IF(push_inst(compiler, STRI | RT(i) | RN(TMP_SP) | (offs >> 5))); in sljit_emit_enter()
1111 FAIL_IF(push_inst(compiler, STP | RT(prev) | RT2(i) | RN(TMP_SP) | offs)); in sljit_emit_enter()
1122 FAIL_IF(push_inst(compiler, STRI | RT(i) | RN(TMP_SP) | (offs >> 5))); in sljit_emit_enter()
1126 FAIL_IF(push_inst(compiler, STP | RT(prev) | RT2(i) | RN(TMP_SP) | offs)); in sljit_emit_enter()
1133 SLJIT_ASSERT(compiler->local_size >= 0); in sljit_emit_enter()
1134 if ((size_t)compiler->local_size > (63 * sizeof(sljit_sw))) { in sljit_emit_enter()
1137 …FAIL_IF(push_inst(compiler, SUBI | RD(TMP_SP) | RN(TMP_SP) | ((local_size >> 12) << 10) | (1 << 22… in sljit_emit_enter()
1141 FAIL_IF(push_inst(compiler, SUBI | RD(TMP_SP) | RN(TMP_SP) | (local_size << 10))); in sljit_emit_enter()
1142 FAIL_IF(push_inst(compiler, STP_PRE | 29 | RT2(TMP_LR) in sljit_emit_enter()
1144 FAIL_IF(push_inst(compiler, ADDI | RD(SLJIT_SP) | RN(TMP_SP) | (0 << 10))); in sljit_emit_enter()
1148 FAIL_IF(push_inst(compiler, ORR | RD(SLJIT_S0) | RN(TMP_ZERO) | RM(SLJIT_R0))); in sljit_emit_enter()
1150 FAIL_IF(push_inst(compiler, ORR | RD(SLJIT_S1) | RN(TMP_ZERO) | RM(SLJIT_R1))); in sljit_emit_enter()
1152 FAIL_IF(push_inst(compiler, ORR | RD(SLJIT_S2) | RN(TMP_ZERO) | RM(SLJIT_R2))); in sljit_emit_enter()
1157 SLJIT_API_FUNC_ATTRIBUTE sljit_s32 sljit_set_context(struct sljit_compiler *compiler, in sljit_set_context() argument
1162 …CHECK(check_sljit_set_context(compiler, options, args, scratches, saveds, fscratches, fsaveds, loc… in sljit_set_context()
1163 set_set_context(compiler, options, args, scratches, saveds, fscratches, fsaveds, local_size); in sljit_set_context()
1167 compiler->local_size = local_size; in sljit_set_context()
1171 SLJIT_API_FUNC_ATTRIBUTE sljit_s32 sljit_emit_return(struct sljit_compiler *compiler, sljit_s32 op,… in sljit_emit_return() argument
1177 CHECK(check_sljit_emit_return(compiler, op, src, srcw)); in sljit_emit_return()
1179 FAIL_IF(emit_mov_before_return(compiler, op, src, srcw)); in sljit_emit_return()
1181 local_size = compiler->local_size; in sljit_emit_return()
1183 saved_regs_size = GET_SAVED_REGISTERS_SIZE(compiler->scratches, compiler->saveds, 0); in sljit_emit_return()
1188 FAIL_IF(push_inst(compiler, LDP_PST | 29 | RT2(TMP_LR) in sljit_emit_return()
1197 …FAIL_IF(push_inst(compiler, ADDI | RD(TMP_SP) | RN(TMP_SP) | ((local_size >> 12) << 10) | (1 << 22… in sljit_emit_return()
1201 FAIL_IF(push_inst(compiler, ADDI | RD(TMP_SP) | RN(TMP_SP) | (local_size << 10))); in sljit_emit_return()
1204 …tmp = compiler->saveds < SLJIT_NUMBER_OF_SAVED_REGISTERS ? (SLJIT_S0 + 1 - compiler->saveds) : SLJ… in sljit_emit_return()
1212 FAIL_IF(push_inst(compiler, LDRI | RT(i) | RN(TMP_SP) | (offs >> 5))); in sljit_emit_return()
1216 FAIL_IF(push_inst(compiler, LDP | RT(prev) | RT2(i) | RN(TMP_SP) | offs)); in sljit_emit_return()
1221 for (i = compiler->scratches; i >= SLJIT_FIRST_SAVED_REG; i--) { in sljit_emit_return()
1227 FAIL_IF(push_inst(compiler, LDRI | RT(i) | RN(TMP_SP) | (offs >> 5))); in sljit_emit_return()
1231 FAIL_IF(push_inst(compiler, LDP | RT(prev) | RT2(i) | RN(TMP_SP) | offs)); in sljit_emit_return()
1238 SLJIT_ASSERT(compiler->local_size >= 0); in sljit_emit_return()
1239 if ((size_t)compiler->local_size <= (63 * sizeof(sljit_sw))) { in sljit_emit_return()
1240 FAIL_IF(push_inst(compiler, LDP_PST | 29 | RT2(TMP_LR) in sljit_emit_return()
1243 FAIL_IF(push_inst(compiler, ADDI | RD(TMP_SP) | RN(TMP_SP) | (saved_regs_size << 10))); in sljit_emit_return()
1246 FAIL_IF(push_inst(compiler, RET | RN(TMP_LR))); in sljit_emit_return()
1254 SLJIT_API_FUNC_ATTRIBUTE sljit_s32 sljit_emit_op0(struct sljit_compiler *compiler, sljit_s32 op) in sljit_emit_op0() argument
1259 CHECK(check_sljit_emit_op0(compiler, op)); in sljit_emit_op0()
1264 return push_inst(compiler, BRK); in sljit_emit_op0()
1266 return push_inst(compiler, NOP); in sljit_emit_op0()
1269 FAIL_IF(push_inst(compiler, ORR | RD(TMP_REG1) | RN(TMP_ZERO) | RM(SLJIT_R0))); in sljit_emit_op0()
1270 FAIL_IF(push_inst(compiler, MADD | RD(SLJIT_R0) | RN(SLJIT_R0) | RM(SLJIT_R1) | RT2(TMP_ZERO))); in sljit_emit_op0()
1271 …return push_inst(compiler, (op == SLJIT_LMUL_UW ? UMULH : SMULH) | RD(SLJIT_R1) | RN(TMP_REG1) | R… in sljit_emit_op0()
1274 FAIL_IF(push_inst(compiler, (ORR ^ inv_bits) | RD(TMP_REG1) | RN(TMP_ZERO) | RM(SLJIT_R0))); in sljit_emit_op0()
1275 …FAIL_IF(push_inst(compiler, ((op == SLJIT_DIVMOD_UW ? UDIV : SDIV) ^ inv_bits) | RD(SLJIT_R0) | RN… in sljit_emit_op0()
1276 …FAIL_IF(push_inst(compiler, (MADD ^ inv_bits) | RD(SLJIT_R1) | RN(SLJIT_R0) | RM(SLJIT_R1) | RT2(T… in sljit_emit_op0()
1277 return push_inst(compiler, (SUB ^ inv_bits) | RD(SLJIT_R1) | RN(TMP_REG1) | RM(SLJIT_R1)); in sljit_emit_op0()
1280 …return push_inst(compiler, ((op == SLJIT_DIV_UW ? UDIV : SDIV) ^ inv_bits) | RD(SLJIT_R0) | RN(SLJ… in sljit_emit_op0()
1286 SLJIT_API_FUNC_ATTRIBUTE sljit_s32 sljit_emit_op1(struct sljit_compiler *compiler, sljit_s32 op, in sljit_emit_op1() argument
1294 CHECK(check_sljit_emit_op1(compiler, op, dst, dstw, src, srcw)); in sljit_emit_op1()
1298 compiler->cache_arg = 0; in sljit_emit_op1()
1299 compiler->cache_argw = 0; in sljit_emit_op1()
1381 FAIL_IF(emit_op_imm(compiler, SLJIT_MOV | ARG2_IMM, dst_r, TMP_REG1, srcw)); in sljit_emit_op1()
1383 if (getput_arg_fast(compiler, flags, dst_r, src, srcw)) in sljit_emit_op1()
1384 FAIL_IF(compiler->error); in sljit_emit_op1()
1386 FAIL_IF(getput_arg(compiler, flags, dst_r, src, srcw, dst, dstw)); in sljit_emit_op1()
1389 … return emit_op_imm(compiler, op | ((op_flags & SLJIT_I32_OP) ? INT_OP : 0), dst_r, TMP_REG1, src); in sljit_emit_op1()
1394 if (getput_arg_fast(compiler, flags | STORE, dst_r, dst, dstw)) in sljit_emit_op1()
1395 return compiler->error; in sljit_emit_op1()
1397 return getput_arg(compiler, flags | STORE, dst_r, dst, dstw, 0, 0); in sljit_emit_op1()
1413 if (getput_arg_fast(compiler, mem_flags, TMP_REG2, src, srcw)) in sljit_emit_op1()
1414 FAIL_IF(compiler->error); in sljit_emit_op1()
1416 FAIL_IF(getput_arg(compiler, mem_flags, TMP_REG2, src, srcw, dst, dstw)); in sljit_emit_op1()
1427 emit_op_imm(compiler, flags | op, dst_r, TMP_REG1, srcw); in sljit_emit_op1()
1430 if (getput_arg_fast(compiler, mem_flags | STORE, dst_r, dst, dstw)) in sljit_emit_op1()
1431 return compiler->error; in sljit_emit_op1()
1433 return getput_arg(compiler, mem_flags | STORE, dst_r, dst, dstw, 0, 0); in sljit_emit_op1()
1438 SLJIT_API_FUNC_ATTRIBUTE sljit_s32 sljit_emit_op2(struct sljit_compiler *compiler, sljit_s32 op, in sljit_emit_op2() argument
1446 CHECK(check_sljit_emit_op2(compiler, op, dst, dstw, src1, src1w, src2, src2w)); in sljit_emit_op2()
1451 compiler->cache_arg = 0; in sljit_emit_op2()
1452 compiler->cache_argw = 0; in sljit_emit_op2()
1465 …if ((dst & SLJIT_MEM) && !getput_arg_fast(compiler, mem_flags | STORE | ARG_TEST, TMP_REG1, dst, d… in sljit_emit_op2()
1469 if (getput_arg_fast(compiler, mem_flags, TMP_REG1, src1, src1w)) in sljit_emit_op2()
1470 FAIL_IF(compiler->error); in sljit_emit_op2()
1475 if (getput_arg_fast(compiler, mem_flags, TMP_REG2, src2, src2w)) in sljit_emit_op2()
1476 FAIL_IF(compiler->error); in sljit_emit_op2()
1483 FAIL_IF(getput_arg(compiler, mem_flags, TMP_REG2, src2, src2w, src1, src1w)); in sljit_emit_op2()
1484 FAIL_IF(getput_arg(compiler, mem_flags, TMP_REG1, src1, src1w, dst, dstw)); in sljit_emit_op2()
1487 FAIL_IF(getput_arg(compiler, mem_flags, TMP_REG1, src1, src1w, src2, src2w)); in sljit_emit_op2()
1488 FAIL_IF(getput_arg(compiler, mem_flags, TMP_REG2, src2, src2w, dst, dstw)); in sljit_emit_op2()
1492 FAIL_IF(getput_arg(compiler, mem_flags, TMP_REG1, src1, src1w, dst, dstw)); in sljit_emit_op2()
1494 FAIL_IF(getput_arg(compiler, mem_flags, TMP_REG2, src2, src2w, dst, dstw)); in sljit_emit_op2()
1510 emit_op_imm(compiler, flags | GET_OPCODE(op), dst_r, src1w, src2w); in sljit_emit_op2()
1514 getput_arg_fast(compiler, mem_flags | STORE, dst_r, dst, dstw); in sljit_emit_op2()
1515 return compiler->error; in sljit_emit_op2()
1517 return getput_arg(compiler, mem_flags | STORE, TMP_REG1, dst, dstw, 0, 0); in sljit_emit_op2()
1535 SLJIT_API_FUNC_ATTRIBUTE sljit_s32 sljit_emit_op_custom(struct sljit_compiler *compiler, in sljit_emit_op_custom() argument
1539 CHECK(check_sljit_emit_op_custom(compiler, instruction, size)); in sljit_emit_op_custom()
1541 return push_inst(compiler, *(sljit_ins*)instruction); in sljit_emit_op_custom()
1558 static sljit_s32 emit_fop_mem(struct sljit_compiler *compiler, sljit_s32 flags, sljit_s32 reg, slji… in emit_fop_mem() argument
1573 return push_inst(compiler, STR_FR | ins_bits | VT(reg) in emit_fop_mem()
1577 FAIL_IF(push_inst(compiler, ADD | RD(TMP_REG1) | RN(arg) | RM(other_r) | (argw << 10))); in emit_fop_mem()
1584 return push_inst(compiler, STR_FI | ins_bits | VT(reg) | RN(arg) | (argw << (10 - shift))); in emit_fop_mem()
1587 return push_inst(compiler, STUR_FI | ins_bits | VT(reg) | RN(arg) | ((argw & 0x1ff) << 12)); in emit_fop_mem()
1590 if (compiler->cache_arg == SLJIT_MEM && argw != compiler->cache_argw) { in emit_fop_mem()
1591 diff = argw - compiler->cache_argw; in emit_fop_mem()
1593 return push_inst(compiler, STUR_FI | ins_bits | VT(reg) | RN(TMP_REG3) | ((diff & 0x1ff) << 12)); in emit_fop_mem()
1594 …if (emit_set_delta(compiler, TMP_REG3, TMP_REG3, argw - compiler->cache_argw) != SLJIT_ERR_UNSUPPO… in emit_fop_mem()
1595 FAIL_IF(compiler->error); in emit_fop_mem()
1596 compiler->cache_argw = argw; in emit_fop_mem()
1600 if (compiler->cache_arg != SLJIT_MEM || argw != compiler->cache_argw) { in emit_fop_mem()
1601 compiler->cache_arg = SLJIT_MEM; in emit_fop_mem()
1602 compiler->cache_argw = argw; in emit_fop_mem()
1603 FAIL_IF(load_immediate(compiler, TMP_REG3, argw)); in emit_fop_mem()
1607 return push_inst(compiler, STR_FR | ins_bits | VT(reg) | RN(arg) | RM(TMP_REG3)); in emit_fop_mem()
1608 return push_inst(compiler, STR_FI | ins_bits | VT(reg) | RN(TMP_REG3)); in emit_fop_mem()
1611 static SLJIT_INLINE sljit_s32 sljit_emit_fop1_conv_sw_from_f64(struct sljit_compiler *compiler, slj… in sljit_emit_fop1_conv_sw_from_f64() argument
1622 emit_fop_mem(compiler, (op & SLJIT_F32_OP) ? INT_SIZE : WORD_SIZE, TMP_FREG1, src, srcw); in sljit_emit_fop1_conv_sw_from_f64()
1626 FAIL_IF(push_inst(compiler, (FCVTZS ^ inv_bits) | RD(dst_r) | VN(src))); in sljit_emit_fop1_conv_sw_from_f64()
1629 …return emit_op_mem(compiler, ((GET_OPCODE(op) == SLJIT_CONV_S32_FROM_F64) ? INT_SIZE : WORD_SIZE) … in sljit_emit_fop1_conv_sw_from_f64()
1633 static SLJIT_INLINE sljit_s32 sljit_emit_fop1_conv_f64_from_sw(struct sljit_compiler *compiler, slj… in sljit_emit_fop1_conv_f64_from_sw() argument
1644 …emit_op_mem(compiler, ((GET_OPCODE(op) == SLJIT_CONV_F64_FROM_S32) ? INT_SIZE : WORD_SIZE), TMP_RE… in sljit_emit_fop1_conv_f64_from_sw()
1651 FAIL_IF(load_immediate(compiler, TMP_REG1, srcw)); in sljit_emit_fop1_conv_f64_from_sw()
1655 FAIL_IF(push_inst(compiler, (SCVTF ^ inv_bits) | VD(dst_r) | RN(src))); in sljit_emit_fop1_conv_f64_from_sw()
1658 …return emit_fop_mem(compiler, ((op & SLJIT_F32_OP) ? INT_SIZE : WORD_SIZE) | STORE, TMP_FREG1, dst… in sljit_emit_fop1_conv_f64_from_sw()
1662 static SLJIT_INLINE sljit_s32 sljit_emit_fop1_cmp(struct sljit_compiler *compiler, sljit_s32 op, in sljit_emit_fop1_cmp() argument
1670 emit_fop_mem(compiler, mem_flags, TMP_FREG1, src1, src1w); in sljit_emit_fop1_cmp()
1675 emit_fop_mem(compiler, mem_flags, TMP_FREG2, src2, src2w); in sljit_emit_fop1_cmp()
1679 return push_inst(compiler, (FCMP ^ inv_bits) | VN(src1) | VM(src2)); in sljit_emit_fop1_cmp()
1682 SLJIT_API_FUNC_ATTRIBUTE sljit_s32 sljit_emit_fop1(struct sljit_compiler *compiler, sljit_s32 op, in sljit_emit_fop1() argument
1690 compiler->cache_arg = 0; in sljit_emit_fop1()
1691 compiler->cache_argw = 0; in sljit_emit_fop1()
1694 SELECT_FOP1_OPERATION_WITH_CHECKS(compiler, op, dst, dstw, src, srcw); in sljit_emit_fop1()
1700 …emit_fop_mem(compiler, (GET_OPCODE(op) == SLJIT_CONV_F64_FROM_F32) ? (mem_flags ^ 0x100) : mem_fla… in sljit_emit_fop1()
1708 FAIL_IF(push_inst(compiler, (FMOV ^ inv_bits) | VD(dst_r) | VN(src))); in sljit_emit_fop1()
1714 FAIL_IF(push_inst(compiler, (FNEG ^ inv_bits) | VD(dst_r) | VN(src))); in sljit_emit_fop1()
1717 FAIL_IF(push_inst(compiler, (FABS ^ inv_bits) | VD(dst_r) | VN(src))); in sljit_emit_fop1()
1720 …FAIL_IF(push_inst(compiler, FCVT | ((op & SLJIT_F32_OP) ? (1 << 22) : (1 << 15)) | VD(dst_r) | VN(… in sljit_emit_fop1()
1725 return emit_fop_mem(compiler, mem_flags | STORE, dst_r, dst, dstw); in sljit_emit_fop1()
1729 SLJIT_API_FUNC_ATTRIBUTE sljit_s32 sljit_emit_fop2(struct sljit_compiler *compiler, sljit_s32 op, in sljit_emit_fop2() argument
1738 CHECK(check_sljit_emit_fop2(compiler, op, dst, dstw, src1, src1w, src2, src2w)); in sljit_emit_fop2()
1743 compiler->cache_arg = 0; in sljit_emit_fop2()
1744 compiler->cache_argw = 0; in sljit_emit_fop2()
1748 emit_fop_mem(compiler, mem_flags, TMP_FREG1, src1, src1w); in sljit_emit_fop2()
1752 emit_fop_mem(compiler, mem_flags, TMP_FREG2, src2, src2w); in sljit_emit_fop2()
1758 FAIL_IF(push_inst(compiler, (FADD ^ inv_bits) | VD(dst_r) | VN(src1) | VM(src2))); in sljit_emit_fop2()
1761 FAIL_IF(push_inst(compiler, (FSUB ^ inv_bits) | VD(dst_r) | VN(src1) | VM(src2))); in sljit_emit_fop2()
1764 FAIL_IF(push_inst(compiler, (FMUL ^ inv_bits) | VD(dst_r) | VN(src1) | VM(src2))); in sljit_emit_fop2()
1767 FAIL_IF(push_inst(compiler, (FDIV ^ inv_bits) | VD(dst_r) | VN(src1) | VM(src2))); in sljit_emit_fop2()
1773 return emit_fop_mem(compiler, mem_flags | STORE, TMP_FREG1, dst, dstw); in sljit_emit_fop2()
1780 SLJIT_API_FUNC_ATTRIBUTE sljit_s32 sljit_emit_fast_enter(struct sljit_compiler *compiler, sljit_s32… in sljit_emit_fast_enter() argument
1783 CHECK(check_sljit_emit_fast_enter(compiler, dst, dstw)); in sljit_emit_fast_enter()
1791 return push_inst(compiler, ORR | RD(dst) | RN(TMP_ZERO) | RM(TMP_LR)); in sljit_emit_fast_enter()
1794 return emit_op_mem(compiler, WORD_SIZE | STORE, TMP_LR, dst, dstw); in sljit_emit_fast_enter()
1797 SLJIT_API_FUNC_ATTRIBUTE sljit_s32 sljit_emit_fast_return(struct sljit_compiler *compiler, sljit_s3… in sljit_emit_fast_return() argument
1800 CHECK(check_sljit_emit_fast_return(compiler, src, srcw)); in sljit_emit_fast_return()
1804 FAIL_IF(push_inst(compiler, ORR | RD(TMP_LR) | RN(TMP_ZERO) | RM(src))); in sljit_emit_fast_return()
1806 FAIL_IF(emit_op_mem(compiler, WORD_SIZE, TMP_LR, src, srcw)); in sljit_emit_fast_return()
1808 FAIL_IF(load_immediate(compiler, TMP_LR, srcw)); in sljit_emit_fast_return()
1810 return push_inst(compiler, RET | RN(TMP_LR)); in sljit_emit_fast_return()
1872 SLJIT_API_FUNC_ATTRIBUTE struct sljit_label* sljit_emit_label(struct sljit_compiler *compiler) in sljit_emit_label() argument
1877 CHECK_PTR(check_sljit_emit_label(compiler)); in sljit_emit_label()
1879 if (compiler->last_label && compiler->last_label->size == compiler->size) in sljit_emit_label()
1880 return compiler->last_label; in sljit_emit_label()
1882 label = (struct sljit_label*)ensure_abuf(compiler, sizeof(struct sljit_label)); in sljit_emit_label()
1884 set_label(label, compiler); in sljit_emit_label()
1888 SLJIT_API_FUNC_ATTRIBUTE struct sljit_jump* sljit_emit_jump(struct sljit_compiler *compiler, sljit_… in sljit_emit_jump() argument
1893 CHECK_PTR(check_sljit_emit_jump(compiler, type)); in sljit_emit_jump()
1895 jump = (struct sljit_jump*)ensure_abuf(compiler, sizeof(struct sljit_jump)); in sljit_emit_jump()
1897 set_jump(jump, compiler, type & SLJIT_REWRITABLE_JUMP); in sljit_emit_jump()
1902 PTR_FAIL_IF(push_inst(compiler, B_CC | (6 << 5) | get_cc(type))); in sljit_emit_jump()
1907 PTR_FAIL_IF(emit_imm64_const(compiler, TMP_REG1, 0)); in sljit_emit_jump()
1908 jump->addr = compiler->size; in sljit_emit_jump()
1909 PTR_FAIL_IF(push_inst(compiler, ((type >= SLJIT_FAST_CALL) ? BLR : BR) | RN(TMP_REG1))); in sljit_emit_jump()
1914 static SLJIT_INLINE struct sljit_jump* emit_cmp_to0(struct sljit_compiler *compiler, sljit_s32 type, in emit_cmp_to0() argument
1923 jump = (struct sljit_jump*)ensure_abuf(compiler, sizeof(struct sljit_jump)); in emit_cmp_to0()
1925 set_jump(jump, compiler, type & SLJIT_REWRITABLE_JUMP); in emit_cmp_to0()
1929 PTR_FAIL_IF(emit_op_mem(compiler, inv_bits ? INT_SIZE : WORD_SIZE, TMP_REG1, src, srcw)); in emit_cmp_to0()
1933 PTR_FAIL_IF(load_immediate(compiler, TMP_REG1, srcw)); in emit_cmp_to0()
1941 PTR_FAIL_IF(push_inst(compiler, (CBZ ^ inv_bits) | (6 << 5) | RT(src))); in emit_cmp_to0()
1942 PTR_FAIL_IF(emit_imm64_const(compiler, TMP_REG1, 0)); in emit_cmp_to0()
1943 jump->addr = compiler->size; in emit_cmp_to0()
1944 PTR_FAIL_IF(push_inst(compiler, BR | RN(TMP_REG1))); in emit_cmp_to0()
1948 SLJIT_API_FUNC_ATTRIBUTE sljit_s32 sljit_emit_ijump(struct sljit_compiler *compiler, sljit_s32 type… in sljit_emit_ijump() argument
1953 CHECK(check_sljit_emit_ijump(compiler, type, src, srcw)); in sljit_emit_ijump()
1959 FAIL_IF(emit_op_mem(compiler, WORD_SIZE, TMP_REG1, src, srcw)); in sljit_emit_ijump()
1962 return push_inst(compiler, ((type >= SLJIT_FAST_CALL) ? BLR : BR) | RN(src)); in sljit_emit_ijump()
1965 jump = (struct sljit_jump*)ensure_abuf(compiler, sizeof(struct sljit_jump)); in sljit_emit_ijump()
1967 set_jump(jump, compiler, JUMP_ADDR | ((type >= SLJIT_FAST_CALL) ? IS_BL : 0)); in sljit_emit_ijump()
1970 FAIL_IF(emit_imm64_const(compiler, TMP_REG1, 0)); in sljit_emit_ijump()
1971 jump->addr = compiler->size; in sljit_emit_ijump()
1972 return push_inst(compiler, ((type >= SLJIT_FAST_CALL) ? BLR : BR) | RN(TMP_REG1)); in sljit_emit_ijump()
1975 SLJIT_API_FUNC_ATTRIBUTE sljit_s32 sljit_emit_op_flags(struct sljit_compiler *compiler, sljit_s32 o… in sljit_emit_op_flags() argument
1984 CHECK(check_sljit_emit_op_flags(compiler, op, dst, dstw, src, srcw, type)); in sljit_emit_op_flags()
1995 FAIL_IF(push_inst(compiler, CSINC | (cc << 12) | RD(dst_r) | RN(TMP_ZERO) | RM(TMP_ZERO))); in sljit_emit_op_flags()
1998 …return emit_op_mem(compiler, (GET_OPCODE(op) == SLJIT_MOV ? WORD_SIZE : INT_SIZE) | STORE, TMP_REG… in sljit_emit_op_flags()
2001 compiler->cache_arg = 0; in sljit_emit_op_flags()
2002 compiler->cache_argw = 0; in sljit_emit_op_flags()
2011 FAIL_IF(emit_op_mem2(compiler, mem_flags, TMP_REG1, src, srcw, dst, dstw)); in sljit_emit_op_flags()
2017 FAIL_IF(push_inst(compiler, CSINC | (cc << 12) | RD(TMP_REG2) | RN(TMP_ZERO) | RM(TMP_ZERO))); in sljit_emit_op_flags()
2018 emit_op_imm(compiler, flags | GET_OPCODE(op), dst_r, src, TMP_REG2); in sljit_emit_op_flags()
2022 return emit_op_mem2(compiler, mem_flags | STORE, TMP_REG1, dst, dstw, 0, 0); in sljit_emit_op_flags()
2025 SLJIT_API_FUNC_ATTRIBUTE struct sljit_const* sljit_emit_const(struct sljit_compiler *compiler, slji… in sljit_emit_const() argument
2031 CHECK_PTR(check_sljit_emit_const(compiler, dst, dstw, init_value)); in sljit_emit_const()
2034 const_ = (struct sljit_const*)ensure_abuf(compiler, sizeof(struct sljit_const)); in sljit_emit_const()
2036 set_const(const_, compiler); in sljit_emit_const()
2039 PTR_FAIL_IF(emit_imm64_const(compiler, dst_r, init_value)); in sljit_emit_const()
2042 PTR_FAIL_IF(emit_op_mem(compiler, WORD_SIZE | STORE, dst_r, dst, dstw)); in sljit_emit_const()