From f115c1234692364f3f097a416e4a6e21abf0cbf3 Mon Sep 17 00:00:00 2001 From: grischka Date: Sat, 6 Aug 2011 16:08:03 +0200 Subject: [PATCH] x86-64: fix flags and zero-pad long doubles This fixes a bug introduced in commit 8d107d9ffd8126d82b1c56be47431a6bcef39f08 that produced wrong code because of interference between 0x10 bits VT_CONST and x86_64-gen.c:TREG_MEM Also fully zero-pad long doubles on x86-64 to avoid random bytes in output files which disturb file comparison. --- tcc.h | 17 ++++++++--------- tccgen.c | 6 +++++- 2 files changed, 13 insertions(+), 10 deletions(-) diff --git a/tcc.h b/tcc.h index 6e9b01f5..b0c516ce 100644 --- a/tcc.h +++ b/tcc.h @@ -631,14 +631,15 @@ struct TCCState { }; /* The current value can be: */ -#define VT_VALMASK 0x001f -#define VT_CONST 0x0010 /* constant in vc +#define VT_VALMASK 0x003f +#define VT_CONST 0x0030 /* constant in vc (must be first non register value) */ -#define VT_LLOCAL 0x0011 /* lvalue, offset on stack */ -#define VT_LOCAL 0x0012 /* offset on stack */ -#define VT_CMP 0x0013 /* the value is stored in processor flags (in vc) */ -#define VT_JMP 0x0014 /* value is the consequence of jmp true (even) */ -#define VT_JMPI 0x0015 /* value is the consequence of jmp false (odd) */ +#define VT_LLOCAL 0x0031 /* lvalue, offset on stack */ +#define VT_LOCAL 0x0032 /* offset on stack */ +#define VT_CMP 0x0033 /* the value is stored in processor flags (in vc) */ +#define VT_JMP 0x0034 /* value is the consequence of jmp true (even) */ +#define VT_JMPI 0x0035 /* value is the consequence of jmp false (odd) */ +#define VT_REF 0x0040 /* value is pointer to structure rather than address */ #define VT_LVAL 0x0100 /* var is an lvalue */ #define VT_SYM 0x0200 /* a symbol value is added */ #define VT_MUSTCAST 0x0400 /* value must be casted to be correct (used for @@ -652,8 +653,6 @@ struct TCCState { #define VT_LVAL_UNSIGNED 0x4000 /* lvalue is unsigned */ #define VT_LVAL_TYPE (VT_LVAL_BYTE | VT_LVAL_SHORT | VT_LVAL_UNSIGNED) -#define VT_REF 0x0020 - /* types */ #define VT_INT 0 /* integer type */ #define VT_BYTE 1 /* signed byte type */ diff --git a/tccgen.c b/tccgen.c index 2df5de50..c800acca 100644 --- a/tccgen.c +++ b/tccgen.c @@ -709,8 +709,12 @@ ST_FUNC int gv(int rc) /* XXX: not portable yet */ #if defined(__i386__) || defined(__x86_64__) /* Zero pad x87 tenbyte long doubles */ - if (size == LDOUBLE_SIZE) + if (size == LDOUBLE_SIZE) { vtop->c.tab[2] &= 0xffff; +#if LDOUBLE_SIZE == 16 + vtop->c.tab[3] = 0; +#endif + } #endif ptr = section_ptr_add(data_section, size); size = size >> 2; -- 2.11.4.GIT