This patch set tries to improve the size changing ops in TCG, so that we have a clean interface and a better view of how 32-bit and 64-bit values are handled. I believe part of the code we have now are more band aid than real fixes. The idea behind this patchset is that size changing ops should be real ops and not implemented as mov or casting types, so that we can distinguish them in the register allocator and the optimizer. It however allow targets to override that and replace them by a mov in case the target CPU already maintain values zero/sign extended.
It is currently only correct on x86, for other targets we have to review and decide how to handle things (or be conservative and implement the 3 size changing ops). For x86 I have made the choice to implement ext_i32_i64 and extu_i32_i64 as real ops and trunc_shr_i64_i32 as a mov as it doesn't change the generated code. I believe it is also possible to implement ext_i32_i64 and trunc_shr_i64_i32 as real ops and extu_i32_i64 as a mov. Note that it doesn't fix the qemu_ld/st issue reported by Leon Alrae. Also note that this is definitely not 2.4 material, but I post it now in the hope it helps to have a better view about how things are currently handled. Aurelien Jarno (9): tcg: rename trunc_shr_i32 into trunc_shr_i64_i32 tcg: don't abuse TCG type in tcg_gen_trunc_shr_i64_i32 tcg: implement real ext_i32_i64 and extu_i32_i64 ops tcg/optimize: add optimizations for ext_i32_i64 and extu_i32_i64 ops tcg/i386: implement ext_i32_i64 and extu_i32_i64 ops tcg/i386: document the way 32/64-bit conversions are handled tcg: replace ext/u_i32_i64 by a mov when not implemented tcg/optimize: do not simplify size changing moves tcg: update README about size changing ops tcg/README | 17 ++++++++++++++--- tcg/aarch64/tcg-target.h | 6 +++++- tcg/i386/tcg-target.c | 5 +++++ tcg/i386/tcg-target.h | 11 ++++++++++- tcg/ia64/tcg-target.h | 6 +++++- tcg/optimize.c | 44 +++++++++++++++++++------------------------- tcg/ppc/tcg-target.h | 7 ++++++- tcg/s390/tcg-target.h | 6 +++++- tcg/sparc/tcg-target.c | 4 ++-- tcg/sparc/tcg-target.h | 6 +++++- tcg/tcg-op.c | 16 +++++++++++----- tcg/tcg-opc.h | 7 +++++-- tcg/tcg.h | 2 +- tcg/tci/tcg-target.h | 7 ++++++- 14 files changed, 99 insertions(+), 45 deletions(-) -- 2.1.4