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
132 inst = (sljit_u8*)ensure_buf(compiler, 1 + inst_size); in emit_x86_instruction()
262 SLJIT_API_FUNC_ATTRIBUTE sljit_s32 sljit_emit_enter(struct sljit_compiler *compiler, in sljit_emit_enter() argument
275 …CHECK(check_sljit_emit_enter(compiler, options, arg_types, scratches, saveds, fscratches, fsaveds,… in sljit_emit_enter()
276 set_emit_enter(compiler, options, arg_types, scratches, saveds, fscratches, fsaveds, local_size); in sljit_emit_enter()
279 FAIL_IF(emit_endbranch(compiler)); in sljit_emit_enter()
300 compiler->args_size = 0; in sljit_emit_enter()
310 FAIL_IF(emit_sse2_load(compiler, 0, float_arg_count, SLJIT_MEM1(SLJIT_SP), args_size)); in sljit_emit_enter()
315 FAIL_IF(emit_sse2_load(compiler, 1, float_arg_count, SLJIT_MEM1(SLJIT_SP), args_size)); in sljit_emit_enter()
341 compiler->args_size = args_size; in sljit_emit_enter()
349 inst = (sljit_u8*)ensure_buf(compiler, (sljit_uw)(size + 1)); in sljit_emit_enter()
368 EMIT_MOV(compiler, TMP_REG1, 0, SLJIT_MEM1(SLJIT_SP), args_size + size); in sljit_emit_enter()
373 compiler->local_size = local_size; in sljit_emit_enter()
396 EMIT_MOV(compiler, word_arg_count, 0, SLJIT_MEM1(SLJIT_SP), args_size); in sljit_emit_enter()
399 EMIT_MOV(compiler, SLJIT_S0 - saved_arg_count, 0, SLJIT_MEM1(SLJIT_SP), args_size); in sljit_emit_enter()
427 inst = (sljit_u8*)ensure_buf(compiler, (sljit_uw)(1 + 1)); in sljit_emit_enter()
436 EMIT_MOV(compiler, SLJIT_R2, 0, SLJIT_IMM, local_size >> 12); in sljit_emit_enter()
441 inst = (sljit_u8*)ensure_buf(compiler, 1 + 2); in sljit_emit_enter()
457 EMIT_MOV(compiler, SLJIT_R2, 0, SLJIT_MEM1(SLJIT_SP), r2_offset); in sljit_emit_enter()
471 EMIT_MOV(compiler, SLJIT_MEM1(SLJIT_SP), size, kept_saveds_count, 0); in sljit_emit_enter()
481 EMIT_MOV(compiler, SLJIT_MEM1(SLJIT_SP), size, TMP_REG1, 0); in sljit_emit_enter()
487 SLJIT_API_FUNC_ATTRIBUTE sljit_s32 sljit_set_context(struct sljit_compiler *compiler, in sljit_set_context() argument
494 …CHECK(check_sljit_set_context(compiler, options, arg_types, scratches, saveds, fscratches, fsaveds… in sljit_set_context()
495 set_set_context(compiler, options, arg_types, scratches, saveds, fscratches, fsaveds, local_size); in sljit_set_context()
517 compiler->args_size = args_size; in sljit_set_context()
527 compiler->local_size = ((SLJIT_LOCALS_OFFSET_BASE + local_size + saveds + 0xf) & ~0xf) - saveds; in sljit_set_context()
531 static sljit_s32 emit_stack_frame_release(struct sljit_compiler *compiler, sljit_s32 is_return_to) in emit_stack_frame_release() argument
533 sljit_s32 kept_saveds_count = SLJIT_KEPT_SAVEDS_COUNT(compiler->options); in emit_stack_frame_release()
538 size = (sljit_uw)((compiler->scratches > 9 ? (compiler->scratches - 9) : 0) + in emit_stack_frame_release()
539 (compiler->saveds <= 3 ? compiler->saveds : 3) - kept_saveds_count); in emit_stack_frame_release()
541 local_size = compiler->local_size; in emit_stack_frame_release()
543 if (!(compiler->options & SLJIT_ENTER_REG_ARG)) in emit_stack_frame_release()
556 inst = (sljit_u8*)ensure_buf(compiler, 1 + size); in emit_stack_frame_release()
561 saveds = compiler->saveds; in emit_stack_frame_release()
563 if ((saveds > 0 && kept_saveds_count == 0) || compiler->scratches > 11) in emit_stack_frame_release()
565 if ((saveds > 1 && kept_saveds_count <= 1) || compiler->scratches > 10) in emit_stack_frame_release()
567 if ((saveds > 2 && kept_saveds_count <= 2) || compiler->scratches > 9) in emit_stack_frame_release()
570 if (!(compiler->options & SLJIT_ENTER_REG_ARG)) in emit_stack_frame_release()
579 SLJIT_API_FUNC_ATTRIBUTE sljit_s32 sljit_emit_return_void(struct sljit_compiler *compiler) in sljit_emit_return_void() argument
584 CHECK(check_sljit_emit_return_void(compiler)); in sljit_emit_return_void()
586 SLJIT_ASSERT(compiler->args_size >= 0); in sljit_emit_return_void()
587 SLJIT_ASSERT(compiler->local_size > 0); in sljit_emit_return_void()
589 FAIL_IF(emit_stack_frame_release(compiler, 0)); in sljit_emit_return_void()
591 inst = (sljit_u8*)ensure_buf(compiler, 1 + 1); in sljit_emit_return_void()
598 SLJIT_API_FUNC_ATTRIBUTE sljit_s32 sljit_emit_return_to(struct sljit_compiler *compiler, in sljit_emit_return_to() argument
604 CHECK(check_sljit_emit_return_to(compiler, src, srcw)); in sljit_emit_return_to()
606 …if ((src & SLJIT_MEM) || (src > SLJIT_R2 && src <= (SLJIT_S0 - SLJIT_KEPT_SAVEDS_COUNT(compiler->o… in sljit_emit_return_to()
610 src_r = (compiler->options & SLJIT_ENTER_REG_ARG) ? TMP_REG1 : SLJIT_R1; in sljit_emit_return_to()
612 EMIT_MOV(compiler, src_r, 0, src, srcw); in sljit_emit_return_to()
617 FAIL_IF(emit_stack_frame_release(compiler, 1)); in sljit_emit_return_to()
619 SLJIT_SKIP_CHECKS(compiler); in sljit_emit_return_to()
620 return sljit_emit_ijump(compiler, SLJIT_JUMP, src, srcw); in sljit_emit_return_to()
660 static sljit_s32 call_with_args(struct sljit_compiler *compiler, in call_with_args() argument
670 EMIT_MOV(compiler, TMP_REG1, 0, SLJIT_MEM1(SLJIT_SP), 2 * SSIZE_OF(sw)); in call_with_args()
686 FAIL_IF(emit_sse2_store(compiler, 0, SLJIT_MEM1(SLJIT_SP), arg_offset, float_arg_count)); in call_with_args()
691 FAIL_IF(emit_sse2_store(compiler, 1, SLJIT_MEM1(SLJIT_SP), arg_offset, float_arg_count)); in call_with_args()
696 …EMIT_MOV(compiler, SLJIT_MEM1(SLJIT_SP), arg_offset, (word_arg_count >= 4) ? arg4_reg : word_arg_c… in call_with_args()
699 EMIT_MOV(compiler, SLJIT_R0, 0, SLJIT_MEM1(SLJIT_SP), 2 * SSIZE_OF(sw) + stack_size); in call_with_args()
711 static sljit_s32 post_call_with_args(struct sljit_compiler *compiler, in post_call_with_args() argument
725 inst = (sljit_u8*)ensure_buf(compiler, 1 + 3); in post_call_with_args()
732 return emit_sse2_load(compiler, single, SLJIT_FR0, SLJIT_MEM1(SLJIT_SP), 0); in post_call_with_args()
735 static sljit_s32 tail_call_with_args(struct sljit_compiler *compiler, in tail_call_with_args() argument
744 sljit_s32 kept_saveds_count = SLJIT_KEPT_SAVEDS_COUNT(compiler->options); in tail_call_with_args()
750 saved_regs_size = (1 + (compiler->scratches > 9 ? (compiler->scratches - 9) : 0) in tail_call_with_args()
751 + (compiler->saveds <= 3 ? compiler->saveds : 3) - kept_saveds_count) * SSIZE_OF(sw); in tail_call_with_args()
779 if (args_size <= compiler->args_size) { in tail_call_with_args()
783 offset = stack_size + compiler->local_size; in tail_call_with_args()
787 EMIT_MOV(compiler, SLJIT_MEM1(SLJIT_SP), 0, SLJIT_R0, 0); in tail_call_with_args()
790 EMIT_MOV(compiler, SLJIT_R0, 0, src, srcw); in tail_call_with_args()
797 FAIL_IF(emit_sse2_store(compiler, 0, SLJIT_MEM1(SLJIT_SP), offset, float_arg_count)); in tail_call_with_args()
802 FAIL_IF(emit_sse2_store(compiler, 0, SLJIT_MEM1(SLJIT_SP), offset, float_arg_count)); in tail_call_with_args()
810 EMIT_MOV(compiler, SLJIT_R2, 0, SLJIT_MEM1(SLJIT_SP), 0); in tail_call_with_args()
811 EMIT_MOV(compiler, SLJIT_MEM1(SLJIT_SP), offset, SLJIT_R2, 0); in tail_call_with_args()
813 EMIT_MOV(compiler, SLJIT_MEM1(SLJIT_SP), offset, SLJIT_R0, 0); in tail_call_with_args()
817 EMIT_MOV(compiler, SLJIT_MEM1(SLJIT_SP), offset, SLJIT_R1, 0); in tail_call_with_args()
824 EMIT_MOV(compiler, SLJIT_R2, 0, SLJIT_MEM1(SLJIT_SP), 2 * SSIZE_OF(sw)); in tail_call_with_args()
825 EMIT_MOV(compiler, SLJIT_MEM1(SLJIT_SP), offset, SLJIT_R2, 0); in tail_call_with_args()
834 return emit_stack_frame_release(compiler, 0); in tail_call_with_args()
848 min_size = prev_stack_size + compiler->local_size; in tail_call_with_args()
862 EMIT_MOV(compiler, SLJIT_MEM1(SLJIT_SP), r2_offset, SLJIT_R2, 0); in tail_call_with_args()
865 EMIT_MOV(compiler, SLJIT_R2, 0, SLJIT_MEM1(SLJIT_SP), word_arg4_offset); in tail_call_with_args()
871 EMIT_MOV(compiler, SLJIT_MEM1(SLJIT_SP), 0, SLJIT_R0, 0); in tail_call_with_args()
873 EMIT_MOV(compiler, SLJIT_R0, 0, src, srcw); in tail_call_with_args()
878 EMIT_MOV(compiler, TMP_REG1, 0, SLJIT_MEM1(SLJIT_SP), offset); in tail_call_with_args()
880 if (compiler->saveds > 2 || compiler->scratches > 9) { in tail_call_with_args()
882 EMIT_MOV(compiler, SLJIT_S2, 0, SLJIT_MEM1(SLJIT_SP), offset); in tail_call_with_args()
884 if ((compiler->saveds > 1 && kept_saveds_count <= 1) || compiler->scratches > 10) { in tail_call_with_args()
886 EMIT_MOV(compiler, SLJIT_S1, 0, SLJIT_MEM1(SLJIT_SP), offset); in tail_call_with_args()
888 if ((compiler->saveds > 0 && kept_saveds_count == 0) || compiler->scratches > 11) { in tail_call_with_args()
890 EMIT_MOV(compiler, SLJIT_S0, 0, SLJIT_MEM1(SLJIT_SP), offset); in tail_call_with_args()
899 EMIT_MOV(compiler, SLJIT_MEM1(SLJIT_SP), offset, SLJIT_R2, 0); in tail_call_with_args()
906 FAIL_IF(emit_sse2_store(compiler, 0, SLJIT_MEM1(SLJIT_SP), offset, float_arg_count)); in tail_call_with_args()
911 FAIL_IF(emit_sse2_store(compiler, 0, SLJIT_MEM1(SLJIT_SP), offset, float_arg_count)); in tail_call_with_args()
919 EMIT_MOV(compiler, SLJIT_R2, 0, SLJIT_MEM1(SLJIT_SP), 0); in tail_call_with_args()
920 EMIT_MOV(compiler, SLJIT_MEM1(SLJIT_SP), offset, SLJIT_R2, 0); in tail_call_with_args()
922 EMIT_MOV(compiler, SLJIT_MEM1(SLJIT_SP), offset, SLJIT_R0, 0); in tail_call_with_args()
926 EMIT_MOV(compiler, SLJIT_MEM1(SLJIT_SP), offset, SLJIT_R1, 0); in tail_call_with_args()
930 EMIT_MOV(compiler, SLJIT_R2, 0, SLJIT_MEM1(SLJIT_SP), r2_offset); in tail_call_with_args()
931 EMIT_MOV(compiler, SLJIT_MEM1(SLJIT_SP), offset, SLJIT_R2, 0); in tail_call_with_args()
949 static sljit_s32 emit_tail_call_end(struct sljit_compiler *compiler, sljit_s32 extra_space) in emit_tail_call_end() argument
956 inst = (sljit_u8*)ensure_buf(compiler, 1 + 1); in emit_tail_call_end()
964 static sljit_s32 tail_call_reg_arg_with_args(struct sljit_compiler *compiler, sljit_s32 arg_types) in tail_call_reg_arg_with_args() argument
981 EMIT_MOV(compiler, TMP_REG1, 0, SLJIT_MEM1(SLJIT_SP), 2 * SSIZE_OF(sw)); in tail_call_reg_arg_with_args()
983 kept_saveds_count = SLJIT_KEPT_SAVEDS_COUNT(compiler->options); in tail_call_reg_arg_with_args()
984 offset = compiler->local_size + 3 * SSIZE_OF(sw); in tail_call_reg_arg_with_args()
986 if ((compiler->saveds > 0 && kept_saveds_count == 0) || compiler->scratches > 11) in tail_call_reg_arg_with_args()
988 if ((compiler->saveds > 1 && kept_saveds_count <= 1) || compiler->scratches > 10) in tail_call_reg_arg_with_args()
990 if ((compiler->saveds > 2 && kept_saveds_count <= 2) || compiler->scratches > 9) in tail_call_reg_arg_with_args()
993 return emit_mov(compiler, SLJIT_MEM1(SLJIT_SP), offset, TMP_REG1, 0); in tail_call_reg_arg_with_args()
996 SLJIT_API_FUNC_ATTRIBUTE struct sljit_jump* sljit_emit_call(struct sljit_compiler *compiler, sljit_… in sljit_emit_call() argument
1004 CHECK_PTR(check_sljit_emit_call(compiler, type, arg_types)); in sljit_emit_call()
1008 PTR_FAIL_IF(tail_call_reg_arg_with_args(compiler, arg_types)); in sljit_emit_call()
1009 PTR_FAIL_IF(emit_stack_frame_release(compiler, 0)); in sljit_emit_call()
1011 SLJIT_SKIP_CHECKS(compiler); in sljit_emit_call()
1012 return sljit_emit_jump(compiler, SLJIT_JUMP | (type & SLJIT_REWRITABLE_JUMP)); in sljit_emit_call()
1016 PTR_FAIL_IF(tail_call_with_args(compiler, &stack_size, arg_types, SLJIT_IMM, 0)); in sljit_emit_call()
1018 SLJIT_SKIP_CHECKS(compiler); in sljit_emit_call()
1021 return sljit_emit_jump(compiler, SLJIT_JUMP | (type & SLJIT_REWRITABLE_JUMP)); in sljit_emit_call()
1023 jump = sljit_emit_jump(compiler, type); in sljit_emit_call()
1026 PTR_FAIL_IF(emit_tail_call_end(compiler, stack_size)); in sljit_emit_call()
1031 SLJIT_SKIP_CHECKS(compiler); in sljit_emit_call()
1032 return sljit_emit_jump(compiler, type); in sljit_emit_call()
1036 PTR_FAIL_IF(call_with_args(compiler, arg_types, stack_size, word_arg_count, 0)); in sljit_emit_call()
1038 SLJIT_SKIP_CHECKS(compiler); in sljit_emit_call()
1039 jump = sljit_emit_jump(compiler, type); in sljit_emit_call()
1042 PTR_FAIL_IF(post_call_with_args(compiler, arg_types, stack_size)); in sljit_emit_call()
1046 SLJIT_API_FUNC_ATTRIBUTE sljit_s32 sljit_emit_icall(struct sljit_compiler *compiler, sljit_s32 type, in sljit_emit_icall() argument
1054 CHECK(check_sljit_emit_icall(compiler, type, arg_types, src, srcw)); in sljit_emit_icall()
1058 FAIL_IF(tail_call_reg_arg_with_args(compiler, arg_types)); in sljit_emit_icall()
1060 …if ((src & SLJIT_MEM) || (src > SLJIT_R2 && src <= (SLJIT_S0 - SLJIT_KEPT_SAVEDS_COUNT(compiler->o… in sljit_emit_icall()
1064 EMIT_MOV(compiler, TMP_REG1, 0, src, srcw); in sljit_emit_icall()
1069 FAIL_IF(emit_stack_frame_release(compiler, 0)); in sljit_emit_icall()
1071 SLJIT_SKIP_CHECKS(compiler); in sljit_emit_icall()
1072 return sljit_emit_ijump(compiler, SLJIT_JUMP, src, srcw); in sljit_emit_icall()
1076 FAIL_IF(tail_call_with_args(compiler, &stack_size, arg_types, src, srcw)); in sljit_emit_icall()
1083 SLJIT_SKIP_CHECKS(compiler); in sljit_emit_icall()
1086 return sljit_emit_ijump(compiler, SLJIT_JUMP, src, srcw); in sljit_emit_icall()
1088 FAIL_IF(sljit_emit_ijump(compiler, type, src, srcw)); in sljit_emit_icall()
1089 return emit_tail_call_end(compiler, stack_size); in sljit_emit_icall()
1093 SLJIT_SKIP_CHECKS(compiler); in sljit_emit_icall()
1094 return sljit_emit_ijump(compiler, type, src, srcw); in sljit_emit_icall()
1101 EMIT_MOV(compiler, TMP_REG1, 0, src, srcw); in sljit_emit_icall()
1107 FAIL_IF(call_with_args(compiler, arg_types, stack_size, word_arg_count, src == TMP_REG1)); in sljit_emit_icall()
1112 SLJIT_SKIP_CHECKS(compiler); in sljit_emit_icall()
1113 FAIL_IF(sljit_emit_ijump(compiler, type, src, srcw)); in sljit_emit_icall()
1115 return post_call_with_args(compiler, arg_types, stack_size); in sljit_emit_icall()
1118 static SLJIT_INLINE sljit_s32 emit_fmov_before_return(struct sljit_compiler *compiler, sljit_s32 op… in emit_fmov_before_return() argument
1122 if (compiler->options & SLJIT_ENTER_REG_ARG) { in emit_fmov_before_return()
1126 SLJIT_SKIP_CHECKS(compiler); in emit_fmov_before_return()
1127 return sljit_emit_fop1(compiler, op, SLJIT_RETURN_FREG, 0, src, srcw); in emit_fmov_before_return()
1131 FAIL_IF(emit_sse2_store(compiler, op & SLJIT_32, SLJIT_MEM1(SLJIT_SP), 0, src)); in emit_fmov_before_return()
1139 inst = emit_x86_instruction(compiler, 1 | EX86_SSE2_OP1, 0, 0, src, srcw); in emit_fmov_before_return()
1145 SLJIT_API_FUNC_ATTRIBUTE sljit_s32 sljit_emit_fast_enter(struct sljit_compiler *compiler, sljit_s32… in sljit_emit_fast_enter() argument
1150 CHECK(check_sljit_emit_fast_enter(compiler, dst, dstw)); in sljit_emit_fast_enter()
1157 inst = (sljit_u8*)ensure_buf(compiler, 1 + 1); in sljit_emit_fast_enter()
1166 inst = emit_x86_instruction(compiler, 1, 0, 0, dst, dstw); in sljit_emit_fast_enter()
1172 static sljit_s32 emit_fast_return(struct sljit_compiler *compiler, sljit_s32 src, sljit_sw srcw) in emit_fast_return() argument
1179 inst = (sljit_u8*)ensure_buf(compiler, 1 + 1 + 1); in emit_fast_return()
1186 inst = emit_x86_instruction(compiler, 1, 0, 0, src, srcw); in emit_fast_return()
1191 inst = (sljit_u8*)ensure_buf(compiler, 1 + 1); in emit_fast_return()
1204 SLJIT_API_FUNC_ATTRIBUTE sljit_s32 sljit_emit_mem(struct sljit_compiler *compiler, sljit_s32 type, in sljit_emit_mem() argument
1213 CHECK(check_sljit_emit_mem(compiler, type, reg, mem, memw)); in sljit_emit_mem()
1216 return sljit_emit_mem_unaligned(compiler, type, reg, mem, memw); in sljit_emit_mem()
1228 EMIT_MOV(compiler, TMP_REG1, 0, OFFS_REG(mem), 0); in sljit_emit_mem()
1253 EMIT_MOV(compiler, TMP_REG1, 0, SLJIT_MEM1(SLJIT_SP), offset); in sljit_emit_mem()
1257 inst = (sljit_u8*)ensure_buf(compiler, (sljit_uw)(1 + 4)); in sljit_emit_mem()
1267 EMIT_MOV(compiler, mem, memw, reg, 0); in sljit_emit_mem()
1269 EMIT_MOV(compiler, reg, 0, mem, memw); in sljit_emit_mem()
1276 EMIT_MOV(compiler, SLJIT_MEM1(SLJIT_SP), offset, TMP_REG1, 0); in sljit_emit_mem()
1282 static sljit_s32 skip_frames_before_return(struct sljit_compiler *compiler) in skip_frames_before_return() argument
1290 SLJIT_ASSERT(compiler->args_size >= 0); in skip_frames_before_return()
1291 SLJIT_ASSERT(compiler->local_size > 0); in skip_frames_before_return()
1293 size = compiler->local_size; in skip_frames_before_return()
1294 size += (1 + (compiler->scratches > 9 ? (compiler->scratches - 9) : 0) in skip_frames_before_return()
1295 + (compiler->saveds <= 3 ? compiler->saveds : 3)) * SSIZE_OF(sw); in skip_frames_before_return()
1297 return adjust_shadow_stack(compiler, SLJIT_MEM1(SLJIT_SP), size); in skip_frames_before_return()