mirror of
https://github.com/mirror/tinycc.git
synced 2025-02-26 08:00:09 +08:00
Fix riscv64 compare problem.
Fix 64->32 bits sign/zero extention for riscv64.
This commit is contained in:
parent
d1ce34448f
commit
d55a3f3362
10
tccgen.c
10
tccgen.c
@ -3605,10 +3605,12 @@ again:
|
|||||||
}
|
}
|
||||||
ss = ds, ds = 4, dbt = sbt;
|
ss = ds, ds = 4, dbt = sbt;
|
||||||
} else if (ss == 8) {
|
} else if (ss == 8) {
|
||||||
/* XXX some architectures (e.g. risc-v) would like it
|
/* RISC-V keeps 32bit vals in registers sign-extended.
|
||||||
better for this merely being a 32-to-64 sign or zero-
|
So here we need a sign-extension for signed types and
|
||||||
extension. */
|
zero-extension. for unsigned types. */
|
||||||
trunc = 32; /* zero upper 32 bits */
|
#if !defined(TCC_TARGET_RISCV64)
|
||||||
|
trunc = 32; /* zero upper 32 bits for non RISC-V targets */
|
||||||
|
#endif
|
||||||
} else {
|
} else {
|
||||||
ss = 4;
|
ss = 4;
|
||||||
}
|
}
|
||||||
|
@ -117,6 +117,18 @@ void tst_builtin(void)
|
|||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int tst(void)
|
||||||
|
{
|
||||||
|
long value = 3;
|
||||||
|
return -value;
|
||||||
|
}
|
||||||
|
|
||||||
|
void tst_compare(void)
|
||||||
|
{
|
||||||
|
/* This failed on risc64 */
|
||||||
|
if (tst() > 0) printf ("error\n");
|
||||||
|
}
|
||||||
|
|
||||||
int
|
int
|
||||||
main (void)
|
main (void)
|
||||||
{
|
{
|
||||||
@ -131,4 +143,5 @@ main (void)
|
|||||||
tst_big(big);
|
tst_big(big);
|
||||||
tst_adr(&sprintf);
|
tst_adr(&sprintf);
|
||||||
tst_builtin();
|
tst_builtin();
|
||||||
|
tst_compare();
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user