mirror of
https://github.com/frida/tinycc
synced 2024-11-28 10:33:07 +03:00
x86-64: Cast from 64bit pointer to long long must not generate movslq.
This commit is contained in:
parent
a9c78d04f2
commit
be43c8e0ed
2
tcc.c
2
tcc.c
@ -6228,7 +6228,7 @@ static void gen_cast(CType *type)
|
|||||||
vpop();
|
vpop();
|
||||||
#else
|
#else
|
||||||
int r = gv(RC_INT);
|
int r = gv(RC_INT);
|
||||||
if (sbt != (VT_INT | VT_UNSIGNED)) {
|
if (sbt != (VT_INT | VT_UNSIGNED) && sbt != VT_PTR) {
|
||||||
/* x86_64 specific: movslq */
|
/* x86_64 specific: movslq */
|
||||||
o(0x6348);
|
o(0x6348);
|
||||||
o(0xc0 + (REG_VALUE(r) << 3) + REG_VALUE(r));
|
o(0xc0 + (REG_VALUE(r) << 3) + REG_VALUE(r));
|
||||||
|
10
tcctest.c
10
tcctest.c
@ -1109,6 +1109,8 @@ void cast_test()
|
|||||||
char tab[10];
|
char tab[10];
|
||||||
unsigned b,d;
|
unsigned b,d;
|
||||||
short s;
|
short s;
|
||||||
|
char *p = NULL;
|
||||||
|
p -= 0x700000000042;
|
||||||
|
|
||||||
printf("cast_test:\n");
|
printf("cast_test:\n");
|
||||||
a = 0xfffff;
|
a = 0xfffff;
|
||||||
@ -1150,6 +1152,14 @@ void cast_test()
|
|||||||
printf("sizeof(+(char)'a') = %d\n", sizeof(+(char)'a'));
|
printf("sizeof(+(char)'a') = %d\n", sizeof(+(char)'a'));
|
||||||
printf("sizeof(-(char)'a') = %d\n", sizeof(-(char)'a'));
|
printf("sizeof(-(char)'a') = %d\n", sizeof(-(char)'a'));
|
||||||
printf("sizeof(~(char)'a') = %d\n", sizeof(-(char)'a'));
|
printf("sizeof(~(char)'a') = %d\n", sizeof(-(char)'a'));
|
||||||
|
|
||||||
|
/* from pointer to integer types */
|
||||||
|
printf("%d %d %d %d %d %d %ld %ld %lld %lld\n",
|
||||||
|
(char)p, (unsigned char)p,
|
||||||
|
(short)p, (unsigned short)p,
|
||||||
|
(int)p, (unsigned int)p,
|
||||||
|
(long)p, (unsigned long)p,
|
||||||
|
(long long)p, (unsigned long long)p);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* initializers tests */
|
/* initializers tests */
|
||||||
|
Loading…
Reference in New Issue
Block a user