for compiling tcc with msc
Unified · Split
| @@ -366,10 +366,12 @@ static uint8_t fastcall_regs[3] = { TREG_EAX, TREG_EDX, TREG_ECX }; · 365 unmodified lines | ||
| 366 | 366 | static uint8_t fastcallw_regs[2] = { TREG_ECX, TREG_EDX }; |
| 367 | 367 | |
| 368 | 368 | /* Return 1 if this function returns via an sret pointer, 0 otherwise */ |
| 369 | −ST_FUNC int gfunc_sret(CType *vt, CType *ret, int *ret_align) { | |
| 370 | − *ret_align = 1; // Never have to re-align return values for x86 | |
| 369 | +ST_FUNC int gfunc_sret(CType *vt, CType *ret, int *ret_align) | |
| 370 | +{ | |
| 371 | 371 | #ifdef TCC_TARGET_PE |
| 372 | 372 | int size, align; |
| 373 | + | |
| 374 | + *ret_align = 1; // Never have to re-align return values for x86 | |
| 373 | 375 | size = type_size(vt, &align); |
| 374 | 376 | if (size > 8) { |
| 375 | 377 | return 1; |
| @@ -383,6 +385,7 @@ ST_FUNC int gfunc_sret(CType *vt, CType *ret, int *ret_align) { · 7 unmodified lines | ||
| 383 | 385 | return 0; |
| 384 | 386 | } |
| 385 | 387 | #else |
| 388 | + *ret_align = 1; // Never have to re-align return values for x86 | |
| 386 | 389 | return 1; |
| 387 | 390 | #endif |
| 388 | 391 | } |
| @@ -3995,9 +3995,10 @@ ST_FUNC void unary(void) · 3994 unmodified lines | ||
| 3995 | 3995 | vtop->r2 = ret.r2; |
| 3996 | 3996 | /* handle packed struct return */ |
| 3997 | 3997 | if (((s->type.t & VT_BTYPE) == VT_STRUCT) && !sret) { |
| 3998 | + int addr; | |
| 3998 | 3999 | size = type_size(&s->type, &align); |
| 3999 | 4000 | loc = (loc - size) & -align; |
| 4000 | − int addr = loc; | |
| 4001 | + addr = loc; | |
| 4001 | 4002 | vset(&ret.type, VT_LOCAL | VT_LVAL, addr); |
| 4002 | 4003 | vswap(); |
| 4003 | 4004 | vstore(); |
| @@ -4493,7 +4494,8 @@ static void block(int *bsym, int *csym, int *case_sym, int *def_sym, · 489 unmodified lines | ||
| 4493 | 4494 | gsym_addr(b, d); |
| 4494 | 4495 | } else if (tok == '{') { |
| 4495 | 4496 | Sym *llabel; |
| 4496 | − | |
| 4497 | + int block_vla_sp_loc, *saved_vla_sp_loc, saved_vla_flags; | |
| 4498 | + | |
| 4497 | 4499 | next(); |
| 4498 | 4500 | /* record local declaration stack position */ |
| 4499 | 4501 | s = local_stack; |
| @@ -4503,12 +4505,11 @@ static void block(int *bsym, int *csym, int *case_sym, int *def_sym, · 3 unmodified lines | ||
| 4503 | 4505 | llabel = local_label_stack; |
| 4504 | 4506 | |
| 4505 | 4507 | /* save VLA state */ |
| 4506 | − int block_vla_sp_loc = *vla_sp_loc; | |
| 4507 | − int *saved_vla_sp_loc = vla_sp_loc; | |
| 4508 | + block_vla_sp_loc = *(saved_vla_sp_loc = vla_sp_loc); | |
| 4508 | 4509 | if (saved_vla_sp_loc != &vla_sp_root_loc) |
| 4509 | 4510 | vla_sp_loc = &block_vla_sp_loc; |
| 4510 | 4511 | |
| 4511 | − int saved_vla_flags = vla_flags; | |
| 4512 | + saved_vla_flags = vla_flags; | |
| 4512 | 4513 | vla_flags |= VLA_NEED_NEW_FRAME; |
| 4513 | 4514 | |
| 4514 | 4515 | /* handle local labels declarations */ |
| @@ -664,9 +664,10 @@ void gen_offs_sp(int b, int r, int d) · 663 unmodified lines | ||
| 664 | 664 | } |
| 665 | 665 | |
| 666 | 666 | /* Return 1 if this function returns via an sret pointer, 0 otherwise */ |
| 667 | −ST_FUNC int gfunc_sret(CType *vt, CType *ret, int *ret_align) { | |
| 668 | − *ret_align = 1; // Never have to re-align return values for x86-64 | |
| 667 | +ST_FUNC int gfunc_sret(CType *vt, CType *ret, int *ret_align) | |
| 668 | +{ | |
| 669 | 669 | int size, align; |
| 670 | + *ret_align = 1; // Never have to re-align return values for x86-64 | |
| 670 | 671 | size = type_size(vt, &align); |
| 671 | 672 | ret->ref = NULL; |
| 672 | 673 | if (size > 8) { |
| @@ -687,9 +688,9 @@ ST_FUNC int gfunc_sret(CType *vt, CType *ret, int *ret_align) { · 14 unmodified lines | ||
| 687 | 688 | } |
| 688 | 689 | |
| 689 | 690 | int gfunc_arg_size(CType *type) { |
| 691 | + int align; | |
| 690 | 692 | if (type->t & (VT_ARRAY|VT_BITFIELD)) |
| 691 | 693 | return 8; |
| 692 | − int align; | |
| 693 | 694 | return type_size(type, &align); |
| 694 | 695 | } |
| 695 | 696 | |
| @@ -706,9 +707,10 @@ void gfunc_call(int nb_args) · 10 unmodified lines | ||
| 706 | 707 | So, we process arguments which will be passed by stack first. */ |
| 707 | 708 | struct_size = args_size; |
| 708 | 709 | for(i = 0; i < nb_args; i++) { |
| 709 | − --arg; | |
| 710 | + SValue *sv; | |
| 710 | 711 | |
| 711 | − SValue *sv = &vtop[-i]; | |
| 712 | + --arg; | |
| 713 | + sv = &vtop[-i]; | |
| 712 | 714 | bt = (sv->type.t & VT_BTYPE); |
| 713 | 715 | size = gfunc_arg_size(&sv->type); |
| 714 | 716 | |
| @@ -2025,8 +2027,9 @@ void gen_cvt_ftof(int t) · 1310 unmodified lines | ||
| 2025 | 2027 | vtop->r = TREG_ST0; |
| 2026 | 2028 | } |
| 2027 | 2029 | } else { |
| 2030 | + int r; | |
| 2028 | 2031 | gv(RC_ST0); |
| 2029 | − int r = get_reg(RC_FLOAT); | |
| 2032 | + r = get_reg(RC_FLOAT); | |
| 2030 | 2033 | if (tbt == VT_DOUBLE) { |
| 2031 | 2034 | o(0xf0245cdd); /* fstpl -0x10(%rsp) */ |
| 2032 | 2035 | /* movsd -0x10(%rsp),%xmm0 */ |