mirror of
https://github.com/mirror/tinycc.git
synced 2025-01-29 06:10:09 +08:00
avoid "decl after statement" please
for compiling tcc with msc
This commit is contained in:
parent
41b3c7a507
commit
be1b6ba7b7
@ -366,10 +366,12 @@ static uint8_t fastcall_regs[3] = { TREG_EAX, TREG_EDX, TREG_ECX };
|
|||||||
static uint8_t fastcallw_regs[2] = { TREG_ECX, TREG_EDX };
|
static uint8_t fastcallw_regs[2] = { TREG_ECX, TREG_EDX };
|
||||||
|
|
||||||
/* Return 1 if this function returns via an sret pointer, 0 otherwise */
|
/* Return 1 if this function returns via an sret pointer, 0 otherwise */
|
||||||
ST_FUNC int gfunc_sret(CType *vt, CType *ret, int *ret_align) {
|
ST_FUNC int gfunc_sret(CType *vt, CType *ret, int *ret_align)
|
||||||
*ret_align = 1; // Never have to re-align return values for x86
|
{
|
||||||
#ifdef TCC_TARGET_PE
|
#ifdef TCC_TARGET_PE
|
||||||
int size, align;
|
int size, align;
|
||||||
|
|
||||||
|
*ret_align = 1; // Never have to re-align return values for x86
|
||||||
size = type_size(vt, &align);
|
size = type_size(vt, &align);
|
||||||
if (size > 8) {
|
if (size > 8) {
|
||||||
return 1;
|
return 1;
|
||||||
@ -383,6 +385,7 @@ ST_FUNC int gfunc_sret(CType *vt, CType *ret, int *ret_align) {
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
#else
|
#else
|
||||||
|
*ret_align = 1; // Never have to re-align return values for x86
|
||||||
return 1;
|
return 1;
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
9
tccgen.c
9
tccgen.c
@ -3995,9 +3995,10 @@ ST_FUNC void unary(void)
|
|||||||
vtop->r2 = ret.r2;
|
vtop->r2 = ret.r2;
|
||||||
/* handle packed struct return */
|
/* handle packed struct return */
|
||||||
if (((s->type.t & VT_BTYPE) == VT_STRUCT) && !sret) {
|
if (((s->type.t & VT_BTYPE) == VT_STRUCT) && !sret) {
|
||||||
|
int addr;
|
||||||
size = type_size(&s->type, &align);
|
size = type_size(&s->type, &align);
|
||||||
loc = (loc - size) & -align;
|
loc = (loc - size) & -align;
|
||||||
int addr = loc;
|
addr = loc;
|
||||||
vset(&ret.type, VT_LOCAL | VT_LVAL, addr);
|
vset(&ret.type, VT_LOCAL | VT_LVAL, addr);
|
||||||
vswap();
|
vswap();
|
||||||
vstore();
|
vstore();
|
||||||
@ -4493,6 +4494,7 @@ static void block(int *bsym, int *csym, int *case_sym, int *def_sym,
|
|||||||
gsym_addr(b, d);
|
gsym_addr(b, d);
|
||||||
} else if (tok == '{') {
|
} else if (tok == '{') {
|
||||||
Sym *llabel;
|
Sym *llabel;
|
||||||
|
int block_vla_sp_loc, *saved_vla_sp_loc, saved_vla_flags;
|
||||||
|
|
||||||
next();
|
next();
|
||||||
/* record local declaration stack position */
|
/* record local declaration stack position */
|
||||||
@ -4503,12 +4505,11 @@ static void block(int *bsym, int *csym, int *case_sym, int *def_sym,
|
|||||||
llabel = local_label_stack;
|
llabel = local_label_stack;
|
||||||
|
|
||||||
/* save VLA state */
|
/* save VLA state */
|
||||||
int block_vla_sp_loc = *vla_sp_loc;
|
block_vla_sp_loc = *(saved_vla_sp_loc = vla_sp_loc);
|
||||||
int *saved_vla_sp_loc = vla_sp_loc;
|
|
||||||
if (saved_vla_sp_loc != &vla_sp_root_loc)
|
if (saved_vla_sp_loc != &vla_sp_root_loc)
|
||||||
vla_sp_loc = &block_vla_sp_loc;
|
vla_sp_loc = &block_vla_sp_loc;
|
||||||
|
|
||||||
int saved_vla_flags = vla_flags;
|
saved_vla_flags = vla_flags;
|
||||||
vla_flags |= VLA_NEED_NEW_FRAME;
|
vla_flags |= VLA_NEED_NEW_FRAME;
|
||||||
|
|
||||||
/* handle local labels declarations */
|
/* handle local labels declarations */
|
||||||
|
15
x86_64-gen.c
15
x86_64-gen.c
@ -664,9 +664,10 @@ void gen_offs_sp(int b, int r, int d)
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* Return 1 if this function returns via an sret pointer, 0 otherwise */
|
/* Return 1 if this function returns via an sret pointer, 0 otherwise */
|
||||||
ST_FUNC int gfunc_sret(CType *vt, CType *ret, int *ret_align) {
|
ST_FUNC int gfunc_sret(CType *vt, CType *ret, int *ret_align)
|
||||||
*ret_align = 1; // Never have to re-align return values for x86-64
|
{
|
||||||
int size, align;
|
int size, align;
|
||||||
|
*ret_align = 1; // Never have to re-align return values for x86-64
|
||||||
size = type_size(vt, &align);
|
size = type_size(vt, &align);
|
||||||
ret->ref = NULL;
|
ret->ref = NULL;
|
||||||
if (size > 8) {
|
if (size > 8) {
|
||||||
@ -687,9 +688,9 @@ ST_FUNC int gfunc_sret(CType *vt, CType *ret, int *ret_align) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
int gfunc_arg_size(CType *type) {
|
int gfunc_arg_size(CType *type) {
|
||||||
|
int align;
|
||||||
if (type->t & (VT_ARRAY|VT_BITFIELD))
|
if (type->t & (VT_ARRAY|VT_BITFIELD))
|
||||||
return 8;
|
return 8;
|
||||||
int align;
|
|
||||||
return type_size(type, &align);
|
return type_size(type, &align);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -706,9 +707,10 @@ void gfunc_call(int nb_args)
|
|||||||
So, we process arguments which will be passed by stack first. */
|
So, we process arguments which will be passed by stack first. */
|
||||||
struct_size = args_size;
|
struct_size = args_size;
|
||||||
for(i = 0; i < nb_args; i++) {
|
for(i = 0; i < nb_args; i++) {
|
||||||
--arg;
|
SValue *sv;
|
||||||
|
|
||||||
SValue *sv = &vtop[-i];
|
--arg;
|
||||||
|
sv = &vtop[-i];
|
||||||
bt = (sv->type.t & VT_BTYPE);
|
bt = (sv->type.t & VT_BTYPE);
|
||||||
size = gfunc_arg_size(&sv->type);
|
size = gfunc_arg_size(&sv->type);
|
||||||
|
|
||||||
@ -2025,8 +2027,9 @@ void gen_cvt_ftof(int t)
|
|||||||
vtop->r = TREG_ST0;
|
vtop->r = TREG_ST0;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
int r;
|
||||||
gv(RC_ST0);
|
gv(RC_ST0);
|
||||||
int r = get_reg(RC_FLOAT);
|
r = get_reg(RC_FLOAT);
|
||||||
if (tbt == VT_DOUBLE) {
|
if (tbt == VT_DOUBLE) {
|
||||||
o(0xf0245cdd); /* fstpl -0x10(%rsp) */
|
o(0xf0245cdd); /* fstpl -0x10(%rsp) */
|
||||||
/* movsd -0x10(%rsp),%xmm0 */
|
/* movsd -0x10(%rsp),%xmm0 */
|
||||||
|
Loading…
Reference in New Issue
Block a user