Adjust return value promotion for some archs
commitc8ca64d28ba107f652f3ee24a4deb8e93609b9ca
authorMichael Matz <matz@suse.de>
Tue, 17 Dec 2019 00:46:06 +0000 (17 01:46 +0100)
committerMichael Matz <matz@suse.de>
Tue, 17 Dec 2019 00:46:06 +0000 (17 01:46 +0100)
treed76896b021a80a9c02eef4a31bcff5d9679c96a1
parent2d17e5a6c435c39fb2ee6c0268c18804d83684ab
Adjust return value promotion for some archs

this is a bit complicated: for i386 and x86-64 we really need to
extend return values ourself, as the common code now does.  For arm64
this at least preserves old behaviour.  For riscv64 we don't have to
extend ourself but can expect things to be extended up to int (this
matters for var-args tests, when the sign-extension to int64 needs to
happen explicitely).  As the extensions are useless, don't do them.

And for arm32 we actually can't express GCC behaviour: the callee side
expects the return value to be correctly extended to int32, but
remembers the original type.  In case the ultimate target type for the
call result is only int, no further extension is done.  But in case
the target type is e.g. int64 an extension happens, but not from int32
but from the original type.  We don't know the ultimate target type,
so we have to choose a type to put into vtop:
* original type (plus VT_MUSTCAST) - this looses when the ultimate
  target is int (GCC: no cast, TCC: a cast)
* int (without MUSTCAST) - this looses when the ultimate target is
  int64 (GCC: cast from original type, TCC: cast from int)
This difference can only be seen with undefined sources, like the
testcases, so it doesn't seem worthwhile to try an make it work, just
disable the test on arm and choose the second variant as that generates
less code.
arm64-gen.c
i386-gen.c
tccgen.c
tests/tcctest.c
x86_64-gen.c