bootstrappable: ARM: HAVE_FLOAT?

This commit is contained in:
Jan (janneke) Nieuwenhuizen 2021-12-05 13:21:22 +01:00
parent 6c6adc6301
commit 50b5eaeda9
No known key found for this signature in database
GPG Key ID: F3C1A0D9C1D65273
2 changed files with 37 additions and 0 deletions

4
tcc.h
View File

@ -400,7 +400,11 @@ typedef union CValue {
int size;
const void *data;
} str;
#if BOOTSTRAP && __arm__
int tab[4];
#else
int tab[LDOUBLE_SIZE/4];
#endif
} CValue;
/* value on stack */

View File

@ -6174,6 +6174,15 @@ static int decl_designator(CType *type, Section *sec, unsigned long c,
return al;
}
#if BOOTSTRAP && HAVE_FLOAT
struct long_double
{
int one;
int two;
int three;
};
#endif
/* store a value or an expression directly in global data or in local array */
static void init_putv(CType *type, Section *sec, unsigned long c)
{
@ -6284,18 +6293,42 @@ static void init_putv(CType *type, Section *sec, unsigned long c)
break;
case VT_FLOAT:
#if HAVE_FLOAT
#if !(BOOTSTRAP && __arm__)
*(float*)ptr = vtop->c.f;
#else
{
long *lptr = ptr;
*lptr = vtop->c.f;
}
#endif
#endif
break;
case VT_DOUBLE:
#if HAVE_FLOAT
#if !(BOOTSTRAP && __arm__)
*(double *)ptr = vtop->c.d;
#else
{
long long *llptr = ptr;
*llptr = vtop->c.d;
}
#endif
#endif
break;
case VT_LDOUBLE:
#if HAVE_FLOAT
if (sizeof(long double) == LDOUBLE_SIZE)
#if !(BOOTSTRAP && __arm__)
*(long double *)ptr = vtop->c.ld;
#else
{
// XXX TODO: breaks on mescc/mes-tcc based build
// maybe disable with HAVE_LONG_DOUBLE?
//struct long_double *ldptr = ptr;
//struct long_double tmp = (struct long_double)vtop->c.ld;
//*ldptr = (struct long_double)tmp;
}
#endif
else if (sizeof(double) == LDOUBLE_SIZE)
*(double *)ptr = (double)vtop->c.ld;
#if (defined __i386__ || defined __x86_64__) && (defined TCC_TARGET_I386 || defined TCC_TARGET_X86_64)