mirror of
https://github.com/frida/tinycc
synced 2024-12-24 05:56:49 +03:00
riscv: fix more sign/zero-extension problems
see the testcase. For the signed case this problably does the wrong thing, and it should break other archs. Rework once there are testcases for this.
This commit is contained in:
parent
1ada32900b
commit
509f561823
17
tccgen.c
17
tccgen.c
@ -2867,12 +2867,15 @@ static void gen_cast(CType *type)
|
||||
lexpand();
|
||||
vpop();
|
||||
#else
|
||||
/* XXX some architectures (e.g. risc-v) would like it
|
||||
better for this merely being a 32-to-64 sign or zero-
|
||||
extension. */
|
||||
vpushi(0xffffffff);
|
||||
vtop->type.t |= VT_UNSIGNED;
|
||||
gen_op('&');
|
||||
if (dbt & VT_UNSIGNED) {
|
||||
/* XXX some architectures (e.g. risc-v) would like it
|
||||
better for this merely being a 32-to-64 sign or zero-
|
||||
extension. */
|
||||
vpushi(0xffffffff);
|
||||
vtop->type.t |= VT_UNSIGNED;
|
||||
gen_op('&');
|
||||
} else {
|
||||
}
|
||||
#endif
|
||||
}
|
||||
/* if lvalue and single word type, nothing to do because
|
||||
@ -5253,7 +5256,7 @@ ST_FUNC void unary(void)
|
||||
vtop->c.f = -1.0 * 0.0;
|
||||
else if (t == VT_DOUBLE)
|
||||
vtop->c.d = -1.0 * 0.0;
|
||||
else
|
||||
else
|
||||
vtop->c.ld = -1.0 * 0.0;
|
||||
} else
|
||||
vpushi(0);
|
||||
|
@ -1633,6 +1633,7 @@ void cast_test()
|
||||
unsigned b,d;
|
||||
short s;
|
||||
char *p = NULL;
|
||||
unsigned long ul = 0x80000000UL;
|
||||
p -= 0x700000000042;
|
||||
|
||||
printf("cast_test:\n");
|
||||
@ -1685,6 +1686,9 @@ void cast_test()
|
||||
/* from integers to pointers */
|
||||
printf("%p %p %p %p\n",
|
||||
(void *)a, (void *)b, (void *)c, (void *)d);
|
||||
|
||||
/* int to int with sign set */
|
||||
printf("0x%lx\n", (unsigned long)(int)ul);
|
||||
}
|
||||
|
||||
/* initializers tests */
|
||||
|
Loading…
Reference in New Issue
Block a user