@@ -2937,6 +2937,9 @@ store_int:
2937
2937
ir_match_fuse_load(ctx, insn->op1, ref);
2938
2938
return (ctx->mflags & IR_X86_BMI1) ? IR_BIT_COUNT : IR_CTPOP;
2939
2939
case IR_VA_START:
2940
+ #ifdef IR_HAVE_PRESERVE_NONE
2941
+ IR_ASSERT(!(ctx->flags & IR_PRESERVE_NONE_FUNC) && "preserve_none does not support var args");
2942
+ #endif
2940
2943
ctx->flags2 |= IR_HAS_VA_START;
2941
2944
if ((ctx->ir_base[insn->op2].op == IR_ALLOCA) || (ctx->ir_base[insn->op2].op == IR_VADDR)) {
2942
2945
ir_use_list *use_list = &ctx->use_lists[insn->op2];
@@ -3789,20 +3792,9 @@ static void ir_emit_prologue(ir_ctx *ctx)
3789
3792
| mov [Ra(fp)+offset+24], Ra(IR_REG_INT_ARG4)
3790
3793
#elif defined(IR_TARGET_X64)
3791
3794
|.if X64
3792
- int int_reg_params_count = IR_REG_INT_ARGS;
3793
3795
const int8_t *int_reg_params = _ir_int_reg_params;
3794
3796
const int8_t *fp_reg_params = _ir_fp_reg_params;
3795
3797
3796
- IR_CHECK_CALLING_CONV(ctx->flags);
3797
-
3798
- # ifdef IR_HAVE_PRESERVE_NONE
3799
- // TODO: test
3800
- if (ctx->flags & IR_PRESERVE_NONE_FUNC) {
3801
- int_reg_params_count = IR_REG_INT_PNARGS;
3802
- int_reg_params = _ir_int_pn_reg_params;
3803
- }
3804
- # endif
3805
-
3806
3798
uint32_t i;
3807
3799
ir_reg fp;
3808
3800
int offset;
@@ -3819,7 +3811,7 @@ static void ir_emit_prologue(ir_ctx *ctx)
3819
3811
if ((ctx->flags2 & (IR_HAS_VA_ARG_GP|IR_HAS_VA_COPY)) && ctx->gp_reg_params < IR_REG_INT_ARGS) {
3820
3812
/* skip named args */
3821
3813
offset += sizeof(void*) * ctx->gp_reg_params;
3822
- for (i = ctx->gp_reg_params; i < int_reg_params_count ; i++) {
3814
+ for (i = ctx->gp_reg_params; i < IR_REG_INT_ARGS ; i++) {
3823
3815
| mov qword [Ra(fp)+offset], Rq(int_reg_params[i])
3824
3816
offset += sizeof(void*);
3825
3817
}
@@ -8350,7 +8342,6 @@ static void ir_emit_va_start(ir_ctx *ctx, ir_ref def, ir_insn *insn)
8350
8342
overflow_arg_area_offset = ctx->stack_frame_size + ctx->call_stack_size + sizeof(void*) + ctx->param_stack_size;
8351
8343
}
8352
8344
8353
- // TODO: preserve none
8354
8345
if ((ctx->flags2 & (IR_HAS_VA_ARG_GP|IR_HAS_VA_COPY)) && ctx->gp_reg_params < IR_REG_INT_ARGS) {
8355
8346
| lea Ra(tmp_reg), aword [Ra(fp)+reg_save_area_offset]
8356
8347
have_reg_save_area = 1;
@@ -8518,7 +8509,6 @@ static void ir_emit_va_arg(ir_ctx *ctx, ir_ref def, ir_insn *insn)
8518
8509
op2_reg = (ctx->flags & IR_USE_FRAME_POINTER) ? IR_REG_FRAME_POINTER : IR_REG_STACK_POINTER;
8519
8510
offset = IR_SPILL_POS_TO_OFFSET(ctx->ir_base[insn->op2].op3);
8520
8511
}
8521
- // TODO: preserve none
8522
8512
if (IR_IS_TYPE_INT(type)) {
8523
8513
| mov Rd(tmp_reg), dword [Ra(op2_reg)+(offset+offsetof(ir_va_list, gp_offset))]
8524
8514
| cmp Rd(tmp_reg), sizeof(void*)*IR_REG_INT_ARGS
@@ -10614,7 +10604,6 @@ void ir_fix_stack_frame(ir_ctx *ctx)
10614
10604
ctx->flags2 |= IR_16B_FRAME_ALIGNMENT;
10615
10605
ctx->stack_frame_size = IR_ALIGNED_SIZE(ctx->stack_frame_size, 16);
10616
10606
ctx->locals_area_size = ctx->stack_frame_size;
10617
- // TODO: preserve none
10618
10607
if ((ctx->flags2 & (IR_HAS_VA_ARG_GP|IR_HAS_VA_COPY)) && ctx->gp_reg_params < IR_REG_INT_ARGS) {
10619
10608
additional_size += sizeof(void*) * IR_REG_INT_ARGS;
10620
10609
}
0 commit comments