History

avoid "decl after statement" please

for compiling tcc with msc

grischka committed 13 years ago

Commit be1b6ba1 parent 41b3c7a3 files · +20 −13Browse files

Unified · Split

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

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t