Lines Matching refs:compiler

33 static sljit_s32 emit_do_imm(struct sljit_compiler *compiler, sljit_u8 opcode, sljit_sw imm)  in emit_do_imm()  argument
37 inst = (sljit_u8*)ensure_buf(compiler, 1 + 1 + sizeof(sljit_sw)); in emit_do_imm()
46 static sljit_u8* emit_x86_instruction(struct sljit_compiler *compiler, sljit_uw size, in emit_x86_instruction() argument
125 inst = (sljit_u8*)ensure_buf(compiler, 1 + inst_size); in emit_x86_instruction()
253 SLJIT_API_FUNC_ATTRIBUTE sljit_s32 sljit_emit_enter(struct sljit_compiler *compiler, in sljit_emit_enter() argument
265 …CHECK(check_sljit_emit_enter(compiler, options, arg_types, scratches, saveds, fscratches, fsaveds,… in sljit_emit_enter()
266 set_emit_enter(compiler, options, arg_types, scratches, saveds, fscratches, fsaveds, local_size); in sljit_emit_enter()
269 FAIL_IF(emit_endbranch(compiler)); in sljit_emit_enter()
284 FAIL_IF(emit_sse2_load(compiler, 0, float_arg_count, SLJIT_MEM1(SLJIT_SP), args_size)); in sljit_emit_enter()
289 FAIL_IF(emit_sse2_load(compiler, 1, float_arg_count, SLJIT_MEM1(SLJIT_SP), args_size)); in sljit_emit_enter()
320 compiler->args_size = args_size; in sljit_emit_enter()
333 compiler->scratches_offset = locals_offset; in sljit_emit_enter()
341 compiler->locals_offset = locals_offset; in sljit_emit_enter()
344 inst = (sljit_u8*)ensure_buf(compiler, (sljit_uw)(size + 1)); in sljit_emit_enter()
359 EMIT_MOV(compiler, TMP_REG1, 0, SLJIT_MEM1(SLJIT_SP), args_size + size); in sljit_emit_enter()
369 compiler->local_size = local_size; in sljit_emit_enter()
394 …EMIT_MOV(compiler, (arg_types & SLJIT_ARG_TYPE_SCRATCH_REG) ? SLJIT_R0 : SLJIT_S0, 0, SLJIT_R2, 0); in sljit_emit_enter()
416 EMIT_MOV(compiler, word_arg_count, 0, SLJIT_MEM1(SLJIT_SP), args_size); in sljit_emit_enter()
422 EMIT_MOV(compiler, SLJIT_S0 - saved_arg_count, 0, SLJIT_MEM1(SLJIT_SP), args_size); in sljit_emit_enter()
434 EMIT_MOV(compiler, SLJIT_R0, 0, SLJIT_R2, 0); in sljit_emit_enter()
438 EMIT_MOV(compiler, SLJIT_S0, 0, SLJIT_R2, 0); in sljit_emit_enter()
443 EMIT_MOV(compiler, SLJIT_S0 - saved_arg_count, 0, SLJIT_R1, 0); in sljit_emit_enter()
462 EMIT_MOV(compiler, SLJIT_R2, 0, SLJIT_IMM, local_size >> 12); in sljit_emit_enter()
467 inst = (sljit_u8*)ensure_buf(compiler, 1 + 2); in sljit_emit_enter()
483 EMIT_MOV(compiler, SLJIT_R2, 0, SLJIT_MEM1(SLJIT_SP), r2_offset); in sljit_emit_enter()
494 …size = (status & ENTER_TMP_TO_R4) ? compiler->scratches_offset : compiler->locals_offset - SSIZE_O… in sljit_emit_enter()
495 EMIT_MOV(compiler, SLJIT_MEM1(SLJIT_SP), size, TMP_REG1, 0); in sljit_emit_enter()
501 SLJIT_API_FUNC_ATTRIBUTE sljit_s32 sljit_set_context(struct sljit_compiler *compiler, in sljit_set_context() argument
511 …CHECK(check_sljit_set_context(compiler, options, arg_types, scratches, saveds, fscratches, fsaveds… in sljit_set_context()
512 set_set_context(compiler, options, arg_types, scratches, saveds, fscratches, fsaveds, local_size); in sljit_set_context()
537 compiler->args_size = args_size; in sljit_set_context()
550 compiler->scratches_offset = locals_offset; in sljit_set_context()
558 compiler->locals_offset = locals_offset; in sljit_set_context()
567 compiler->local_size = ((locals_offset + local_size + saveds + 0xf) & ~0xf) - saveds; in sljit_set_context()
571 static sljit_s32 emit_stack_frame_release(struct sljit_compiler *compiler) in emit_stack_frame_release() argument
576 size = (sljit_uw)(1 + (compiler->scratches > 9 ? (compiler->scratches - 9) : 0) + in emit_stack_frame_release()
577 (compiler->saveds <= 3 ? compiler->saveds : 3)); in emit_stack_frame_release()
578 inst = (sljit_u8*)ensure_buf(compiler, 1 + size); in emit_stack_frame_release()
583 if (compiler->saveds > 0 || compiler->scratches > 11) in emit_stack_frame_release()
585 if (compiler->saveds > 1 || compiler->scratches > 10) in emit_stack_frame_release()
587 if (compiler->saveds > 2 || compiler->scratches > 9) in emit_stack_frame_release()
594 SLJIT_API_FUNC_ATTRIBUTE sljit_s32 sljit_emit_return_void(struct sljit_compiler *compiler) in sljit_emit_return_void() argument
600 CHECK(check_sljit_emit_return_void(compiler)); in sljit_emit_return_void()
602 SLJIT_ASSERT(compiler->args_size >= 0); in sljit_emit_return_void()
603 SLJIT_ASSERT(compiler->local_size > 0); in sljit_emit_return_void()
605 BINARY_IMM32(ADD, compiler->local_size, SLJIT_SP, 0); in sljit_emit_return_void()
607 FAIL_IF(emit_stack_frame_release(compiler)); in sljit_emit_return_void()
611 if (compiler->args_size > 0 && !(compiler->options & SLJIT_ENTER_CDECL)) in sljit_emit_return_void()
614 inst = (sljit_u8*)ensure_buf(compiler, 1 + size); in sljit_emit_return_void()
620 if (compiler->args_size > 0 && !(compiler->options & SLJIT_ENTER_CDECL)) { in sljit_emit_return_void()
621 RET_I16(U8(compiler->args_size)); in sljit_emit_return_void()
667 static sljit_s32 c_fast_call_with_args(struct sljit_compiler *compiler, in c_fast_call_with_args() argument
674 inst = (sljit_u8*)ensure_buf(compiler, 1 + 1); in c_fast_call_with_args()
681 EMIT_MOV(compiler, TMP_REG1, 0, SLJIT_MEM1(SLJIT_SP), compiler->scratches_offset); in c_fast_call_with_args()
693 FAIL_IF(emit_sse2_store(compiler, 0, SLJIT_MEM1(SLJIT_SP), stack_size, float_arg_count)); in c_fast_call_with_args()
698 FAIL_IF(emit_sse2_store(compiler, 1, SLJIT_MEM1(SLJIT_SP), stack_size, float_arg_count)); in c_fast_call_with_args()
704 EMIT_MOV(compiler, SLJIT_MEM1(SLJIT_SP), stack_size, SLJIT_R2, 0); in c_fast_call_with_args()
708 EMIT_MOV(compiler, SLJIT_MEM1(SLJIT_SP), stack_size, TMP_REG1, 0); in c_fast_call_with_args()
720 inst = (sljit_u8*)ensure_buf(compiler, 1 + 1); in c_fast_call_with_args()
727 inst = (sljit_u8*)ensure_buf(compiler, 1 + 2); in c_fast_call_with_args()
741 static sljit_s32 cdecl_call_get_stack_size(struct sljit_compiler *compiler, sljit_s32 arg_types, sl… in cdecl_call_get_stack_size() argument
768 if (stack_size <= compiler->scratches_offset) in cdecl_call_get_stack_size()
771 return ((stack_size - compiler->scratches_offset + 0xf) & ~0xf); in cdecl_call_get_stack_size()
774 static sljit_s32 cdecl_call_with_args(struct sljit_compiler *compiler, in cdecl_call_with_args() argument
781 EMIT_MOV(compiler, TMP_REG1, 0, SLJIT_MEM1(SLJIT_SP), compiler->scratches_offset); in cdecl_call_with_args()
794 FAIL_IF(emit_sse2_store(compiler, 0, SLJIT_MEM1(SLJIT_SP), stack_size, float_arg_count)); in cdecl_call_with_args()
799 FAIL_IF(emit_sse2_store(compiler, 1, SLJIT_MEM1(SLJIT_SP), stack_size, float_arg_count)); in cdecl_call_with_args()
804 …EMIT_MOV(compiler, SLJIT_MEM1(SLJIT_SP), stack_size, (word_arg_count >= 4) ? TMP_REG1 : word_arg_c… in cdecl_call_with_args()
815 static sljit_s32 post_call_with_args(struct sljit_compiler *compiler, in post_call_with_args() argument
829 inst = (sljit_u8*)ensure_buf(compiler, 1 + 3); in post_call_with_args()
836 return emit_sse2_load(compiler, single, SLJIT_FR0, SLJIT_MEM1(SLJIT_SP), 0); in post_call_with_args()
839 static sljit_s32 tail_call_with_args(struct sljit_compiler *compiler, in tail_call_with_args() argument
856 saved_regs_size = (1 + (compiler->scratches > 9 ? (compiler->scratches - 9) : 0) in tail_call_with_args()
857 + (compiler->saveds <= 3 ? compiler->saveds : 3)) * SSIZE_OF(sw); in tail_call_with_args()
890 if (args_size <= compiler->args_size in tail_call_with_args()
892 && (!(compiler->options & SLJIT_ENTER_CDECL) || args_size == 0 || !fast_call) in tail_call_with_args()
897 prev_args_size = compiler->args_size; in tail_call_with_args()
904 offset = stack_size + compiler->local_size; in tail_call_with_args()
908 EMIT_MOV(compiler, SLJIT_MEM1(SLJIT_SP), 0, SLJIT_R0, 0); in tail_call_with_args()
911 EMIT_MOV(compiler, SLJIT_R0, 0, src, srcw); in tail_call_with_args()
915 if (!(compiler->options & SLJIT_ENTER_CDECL)) { in tail_call_with_args()
930 EMIT_MOV(compiler, SLJIT_MEM1(SLJIT_SP), offset - word_arg4_offset, SLJIT_R2, 0); in tail_call_with_args()
935 EMIT_MOV(compiler, SLJIT_R2, 0, SLJIT_MEM1(SLJIT_SP), offset - prev_args_size - SSIZE_OF(sw)); in tail_call_with_args()
936 EMIT_MOV(compiler, SLJIT_MEM1(SLJIT_SP), offset - args_size - SSIZE_OF(sw), SLJIT_R2, 0); in tail_call_with_args()
939 EMIT_MOV(compiler, SLJIT_R2, 0, SLJIT_MEM1(SLJIT_SP), offset - prev_args_size); in tail_call_with_args()
940 EMIT_MOV(compiler, SLJIT_MEM1(SLJIT_SP), offset, SLJIT_R2, 0); in tail_call_with_args()
949 FAIL_IF(emit_sse2_store(compiler, 0, SLJIT_MEM1(SLJIT_SP), offset, float_arg_count)); in tail_call_with_args()
954 FAIL_IF(emit_sse2_store(compiler, 0, SLJIT_MEM1(SLJIT_SP), offset, float_arg_count)); in tail_call_with_args()
962 EMIT_MOV(compiler, SLJIT_R2, 0, r2_offset != 0 ? SLJIT_MEM1(SLJIT_SP) : SLJIT_R0, 0); in tail_call_with_args()
968 EMIT_MOV(compiler, SLJIT_R2, 0, SLJIT_MEM1(SLJIT_SP), 0); in tail_call_with_args()
969 EMIT_MOV(compiler, SLJIT_MEM1(SLJIT_SP), offset, SLJIT_R2, 0); in tail_call_with_args()
971 EMIT_MOV(compiler, SLJIT_MEM1(SLJIT_SP), offset, SLJIT_R0, 0); in tail_call_with_args()
979 EMIT_MOV(compiler, SLJIT_MEM1(SLJIT_SP), offset, SLJIT_R1, 0); in tail_call_with_args()
986 EMIT_MOV(compiler, SLJIT_R2, 0, SLJIT_MEM1(SLJIT_SP), compiler->scratches_offset); in tail_call_with_args()
987 EMIT_MOV(compiler, SLJIT_MEM1(SLJIT_SP), offset, SLJIT_R2, 0); in tail_call_with_args()
996 BINARY_IMM32(ADD, compiler->local_size, SLJIT_SP, 0); in tail_call_with_args()
997 FAIL_IF(emit_stack_frame_release(compiler)); in tail_call_with_args()
1019 if (!(compiler->options & SLJIT_ENTER_CDECL)) in tail_call_with_args()
1020 prev_args_size = compiler->args_size; in tail_call_with_args()
1024 min_size = prev_stack_size + compiler->local_size; in tail_call_with_args()
1026 word_arg4_offset = compiler->scratches_offset; in tail_call_with_args()
1038 EMIT_MOV(compiler, SLJIT_MEM1(SLJIT_SP), r2_offset, SLJIT_R2, 0); in tail_call_with_args()
1041 EMIT_MOV(compiler, SLJIT_R2, 0, SLJIT_MEM1(SLJIT_SP), word_arg4_offset); in tail_call_with_args()
1047 EMIT_MOV(compiler, SLJIT_MEM1(SLJIT_SP), 0, SLJIT_R0, 0); in tail_call_with_args()
1049 EMIT_MOV(compiler, SLJIT_R0, 0, src, srcw); in tail_call_with_args()
1054 EMIT_MOV(compiler, TMP_REG1, 0, SLJIT_MEM1(SLJIT_SP), offset); in tail_call_with_args()
1056 if (compiler->saveds > 2 || compiler->scratches > 9) { in tail_call_with_args()
1058 EMIT_MOV(compiler, SLJIT_S2, 0, SLJIT_MEM1(SLJIT_SP), offset); in tail_call_with_args()
1060 if (compiler->saveds > 1 || compiler->scratches > 10) { in tail_call_with_args()
1062 EMIT_MOV(compiler, SLJIT_S1, 0, SLJIT_MEM1(SLJIT_SP), offset); in tail_call_with_args()
1064 if (compiler->saveds > 0 || compiler->scratches > 11) { in tail_call_with_args()
1066 EMIT_MOV(compiler, SLJIT_S0, 0, SLJIT_MEM1(SLJIT_SP), offset); in tail_call_with_args()
1077 inst = emit_x86_instruction(compiler, 1, SLJIT_R2, 0, SLJIT_MEM1(SLJIT_SP), offset); in tail_call_with_args()
1085 EMIT_MOV(compiler, SLJIT_MEM1(SLJIT_SP), offset, SLJIT_R2, 0); in tail_call_with_args()
1089 … EMIT_MOV(compiler, SLJIT_R2, 0, SLJIT_MEM1(SLJIT_SP), stack_size - prev_args_size - SSIZE_OF(sw)); in tail_call_with_args()
1093 EMIT_MOV(compiler, SLJIT_MEM1(SLJIT_SP), stack_size - args_size - SSIZE_OF(sw), SLJIT_R2, 0); in tail_call_with_args()
1101 inst = emit_x86_instruction(compiler, 1, SLJIT_R2, 0, SLJIT_MEM1(SLJIT_SP), offset); in tail_call_with_args()
1109 EMIT_MOV(compiler, SLJIT_MEM1(SLJIT_SP), offset, SLJIT_R2, 0); in tail_call_with_args()
1113 … EMIT_MOV(compiler, SLJIT_R2, 0, SLJIT_MEM1(SLJIT_SP), stack_size - prev_args_size - SSIZE_OF(sw)); in tail_call_with_args()
1118 EMIT_MOV(compiler, SLJIT_MEM1(SLJIT_SP), stack_size - SSIZE_OF(sw), SLJIT_R2, 0); in tail_call_with_args()
1127 FAIL_IF(emit_sse2_store(compiler, 0, SLJIT_MEM1(SLJIT_SP), offset, float_arg_count)); in tail_call_with_args()
1132 FAIL_IF(emit_sse2_store(compiler, 0, SLJIT_MEM1(SLJIT_SP), offset, float_arg_count)); in tail_call_with_args()
1140 EMIT_MOV(compiler, SLJIT_R2, 0, r2_offset != 0 ? SLJIT_MEM1(SLJIT_SP) : SLJIT_R0, 0); in tail_call_with_args()
1146 EMIT_MOV(compiler, SLJIT_R2, 0, SLJIT_MEM1(SLJIT_SP), 0); in tail_call_with_args()
1147 EMIT_MOV(compiler, SLJIT_MEM1(SLJIT_SP), offset, SLJIT_R2, 0); in tail_call_with_args()
1149 EMIT_MOV(compiler, SLJIT_MEM1(SLJIT_SP), offset, SLJIT_R0, 0); in tail_call_with_args()
1157 EMIT_MOV(compiler, SLJIT_MEM1(SLJIT_SP), offset, SLJIT_R1, 0); in tail_call_with_args()
1161 EMIT_MOV(compiler, SLJIT_R2, 0, SLJIT_MEM1(SLJIT_SP), r2_offset); in tail_call_with_args()
1162 EMIT_MOV(compiler, SLJIT_MEM1(SLJIT_SP), offset, SLJIT_R2, 0); in tail_call_with_args()
1186 static sljit_s32 emit_tail_call_end(struct sljit_compiler *compiler, sljit_s32 extra_space) in emit_tail_call_end() argument
1193 inst = (sljit_u8*)ensure_buf(compiler, 1 + 1); in emit_tail_call_end()
1201 SLJIT_API_FUNC_ATTRIBUTE struct sljit_jump* sljit_emit_call(struct sljit_compiler *compiler, sljit_… in sljit_emit_call() argument
1209 CHECK_PTR(check_sljit_emit_call(compiler, type, arg_types)); in sljit_emit_call()
1213 PTR_FAIL_IF(tail_call_with_args(compiler, &stack_size, arg_types, SLJIT_IMM, 0)); in sljit_emit_call()
1217 compiler->skip_checks = 1; in sljit_emit_call()
1222 return sljit_emit_jump(compiler, type); in sljit_emit_call()
1225 jump = sljit_emit_jump(compiler, type); in sljit_emit_call()
1228 PTR_FAIL_IF(emit_tail_call_end(compiler, stack_size)); in sljit_emit_call()
1235 PTR_FAIL_IF(c_fast_call_with_args(compiler, arg_types, stack_size, word_arg_count, 0)); in sljit_emit_call()
1239 compiler->skip_checks = 1; in sljit_emit_call()
1242 jump = sljit_emit_jump(compiler, type); in sljit_emit_call()
1245 PTR_FAIL_IF(post_call_with_args(compiler, arg_types, 0)); in sljit_emit_call()
1250 stack_size = cdecl_call_get_stack_size(compiler, arg_types, &word_arg_count); in sljit_emit_call()
1251 PTR_FAIL_IF(cdecl_call_with_args(compiler, arg_types, stack_size, word_arg_count)); in sljit_emit_call()
1255 compiler->skip_checks = 1; in sljit_emit_call()
1258 jump = sljit_emit_jump(compiler, type); in sljit_emit_call()
1261 PTR_FAIL_IF(post_call_with_args(compiler, arg_types, stack_size)); in sljit_emit_call()
1265 SLJIT_API_FUNC_ATTRIBUTE sljit_s32 sljit_emit_icall(struct sljit_compiler *compiler, sljit_s32 type, in sljit_emit_icall() argument
1276 CHECK(check_sljit_emit_icall(compiler, type, arg_types, src, srcw)); in sljit_emit_icall()
1280 FAIL_IF(tail_call_with_args(compiler, &stack_size, arg_types, src, srcw)); in sljit_emit_icall()
1289 compiler->skip_checks = 1; in sljit_emit_icall()
1293 return sljit_emit_ijump(compiler, SLJIT_JUMP, src, srcw); in sljit_emit_icall()
1295 FAIL_IF(sljit_emit_ijump(compiler, type, src, srcw)); in sljit_emit_icall()
1296 return emit_tail_call_end(compiler, stack_size); in sljit_emit_icall()
1316 FAIL_IF(c_fast_call_with_args(compiler, arg_types, stack_size, word_arg_count, swap_args)); in sljit_emit_icall()
1318 compiler->scratches_offset += stack_size; in sljit_emit_icall()
1319 compiler->locals_offset += stack_size; in sljit_emit_icall()
1323 compiler->skip_checks = 1; in sljit_emit_icall()
1325 FAIL_IF(sljit_emit_ijump(compiler, type, src, srcw)); in sljit_emit_icall()
1327 compiler->scratches_offset -= stack_size; in sljit_emit_icall()
1328 compiler->locals_offset -= stack_size; in sljit_emit_icall()
1330 return post_call_with_args(compiler, arg_types, 0); in sljit_emit_icall()
1334 stack_size = cdecl_call_get_stack_size(compiler, arg_types, &word_arg_count); in sljit_emit_icall()
1335 FAIL_IF(cdecl_call_with_args(compiler, arg_types, stack_size, word_arg_count)); in sljit_emit_icall()
1337 compiler->scratches_offset += stack_size; in sljit_emit_icall()
1338 compiler->locals_offset += stack_size; in sljit_emit_icall()
1342 compiler->skip_checks = 1; in sljit_emit_icall()
1344 FAIL_IF(sljit_emit_ijump(compiler, type, src, srcw)); in sljit_emit_icall()
1346 compiler->scratches_offset -= stack_size; in sljit_emit_icall()
1347 compiler->locals_offset -= stack_size; in sljit_emit_icall()
1349 return post_call_with_args(compiler, arg_types, stack_size); in sljit_emit_icall()
1352 SLJIT_API_FUNC_ATTRIBUTE sljit_s32 sljit_emit_fast_enter(struct sljit_compiler *compiler, sljit_s32… in sljit_emit_fast_enter() argument
1357 CHECK(check_sljit_emit_fast_enter(compiler, dst, dstw)); in sljit_emit_fast_enter()
1364 inst = (sljit_u8*)ensure_buf(compiler, 1 + 1); in sljit_emit_fast_enter()
1373 inst = emit_x86_instruction(compiler, 1, 0, 0, dst, dstw); in sljit_emit_fast_enter()
1379 static sljit_s32 emit_fast_return(struct sljit_compiler *compiler, sljit_s32 src, sljit_sw srcw) in emit_fast_return() argument
1386 inst = (sljit_u8*)ensure_buf(compiler, 1 + 1 + 1); in emit_fast_return()
1393 inst = emit_x86_instruction(compiler, 1, 0, 0, src, srcw); in emit_fast_return()
1398 inst = (sljit_u8*)ensure_buf(compiler, 1 + 1); in emit_fast_return()
1407 static sljit_s32 skip_frames_before_return(struct sljit_compiler *compiler) in skip_frames_before_return() argument
1415 SLJIT_ASSERT(compiler->args_size >= 0); in skip_frames_before_return()
1416 SLJIT_ASSERT(compiler->local_size > 0); in skip_frames_before_return()
1418 size = compiler->local_size; in skip_frames_before_return()
1419 size += (1 + (compiler->scratches > 9 ? (compiler->scratches - 9) : 0) in skip_frames_before_return()
1420 + (compiler->saveds <= 3 ? compiler->saveds : 3)) * SSIZE_OF(sw); in skip_frames_before_return()
1422 return adjust_shadow_stack(compiler, SLJIT_MEM1(SLJIT_SP), size); in skip_frames_before_return()