aboutsummaryrefslogtreecommitdiff
path: root/i386-gen.c
diff options
context:
space:
mode:
authorThomas Preud'homme <robotux@celest.fr>2013-11-22 09:27:15 +0800
committerThomas Preud'homme <robotux@celest.fr>2013-11-22 09:27:15 +0800
commitdcec8673f21da86ae3dcf1ca3e9498127715b795 (patch)
treed545ceed139dd57a6d6077368c9bbd248123f964 /i386-gen.c
parentd9d60a1ebd9ae24aafd2e042d5ad38f515583b7e (diff)
downloadtinycc-dcec8673f21da86ae3dcf1ca3e9498127715b795.tar.gz
tinycc-dcec8673f21da86ae3dcf1ca3e9498127715b795.tar.bz2
Add support for struct > 4B returned via registers
On ARM with hardfloat calling convention, structure containing 4 fields or less of the same float type are returned via float registers. This means that a structure can be returned in up to 4 double registers in a structure is composed of 4 doubles. This commit adds support for return of structures in several registers.
Diffstat (limited to 'i386-gen.c')
-rw-r--r--i386-gen.c9
1 files changed, 5 insertions, 4 deletions
diff --git a/i386-gen.c b/i386-gen.c
index 0a6d4d3..eaab2b7 100644
--- a/i386-gen.c
+++ b/i386-gen.c
@@ -374,7 +374,8 @@ static void gcall_or_jmp(int is_jmp)
static uint8_t fastcall_regs[3] = { TREG_EAX, TREG_EDX, TREG_ECX };
static uint8_t fastcallw_regs[2] = { TREG_ECX, TREG_EDX };
-/* Return 1 if this function returns via an sret pointer, 0 otherwise */
+/* Return the number of registers needed to return the struct, or 0 if
+ returning via struct pointer. */
ST_FUNC int gfunc_sret(CType *vt, CType *ret, int *ret_align)
{
#ifdef TCC_TARGET_PE
@@ -383,11 +384,11 @@ ST_FUNC int gfunc_sret(CType *vt, CType *ret, int *ret_align)
*ret_align = 1; // Never have to re-align return values for x86
size = type_size(vt, &align);
if (size > 8) {
- return 1;
+ return 0;
} else if (size > 4) {
ret->ref = NULL;
ret->t = VT_LLONG;
- return 0;
+ return 1;
} else {
ret->ref = NULL;
ret->t = VT_INT;
@@ -395,7 +396,7 @@ ST_FUNC int gfunc_sret(CType *vt, CType *ret, int *ret_align)
}
#else
*ret_align = 1; // Never have to re-align return values for x86
- return 1;
+ return 0;
#endif
}