From 68666eee2ade45ab73b07361367d0a38d350d663 Mon Sep 17 00:00:00 2001 From: grischka Date: Wed, 8 Feb 2017 19:45:31 +0100 Subject: tccgen: factor out gfunc_return Also: - on windows i386 and x86-64, structures of size <= 8 are NOT returned in registers if size is not one of 1,2,4,8. - cleanup: put all tv-push/pop/swap/rot into one place --- arm64-gen.c | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) (limited to 'arm64-gen.c') diff --git a/arm64-gen.c b/arm64-gen.c index 71e977e..0ff6099 100644 --- a/arm64-gen.c +++ b/arm64-gen.c @@ -1193,9 +1193,9 @@ ST_FUNC int gfunc_sret(CType *vt, int variadic, CType *ret, return 0; } -ST_FUNC void greturn(void) +ST_FUNC void gfunc_return(CType *func_type) { - CType *t = &func_vt; + CType *t = func_type; unsigned long a; arm64_pcs(0, &t, &a); @@ -1203,8 +1203,8 @@ ST_FUNC void greturn(void) case -1: break; case 0: - if ((func_vt.t & VT_BTYPE) == VT_STRUCT) { - int align, size = type_size(&func_vt, &align); + if ((func_type->t & VT_BTYPE) == VT_STRUCT) { + int align, size = type_size(func_type, &align); gaddrof(); gv(RC_R(0)); arm64_ldrs(0, size); @@ -1213,7 +1213,7 @@ ST_FUNC void greturn(void) gv(RC_IRET); break; case 1: { - CType type = func_vt; + CType type = *func_type; mk_pointer(&type); vset(&type, VT_LOCAL | VT_LVAL, func_vc); indir(); @@ -1222,7 +1222,7 @@ ST_FUNC void greturn(void) break; } case 16: - if ((func_vt.t & VT_BTYPE) == VT_STRUCT) { + if ((func_type->t & VT_BTYPE) == VT_STRUCT) { uint32_t j, sz, n = arm64_hfa(&vtop->type, &sz); gaddrof(); gv(RC_R(0)); @@ -1237,6 +1237,7 @@ ST_FUNC void greturn(void) default: assert(0); } + vtop--; } ST_FUNC void gfunc_epilog(void) -- cgit v1.3.1