1 | The following changes since commit 2d894e48362ad2a576fca929dcca1787f43a8af6: | 1 | The following changes since commit 41192db338588051f21501abc13743e62b0a5605: |
---|---|---|---|
2 | 2 | ||
3 | Merge remote-tracking branch 'remotes/stefanha/tags/tracing-pull-request' into staging (2018-12-13 17:50:45 +0000) | 3 | Merge remote-tracking branch 'remotes/ehabkost-gl/tags/machine-next-pull-request' into staging (2021-01-01 22:57:15 +0000) |
4 | 4 | ||
5 | are available in the Git repository at: | 5 | are available in the Git repository at: |
6 | 6 | ||
7 | https://github.com/rth7680/qemu.git tags/pull-tcg-20181213 | 7 | https://gitlab.com/rth7680/qemu.git tags/pull-tcg-20210104 |
8 | 8 | ||
9 | for you to fetch changes up to 99f70ba5b6b4566509b2069a8d29c6686b8115de: | 9 | for you to fetch changes up to a66424ba17d661007dc13d78c9e3014ccbaf0efb: |
10 | 10 | ||
11 | xxhash: match output against the original xxhash32 (2018-12-13 18:56:11 -0600) | 11 | tcg: Add tcg_gen_bswap_tl alias (2021-01-04 06:32:58 -1000) |
12 | 12 | ||
13 | ---------------------------------------------------------------- | 13 | ---------------------------------------------------------------- |
14 | - Remove retranslation remenents | 14 | Fix vector clear issue. |
15 | - Return success from patch_reloc | 15 | Fix riscv host shift issue. |
16 | - Preserve 32-bit values as zero-extended on x86_64 | 16 | Add tcg_gen_bswap_tl. |
17 | - Make bswap during memory ops as optional | ||
18 | - Cleanup xxhash | ||
19 | 17 | ||
20 | ---------------------------------------------------------------- | 18 | ---------------------------------------------------------------- |
21 | Alistair Francis (1): | 19 | Richard Henderson (2): |
22 | tcg/mips: Improve the add2/sub2 command to use TCG_TARGET_REG_BITS | 20 | tcg: Use memset for large vector byte replication |
21 | tcg: Add tcg_gen_bswap_tl alias | ||
23 | 22 | ||
24 | Emilio G. Cota (5): | 23 | Zihao Yu (1): |
25 | tcg: Drop nargs from tcg_op_insert_{before,after} | 24 | tcg/riscv: Fix illegal shift instructions |
26 | qht-bench: document -p flag | ||
27 | exec: introduce qemu_xxhash{2,4,5,6,7} | ||
28 | include: move exec/tb-hash-xx.h to qemu/xxhash.h | ||
29 | xxhash: match output against the original xxhash32 | ||
30 | 25 | ||
31 | Richard Henderson (26): | 26 | accel/tcg/tcg-runtime.h | 11 +++++++++++ |
32 | tcg/i386: Always use %ebp for TCG_AREG0 | 27 | include/exec/helper-proto.h | 4 ++++ |
33 | tcg/i386: Move TCG_REG_CALL_STACK from define to enum | 28 | include/tcg/tcg-op.h | 2 ++ |
34 | tcg/aarch64: Remove reloc_pc26_atomic | 29 | tcg/tcg-op-gvec.c | 32 ++++++++++++++++++++++++++++++++ |
35 | tcg/aarch64: Fold away "noaddr" branch routines | 30 | tcg/riscv/tcg-target.c.inc | 12 ++++++------ |
36 | tcg/arm: Remove reloc_pc24_atomic | 31 | 5 files changed, 55 insertions(+), 6 deletions(-) |
37 | tcg/arm: Fold away "noaddr" branch routines | ||
38 | tcg/ppc: Fold away "noaddr" branch routines | ||
39 | tcg/s390: Remove retranslation code | ||
40 | tcg/sparc: Remove retranslation code | ||
41 | tcg/mips: Remove retranslation code | ||
42 | tcg: Return success from patch_reloc | ||
43 | tcg/i386: Return false on failure from patch_reloc | ||
44 | tcg/aarch64: Return false on failure from patch_reloc | ||
45 | tcg/arm: Return false on failure from patch_reloc | ||
46 | tcg/ppc: Return false on failure from patch_reloc | ||
47 | tcg/s390x: Return false on failure from patch_reloc | ||
48 | tcg/i386: Propagate is64 to tcg_out_qemu_ld_direct | ||
49 | tcg/i386: Propagate is64 to tcg_out_qemu_ld_slow_path | ||
50 | tcg/i386: Implement INDEX_op_extr{lh}_i64_i32 for 32-bit guests | ||
51 | tcg/i386: Assume 32-bit values are zero-extended | ||
52 | tcg/i386: Precompute all guest_base parameters | ||
53 | tcg/i386: Add setup_guest_base_seg for FreeBSD | ||
54 | tcg: Clean up generic bswap32 | ||
55 | tcg: Clean up generic bswap64 | ||
56 | tcg/optimize: Optimize bswap | ||
57 | tcg: Add TCG_TARGET_HAS_MEMORY_BSWAP | ||
58 | 32 | ||
59 | include/exec/tb-hash.h | 4 +- | ||
60 | include/{exec/tb-hash-xx.h => qemu/xxhash.h} | 47 ++++-- | ||
61 | tcg/aarch64/tcg-target.h | 1 + | ||
62 | tcg/arm/tcg-target.h | 1 + | ||
63 | tcg/i386/tcg-target.h | 17 +-- | ||
64 | tcg/mips/tcg-target.h | 1 + | ||
65 | tcg/ppc/tcg-target.h | 1 + | ||
66 | tcg/s390/tcg-target.h | 1 + | ||
67 | tcg/sparc/tcg-target.h | 1 + | ||
68 | tcg/tcg.h | 4 +- | ||
69 | tcg/tci/tcg-target.h | 2 + | ||
70 | tcg/aarch64/tcg-target.inc.c | 71 +++------ | ||
71 | tcg/arm/tcg-target.inc.c | 55 +++---- | ||
72 | tcg/i386/tcg-target.inc.c | 208 ++++++++++++-------------- | ||
73 | tcg/mips/tcg-target.inc.c | 12 +- | ||
74 | tcg/optimize.c | 16 +- | ||
75 | tcg/ppc/tcg-target.inc.c | 60 ++++---- | ||
76 | tcg/s390/tcg-target.inc.c | 45 +++--- | ||
77 | tcg/sparc/tcg-target.inc.c | 13 +- | ||
78 | tcg/tcg-op.c | 215 ++++++++++++++++++++------- | ||
79 | tcg/tcg.c | 18 +-- | ||
80 | tcg/tci/tcg-target.inc.c | 3 +- | ||
81 | tests/qht-bench.c | 5 +- | ||
82 | util/qsp.c | 14 +- | ||
83 | 24 files changed, 452 insertions(+), 363 deletions(-) | ||
84 | rename include/{exec/tb-hash-xx.h => qemu/xxhash.h} (73%) | ||
85 | diff view generated by jsdifflib |
Deleted patch | |||
---|---|---|---|
1 | For x86_64, this can remove a REX prefix resulting in smaller code | ||
2 | when manipulating globals of type i32, as we move them between backing | ||
3 | store via cpu_env, aka TCG_AREG0. | ||
4 | 1 | ||
5 | Reviewed-by: Alex Bennée <alex.bennee@linaro.org> | ||
6 | Reviewed-by: Emilio G. Cota <cota@braap.org> | ||
7 | Signed-off-by: Richard Henderson <richard.henderson@linaro.org> | ||
8 | --- | ||
9 | tcg/i386/tcg-target.h | 8 ++------ | ||
10 | 1 file changed, 2 insertions(+), 6 deletions(-) | ||
11 | |||
12 | diff --git a/tcg/i386/tcg-target.h b/tcg/i386/tcg-target.h | ||
13 | index XXXXXXX..XXXXXXX 100644 | ||
14 | --- a/tcg/i386/tcg-target.h | ||
15 | +++ b/tcg/i386/tcg-target.h | ||
16 | @@ -XXX,XX +XXX,XX @@ typedef enum { | ||
17 | TCG_REG_RBP = TCG_REG_EBP, | ||
18 | TCG_REG_RSI = TCG_REG_ESI, | ||
19 | TCG_REG_RDI = TCG_REG_EDI, | ||
20 | + | ||
21 | + TCG_AREG0 = TCG_REG_EBP, | ||
22 | } TCGReg; | ||
23 | |||
24 | /* used for function call generation */ | ||
25 | @@ -XXX,XX +XXX,XX @@ extern bool have_avx2; | ||
26 | #define TCG_TARGET_extract_i64_valid(ofs, len) \ | ||
27 | (((ofs) == 8 && (len) == 8) || ((ofs) + (len)) == 32) | ||
28 | |||
29 | -#if TCG_TARGET_REG_BITS == 64 | ||
30 | -# define TCG_AREG0 TCG_REG_R14 | ||
31 | -#else | ||
32 | -# define TCG_AREG0 TCG_REG_EBP | ||
33 | -#endif | ||
34 | - | ||
35 | static inline void flush_icache_range(uintptr_t start, uintptr_t stop) | ||
36 | { | ||
37 | } | ||
38 | -- | ||
39 | 2.17.2 | ||
40 | |||
41 | diff view generated by jsdifflib |
Deleted patch | |||
---|---|---|---|
1 | Reviewed-by: Alex Bennée <alex.bennee@linaro.org> | ||
2 | Reviewed-by: Emilio G. Cota <cota@braap.org> | ||
3 | Signed-off-by: Richard Henderson <richard.henderson@linaro.org> | ||
4 | --- | ||
5 | tcg/i386/tcg-target.h | 2 +- | ||
6 | 1 file changed, 1 insertion(+), 1 deletion(-) | ||
7 | 1 | ||
8 | diff --git a/tcg/i386/tcg-target.h b/tcg/i386/tcg-target.h | ||
9 | index XXXXXXX..XXXXXXX 100644 | ||
10 | --- a/tcg/i386/tcg-target.h | ||
11 | +++ b/tcg/i386/tcg-target.h | ||
12 | @@ -XXX,XX +XXX,XX @@ typedef enum { | ||
13 | TCG_REG_RDI = TCG_REG_EDI, | ||
14 | |||
15 | TCG_AREG0 = TCG_REG_EBP, | ||
16 | + TCG_REG_CALL_STACK = TCG_REG_ESP | ||
17 | } TCGReg; | ||
18 | |||
19 | /* used for function call generation */ | ||
20 | -#define TCG_REG_CALL_STACK TCG_REG_ESP | ||
21 | #define TCG_TARGET_STACK_ALIGN 16 | ||
22 | #if defined(_WIN64) | ||
23 | #define TCG_TARGET_CALL_STACK_OFFSET 32 | ||
24 | -- | ||
25 | 2.17.2 | ||
26 | |||
27 | diff view generated by jsdifflib |
Deleted patch | |||
---|---|---|---|
1 | It is unused since b68686bd4bfeb70040b4099df993dfa0b4f37b03. | ||
2 | 1 | ||
3 | Reviewed-by: Alex Bennée <alex.bennee@linaro.org> | ||
4 | Signed-off-by: Richard Henderson <richard.henderson@linaro.org> | ||
5 | --- | ||
6 | tcg/aarch64/tcg-target.inc.c | 12 ------------ | ||
7 | 1 file changed, 12 deletions(-) | ||
8 | |||
9 | diff --git a/tcg/aarch64/tcg-target.inc.c b/tcg/aarch64/tcg-target.inc.c | ||
10 | index XXXXXXX..XXXXXXX 100644 | ||
11 | --- a/tcg/aarch64/tcg-target.inc.c | ||
12 | +++ b/tcg/aarch64/tcg-target.inc.c | ||
13 | @@ -XXX,XX +XXX,XX @@ static inline void reloc_pc26(tcg_insn_unit *code_ptr, tcg_insn_unit *target) | ||
14 | *code_ptr = deposit32(*code_ptr, 0, 26, offset); | ||
15 | } | ||
16 | |||
17 | -static inline void reloc_pc26_atomic(tcg_insn_unit *code_ptr, | ||
18 | - tcg_insn_unit *target) | ||
19 | -{ | ||
20 | - ptrdiff_t offset = target - code_ptr; | ||
21 | - tcg_insn_unit insn; | ||
22 | - tcg_debug_assert(offset == sextract64(offset, 0, 26)); | ||
23 | - /* read instruction, mask away previous PC_REL26 parameter contents, | ||
24 | - set the proper offset, then write back the instruction. */ | ||
25 | - insn = atomic_read(code_ptr); | ||
26 | - atomic_set(code_ptr, deposit32(insn, 0, 26, offset)); | ||
27 | -} | ||
28 | - | ||
29 | static inline void reloc_pc19(tcg_insn_unit *code_ptr, tcg_insn_unit *target) | ||
30 | { | ||
31 | ptrdiff_t offset = target - code_ptr; | ||
32 | -- | ||
33 | 2.17.2 | ||
34 | |||
35 | diff view generated by jsdifflib |
Deleted patch | |||
---|---|---|---|
1 | There are one use apiece for these. There is no longer a need for | ||
2 | preserving branch offset operands, as we no longer re-translate. | ||
3 | 1 | ||
4 | Reviewed-by: Alex Bennée <alex.bennee@linaro.org> | ||
5 | Signed-off-by: Richard Henderson <richard.henderson@linaro.org> | ||
6 | --- | ||
7 | tcg/aarch64/tcg-target.inc.c | 21 ++------------------- | ||
8 | 1 file changed, 2 insertions(+), 19 deletions(-) | ||
9 | |||
10 | diff --git a/tcg/aarch64/tcg-target.inc.c b/tcg/aarch64/tcg-target.inc.c | ||
11 | index XXXXXXX..XXXXXXX 100644 | ||
12 | --- a/tcg/aarch64/tcg-target.inc.c | ||
13 | +++ b/tcg/aarch64/tcg-target.inc.c | ||
14 | @@ -XXX,XX +XXX,XX @@ static inline void tcg_out_goto_long(TCGContext *s, tcg_insn_unit *target) | ||
15 | } | ||
16 | } | ||
17 | |||
18 | -static inline void tcg_out_goto_noaddr(TCGContext *s) | ||
19 | -{ | ||
20 | - /* We pay attention here to not modify the branch target by reading from | ||
21 | - the buffer. This ensure that caches and memory are kept coherent during | ||
22 | - retranslation. Mask away possible garbage in the high bits for the | ||
23 | - first translation, while keeping the offset bits for retranslation. */ | ||
24 | - uint32_t old = tcg_in32(s); | ||
25 | - tcg_out_insn(s, 3206, B, old); | ||
26 | -} | ||
27 | - | ||
28 | -static inline void tcg_out_goto_cond_noaddr(TCGContext *s, TCGCond c) | ||
29 | -{ | ||
30 | - /* See comments in tcg_out_goto_noaddr. */ | ||
31 | - uint32_t old = tcg_in32(s) >> 5; | ||
32 | - tcg_out_insn(s, 3202, B_C, c, old); | ||
33 | -} | ||
34 | - | ||
35 | static inline void tcg_out_callr(TCGContext *s, TCGReg reg) | ||
36 | { | ||
37 | tcg_out_insn(s, 3207, BLR, reg); | ||
38 | @@ -XXX,XX +XXX,XX @@ static inline void tcg_out_goto_label(TCGContext *s, TCGLabel *l) | ||
39 | { | ||
40 | if (!l->has_value) { | ||
41 | tcg_out_reloc(s, s->code_ptr, R_AARCH64_JUMP26, l, 0); | ||
42 | - tcg_out_goto_noaddr(s); | ||
43 | + tcg_out_insn(s, 3206, B, 0); | ||
44 | } else { | ||
45 | tcg_out_goto(s, l->u.value_ptr); | ||
46 | } | ||
47 | @@ -XXX,XX +XXX,XX @@ static void tcg_out_tlb_read(TCGContext *s, TCGReg addr_reg, TCGMemOp opc, | ||
48 | |||
49 | /* If not equal, we jump to the slow path. */ | ||
50 | *label_ptr = s->code_ptr; | ||
51 | - tcg_out_goto_cond_noaddr(s, TCG_COND_NE); | ||
52 | + tcg_out_insn(s, 3202, B_C, TCG_COND_NE, 0); | ||
53 | } | ||
54 | |||
55 | #endif /* CONFIG_SOFTMMU */ | ||
56 | -- | ||
57 | 2.17.2 | ||
58 | |||
59 | diff view generated by jsdifflib |
Deleted patch | |||
---|---|---|---|
1 | It is unused since 3fb53fb4d12f2e7833bd1659e6013237b130ef20. | ||
2 | 1 | ||
3 | Reviewed-by: Alex Bennée <alex.bennee@linaro.org> | ||
4 | Signed-off-by: Richard Henderson <richard.henderson@linaro.org> | ||
5 | --- | ||
6 | tcg/arm/tcg-target.inc.c | 8 -------- | ||
7 | 1 file changed, 8 deletions(-) | ||
8 | |||
9 | diff --git a/tcg/arm/tcg-target.inc.c b/tcg/arm/tcg-target.inc.c | ||
10 | index XXXXXXX..XXXXXXX 100644 | ||
11 | --- a/tcg/arm/tcg-target.inc.c | ||
12 | +++ b/tcg/arm/tcg-target.inc.c | ||
13 | @@ -XXX,XX +XXX,XX @@ static inline void reloc_pc24(tcg_insn_unit *code_ptr, tcg_insn_unit *target) | ||
14 | *code_ptr = (*code_ptr & ~0xffffff) | (offset & 0xffffff); | ||
15 | } | ||
16 | |||
17 | -static inline void reloc_pc24_atomic(tcg_insn_unit *code_ptr, tcg_insn_unit *target) | ||
18 | -{ | ||
19 | - ptrdiff_t offset = (tcg_ptr_byte_diff(target, code_ptr) - 8) >> 2; | ||
20 | - tcg_insn_unit insn = atomic_read(code_ptr); | ||
21 | - tcg_debug_assert(offset == sextract32(offset, 0, 24)); | ||
22 | - atomic_set(code_ptr, deposit32(insn, 0, 24, offset)); | ||
23 | -} | ||
24 | - | ||
25 | static void patch_reloc(tcg_insn_unit *code_ptr, int type, | ||
26 | intptr_t value, intptr_t addend) | ||
27 | { | ||
28 | -- | ||
29 | 2.17.2 | ||
30 | |||
31 | diff view generated by jsdifflib |
Deleted patch | |||
---|---|---|---|
1 | There are one use apiece for these. There is no longer a need for | ||
2 | preserving branch offset operands, as we no longer re-translate. | ||
3 | 1 | ||
4 | Reviewed-by: Alex Bennée <alex.bennee@linaro.org> | ||
5 | Signed-off-by: Richard Henderson <richard.henderson@linaro.org> | ||
6 | --- | ||
7 | tcg/arm/tcg-target.inc.c | 22 +++------------------- | ||
8 | 1 file changed, 3 insertions(+), 19 deletions(-) | ||
9 | |||
10 | diff --git a/tcg/arm/tcg-target.inc.c b/tcg/arm/tcg-target.inc.c | ||
11 | index XXXXXXX..XXXXXXX 100644 | ||
12 | --- a/tcg/arm/tcg-target.inc.c | ||
13 | +++ b/tcg/arm/tcg-target.inc.c | ||
14 | @@ -XXX,XX +XXX,XX @@ static inline void tcg_out_b(TCGContext *s, int cond, int32_t offset) | ||
15 | (((offset - 8) >> 2) & 0x00ffffff)); | ||
16 | } | ||
17 | |||
18 | -static inline void tcg_out_b_noaddr(TCGContext *s, int cond) | ||
19 | -{ | ||
20 | - /* We pay attention here to not modify the branch target by masking | ||
21 | - the corresponding bytes. This ensure that caches and memory are | ||
22 | - kept coherent during retranslation. */ | ||
23 | - tcg_out32(s, deposit32(*s->code_ptr, 24, 8, (cond << 4) | 0x0a)); | ||
24 | -} | ||
25 | - | ||
26 | -static inline void tcg_out_bl_noaddr(TCGContext *s, int cond) | ||
27 | -{ | ||
28 | - /* We pay attention here to not modify the branch target by masking | ||
29 | - the corresponding bytes. This ensure that caches and memory are | ||
30 | - kept coherent during retranslation. */ | ||
31 | - tcg_out32(s, deposit32(*s->code_ptr, 24, 8, (cond << 4) | 0x0b)); | ||
32 | -} | ||
33 | - | ||
34 | static inline void tcg_out_bl(TCGContext *s, int cond, int32_t offset) | ||
35 | { | ||
36 | tcg_out32(s, (cond << 28) | 0x0b000000 | | ||
37 | @@ -XXX,XX +XXX,XX @@ static inline void tcg_out_goto_label(TCGContext *s, int cond, TCGLabel *l) | ||
38 | tcg_out_goto(s, cond, l->u.value_ptr); | ||
39 | } else { | ||
40 | tcg_out_reloc(s, s->code_ptr, R_ARM_PC24, l, 0); | ||
41 | - tcg_out_b_noaddr(s, cond); | ||
42 | + tcg_out_b(s, cond, 0); | ||
43 | } | ||
44 | } | ||
45 | |||
46 | @@ -XXX,XX +XXX,XX @@ static void tcg_out_qemu_ld(TCGContext *s, const TCGArg *args, bool is64) | ||
47 | /* This a conditional BL only to load a pointer within this opcode into LR | ||
48 | for the slow path. We will not be using the value for a tail call. */ | ||
49 | label_ptr = s->code_ptr; | ||
50 | - tcg_out_bl_noaddr(s, COND_NE); | ||
51 | + tcg_out_bl(s, COND_NE, 0); | ||
52 | |||
53 | tcg_out_qemu_ld_index(s, opc, datalo, datahi, addrlo, addend); | ||
54 | |||
55 | @@ -XXX,XX +XXX,XX @@ static void tcg_out_qemu_st(TCGContext *s, const TCGArg *args, bool is64) | ||
56 | |||
57 | /* The conditional call must come last, as we're going to return here. */ | ||
58 | label_ptr = s->code_ptr; | ||
59 | - tcg_out_bl_noaddr(s, COND_NE); | ||
60 | + tcg_out_bl(s, COND_NE, 0); | ||
61 | |||
62 | add_qemu_ldst_label(s, false, oi, datalo, datahi, addrlo, addrhi, | ||
63 | s->code_ptr, label_ptr); | ||
64 | -- | ||
65 | 2.17.2 | ||
66 | |||
67 | diff view generated by jsdifflib |
1 | For now, defined universally as true, since we previously required | 1 | In f47db80cc07, we handled odd-sized tail clearing for |
---|---|---|---|
2 | backends to implement swapped memory operations. Future patches | 2 | the case of hosts that have vector operations, but did |
3 | may now remove that support where it is onerous. | 3 | not handle the case of hosts that do not have vector ops. |
4 | 4 | ||
5 | This was ok until e2e7168a214b, which changed the encoding | ||
6 | of simd_desc such that the odd sizes are impossible. | ||
7 | |||
8 | Add memset as a tcg helper, and use that for all out-of-line | ||
9 | byte stores to vectors. This includes, but is not limited to, | ||
10 | the tail clearing operation in question. | ||
11 | |||
12 | Cc: qemu-stable@nongnu.org | ||
13 | Buglink: https://bugs.launchpad.net/bugs/1907817 | ||
14 | Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org> | ||
5 | Signed-off-by: Richard Henderson <richard.henderson@linaro.org> | 15 | Signed-off-by: Richard Henderson <richard.henderson@linaro.org> |
6 | --- | 16 | --- |
7 | tcg/aarch64/tcg-target.h | 1 + | 17 | accel/tcg/tcg-runtime.h | 11 +++++++++++ |
8 | tcg/arm/tcg-target.h | 1 + | 18 | include/exec/helper-proto.h | 4 ++++ |
9 | tcg/i386/tcg-target.h | 2 + | 19 | tcg/tcg-op-gvec.c | 32 ++++++++++++++++++++++++++++++++ |
10 | tcg/mips/tcg-target.h | 1 + | 20 | 3 files changed, 47 insertions(+) |
11 | tcg/ppc/tcg-target.h | 1 + | ||
12 | tcg/s390/tcg-target.h | 1 + | ||
13 | tcg/sparc/tcg-target.h | 1 + | ||
14 | tcg/tci/tcg-target.h | 2 + | ||
15 | tcg/tcg-op.c | 118 ++++++++++++++++++++++++++++++++++++++- | ||
16 | 9 files changed, 126 insertions(+), 2 deletions(-) | ||
17 | 21 | ||
18 | diff --git a/tcg/aarch64/tcg-target.h b/tcg/aarch64/tcg-target.h | 22 | diff --git a/accel/tcg/tcg-runtime.h b/accel/tcg/tcg-runtime.h |
19 | index XXXXXXX..XXXXXXX 100644 | 23 | index XXXXXXX..XXXXXXX 100644 |
20 | --- a/tcg/aarch64/tcg-target.h | 24 | --- a/accel/tcg/tcg-runtime.h |
21 | +++ b/tcg/aarch64/tcg-target.h | 25 | +++ b/accel/tcg/tcg-runtime.h |
22 | @@ -XXX,XX +XXX,XX @@ typedef enum { | 26 | @@ -XXX,XX +XXX,XX @@ DEF_HELPER_FLAGS_1(lookup_tb_ptr, TCG_CALL_NO_WG_SE, ptr, env) |
23 | #define TCG_TARGET_HAS_mul_vec 1 | 27 | |
24 | 28 | DEF_HELPER_FLAGS_1(exit_atomic, TCG_CALL_NO_WG, noreturn, env) | |
25 | #define TCG_TARGET_DEFAULT_MO (0) | 29 | |
26 | +#define TCG_TARGET_HAS_MEMORY_BSWAP 1 | 30 | +#ifndef IN_HELPER_PROTO |
27 | 31 | +/* | |
28 | static inline void flush_icache_range(uintptr_t start, uintptr_t stop) | 32 | + * Pass calls to memset directly to libc, without a thunk in qemu. |
29 | { | 33 | + * Do not re-declare memset, especially since we fudge the type here; |
30 | diff --git a/tcg/arm/tcg-target.h b/tcg/arm/tcg-target.h | 34 | + * we assume sizeof(void *) == sizeof(size_t), which is true for |
31 | index XXXXXXX..XXXXXXX 100644 | 35 | + * all supported hosts. |
32 | --- a/tcg/arm/tcg-target.h | 36 | + */ |
33 | +++ b/tcg/arm/tcg-target.h | 37 | +#define helper_memset memset |
34 | @@ -XXX,XX +XXX,XX @@ enum { | 38 | +DEF_HELPER_FLAGS_3(memset, TCG_CALL_NO_RWG, ptr, ptr, int, ptr) |
35 | }; | 39 | +#endif /* IN_HELPER_PROTO */ |
36 | |||
37 | #define TCG_TARGET_DEFAULT_MO (0) | ||
38 | +#define TCG_TARGET_HAS_MEMORY_BSWAP 1 | ||
39 | |||
40 | static inline void flush_icache_range(uintptr_t start, uintptr_t stop) | ||
41 | { | ||
42 | diff --git a/tcg/i386/tcg-target.h b/tcg/i386/tcg-target.h | ||
43 | index XXXXXXX..XXXXXXX 100644 | ||
44 | --- a/tcg/i386/tcg-target.h | ||
45 | +++ b/tcg/i386/tcg-target.h | ||
46 | @@ -XXX,XX +XXX,XX @@ static inline void tb_target_set_jmp_target(uintptr_t tc_ptr, | ||
47 | |||
48 | #define TCG_TARGET_DEFAULT_MO (TCG_MO_ALL & ~TCG_MO_ST_LD) | ||
49 | |||
50 | +#define TCG_TARGET_HAS_MEMORY_BSWAP 1 | ||
51 | + | 40 | + |
52 | #ifdef CONFIG_SOFTMMU | 41 | #ifdef CONFIG_SOFTMMU |
53 | #define TCG_TARGET_NEED_LDST_LABELS | 42 | |
54 | #endif | 43 | DEF_HELPER_FLAGS_5(atomic_cmpxchgb, TCG_CALL_NO_WG, |
55 | diff --git a/tcg/mips/tcg-target.h b/tcg/mips/tcg-target.h | 44 | diff --git a/include/exec/helper-proto.h b/include/exec/helper-proto.h |
56 | index XXXXXXX..XXXXXXX 100644 | 45 | index XXXXXXX..XXXXXXX 100644 |
57 | --- a/tcg/mips/tcg-target.h | 46 | --- a/include/exec/helper-proto.h |
58 | +++ b/tcg/mips/tcg-target.h | 47 | +++ b/include/exec/helper-proto.h |
59 | @@ -XXX,XX +XXX,XX @@ extern bool use_mips32r2_instructions; | 48 | @@ -XXX,XX +XXX,XX @@ dh_ctype(ret) HELPER(name) (dh_ctype(t1), dh_ctype(t2), dh_ctype(t3), \ |
60 | #endif | 49 | dh_ctype(t4), dh_ctype(t5), dh_ctype(t6), \ |
61 | 50 | dh_ctype(t7)); | |
62 | #define TCG_TARGET_DEFAULT_MO (0) | 51 | |
63 | +#define TCG_TARGET_HAS_MEMORY_BSWAP 1 | 52 | +#define IN_HELPER_PROTO |
64 | 53 | + | |
65 | static inline void flush_icache_range(uintptr_t start, uintptr_t stop) | 54 | #include "helper.h" |
66 | { | 55 | #include "trace/generated-helpers.h" |
67 | diff --git a/tcg/ppc/tcg-target.h b/tcg/ppc/tcg-target.h | 56 | #include "tcg-runtime.h" |
57 | #include "plugin-helpers.h" | ||
58 | |||
59 | +#undef IN_HELPER_PROTO | ||
60 | + | ||
61 | #undef DEF_HELPER_FLAGS_0 | ||
62 | #undef DEF_HELPER_FLAGS_1 | ||
63 | #undef DEF_HELPER_FLAGS_2 | ||
64 | diff --git a/tcg/tcg-op-gvec.c b/tcg/tcg-op-gvec.c | ||
68 | index XXXXXXX..XXXXXXX 100644 | 65 | index XXXXXXX..XXXXXXX 100644 |
69 | --- a/tcg/ppc/tcg-target.h | 66 | --- a/tcg/tcg-op-gvec.c |
70 | +++ b/tcg/ppc/tcg-target.h | 67 | +++ b/tcg/tcg-op-gvec.c |
71 | @@ -XXX,XX +XXX,XX @@ void flush_icache_range(uintptr_t start, uintptr_t stop); | 68 | @@ -XXX,XX +XXX,XX @@ static void do_dup(unsigned vece, uint32_t dofs, uint32_t oprsz, |
72 | void tb_target_set_jmp_target(uintptr_t, uintptr_t, uintptr_t); | 69 | in_c = dup_const(vece, in_c); |
73 | 70 | if (in_c == 0) { | |
74 | #define TCG_TARGET_DEFAULT_MO (0) | 71 | oprsz = maxsz; |
75 | +#define TCG_TARGET_HAS_MEMORY_BSWAP 1 | 72 | + vece = MO_8; |
76 | 73 | + } else if (in_c == dup_const(MO_8, in_c)) { | |
77 | #ifdef CONFIG_SOFTMMU | 74 | + vece = MO_8; |
78 | #define TCG_TARGET_NEED_LDST_LABELS | 75 | } |
79 | diff --git a/tcg/s390/tcg-target.h b/tcg/s390/tcg-target.h | 76 | } |
80 | index XXXXXXX..XXXXXXX 100644 | 77 | |
81 | --- a/tcg/s390/tcg-target.h | 78 | @@ -XXX,XX +XXX,XX @@ static void do_dup(unsigned vece, uint32_t dofs, uint32_t oprsz, |
82 | +++ b/tcg/s390/tcg-target.h | 79 | /* Otherwise implement out of line. */ |
83 | @@ -XXX,XX +XXX,XX @@ extern uint64_t s390_facilities; | 80 | t_ptr = tcg_temp_new_ptr(); |
84 | #define TCG_TARGET_CALL_STACK_OFFSET 160 | 81 | tcg_gen_addi_ptr(t_ptr, cpu_env, dofs); |
85 | |||
86 | #define TCG_TARGET_EXTEND_ARGS 1 | ||
87 | +#define TCG_TARGET_HAS_MEMORY_BSWAP 1 | ||
88 | |||
89 | #define TCG_TARGET_DEFAULT_MO (TCG_MO_ALL & ~TCG_MO_ST_LD) | ||
90 | |||
91 | diff --git a/tcg/sparc/tcg-target.h b/tcg/sparc/tcg-target.h | ||
92 | index XXXXXXX..XXXXXXX 100644 | ||
93 | --- a/tcg/sparc/tcg-target.h | ||
94 | +++ b/tcg/sparc/tcg-target.h | ||
95 | @@ -XXX,XX +XXX,XX @@ extern bool use_vis3_instructions; | ||
96 | #define TCG_AREG0 TCG_REG_I0 | ||
97 | |||
98 | #define TCG_TARGET_DEFAULT_MO (0) | ||
99 | +#define TCG_TARGET_HAS_MEMORY_BSWAP 1 | ||
100 | |||
101 | static inline void flush_icache_range(uintptr_t start, uintptr_t stop) | ||
102 | { | ||
103 | diff --git a/tcg/tci/tcg-target.h b/tcg/tci/tcg-target.h | ||
104 | index XXXXXXX..XXXXXXX 100644 | ||
105 | --- a/tcg/tci/tcg-target.h | ||
106 | +++ b/tcg/tci/tcg-target.h | ||
107 | @@ -XXX,XX +XXX,XX @@ static inline void flush_icache_range(uintptr_t start, uintptr_t stop) | ||
108 | We prefer consistency across hosts on this. */ | ||
109 | #define TCG_TARGET_DEFAULT_MO (0) | ||
110 | |||
111 | +#define TCG_TARGET_HAS_MEMORY_BSWAP 1 | ||
112 | + | 82 | + |
113 | static inline void tb_target_set_jmp_target(uintptr_t tc_ptr, | 83 | + /* |
114 | uintptr_t jmp_addr, uintptr_t addr) | 84 | + * This may be expand_clr for the tail of an operation, e.g. |
115 | { | 85 | + * oprsz == 8 && maxsz == 64. The size of the clear is misaligned |
116 | diff --git a/tcg/tcg-op.c b/tcg/tcg-op.c | 86 | + * wrt simd_desc and will assert. Simply pass all replicated byte |
117 | index XXXXXXX..XXXXXXX 100644 | 87 | + * stores through to memset. |
118 | --- a/tcg/tcg-op.c | 88 | + */ |
119 | +++ b/tcg/tcg-op.c | 89 | + if (oprsz == maxsz && vece == MO_8) { |
120 | @@ -XXX,XX +XXX,XX @@ static void tcg_gen_req_mo(TCGBar type) | 90 | + TCGv_ptr t_size = tcg_const_ptr(oprsz); |
121 | 91 | + TCGv_i32 t_val; | |
122 | void tcg_gen_qemu_ld_i32(TCGv_i32 val, TCGv addr, TCGArg idx, TCGMemOp memop) | ||
123 | { | ||
124 | + TCGMemOp orig_memop; | ||
125 | + | 92 | + |
126 | tcg_gen_req_mo(TCG_MO_LD_LD | TCG_MO_ST_LD); | 93 | + if (in_32) { |
127 | memop = tcg_canonicalize_memop(memop, 0, 0); | 94 | + t_val = in_32; |
128 | trace_guest_mem_before_tcg(tcg_ctx->cpu, cpu_env, | 95 | + } else if (in_64) { |
129 | addr, trace_mem_get_info(memop, 0)); | 96 | + t_val = tcg_temp_new_i32(); |
97 | + tcg_gen_extrl_i64_i32(t_val, in_64); | ||
98 | + } else { | ||
99 | + t_val = tcg_const_i32(in_c); | ||
100 | + } | ||
101 | + gen_helper_memset(t_ptr, t_ptr, t_val, t_size); | ||
130 | + | 102 | + |
131 | + orig_memop = memop; | 103 | + if (!in_32) { |
132 | + if (!TCG_TARGET_HAS_MEMORY_BSWAP && (memop & MO_BSWAP)) { | 104 | + tcg_temp_free_i32(t_val); |
133 | + memop &= ~MO_BSWAP; | ||
134 | + /* The bswap primitive requires zero-extended input. */ | ||
135 | + if ((memop & MO_SSIZE) == MO_SW) { | ||
136 | + memop &= ~MO_SIGN; | ||
137 | + } | 105 | + } |
106 | + tcg_temp_free_ptr(t_size); | ||
107 | + tcg_temp_free_ptr(t_ptr); | ||
108 | + return; | ||
138 | + } | 109 | + } |
139 | + | 110 | + |
140 | gen_ldst_i32(INDEX_op_qemu_ld_i32, val, addr, memop, idx); | 111 | t_desc = tcg_const_i32(simd_desc(oprsz, maxsz, 0)); |
141 | + | 112 | |
142 | + if ((orig_memop ^ memop) & MO_BSWAP) { | 113 | if (vece == MO_64) { |
143 | + switch (orig_memop & MO_SIZE) { | ||
144 | + case MO_16: | ||
145 | + tcg_gen_bswap16_i32(val, val); | ||
146 | + if (orig_memop & MO_SIGN) { | ||
147 | + tcg_gen_ext16s_i32(val, val); | ||
148 | + } | ||
149 | + break; | ||
150 | + case MO_32: | ||
151 | + tcg_gen_bswap32_i32(val, val); | ||
152 | + break; | ||
153 | + default: | ||
154 | + g_assert_not_reached(); | ||
155 | + } | ||
156 | + } | ||
157 | } | ||
158 | |||
159 | void tcg_gen_qemu_st_i32(TCGv_i32 val, TCGv addr, TCGArg idx, TCGMemOp memop) | ||
160 | { | ||
161 | + TCGv_i32 swap = NULL; | ||
162 | + | ||
163 | tcg_gen_req_mo(TCG_MO_LD_ST | TCG_MO_ST_ST); | ||
164 | memop = tcg_canonicalize_memop(memop, 0, 1); | ||
165 | trace_guest_mem_before_tcg(tcg_ctx->cpu, cpu_env, | ||
166 | addr, trace_mem_get_info(memop, 1)); | ||
167 | + | ||
168 | + if (!TCG_TARGET_HAS_MEMORY_BSWAP && (memop & MO_BSWAP)) { | ||
169 | + swap = tcg_temp_new_i32(); | ||
170 | + switch (memop & MO_SIZE) { | ||
171 | + case MO_16: | ||
172 | + tcg_gen_ext16u_i32(swap, val); | ||
173 | + tcg_gen_bswap16_i32(swap, swap); | ||
174 | + break; | ||
175 | + case MO_32: | ||
176 | + tcg_gen_bswap32_i32(swap, val); | ||
177 | + break; | ||
178 | + default: | ||
179 | + g_assert_not_reached(); | ||
180 | + } | ||
181 | + val = swap; | ||
182 | + memop &= ~MO_BSWAP; | ||
183 | + } | ||
184 | + | ||
185 | gen_ldst_i32(INDEX_op_qemu_st_i32, val, addr, memop, idx); | ||
186 | + | ||
187 | + if (swap) { | ||
188 | + tcg_temp_free_i32(swap); | ||
189 | + } | ||
190 | } | ||
191 | |||
192 | void tcg_gen_qemu_ld_i64(TCGv_i64 val, TCGv addr, TCGArg idx, TCGMemOp memop) | ||
193 | { | ||
194 | - tcg_gen_req_mo(TCG_MO_LD_LD | TCG_MO_ST_LD); | ||
195 | + TCGMemOp orig_memop; | ||
196 | + | ||
197 | if (TCG_TARGET_REG_BITS == 32 && (memop & MO_SIZE) < MO_64) { | ||
198 | tcg_gen_qemu_ld_i32(TCGV_LOW(val), addr, idx, memop); | ||
199 | if (memop & MO_SIGN) { | ||
200 | @@ -XXX,XX +XXX,XX @@ void tcg_gen_qemu_ld_i64(TCGv_i64 val, TCGv addr, TCGArg idx, TCGMemOp memop) | ||
201 | return; | ||
202 | } | ||
203 | |||
204 | + tcg_gen_req_mo(TCG_MO_LD_LD | TCG_MO_ST_LD); | ||
205 | memop = tcg_canonicalize_memop(memop, 1, 0); | ||
206 | trace_guest_mem_before_tcg(tcg_ctx->cpu, cpu_env, | ||
207 | addr, trace_mem_get_info(memop, 0)); | ||
208 | + | ||
209 | + orig_memop = memop; | ||
210 | + if (!TCG_TARGET_HAS_MEMORY_BSWAP && (memop & MO_BSWAP)) { | ||
211 | + memop &= ~MO_BSWAP; | ||
212 | + /* The bswap primitive requires zero-extended input. */ | ||
213 | + if ((memop & MO_SIGN) && (memop & MO_SIZE) < MO_64) { | ||
214 | + memop &= ~MO_SIGN; | ||
215 | + } | ||
216 | + } | ||
217 | + | ||
218 | gen_ldst_i64(INDEX_op_qemu_ld_i64, val, addr, memop, idx); | ||
219 | + | ||
220 | + if ((orig_memop ^ memop) & MO_BSWAP) { | ||
221 | + switch (orig_memop & MO_SIZE) { | ||
222 | + case MO_16: | ||
223 | + tcg_gen_bswap16_i64(val, val); | ||
224 | + if (orig_memop & MO_SIGN) { | ||
225 | + tcg_gen_ext16s_i64(val, val); | ||
226 | + } | ||
227 | + break; | ||
228 | + case MO_32: | ||
229 | + tcg_gen_bswap32_i64(val, val); | ||
230 | + if (orig_memop & MO_SIGN) { | ||
231 | + tcg_gen_ext32s_i64(val, val); | ||
232 | + } | ||
233 | + break; | ||
234 | + case MO_64: | ||
235 | + tcg_gen_bswap64_i64(val, val); | ||
236 | + break; | ||
237 | + default: | ||
238 | + g_assert_not_reached(); | ||
239 | + } | ||
240 | + } | ||
241 | } | ||
242 | |||
243 | void tcg_gen_qemu_st_i64(TCGv_i64 val, TCGv addr, TCGArg idx, TCGMemOp memop) | ||
244 | { | ||
245 | - tcg_gen_req_mo(TCG_MO_LD_ST | TCG_MO_ST_ST); | ||
246 | + TCGv_i64 swap = NULL; | ||
247 | + | ||
248 | if (TCG_TARGET_REG_BITS == 32 && (memop & MO_SIZE) < MO_64) { | ||
249 | tcg_gen_qemu_st_i32(TCGV_LOW(val), addr, idx, memop); | ||
250 | return; | ||
251 | } | ||
252 | |||
253 | + tcg_gen_req_mo(TCG_MO_LD_ST | TCG_MO_ST_ST); | ||
254 | memop = tcg_canonicalize_memop(memop, 1, 1); | ||
255 | trace_guest_mem_before_tcg(tcg_ctx->cpu, cpu_env, | ||
256 | addr, trace_mem_get_info(memop, 1)); | ||
257 | + | ||
258 | + if (!TCG_TARGET_HAS_MEMORY_BSWAP && (memop & MO_BSWAP)) { | ||
259 | + swap = tcg_temp_new_i64(); | ||
260 | + switch (memop & MO_SIZE) { | ||
261 | + case MO_16: | ||
262 | + tcg_gen_ext16u_i64(swap, val); | ||
263 | + tcg_gen_bswap16_i64(swap, swap); | ||
264 | + break; | ||
265 | + case MO_32: | ||
266 | + tcg_gen_ext32u_i64(swap, val); | ||
267 | + tcg_gen_bswap32_i64(swap, swap); | ||
268 | + break; | ||
269 | + case MO_64: | ||
270 | + tcg_gen_bswap64_i64(swap, val); | ||
271 | + break; | ||
272 | + default: | ||
273 | + g_assert_not_reached(); | ||
274 | + } | ||
275 | + val = swap; | ||
276 | + memop &= ~MO_BSWAP; | ||
277 | + } | ||
278 | + | ||
279 | gen_ldst_i64(INDEX_op_qemu_st_i64, val, addr, memop, idx); | ||
280 | + | ||
281 | + if (swap) { | ||
282 | + tcg_temp_free_i64(swap); | ||
283 | + } | ||
284 | } | ||
285 | |||
286 | static void tcg_gen_ext_i32(TCGv_i32 ret, TCGv_i32 val, TCGMemOp opc) | ||
287 | -- | 114 | -- |
288 | 2.17.2 | 115 | 2.25.1 |
289 | 116 | ||
290 | 117 | diff view generated by jsdifflib |
1 | There is no longer a need for preserving branch offset operands, | 1 | From: Zihao Yu <yuzihao@ict.ac.cn> |
---|---|---|---|
2 | as we no longer re-translate. | ||
3 | 2 | ||
4 | Reviewed-by: Alex Bennée <alex.bennee@linaro.org> | 3 | Out-of-range shifts have undefined results, but must not trap. |
4 | Mask off immediate shift counts to solve this problem. | ||
5 | |||
6 | This bug can be reproduced by running the following guest instructions: | ||
7 | |||
8 | xor %ecx,%ecx | ||
9 | sar %cl,%eax | ||
10 | cmovne %edi,%eax | ||
11 | |||
12 | After optimization, the tcg opcodes of the sar are | ||
13 | |||
14 | movi_i32 tmp3,$0xffffffffffffffff pref=all | ||
15 | sar_i32 tmp3,eax,tmp3 dead: 2 pref=all | ||
16 | mov_i32 cc_dst,eax sync: 0 dead: 1 pref=0xffc0300 | ||
17 | mov_i32 cc_src,tmp3 sync: 0 dead: 0 1 pref=all | ||
18 | movi_i32 cc_op,$0x31 sync: 0 dead: 0 pref=all | ||
19 | |||
20 | The sar_i32 opcode is a shift by -1, which unmasked generates | ||
21 | |||
22 | 0x200808d618: fffa5b9b illegal | ||
23 | |||
24 | Signed-off-by: Zihao Yu <yuzihao@ict.ac.cn> | ||
25 | Message-Id: <20201216081206.9628-1-yuzihao@ict.ac.cn> | ||
26 | [rth: Reworded the patch description.] | ||
5 | Signed-off-by: Richard Henderson <richard.henderson@linaro.org> | 27 | Signed-off-by: Richard Henderson <richard.henderson@linaro.org> |
6 | --- | 28 | --- |
7 | tcg/ppc/tcg-target.inc.c | 25 +++++++------------------ | 29 | tcg/riscv/tcg-target.c.inc | 12 ++++++------ |
8 | 1 file changed, 7 insertions(+), 18 deletions(-) | 30 | 1 file changed, 6 insertions(+), 6 deletions(-) |
9 | 31 | ||
10 | diff --git a/tcg/ppc/tcg-target.inc.c b/tcg/ppc/tcg-target.inc.c | 32 | diff --git a/tcg/riscv/tcg-target.c.inc b/tcg/riscv/tcg-target.c.inc |
11 | index XXXXXXX..XXXXXXX 100644 | 33 | index XXXXXXX..XXXXXXX 100644 |
12 | --- a/tcg/ppc/tcg-target.inc.c | 34 | --- a/tcg/riscv/tcg-target.c.inc |
13 | +++ b/tcg/ppc/tcg-target.inc.c | 35 | +++ b/tcg/riscv/tcg-target.c.inc |
14 | @@ -XXX,XX +XXX,XX @@ static void reloc_pc14(tcg_insn_unit *pc, tcg_insn_unit *target) | 36 | @@ -XXX,XX +XXX,XX @@ static void tcg_out_op(TCGContext *s, TCGOpcode opc, |
15 | *pc = (*pc & ~0xfffc) | reloc_pc14_val(pc, target); | 37 | |
16 | } | 38 | case INDEX_op_shl_i32: |
17 | 39 | if (c2) { | |
18 | -static inline void tcg_out_b_noaddr(TCGContext *s, int insn) | 40 | - tcg_out_opc_imm(s, OPC_SLLIW, a0, a1, a2); |
19 | -{ | 41 | + tcg_out_opc_imm(s, OPC_SLLIW, a0, a1, a2 & 0x1f); |
20 | - unsigned retrans = *s->code_ptr & 0x3fffffc; | 42 | } else { |
21 | - tcg_out32(s, insn | retrans); | 43 | tcg_out_opc_reg(s, OPC_SLLW, a0, a1, a2); |
22 | -} | ||
23 | - | ||
24 | -static inline void tcg_out_bc_noaddr(TCGContext *s, int insn) | ||
25 | -{ | ||
26 | - unsigned retrans = *s->code_ptr & 0xfffc; | ||
27 | - tcg_out32(s, insn | retrans); | ||
28 | -} | ||
29 | - | ||
30 | /* parse target specific constraints */ | ||
31 | static const char *target_parse_constraint(TCGArgConstraint *ct, | ||
32 | const char *ct_str, TCGType type) | ||
33 | @@ -XXX,XX +XXX,XX @@ static void tcg_out_setcond(TCGContext *s, TCGType type, TCGCond cond, | ||
34 | static void tcg_out_bc(TCGContext *s, int bc, TCGLabel *l) | ||
35 | { | ||
36 | if (l->has_value) { | ||
37 | - tcg_out32(s, bc | reloc_pc14_val(s->code_ptr, l->u.value_ptr)); | ||
38 | + bc |= reloc_pc14_val(s->code_ptr, l->u.value_ptr); | ||
39 | } else { | ||
40 | tcg_out_reloc(s, s->code_ptr, R_PPC_REL14, l, 0); | ||
41 | - tcg_out_bc_noaddr(s, bc); | ||
42 | } | ||
43 | + tcg_out32(s, bc); | ||
44 | } | ||
45 | |||
46 | static void tcg_out_brcond(TCGContext *s, TCGCond cond, | ||
47 | @@ -XXX,XX +XXX,XX @@ static void tcg_out_qemu_ld(TCGContext *s, const TCGArg *args, bool is_64) | ||
48 | |||
49 | /* Load a pointer into the current opcode w/conditional branch-link. */ | ||
50 | label_ptr = s->code_ptr; | ||
51 | - tcg_out_bc_noaddr(s, BC | BI(7, CR_EQ) | BO_COND_FALSE | LK); | ||
52 | + tcg_out32(s, BC | BI(7, CR_EQ) | BO_COND_FALSE | LK); | ||
53 | |||
54 | rbase = TCG_REG_R3; | ||
55 | #else /* !CONFIG_SOFTMMU */ | ||
56 | @@ -XXX,XX +XXX,XX @@ static void tcg_out_qemu_st(TCGContext *s, const TCGArg *args, bool is_64) | ||
57 | |||
58 | /* Load a pointer into the current opcode w/conditional branch-link. */ | ||
59 | label_ptr = s->code_ptr; | ||
60 | - tcg_out_bc_noaddr(s, BC | BI(7, CR_EQ) | BO_COND_FALSE | LK); | ||
61 | + tcg_out32(s, BC | BI(7, CR_EQ) | BO_COND_FALSE | LK); | ||
62 | |||
63 | rbase = TCG_REG_R3; | ||
64 | #else /* !CONFIG_SOFTMMU */ | ||
65 | @@ -XXX,XX +XXX,XX @@ static void tcg_out_op(TCGContext *s, TCGOpcode opc, const TCGArg *args, | ||
66 | case INDEX_op_br: | ||
67 | { | ||
68 | TCGLabel *l = arg_label(args[0]); | ||
69 | + uint32_t insn = B; | ||
70 | |||
71 | if (l->has_value) { | ||
72 | - tcg_out_b(s, 0, l->u.value_ptr); | ||
73 | + insn |= reloc_pc24_val(s->code_ptr, l->u.value_ptr); | ||
74 | } else { | ||
75 | tcg_out_reloc(s, s->code_ptr, R_PPC_REL24, l, 0); | ||
76 | - tcg_out_b_noaddr(s, B); | ||
77 | } | ||
78 | + tcg_out32(s, insn); | ||
79 | } | 44 | } |
80 | break; | 45 | break; |
81 | case INDEX_op_ld8u_i32: | 46 | case INDEX_op_shl_i64: |
47 | if (c2) { | ||
48 | - tcg_out_opc_imm(s, OPC_SLLI, a0, a1, a2); | ||
49 | + tcg_out_opc_imm(s, OPC_SLLI, a0, a1, a2 & 0x3f); | ||
50 | } else { | ||
51 | tcg_out_opc_reg(s, OPC_SLL, a0, a1, a2); | ||
52 | } | ||
53 | @@ -XXX,XX +XXX,XX @@ static void tcg_out_op(TCGContext *s, TCGOpcode opc, | ||
54 | |||
55 | case INDEX_op_shr_i32: | ||
56 | if (c2) { | ||
57 | - tcg_out_opc_imm(s, OPC_SRLIW, a0, a1, a2); | ||
58 | + tcg_out_opc_imm(s, OPC_SRLIW, a0, a1, a2 & 0x1f); | ||
59 | } else { | ||
60 | tcg_out_opc_reg(s, OPC_SRLW, a0, a1, a2); | ||
61 | } | ||
62 | break; | ||
63 | case INDEX_op_shr_i64: | ||
64 | if (c2) { | ||
65 | - tcg_out_opc_imm(s, OPC_SRLI, a0, a1, a2); | ||
66 | + tcg_out_opc_imm(s, OPC_SRLI, a0, a1, a2 & 0x3f); | ||
67 | } else { | ||
68 | tcg_out_opc_reg(s, OPC_SRL, a0, a1, a2); | ||
69 | } | ||
70 | @@ -XXX,XX +XXX,XX @@ static void tcg_out_op(TCGContext *s, TCGOpcode opc, | ||
71 | |||
72 | case INDEX_op_sar_i32: | ||
73 | if (c2) { | ||
74 | - tcg_out_opc_imm(s, OPC_SRAIW, a0, a1, a2); | ||
75 | + tcg_out_opc_imm(s, OPC_SRAIW, a0, a1, a2 & 0x1f); | ||
76 | } else { | ||
77 | tcg_out_opc_reg(s, OPC_SRAW, a0, a1, a2); | ||
78 | } | ||
79 | break; | ||
80 | case INDEX_op_sar_i64: | ||
81 | if (c2) { | ||
82 | - tcg_out_opc_imm(s, OPC_SRAI, a0, a1, a2); | ||
83 | + tcg_out_opc_imm(s, OPC_SRAI, a0, a1, a2 & 0x3f); | ||
84 | } else { | ||
85 | tcg_out_opc_reg(s, OPC_SRA, a0, a1, a2); | ||
86 | } | ||
82 | -- | 87 | -- |
83 | 2.17.2 | 88 | 2.25.1 |
84 | 89 | ||
85 | 90 | diff view generated by jsdifflib |
Deleted patch | |||
---|---|---|---|
1 | There is no longer a need for preserving branch offset operands, | ||
2 | as we no longer re-translate. | ||
3 | 1 | ||
4 | Reviewed-by: Alex Bennée <alex.bennee@linaro.org> | ||
5 | Signed-off-by: Richard Henderson <richard.henderson@linaro.org> | ||
6 | --- | ||
7 | tcg/s390/tcg-target.inc.c | 10 ++-------- | ||
8 | 1 file changed, 2 insertions(+), 8 deletions(-) | ||
9 | |||
10 | diff --git a/tcg/s390/tcg-target.inc.c b/tcg/s390/tcg-target.inc.c | ||
11 | index XXXXXXX..XXXXXXX 100644 | ||
12 | --- a/tcg/s390/tcg-target.inc.c | ||
13 | +++ b/tcg/s390/tcg-target.inc.c | ||
14 | @@ -XXX,XX +XXX,XX @@ static void tgen_branch(TCGContext *s, int cc, TCGLabel *l) | ||
15 | static void tgen_compare_branch(TCGContext *s, S390Opcode opc, int cc, | ||
16 | TCGReg r1, TCGReg r2, TCGLabel *l) | ||
17 | { | ||
18 | - intptr_t off; | ||
19 | + intptr_t off = 0; | ||
20 | |||
21 | if (l->has_value) { | ||
22 | off = l->u.value_ptr - s->code_ptr; | ||
23 | } else { | ||
24 | - /* We need to keep the offset unchanged for retranslation. */ | ||
25 | - off = s->code_ptr[1]; | ||
26 | tcg_out_reloc(s, s->code_ptr + 1, R_390_PC16DBL, l, 2); | ||
27 | } | ||
28 | |||
29 | @@ -XXX,XX +XXX,XX @@ static void tgen_compare_branch(TCGContext *s, S390Opcode opc, int cc, | ||
30 | static void tgen_compare_imm_branch(TCGContext *s, S390Opcode opc, int cc, | ||
31 | TCGReg r1, int i2, TCGLabel *l) | ||
32 | { | ||
33 | - tcg_target_long off; | ||
34 | + tcg_target_long off = 0; | ||
35 | |||
36 | if (l->has_value) { | ||
37 | off = l->u.value_ptr - s->code_ptr; | ||
38 | } else { | ||
39 | - /* We need to keep the offset unchanged for retranslation. */ | ||
40 | - off = s->code_ptr[1]; | ||
41 | tcg_out_reloc(s, s->code_ptr + 1, R_390_PC16DBL, l, 2); | ||
42 | } | ||
43 | |||
44 | @@ -XXX,XX +XXX,XX @@ static void tcg_out_qemu_ld(TCGContext* s, TCGReg data_reg, TCGReg addr_reg, | ||
45 | |||
46 | base_reg = tcg_out_tlb_read(s, addr_reg, opc, mem_index, 1); | ||
47 | |||
48 | - /* We need to keep the offset unchanged for retranslation. */ | ||
49 | tcg_out16(s, RI_BRC | (S390_CC_NE << 4)); | ||
50 | label_ptr = s->code_ptr; | ||
51 | s->code_ptr += 1; | ||
52 | @@ -XXX,XX +XXX,XX @@ static void tcg_out_qemu_st(TCGContext* s, TCGReg data_reg, TCGReg addr_reg, | ||
53 | |||
54 | base_reg = tcg_out_tlb_read(s, addr_reg, opc, mem_index, 0); | ||
55 | |||
56 | - /* We need to keep the offset unchanged for retranslation. */ | ||
57 | tcg_out16(s, RI_BRC | (S390_CC_NE << 4)); | ||
58 | label_ptr = s->code_ptr; | ||
59 | s->code_ptr += 1; | ||
60 | -- | ||
61 | 2.17.2 | ||
62 | |||
63 | diff view generated by jsdifflib |
Deleted patch | |||
---|---|---|---|
1 | There is no longer a need for preserving branch offset operands, | ||
2 | as we no longer re-translate. | ||
3 | 1 | ||
4 | Reviewed-by: Alex Bennée <alex.bennee@linaro.org> | ||
5 | Signed-off-by: Richard Henderson <richard.henderson@linaro.org> | ||
6 | --- | ||
7 | tcg/sparc/tcg-target.inc.c | 8 ++------ | ||
8 | 1 file changed, 2 insertions(+), 6 deletions(-) | ||
9 | |||
10 | diff --git a/tcg/sparc/tcg-target.inc.c b/tcg/sparc/tcg-target.inc.c | ||
11 | index XXXXXXX..XXXXXXX 100644 | ||
12 | --- a/tcg/sparc/tcg-target.inc.c | ||
13 | +++ b/tcg/sparc/tcg-target.inc.c | ||
14 | @@ -XXX,XX +XXX,XX @@ static void tcg_out_bpcc0(TCGContext *s, int scond, int flags, int off19) | ||
15 | |||
16 | static void tcg_out_bpcc(TCGContext *s, int scond, int flags, TCGLabel *l) | ||
17 | { | ||
18 | - int off19; | ||
19 | + int off19 = 0; | ||
20 | |||
21 | if (l->has_value) { | ||
22 | off19 = INSN_OFF19(tcg_pcrel_diff(s, l->u.value_ptr)); | ||
23 | } else { | ||
24 | - /* Make sure to preserve destinations during retranslation. */ | ||
25 | - off19 = *s->code_ptr & INSN_OFF19(-1); | ||
26 | tcg_out_reloc(s, s->code_ptr, R_SPARC_WDISP19, l, 0); | ||
27 | } | ||
28 | tcg_out_bpcc0(s, scond, flags, off19); | ||
29 | @@ -XXX,XX +XXX,XX @@ static void tcg_out_brcond_i64(TCGContext *s, TCGCond cond, TCGReg arg1, | ||
30 | { | ||
31 | /* For 64-bit signed comparisons vs zero, we can avoid the compare. */ | ||
32 | if (arg2 == 0 && !is_unsigned_cond(cond)) { | ||
33 | - int off16; | ||
34 | + int off16 = 0; | ||
35 | |||
36 | if (l->has_value) { | ||
37 | off16 = INSN_OFF16(tcg_pcrel_diff(s, l->u.value_ptr)); | ||
38 | } else { | ||
39 | - /* Make sure to preserve destinations during retranslation. */ | ||
40 | - off16 = *s->code_ptr & INSN_OFF16(-1); | ||
41 | tcg_out_reloc(s, s->code_ptr, R_SPARC_WDISP16, l, 0); | ||
42 | } | ||
43 | tcg_out32(s, INSN_OP(0) | INSN_OP2(3) | BPR_PT | INSN_RS1(arg1) | ||
44 | -- | ||
45 | 2.17.2 | ||
46 | |||
47 | diff view generated by jsdifflib |
Deleted patch | |||
---|---|---|---|
1 | There is no longer a need for preserving branch offset operands, | ||
2 | as we no longer re-translate. | ||
3 | 1 | ||
4 | Reviewed-by: Alex Bennée <alex.bennee@linaro.org> | ||
5 | Signed-off-by: Richard Henderson <richard.henderson@linaro.org> | ||
6 | --- | ||
7 | tcg/mips/tcg-target.inc.c | 7 +------ | ||
8 | 1 file changed, 1 insertion(+), 6 deletions(-) | ||
9 | |||
10 | diff --git a/tcg/mips/tcg-target.inc.c b/tcg/mips/tcg-target.inc.c | ||
11 | index XXXXXXX..XXXXXXX 100644 | ||
12 | --- a/tcg/mips/tcg-target.inc.c | ||
13 | +++ b/tcg/mips/tcg-target.inc.c | ||
14 | @@ -XXX,XX +XXX,XX @@ static inline void tcg_out_opc_bf64(TCGContext *s, MIPSInsn opc, MIPSInsn opm, | ||
15 | static inline void tcg_out_opc_br(TCGContext *s, MIPSInsn opc, | ||
16 | TCGReg rt, TCGReg rs) | ||
17 | { | ||
18 | - /* We pay attention here to not modify the branch target by reading | ||
19 | - the existing value and using it again. This ensure that caches and | ||
20 | - memory are kept coherent during retranslation. */ | ||
21 | - uint16_t offset = (uint16_t)*s->code_ptr; | ||
22 | - | ||
23 | - tcg_out_opc_imm(s, opc, rt, rs, offset); | ||
24 | + tcg_out_opc_imm(s, opc, rt, rs, 0); | ||
25 | } | ||
26 | |||
27 | /* | ||
28 | -- | ||
29 | 2.17.2 | ||
30 | |||
31 | diff view generated by jsdifflib |
Deleted patch | |||
---|---|---|---|
1 | This will move the assert for success from within (subroutines of) | ||
2 | patch_reloc into the callers. It will also let new code do something | ||
3 | different when a relocation is out of range. | ||
4 | 1 | ||
5 | For the moment, all backends are trivially converted to return true. | ||
6 | |||
7 | Reviewed-by: Alex Bennée <alex.bennee@linaro.org> | ||
8 | Signed-off-by: Richard Henderson <richard.henderson@linaro.org> | ||
9 | --- | ||
10 | tcg/aarch64/tcg-target.inc.c | 3 ++- | ||
11 | tcg/arm/tcg-target.inc.c | 3 ++- | ||
12 | tcg/i386/tcg-target.inc.c | 3 ++- | ||
13 | tcg/mips/tcg-target.inc.c | 3 ++- | ||
14 | tcg/ppc/tcg-target.inc.c | 3 ++- | ||
15 | tcg/s390/tcg-target.inc.c | 3 ++- | ||
16 | tcg/sparc/tcg-target.inc.c | 5 +++-- | ||
17 | tcg/tcg.c | 8 +++++--- | ||
18 | tcg/tci/tcg-target.inc.c | 3 ++- | ||
19 | 9 files changed, 22 insertions(+), 12 deletions(-) | ||
20 | |||
21 | diff --git a/tcg/aarch64/tcg-target.inc.c b/tcg/aarch64/tcg-target.inc.c | ||
22 | index XXXXXXX..XXXXXXX 100644 | ||
23 | --- a/tcg/aarch64/tcg-target.inc.c | ||
24 | +++ b/tcg/aarch64/tcg-target.inc.c | ||
25 | @@ -XXX,XX +XXX,XX @@ static inline void reloc_pc19(tcg_insn_unit *code_ptr, tcg_insn_unit *target) | ||
26 | *code_ptr = deposit32(*code_ptr, 5, 19, offset); | ||
27 | } | ||
28 | |||
29 | -static inline void patch_reloc(tcg_insn_unit *code_ptr, int type, | ||
30 | +static inline bool patch_reloc(tcg_insn_unit *code_ptr, int type, | ||
31 | intptr_t value, intptr_t addend) | ||
32 | { | ||
33 | tcg_debug_assert(addend == 0); | ||
34 | @@ -XXX,XX +XXX,XX @@ static inline void patch_reloc(tcg_insn_unit *code_ptr, int type, | ||
35 | default: | ||
36 | tcg_abort(); | ||
37 | } | ||
38 | + return true; | ||
39 | } | ||
40 | |||
41 | #define TCG_CT_CONST_AIMM 0x100 | ||
42 | diff --git a/tcg/arm/tcg-target.inc.c b/tcg/arm/tcg-target.inc.c | ||
43 | index XXXXXXX..XXXXXXX 100644 | ||
44 | --- a/tcg/arm/tcg-target.inc.c | ||
45 | +++ b/tcg/arm/tcg-target.inc.c | ||
46 | @@ -XXX,XX +XXX,XX @@ static inline void reloc_pc24(tcg_insn_unit *code_ptr, tcg_insn_unit *target) | ||
47 | *code_ptr = (*code_ptr & ~0xffffff) | (offset & 0xffffff); | ||
48 | } | ||
49 | |||
50 | -static void patch_reloc(tcg_insn_unit *code_ptr, int type, | ||
51 | +static bool patch_reloc(tcg_insn_unit *code_ptr, int type, | ||
52 | intptr_t value, intptr_t addend) | ||
53 | { | ||
54 | tcg_debug_assert(addend == 0); | ||
55 | @@ -XXX,XX +XXX,XX @@ static void patch_reloc(tcg_insn_unit *code_ptr, int type, | ||
56 | } else { | ||
57 | g_assert_not_reached(); | ||
58 | } | ||
59 | + return true; | ||
60 | } | ||
61 | |||
62 | #define TCG_CT_CONST_ARM 0x100 | ||
63 | diff --git a/tcg/i386/tcg-target.inc.c b/tcg/i386/tcg-target.inc.c | ||
64 | index XXXXXXX..XXXXXXX 100644 | ||
65 | --- a/tcg/i386/tcg-target.inc.c | ||
66 | +++ b/tcg/i386/tcg-target.inc.c | ||
67 | @@ -XXX,XX +XXX,XX @@ static bool have_lzcnt; | ||
68 | |||
69 | static tcg_insn_unit *tb_ret_addr; | ||
70 | |||
71 | -static void patch_reloc(tcg_insn_unit *code_ptr, int type, | ||
72 | +static bool patch_reloc(tcg_insn_unit *code_ptr, int type, | ||
73 | intptr_t value, intptr_t addend) | ||
74 | { | ||
75 | value += addend; | ||
76 | @@ -XXX,XX +XXX,XX @@ static void patch_reloc(tcg_insn_unit *code_ptr, int type, | ||
77 | default: | ||
78 | tcg_abort(); | ||
79 | } | ||
80 | + return true; | ||
81 | } | ||
82 | |||
83 | #if TCG_TARGET_REG_BITS == 64 | ||
84 | diff --git a/tcg/mips/tcg-target.inc.c b/tcg/mips/tcg-target.inc.c | ||
85 | index XXXXXXX..XXXXXXX 100644 | ||
86 | --- a/tcg/mips/tcg-target.inc.c | ||
87 | +++ b/tcg/mips/tcg-target.inc.c | ||
88 | @@ -XXX,XX +XXX,XX @@ static inline void reloc_26(tcg_insn_unit *pc, tcg_insn_unit *target) | ||
89 | *pc = deposit32(*pc, 0, 26, reloc_26_val(pc, target)); | ||
90 | } | ||
91 | |||
92 | -static void patch_reloc(tcg_insn_unit *code_ptr, int type, | ||
93 | +static bool patch_reloc(tcg_insn_unit *code_ptr, int type, | ||
94 | intptr_t value, intptr_t addend) | ||
95 | { | ||
96 | tcg_debug_assert(type == R_MIPS_PC16); | ||
97 | tcg_debug_assert(addend == 0); | ||
98 | reloc_pc16(code_ptr, (tcg_insn_unit *)value); | ||
99 | + return true; | ||
100 | } | ||
101 | |||
102 | #define TCG_CT_CONST_ZERO 0x100 | ||
103 | diff --git a/tcg/ppc/tcg-target.inc.c b/tcg/ppc/tcg-target.inc.c | ||
104 | index XXXXXXX..XXXXXXX 100644 | ||
105 | --- a/tcg/ppc/tcg-target.inc.c | ||
106 | +++ b/tcg/ppc/tcg-target.inc.c | ||
107 | @@ -XXX,XX +XXX,XX @@ static const uint32_t tcg_to_isel[] = { | ||
108 | [TCG_COND_GTU] = ISEL | BC_(7, CR_GT), | ||
109 | }; | ||
110 | |||
111 | -static void patch_reloc(tcg_insn_unit *code_ptr, int type, | ||
112 | +static bool patch_reloc(tcg_insn_unit *code_ptr, int type, | ||
113 | intptr_t value, intptr_t addend) | ||
114 | { | ||
115 | tcg_insn_unit *target; | ||
116 | @@ -XXX,XX +XXX,XX @@ static void patch_reloc(tcg_insn_unit *code_ptr, int type, | ||
117 | default: | ||
118 | g_assert_not_reached(); | ||
119 | } | ||
120 | + return true; | ||
121 | } | ||
122 | |||
123 | static void tcg_out_mem_long(TCGContext *s, int opi, int opx, TCGReg rt, | ||
124 | diff --git a/tcg/s390/tcg-target.inc.c b/tcg/s390/tcg-target.inc.c | ||
125 | index XXXXXXX..XXXXXXX 100644 | ||
126 | --- a/tcg/s390/tcg-target.inc.c | ||
127 | +++ b/tcg/s390/tcg-target.inc.c | ||
128 | @@ -XXX,XX +XXX,XX @@ static void * const qemu_st_helpers[16] = { | ||
129 | static tcg_insn_unit *tb_ret_addr; | ||
130 | uint64_t s390_facilities; | ||
131 | |||
132 | -static void patch_reloc(tcg_insn_unit *code_ptr, int type, | ||
133 | +static bool patch_reloc(tcg_insn_unit *code_ptr, int type, | ||
134 | intptr_t value, intptr_t addend) | ||
135 | { | ||
136 | intptr_t pcrel2; | ||
137 | @@ -XXX,XX +XXX,XX @@ static void patch_reloc(tcg_insn_unit *code_ptr, int type, | ||
138 | default: | ||
139 | g_assert_not_reached(); | ||
140 | } | ||
141 | + return true; | ||
142 | } | ||
143 | |||
144 | /* parse target specific constraints */ | ||
145 | diff --git a/tcg/sparc/tcg-target.inc.c b/tcg/sparc/tcg-target.inc.c | ||
146 | index XXXXXXX..XXXXXXX 100644 | ||
147 | --- a/tcg/sparc/tcg-target.inc.c | ||
148 | +++ b/tcg/sparc/tcg-target.inc.c | ||
149 | @@ -XXX,XX +XXX,XX @@ static inline int check_fit_i32(int32_t val, unsigned int bits) | ||
150 | # define check_fit_ptr check_fit_i32 | ||
151 | #endif | ||
152 | |||
153 | -static void patch_reloc(tcg_insn_unit *code_ptr, int type, | ||
154 | +static bool patch_reloc(tcg_insn_unit *code_ptr, int type, | ||
155 | intptr_t value, intptr_t addend) | ||
156 | { | ||
157 | uint32_t insn = *code_ptr; | ||
158 | @@ -XXX,XX +XXX,XX @@ static void patch_reloc(tcg_insn_unit *code_ptr, int type, | ||
159 | /* Note that we're abusing this reloc type for our own needs. */ | ||
160 | code_ptr[0] = deposit32(code_ptr[0], 0, 22, value >> 10); | ||
161 | code_ptr[1] = deposit32(code_ptr[1], 0, 10, value); | ||
162 | - return; | ||
163 | + return true; | ||
164 | default: | ||
165 | g_assert_not_reached(); | ||
166 | } | ||
167 | |||
168 | *code_ptr = insn; | ||
169 | + return true; | ||
170 | } | ||
171 | |||
172 | /* parse target specific constraints */ | ||
173 | diff --git a/tcg/tcg.c b/tcg/tcg.c | ||
174 | index XXXXXXX..XXXXXXX 100644 | ||
175 | --- a/tcg/tcg.c | ||
176 | +++ b/tcg/tcg.c | ||
177 | @@ -XXX,XX +XXX,XX @@ | ||
178 | static void tcg_target_init(TCGContext *s); | ||
179 | static const TCGTargetOpDef *tcg_target_op_def(TCGOpcode); | ||
180 | static void tcg_target_qemu_prologue(TCGContext *s); | ||
181 | -static void patch_reloc(tcg_insn_unit *code_ptr, int type, | ||
182 | +static bool patch_reloc(tcg_insn_unit *code_ptr, int type, | ||
183 | intptr_t value, intptr_t addend); | ||
184 | |||
185 | /* The CIE and FDE header definitions will be common to all hosts. */ | ||
186 | @@ -XXX,XX +XXX,XX @@ static void tcg_out_reloc(TCGContext *s, tcg_insn_unit *code_ptr, int type, | ||
187 | /* FIXME: This may break relocations on RISC targets that | ||
188 | modify instruction fields in place. The caller may not have | ||
189 | written the initial value. */ | ||
190 | - patch_reloc(code_ptr, type, l->u.value, addend); | ||
191 | + bool ok = patch_reloc(code_ptr, type, l->u.value, addend); | ||
192 | + tcg_debug_assert(ok); | ||
193 | } else { | ||
194 | /* add a new relocation entry */ | ||
195 | r = tcg_malloc(sizeof(TCGRelocation)); | ||
196 | @@ -XXX,XX +XXX,XX @@ static void tcg_out_label(TCGContext *s, TCGLabel *l, tcg_insn_unit *ptr) | ||
197 | tcg_debug_assert(!l->has_value); | ||
198 | |||
199 | for (r = l->u.first_reloc; r != NULL; r = r->next) { | ||
200 | - patch_reloc(r->ptr, r->type, value, r->addend); | ||
201 | + bool ok = patch_reloc(r->ptr, r->type, value, r->addend); | ||
202 | + tcg_debug_assert(ok); | ||
203 | } | ||
204 | |||
205 | l->has_value = 1; | ||
206 | diff --git a/tcg/tci/tcg-target.inc.c b/tcg/tci/tcg-target.inc.c | ||
207 | index XXXXXXX..XXXXXXX 100644 | ||
208 | --- a/tcg/tci/tcg-target.inc.c | ||
209 | +++ b/tcg/tci/tcg-target.inc.c | ||
210 | @@ -XXX,XX +XXX,XX @@ static const char *const tcg_target_reg_names[TCG_TARGET_NB_REGS] = { | ||
211 | }; | ||
212 | #endif | ||
213 | |||
214 | -static void patch_reloc(tcg_insn_unit *code_ptr, int type, | ||
215 | +static bool patch_reloc(tcg_insn_unit *code_ptr, int type, | ||
216 | intptr_t value, intptr_t addend) | ||
217 | { | ||
218 | /* tcg_out_reloc always uses the same type, addend. */ | ||
219 | @@ -XXX,XX +XXX,XX @@ static void patch_reloc(tcg_insn_unit *code_ptr, int type, | ||
220 | } else { | ||
221 | tcg_patch64(code_ptr, value); | ||
222 | } | ||
223 | + return true; | ||
224 | } | ||
225 | |||
226 | /* Parse target specific constraints. */ | ||
227 | -- | ||
228 | 2.17.2 | ||
229 | |||
230 | diff view generated by jsdifflib |
Deleted patch | |||
---|---|---|---|
1 | Reviewed-by: Alex Bennée <alex.bennee@linaro.org> | ||
2 | Signed-off-by: Richard Henderson <richard.henderson@linaro.org> | ||
3 | --- | ||
4 | tcg/i386/tcg-target.inc.c | 4 ++-- | ||
5 | 1 file changed, 2 insertions(+), 2 deletions(-) | ||
6 | 1 | ||
7 | diff --git a/tcg/i386/tcg-target.inc.c b/tcg/i386/tcg-target.inc.c | ||
8 | index XXXXXXX..XXXXXXX 100644 | ||
9 | --- a/tcg/i386/tcg-target.inc.c | ||
10 | +++ b/tcg/i386/tcg-target.inc.c | ||
11 | @@ -XXX,XX +XXX,XX @@ static bool patch_reloc(tcg_insn_unit *code_ptr, int type, | ||
12 | case R_386_PC32: | ||
13 | value -= (uintptr_t)code_ptr; | ||
14 | if (value != (int32_t)value) { | ||
15 | - tcg_abort(); | ||
16 | + return false; | ||
17 | } | ||
18 | /* FALLTHRU */ | ||
19 | case R_386_32: | ||
20 | @@ -XXX,XX +XXX,XX @@ static bool patch_reloc(tcg_insn_unit *code_ptr, int type, | ||
21 | case R_386_PC8: | ||
22 | value -= (uintptr_t)code_ptr; | ||
23 | if (value != (int8_t)value) { | ||
24 | - tcg_abort(); | ||
25 | + return false; | ||
26 | } | ||
27 | tcg_patch8(code_ptr, value); | ||
28 | break; | ||
29 | -- | ||
30 | 2.17.2 | ||
31 | |||
32 | diff view generated by jsdifflib |
Deleted patch | |||
---|---|---|---|
1 | This does require an extra two checks within the slow paths | ||
2 | to replace the assert that we're moving. | ||
3 | 1 | ||
4 | Reviewed-by: Alex Bennée <alex.bennee@linaro.org> | ||
5 | Signed-off-by: Richard Henderson <richard.henderson@linaro.org> | ||
6 | --- | ||
7 | tcg/aarch64/tcg-target.inc.c | 37 ++++++++++++++++++++---------------- | ||
8 | 1 file changed, 21 insertions(+), 16 deletions(-) | ||
9 | |||
10 | diff --git a/tcg/aarch64/tcg-target.inc.c b/tcg/aarch64/tcg-target.inc.c | ||
11 | index XXXXXXX..XXXXXXX 100644 | ||
12 | --- a/tcg/aarch64/tcg-target.inc.c | ||
13 | +++ b/tcg/aarch64/tcg-target.inc.c | ||
14 | @@ -XXX,XX +XXX,XX @@ static const int tcg_target_call_oarg_regs[1] = { | ||
15 | #define TCG_REG_GUEST_BASE TCG_REG_X28 | ||
16 | #endif | ||
17 | |||
18 | -static inline void reloc_pc26(tcg_insn_unit *code_ptr, tcg_insn_unit *target) | ||
19 | +static inline bool reloc_pc26(tcg_insn_unit *code_ptr, tcg_insn_unit *target) | ||
20 | { | ||
21 | ptrdiff_t offset = target - code_ptr; | ||
22 | - tcg_debug_assert(offset == sextract64(offset, 0, 26)); | ||
23 | - /* read instruction, mask away previous PC_REL26 parameter contents, | ||
24 | - set the proper offset, then write back the instruction. */ | ||
25 | - *code_ptr = deposit32(*code_ptr, 0, 26, offset); | ||
26 | + if (offset == sextract64(offset, 0, 26)) { | ||
27 | + /* read instruction, mask away previous PC_REL26 parameter contents, | ||
28 | + set the proper offset, then write back the instruction. */ | ||
29 | + *code_ptr = deposit32(*code_ptr, 0, 26, offset); | ||
30 | + return true; | ||
31 | + } | ||
32 | + return false; | ||
33 | } | ||
34 | |||
35 | -static inline void reloc_pc19(tcg_insn_unit *code_ptr, tcg_insn_unit *target) | ||
36 | +static inline bool reloc_pc19(tcg_insn_unit *code_ptr, tcg_insn_unit *target) | ||
37 | { | ||
38 | ptrdiff_t offset = target - code_ptr; | ||
39 | - tcg_debug_assert(offset == sextract64(offset, 0, 19)); | ||
40 | - *code_ptr = deposit32(*code_ptr, 5, 19, offset); | ||
41 | + if (offset == sextract64(offset, 0, 19)) { | ||
42 | + *code_ptr = deposit32(*code_ptr, 5, 19, offset); | ||
43 | + return true; | ||
44 | + } | ||
45 | + return false; | ||
46 | } | ||
47 | |||
48 | static inline bool patch_reloc(tcg_insn_unit *code_ptr, int type, | ||
49 | @@ -XXX,XX +XXX,XX @@ static inline bool patch_reloc(tcg_insn_unit *code_ptr, int type, | ||
50 | switch (type) { | ||
51 | case R_AARCH64_JUMP26: | ||
52 | case R_AARCH64_CALL26: | ||
53 | - reloc_pc26(code_ptr, (tcg_insn_unit *)value); | ||
54 | - break; | ||
55 | + return reloc_pc26(code_ptr, (tcg_insn_unit *)value); | ||
56 | case R_AARCH64_CONDBR19: | ||
57 | - reloc_pc19(code_ptr, (tcg_insn_unit *)value); | ||
58 | - break; | ||
59 | + return reloc_pc19(code_ptr, (tcg_insn_unit *)value); | ||
60 | default: | ||
61 | - tcg_abort(); | ||
62 | + g_assert_not_reached(); | ||
63 | } | ||
64 | - return true; | ||
65 | } | ||
66 | |||
67 | #define TCG_CT_CONST_AIMM 0x100 | ||
68 | @@ -XXX,XX +XXX,XX @@ static void tcg_out_qemu_ld_slow_path(TCGContext *s, TCGLabelQemuLdst *lb) | ||
69 | TCGMemOp opc = get_memop(oi); | ||
70 | TCGMemOp size = opc & MO_SIZE; | ||
71 | |||
72 | - reloc_pc19(lb->label_ptr[0], s->code_ptr); | ||
73 | + bool ok = reloc_pc19(lb->label_ptr[0], s->code_ptr); | ||
74 | + tcg_debug_assert(ok); | ||
75 | |||
76 | tcg_out_mov(s, TCG_TYPE_PTR, TCG_REG_X0, TCG_AREG0); | ||
77 | tcg_out_mov(s, TARGET_LONG_BITS == 64, TCG_REG_X1, lb->addrlo_reg); | ||
78 | @@ -XXX,XX +XXX,XX @@ static void tcg_out_qemu_st_slow_path(TCGContext *s, TCGLabelQemuLdst *lb) | ||
79 | TCGMemOp opc = get_memop(oi); | ||
80 | TCGMemOp size = opc & MO_SIZE; | ||
81 | |||
82 | - reloc_pc19(lb->label_ptr[0], s->code_ptr); | ||
83 | + bool ok = reloc_pc19(lb->label_ptr[0], s->code_ptr); | ||
84 | + tcg_debug_assert(ok); | ||
85 | |||
86 | tcg_out_mov(s, TCG_TYPE_PTR, TCG_REG_X0, TCG_AREG0); | ||
87 | tcg_out_mov(s, TARGET_LONG_BITS == 64, TCG_REG_X1, lb->addrlo_reg); | ||
88 | -- | ||
89 | 2.17.2 | ||
90 | |||
91 | diff view generated by jsdifflib |
Deleted patch | |||
---|---|---|---|
1 | This does require an extra two checks within the slow paths | ||
2 | to replace the assert that we're moving. | ||
3 | 1 | ||
4 | Reviewed-by: Alex Bennée <alex.bennee@linaro.org> | ||
5 | Signed-off-by: Richard Henderson <richard.henderson@linaro.org> | ||
6 | --- | ||
7 | tcg/arm/tcg-target.inc.c | 22 ++++++++++++++++------ | ||
8 | 1 file changed, 16 insertions(+), 6 deletions(-) | ||
9 | |||
10 | diff --git a/tcg/arm/tcg-target.inc.c b/tcg/arm/tcg-target.inc.c | ||
11 | index XXXXXXX..XXXXXXX 100644 | ||
12 | --- a/tcg/arm/tcg-target.inc.c | ||
13 | +++ b/tcg/arm/tcg-target.inc.c | ||
14 | @@ -XXX,XX +XXX,XX @@ static const uint8_t tcg_cond_to_arm_cond[] = { | ||
15 | [TCG_COND_GTU] = COND_HI, | ||
16 | }; | ||
17 | |||
18 | -static inline void reloc_pc24(tcg_insn_unit *code_ptr, tcg_insn_unit *target) | ||
19 | +static inline bool reloc_pc24(tcg_insn_unit *code_ptr, tcg_insn_unit *target) | ||
20 | { | ||
21 | ptrdiff_t offset = (tcg_ptr_byte_diff(target, code_ptr) - 8) >> 2; | ||
22 | - *code_ptr = (*code_ptr & ~0xffffff) | (offset & 0xffffff); | ||
23 | + if (offset == sextract32(offset, 0, 24)) { | ||
24 | + *code_ptr = (*code_ptr & ~0xffffff) | (offset & 0xffffff); | ||
25 | + return true; | ||
26 | + } | ||
27 | + return false; | ||
28 | } | ||
29 | |||
30 | static bool patch_reloc(tcg_insn_unit *code_ptr, int type, | ||
31 | @@ -XXX,XX +XXX,XX @@ static bool patch_reloc(tcg_insn_unit *code_ptr, int type, | ||
32 | tcg_debug_assert(addend == 0); | ||
33 | |||
34 | if (type == R_ARM_PC24) { | ||
35 | - reloc_pc24(code_ptr, (tcg_insn_unit *)value); | ||
36 | + return reloc_pc24(code_ptr, (tcg_insn_unit *)value); | ||
37 | } else if (type == R_ARM_PC13) { | ||
38 | intptr_t diff = value - (uintptr_t)(code_ptr + 2); | ||
39 | tcg_insn_unit insn = *code_ptr; | ||
40 | @@ -XXX,XX +XXX,XX @@ static bool patch_reloc(tcg_insn_unit *code_ptr, int type, | ||
41 | } else { | ||
42 | int rd = extract32(insn, 12, 4); | ||
43 | int rt = rd == TCG_REG_PC ? TCG_REG_TMP : rd; | ||
44 | - assert(diff >= 0x1000 && diff < 0x100000); | ||
45 | + | ||
46 | + if (diff < 0x1000 || diff >= 0x100000) { | ||
47 | + return false; | ||
48 | + } | ||
49 | + | ||
50 | /* add rt, pc, #high */ | ||
51 | *code_ptr++ = ((insn & 0xf0000000) | (1 << 25) | ARITH_ADD | ||
52 | | (TCG_REG_PC << 16) | (rt << 12) | ||
53 | @@ -XXX,XX +XXX,XX @@ static void tcg_out_qemu_ld_slow_path(TCGContext *s, TCGLabelQemuLdst *lb) | ||
54 | TCGMemOp opc = get_memop(oi); | ||
55 | void *func; | ||
56 | |||
57 | - reloc_pc24(lb->label_ptr[0], s->code_ptr); | ||
58 | + bool ok = reloc_pc24(lb->label_ptr[0], s->code_ptr); | ||
59 | + tcg_debug_assert(ok); | ||
60 | |||
61 | argreg = tcg_out_arg_reg32(s, TCG_REG_R0, TCG_AREG0); | ||
62 | if (TARGET_LONG_BITS == 64) { | ||
63 | @@ -XXX,XX +XXX,XX @@ static void tcg_out_qemu_st_slow_path(TCGContext *s, TCGLabelQemuLdst *lb) | ||
64 | TCGMemOpIdx oi = lb->oi; | ||
65 | TCGMemOp opc = get_memop(oi); | ||
66 | |||
67 | - reloc_pc24(lb->label_ptr[0], s->code_ptr); | ||
68 | + bool ok = reloc_pc24(lb->label_ptr[0], s->code_ptr); | ||
69 | + tcg_debug_assert(ok); | ||
70 | |||
71 | argreg = TCG_REG_R0; | ||
72 | argreg = tcg_out_arg_reg32(s, argreg, TCG_AREG0); | ||
73 | -- | ||
74 | 2.17.2 | ||
75 | |||
76 | diff view generated by jsdifflib |
Deleted patch | |||
---|---|---|---|
1 | The reloc_pc{14,24}_val routines retain their asserts. | ||
2 | Use these directly within the slow paths. | ||
3 | 1 | ||
4 | Reviewed-by: Alex Bennée <alex.bennee@linaro.org> | ||
5 | Signed-off-by: Richard Henderson <richard.henderson@linaro.org> | ||
6 | --- | ||
7 | tcg/ppc/tcg-target.inc.c | 32 +++++++++++++++++++++----------- | ||
8 | 1 file changed, 21 insertions(+), 11 deletions(-) | ||
9 | |||
10 | diff --git a/tcg/ppc/tcg-target.inc.c b/tcg/ppc/tcg-target.inc.c | ||
11 | index XXXXXXX..XXXXXXX 100644 | ||
12 | --- a/tcg/ppc/tcg-target.inc.c | ||
13 | +++ b/tcg/ppc/tcg-target.inc.c | ||
14 | @@ -XXX,XX +XXX,XX @@ static uint32_t reloc_pc24_val(tcg_insn_unit *pc, tcg_insn_unit *target) | ||
15 | return disp & 0x3fffffc; | ||
16 | } | ||
17 | |||
18 | -static void reloc_pc24(tcg_insn_unit *pc, tcg_insn_unit *target) | ||
19 | +static bool reloc_pc24(tcg_insn_unit *pc, tcg_insn_unit *target) | ||
20 | { | ||
21 | - *pc = (*pc & ~0x3fffffc) | reloc_pc24_val(pc, target); | ||
22 | + ptrdiff_t disp = tcg_ptr_byte_diff(target, pc); | ||
23 | + if (in_range_b(disp)) { | ||
24 | + *pc = (*pc & ~0x3fffffc) | (disp & 0x3fffffc); | ||
25 | + return true; | ||
26 | + } | ||
27 | + return false; | ||
28 | } | ||
29 | |||
30 | static uint16_t reloc_pc14_val(tcg_insn_unit *pc, tcg_insn_unit *target) | ||
31 | @@ -XXX,XX +XXX,XX @@ static uint16_t reloc_pc14_val(tcg_insn_unit *pc, tcg_insn_unit *target) | ||
32 | return disp & 0xfffc; | ||
33 | } | ||
34 | |||
35 | -static void reloc_pc14(tcg_insn_unit *pc, tcg_insn_unit *target) | ||
36 | +static bool reloc_pc14(tcg_insn_unit *pc, tcg_insn_unit *target) | ||
37 | { | ||
38 | - *pc = (*pc & ~0xfffc) | reloc_pc14_val(pc, target); | ||
39 | + ptrdiff_t disp = tcg_ptr_byte_diff(target, pc); | ||
40 | + if (disp == (int16_t) disp) { | ||
41 | + *pc = (*pc & ~0xfffc) | (disp & 0xfffc); | ||
42 | + return true; | ||
43 | + } | ||
44 | + return false; | ||
45 | } | ||
46 | |||
47 | /* parse target specific constraints */ | ||
48 | @@ -XXX,XX +XXX,XX @@ static bool patch_reloc(tcg_insn_unit *code_ptr, int type, | ||
49 | |||
50 | switch (type) { | ||
51 | case R_PPC_REL14: | ||
52 | - reloc_pc14(code_ptr, target); | ||
53 | - break; | ||
54 | + return reloc_pc14(code_ptr, target); | ||
55 | case R_PPC_REL24: | ||
56 | - reloc_pc24(code_ptr, target); | ||
57 | - break; | ||
58 | + return reloc_pc24(code_ptr, target); | ||
59 | case R_PPC_ADDR16: | ||
60 | /* We are abusing this relocation type. This points to a pair | ||
61 | of insns, addis + load. If the displacement is small, we | ||
62 | @@ -XXX,XX +XXX,XX @@ static bool patch_reloc(tcg_insn_unit *code_ptr, int type, | ||
63 | } else { | ||
64 | int16_t lo = value; | ||
65 | int hi = value - lo; | ||
66 | - assert(hi + lo == value); | ||
67 | + if (hi + lo != value) { | ||
68 | + return false; | ||
69 | + } | ||
70 | code_ptr[0] = deposit32(code_ptr[0], 0, 16, hi >> 16); | ||
71 | code_ptr[1] = deposit32(code_ptr[1], 0, 16, lo); | ||
72 | } | ||
73 | @@ -XXX,XX +XXX,XX @@ static void tcg_out_qemu_ld_slow_path(TCGContext *s, TCGLabelQemuLdst *lb) | ||
74 | TCGMemOp opc = get_memop(oi); | ||
75 | TCGReg hi, lo, arg = TCG_REG_R3; | ||
76 | |||
77 | - reloc_pc14(lb->label_ptr[0], s->code_ptr); | ||
78 | + **lb->label_ptr |= reloc_pc14_val(*lb->label_ptr, s->code_ptr); | ||
79 | |||
80 | tcg_out_mov(s, TCG_TYPE_PTR, arg++, TCG_AREG0); | ||
81 | |||
82 | @@ -XXX,XX +XXX,XX @@ static void tcg_out_qemu_st_slow_path(TCGContext *s, TCGLabelQemuLdst *lb) | ||
83 | TCGMemOp s_bits = opc & MO_SIZE; | ||
84 | TCGReg hi, lo, arg = TCG_REG_R3; | ||
85 | |||
86 | - reloc_pc14(lb->label_ptr[0], s->code_ptr); | ||
87 | + **lb->label_ptr |= reloc_pc14_val(*lb->label_ptr, s->code_ptr); | ||
88 | |||
89 | tcg_out_mov(s, TCG_TYPE_PTR, arg++, TCG_AREG0); | ||
90 | |||
91 | -- | ||
92 | 2.17.2 | ||
93 | |||
94 | diff view generated by jsdifflib |
Deleted patch | |||
---|---|---|---|
1 | This does require an extra two checks within the slow paths | ||
2 | to replace the assert that we're moving. Also add two checks | ||
3 | within existing functions that lacked any kind of assert for | ||
4 | out of range branch. | ||
5 | 1 | ||
6 | Reviewed-by: Alex Bennée <alex.bennee@linaro.org> | ||
7 | Signed-off-by: Richard Henderson <richard.henderson@linaro.org> | ||
8 | --- | ||
9 | tcg/s390/tcg-target.inc.c | 34 +++++++++++++++++++++++----------- | ||
10 | 1 file changed, 23 insertions(+), 11 deletions(-) | ||
11 | |||
12 | diff --git a/tcg/s390/tcg-target.inc.c b/tcg/s390/tcg-target.inc.c | ||
13 | index XXXXXXX..XXXXXXX 100644 | ||
14 | --- a/tcg/s390/tcg-target.inc.c | ||
15 | +++ b/tcg/s390/tcg-target.inc.c | ||
16 | @@ -XXX,XX +XXX,XX @@ static bool patch_reloc(tcg_insn_unit *code_ptr, int type, | ||
17 | |||
18 | switch (type) { | ||
19 | case R_390_PC16DBL: | ||
20 | - assert(pcrel2 == (int16_t)pcrel2); | ||
21 | - tcg_patch16(code_ptr, pcrel2); | ||
22 | + if (pcrel2 == (int16_t)pcrel2) { | ||
23 | + tcg_patch16(code_ptr, pcrel2); | ||
24 | + return true; | ||
25 | + } | ||
26 | break; | ||
27 | case R_390_PC32DBL: | ||
28 | - assert(pcrel2 == (int32_t)pcrel2); | ||
29 | - tcg_patch32(code_ptr, pcrel2); | ||
30 | + if (pcrel2 == (int32_t)pcrel2) { | ||
31 | + tcg_patch32(code_ptr, pcrel2); | ||
32 | + return true; | ||
33 | + } | ||
34 | break; | ||
35 | case R_390_20: | ||
36 | - assert(value == sextract64(value, 0, 20)); | ||
37 | - old = *(uint32_t *)code_ptr & 0xf00000ff; | ||
38 | - old |= ((value & 0xfff) << 16) | ((value & 0xff000) >> 4); | ||
39 | - tcg_patch32(code_ptr, old); | ||
40 | + if (value == sextract64(value, 0, 20)) { | ||
41 | + old = *(uint32_t *)code_ptr & 0xf00000ff; | ||
42 | + old |= ((value & 0xfff) << 16) | ((value & 0xff000) >> 4); | ||
43 | + tcg_patch32(code_ptr, old); | ||
44 | + return true; | ||
45 | + } | ||
46 | break; | ||
47 | default: | ||
48 | g_assert_not_reached(); | ||
49 | } | ||
50 | - return true; | ||
51 | + return false; | ||
52 | } | ||
53 | |||
54 | /* parse target specific constraints */ | ||
55 | @@ -XXX,XX +XXX,XX @@ static void tgen_compare_branch(TCGContext *s, S390Opcode opc, int cc, | ||
56 | |||
57 | if (l->has_value) { | ||
58 | off = l->u.value_ptr - s->code_ptr; | ||
59 | + tcg_debug_assert(off == (int16_t)off); | ||
60 | } else { | ||
61 | tcg_out_reloc(s, s->code_ptr + 1, R_390_PC16DBL, l, 2); | ||
62 | } | ||
63 | @@ -XXX,XX +XXX,XX @@ static void tgen_compare_imm_branch(TCGContext *s, S390Opcode opc, int cc, | ||
64 | |||
65 | if (l->has_value) { | ||
66 | off = l->u.value_ptr - s->code_ptr; | ||
67 | + tcg_debug_assert(off == (int16_t)off); | ||
68 | } else { | ||
69 | tcg_out_reloc(s, s->code_ptr + 1, R_390_PC16DBL, l, 2); | ||
70 | } | ||
71 | @@ -XXX,XX +XXX,XX @@ static void tcg_out_qemu_ld_slow_path(TCGContext *s, TCGLabelQemuLdst *lb) | ||
72 | TCGMemOpIdx oi = lb->oi; | ||
73 | TCGMemOp opc = get_memop(oi); | ||
74 | |||
75 | - patch_reloc(lb->label_ptr[0], R_390_PC16DBL, (intptr_t)s->code_ptr, 2); | ||
76 | + bool ok = patch_reloc(lb->label_ptr[0], R_390_PC16DBL, | ||
77 | + (intptr_t)s->code_ptr, 2); | ||
78 | + tcg_debug_assert(ok); | ||
79 | |||
80 | tcg_out_mov(s, TCG_TYPE_PTR, TCG_REG_R2, TCG_AREG0); | ||
81 | if (TARGET_LONG_BITS == 64) { | ||
82 | @@ -XXX,XX +XXX,XX @@ static void tcg_out_qemu_st_slow_path(TCGContext *s, TCGLabelQemuLdst *lb) | ||
83 | TCGMemOpIdx oi = lb->oi; | ||
84 | TCGMemOp opc = get_memop(oi); | ||
85 | |||
86 | - patch_reloc(lb->label_ptr[0], R_390_PC16DBL, (intptr_t)s->code_ptr, 2); | ||
87 | + bool ok = patch_reloc(lb->label_ptr[0], R_390_PC16DBL, | ||
88 | + (intptr_t)s->code_ptr, 2); | ||
89 | + tcg_debug_assert(ok); | ||
90 | |||
91 | tcg_out_mov(s, TCG_TYPE_PTR, TCG_REG_R2, TCG_AREG0); | ||
92 | if (TARGET_LONG_BITS == 64) { | ||
93 | -- | ||
94 | 2.17.2 | ||
95 | |||
96 | diff view generated by jsdifflib |
Deleted patch | |||
---|---|---|---|
1 | This helps preserve the invariant that all TCG_TYPE_I32 values | ||
2 | are stored zero-extended in the 64-bit host registers. | ||
3 | 1 | ||
4 | Reviewed-by: Emilio G. Cota <cota@braap.org> | ||
5 | Signed-off-by: Richard Henderson <richard.henderson@linaro.org> | ||
6 | --- | ||
7 | tcg/i386/tcg-target.inc.c | 13 +++++++------ | ||
8 | 1 file changed, 7 insertions(+), 6 deletions(-) | ||
9 | |||
10 | diff --git a/tcg/i386/tcg-target.inc.c b/tcg/i386/tcg-target.inc.c | ||
11 | index XXXXXXX..XXXXXXX 100644 | ||
12 | --- a/tcg/i386/tcg-target.inc.c | ||
13 | +++ b/tcg/i386/tcg-target.inc.c | ||
14 | @@ -XXX,XX +XXX,XX @@ static inline void setup_guest_base_seg(void) { } | ||
15 | |||
16 | static void tcg_out_qemu_ld_direct(TCGContext *s, TCGReg datalo, TCGReg datahi, | ||
17 | TCGReg base, int index, intptr_t ofs, | ||
18 | - int seg, TCGMemOp memop) | ||
19 | + int seg, bool is64, TCGMemOp memop) | ||
20 | { | ||
21 | const TCGMemOp real_bswap = memop & MO_BSWAP; | ||
22 | TCGMemOp bswap = real_bswap; | ||
23 | + int rexw = is64 * P_REXW; | ||
24 | int movop = OPC_MOVL_GvEv; | ||
25 | |||
26 | if (have_movbe && real_bswap) { | ||
27 | @@ -XXX,XX +XXX,XX @@ static void tcg_out_qemu_ld_direct(TCGContext *s, TCGReg datalo, TCGReg datahi, | ||
28 | base, index, 0, ofs); | ||
29 | break; | ||
30 | case MO_SB: | ||
31 | - tcg_out_modrm_sib_offset(s, OPC_MOVSBL + P_REXW + seg, datalo, | ||
32 | + tcg_out_modrm_sib_offset(s, OPC_MOVSBL + rexw + seg, datalo, | ||
33 | base, index, 0, ofs); | ||
34 | break; | ||
35 | case MO_UW: | ||
36 | @@ -XXX,XX +XXX,XX @@ static void tcg_out_qemu_ld_direct(TCGContext *s, TCGReg datalo, TCGReg datahi, | ||
37 | base, index, 0, ofs); | ||
38 | tcg_out_rolw_8(s, datalo); | ||
39 | } | ||
40 | - tcg_out_modrm(s, OPC_MOVSWL + P_REXW, datalo, datalo); | ||
41 | + tcg_out_modrm(s, OPC_MOVSWL + rexw, datalo, datalo); | ||
42 | } else { | ||
43 | - tcg_out_modrm_sib_offset(s, OPC_MOVSWL + P_REXW + seg, | ||
44 | + tcg_out_modrm_sib_offset(s, OPC_MOVSWL + rexw + seg, | ||
45 | datalo, base, index, 0, ofs); | ||
46 | } | ||
47 | break; | ||
48 | @@ -XXX,XX +XXX,XX @@ static void tcg_out_qemu_ld(TCGContext *s, const TCGArg *args, bool is64) | ||
49 | label_ptr, offsetof(CPUTLBEntry, addr_read)); | ||
50 | |||
51 | /* TLB Hit. */ | ||
52 | - tcg_out_qemu_ld_direct(s, datalo, datahi, TCG_REG_L1, -1, 0, 0, opc); | ||
53 | + tcg_out_qemu_ld_direct(s, datalo, datahi, TCG_REG_L1, -1, 0, 0, is64, opc); | ||
54 | |||
55 | /* Record the current context of a load into ldst label */ | ||
56 | add_qemu_ldst_label(s, true, oi, datalo, datahi, addrlo, addrhi, | ||
57 | @@ -XXX,XX +XXX,XX @@ static void tcg_out_qemu_ld(TCGContext *s, const TCGArg *args, bool is64) | ||
58 | } | ||
59 | |||
60 | tcg_out_qemu_ld_direct(s, datalo, datahi, | ||
61 | - base, index, offset, seg, opc); | ||
62 | + base, index, offset, seg, is64, opc); | ||
63 | } | ||
64 | #endif | ||
65 | } | ||
66 | -- | ||
67 | 2.17.2 | ||
68 | |||
69 | diff view generated by jsdifflib |
Deleted patch | |||
---|---|---|---|
1 | This helps preserve the invariant that all TCG_TYPE_I32 values | ||
2 | are stored zero-extended in the 64-bit host registers. | ||
3 | 1 | ||
4 | Signed-off-by: Richard Henderson <richard.henderson@linaro.org> | ||
5 | --- | ||
6 | tcg/i386/tcg-target.inc.c | 13 ++++++++----- | ||
7 | 1 file changed, 8 insertions(+), 5 deletions(-) | ||
8 | |||
9 | diff --git a/tcg/i386/tcg-target.inc.c b/tcg/i386/tcg-target.inc.c | ||
10 | index XXXXXXX..XXXXXXX 100644 | ||
11 | --- a/tcg/i386/tcg-target.inc.c | ||
12 | +++ b/tcg/i386/tcg-target.inc.c | ||
13 | @@ -XXX,XX +XXX,XX @@ static inline void tcg_out_tlb_load(TCGContext *s, TCGReg addrlo, TCGReg addrhi, | ||
14 | * Record the context of a call to the out of line helper code for the slow path | ||
15 | * for a load or store, so that we can later generate the correct helper code | ||
16 | */ | ||
17 | -static void add_qemu_ldst_label(TCGContext *s, bool is_ld, TCGMemOpIdx oi, | ||
18 | +static void add_qemu_ldst_label(TCGContext *s, bool is_ld, bool is_64, | ||
19 | + TCGMemOpIdx oi, | ||
20 | TCGReg datalo, TCGReg datahi, | ||
21 | TCGReg addrlo, TCGReg addrhi, | ||
22 | tcg_insn_unit *raddr, | ||
23 | @@ -XXX,XX +XXX,XX @@ static void add_qemu_ldst_label(TCGContext *s, bool is_ld, TCGMemOpIdx oi, | ||
24 | |||
25 | label->is_ld = is_ld; | ||
26 | label->oi = oi; | ||
27 | + label->type = is_64 ? TCG_TYPE_I64 : TCG_TYPE_I32; | ||
28 | label->datalo_reg = datalo; | ||
29 | label->datahi_reg = datahi; | ||
30 | label->addrlo_reg = addrlo; | ||
31 | @@ -XXX,XX +XXX,XX @@ static void tcg_out_qemu_ld_slow_path(TCGContext *s, TCGLabelQemuLdst *l) | ||
32 | TCGMemOp opc = get_memop(oi); | ||
33 | TCGReg data_reg; | ||
34 | tcg_insn_unit **label_ptr = &l->label_ptr[0]; | ||
35 | + int rexw = (l->type == TCG_TYPE_I64 ? P_REXW : 0); | ||
36 | |||
37 | /* resolve label address */ | ||
38 | tcg_patch32(label_ptr[0], s->code_ptr - label_ptr[0] - 4); | ||
39 | @@ -XXX,XX +XXX,XX @@ static void tcg_out_qemu_ld_slow_path(TCGContext *s, TCGLabelQemuLdst *l) | ||
40 | data_reg = l->datalo_reg; | ||
41 | switch (opc & MO_SSIZE) { | ||
42 | case MO_SB: | ||
43 | - tcg_out_ext8s(s, data_reg, TCG_REG_EAX, P_REXW); | ||
44 | + tcg_out_ext8s(s, data_reg, TCG_REG_EAX, rexw); | ||
45 | break; | ||
46 | case MO_SW: | ||
47 | - tcg_out_ext16s(s, data_reg, TCG_REG_EAX, P_REXW); | ||
48 | + tcg_out_ext16s(s, data_reg, TCG_REG_EAX, rexw); | ||
49 | break; | ||
50 | #if TCG_TARGET_REG_BITS == 64 | ||
51 | case MO_SL: | ||
52 | @@ -XXX,XX +XXX,XX @@ static void tcg_out_qemu_ld(TCGContext *s, const TCGArg *args, bool is64) | ||
53 | tcg_out_qemu_ld_direct(s, datalo, datahi, TCG_REG_L1, -1, 0, 0, is64, opc); | ||
54 | |||
55 | /* Record the current context of a load into ldst label */ | ||
56 | - add_qemu_ldst_label(s, true, oi, datalo, datahi, addrlo, addrhi, | ||
57 | + add_qemu_ldst_label(s, true, is64, oi, datalo, datahi, addrlo, addrhi, | ||
58 | s->code_ptr, label_ptr); | ||
59 | #else | ||
60 | { | ||
61 | @@ -XXX,XX +XXX,XX @@ static void tcg_out_qemu_st(TCGContext *s, const TCGArg *args, bool is64) | ||
62 | tcg_out_qemu_st_direct(s, datalo, datahi, TCG_REG_L1, 0, 0, opc); | ||
63 | |||
64 | /* Record the current context of a store into ldst label */ | ||
65 | - add_qemu_ldst_label(s, false, oi, datalo, datahi, addrlo, addrhi, | ||
66 | + add_qemu_ldst_label(s, false, is64, oi, datalo, datahi, addrlo, addrhi, | ||
67 | s->code_ptr, label_ptr); | ||
68 | #else | ||
69 | { | ||
70 | -- | ||
71 | 2.17.2 | ||
72 | |||
73 | diff view generated by jsdifflib |
Deleted patch | |||
---|---|---|---|
1 | This preserves the invariant that all TCG_TYPE_I32 values are | ||
2 | zero-extended in the 64-bit host register. | ||
3 | 1 | ||
4 | Reviewed-by: Emilio G. Cota <cota@braap.org> | ||
5 | Signed-off-by: Richard Henderson <richard.henderson@linaro.org> | ||
6 | --- | ||
7 | tcg/i386/tcg-target.h | 5 +++-- | ||
8 | tcg/i386/tcg-target.inc.c | 6 ++++++ | ||
9 | 2 files changed, 9 insertions(+), 2 deletions(-) | ||
10 | |||
11 | diff --git a/tcg/i386/tcg-target.h b/tcg/i386/tcg-target.h | ||
12 | index XXXXXXX..XXXXXXX 100644 | ||
13 | --- a/tcg/i386/tcg-target.h | ||
14 | +++ b/tcg/i386/tcg-target.h | ||
15 | @@ -XXX,XX +XXX,XX @@ extern bool have_avx2; | ||
16 | #define TCG_TARGET_HAS_direct_jump 1 | ||
17 | |||
18 | #if TCG_TARGET_REG_BITS == 64 | ||
19 | -#define TCG_TARGET_HAS_extrl_i64_i32 0 | ||
20 | -#define TCG_TARGET_HAS_extrh_i64_i32 0 | ||
21 | +/* Keep target addresses zero-extended in a register. */ | ||
22 | +#define TCG_TARGET_HAS_extrl_i64_i32 (TARGET_LONG_BITS == 32) | ||
23 | +#define TCG_TARGET_HAS_extrh_i64_i32 (TARGET_LONG_BITS == 32) | ||
24 | #define TCG_TARGET_HAS_div2_i64 1 | ||
25 | #define TCG_TARGET_HAS_rot_i64 1 | ||
26 | #define TCG_TARGET_HAS_ext8s_i64 1 | ||
27 | diff --git a/tcg/i386/tcg-target.inc.c b/tcg/i386/tcg-target.inc.c | ||
28 | index XXXXXXX..XXXXXXX 100644 | ||
29 | --- a/tcg/i386/tcg-target.inc.c | ||
30 | +++ b/tcg/i386/tcg-target.inc.c | ||
31 | @@ -XXX,XX +XXX,XX @@ static inline void tcg_out_op(TCGContext *s, TCGOpcode opc, | ||
32 | break; | ||
33 | case INDEX_op_extu_i32_i64: | ||
34 | case INDEX_op_ext32u_i64: | ||
35 | + case INDEX_op_extrl_i64_i32: | ||
36 | tcg_out_ext32u(s, a0, a1); | ||
37 | break; | ||
38 | case INDEX_op_ext_i32_i64: | ||
39 | case INDEX_op_ext32s_i64: | ||
40 | tcg_out_ext32s(s, a0, a1); | ||
41 | break; | ||
42 | + case INDEX_op_extrh_i64_i32: | ||
43 | + tcg_out_shifti(s, SHIFT_SHR + P_REXW, a0, 32); | ||
44 | + break; | ||
45 | #endif | ||
46 | |||
47 | OP_32_64(deposit): | ||
48 | @@ -XXX,XX +XXX,XX @@ static const TCGTargetOpDef *tcg_target_op_def(TCGOpcode op) | ||
49 | case INDEX_op_neg_i64: | ||
50 | case INDEX_op_not_i32: | ||
51 | case INDEX_op_not_i64: | ||
52 | + case INDEX_op_extrh_i64_i32: | ||
53 | return &r_0; | ||
54 | |||
55 | case INDEX_op_ext8s_i32: | ||
56 | @@ -XXX,XX +XXX,XX @@ static const TCGTargetOpDef *tcg_target_op_def(TCGOpcode op) | ||
57 | case INDEX_op_ext32u_i64: | ||
58 | case INDEX_op_ext_i32_i64: | ||
59 | case INDEX_op_extu_i32_i64: | ||
60 | + case INDEX_op_extrl_i64_i32: | ||
61 | case INDEX_op_extract_i32: | ||
62 | case INDEX_op_extract_i64: | ||
63 | case INDEX_op_sextract_i32: | ||
64 | -- | ||
65 | 2.17.2 | ||
66 | |||
67 | diff view generated by jsdifflib |
Deleted patch | |||
---|---|---|---|
1 | We now have an invariant that all TCG_TYPE_I32 values are | ||
2 | zero-extended, which means that we do not need to extend | ||
3 | them again during qemu_ld/st, either explicitly via a separate | ||
4 | tcg_out_ext32u or implicitly via P_ADDR32. | ||
5 | 1 | ||
6 | Reviewed-by: Emilio G. Cota <cota@braap.org> | ||
7 | Signed-off-by: Richard Henderson <richard.henderson@linaro.org> | ||
8 | --- | ||
9 | tcg/i386/tcg-target.inc.c | 103 +++++++++++++++----------------------- | ||
10 | 1 file changed, 40 insertions(+), 63 deletions(-) | ||
11 | |||
12 | diff --git a/tcg/i386/tcg-target.inc.c b/tcg/i386/tcg-target.inc.c | ||
13 | index XXXXXXX..XXXXXXX 100644 | ||
14 | --- a/tcg/i386/tcg-target.inc.c | ||
15 | +++ b/tcg/i386/tcg-target.inc.c | ||
16 | @@ -XXX,XX +XXX,XX @@ static inline int tcg_target_const_match(tcg_target_long val, TCGType type, | ||
17 | #define P_EXT38 0x200 /* 0x0f 0x38 opcode prefix */ | ||
18 | #define P_DATA16 0x400 /* 0x66 opcode prefix */ | ||
19 | #if TCG_TARGET_REG_BITS == 64 | ||
20 | -# define P_ADDR32 0x800 /* 0x67 opcode prefix */ | ||
21 | # define P_REXW 0x1000 /* Set REX.W = 1 */ | ||
22 | # define P_REXB_R 0x2000 /* REG field as byte register */ | ||
23 | # define P_REXB_RM 0x4000 /* R/M field as byte register */ | ||
24 | # define P_GS 0x8000 /* gs segment override */ | ||
25 | #else | ||
26 | -# define P_ADDR32 0 | ||
27 | # define P_REXW 0 | ||
28 | # define P_REXB_R 0 | ||
29 | # define P_REXB_RM 0 | ||
30 | @@ -XXX,XX +XXX,XX @@ static void tcg_out_opc(TCGContext *s, int opc, int r, int rm, int x) | ||
31 | tcg_debug_assert((opc & P_REXW) == 0); | ||
32 | tcg_out8(s, 0x66); | ||
33 | } | ||
34 | - if (opc & P_ADDR32) { | ||
35 | - tcg_out8(s, 0x67); | ||
36 | - } | ||
37 | if (opc & P_SIMDF3) { | ||
38 | tcg_out8(s, 0xf3); | ||
39 | } else if (opc & P_SIMDF2) { | ||
40 | @@ -XXX,XX +XXX,XX @@ static inline void tcg_out_tlb_load(TCGContext *s, TCGReg addrlo, TCGReg addrhi, | ||
41 | tcg_out_modrm_offset(s, OPC_CMP_GvEv + trexw, r1, r0, 0); | ||
42 | |||
43 | /* Prepare for both the fast path add of the tlb addend, and the slow | ||
44 | - path function argument setup. There are two cases worth note: | ||
45 | - For 32-bit guest and x86_64 host, MOVL zero-extends the guest address | ||
46 | - before the fastpath ADDQ below. For 64-bit guest and x32 host, MOVQ | ||
47 | - copies the entire guest address for the slow path, while truncation | ||
48 | - for the 32-bit host happens with the fastpath ADDL below. */ | ||
49 | + path function argument setup. */ | ||
50 | tcg_out_mov(s, ttype, r1, addrlo); | ||
51 | |||
52 | /* jne slow_path */ | ||
53 | @@ -XXX,XX +XXX,XX @@ static void tcg_out_qemu_ld(TCGContext *s, const TCGArg *args, bool is64) | ||
54 | #else | ||
55 | { | ||
56 | int32_t offset = guest_base; | ||
57 | - TCGReg base = addrlo; | ||
58 | int index = -1; | ||
59 | int seg = 0; | ||
60 | |||
61 | - /* For a 32-bit guest, the high 32 bits may contain garbage. | ||
62 | - We can do this with the ADDR32 prefix if we're not using | ||
63 | - a guest base, or when using segmentation. Otherwise we | ||
64 | - need to zero-extend manually. */ | ||
65 | + /* | ||
66 | + * Recall we store 32-bit values zero-extended. No need for | ||
67 | + * further manual extension or an addr32 (0x67) prefix. | ||
68 | + */ | ||
69 | if (guest_base == 0 || guest_base_flags) { | ||
70 | seg = guest_base_flags; | ||
71 | offset = 0; | ||
72 | - if (TCG_TARGET_REG_BITS > TARGET_LONG_BITS) { | ||
73 | - seg |= P_ADDR32; | ||
74 | - } | ||
75 | - } else if (TCG_TARGET_REG_BITS == 64) { | ||
76 | - if (TARGET_LONG_BITS == 32) { | ||
77 | - tcg_out_ext32u(s, TCG_REG_L0, base); | ||
78 | - base = TCG_REG_L0; | ||
79 | - } | ||
80 | - if (offset != guest_base) { | ||
81 | - tcg_out_movi(s, TCG_TYPE_I64, TCG_REG_L1, guest_base); | ||
82 | - index = TCG_REG_L1; | ||
83 | - offset = 0; | ||
84 | - } | ||
85 | + } else if (TCG_TARGET_REG_BITS == 64 && offset != guest_base) { | ||
86 | + tcg_out_movi(s, TCG_TYPE_I64, TCG_REG_L1, guest_base); | ||
87 | + index = TCG_REG_L1; | ||
88 | + offset = 0; | ||
89 | } | ||
90 | |||
91 | tcg_out_qemu_ld_direct(s, datalo, datahi, | ||
92 | - base, index, offset, seg, is64, opc); | ||
93 | + addrlo, index, offset, seg, is64, opc); | ||
94 | } | ||
95 | #endif | ||
96 | } | ||
97 | |||
98 | static void tcg_out_qemu_st_direct(TCGContext *s, TCGReg datalo, TCGReg datahi, | ||
99 | - TCGReg base, intptr_t ofs, int seg, | ||
100 | - TCGMemOp memop) | ||
101 | + TCGReg base, int index, intptr_t ofs, | ||
102 | + int seg, TCGMemOp memop) | ||
103 | { | ||
104 | /* ??? Ideally we wouldn't need a scratch register. For user-only, | ||
105 | we could perform the bswap twice to restore the original value | ||
106 | @@ -XXX,XX +XXX,XX @@ static void tcg_out_qemu_st_direct(TCGContext *s, TCGReg datalo, TCGReg datahi, | ||
107 | tcg_out_mov(s, TCG_TYPE_I32, scratch, datalo); | ||
108 | datalo = scratch; | ||
109 | } | ||
110 | - tcg_out_modrm_offset(s, OPC_MOVB_EvGv + P_REXB_R + seg, | ||
111 | - datalo, base, ofs); | ||
112 | + tcg_out_modrm_sib_offset(s, OPC_MOVB_EvGv + P_REXB_R + seg, | ||
113 | + datalo, base, index, 0, ofs); | ||
114 | break; | ||
115 | case MO_16: | ||
116 | if (bswap) { | ||
117 | @@ -XXX,XX +XXX,XX @@ static void tcg_out_qemu_st_direct(TCGContext *s, TCGReg datalo, TCGReg datahi, | ||
118 | tcg_out_rolw_8(s, scratch); | ||
119 | datalo = scratch; | ||
120 | } | ||
121 | - tcg_out_modrm_offset(s, movop + P_DATA16 + seg, datalo, base, ofs); | ||
122 | + tcg_out_modrm_sib_offset(s, movop + P_DATA16 + seg, datalo, | ||
123 | + base, index, 0, ofs); | ||
124 | break; | ||
125 | case MO_32: | ||
126 | if (bswap) { | ||
127 | @@ -XXX,XX +XXX,XX @@ static void tcg_out_qemu_st_direct(TCGContext *s, TCGReg datalo, TCGReg datahi, | ||
128 | tcg_out_bswap32(s, scratch); | ||
129 | datalo = scratch; | ||
130 | } | ||
131 | - tcg_out_modrm_offset(s, movop + seg, datalo, base, ofs); | ||
132 | + tcg_out_modrm_sib_offset(s, movop + seg, datalo, base, index, 0, ofs); | ||
133 | break; | ||
134 | case MO_64: | ||
135 | if (TCG_TARGET_REG_BITS == 64) { | ||
136 | @@ -XXX,XX +XXX,XX @@ static void tcg_out_qemu_st_direct(TCGContext *s, TCGReg datalo, TCGReg datahi, | ||
137 | tcg_out_bswap64(s, scratch); | ||
138 | datalo = scratch; | ||
139 | } | ||
140 | - tcg_out_modrm_offset(s, movop + P_REXW + seg, datalo, base, ofs); | ||
141 | + tcg_out_modrm_sib_offset(s, movop + P_REXW + seg, datalo, | ||
142 | + base, index, 0, ofs); | ||
143 | } else if (bswap) { | ||
144 | tcg_out_mov(s, TCG_TYPE_I32, scratch, datahi); | ||
145 | tcg_out_bswap32(s, scratch); | ||
146 | - tcg_out_modrm_offset(s, OPC_MOVL_EvGv + seg, scratch, base, ofs); | ||
147 | + tcg_out_modrm_sib_offset(s, OPC_MOVL_EvGv + seg, scratch, | ||
148 | + base, index, 0, ofs); | ||
149 | tcg_out_mov(s, TCG_TYPE_I32, scratch, datalo); | ||
150 | tcg_out_bswap32(s, scratch); | ||
151 | - tcg_out_modrm_offset(s, OPC_MOVL_EvGv + seg, scratch, base, ofs+4); | ||
152 | + tcg_out_modrm_sib_offset(s, OPC_MOVL_EvGv + seg, scratch, | ||
153 | + base, index, 0, ofs + 4); | ||
154 | } else { | ||
155 | if (real_bswap) { | ||
156 | int t = datalo; | ||
157 | datalo = datahi; | ||
158 | datahi = t; | ||
159 | } | ||
160 | - tcg_out_modrm_offset(s, movop + seg, datalo, base, ofs); | ||
161 | - tcg_out_modrm_offset(s, movop + seg, datahi, base, ofs+4); | ||
162 | + tcg_out_modrm_sib_offset(s, movop + seg, datalo, | ||
163 | + base, index, 0, ofs); | ||
164 | + tcg_out_modrm_sib_offset(s, movop + seg, datahi, | ||
165 | + base, index, 0, ofs + 4); | ||
166 | } | ||
167 | break; | ||
168 | default: | ||
169 | @@ -XXX,XX +XXX,XX @@ static void tcg_out_qemu_st(TCGContext *s, const TCGArg *args, bool is64) | ||
170 | label_ptr, offsetof(CPUTLBEntry, addr_write)); | ||
171 | |||
172 | /* TLB Hit. */ | ||
173 | - tcg_out_qemu_st_direct(s, datalo, datahi, TCG_REG_L1, 0, 0, opc); | ||
174 | + tcg_out_qemu_st_direct(s, datalo, datahi, TCG_REG_L1, -1, 0, 0, opc); | ||
175 | |||
176 | /* Record the current context of a store into ldst label */ | ||
177 | add_qemu_ldst_label(s, false, is64, oi, datalo, datahi, addrlo, addrhi, | ||
178 | @@ -XXX,XX +XXX,XX @@ static void tcg_out_qemu_st(TCGContext *s, const TCGArg *args, bool is64) | ||
179 | #else | ||
180 | { | ||
181 | int32_t offset = guest_base; | ||
182 | - TCGReg base = addrlo; | ||
183 | + int index = -1; | ||
184 | int seg = 0; | ||
185 | |||
186 | - /* See comment in tcg_out_qemu_ld re zero-extension of addrlo. */ | ||
187 | + /* | ||
188 | + * Recall we store 32-bit values zero-extended. No need for | ||
189 | + * further manual extension or an addr32 (0x67) prefix. | ||
190 | + */ | ||
191 | if (guest_base == 0 || guest_base_flags) { | ||
192 | seg = guest_base_flags; | ||
193 | offset = 0; | ||
194 | - if (TCG_TARGET_REG_BITS > TARGET_LONG_BITS) { | ||
195 | - seg |= P_ADDR32; | ||
196 | - } | ||
197 | - } else if (TCG_TARGET_REG_BITS == 64) { | ||
198 | - /* ??? Note that we can't use the same SIB addressing scheme | ||
199 | - as for loads, since we require L0 free for bswap. */ | ||
200 | - if (offset != guest_base) { | ||
201 | - if (TARGET_LONG_BITS == 32) { | ||
202 | - tcg_out_ext32u(s, TCG_REG_L0, base); | ||
203 | - base = TCG_REG_L0; | ||
204 | - } | ||
205 | - tcg_out_movi(s, TCG_TYPE_I64, TCG_REG_L1, guest_base); | ||
206 | - tgen_arithr(s, ARITH_ADD + P_REXW, TCG_REG_L1, base); | ||
207 | - base = TCG_REG_L1; | ||
208 | - offset = 0; | ||
209 | - } else if (TARGET_LONG_BITS == 32) { | ||
210 | - tcg_out_ext32u(s, TCG_REG_L1, base); | ||
211 | - base = TCG_REG_L1; | ||
212 | - } | ||
213 | + } else if (TCG_TARGET_REG_BITS == 64 && offset != guest_base) { | ||
214 | + /* ??? Note that we require L0 free for bswap. */ | ||
215 | + tcg_out_movi(s, TCG_TYPE_I64, TCG_REG_L1, guest_base); | ||
216 | + index = TCG_REG_L1; | ||
217 | + offset = 0; | ||
218 | } | ||
219 | |||
220 | - tcg_out_qemu_st_direct(s, datalo, datahi, base, offset, seg, opc); | ||
221 | + tcg_out_qemu_st_direct(s, datalo, datahi, | ||
222 | + addrlo, index, offset, seg, opc); | ||
223 | } | ||
224 | #endif | ||
225 | } | ||
226 | -- | ||
227 | 2.17.2 | ||
228 | |||
229 | diff view generated by jsdifflib |
Deleted patch | |||
---|---|---|---|
1 | These values are constant between all qemu_ld/st invocations; | ||
2 | there is no need to figure this out each time. If we cannot | ||
3 | use a segment or an offset directly for guest_base, load the | ||
4 | value into a register in the prologue. | ||
5 | 1 | ||
6 | Reviewed-by: Emilio G. Cota <cota@braap.org> | ||
7 | Signed-off-by: Richard Henderson <richard.henderson@linaro.org> | ||
8 | --- | ||
9 | tcg/i386/tcg-target.inc.c | 101 +++++++++++++++----------------------- | ||
10 | 1 file changed, 40 insertions(+), 61 deletions(-) | ||
11 | |||
12 | diff --git a/tcg/i386/tcg-target.inc.c b/tcg/i386/tcg-target.inc.c | ||
13 | index XXXXXXX..XXXXXXX 100644 | ||
14 | --- a/tcg/i386/tcg-target.inc.c | ||
15 | +++ b/tcg/i386/tcg-target.inc.c | ||
16 | @@ -XXX,XX +XXX,XX @@ static void tcg_out_qemu_st_slow_path(TCGContext *s, TCGLabelQemuLdst *l) | ||
17 | tcg_out_push(s, retaddr); | ||
18 | tcg_out_jmp(s, qemu_st_helpers[opc & (MO_BSWAP | MO_SIZE)]); | ||
19 | } | ||
20 | -#elif defined(__x86_64__) && defined(__linux__) | ||
21 | -# include <asm/prctl.h> | ||
22 | -# include <sys/prctl.h> | ||
23 | - | ||
24 | +#elif TCG_TARGET_REG_BITS == 32 | ||
25 | +# define x86_guest_base_seg 0 | ||
26 | +# define x86_guest_base_index -1 | ||
27 | +# define x86_guest_base_offset guest_base | ||
28 | +#else | ||
29 | +static int x86_guest_base_seg; | ||
30 | +static int x86_guest_base_index = -1; | ||
31 | +static int32_t x86_guest_base_offset; | ||
32 | +# if defined(__x86_64__) && defined(__linux__) | ||
33 | +# include <asm/prctl.h> | ||
34 | +# include <sys/prctl.h> | ||
35 | int arch_prctl(int code, unsigned long addr); | ||
36 | - | ||
37 | -static int guest_base_flags; | ||
38 | -static inline void setup_guest_base_seg(void) | ||
39 | +static inline int setup_guest_base_seg(void) | ||
40 | { | ||
41 | if (arch_prctl(ARCH_SET_GS, guest_base) == 0) { | ||
42 | - guest_base_flags = P_GS; | ||
43 | + return P_GS; | ||
44 | } | ||
45 | + return 0; | ||
46 | } | ||
47 | -#else | ||
48 | -# define guest_base_flags 0 | ||
49 | -static inline void setup_guest_base_seg(void) { } | ||
50 | +# else | ||
51 | +static inline int setup_guest_base_seg(void) | ||
52 | +{ | ||
53 | + return 0; | ||
54 | +} | ||
55 | +# endif | ||
56 | #endif /* SOFTMMU */ | ||
57 | |||
58 | static void tcg_out_qemu_ld_direct(TCGContext *s, TCGReg datalo, TCGReg datahi, | ||
59 | @@ -XXX,XX +XXX,XX @@ static void tcg_out_qemu_ld(TCGContext *s, const TCGArg *args, bool is64) | ||
60 | add_qemu_ldst_label(s, true, is64, oi, datalo, datahi, addrlo, addrhi, | ||
61 | s->code_ptr, label_ptr); | ||
62 | #else | ||
63 | - { | ||
64 | - int32_t offset = guest_base; | ||
65 | - int index = -1; | ||
66 | - int seg = 0; | ||
67 | - | ||
68 | - /* | ||
69 | - * Recall we store 32-bit values zero-extended. No need for | ||
70 | - * further manual extension or an addr32 (0x67) prefix. | ||
71 | - */ | ||
72 | - if (guest_base == 0 || guest_base_flags) { | ||
73 | - seg = guest_base_flags; | ||
74 | - offset = 0; | ||
75 | - } else if (TCG_TARGET_REG_BITS == 64 && offset != guest_base) { | ||
76 | - tcg_out_movi(s, TCG_TYPE_I64, TCG_REG_L1, guest_base); | ||
77 | - index = TCG_REG_L1; | ||
78 | - offset = 0; | ||
79 | - } | ||
80 | - | ||
81 | - tcg_out_qemu_ld_direct(s, datalo, datahi, | ||
82 | - addrlo, index, offset, seg, is64, opc); | ||
83 | - } | ||
84 | + tcg_out_qemu_ld_direct(s, datalo, datahi, addrlo, x86_guest_base_index, | ||
85 | + x86_guest_base_offset, x86_guest_base_seg, | ||
86 | + is64, opc); | ||
87 | #endif | ||
88 | } | ||
89 | |||
90 | @@ -XXX,XX +XXX,XX @@ static void tcg_out_qemu_st(TCGContext *s, const TCGArg *args, bool is64) | ||
91 | add_qemu_ldst_label(s, false, is64, oi, datalo, datahi, addrlo, addrhi, | ||
92 | s->code_ptr, label_ptr); | ||
93 | #else | ||
94 | - { | ||
95 | - int32_t offset = guest_base; | ||
96 | - int index = -1; | ||
97 | - int seg = 0; | ||
98 | - | ||
99 | - /* | ||
100 | - * Recall we store 32-bit values zero-extended. No need for | ||
101 | - * further manual extension or an addr32 (0x67) prefix. | ||
102 | - */ | ||
103 | - if (guest_base == 0 || guest_base_flags) { | ||
104 | - seg = guest_base_flags; | ||
105 | - offset = 0; | ||
106 | - } else if (TCG_TARGET_REG_BITS == 64 && offset != guest_base) { | ||
107 | - /* ??? Note that we require L0 free for bswap. */ | ||
108 | - tcg_out_movi(s, TCG_TYPE_I64, TCG_REG_L1, guest_base); | ||
109 | - index = TCG_REG_L1; | ||
110 | - offset = 0; | ||
111 | - } | ||
112 | - | ||
113 | - tcg_out_qemu_st_direct(s, datalo, datahi, | ||
114 | - addrlo, index, offset, seg, opc); | ||
115 | - } | ||
116 | + tcg_out_qemu_st_direct(s, datalo, datahi, addrlo, x86_guest_base_index, | ||
117 | + x86_guest_base_offset, x86_guest_base_seg, opc); | ||
118 | #endif | ||
119 | } | ||
120 | |||
121 | @@ -XXX,XX +XXX,XX @@ static void tcg_target_qemu_prologue(TCGContext *s) | ||
122 | (ARRAY_SIZE(tcg_target_callee_save_regs) + 2) * 4 | ||
123 | + stack_addend); | ||
124 | #else | ||
125 | +# if !defined(CONFIG_SOFTMMU) && TCG_TARGET_REG_BITS == 64 | ||
126 | + if (guest_base) { | ||
127 | + int seg = setup_guest_base_seg(); | ||
128 | + if (seg != 0) { | ||
129 | + x86_guest_base_seg = seg; | ||
130 | + } else if (guest_base == (int32_t)guest_base) { | ||
131 | + x86_guest_base_offset = guest_base; | ||
132 | + } else { | ||
133 | + /* Choose R12 because, as a base, it requires a SIB byte. */ | ||
134 | + x86_guest_base_index = TCG_REG_R12; | ||
135 | + tcg_out_mov(s, TCG_TYPE_PTR, x86_guest_base_index, guest_base); | ||
136 | + tcg_regset_set_reg(s->reserved_regs, x86_guest_base_index); | ||
137 | + } | ||
138 | + } | ||
139 | +# endif | ||
140 | tcg_out_mov(s, TCG_TYPE_PTR, TCG_AREG0, tcg_target_call_iarg_regs[0]); | ||
141 | tcg_out_addi(s, TCG_REG_ESP, -stack_addend); | ||
142 | /* jmp *tb. */ | ||
143 | @@ -XXX,XX +XXX,XX @@ static void tcg_target_qemu_prologue(TCGContext *s) | ||
144 | tcg_out_pop(s, tcg_target_callee_save_regs[i]); | ||
145 | } | ||
146 | tcg_out_opc(s, OPC_RET, 0, 0, 0); | ||
147 | - | ||
148 | -#if !defined(CONFIG_SOFTMMU) | ||
149 | - /* Try to set up a segment register to point to guest_base. */ | ||
150 | - if (guest_base) { | ||
151 | - setup_guest_base_seg(); | ||
152 | - } | ||
153 | -#endif | ||
154 | } | ||
155 | |||
156 | static void tcg_out_nop_fill(tcg_insn_unit *p, int count) | ||
157 | -- | ||
158 | 2.17.2 | ||
159 | |||
160 | diff view generated by jsdifflib |
Deleted patch | |||
---|---|---|---|
1 | Reviewed-by: Emilio G. Cota <cota@braap.org> | ||
2 | Signed-off-by: Richard Henderson <richard.henderson@linaro.org> | ||
3 | --- | ||
4 | tcg/i386/tcg-target.inc.c | 9 +++++++++ | ||
5 | 1 file changed, 9 insertions(+) | ||
6 | 1 | ||
7 | diff --git a/tcg/i386/tcg-target.inc.c b/tcg/i386/tcg-target.inc.c | ||
8 | index XXXXXXX..XXXXXXX 100644 | ||
9 | --- a/tcg/i386/tcg-target.inc.c | ||
10 | +++ b/tcg/i386/tcg-target.inc.c | ||
11 | @@ -XXX,XX +XXX,XX @@ static inline int setup_guest_base_seg(void) | ||
12 | } | ||
13 | return 0; | ||
14 | } | ||
15 | +# elif defined (__FreeBSD__) || defined (__FreeBSD_kernel__) | ||
16 | +# include <machine/sysarch.h> | ||
17 | +static inline int setup_guest_base_seg(void) | ||
18 | +{ | ||
19 | + if (sysarch(AMD64_SET_GSBASE, &guest_base) == 0) { | ||
20 | + return P_GS; | ||
21 | + } | ||
22 | + return 0; | ||
23 | +} | ||
24 | # else | ||
25 | static inline int setup_guest_base_seg(void) | ||
26 | { | ||
27 | -- | ||
28 | 2.17.2 | ||
29 | |||
30 | diff view generated by jsdifflib |
Deleted patch | |||
---|---|---|---|
1 | Based on the only current user, Sparc: | ||
2 | 1 | ||
3 | New code uses 1 constant that takes 2 insns to create, plus 8. | ||
4 | Old code used 2 constants that took 2 insns to create, plus 9. | ||
5 | The result is a new total of 10 vs an old total of 13. | ||
6 | |||
7 | Signed-off-by: Richard Henderson <richard.henderson@linaro.org> | ||
8 | --- | ||
9 | tcg/tcg-op.c | 54 ++++++++++++++++++++++++++-------------------------- | ||
10 | 1 file changed, 27 insertions(+), 27 deletions(-) | ||
11 | |||
12 | diff --git a/tcg/tcg-op.c b/tcg/tcg-op.c | ||
13 | index XXXXXXX..XXXXXXX 100644 | ||
14 | --- a/tcg/tcg-op.c | ||
15 | +++ b/tcg/tcg-op.c | ||
16 | @@ -XXX,XX +XXX,XX @@ void tcg_gen_bswap32_i32(TCGv_i32 ret, TCGv_i32 arg) | ||
17 | if (TCG_TARGET_HAS_bswap32_i32) { | ||
18 | tcg_gen_op2_i32(INDEX_op_bswap32_i32, ret, arg); | ||
19 | } else { | ||
20 | - TCGv_i32 t0, t1; | ||
21 | - t0 = tcg_temp_new_i32(); | ||
22 | - t1 = tcg_temp_new_i32(); | ||
23 | + TCGv_i32 t0 = tcg_temp_new_i32(); | ||
24 | + TCGv_i32 t1 = tcg_temp_new_i32(); | ||
25 | + TCGv_i32 t2 = tcg_const_i32(0x00ff00ff); | ||
26 | |||
27 | - tcg_gen_shli_i32(t0, arg, 24); | ||
28 | + /* arg = abcd */ | ||
29 | + tcg_gen_shri_i32(t0, arg, 8); /* t0 = .abc */ | ||
30 | + tcg_gen_and_i32(t1, arg, t2); /* t1 = .b.d */ | ||
31 | + tcg_gen_and_i32(t0, t0, t2); /* t0 = .a.c */ | ||
32 | + tcg_temp_free_i32(t2); | ||
33 | + tcg_gen_shli_i32(t1, t1, 8); /* t1 = b.d. */ | ||
34 | + tcg_gen_or_i32(ret, t0, t1); /* ret = badc */ | ||
35 | |||
36 | - tcg_gen_andi_i32(t1, arg, 0x0000ff00); | ||
37 | - tcg_gen_shli_i32(t1, t1, 8); | ||
38 | - tcg_gen_or_i32(t0, t0, t1); | ||
39 | + tcg_gen_shri_i32(t0, ret, 16); /* t0 = ..ba */ | ||
40 | + tcg_gen_shli_i32(t1, ret, 16); /* t1 = dc.. */ | ||
41 | + tcg_gen_or_i32(ret, t0, t1); /* ret = dcba */ | ||
42 | |||
43 | - tcg_gen_shri_i32(t1, arg, 8); | ||
44 | - tcg_gen_andi_i32(t1, t1, 0x0000ff00); | ||
45 | - tcg_gen_or_i32(t0, t0, t1); | ||
46 | - | ||
47 | - tcg_gen_shri_i32(t1, arg, 24); | ||
48 | - tcg_gen_or_i32(ret, t0, t1); | ||
49 | tcg_temp_free_i32(t0); | ||
50 | tcg_temp_free_i32(t1); | ||
51 | } | ||
52 | @@ -XXX,XX +XXX,XX @@ void tcg_gen_bswap32_i64(TCGv_i64 ret, TCGv_i64 arg) | ||
53 | } else if (TCG_TARGET_HAS_bswap32_i64) { | ||
54 | tcg_gen_op2_i64(INDEX_op_bswap32_i64, ret, arg); | ||
55 | } else { | ||
56 | - TCGv_i64 t0, t1; | ||
57 | - t0 = tcg_temp_new_i64(); | ||
58 | - t1 = tcg_temp_new_i64(); | ||
59 | + TCGv_i64 t0 = tcg_temp_new_i64(); | ||
60 | + TCGv_i64 t1 = tcg_temp_new_i64(); | ||
61 | + TCGv_i64 t2 = tcg_const_i64(0x00ff00ff); | ||
62 | |||
63 | - tcg_gen_shli_i64(t0, arg, 24); | ||
64 | - tcg_gen_ext32u_i64(t0, t0); | ||
65 | + /* arg = ....abcd */ | ||
66 | + tcg_gen_shri_i64(t0, arg, 8); /* t0 = .....abc */ | ||
67 | + tcg_gen_and_i64(t1, arg, t2); /* t1 = .....b.d */ | ||
68 | + tcg_gen_and_i64(t0, t0, t2); /* t0 = .....a.c */ | ||
69 | + tcg_temp_free_i64(t2); | ||
70 | + tcg_gen_shli_i64(t1, t1, 8); /* t1 = ....b.d. */ | ||
71 | + tcg_gen_or_i64(ret, t0, t1); /* ret = ....badc */ | ||
72 | |||
73 | - tcg_gen_andi_i64(t1, arg, 0x0000ff00); | ||
74 | - tcg_gen_shli_i64(t1, t1, 8); | ||
75 | - tcg_gen_or_i64(t0, t0, t1); | ||
76 | + tcg_gen_shli_i64(t1, ret, 48); /* t1 = dc...... */ | ||
77 | + tcg_gen_shri_i64(t0, ret, 16); /* t0 = ......ba */ | ||
78 | + tcg_gen_shri_i64(t1, ret, 32); /* t1 = ....dc.. */ | ||
79 | + tcg_gen_or_i64(ret, t0, t1); /* ret = ....dcba */ | ||
80 | |||
81 | - tcg_gen_shri_i64(t1, arg, 8); | ||
82 | - tcg_gen_andi_i64(t1, t1, 0x0000ff00); | ||
83 | - tcg_gen_or_i64(t0, t0, t1); | ||
84 | - | ||
85 | - tcg_gen_shri_i64(t1, arg, 24); | ||
86 | - tcg_gen_or_i64(ret, t0, t1); | ||
87 | tcg_temp_free_i64(t0); | ||
88 | tcg_temp_free_i64(t1); | ||
89 | } | ||
90 | -- | ||
91 | 2.17.2 | ||
92 | |||
93 | diff view generated by jsdifflib |
Deleted patch | |||
---|---|---|---|
1 | Based on the only current user, Sparc: | ||
2 | 1 | ||
3 | New code uses 2 constants that take 2 insns to load from constant pool, | ||
4 | plus 13. Old code used 6 constants that took 1 or 2 insns to create, | ||
5 | plus 21. The result is a new total of 17 vs an old total of 29. | ||
6 | |||
7 | Signed-off-by: Richard Henderson <richard.henderson@linaro.org> | ||
8 | --- | ||
9 | tcg/tcg-op.c | 43 ++++++++++++++++++------------------------- | ||
10 | 1 file changed, 18 insertions(+), 25 deletions(-) | ||
11 | |||
12 | diff --git a/tcg/tcg-op.c b/tcg/tcg-op.c | ||
13 | index XXXXXXX..XXXXXXX 100644 | ||
14 | --- a/tcg/tcg-op.c | ||
15 | +++ b/tcg/tcg-op.c | ||
16 | @@ -XXX,XX +XXX,XX @@ void tcg_gen_bswap64_i64(TCGv_i64 ret, TCGv_i64 arg) | ||
17 | } else { | ||
18 | TCGv_i64 t0 = tcg_temp_new_i64(); | ||
19 | TCGv_i64 t1 = tcg_temp_new_i64(); | ||
20 | + TCGv_i64 t2 = tcg_temp_new_i64(); | ||
21 | |||
22 | - tcg_gen_shli_i64(t0, arg, 56); | ||
23 | + /* arg = abcdefgh */ | ||
24 | + tcg_gen_movi_i64(t2, 0x00ff00ff00ff00ffull); | ||
25 | + tcg_gen_shri_i64(t0, arg, 8); /* t0 = .abcdefg */ | ||
26 | + tcg_gen_and_i64(t1, arg, t2); /* t1 = .b.d.f.h */ | ||
27 | + tcg_gen_and_i64(t0, t0, t2); /* t0 = .a.c.e.g */ | ||
28 | + tcg_gen_shli_i64(t1, t1, 8); /* t1 = b.d.f.h. */ | ||
29 | + tcg_gen_or_i64(ret, t0, t1); /* ret = badcfehg */ | ||
30 | |||
31 | - tcg_gen_andi_i64(t1, arg, 0x0000ff00); | ||
32 | - tcg_gen_shli_i64(t1, t1, 40); | ||
33 | - tcg_gen_or_i64(t0, t0, t1); | ||
34 | + tcg_gen_movi_i64(t2, 0x0000ffff0000ffffull); | ||
35 | + tcg_gen_shri_i64(t0, ret, 16); /* t0 = ..badcfe */ | ||
36 | + tcg_gen_and_i64(t1, ret, t2); /* t1 = ..dc..hg */ | ||
37 | + tcg_gen_and_i64(t0, t0, t2); /* t0 = ..ba..fe */ | ||
38 | + tcg_gen_shli_i64(t1, t1, 16); /* t1 = dc..hg.. */ | ||
39 | + tcg_gen_or_i64(ret, t0, t1); /* ret = dcbahgfe */ | ||
40 | |||
41 | - tcg_gen_andi_i64(t1, arg, 0x00ff0000); | ||
42 | - tcg_gen_shli_i64(t1, t1, 24); | ||
43 | - tcg_gen_or_i64(t0, t0, t1); | ||
44 | + tcg_gen_shri_i64(t0, ret, 32); /* t0 = ....dcba */ | ||
45 | + tcg_gen_shli_i64(t1, ret, 32); /* t1 = hgfe.... */ | ||
46 | + tcg_gen_or_i64(ret, t0, t1); /* ret = hgfedcba */ | ||
47 | |||
48 | - tcg_gen_andi_i64(t1, arg, 0xff000000); | ||
49 | - tcg_gen_shli_i64(t1, t1, 8); | ||
50 | - tcg_gen_or_i64(t0, t0, t1); | ||
51 | - | ||
52 | - tcg_gen_shri_i64(t1, arg, 8); | ||
53 | - tcg_gen_andi_i64(t1, t1, 0xff000000); | ||
54 | - tcg_gen_or_i64(t0, t0, t1); | ||
55 | - | ||
56 | - tcg_gen_shri_i64(t1, arg, 24); | ||
57 | - tcg_gen_andi_i64(t1, t1, 0x00ff0000); | ||
58 | - tcg_gen_or_i64(t0, t0, t1); | ||
59 | - | ||
60 | - tcg_gen_shri_i64(t1, arg, 40); | ||
61 | - tcg_gen_andi_i64(t1, t1, 0x0000ff00); | ||
62 | - tcg_gen_or_i64(t0, t0, t1); | ||
63 | - | ||
64 | - tcg_gen_shri_i64(t1, arg, 56); | ||
65 | - tcg_gen_or_i64(ret, t0, t1); | ||
66 | tcg_temp_free_i64(t0); | ||
67 | tcg_temp_free_i64(t1); | ||
68 | + tcg_temp_free_i64(t2); | ||
69 | } | ||
70 | } | ||
71 | |||
72 | -- | ||
73 | 2.17.2 | ||
74 | |||
75 | diff view generated by jsdifflib |
Deleted patch | |||
---|---|---|---|
1 | Somehow we forgot these operations, once upon a time. | ||
2 | This will allow immediate stores to have their bswap | ||
3 | optimized away. | ||
4 | 1 | ||
5 | Signed-off-by: Richard Henderson <richard.henderson@linaro.org> | ||
6 | --- | ||
7 | tcg/optimize.c | 12 ++++++++++++ | ||
8 | 1 file changed, 12 insertions(+) | ||
9 | |||
10 | diff --git a/tcg/optimize.c b/tcg/optimize.c | ||
11 | index XXXXXXX..XXXXXXX 100644 | ||
12 | --- a/tcg/optimize.c | ||
13 | +++ b/tcg/optimize.c | ||
14 | @@ -XXX,XX +XXX,XX @@ static TCGArg do_constant_folding_2(TCGOpcode op, TCGArg x, TCGArg y) | ||
15 | CASE_OP_32_64(ext16u): | ||
16 | return (uint16_t)x; | ||
17 | |||
18 | + CASE_OP_32_64(bswap16): | ||
19 | + return bswap16(x); | ||
20 | + | ||
21 | + CASE_OP_32_64(bswap32): | ||
22 | + return bswap32(x); | ||
23 | + | ||
24 | + case INDEX_op_bswap64_i64: | ||
25 | + return bswap64(x); | ||
26 | + | ||
27 | case INDEX_op_ext_i32_i64: | ||
28 | case INDEX_op_ext32s_i64: | ||
29 | return (int32_t)x; | ||
30 | @@ -XXX,XX +XXX,XX @@ void tcg_optimize(TCGContext *s) | ||
31 | CASE_OP_32_64(ext16s): | ||
32 | CASE_OP_32_64(ext16u): | ||
33 | CASE_OP_32_64(ctpop): | ||
34 | + CASE_OP_32_64(bswap16): | ||
35 | + CASE_OP_32_64(bswap32): | ||
36 | + case INDEX_op_bswap64_i64: | ||
37 | case INDEX_op_ext32s_i64: | ||
38 | case INDEX_op_ext32u_i64: | ||
39 | case INDEX_op_ext_i32_i64: | ||
40 | -- | ||
41 | 2.17.2 | ||
42 | |||
43 | diff view generated by jsdifflib |
Deleted patch | |||
---|---|---|---|
1 | From: Alistair Francis <Alistair.Francis@wdc.com> | ||
2 | 1 | ||
3 | Instead of hard coding 31 for the shift right use TCG_TARGET_REG_BITS - 1. | ||
4 | |||
5 | Signed-off-by: Alistair Francis <alistair.francis@wdc.com> | ||
6 | Message-Id: <7dfbddf7014a595150aa79011ddb342c3cc17ec3.1544648105.git.alistair.francis@wdc.com> | ||
7 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> | ||
8 | Signed-off-by: Richard Henderson <richard.henderson@linaro.org> | ||
9 | --- | ||
10 | tcg/mips/tcg-target.inc.c | 2 +- | ||
11 | 1 file changed, 1 insertion(+), 1 deletion(-) | ||
12 | |||
13 | diff --git a/tcg/mips/tcg-target.inc.c b/tcg/mips/tcg-target.inc.c | ||
14 | index XXXXXXX..XXXXXXX 100644 | ||
15 | --- a/tcg/mips/tcg-target.inc.c | ||
16 | +++ b/tcg/mips/tcg-target.inc.c | ||
17 | @@ -XXX,XX +XXX,XX @@ static void tcg_out_addsub2(TCGContext *s, TCGReg rl, TCGReg rh, TCGReg al, | ||
18 | tcg_out_opc_imm(s, OPC_ADDIU, rl, al, bl); | ||
19 | tcg_out_opc_imm(s, OPC_SLTIU, TCG_TMP0, rl, bl); | ||
20 | } else if (rl == al && rl == bl) { | ||
21 | - tcg_out_opc_sa(s, OPC_SRL, TCG_TMP0, al, 31); | ||
22 | + tcg_out_opc_sa(s, OPC_SRL, TCG_TMP0, al, TCG_TARGET_REG_BITS - 1); | ||
23 | tcg_out_opc_reg(s, OPC_ADDU, rl, al, bl); | ||
24 | } else { | ||
25 | tcg_out_opc_reg(s, OPC_ADDU, rl, al, bl); | ||
26 | -- | ||
27 | 2.17.2 | ||
28 | |||
29 | diff view generated by jsdifflib |
Deleted patch | |||
---|---|---|---|
1 | From: "Emilio G. Cota" <cota@braap.org> | ||
2 | 1 | ||
3 | It's unused since 75e8b9b7aa0b95a761b9add7e2f09248b101a392. | ||
4 | |||
5 | Signed-off-by: Emilio G. Cota <cota@braap.org> | ||
6 | Message-Id: <20181209193749.12277-9-cota@braap.org> | ||
7 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> | ||
8 | Signed-off-by: Richard Henderson <richard.henderson@linaro.org> | ||
9 | --- | ||
10 | tcg/tcg.h | 4 ++-- | ||
11 | tcg/optimize.c | 4 ++-- | ||
12 | tcg/tcg.c | 10 ++++------ | ||
13 | 3 files changed, 8 insertions(+), 10 deletions(-) | ||
14 | |||
15 | diff --git a/tcg/tcg.h b/tcg/tcg.h | ||
16 | index XXXXXXX..XXXXXXX 100644 | ||
17 | --- a/tcg/tcg.h | ||
18 | +++ b/tcg/tcg.h | ||
19 | @@ -XXX,XX +XXX,XX @@ void tcg_gen_callN(void *func, TCGTemp *ret, int nargs, TCGTemp **args); | ||
20 | |||
21 | TCGOp *tcg_emit_op(TCGOpcode opc); | ||
22 | void tcg_op_remove(TCGContext *s, TCGOp *op); | ||
23 | -TCGOp *tcg_op_insert_before(TCGContext *s, TCGOp *op, TCGOpcode opc, int narg); | ||
24 | -TCGOp *tcg_op_insert_after(TCGContext *s, TCGOp *op, TCGOpcode opc, int narg); | ||
25 | +TCGOp *tcg_op_insert_before(TCGContext *s, TCGOp *op, TCGOpcode opc); | ||
26 | +TCGOp *tcg_op_insert_after(TCGContext *s, TCGOp *op, TCGOpcode opc); | ||
27 | |||
28 | void tcg_optimize(TCGContext *s); | ||
29 | |||
30 | diff --git a/tcg/optimize.c b/tcg/optimize.c | ||
31 | index XXXXXXX..XXXXXXX 100644 | ||
32 | --- a/tcg/optimize.c | ||
33 | +++ b/tcg/optimize.c | ||
34 | @@ -XXX,XX +XXX,XX @@ void tcg_optimize(TCGContext *s) | ||
35 | uint64_t a = ((uint64_t)ah << 32) | al; | ||
36 | uint64_t b = ((uint64_t)bh << 32) | bl; | ||
37 | TCGArg rl, rh; | ||
38 | - TCGOp *op2 = tcg_op_insert_before(s, op, INDEX_op_movi_i32, 2); | ||
39 | + TCGOp *op2 = tcg_op_insert_before(s, op, INDEX_op_movi_i32); | ||
40 | |||
41 | if (opc == INDEX_op_add2_i32) { | ||
42 | a += b; | ||
43 | @@ -XXX,XX +XXX,XX @@ void tcg_optimize(TCGContext *s) | ||
44 | uint32_t b = arg_info(op->args[3])->val; | ||
45 | uint64_t r = (uint64_t)a * b; | ||
46 | TCGArg rl, rh; | ||
47 | - TCGOp *op2 = tcg_op_insert_before(s, op, INDEX_op_movi_i32, 2); | ||
48 | + TCGOp *op2 = tcg_op_insert_before(s, op, INDEX_op_movi_i32); | ||
49 | |||
50 | rl = op->args[0]; | ||
51 | rh = op->args[1]; | ||
52 | diff --git a/tcg/tcg.c b/tcg/tcg.c | ||
53 | index XXXXXXX..XXXXXXX 100644 | ||
54 | --- a/tcg/tcg.c | ||
55 | +++ b/tcg/tcg.c | ||
56 | @@ -XXX,XX +XXX,XX @@ TCGOp *tcg_emit_op(TCGOpcode opc) | ||
57 | return op; | ||
58 | } | ||
59 | |||
60 | -TCGOp *tcg_op_insert_before(TCGContext *s, TCGOp *old_op, | ||
61 | - TCGOpcode opc, int nargs) | ||
62 | +TCGOp *tcg_op_insert_before(TCGContext *s, TCGOp *old_op, TCGOpcode opc) | ||
63 | { | ||
64 | TCGOp *new_op = tcg_op_alloc(opc); | ||
65 | QTAILQ_INSERT_BEFORE(old_op, new_op, link); | ||
66 | return new_op; | ||
67 | } | ||
68 | |||
69 | -TCGOp *tcg_op_insert_after(TCGContext *s, TCGOp *old_op, | ||
70 | - TCGOpcode opc, int nargs) | ||
71 | +TCGOp *tcg_op_insert_after(TCGContext *s, TCGOp *old_op, TCGOpcode opc) | ||
72 | { | ||
73 | TCGOp *new_op = tcg_op_alloc(opc); | ||
74 | QTAILQ_INSERT_AFTER(&s->ops, old_op, new_op, link); | ||
75 | @@ -XXX,XX +XXX,XX @@ static bool liveness_pass_2(TCGContext *s) | ||
76 | TCGOpcode lopc = (arg_ts->type == TCG_TYPE_I32 | ||
77 | ? INDEX_op_ld_i32 | ||
78 | : INDEX_op_ld_i64); | ||
79 | - TCGOp *lop = tcg_op_insert_before(s, op, lopc, 3); | ||
80 | + TCGOp *lop = tcg_op_insert_before(s, op, lopc); | ||
81 | |||
82 | lop->args[0] = temp_arg(dir_ts); | ||
83 | lop->args[1] = temp_arg(arg_ts->mem_base); | ||
84 | @@ -XXX,XX +XXX,XX @@ static bool liveness_pass_2(TCGContext *s) | ||
85 | TCGOpcode sopc = (arg_ts->type == TCG_TYPE_I32 | ||
86 | ? INDEX_op_st_i32 | ||
87 | : INDEX_op_st_i64); | ||
88 | - TCGOp *sop = tcg_op_insert_after(s, op, sopc, 3); | ||
89 | + TCGOp *sop = tcg_op_insert_after(s, op, sopc); | ||
90 | |||
91 | sop->args[0] = temp_arg(dir_ts); | ||
92 | sop->args[1] = temp_arg(arg_ts->mem_base); | ||
93 | -- | ||
94 | 2.17.2 | ||
95 | |||
96 | diff view generated by jsdifflib |
Deleted patch | |||
---|---|---|---|
1 | From: "Emilio G. Cota" <cota@braap.org> | ||
2 | 1 | ||
3 | Which we forgot to do in bd224fce60 ("qht-bench: add -p flag | ||
4 | to precompute hash values", 2018-09-26). | ||
5 | |||
6 | Reviewed-by: Alex Bennée <alex.bennee@linaro.org> | ||
7 | Signed-off-by: Emilio G. Cota <cota@braap.org> | ||
8 | Signed-off-by: Richard Henderson <richard.henderson@linaro.org> | ||
9 | --- | ||
10 | tests/qht-bench.c | 1 + | ||
11 | 1 file changed, 1 insertion(+) | ||
12 | |||
13 | diff --git a/tests/qht-bench.c b/tests/qht-bench.c | ||
14 | index XXXXXXX..XXXXXXX 100644 | ||
15 | --- a/tests/qht-bench.c | ||
16 | +++ b/tests/qht-bench.c | ||
17 | @@ -XXX,XX +XXX,XX @@ static const char commands_string[] = | ||
18 | " -n = number of threads\n" | ||
19 | "\n" | ||
20 | " -o = offset at which keys start\n" | ||
21 | + " -p = precompute hashes\n" | ||
22 | "\n" | ||
23 | " -g = set -s,-k,-K,-l,-r to the same value\n" | ||
24 | " -s = initial size hint\n" | ||
25 | -- | ||
26 | 2.17.2 | ||
27 | |||
28 | diff view generated by jsdifflib |
Deleted patch | |||
---|---|---|---|
1 | From: "Emilio G. Cota" <cota@braap.org> | ||
2 | 1 | ||
3 | Before moving them all to include/qemu/xxhash.h. | ||
4 | |||
5 | Reviewed-by: Alex Bennée <alex.bennee@linaro.org> | ||
6 | Signed-off-by: Emilio G. Cota <cota@braap.org> | ||
7 | Signed-off-by: Richard Henderson <richard.henderson@linaro.org> | ||
8 | --- | ||
9 | include/exec/tb-hash-xx.h | 41 +++++++++++++++++++++++++++++---------- | ||
10 | include/exec/tb-hash.h | 2 +- | ||
11 | tests/qht-bench.c | 2 +- | ||
12 | util/qsp.c | 12 ++++++------ | ||
13 | 4 files changed, 39 insertions(+), 18 deletions(-) | ||
14 | |||
15 | diff --git a/include/exec/tb-hash-xx.h b/include/exec/tb-hash-xx.h | ||
16 | index XXXXXXX..XXXXXXX 100644 | ||
17 | --- a/include/exec/tb-hash-xx.h | ||
18 | +++ b/include/exec/tb-hash-xx.h | ||
19 | @@ -XXX,XX +XXX,XX @@ | ||
20 | #define PRIME32_4 668265263U | ||
21 | #define PRIME32_5 374761393U | ||
22 | |||
23 | -#define TB_HASH_XX_SEED 1 | ||
24 | +#define QEMU_XXHASH_SEED 1 | ||
25 | |||
26 | /* | ||
27 | * xxhash32, customized for input variables that are not guaranteed to be | ||
28 | * contiguous in memory. | ||
29 | */ | ||
30 | static inline uint32_t | ||
31 | -tb_hash_func7(uint64_t a0, uint64_t b0, uint32_t e, uint32_t f, uint32_t g) | ||
32 | +qemu_xxhash7(uint64_t ab, uint64_t cd, uint32_t e, uint32_t f, uint32_t g) | ||
33 | { | ||
34 | - uint32_t v1 = TB_HASH_XX_SEED + PRIME32_1 + PRIME32_2; | ||
35 | - uint32_t v2 = TB_HASH_XX_SEED + PRIME32_2; | ||
36 | - uint32_t v3 = TB_HASH_XX_SEED + 0; | ||
37 | - uint32_t v4 = TB_HASH_XX_SEED - PRIME32_1; | ||
38 | - uint32_t a = a0 >> 32; | ||
39 | - uint32_t b = a0; | ||
40 | - uint32_t c = b0 >> 32; | ||
41 | - uint32_t d = b0; | ||
42 | + uint32_t v1 = QEMU_XXHASH_SEED + PRIME32_1 + PRIME32_2; | ||
43 | + uint32_t v2 = QEMU_XXHASH_SEED + PRIME32_2; | ||
44 | + uint32_t v3 = QEMU_XXHASH_SEED + 0; | ||
45 | + uint32_t v4 = QEMU_XXHASH_SEED - PRIME32_1; | ||
46 | + uint32_t a = ab >> 32; | ||
47 | + uint32_t b = ab; | ||
48 | + uint32_t c = cd >> 32; | ||
49 | + uint32_t d = cd; | ||
50 | uint32_t h32; | ||
51 | |||
52 | v1 += a * PRIME32_2; | ||
53 | @@ -XXX,XX +XXX,XX @@ tb_hash_func7(uint64_t a0, uint64_t b0, uint32_t e, uint32_t f, uint32_t g) | ||
54 | return h32; | ||
55 | } | ||
56 | |||
57 | +static inline uint32_t qemu_xxhash2(uint64_t ab) | ||
58 | +{ | ||
59 | + return qemu_xxhash7(ab, 0, 0, 0, 0); | ||
60 | +} | ||
61 | + | ||
62 | +static inline uint32_t qemu_xxhash4(uint64_t ab, uint64_t cd) | ||
63 | +{ | ||
64 | + return qemu_xxhash7(ab, cd, 0, 0, 0); | ||
65 | +} | ||
66 | + | ||
67 | +static inline uint32_t qemu_xxhash5(uint64_t ab, uint64_t cd, uint32_t e) | ||
68 | +{ | ||
69 | + return qemu_xxhash7(ab, cd, e, 0, 0); | ||
70 | +} | ||
71 | + | ||
72 | +static inline uint32_t qemu_xxhash6(uint64_t ab, uint64_t cd, uint32_t e, | ||
73 | + uint32_t f) | ||
74 | +{ | ||
75 | + return qemu_xxhash7(ab, cd, e, f, 0); | ||
76 | +} | ||
77 | + | ||
78 | #endif /* EXEC_TB_HASH_XX_H */ | ||
79 | diff --git a/include/exec/tb-hash.h b/include/exec/tb-hash.h | ||
80 | index XXXXXXX..XXXXXXX 100644 | ||
81 | --- a/include/exec/tb-hash.h | ||
82 | +++ b/include/exec/tb-hash.h | ||
83 | @@ -XXX,XX +XXX,XX @@ static inline | ||
84 | uint32_t tb_hash_func(tb_page_addr_t phys_pc, target_ulong pc, uint32_t flags, | ||
85 | uint32_t cf_mask, uint32_t trace_vcpu_dstate) | ||
86 | { | ||
87 | - return tb_hash_func7(phys_pc, pc, flags, cf_mask, trace_vcpu_dstate); | ||
88 | + return qemu_xxhash7(phys_pc, pc, flags, cf_mask, trace_vcpu_dstate); | ||
89 | } | ||
90 | |||
91 | #endif | ||
92 | diff --git a/tests/qht-bench.c b/tests/qht-bench.c | ||
93 | index XXXXXXX..XXXXXXX 100644 | ||
94 | --- a/tests/qht-bench.c | ||
95 | +++ b/tests/qht-bench.c | ||
96 | @@ -XXX,XX +XXX,XX @@ static bool is_equal(const void *ap, const void *bp) | ||
97 | |||
98 | static uint32_t h(unsigned long v) | ||
99 | { | ||
100 | - return tb_hash_func7(v, 0, 0, 0, 0); | ||
101 | + return qemu_xxhash2(v); | ||
102 | } | ||
103 | |||
104 | static uint32_t hval(unsigned long v) | ||
105 | diff --git a/util/qsp.c b/util/qsp.c | ||
106 | index XXXXXXX..XXXXXXX 100644 | ||
107 | --- a/util/qsp.c | ||
108 | +++ b/util/qsp.c | ||
109 | @@ -XXX,XX +XXX,XX @@ QemuCondWaitFunc qemu_cond_wait_func = qemu_cond_wait_impl; | ||
110 | * without it we still get a pretty unique hash. | ||
111 | */ | ||
112 | static inline | ||
113 | -uint32_t do_qsp_callsite_hash(const QSPCallSite *callsite, uint64_t a) | ||
114 | +uint32_t do_qsp_callsite_hash(const QSPCallSite *callsite, uint64_t ab) | ||
115 | { | ||
116 | - uint64_t b = (uint64_t)(uintptr_t)callsite->obj; | ||
117 | + uint64_t cd = (uint64_t)(uintptr_t)callsite->obj; | ||
118 | uint32_t e = callsite->line; | ||
119 | uint32_t f = callsite->type; | ||
120 | |||
121 | - return tb_hash_func7(a, b, e, f, 0); | ||
122 | + return qemu_xxhash6(ab, cd, e, f); | ||
123 | } | ||
124 | |||
125 | static inline | ||
126 | @@ -XXX,XX +XXX,XX @@ static uint32_t qsp_entry_no_thread_hash(const QSPEntry *entry) | ||
127 | static uint32_t qsp_entry_no_thread_obj_hash(const QSPEntry *entry) | ||
128 | { | ||
129 | const QSPCallSite *callsite = entry->callsite; | ||
130 | - uint64_t a = g_str_hash(callsite->file); | ||
131 | - uint64_t b = callsite->line; | ||
132 | + uint64_t ab = g_str_hash(callsite->file); | ||
133 | + uint64_t cd = callsite->line; | ||
134 | uint32_t e = callsite->type; | ||
135 | |||
136 | - return tb_hash_func7(a, b, e, 0, 0); | ||
137 | + return qemu_xxhash5(ab, cd, e); | ||
138 | } | ||
139 | |||
140 | static bool qsp_callsite_cmp(const void *ap, const void *bp) | ||
141 | -- | ||
142 | 2.17.2 | ||
143 | |||
144 | diff view generated by jsdifflib |
Deleted patch | |||
---|---|---|---|
1 | From: "Emilio G. Cota" <cota@braap.org> | ||
2 | 1 | ||
3 | Reviewed-by: Alex Bennée <alex.bennee@linaro.org> | ||
4 | Signed-off-by: Emilio G. Cota <cota@braap.org> | ||
5 | Signed-off-by: Richard Henderson <richard.henderson@linaro.org> | ||
6 | --- | ||
7 | include/exec/tb-hash.h | 2 +- | ||
8 | include/{exec/tb-hash-xx.h => qemu/xxhash.h} | 6 +++--- | ||
9 | tests/qht-bench.c | 2 +- | ||
10 | util/qsp.c | 2 +- | ||
11 | 4 files changed, 6 insertions(+), 6 deletions(-) | ||
12 | rename include/{exec/tb-hash-xx.h => qemu/xxhash.h} (97%) | ||
13 | |||
14 | diff --git a/include/exec/tb-hash.h b/include/exec/tb-hash.h | ||
15 | index XXXXXXX..XXXXXXX 100644 | ||
16 | --- a/include/exec/tb-hash.h | ||
17 | +++ b/include/exec/tb-hash.h | ||
18 | @@ -XXX,XX +XXX,XX @@ | ||
19 | #ifndef EXEC_TB_HASH_H | ||
20 | #define EXEC_TB_HASH_H | ||
21 | |||
22 | -#include "exec/tb-hash-xx.h" | ||
23 | +#include "qemu/xxhash.h" | ||
24 | |||
25 | #ifdef CONFIG_SOFTMMU | ||
26 | |||
27 | diff --git a/include/exec/tb-hash-xx.h b/include/qemu/xxhash.h | ||
28 | similarity index 97% | ||
29 | rename from include/exec/tb-hash-xx.h | ||
30 | rename to include/qemu/xxhash.h | ||
31 | index XXXXXXX..XXXXXXX 100644 | ||
32 | --- a/include/exec/tb-hash-xx.h | ||
33 | +++ b/include/qemu/xxhash.h | ||
34 | @@ -XXX,XX +XXX,XX @@ | ||
35 | * - xxHash source repository : https://github.com/Cyan4973/xxHash | ||
36 | */ | ||
37 | |||
38 | -#ifndef EXEC_TB_HASH_XX_H | ||
39 | -#define EXEC_TB_HASH_XX_H | ||
40 | +#ifndef QEMU_XXHASH_H | ||
41 | +#define QEMU_XXHASH_H | ||
42 | |||
43 | #include "qemu/bitops.h" | ||
44 | |||
45 | @@ -XXX,XX +XXX,XX @@ static inline uint32_t qemu_xxhash6(uint64_t ab, uint64_t cd, uint32_t e, | ||
46 | return qemu_xxhash7(ab, cd, e, f, 0); | ||
47 | } | ||
48 | |||
49 | -#endif /* EXEC_TB_HASH_XX_H */ | ||
50 | +#endif /* QEMU_XXHASH_H */ | ||
51 | diff --git a/tests/qht-bench.c b/tests/qht-bench.c | ||
52 | index XXXXXXX..XXXXXXX 100644 | ||
53 | --- a/tests/qht-bench.c | ||
54 | +++ b/tests/qht-bench.c | ||
55 | @@ -XXX,XX +XXX,XX @@ | ||
56 | #include "qemu/atomic.h" | ||
57 | #include "qemu/qht.h" | ||
58 | #include "qemu/rcu.h" | ||
59 | -#include "exec/tb-hash-xx.h" | ||
60 | +#include "qemu/xxhash.h" | ||
61 | |||
62 | struct thread_stats { | ||
63 | size_t rd; | ||
64 | diff --git a/util/qsp.c b/util/qsp.c | ||
65 | index XXXXXXX..XXXXXXX 100644 | ||
66 | --- a/util/qsp.c | ||
67 | +++ b/util/qsp.c | ||
68 | @@ -XXX,XX +XXX,XX @@ | ||
69 | #include "qemu/timer.h" | ||
70 | #include "qemu/qht.h" | ||
71 | #include "qemu/rcu.h" | ||
72 | -#include "exec/tb-hash-xx.h" | ||
73 | +#include "qemu/xxhash.h" | ||
74 | |||
75 | enum QSPType { | ||
76 | QSP_MUTEX, | ||
77 | -- | ||
78 | 2.17.2 | ||
79 | |||
80 | diff view generated by jsdifflib |
1 | From: "Emilio G. Cota" <cota@braap.org> | 1 | The alias is intended to indicate that the bswap is for the |
---|---|---|---|
2 | entire target_long. This should avoid ifdefs on some targets. | ||
2 | 3 | ||
3 | Change the order in which we extract a/b and c/d to | 4 | Reviewed-by: Frank Chang <frank.chang@sifive.com> |
4 | match the output of the upstream xxhash32. | ||
5 | |||
6 | Tested with: | ||
7 | https://github.com/cota/xxhash/tree/qemu | ||
8 | |||
9 | Reviewed-by: Alex Bennée <alex.bennee@linaro.org> | ||
10 | Tested-by: Alex Bennée <alex.bennee@linaro.org> | ||
11 | Signed-off-by: Emilio G. Cota <cota@braap.org> | ||
12 | Signed-off-by: Richard Henderson <richard.henderson@linaro.org> | 5 | Signed-off-by: Richard Henderson <richard.henderson@linaro.org> |
13 | --- | 6 | --- |
14 | include/qemu/xxhash.h | 8 ++++---- | 7 | include/tcg/tcg-op.h | 2 ++ |
15 | 1 file changed, 4 insertions(+), 4 deletions(-) | 8 | 1 file changed, 2 insertions(+) |
16 | 9 | ||
17 | diff --git a/include/qemu/xxhash.h b/include/qemu/xxhash.h | 10 | diff --git a/include/tcg/tcg-op.h b/include/tcg/tcg-op.h |
18 | index XXXXXXX..XXXXXXX 100644 | 11 | index XXXXXXX..XXXXXXX 100644 |
19 | --- a/include/qemu/xxhash.h | 12 | --- a/include/tcg/tcg-op.h |
20 | +++ b/include/qemu/xxhash.h | 13 | +++ b/include/tcg/tcg-op.h |
21 | @@ -XXX,XX +XXX,XX @@ qemu_xxhash7(uint64_t ab, uint64_t cd, uint32_t e, uint32_t f, uint32_t g) | 14 | @@ -XXX,XX +XXX,XX @@ void tcg_gen_stl_vec(TCGv_vec r, TCGv_ptr base, TCGArg offset, TCGType t); |
22 | uint32_t v2 = QEMU_XXHASH_SEED + PRIME32_2; | 15 | #define tcg_gen_bswap16_tl tcg_gen_bswap16_i64 |
23 | uint32_t v3 = QEMU_XXHASH_SEED + 0; | 16 | #define tcg_gen_bswap32_tl tcg_gen_bswap32_i64 |
24 | uint32_t v4 = QEMU_XXHASH_SEED - PRIME32_1; | 17 | #define tcg_gen_bswap64_tl tcg_gen_bswap64_i64 |
25 | - uint32_t a = ab >> 32; | 18 | +#define tcg_gen_bswap_tl tcg_gen_bswap64_i64 |
26 | - uint32_t b = ab; | 19 | #define tcg_gen_concat_tl_i64 tcg_gen_concat32_i64 |
27 | - uint32_t c = cd >> 32; | 20 | #define tcg_gen_extr_i64_tl tcg_gen_extr32_i64 |
28 | - uint32_t d = cd; | 21 | #define tcg_gen_andc_tl tcg_gen_andc_i64 |
29 | + uint32_t a = ab; | 22 | @@ -XXX,XX +XXX,XX @@ void tcg_gen_stl_vec(TCGv_vec r, TCGv_ptr base, TCGArg offset, TCGType t); |
30 | + uint32_t b = ab >> 32; | 23 | #define tcg_gen_ext32s_tl tcg_gen_mov_i32 |
31 | + uint32_t c = cd; | 24 | #define tcg_gen_bswap16_tl tcg_gen_bswap16_i32 |
32 | + uint32_t d = cd >> 32; | 25 | #define tcg_gen_bswap32_tl tcg_gen_bswap32_i32 |
33 | uint32_t h32; | 26 | +#define tcg_gen_bswap_tl tcg_gen_bswap32_i32 |
34 | 27 | #define tcg_gen_concat_tl_i64 tcg_gen_concat_i32_i64 | |
35 | v1 += a * PRIME32_2; | 28 | #define tcg_gen_extr_i64_tl tcg_gen_extr_i64_i32 |
29 | #define tcg_gen_andc_tl tcg_gen_andc_i32 | ||
36 | -- | 30 | -- |
37 | 2.17.2 | 31 | 2.25.1 |
38 | 32 | ||
39 | 33 | diff view generated by jsdifflib |
Deleted patch | |||
---|---|---|---|
1 | I didn't get this fix pushed back into the patch set that I actually | ||
2 | sent last week. The patch is in target-arm.next, and I'm sure you | ||
3 | would have eventually seen the error in testing. | ||
4 | 1 | ||
5 | |||
6 | r~ | ||
7 | --- | ||
8 | target/arm/kvm64.c | 4 ++-- | ||
9 | 1 file changed, 2 insertions(+), 2 deletions(-) | ||
10 | |||
11 | diff --git a/target/arm/kvm64.c b/target/arm/kvm64.c | ||
12 | index XXXXXXX..XXXXXXX 100644 | ||
13 | --- a/target/arm/kvm64.c | ||
14 | +++ b/target/arm/kvm64.c | ||
15 | @@ -XXX,XX +XXX,XX @@ bool kvm_arm_get_host_cpu_features(ARMHostCPUFeatures *ahcf) | ||
16 | ARM64_SYS_REG(3, 0, 0, 6, 0)); | ||
17 | err |= read_sys_reg64(fdarray[2], &ahcf->isar.id_aa64isar1, | ||
18 | ARM64_SYS_REG(3, 0, 0, 6, 1)); | ||
19 | - err |= read_sys_reg64(fdarray[2], &achf->isar.id_aa64mmfr0, | ||
20 | + err |= read_sys_reg64(fdarray[2], &ahcf->isar.id_aa64mmfr0, | ||
21 | ARM64_SYS_REG(3, 0, 0, 7, 0)); | ||
22 | - err |= read_sys_reg64(fdarray[2], &achf->isar.id_aa64mmfr1, | ||
23 | + err |= read_sys_reg64(fdarray[2], &ahcf->isar.id_aa64mmfr1, | ||
24 | ARM64_SYS_REG(3, 0, 0, 7, 1)); | ||
25 | |||
26 | /* | ||
27 | -- | ||
28 | 2.17.2 | ||
29 | |||
30 | diff view generated by jsdifflib |