x86-64: fix flags and zero-pad long doubles

This fixes a bug introduced in commit
    8d107d9ffd
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.
This commit is contained in:
grischka 2011-08-06 16:08:03 +02:00
parent 81cd0cf6fd
commit f115c12346
2 changed files with 13 additions and 10 deletions

17
tcc.h
View File

@ -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 */

View File

@ -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;