Lines Matching refs:compiler

29 static sljit_s32 emit_do_imm(struct sljit_compiler *compiler, sljit_u8 opcode, sljit_sw imm)  in emit_do_imm()  argument
33 inst = (sljit_u8*)ensure_buf(compiler, 1 + 1 + sizeof(sljit_sw)); in emit_do_imm()
68 SLJIT_API_FUNC_ATTRIBUTE sljit_s32 sljit_emit_enter(struct sljit_compiler *compiler, in sljit_emit_enter() argument
76 …CHECK(check_sljit_emit_enter(compiler, options, arg_types, scratches, saveds, fscratches, fsaveds,… in sljit_emit_enter()
77 set_emit_enter(compiler, options, arg_types, scratches, saveds, fscratches, fsaveds, local_size); in sljit_emit_enter()
80 FAIL_IF(emit_endbranch(compiler)); in sljit_emit_enter()
83 compiler->args = args; in sljit_emit_enter()
86 compiler->stack_tmp_size = 2 * sizeof(sljit_sw); in sljit_emit_enter()
90 compiler->stack_tmp_size = 3 * sizeof(sljit_sw); in sljit_emit_enter()
93 compiler->saveds_offset = compiler->stack_tmp_size; in sljit_emit_enter()
95 compiler->saveds_offset += ((scratches > (3 + 6)) ? 6 : (scratches - 3)) * sizeof(sljit_sw); in sljit_emit_enter()
97 compiler->locals_offset = compiler->saveds_offset; in sljit_emit_enter()
100 compiler->locals_offset += (saveds - 3) * sizeof(sljit_sw); in sljit_emit_enter()
103compiler->locals_offset = (compiler->locals_offset + sizeof(sljit_f64) - 1) & ~(sizeof(sljit_f64) … in sljit_emit_enter()
111 inst = (sljit_u8*)ensure_buf(compiler, 1 + size); in sljit_emit_enter()
179 compiler->local_size = local_size; in sljit_emit_enter()
185 EMIT_MOV(compiler, TMP_REG1, 0, SLJIT_MEM1(SLJIT_SP), -4096); in sljit_emit_enter()
187 EMIT_MOV(compiler, TMP_REG1, 0, SLJIT_MEM1(SLJIT_SP), -4096 * 2); in sljit_emit_enter()
189 EMIT_MOV(compiler, TMP_REG1, 0, SLJIT_MEM1(SLJIT_SP), -4096 * 3); in sljit_emit_enter()
192 EMIT_MOV(compiler, SLJIT_R0, 0, SLJIT_SP, 0); in sljit_emit_enter()
193 EMIT_MOV(compiler, SLJIT_R1, 0, SLJIT_IMM, (local_size - 1) >> 12); in sljit_emit_enter()
197 EMIT_MOV(compiler, TMP_REG1, 0, SLJIT_MEM1(SLJIT_R0), -4096); in sljit_emit_enter()
198 FAIL_IF(emit_non_cum_binary(compiler, BINARY_OPCODE(SUB), in sljit_emit_enter()
200 FAIL_IF(emit_non_cum_binary(compiler, BINARY_OPCODE(SUB), in sljit_emit_enter()
203 inst = (sljit_u8*)ensure_buf(compiler, 1 + 2); in sljit_emit_enter()
211 EMIT_MOV(compiler, TMP_REG1, 0, SLJIT_MEM1(SLJIT_SP), -local_size); in sljit_emit_enter()
219 EMIT_MOV(compiler, TMP_REG1, 0, SLJIT_SP, 0); in sljit_emit_enter()
222 FAIL_IF(emit_non_cum_binary(compiler, BINARY_OPCODE(SUB), in sljit_emit_enter()
226 if (compiler->local_size > 1024) in sljit_emit_enter()
227 FAIL_IF(emit_cum_binary(compiler, BINARY_OPCODE(ADD), in sljit_emit_enter()
231 inst = (sljit_u8*)ensure_buf(compiler, 1 + 6); in sljit_emit_enter()
240 return emit_mov(compiler, SLJIT_MEM1(SLJIT_SP), compiler->local_size, TMP_REG1, 0); in sljit_emit_enter()
243 return emit_non_cum_binary(compiler, BINARY_OPCODE(SUB), in sljit_emit_enter()
247 SLJIT_API_FUNC_ATTRIBUTE sljit_s32 sljit_set_context(struct sljit_compiler *compiler, in sljit_set_context() argument
252 …CHECK(check_sljit_set_context(compiler, options, arg_types, scratches, saveds, fscratches, fsaveds… in sljit_set_context()
253 set_set_context(compiler, options, arg_types, scratches, saveds, fscratches, fsaveds, local_size); in sljit_set_context()
255 compiler->args = get_arg_count(arg_types); in sljit_set_context()
258 compiler->stack_tmp_size = 2 * sizeof(sljit_sw); in sljit_set_context()
262 compiler->stack_tmp_size = 3 * sizeof(sljit_sw); in sljit_set_context()
265 compiler->saveds_offset = compiler->stack_tmp_size; in sljit_set_context()
267 compiler->saveds_offset += ((scratches > (3 + 6)) ? 6 : (scratches - 3)) * sizeof(sljit_sw); in sljit_set_context()
269 compiler->locals_offset = compiler->saveds_offset; in sljit_set_context()
272 compiler->locals_offset += (saveds - 3) * sizeof(sljit_sw); in sljit_set_context()
275compiler->locals_offset = (compiler->locals_offset + sizeof(sljit_f64) - 1) & ~(sizeof(sljit_f64) … in sljit_set_context()
279 compiler->local_size = ((SLJIT_LOCALS_OFFSET + saveds + local_size + 15) & ~15) - saveds; in sljit_set_context()
282compiler->local_size = SLJIT_LOCALS_OFFSET + ((local_size + sizeof(sljit_f64) - 1) & ~(sizeof(slji… in sljit_set_context()
284compiler->local_size = SLJIT_LOCALS_OFFSET + ((local_size + sizeof(sljit_sw) - 1) & ~(sizeof(sljit… in sljit_set_context()
289 SLJIT_API_FUNC_ATTRIBUTE sljit_s32 sljit_emit_return(struct sljit_compiler *compiler, sljit_s32 op,… in sljit_emit_return() argument
295 CHECK(check_sljit_emit_return(compiler, op, src, srcw)); in sljit_emit_return()
296 SLJIT_ASSERT(compiler->args >= 0); in sljit_emit_return()
298 FAIL_IF(emit_mov_before_return(compiler, op, src, srcw)); in sljit_emit_return()
300 SLJIT_ASSERT(compiler->local_size > 0); in sljit_emit_return()
303 if (compiler->options & SLJIT_F64_ALIGNMENT) in sljit_emit_return()
304 EMIT_MOV(compiler, SLJIT_SP, 0, SLJIT_MEM1(SLJIT_SP), compiler->local_size) in sljit_emit_return()
306 FAIL_IF(emit_cum_binary(compiler, BINARY_OPCODE(ADD), in sljit_emit_return()
307 SLJIT_SP, 0, SLJIT_SP, 0, SLJIT_IMM, compiler->local_size)); in sljit_emit_return()
309 FAIL_IF(emit_cum_binary(compiler, BINARY_OPCODE(ADD), in sljit_emit_return()
310 SLJIT_SP, 0, SLJIT_SP, 0, SLJIT_IMM, compiler->local_size)); in sljit_emit_return()
313 size = 2 + (compiler->scratches > 9 ? (compiler->scratches - 9) : 0) + in sljit_emit_return()
314 (compiler->saveds <= 3 ? compiler->saveds : 3); in sljit_emit_return()
316 if (compiler->args > 2) in sljit_emit_return()
319 inst = (sljit_u8*)ensure_buf(compiler, 1 + size); in sljit_emit_return()
324 if (compiler->saveds > 0 || compiler->scratches > 11) in sljit_emit_return()
326 if (compiler->saveds > 1 || compiler->scratches > 10) in sljit_emit_return()
328 if (compiler->saveds > 2 || compiler->scratches > 9) in sljit_emit_return()
332 if (compiler->args > 2) in sljit_emit_return()
348 static sljit_u8* emit_x86_instruction(struct sljit_compiler *compiler, sljit_s32 size, in emit_x86_instruction() argument
426 inst = (sljit_u8*)ensure_buf(compiler, 1 + inst_size); in emit_x86_instruction()
550 static sljit_s32 c_fast_call_with_args(struct sljit_compiler *compiler, in c_fast_call_with_args() argument
557 inst = (sljit_u8*)ensure_buf(compiler, 1 + 1); in c_fast_call_with_args()
564 … EMIT_MOV(compiler, TMP_REG1, 0, SLJIT_MEM1(SLJIT_SP), compiler->saveds_offset - sizeof(sljit_sw)); in c_fast_call_with_args()
566 FAIL_IF(emit_non_cum_binary(compiler, BINARY_OPCODE(SUB), in c_fast_call_with_args()
577 FAIL_IF(emit_sse2_store(compiler, 1, SLJIT_MEM1(SLJIT_SP), stack_size, float_arg_count)); in c_fast_call_with_args()
582 FAIL_IF(emit_sse2_store(compiler, 0, SLJIT_MEM1(SLJIT_SP), stack_size, float_arg_count)); in c_fast_call_with_args()
588 EMIT_MOV(compiler, SLJIT_MEM1(SLJIT_SP), stack_size, SLJIT_R2, 0); in c_fast_call_with_args()
592 EMIT_MOV(compiler, SLJIT_MEM1(SLJIT_SP), stack_size, TMP_REG1, 0); in c_fast_call_with_args()
604 inst = (sljit_u8*)ensure_buf(compiler, 1 + 1); in c_fast_call_with_args()
611 inst = (sljit_u8*)ensure_buf(compiler, 1 + 2); in c_fast_call_with_args()
625 static sljit_s32 cdecl_call_get_stack_size(struct sljit_compiler *compiler, sljit_s32 arg_types, sl… in cdecl_call_get_stack_size() argument
652 if (stack_size <= compiler->stack_tmp_size) in cdecl_call_get_stack_size()
656 return ((stack_size - compiler->stack_tmp_size + 15) & ~15); in cdecl_call_get_stack_size()
658 return stack_size - compiler->stack_tmp_size; in cdecl_call_get_stack_size()
662 static sljit_s32 cdecl_call_with_args(struct sljit_compiler *compiler, in cdecl_call_with_args() argument
668 EMIT_MOV(compiler, TMP_REG1, 0, SLJIT_MEM1(SLJIT_SP), compiler->saveds_offset - sizeof(sljit_sw)); in cdecl_call_with_args()
671 FAIL_IF(emit_non_cum_binary(compiler, BINARY_OPCODE(SUB), in cdecl_call_with_args()
682 FAIL_IF(emit_sse2_store(compiler, 1, SLJIT_MEM1(SLJIT_SP), stack_size, float_arg_count)); in cdecl_call_with_args()
687 FAIL_IF(emit_sse2_store(compiler, 0, SLJIT_MEM1(SLJIT_SP), stack_size, float_arg_count)); in cdecl_call_with_args()
692 …EMIT_MOV(compiler, SLJIT_MEM1(SLJIT_SP), stack_size, (word_arg_count >= 4) ? TMP_REG1 : word_arg_c… in cdecl_call_with_args()
703 static sljit_s32 post_call_with_args(struct sljit_compiler *compiler, in post_call_with_args() argument
710 FAIL_IF(emit_cum_binary(compiler, BINARY_OPCODE(ADD), in post_call_with_args()
718 inst = (sljit_u8*)ensure_buf(compiler, 1 + 3); in post_call_with_args()
725 return emit_sse2_load(compiler, single, SLJIT_FR0, SLJIT_MEM1(SLJIT_SP), 0); in post_call_with_args()
728 SLJIT_API_FUNC_ATTRIBUTE struct sljit_jump* sljit_emit_call(struct sljit_compiler *compiler, sljit_… in sljit_emit_call() argument
736 CHECK_PTR(check_sljit_emit_call(compiler, type, arg_types)); in sljit_emit_call()
741 PTR_FAIL_IF(c_fast_call_with_args(compiler, arg_types, stack_size, word_arg_count, 0)); in sljit_emit_call()
745 compiler->skip_checks = 1; in sljit_emit_call()
748 jump = sljit_emit_jump(compiler, type); in sljit_emit_call()
751 PTR_FAIL_IF(post_call_with_args(compiler, arg_types, 0)); in sljit_emit_call()
756 stack_size = cdecl_call_get_stack_size(compiler, arg_types, &word_arg_count); in sljit_emit_call()
757 PTR_FAIL_IF(cdecl_call_with_args(compiler, arg_types, stack_size, word_arg_count)); in sljit_emit_call()
761 compiler->skip_checks = 1; in sljit_emit_call()
764 jump = sljit_emit_jump(compiler, type); in sljit_emit_call()
767 PTR_FAIL_IF(post_call_with_args(compiler, arg_types, stack_size)); in sljit_emit_call()
771 SLJIT_API_FUNC_ATTRIBUTE sljit_s32 sljit_emit_icall(struct sljit_compiler *compiler, sljit_s32 type, in sljit_emit_icall() argument
782 CHECK(check_sljit_emit_icall(compiler, type, arg_types, src, srcw)); in sljit_emit_icall()
801 FAIL_IF(c_fast_call_with_args(compiler, arg_types, stack_size, word_arg_count, swap_args)); in sljit_emit_icall()
803 compiler->saveds_offset += stack_size; in sljit_emit_icall()
804 compiler->locals_offset += stack_size; in sljit_emit_icall()
808 compiler->skip_checks = 1; in sljit_emit_icall()
810 FAIL_IF(sljit_emit_ijump(compiler, type, src, srcw)); in sljit_emit_icall()
812 compiler->saveds_offset -= stack_size; in sljit_emit_icall()
813 compiler->locals_offset -= stack_size; in sljit_emit_icall()
815 return post_call_with_args(compiler, arg_types, 0); in sljit_emit_icall()
819 stack_size = cdecl_call_get_stack_size(compiler, arg_types, &word_arg_count); in sljit_emit_icall()
820 FAIL_IF(cdecl_call_with_args(compiler, arg_types, stack_size, word_arg_count)); in sljit_emit_icall()
822 compiler->saveds_offset += stack_size; in sljit_emit_icall()
823 compiler->locals_offset += stack_size; in sljit_emit_icall()
827 compiler->skip_checks = 1; in sljit_emit_icall()
829 FAIL_IF(sljit_emit_ijump(compiler, type, src, srcw)); in sljit_emit_icall()
831 compiler->saveds_offset -= stack_size; in sljit_emit_icall()
832 compiler->locals_offset -= stack_size; in sljit_emit_icall()
834 return post_call_with_args(compiler, arg_types, stack_size); in sljit_emit_icall()
837 SLJIT_API_FUNC_ATTRIBUTE sljit_s32 sljit_emit_fast_enter(struct sljit_compiler *compiler, sljit_s32… in sljit_emit_fast_enter() argument
842 CHECK(check_sljit_emit_fast_enter(compiler, dst, dstw)); in sljit_emit_fast_enter()
853 inst = (sljit_u8*)ensure_buf(compiler, 1 + 1); in sljit_emit_fast_enter()
862 inst = emit_x86_instruction(compiler, 1, 0, 0, dst, dstw); in sljit_emit_fast_enter()
868 static sljit_s32 emit_fast_return(struct sljit_compiler *compiler, sljit_s32 src, sljit_sw srcw) in emit_fast_return() argument
875 inst = (sljit_u8*)ensure_buf(compiler, 1 + 1 + 1); in emit_fast_return()
882 inst = emit_x86_instruction(compiler, 1, 0, 0, src, srcw); in emit_fast_return()
887 inst = (sljit_u8*)ensure_buf(compiler, 1 + 1); in emit_fast_return()
896 static sljit_s32 skip_frames_before_return(struct sljit_compiler *compiler) in skip_frames_before_return() argument
905 SLJIT_ASSERT(compiler->args >= 0); in skip_frames_before_return()
906 SLJIT_ASSERT(compiler->local_size > 0); in skip_frames_before_return()
909 has_f64_aligment = compiler->options & SLJIT_F64_ALIGNMENT; in skip_frames_before_return()
914 size = compiler->local_size; in skip_frames_before_return()
915 …saved_size = (1 + (compiler->scratches > 9 ? (compiler->scratches - 9) : 0) + (compiler->saveds <=… in skip_frames_before_return()
918 EMIT_MOV(compiler, TMP_REG1, 0, SLJIT_MEM1(SLJIT_SP), size); in skip_frames_before_return()
920 EMIT_MOV(compiler, TMP_REG1, 0, SLJIT_MEM1(TMP_REG1), saved_size); in skip_frames_before_return()
922 EMIT_MOV(compiler, SLJIT_MEM1(SLJIT_SP), 0, TMP_REG1, 0); in skip_frames_before_return()
927 return adjust_shadow_stack(compiler, SLJIT_UNUSED, 0, SLJIT_SP, size); in skip_frames_before_return()