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()
1090 FAIL_IF(push_inst(compiler, SUBI | RD(TMP_SP) | RN(TMP_SP) | (saved_regs_size << 10))); in sljit_emit_enter()
1100 FAIL_IF(push_inst(compiler, STP | RT(prev) | RT2(i) | RN(TMP_SP) | offs)); in sljit_emit_enter()
1110 FAIL_IF(push_inst(compiler, STP | RT(prev) | RT2(i) | RN(TMP_SP) | offs)); in sljit_emit_enter()
1116 FAIL_IF(push_inst(compiler, STRI | RT(prev) | RN(TMP_SP) | (offs >> 5))); in sljit_emit_enter()
1118 if (compiler->local_size > (63 * sizeof(sljit_sw))) { in sljit_emit_enter()
1121 …FAIL_IF(push_inst(compiler, SUBI | RD(TMP_SP) | RN(TMP_SP) | ((local_size >> 12) << 10) | (1 << 22… in sljit_emit_enter()
1125 FAIL_IF(push_inst(compiler, SUBI | RD(TMP_SP) | RN(TMP_SP) | (local_size << 10))); in sljit_emit_enter()
1126 FAIL_IF(push_inst(compiler, STP_PRE | 29 | RT2(TMP_LR) in sljit_emit_enter()
1128 FAIL_IF(push_inst(compiler, ADDI | RD(SLJIT_SP) | RN(TMP_SP) | (0 << 10))); in sljit_emit_enter()
1132 FAIL_IF(push_inst(compiler, ORR | RD(SLJIT_S0) | RN(TMP_ZERO) | RM(SLJIT_R0))); in sljit_emit_enter()
1134 FAIL_IF(push_inst(compiler, ORR | RD(SLJIT_S1) | RN(TMP_ZERO) | RM(SLJIT_R1))); in sljit_emit_enter()
1136 FAIL_IF(push_inst(compiler, ORR | RD(SLJIT_S2) | RN(TMP_ZERO) | RM(SLJIT_R2))); in sljit_emit_enter()
1141 SLJIT_API_FUNC_ATTRIBUTE sljit_si sljit_set_context(struct sljit_compiler *compiler, in sljit_set_context() argument
1146 …CHECK(check_sljit_set_context(compiler, options, args, scratches, saveds, fscratches, fsaveds, loc… in sljit_set_context()
1147 set_set_context(compiler, options, args, scratches, saveds, fscratches, fsaveds, local_size); in sljit_set_context()
1151 compiler->local_size = local_size; in sljit_set_context()
1155 SLJIT_API_FUNC_ATTRIBUTE sljit_si sljit_emit_return(struct sljit_compiler *compiler, sljit_si op, s… in sljit_emit_return() argument
1161 CHECK(check_sljit_emit_return(compiler, op, src, srcw)); in sljit_emit_return()
1163 FAIL_IF(emit_mov_before_return(compiler, op, src, srcw)); in sljit_emit_return()
1165 local_size = compiler->local_size; in sljit_emit_return()
1167 saved_regs_size = GET_SAVED_REGISTERS_SIZE(compiler->scratches, compiler->saveds, 0); in sljit_emit_return()
1171 FAIL_IF(push_inst(compiler, LDP_PST | 29 | RT2(TMP_LR) in sljit_emit_return()
1180 …FAIL_IF(push_inst(compiler, ADDI | RD(TMP_SP) | RN(TMP_SP) | ((local_size >> 12) << 10) | (1 << 22… in sljit_emit_return()
1184 FAIL_IF(push_inst(compiler, ADDI | RD(TMP_SP) | RN(TMP_SP) | (local_size << 10))); in sljit_emit_return()
1187 …tmp = compiler->saveds < SLJIT_NUMBER_OF_SAVED_REGISTERS ? (SLJIT_S0 + 1 - compiler->saveds) : SLJ… in sljit_emit_return()
1194 FAIL_IF(push_inst(compiler, LDP | RT(prev) | RT2(i) | RN(TMP_SP) | offs)); in sljit_emit_return()
1199 for (i = compiler->scratches; i >= SLJIT_FIRST_SAVED_REG; i--) { in sljit_emit_return()
1204 FAIL_IF(push_inst(compiler, LDP | RT(prev) | RT2(i) | RN(TMP_SP) | offs)); in sljit_emit_return()
1210 FAIL_IF(push_inst(compiler, LDRI | RT(prev) | RN(TMP_SP) | (offs >> 5))); in sljit_emit_return()
1212 if (compiler->local_size <= (63 * sizeof(sljit_sw))) { in sljit_emit_return()
1213 FAIL_IF(push_inst(compiler, LDP_PST | 29 | RT2(TMP_LR) in sljit_emit_return()
1216 FAIL_IF(push_inst(compiler, ADDI | RD(TMP_SP) | RN(TMP_SP) | (saved_regs_size << 10))); in sljit_emit_return()
1219 FAIL_IF(push_inst(compiler, RET | RN(TMP_LR))); in sljit_emit_return()
1227 SLJIT_API_FUNC_ATTRIBUTE sljit_si sljit_emit_op0(struct sljit_compiler *compiler, sljit_si op) in sljit_emit_op0() argument
1232 CHECK(check_sljit_emit_op0(compiler, op)); in sljit_emit_op0()
1237 return push_inst(compiler, BRK); in sljit_emit_op0()
1239 return push_inst(compiler, NOP); in sljit_emit_op0()
1242 FAIL_IF(push_inst(compiler, ORR | RD(TMP_REG1) | RN(TMP_ZERO) | RM(SLJIT_R0))); in sljit_emit_op0()
1243 FAIL_IF(push_inst(compiler, MADD | RD(SLJIT_R0) | RN(SLJIT_R0) | RM(SLJIT_R1) | RT2(TMP_ZERO))); in sljit_emit_op0()
1244 …return push_inst(compiler, (op == SLJIT_LUMUL ? UMULH : SMULH) | RD(SLJIT_R1) | RN(TMP_REG1) | RM(… in sljit_emit_op0()
1247 FAIL_IF(push_inst(compiler, (ORR ^ inv_bits) | RD(TMP_REG1) | RN(TMP_ZERO) | RM(SLJIT_R0))); in sljit_emit_op0()
1248 …FAIL_IF(push_inst(compiler, ((op == SLJIT_LUDIV ? UDIV : SDIV) ^ inv_bits) | RD(SLJIT_R0) | RN(SLJ… in sljit_emit_op0()
1249 …FAIL_IF(push_inst(compiler, (MADD ^ inv_bits) | RD(SLJIT_R1) | RN(SLJIT_R0) | RM(SLJIT_R1) | RT2(T… in sljit_emit_op0()
1250 return push_inst(compiler, (SUB ^ inv_bits) | RD(SLJIT_R1) | RN(TMP_REG1) | RM(SLJIT_R1)); in sljit_emit_op0()
1256 SLJIT_API_FUNC_ATTRIBUTE sljit_si sljit_emit_op1(struct sljit_compiler *compiler, sljit_si op, in sljit_emit_op1() argument
1264 CHECK(check_sljit_emit_op1(compiler, op, dst, dstw, src, srcw)); in sljit_emit_op1()
1268 compiler->cache_arg = 0; in sljit_emit_op1()
1269 compiler->cache_argw = 0; in sljit_emit_op1()
1351 FAIL_IF(emit_op_imm(compiler, SLJIT_MOV | ARG2_IMM, dst_r, TMP_REG1, srcw)); in sljit_emit_op1()
1353 if (getput_arg_fast(compiler, flags, dst_r, src, srcw)) in sljit_emit_op1()
1354 FAIL_IF(compiler->error); in sljit_emit_op1()
1356 FAIL_IF(getput_arg(compiler, flags, dst_r, src, srcw, dst, dstw)); in sljit_emit_op1()
1359 … return emit_op_imm(compiler, op | ((op_flags & SLJIT_INT_OP) ? INT_OP : 0), dst_r, TMP_REG1, src); in sljit_emit_op1()
1364 if (getput_arg_fast(compiler, flags | STORE, dst_r, dst, dstw)) in sljit_emit_op1()
1365 return compiler->error; in sljit_emit_op1()
1367 return getput_arg(compiler, flags | STORE, dst_r, dst, dstw, 0, 0); in sljit_emit_op1()
1383 if (getput_arg_fast(compiler, mem_flags, TMP_REG2, src, srcw)) in sljit_emit_op1()
1384 FAIL_IF(compiler->error); in sljit_emit_op1()
1386 FAIL_IF(getput_arg(compiler, mem_flags, TMP_REG2, src, srcw, dst, dstw)); in sljit_emit_op1()
1397 emit_op_imm(compiler, flags | op, dst_r, TMP_REG1, srcw); in sljit_emit_op1()
1400 if (getput_arg_fast(compiler, mem_flags | STORE, dst_r, dst, dstw)) in sljit_emit_op1()
1401 return compiler->error; in sljit_emit_op1()
1403 return getput_arg(compiler, mem_flags | STORE, dst_r, dst, dstw, 0, 0); in sljit_emit_op1()
1408 SLJIT_API_FUNC_ATTRIBUTE sljit_si sljit_emit_op2(struct sljit_compiler *compiler, sljit_si op, in sljit_emit_op2() argument
1416 CHECK(check_sljit_emit_op2(compiler, op, dst, dstw, src1, src1w, src2, src2w)); in sljit_emit_op2()
1421 compiler->cache_arg = 0; in sljit_emit_op2()
1422 compiler->cache_argw = 0; in sljit_emit_op2()
1435 …if ((dst & SLJIT_MEM) && !getput_arg_fast(compiler, mem_flags | STORE | ARG_TEST, TMP_REG1, dst, d… in sljit_emit_op2()
1439 if (getput_arg_fast(compiler, mem_flags, TMP_REG1, src1, src1w)) in sljit_emit_op2()
1440 FAIL_IF(compiler->error); in sljit_emit_op2()
1445 if (getput_arg_fast(compiler, mem_flags, TMP_REG2, src2, src2w)) in sljit_emit_op2()
1446 FAIL_IF(compiler->error); in sljit_emit_op2()
1453 FAIL_IF(getput_arg(compiler, mem_flags, TMP_REG2, src2, src2w, src1, src1w)); in sljit_emit_op2()
1454 FAIL_IF(getput_arg(compiler, mem_flags, TMP_REG1, src1, src1w, dst, dstw)); in sljit_emit_op2()
1457 FAIL_IF(getput_arg(compiler, mem_flags, TMP_REG1, src1, src1w, src2, src2w)); in sljit_emit_op2()
1458 FAIL_IF(getput_arg(compiler, mem_flags, TMP_REG2, src2, src2w, dst, dstw)); in sljit_emit_op2()
1462 FAIL_IF(getput_arg(compiler, mem_flags, TMP_REG1, src1, src1w, dst, dstw)); in sljit_emit_op2()
1464 FAIL_IF(getput_arg(compiler, mem_flags, TMP_REG2, src2, src2w, dst, dstw)); in sljit_emit_op2()
1480 emit_op_imm(compiler, flags | GET_OPCODE(op), dst_r, src1w, src2w); in sljit_emit_op2()
1484 getput_arg_fast(compiler, mem_flags | STORE, dst_r, dst, dstw); in sljit_emit_op2()
1485 return compiler->error; in sljit_emit_op2()
1487 return getput_arg(compiler, mem_flags | STORE, TMP_REG1, dst, dstw, 0, 0); in sljit_emit_op2()
1505 SLJIT_API_FUNC_ATTRIBUTE sljit_si sljit_emit_op_custom(struct sljit_compiler *compiler, in sljit_emit_op_custom() argument
1509 CHECK(check_sljit_emit_op_custom(compiler, instruction, size)); in sljit_emit_op_custom()
1511 return push_inst(compiler, *(sljit_ins*)instruction); in sljit_emit_op_custom()
1528 static sljit_si emit_fop_mem(struct sljit_compiler *compiler, sljit_si flags, sljit_si reg, sljit_s… in emit_fop_mem() argument
1543 return push_inst(compiler, STR_FR | ins_bits | VT(reg) in emit_fop_mem()
1547 FAIL_IF(push_inst(compiler, ADD | RD(TMP_REG1) | RN(arg) | RM(other_r) | (argw << 10))); in emit_fop_mem()
1554 return push_inst(compiler, STR_FI | ins_bits | VT(reg) | RN(arg) | (argw << (10 - shift))); in emit_fop_mem()
1557 return push_inst(compiler, STUR_FI | ins_bits | VT(reg) | RN(arg) | ((argw & 0x1ff) << 12)); in emit_fop_mem()
1560 if (compiler->cache_arg == SLJIT_MEM && argw != compiler->cache_argw) { in emit_fop_mem()
1561 diff = argw - compiler->cache_argw; in emit_fop_mem()
1563 return push_inst(compiler, STUR_FI | ins_bits | VT(reg) | RN(TMP_REG3) | ((diff & 0x1ff) << 12)); in emit_fop_mem()
1564 …if (emit_set_delta(compiler, TMP_REG3, TMP_REG3, argw - compiler->cache_argw) != SLJIT_ERR_UNSUPPO… in emit_fop_mem()
1565 FAIL_IF(compiler->error); in emit_fop_mem()
1566 compiler->cache_argw = argw; in emit_fop_mem()
1570 if (compiler->cache_arg != SLJIT_MEM || argw != compiler->cache_argw) { in emit_fop_mem()
1571 compiler->cache_arg = SLJIT_MEM; in emit_fop_mem()
1572 compiler->cache_argw = argw; in emit_fop_mem()
1573 FAIL_IF(load_immediate(compiler, TMP_REG3, argw)); in emit_fop_mem()
1577 return push_inst(compiler, STR_FR | ins_bits | VT(reg) | RN(arg) | RM(TMP_REG3)); in emit_fop_mem()
1578 return push_inst(compiler, STR_FI | ins_bits | VT(reg) | RN(TMP_REG3)); in emit_fop_mem()
1581 static SLJIT_INLINE sljit_si sljit_emit_fop1_convw_fromd(struct sljit_compiler *compiler, sljit_si … in sljit_emit_fop1_convw_fromd() argument
1592 emit_fop_mem(compiler, (op & SLJIT_SINGLE_OP) ? INT_SIZE : WORD_SIZE, TMP_FREG1, src, srcw); in sljit_emit_fop1_convw_fromd()
1596 FAIL_IF(push_inst(compiler, (FCVTZS ^ inv_bits) | RD(dst_r) | VN(src))); in sljit_emit_fop1_convw_fromd()
1599 …return emit_op_mem(compiler, ((GET_OPCODE(op) == SLJIT_CONVI_FROMD) ? INT_SIZE : WORD_SIZE) | STOR… in sljit_emit_fop1_convw_fromd()
1603 static SLJIT_INLINE sljit_si sljit_emit_fop1_convd_fromw(struct sljit_compiler *compiler, sljit_si … in sljit_emit_fop1_convd_fromw() argument
1614 …emit_op_mem(compiler, ((GET_OPCODE(op) == SLJIT_CONVD_FROMI) ? INT_SIZE : WORD_SIZE), TMP_REG1, sr… in sljit_emit_fop1_convd_fromw()
1621 FAIL_IF(load_immediate(compiler, TMP_REG1, srcw)); in sljit_emit_fop1_convd_fromw()
1625 FAIL_IF(push_inst(compiler, (SCVTF ^ inv_bits) | VD(dst_r) | RN(src))); in sljit_emit_fop1_convd_fromw()
1628 …return emit_fop_mem(compiler, ((op & SLJIT_SINGLE_OP) ? INT_SIZE : WORD_SIZE) | STORE, TMP_FREG1, … in sljit_emit_fop1_convd_fromw()
1632 static SLJIT_INLINE sljit_si sljit_emit_fop1_cmp(struct sljit_compiler *compiler, sljit_si op, in sljit_emit_fop1_cmp() argument
1640 emit_fop_mem(compiler, mem_flags, TMP_FREG1, src1, src1w); in sljit_emit_fop1_cmp()
1645 emit_fop_mem(compiler, mem_flags, TMP_FREG2, src2, src2w); in sljit_emit_fop1_cmp()
1649 return push_inst(compiler, (FCMP ^ inv_bits) | VN(src1) | VM(src2)); in sljit_emit_fop1_cmp()
1652 SLJIT_API_FUNC_ATTRIBUTE sljit_si sljit_emit_fop1(struct sljit_compiler *compiler, sljit_si op, in sljit_emit_fop1() argument
1660 compiler->cache_arg = 0; in sljit_emit_fop1()
1661 compiler->cache_argw = 0; in sljit_emit_fop1()
1664 SELECT_FOP1_OPERATION_WITH_CHECKS(compiler, op, dst, dstw, src, srcw); in sljit_emit_fop1()
1670 …emit_fop_mem(compiler, (GET_OPCODE(op) == SLJIT_CONVD_FROMS) ? (mem_flags ^ 0x100) : mem_flags, ds… in sljit_emit_fop1()
1678 FAIL_IF(push_inst(compiler, (FMOV ^ inv_bits) | VD(dst_r) | VN(src))); in sljit_emit_fop1()
1684 FAIL_IF(push_inst(compiler, (FNEG ^ inv_bits) | VD(dst_r) | VN(src))); in sljit_emit_fop1()
1687 FAIL_IF(push_inst(compiler, (FABS ^ inv_bits) | VD(dst_r) | VN(src))); in sljit_emit_fop1()
1690 …FAIL_IF(push_inst(compiler, FCVT | ((op & SLJIT_SINGLE_OP) ? (1 << 22) : (1 << 15)) | VD(dst_r) | … in sljit_emit_fop1()
1695 return emit_fop_mem(compiler, mem_flags | STORE, dst_r, dst, dstw); in sljit_emit_fop1()
1699 SLJIT_API_FUNC_ATTRIBUTE sljit_si sljit_emit_fop2(struct sljit_compiler *compiler, sljit_si op, in sljit_emit_fop2() argument
1708 CHECK(check_sljit_emit_fop2(compiler, op, dst, dstw, src1, src1w, src2, src2w)); in sljit_emit_fop2()
1713 compiler->cache_arg = 0; in sljit_emit_fop2()
1714 compiler->cache_argw = 0; in sljit_emit_fop2()
1718 emit_fop_mem(compiler, mem_flags, TMP_FREG1, src1, src1w); in sljit_emit_fop2()
1722 emit_fop_mem(compiler, mem_flags, TMP_FREG2, src2, src2w); in sljit_emit_fop2()
1728 FAIL_IF(push_inst(compiler, (FADD ^ inv_bits) | VD(dst_r) | VN(src1) | VM(src2))); in sljit_emit_fop2()
1731 FAIL_IF(push_inst(compiler, (FSUB ^ inv_bits) | VD(dst_r) | VN(src1) | VM(src2))); in sljit_emit_fop2()
1734 FAIL_IF(push_inst(compiler, (FMUL ^ inv_bits) | VD(dst_r) | VN(src1) | VM(src2))); in sljit_emit_fop2()
1737 FAIL_IF(push_inst(compiler, (FDIV ^ inv_bits) | VD(dst_r) | VN(src1) | VM(src2))); in sljit_emit_fop2()
1743 return emit_fop_mem(compiler, mem_flags | STORE, TMP_FREG1, dst, dstw); in sljit_emit_fop2()
1750 SLJIT_API_FUNC_ATTRIBUTE sljit_si sljit_emit_fast_enter(struct sljit_compiler *compiler, sljit_si d… in sljit_emit_fast_enter() argument
1753 CHECK(check_sljit_emit_fast_enter(compiler, dst, dstw)); in sljit_emit_fast_enter()
1761 return push_inst(compiler, ORR | RD(dst) | RN(TMP_ZERO) | RM(TMP_LR)); in sljit_emit_fast_enter()
1764 return emit_op_mem(compiler, WORD_SIZE | STORE, TMP_LR, dst, dstw); in sljit_emit_fast_enter()
1767 SLJIT_API_FUNC_ATTRIBUTE sljit_si sljit_emit_fast_return(struct sljit_compiler *compiler, sljit_si … in sljit_emit_fast_return() argument
1770 CHECK(check_sljit_emit_fast_return(compiler, src, srcw)); in sljit_emit_fast_return()
1774 FAIL_IF(push_inst(compiler, ORR | RD(TMP_LR) | RN(TMP_ZERO) | RM(src))); in sljit_emit_fast_return()
1776 FAIL_IF(emit_op_mem(compiler, WORD_SIZE, TMP_LR, src, srcw)); in sljit_emit_fast_return()
1778 FAIL_IF(load_immediate(compiler, TMP_LR, srcw)); in sljit_emit_fast_return()
1780 return push_inst(compiler, RET | RN(TMP_LR)); in sljit_emit_fast_return()
1842 SLJIT_API_FUNC_ATTRIBUTE struct sljit_label* sljit_emit_label(struct sljit_compiler *compiler) in sljit_emit_label() argument
1847 CHECK_PTR(check_sljit_emit_label(compiler)); in sljit_emit_label()
1849 if (compiler->last_label && compiler->last_label->size == compiler->size) in sljit_emit_label()
1850 return compiler->last_label; in sljit_emit_label()
1852 label = (struct sljit_label*)ensure_abuf(compiler, sizeof(struct sljit_label)); in sljit_emit_label()
1854 set_label(label, compiler); in sljit_emit_label()
1858 SLJIT_API_FUNC_ATTRIBUTE struct sljit_jump* sljit_emit_jump(struct sljit_compiler *compiler, sljit_… in sljit_emit_jump() argument
1863 CHECK_PTR(check_sljit_emit_jump(compiler, type)); in sljit_emit_jump()
1865 jump = (struct sljit_jump*)ensure_abuf(compiler, sizeof(struct sljit_jump)); in sljit_emit_jump()
1867 set_jump(jump, compiler, type & SLJIT_REWRITABLE_JUMP); in sljit_emit_jump()
1872 PTR_FAIL_IF(push_inst(compiler, B_CC | (6 << 5) | get_cc(type))); in sljit_emit_jump()
1877 PTR_FAIL_IF(emit_imm64_const(compiler, TMP_REG1, 0)); in sljit_emit_jump()
1878 jump->addr = compiler->size; in sljit_emit_jump()
1879 PTR_FAIL_IF(push_inst(compiler, ((type >= SLJIT_FAST_CALL) ? BLR : BR) | RN(TMP_REG1))); in sljit_emit_jump()
1884 static SLJIT_INLINE struct sljit_jump* emit_cmp_to0(struct sljit_compiler *compiler, sljit_si type, in emit_cmp_to0() argument
1893 jump = (struct sljit_jump*)ensure_abuf(compiler, sizeof(struct sljit_jump)); in emit_cmp_to0()
1895 set_jump(jump, compiler, type & SLJIT_REWRITABLE_JUMP); in emit_cmp_to0()
1899 PTR_FAIL_IF(emit_op_mem(compiler, inv_bits ? INT_SIZE : WORD_SIZE, TMP_REG1, src, srcw)); in emit_cmp_to0()
1903 PTR_FAIL_IF(load_immediate(compiler, TMP_REG1, srcw)); in emit_cmp_to0()
1911 PTR_FAIL_IF(push_inst(compiler, (CBZ ^ inv_bits) | (6 << 5) | RT(src))); in emit_cmp_to0()
1912 PTR_FAIL_IF(emit_imm64_const(compiler, TMP_REG1, 0)); in emit_cmp_to0()
1913 jump->addr = compiler->size; in emit_cmp_to0()
1914 PTR_FAIL_IF(push_inst(compiler, BR | RN(TMP_REG1))); in emit_cmp_to0()
1918 SLJIT_API_FUNC_ATTRIBUTE sljit_si sljit_emit_ijump(struct sljit_compiler *compiler, sljit_si type, … in sljit_emit_ijump() argument
1923 CHECK(check_sljit_emit_ijump(compiler, type, src, srcw)); in sljit_emit_ijump()
1929 FAIL_IF(emit_op_mem(compiler, WORD_SIZE, TMP_REG1, src, srcw)); in sljit_emit_ijump()
1932 return push_inst(compiler, ((type >= SLJIT_FAST_CALL) ? BLR : BR) | RN(src)); in sljit_emit_ijump()
1935 jump = (struct sljit_jump*)ensure_abuf(compiler, sizeof(struct sljit_jump)); in sljit_emit_ijump()
1937 set_jump(jump, compiler, JUMP_ADDR | ((type >= SLJIT_FAST_CALL) ? IS_BL : 0)); in sljit_emit_ijump()
1940 FAIL_IF(emit_imm64_const(compiler, TMP_REG1, 0)); in sljit_emit_ijump()
1941 jump->addr = compiler->size; in sljit_emit_ijump()
1942 return push_inst(compiler, ((type >= SLJIT_FAST_CALL) ? BLR : BR) | RN(TMP_REG1)); in sljit_emit_ijump()
1945 SLJIT_API_FUNC_ATTRIBUTE sljit_si sljit_emit_op_flags(struct sljit_compiler *compiler, sljit_si op, in sljit_emit_op_flags() argument
1954 CHECK(check_sljit_emit_op_flags(compiler, op, dst, dstw, src, srcw, type)); in sljit_emit_op_flags()
1965 FAIL_IF(push_inst(compiler, CSINC | (cc << 12) | RD(dst_r) | RN(TMP_ZERO) | RM(TMP_ZERO))); in sljit_emit_op_flags()
1968 …return emit_op_mem(compiler, (GET_OPCODE(op) == SLJIT_MOV ? WORD_SIZE : INT_SIZE) | STORE, TMP_REG… in sljit_emit_op_flags()
1971 compiler->cache_arg = 0; in sljit_emit_op_flags()
1972 compiler->cache_argw = 0; in sljit_emit_op_flags()
1981 FAIL_IF(emit_op_mem2(compiler, mem_flags, TMP_REG1, src, srcw, dst, dstw)); in sljit_emit_op_flags()
1987 FAIL_IF(push_inst(compiler, CSINC | (cc << 12) | RD(TMP_REG2) | RN(TMP_ZERO) | RM(TMP_ZERO))); in sljit_emit_op_flags()
1988 emit_op_imm(compiler, flags | GET_OPCODE(op), dst_r, src, TMP_REG2); in sljit_emit_op_flags()
1992 return emit_op_mem2(compiler, mem_flags | STORE, TMP_REG1, dst, dstw, 0, 0); in sljit_emit_op_flags()
1995 SLJIT_API_FUNC_ATTRIBUTE struct sljit_const* sljit_emit_const(struct sljit_compiler *compiler, slji… in sljit_emit_const() argument
2001 CHECK_PTR(check_sljit_emit_const(compiler, dst, dstw, init_value)); in sljit_emit_const()
2004 const_ = (struct sljit_const*)ensure_abuf(compiler, sizeof(struct sljit_const)); in sljit_emit_const()
2006 set_const(const_, compiler); in sljit_emit_const()
2009 PTR_FAIL_IF(emit_imm64_const(compiler, dst_r, init_value)); in sljit_emit_const()
2012 PTR_FAIL_IF(emit_op_mem(compiler, WORD_SIZE | STORE, dst_r, dst, dstw)); in sljit_emit_const()