1 | The following changes since commit 3284aa128153750f14a61e8a96fd085e6f2999b6: | 1 | Pretty small still, but there are two patches that ought |
---|---|---|---|
2 | to get backported to stable, so no point in delaying. | ||
2 | 3 | ||
3 | Merge remote-tracking branch 'remotes/lersek/tags/edk2-pull-2019-04-22' into staging (2019-04-24 13:19:41 +0100) | 4 | r~ |
5 | |||
6 | The following changes since commit a5ba0a7e4e150d1350a041f0d0ef9ca6c8d7c307: | ||
7 | |||
8 | Merge tag 'pull-aspeed-20241211' of https://github.com/legoater/qemu into staging (2024-12-11 15:16:47 +0000) | ||
4 | 9 | ||
5 | are available in the Git repository at: | 10 | are available in the Git repository at: |
6 | 11 | ||
7 | https://github.com/rth7680/qemu.git tags/pull-tcg-20190426 | 12 | https://gitlab.com/rth7680/qemu.git tags/pull-tcg-20241212 |
8 | 13 | ||
9 | for you to fetch changes up to ef5dae6805cce7b59d129d801bdc5db71bcbd60d: | 14 | for you to fetch changes up to 7ac87b14a92234b6a89b701b4043ad6cf8bdcccf: |
10 | 15 | ||
11 | cputlb: Fix io_readx() to respect the access_type (2019-04-25 10:40:06 -0700) | 16 | target/sparc: Use memcpy() and remove memcpy32() (2024-12-12 14:28:38 -0600) |
12 | 17 | ||
13 | ---------------------------------------------------------------- | 18 | ---------------------------------------------------------------- |
14 | Add tcg_gen_extract2_*. | 19 | tcg: Reset free_temps before tcg_optimize |
15 | Deal with overflow of TranslationBlocks. | 20 | tcg/riscv: Fix StoreStore barrier generation |
16 | Respect access_type in io_readx. | 21 | include/exec: Introduce fpst alias in helper-head.h.inc |
22 | target/sparc: Use memcpy() and remove memcpy32() | ||
17 | 23 | ||
18 | ---------------------------------------------------------------- | 24 | ---------------------------------------------------------------- |
19 | David Hildenbrand (1): | 25 | Philippe Mathieu-Daudé (1): |
20 | tcg: Implement tcg_gen_extract2_{i32,i64} | 26 | target/sparc: Use memcpy() and remove memcpy32() |
21 | 27 | ||
22 | Richard Henderson (13): | 28 | Richard Henderson (2): |
23 | tcg: Add INDEX_op_extract2_{i32,i64} | 29 | tcg: Reset free_temps before tcg_optimize |
24 | tcg: Use deposit and extract2 in tcg_gen_shifti_i64 | 30 | include/exec: Introduce fpst alias in helper-head.h.inc |
25 | tcg: Use extract2 in tcg_gen_deposit_{i32,i64} | ||
26 | tcg/i386: Support INDEX_op_extract2_{i32,i64} | ||
27 | tcg/arm: Support INDEX_op_extract2_i32 | ||
28 | tcg/aarch64: Support INDEX_op_extract2_{i32,i64} | ||
29 | tcg: Hoist max_insns computation to tb_gen_code | ||
30 | tcg: Restart after TB code generation overflow | ||
31 | tcg: Restart TB generation after relocation overflow | ||
32 | tcg: Restart TB generation after constant pool overflow | ||
33 | tcg: Restart TB generation after out-of-line ldst overflow | ||
34 | tcg/ppc: Allow the constant pool to overflow at 32k | ||
35 | tcg/arm: Restrict constant pool displacement to 12 bits | ||
36 | 31 | ||
37 | Shahab Vahedi (1): | 32 | Roman Artemev (1): |
38 | cputlb: Fix io_readx() to respect the access_type | 33 | tcg/riscv: Fix StoreStore barrier generation |
39 | 34 | ||
40 | include/exec/exec-all.h | 4 +- | 35 | include/tcg/tcg-temp-internal.h | 6 ++++++ |
41 | include/exec/translator.h | 3 +- | 36 | accel/tcg/plugin-gen.c | 2 +- |
42 | tcg/aarch64/tcg-target.h | 2 + | 37 | target/sparc/win_helper.c | 26 ++++++++------------------ |
43 | tcg/arm/tcg-target.h | 1 + | 38 | tcg/tcg.c | 5 ++++- |
44 | tcg/i386/tcg-target.h | 2 + | 39 | include/exec/helper-head.h.inc | 3 +++ |
45 | tcg/mips/tcg-target.h | 2 + | 40 | tcg/riscv/tcg-target.c.inc | 2 +- |
46 | tcg/ppc/tcg-target.h | 2 + | 41 | 6 files changed, 23 insertions(+), 21 deletions(-) |
47 | tcg/riscv/tcg-target.h | 2 + | ||
48 | tcg/s390/tcg-target.h | 2 + | ||
49 | tcg/sparc/tcg-target.h | 2 + | ||
50 | tcg/tcg-op.h | 6 ++ | ||
51 | tcg/tcg-opc.h | 2 + | ||
52 | tcg/tcg.h | 16 +++--- | ||
53 | tcg/tci/tcg-target.h | 2 + | ||
54 | accel/tcg/cputlb.c | 5 +- | ||
55 | accel/tcg/translate-all.c | 53 ++++++++++++++--- | ||
56 | accel/tcg/translator.c | 15 +---- | ||
57 | target/alpha/translate.c | 4 +- | ||
58 | target/arm/translate.c | 4 +- | ||
59 | target/cris/translate.c | 10 +--- | ||
60 | target/hppa/translate.c | 5 +- | ||
61 | target/i386/translate.c | 4 +- | ||
62 | target/lm32/translate.c | 10 +--- | ||
63 | target/m68k/translate.c | 4 +- | ||
64 | target/microblaze/translate.c | 10 +--- | ||
65 | target/mips/translate.c | 4 +- | ||
66 | target/moxie/translate.c | 11 +--- | ||
67 | target/nios2/translate.c | 14 +---- | ||
68 | target/openrisc/translate.c | 4 +- | ||
69 | target/ppc/translate.c | 4 +- | ||
70 | target/riscv/translate.c | 4 +- | ||
71 | target/s390x/translate.c | 4 +- | ||
72 | target/sh4/translate.c | 4 +- | ||
73 | target/sparc/translate.c | 4 +- | ||
74 | target/tilegx/translate.c | 12 +--- | ||
75 | target/tricore/translate.c | 16 +----- | ||
76 | target/unicore32/translate.c | 10 +--- | ||
77 | target/xtensa/translate.c | 4 +- | ||
78 | tcg/aarch64/tcg-target.inc.c | 27 +++++++-- | ||
79 | tcg/arm/tcg-target.inc.c | 98 ++++++++++++++++++-------------- | ||
80 | tcg/i386/tcg-target.inc.c | 17 +++++- | ||
81 | tcg/mips/tcg-target.inc.c | 6 +- | ||
82 | tcg/optimize.c | 16 ++++++ | ||
83 | tcg/ppc/tcg-target.inc.c | 42 +++++++------- | ||
84 | tcg/riscv/tcg-target.inc.c | 16 ++++-- | ||
85 | tcg/s390/tcg-target.inc.c | 20 ++++--- | ||
86 | tcg/tcg-ldst.inc.c | 18 +++--- | ||
87 | tcg/tcg-op.c | 129 +++++++++++++++++++++++++++++++++--------- | ||
88 | tcg/tcg-pool.inc.c | 12 ++-- | ||
89 | tcg/tcg.c | 85 +++++++++++++++------------- | ||
90 | tcg/README | 7 +++ | ||
91 | 51 files changed, 451 insertions(+), 309 deletions(-) | ||
92 | 42 | diff view generated by jsdifflib |
Deleted patch | |||
---|---|---|---|
1 | From: David Hildenbrand <david@redhat.com> | ||
2 | 1 | ||
3 | Will be helpful for s390x. Input 128 bit and output 64 bit only, | ||
4 | which is sufficient for now. | ||
5 | |||
6 | Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org> | ||
7 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> | ||
8 | Signed-off-by: David Hildenbrand <david@redhat.com> | ||
9 | Message-Id: <20190225154204.26751-1-david@redhat.com> | ||
10 | [rth: Add matching tcg_gen_extract2_i32.] | ||
11 | Signed-off-by: Richard Henderson <richard.henderson@linaro.org> | ||
12 | --- | ||
13 | tcg/tcg-op.h | 6 ++++++ | ||
14 | tcg/tcg-op.c | 44 ++++++++++++++++++++++++++++++++++++++++++++ | ||
15 | 2 files changed, 50 insertions(+) | ||
16 | |||
17 | diff --git a/tcg/tcg-op.h b/tcg/tcg-op.h | ||
18 | index XXXXXXX..XXXXXXX 100644 | ||
19 | --- a/tcg/tcg-op.h | ||
20 | +++ b/tcg/tcg-op.h | ||
21 | @@ -XXX,XX +XXX,XX @@ void tcg_gen_extract_i32(TCGv_i32 ret, TCGv_i32 arg, | ||
22 | unsigned int ofs, unsigned int len); | ||
23 | void tcg_gen_sextract_i32(TCGv_i32 ret, TCGv_i32 arg, | ||
24 | unsigned int ofs, unsigned int len); | ||
25 | +void tcg_gen_extract2_i32(TCGv_i32 ret, TCGv_i32 al, TCGv_i32 ah, | ||
26 | + unsigned int ofs); | ||
27 | void tcg_gen_brcond_i32(TCGCond cond, TCGv_i32 arg1, TCGv_i32 arg2, TCGLabel *); | ||
28 | void tcg_gen_brcondi_i32(TCGCond cond, TCGv_i32 arg1, int32_t arg2, TCGLabel *); | ||
29 | void tcg_gen_setcond_i32(TCGCond cond, TCGv_i32 ret, | ||
30 | @@ -XXX,XX +XXX,XX @@ void tcg_gen_extract_i64(TCGv_i64 ret, TCGv_i64 arg, | ||
31 | unsigned int ofs, unsigned int len); | ||
32 | void tcg_gen_sextract_i64(TCGv_i64 ret, TCGv_i64 arg, | ||
33 | unsigned int ofs, unsigned int len); | ||
34 | +void tcg_gen_extract2_i64(TCGv_i64 ret, TCGv_i64 al, TCGv_i64 ah, | ||
35 | + unsigned int ofs); | ||
36 | void tcg_gen_brcond_i64(TCGCond cond, TCGv_i64 arg1, TCGv_i64 arg2, TCGLabel *); | ||
37 | void tcg_gen_brcondi_i64(TCGCond cond, TCGv_i64 arg1, int64_t arg2, TCGLabel *); | ||
38 | void tcg_gen_setcond_i64(TCGCond cond, TCGv_i64 ret, | ||
39 | @@ -XXX,XX +XXX,XX @@ void tcg_gen_stl_vec(TCGv_vec r, TCGv_ptr base, TCGArg offset, TCGType t); | ||
40 | #define tcg_gen_deposit_z_tl tcg_gen_deposit_z_i64 | ||
41 | #define tcg_gen_extract_tl tcg_gen_extract_i64 | ||
42 | #define tcg_gen_sextract_tl tcg_gen_sextract_i64 | ||
43 | +#define tcg_gen_extract2_tl tcg_gen_extract2_i64 | ||
44 | #define tcg_const_tl tcg_const_i64 | ||
45 | #define tcg_const_local_tl tcg_const_local_i64 | ||
46 | #define tcg_gen_movcond_tl tcg_gen_movcond_i64 | ||
47 | @@ -XXX,XX +XXX,XX @@ void tcg_gen_stl_vec(TCGv_vec r, TCGv_ptr base, TCGArg offset, TCGType t); | ||
48 | #define tcg_gen_deposit_z_tl tcg_gen_deposit_z_i32 | ||
49 | #define tcg_gen_extract_tl tcg_gen_extract_i32 | ||
50 | #define tcg_gen_sextract_tl tcg_gen_sextract_i32 | ||
51 | +#define tcg_gen_extract2_tl tcg_gen_extract2_i32 | ||
52 | #define tcg_const_tl tcg_const_i32 | ||
53 | #define tcg_const_local_tl tcg_const_local_i32 | ||
54 | #define tcg_gen_movcond_tl tcg_gen_movcond_i32 | ||
55 | diff --git a/tcg/tcg-op.c b/tcg/tcg-op.c | ||
56 | index XXXXXXX..XXXXXXX 100644 | ||
57 | --- a/tcg/tcg-op.c | ||
58 | +++ b/tcg/tcg-op.c | ||
59 | @@ -XXX,XX +XXX,XX @@ void tcg_gen_sextract_i32(TCGv_i32 ret, TCGv_i32 arg, | ||
60 | tcg_gen_sari_i32(ret, ret, 32 - len); | ||
61 | } | ||
62 | |||
63 | +/* | ||
64 | + * Extract 32-bits from a 64-bit input, ah:al, starting from ofs. | ||
65 | + * Unlike tcg_gen_extract_i32 above, len is fixed at 32. | ||
66 | + */ | ||
67 | +void tcg_gen_extract2_i32(TCGv_i32 ret, TCGv_i32 al, TCGv_i32 ah, | ||
68 | + unsigned int ofs) | ||
69 | +{ | ||
70 | + tcg_debug_assert(ofs <= 32); | ||
71 | + if (ofs == 0) { | ||
72 | + tcg_gen_mov_i32(ret, al); | ||
73 | + } else if (ofs == 32) { | ||
74 | + tcg_gen_mov_i32(ret, ah); | ||
75 | + } else if (al == ah) { | ||
76 | + tcg_gen_rotri_i32(ret, al, ofs); | ||
77 | + } else { | ||
78 | + TCGv_i32 t0 = tcg_temp_new_i32(); | ||
79 | + tcg_gen_shri_i32(t0, al, ofs); | ||
80 | + tcg_gen_deposit_i32(ret, t0, ah, 32 - ofs, ofs); | ||
81 | + tcg_temp_free_i32(t0); | ||
82 | + } | ||
83 | +} | ||
84 | + | ||
85 | void tcg_gen_movcond_i32(TCGCond cond, TCGv_i32 ret, TCGv_i32 c1, | ||
86 | TCGv_i32 c2, TCGv_i32 v1, TCGv_i32 v2) | ||
87 | { | ||
88 | @@ -XXX,XX +XXX,XX @@ void tcg_gen_sextract_i64(TCGv_i64 ret, TCGv_i64 arg, | ||
89 | tcg_gen_sari_i64(ret, ret, 64 - len); | ||
90 | } | ||
91 | |||
92 | +/* | ||
93 | + * Extract 64 bits from a 128-bit input, ah:al, starting from ofs. | ||
94 | + * Unlike tcg_gen_extract_i64 above, len is fixed at 64. | ||
95 | + */ | ||
96 | +void tcg_gen_extract2_i64(TCGv_i64 ret, TCGv_i64 al, TCGv_i64 ah, | ||
97 | + unsigned int ofs) | ||
98 | +{ | ||
99 | + tcg_debug_assert(ofs <= 64); | ||
100 | + if (ofs == 0) { | ||
101 | + tcg_gen_mov_i64(ret, al); | ||
102 | + } else if (ofs == 64) { | ||
103 | + tcg_gen_mov_i64(ret, ah); | ||
104 | + } else if (al == ah) { | ||
105 | + tcg_gen_rotri_i64(ret, al, ofs); | ||
106 | + } else { | ||
107 | + TCGv_i64 t0 = tcg_temp_new_i64(); | ||
108 | + tcg_gen_shri_i64(t0, al, ofs); | ||
109 | + tcg_gen_deposit_i64(ret, t0, ah, 64 - ofs, ofs); | ||
110 | + tcg_temp_free_i64(t0); | ||
111 | + } | ||
112 | +} | ||
113 | + | ||
114 | void tcg_gen_movcond_i64(TCGCond cond, TCGv_i64 ret, TCGv_i64 c1, | ||
115 | TCGv_i64 c2, TCGv_i64 v1, TCGv_i64 v2) | ||
116 | { | ||
117 | -- | ||
118 | 2.17.1 | ||
119 | |||
120 | diff view generated by jsdifflib |
Deleted patch | |||
---|---|---|---|
1 | This will let backends implement the double-word shift operation. | ||
2 | 1 | ||
3 | Reviewed-by: David Hildenbrand <david@redhat.com> | ||
4 | Signed-off-by: Richard Henderson <richard.henderson@linaro.org> | ||
5 | --- | ||
6 | tcg/aarch64/tcg-target.h | 2 ++ | ||
7 | tcg/arm/tcg-target.h | 1 + | ||
8 | tcg/i386/tcg-target.h | 2 ++ | ||
9 | tcg/mips/tcg-target.h | 2 ++ | ||
10 | tcg/ppc/tcg-target.h | 2 ++ | ||
11 | tcg/riscv/tcg-target.h | 2 ++ | ||
12 | tcg/s390/tcg-target.h | 2 ++ | ||
13 | tcg/sparc/tcg-target.h | 2 ++ | ||
14 | tcg/tcg-opc.h | 2 ++ | ||
15 | tcg/tcg.h | 1 + | ||
16 | tcg/tci/tcg-target.h | 2 ++ | ||
17 | tcg/optimize.c | 16 ++++++++++++++++ | ||
18 | tcg/tcg-op.c | 4 ++++ | ||
19 | tcg/tcg.c | 4 ++++ | ||
20 | tcg/README | 7 +++++++ | ||
21 | 15 files changed, 51 insertions(+) | ||
22 | |||
23 | diff --git a/tcg/aarch64/tcg-target.h b/tcg/aarch64/tcg-target.h | ||
24 | index XXXXXXX..XXXXXXX 100644 | ||
25 | --- a/tcg/aarch64/tcg-target.h | ||
26 | +++ b/tcg/aarch64/tcg-target.h | ||
27 | @@ -XXX,XX +XXX,XX @@ typedef enum { | ||
28 | #define TCG_TARGET_HAS_deposit_i32 1 | ||
29 | #define TCG_TARGET_HAS_extract_i32 1 | ||
30 | #define TCG_TARGET_HAS_sextract_i32 1 | ||
31 | +#define TCG_TARGET_HAS_extract2_i32 0 | ||
32 | #define TCG_TARGET_HAS_movcond_i32 1 | ||
33 | #define TCG_TARGET_HAS_add2_i32 1 | ||
34 | #define TCG_TARGET_HAS_sub2_i32 1 | ||
35 | @@ -XXX,XX +XXX,XX @@ typedef enum { | ||
36 | #define TCG_TARGET_HAS_deposit_i64 1 | ||
37 | #define TCG_TARGET_HAS_extract_i64 1 | ||
38 | #define TCG_TARGET_HAS_sextract_i64 1 | ||
39 | +#define TCG_TARGET_HAS_extract2_i64 0 | ||
40 | #define TCG_TARGET_HAS_movcond_i64 1 | ||
41 | #define TCG_TARGET_HAS_add2_i64 1 | ||
42 | #define TCG_TARGET_HAS_sub2_i64 1 | ||
43 | diff --git a/tcg/arm/tcg-target.h b/tcg/arm/tcg-target.h | ||
44 | index XXXXXXX..XXXXXXX 100644 | ||
45 | --- a/tcg/arm/tcg-target.h | ||
46 | +++ b/tcg/arm/tcg-target.h | ||
47 | @@ -XXX,XX +XXX,XX @@ extern bool use_idiv_instructions; | ||
48 | #define TCG_TARGET_HAS_deposit_i32 use_armv7_instructions | ||
49 | #define TCG_TARGET_HAS_extract_i32 use_armv7_instructions | ||
50 | #define TCG_TARGET_HAS_sextract_i32 use_armv7_instructions | ||
51 | +#define TCG_TARGET_HAS_extract2_i32 0 | ||
52 | #define TCG_TARGET_HAS_movcond_i32 1 | ||
53 | #define TCG_TARGET_HAS_mulu2_i32 1 | ||
54 | #define TCG_TARGET_HAS_muls2_i32 1 | ||
55 | diff --git a/tcg/i386/tcg-target.h b/tcg/i386/tcg-target.h | ||
56 | index XXXXXXX..XXXXXXX 100644 | ||
57 | --- a/tcg/i386/tcg-target.h | ||
58 | +++ b/tcg/i386/tcg-target.h | ||
59 | @@ -XXX,XX +XXX,XX @@ extern bool have_avx2; | ||
60 | #define TCG_TARGET_HAS_deposit_i32 1 | ||
61 | #define TCG_TARGET_HAS_extract_i32 1 | ||
62 | #define TCG_TARGET_HAS_sextract_i32 1 | ||
63 | +#define TCG_TARGET_HAS_extract2_i32 0 | ||
64 | #define TCG_TARGET_HAS_movcond_i32 1 | ||
65 | #define TCG_TARGET_HAS_add2_i32 1 | ||
66 | #define TCG_TARGET_HAS_sub2_i32 1 | ||
67 | @@ -XXX,XX +XXX,XX @@ extern bool have_avx2; | ||
68 | #define TCG_TARGET_HAS_deposit_i64 1 | ||
69 | #define TCG_TARGET_HAS_extract_i64 1 | ||
70 | #define TCG_TARGET_HAS_sextract_i64 0 | ||
71 | +#define TCG_TARGET_HAS_extract2_i64 0 | ||
72 | #define TCG_TARGET_HAS_movcond_i64 1 | ||
73 | #define TCG_TARGET_HAS_add2_i64 1 | ||
74 | #define TCG_TARGET_HAS_sub2_i64 1 | ||
75 | diff --git a/tcg/mips/tcg-target.h b/tcg/mips/tcg-target.h | ||
76 | index XXXXXXX..XXXXXXX 100644 | ||
77 | --- a/tcg/mips/tcg-target.h | ||
78 | +++ b/tcg/mips/tcg-target.h | ||
79 | @@ -XXX,XX +XXX,XX @@ extern bool use_mips32r2_instructions; | ||
80 | #define TCG_TARGET_HAS_deposit_i32 use_mips32r2_instructions | ||
81 | #define TCG_TARGET_HAS_extract_i32 use_mips32r2_instructions | ||
82 | #define TCG_TARGET_HAS_sextract_i32 0 | ||
83 | +#define TCG_TARGET_HAS_extract2_i32 0 | ||
84 | #define TCG_TARGET_HAS_ext8s_i32 use_mips32r2_instructions | ||
85 | #define TCG_TARGET_HAS_ext16s_i32 use_mips32r2_instructions | ||
86 | #define TCG_TARGET_HAS_rot_i32 use_mips32r2_instructions | ||
87 | @@ -XXX,XX +XXX,XX @@ extern bool use_mips32r2_instructions; | ||
88 | #define TCG_TARGET_HAS_deposit_i64 use_mips32r2_instructions | ||
89 | #define TCG_TARGET_HAS_extract_i64 use_mips32r2_instructions | ||
90 | #define TCG_TARGET_HAS_sextract_i64 0 | ||
91 | +#define TCG_TARGET_HAS_extract2_i64 0 | ||
92 | #define TCG_TARGET_HAS_ext8s_i64 use_mips32r2_instructions | ||
93 | #define TCG_TARGET_HAS_ext16s_i64 use_mips32r2_instructions | ||
94 | #define TCG_TARGET_HAS_rot_i64 use_mips32r2_instructions | ||
95 | diff --git a/tcg/ppc/tcg-target.h b/tcg/ppc/tcg-target.h | ||
96 | index XXXXXXX..XXXXXXX 100644 | ||
97 | --- a/tcg/ppc/tcg-target.h | ||
98 | +++ b/tcg/ppc/tcg-target.h | ||
99 | @@ -XXX,XX +XXX,XX @@ extern bool have_isa_3_00; | ||
100 | #define TCG_TARGET_HAS_deposit_i32 1 | ||
101 | #define TCG_TARGET_HAS_extract_i32 1 | ||
102 | #define TCG_TARGET_HAS_sextract_i32 0 | ||
103 | +#define TCG_TARGET_HAS_extract2_i32 0 | ||
104 | #define TCG_TARGET_HAS_movcond_i32 1 | ||
105 | #define TCG_TARGET_HAS_mulu2_i32 0 | ||
106 | #define TCG_TARGET_HAS_muls2_i32 0 | ||
107 | @@ -XXX,XX +XXX,XX @@ extern bool have_isa_3_00; | ||
108 | #define TCG_TARGET_HAS_deposit_i64 1 | ||
109 | #define TCG_TARGET_HAS_extract_i64 1 | ||
110 | #define TCG_TARGET_HAS_sextract_i64 0 | ||
111 | +#define TCG_TARGET_HAS_extract2_i64 0 | ||
112 | #define TCG_TARGET_HAS_movcond_i64 1 | ||
113 | #define TCG_TARGET_HAS_add2_i64 1 | ||
114 | #define TCG_TARGET_HAS_sub2_i64 1 | ||
115 | diff --git a/tcg/riscv/tcg-target.h b/tcg/riscv/tcg-target.h | ||
116 | index XXXXXXX..XXXXXXX 100644 | ||
117 | --- a/tcg/riscv/tcg-target.h | ||
118 | +++ b/tcg/riscv/tcg-target.h | ||
119 | @@ -XXX,XX +XXX,XX @@ typedef enum { | ||
120 | #define TCG_TARGET_HAS_deposit_i32 0 | ||
121 | #define TCG_TARGET_HAS_extract_i32 0 | ||
122 | #define TCG_TARGET_HAS_sextract_i32 0 | ||
123 | +#define TCG_TARGET_HAS_extract2_i32 0 | ||
124 | #define TCG_TARGET_HAS_add2_i32 1 | ||
125 | #define TCG_TARGET_HAS_sub2_i32 1 | ||
126 | #define TCG_TARGET_HAS_mulu2_i32 0 | ||
127 | @@ -XXX,XX +XXX,XX @@ typedef enum { | ||
128 | #define TCG_TARGET_HAS_deposit_i64 0 | ||
129 | #define TCG_TARGET_HAS_extract_i64 0 | ||
130 | #define TCG_TARGET_HAS_sextract_i64 0 | ||
131 | +#define TCG_TARGET_HAS_extract2_i64 0 | ||
132 | #define TCG_TARGET_HAS_extrl_i64_i32 1 | ||
133 | #define TCG_TARGET_HAS_extrh_i64_i32 1 | ||
134 | #define TCG_TARGET_HAS_ext8s_i64 1 | ||
135 | diff --git a/tcg/s390/tcg-target.h b/tcg/s390/tcg-target.h | ||
136 | index XXXXXXX..XXXXXXX 100644 | ||
137 | --- a/tcg/s390/tcg-target.h | ||
138 | +++ b/tcg/s390/tcg-target.h | ||
139 | @@ -XXX,XX +XXX,XX @@ extern uint64_t s390_facilities; | ||
140 | #define TCG_TARGET_HAS_deposit_i32 (s390_facilities & FACILITY_GEN_INST_EXT) | ||
141 | #define TCG_TARGET_HAS_extract_i32 (s390_facilities & FACILITY_GEN_INST_EXT) | ||
142 | #define TCG_TARGET_HAS_sextract_i32 0 | ||
143 | +#define TCG_TARGET_HAS_extract2_i32 0 | ||
144 | #define TCG_TARGET_HAS_movcond_i32 1 | ||
145 | #define TCG_TARGET_HAS_add2_i32 1 | ||
146 | #define TCG_TARGET_HAS_sub2_i32 1 | ||
147 | @@ -XXX,XX +XXX,XX @@ extern uint64_t s390_facilities; | ||
148 | #define TCG_TARGET_HAS_deposit_i64 (s390_facilities & FACILITY_GEN_INST_EXT) | ||
149 | #define TCG_TARGET_HAS_extract_i64 (s390_facilities & FACILITY_GEN_INST_EXT) | ||
150 | #define TCG_TARGET_HAS_sextract_i64 0 | ||
151 | +#define TCG_TARGET_HAS_extract2_i64 0 | ||
152 | #define TCG_TARGET_HAS_movcond_i64 1 | ||
153 | #define TCG_TARGET_HAS_add2_i64 1 | ||
154 | #define TCG_TARGET_HAS_sub2_i64 1 | ||
155 | diff --git a/tcg/sparc/tcg-target.h b/tcg/sparc/tcg-target.h | ||
156 | index XXXXXXX..XXXXXXX 100644 | ||
157 | --- a/tcg/sparc/tcg-target.h | ||
158 | +++ b/tcg/sparc/tcg-target.h | ||
159 | @@ -XXX,XX +XXX,XX @@ extern bool use_vis3_instructions; | ||
160 | #define TCG_TARGET_HAS_deposit_i32 0 | ||
161 | #define TCG_TARGET_HAS_extract_i32 0 | ||
162 | #define TCG_TARGET_HAS_sextract_i32 0 | ||
163 | +#define TCG_TARGET_HAS_extract2_i32 0 | ||
164 | #define TCG_TARGET_HAS_movcond_i32 1 | ||
165 | #define TCG_TARGET_HAS_add2_i32 1 | ||
166 | #define TCG_TARGET_HAS_sub2_i32 1 | ||
167 | @@ -XXX,XX +XXX,XX @@ extern bool use_vis3_instructions; | ||
168 | #define TCG_TARGET_HAS_deposit_i64 0 | ||
169 | #define TCG_TARGET_HAS_extract_i64 0 | ||
170 | #define TCG_TARGET_HAS_sextract_i64 0 | ||
171 | +#define TCG_TARGET_HAS_extract2_i64 0 | ||
172 | #define TCG_TARGET_HAS_movcond_i64 1 | ||
173 | #define TCG_TARGET_HAS_add2_i64 1 | ||
174 | #define TCG_TARGET_HAS_sub2_i64 1 | ||
175 | diff --git a/tcg/tcg-opc.h b/tcg/tcg-opc.h | ||
176 | index XXXXXXX..XXXXXXX 100644 | ||
177 | --- a/tcg/tcg-opc.h | ||
178 | +++ b/tcg/tcg-opc.h | ||
179 | @@ -XXX,XX +XXX,XX @@ DEF(rotr_i32, 1, 2, 0, IMPL(TCG_TARGET_HAS_rot_i32)) | ||
180 | DEF(deposit_i32, 1, 2, 2, IMPL(TCG_TARGET_HAS_deposit_i32)) | ||
181 | DEF(extract_i32, 1, 1, 2, IMPL(TCG_TARGET_HAS_extract_i32)) | ||
182 | DEF(sextract_i32, 1, 1, 2, IMPL(TCG_TARGET_HAS_sextract_i32)) | ||
183 | +DEF(extract2_i32, 1, 2, 1, IMPL(TCG_TARGET_HAS_extract2_i32)) | ||
184 | |||
185 | DEF(brcond_i32, 0, 2, 2, TCG_OPF_BB_END) | ||
186 | |||
187 | @@ -XXX,XX +XXX,XX @@ DEF(rotr_i64, 1, 2, 0, IMPL64 | IMPL(TCG_TARGET_HAS_rot_i64)) | ||
188 | DEF(deposit_i64, 1, 2, 2, IMPL64 | IMPL(TCG_TARGET_HAS_deposit_i64)) | ||
189 | DEF(extract_i64, 1, 1, 2, IMPL64 | IMPL(TCG_TARGET_HAS_extract_i64)) | ||
190 | DEF(sextract_i64, 1, 1, 2, IMPL64 | IMPL(TCG_TARGET_HAS_sextract_i64)) | ||
191 | +DEF(extract2_i64, 1, 2, 1, IMPL64 | IMPL(TCG_TARGET_HAS_extract2_i64)) | ||
192 | |||
193 | /* size changing ops */ | ||
194 | DEF(ext_i32_i64, 1, 1, 0, IMPL64) | ||
195 | diff --git a/tcg/tcg.h b/tcg/tcg.h | ||
196 | index XXXXXXX..XXXXXXX 100644 | ||
197 | --- a/tcg/tcg.h | ||
198 | +++ b/tcg/tcg.h | ||
199 | @@ -XXX,XX +XXX,XX @@ typedef uint64_t TCGRegSet; | ||
200 | #define TCG_TARGET_HAS_deposit_i64 0 | ||
201 | #define TCG_TARGET_HAS_extract_i64 0 | ||
202 | #define TCG_TARGET_HAS_sextract_i64 0 | ||
203 | +#define TCG_TARGET_HAS_extract2_i64 0 | ||
204 | #define TCG_TARGET_HAS_movcond_i64 0 | ||
205 | #define TCG_TARGET_HAS_add2_i64 0 | ||
206 | #define TCG_TARGET_HAS_sub2_i64 0 | ||
207 | diff --git a/tcg/tci/tcg-target.h b/tcg/tci/tcg-target.h | ||
208 | index XXXXXXX..XXXXXXX 100644 | ||
209 | --- a/tcg/tci/tcg-target.h | ||
210 | +++ b/tcg/tci/tcg-target.h | ||
211 | @@ -XXX,XX +XXX,XX @@ | ||
212 | #define TCG_TARGET_HAS_deposit_i32 1 | ||
213 | #define TCG_TARGET_HAS_extract_i32 0 | ||
214 | #define TCG_TARGET_HAS_sextract_i32 0 | ||
215 | +#define TCG_TARGET_HAS_extract2_i32 0 | ||
216 | #define TCG_TARGET_HAS_eqv_i32 0 | ||
217 | #define TCG_TARGET_HAS_nand_i32 0 | ||
218 | #define TCG_TARGET_HAS_nor_i32 0 | ||
219 | @@ -XXX,XX +XXX,XX @@ | ||
220 | #define TCG_TARGET_HAS_deposit_i64 1 | ||
221 | #define TCG_TARGET_HAS_extract_i64 0 | ||
222 | #define TCG_TARGET_HAS_sextract_i64 0 | ||
223 | +#define TCG_TARGET_HAS_extract2_i64 0 | ||
224 | #define TCG_TARGET_HAS_div_i64 0 | ||
225 | #define TCG_TARGET_HAS_rem_i64 0 | ||
226 | #define TCG_TARGET_HAS_ext8s_i64 1 | ||
227 | diff --git a/tcg/optimize.c b/tcg/optimize.c | ||
228 | index XXXXXXX..XXXXXXX 100644 | ||
229 | --- a/tcg/optimize.c | ||
230 | +++ b/tcg/optimize.c | ||
231 | @@ -XXX,XX +XXX,XX @@ void tcg_optimize(TCGContext *s) | ||
232 | } | ||
233 | goto do_default; | ||
234 | |||
235 | + CASE_OP_32_64(extract2): | ||
236 | + if (arg_is_const(op->args[1]) && arg_is_const(op->args[2])) { | ||
237 | + TCGArg v1 = arg_info(op->args[1])->val; | ||
238 | + TCGArg v2 = arg_info(op->args[2])->val; | ||
239 | + | ||
240 | + if (opc == INDEX_op_extract2_i64) { | ||
241 | + tmp = (v1 >> op->args[3]) | (v2 << (64 - op->args[3])); | ||
242 | + } else { | ||
243 | + tmp = (v1 >> op->args[3]) | (v2 << (32 - op->args[3])); | ||
244 | + tmp = (int32_t)tmp; | ||
245 | + } | ||
246 | + tcg_opt_gen_movi(s, op, op->args[0], tmp); | ||
247 | + break; | ||
248 | + } | ||
249 | + goto do_default; | ||
250 | + | ||
251 | CASE_OP_32_64(setcond): | ||
252 | tmp = do_constant_folding_cond(opc, op->args[1], | ||
253 | op->args[2], op->args[3]); | ||
254 | diff --git a/tcg/tcg-op.c b/tcg/tcg-op.c | ||
255 | index XXXXXXX..XXXXXXX 100644 | ||
256 | --- a/tcg/tcg-op.c | ||
257 | +++ b/tcg/tcg-op.c | ||
258 | @@ -XXX,XX +XXX,XX @@ void tcg_gen_extract2_i32(TCGv_i32 ret, TCGv_i32 al, TCGv_i32 ah, | ||
259 | tcg_gen_mov_i32(ret, ah); | ||
260 | } else if (al == ah) { | ||
261 | tcg_gen_rotri_i32(ret, al, ofs); | ||
262 | + } else if (TCG_TARGET_HAS_extract2_i32) { | ||
263 | + tcg_gen_op4i_i32(INDEX_op_extract2_i32, ret, al, ah, ofs); | ||
264 | } else { | ||
265 | TCGv_i32 t0 = tcg_temp_new_i32(); | ||
266 | tcg_gen_shri_i32(t0, al, ofs); | ||
267 | @@ -XXX,XX +XXX,XX @@ void tcg_gen_extract2_i64(TCGv_i64 ret, TCGv_i64 al, TCGv_i64 ah, | ||
268 | tcg_gen_mov_i64(ret, ah); | ||
269 | } else if (al == ah) { | ||
270 | tcg_gen_rotri_i64(ret, al, ofs); | ||
271 | + } else if (TCG_TARGET_HAS_extract2_i64) { | ||
272 | + tcg_gen_op4i_i64(INDEX_op_extract2_i64, ret, al, ah, ofs); | ||
273 | } else { | ||
274 | TCGv_i64 t0 = tcg_temp_new_i64(); | ||
275 | tcg_gen_shri_i64(t0, al, ofs); | ||
276 | diff --git a/tcg/tcg.c b/tcg/tcg.c | ||
277 | index XXXXXXX..XXXXXXX 100644 | ||
278 | --- a/tcg/tcg.c | ||
279 | +++ b/tcg/tcg.c | ||
280 | @@ -XXX,XX +XXX,XX @@ bool tcg_op_supported(TCGOpcode op) | ||
281 | return TCG_TARGET_HAS_extract_i32; | ||
282 | case INDEX_op_sextract_i32: | ||
283 | return TCG_TARGET_HAS_sextract_i32; | ||
284 | + case INDEX_op_extract2_i32: | ||
285 | + return TCG_TARGET_HAS_extract2_i32; | ||
286 | case INDEX_op_add2_i32: | ||
287 | return TCG_TARGET_HAS_add2_i32; | ||
288 | case INDEX_op_sub2_i32: | ||
289 | @@ -XXX,XX +XXX,XX @@ bool tcg_op_supported(TCGOpcode op) | ||
290 | return TCG_TARGET_HAS_extract_i64; | ||
291 | case INDEX_op_sextract_i64: | ||
292 | return TCG_TARGET_HAS_sextract_i64; | ||
293 | + case INDEX_op_extract2_i64: | ||
294 | + return TCG_TARGET_HAS_extract2_i64; | ||
295 | case INDEX_op_extrl_i64_i32: | ||
296 | return TCG_TARGET_HAS_extrl_i64_i32; | ||
297 | case INDEX_op_extrh_i64_i32: | ||
298 | diff --git a/tcg/README b/tcg/README | ||
299 | index XXXXXXX..XXXXXXX 100644 | ||
300 | --- a/tcg/README | ||
301 | +++ b/tcg/README | ||
302 | @@ -XXX,XX +XXX,XX @@ at bit 8. This operation would be equivalent to | ||
303 | |||
304 | (using an arithmetic right shift). | ||
305 | |||
306 | +* extract2_i32/i64 dest, t1, t2, pos | ||
307 | + | ||
308 | +For N = {32,64}, extract an N-bit quantity from the concatenation | ||
309 | +of t2:t1, beginning at pos. The tcg_gen_extract2_{i32,i64} expander | ||
310 | +accepts 0 <= pos <= N as inputs. The backend code generator will | ||
311 | +not see either 0 or N as inputs for these opcodes. | ||
312 | + | ||
313 | * extrl_i64_i32 t0, t1 | ||
314 | |||
315 | For 64-bit hosts only, extract the low 32-bits of input T1 and place it | ||
316 | -- | ||
317 | 2.17.1 | ||
318 | |||
319 | diff view generated by jsdifflib |
Deleted patch | |||
---|---|---|---|
1 | Signed-off-by: Richard Henderson <richard.henderson@linaro.org> | ||
2 | --- | ||
3 | tcg/tcg-op.c | 47 ++++++++++++++++++++++++----------------------- | ||
4 | 1 file changed, 24 insertions(+), 23 deletions(-) | ||
5 | 1 | ||
6 | diff --git a/tcg/tcg-op.c b/tcg/tcg-op.c | ||
7 | index XXXXXXX..XXXXXXX 100644 | ||
8 | --- a/tcg/tcg-op.c | ||
9 | +++ b/tcg/tcg-op.c | ||
10 | @@ -XXX,XX +XXX,XX @@ static inline void tcg_gen_shifti_i64(TCGv_i64 ret, TCGv_i64 arg1, | ||
11 | tcg_gen_shli_i32(TCGV_HIGH(ret), TCGV_LOW(arg1), c); | ||
12 | tcg_gen_movi_i32(TCGV_LOW(ret), 0); | ||
13 | } | ||
14 | - } else { | ||
15 | - TCGv_i32 t0, t1; | ||
16 | - | ||
17 | - t0 = tcg_temp_new_i32(); | ||
18 | - t1 = tcg_temp_new_i32(); | ||
19 | - if (right) { | ||
20 | - tcg_gen_shli_i32(t0, TCGV_HIGH(arg1), 32 - c); | ||
21 | - if (arith) { | ||
22 | - tcg_gen_sari_i32(t1, TCGV_HIGH(arg1), c); | ||
23 | - } else { | ||
24 | - tcg_gen_shri_i32(t1, TCGV_HIGH(arg1), c); | ||
25 | - } | ||
26 | - tcg_gen_shri_i32(TCGV_LOW(ret), TCGV_LOW(arg1), c); | ||
27 | - tcg_gen_or_i32(TCGV_LOW(ret), TCGV_LOW(ret), t0); | ||
28 | - tcg_gen_mov_i32(TCGV_HIGH(ret), t1); | ||
29 | + } else if (right) { | ||
30 | + if (TCG_TARGET_HAS_extract2_i32) { | ||
31 | + tcg_gen_extract2_i32(TCGV_LOW(ret), | ||
32 | + TCGV_LOW(arg1), TCGV_HIGH(arg1), c); | ||
33 | } else { | ||
34 | - tcg_gen_shri_i32(t0, TCGV_LOW(arg1), 32 - c); | ||
35 | - /* Note: ret can be the same as arg1, so we use t1 */ | ||
36 | - tcg_gen_shli_i32(t1, TCGV_LOW(arg1), c); | ||
37 | - tcg_gen_shli_i32(TCGV_HIGH(ret), TCGV_HIGH(arg1), c); | ||
38 | - tcg_gen_or_i32(TCGV_HIGH(ret), TCGV_HIGH(ret), t0); | ||
39 | - tcg_gen_mov_i32(TCGV_LOW(ret), t1); | ||
40 | + tcg_gen_shri_i32(TCGV_LOW(ret), TCGV_LOW(arg1), c); | ||
41 | + tcg_gen_deposit_i32(TCGV_LOW(ret), TCGV_LOW(ret), | ||
42 | + TCGV_HIGH(arg1), 32 - c, c); | ||
43 | } | ||
44 | - tcg_temp_free_i32(t0); | ||
45 | - tcg_temp_free_i32(t1); | ||
46 | + if (arith) { | ||
47 | + tcg_gen_sari_i32(TCGV_HIGH(ret), TCGV_HIGH(arg1), c); | ||
48 | + } else { | ||
49 | + tcg_gen_shri_i32(TCGV_HIGH(ret), TCGV_HIGH(arg1), c); | ||
50 | + } | ||
51 | + } else { | ||
52 | + if (TCG_TARGET_HAS_extract2_i32) { | ||
53 | + tcg_gen_extract2_i32(TCGV_HIGH(ret), | ||
54 | + TCGV_LOW(arg1), TCGV_HIGH(arg1), 32 - c); | ||
55 | + } else { | ||
56 | + TCGv_i32 t0 = tcg_temp_new_i32(); | ||
57 | + tcg_gen_shri_i32(t0, TCGV_LOW(arg1), 32 - c); | ||
58 | + tcg_gen_deposit_i32(TCGV_HIGH(ret), t0, | ||
59 | + TCGV_HIGH(arg1), c, 32 - c); | ||
60 | + tcg_temp_free_i32(t0); | ||
61 | + } | ||
62 | + tcg_gen_shli_i32(TCGV_LOW(ret), TCGV_LOW(arg1), c); | ||
63 | } | ||
64 | } | ||
65 | |||
66 | -- | ||
67 | 2.17.1 | ||
68 | |||
69 | diff view generated by jsdifflib |
Deleted patch | |||
---|---|---|---|
1 | Signed-off-by: Richard Henderson <richard.henderson@linaro.org> | ||
2 | --- | ||
3 | tcg/tcg-op.c | 34 ++++++++++++++++++++++++++++++---- | ||
4 | 1 file changed, 30 insertions(+), 4 deletions(-) | ||
5 | 1 | ||
6 | diff --git a/tcg/tcg-op.c b/tcg/tcg-op.c | ||
7 | index XXXXXXX..XXXXXXX 100644 | ||
8 | --- a/tcg/tcg-op.c | ||
9 | +++ b/tcg/tcg-op.c | ||
10 | @@ -XXX,XX +XXX,XX @@ void tcg_gen_deposit_i32(TCGv_i32 ret, TCGv_i32 arg1, TCGv_i32 arg2, | ||
11 | return; | ||
12 | } | ||
13 | |||
14 | - mask = (1u << len) - 1; | ||
15 | t1 = tcg_temp_new_i32(); | ||
16 | |||
17 | + if (TCG_TARGET_HAS_extract2_i32) { | ||
18 | + if (ofs + len == 32) { | ||
19 | + tcg_gen_shli_i32(t1, arg1, len); | ||
20 | + tcg_gen_extract2_i32(ret, t1, arg2, len); | ||
21 | + goto done; | ||
22 | + } | ||
23 | + if (ofs == 0) { | ||
24 | + tcg_gen_extract2_i32(ret, arg1, arg2, len); | ||
25 | + tcg_gen_rotli_i32(ret, ret, len); | ||
26 | + goto done; | ||
27 | + } | ||
28 | + } | ||
29 | + | ||
30 | + mask = (1u << len) - 1; | ||
31 | if (ofs + len < 32) { | ||
32 | tcg_gen_andi_i32(t1, arg2, mask); | ||
33 | tcg_gen_shli_i32(t1, t1, ofs); | ||
34 | @@ -XXX,XX +XXX,XX @@ void tcg_gen_deposit_i32(TCGv_i32 ret, TCGv_i32 arg1, TCGv_i32 arg2, | ||
35 | } | ||
36 | tcg_gen_andi_i32(ret, arg1, ~(mask << ofs)); | ||
37 | tcg_gen_or_i32(ret, ret, t1); | ||
38 | - | ||
39 | + done: | ||
40 | tcg_temp_free_i32(t1); | ||
41 | } | ||
42 | |||
43 | @@ -XXX,XX +XXX,XX @@ void tcg_gen_deposit_i64(TCGv_i64 ret, TCGv_i64 arg1, TCGv_i64 arg2, | ||
44 | } | ||
45 | } | ||
46 | |||
47 | - mask = (1ull << len) - 1; | ||
48 | t1 = tcg_temp_new_i64(); | ||
49 | |||
50 | + if (TCG_TARGET_HAS_extract2_i64) { | ||
51 | + if (ofs + len == 64) { | ||
52 | + tcg_gen_shli_i64(t1, arg1, len); | ||
53 | + tcg_gen_extract2_i64(ret, t1, arg2, len); | ||
54 | + goto done; | ||
55 | + } | ||
56 | + if (ofs == 0) { | ||
57 | + tcg_gen_extract2_i64(ret, arg1, arg2, len); | ||
58 | + tcg_gen_rotli_i64(ret, ret, len); | ||
59 | + goto done; | ||
60 | + } | ||
61 | + } | ||
62 | + | ||
63 | + mask = (1ull << len) - 1; | ||
64 | if (ofs + len < 64) { | ||
65 | tcg_gen_andi_i64(t1, arg2, mask); | ||
66 | tcg_gen_shli_i64(t1, t1, ofs); | ||
67 | @@ -XXX,XX +XXX,XX @@ void tcg_gen_deposit_i64(TCGv_i64 ret, TCGv_i64 arg1, TCGv_i64 arg2, | ||
68 | } | ||
69 | tcg_gen_andi_i64(ret, arg1, ~(mask << ofs)); | ||
70 | tcg_gen_or_i64(ret, ret, t1); | ||
71 | - | ||
72 | + done: | ||
73 | tcg_temp_free_i64(t1); | ||
74 | } | ||
75 | |||
76 | -- | ||
77 | 2.17.1 | ||
78 | |||
79 | diff view generated by jsdifflib |
Deleted patch | |||
---|---|---|---|
1 | Signed-off-by: Richard Henderson <richard.henderson@linaro.org> | ||
2 | --- | ||
3 | tcg/i386/tcg-target.h | 4 ++-- | ||
4 | tcg/i386/tcg-target.inc.c | 11 +++++++++++ | ||
5 | 2 files changed, 13 insertions(+), 2 deletions(-) | ||
6 | 1 | ||
7 | diff --git a/tcg/i386/tcg-target.h b/tcg/i386/tcg-target.h | ||
8 | index XXXXXXX..XXXXXXX 100644 | ||
9 | --- a/tcg/i386/tcg-target.h | ||
10 | +++ b/tcg/i386/tcg-target.h | ||
11 | @@ -XXX,XX +XXX,XX @@ extern bool have_avx2; | ||
12 | #define TCG_TARGET_HAS_deposit_i32 1 | ||
13 | #define TCG_TARGET_HAS_extract_i32 1 | ||
14 | #define TCG_TARGET_HAS_sextract_i32 1 | ||
15 | -#define TCG_TARGET_HAS_extract2_i32 0 | ||
16 | +#define TCG_TARGET_HAS_extract2_i32 1 | ||
17 | #define TCG_TARGET_HAS_movcond_i32 1 | ||
18 | #define TCG_TARGET_HAS_add2_i32 1 | ||
19 | #define TCG_TARGET_HAS_sub2_i32 1 | ||
20 | @@ -XXX,XX +XXX,XX @@ extern bool have_avx2; | ||
21 | #define TCG_TARGET_HAS_deposit_i64 1 | ||
22 | #define TCG_TARGET_HAS_extract_i64 1 | ||
23 | #define TCG_TARGET_HAS_sextract_i64 0 | ||
24 | -#define TCG_TARGET_HAS_extract2_i64 0 | ||
25 | +#define TCG_TARGET_HAS_extract2_i64 1 | ||
26 | #define TCG_TARGET_HAS_movcond_i64 1 | ||
27 | #define TCG_TARGET_HAS_add2_i64 1 | ||
28 | #define TCG_TARGET_HAS_sub2_i64 1 | ||
29 | diff --git a/tcg/i386/tcg-target.inc.c b/tcg/i386/tcg-target.inc.c | ||
30 | index XXXXXXX..XXXXXXX 100644 | ||
31 | --- a/tcg/i386/tcg-target.inc.c | ||
32 | +++ b/tcg/i386/tcg-target.inc.c | ||
33 | @@ -XXX,XX +XXX,XX @@ static inline int tcg_target_const_match(tcg_target_long val, TCGType type, | ||
34 | #define OPC_SHUFPS (0xc6 | P_EXT) | ||
35 | #define OPC_SHLX (0xf7 | P_EXT38 | P_DATA16) | ||
36 | #define OPC_SHRX (0xf7 | P_EXT38 | P_SIMDF2) | ||
37 | +#define OPC_SHRD_Ib (0xac | P_EXT) | ||
38 | #define OPC_TESTL (0x85) | ||
39 | #define OPC_TZCNT (0xbc | P_EXT | P_SIMDF3) | ||
40 | #define OPC_UD2 (0x0b | P_EXT) | ||
41 | @@ -XXX,XX +XXX,XX @@ static inline void tcg_out_op(TCGContext *s, TCGOpcode opc, | ||
42 | } | ||
43 | break; | ||
44 | |||
45 | + OP_32_64(extract2): | ||
46 | + /* Note that SHRD outputs to the r/m operand. */ | ||
47 | + tcg_out_modrm(s, OPC_SHRD_Ib + rexw, a2, a0); | ||
48 | + tcg_out8(s, args[3]); | ||
49 | + break; | ||
50 | + | ||
51 | case INDEX_op_mb: | ||
52 | tcg_out_mb(s, a0); | ||
53 | break; | ||
54 | @@ -XXX,XX +XXX,XX @@ static const TCGTargetOpDef *tcg_target_op_def(TCGOpcode op) | ||
55 | static const TCGTargetOpDef r_0 = { .args_ct_str = { "r", "0" } }; | ||
56 | static const TCGTargetOpDef r_r_ri = { .args_ct_str = { "r", "r", "ri" } }; | ||
57 | static const TCGTargetOpDef r_r_re = { .args_ct_str = { "r", "r", "re" } }; | ||
58 | + static const TCGTargetOpDef r_0_r = { .args_ct_str = { "r", "0", "r" } }; | ||
59 | static const TCGTargetOpDef r_0_re = { .args_ct_str = { "r", "0", "re" } }; | ||
60 | static const TCGTargetOpDef r_0_ci = { .args_ct_str = { "r", "0", "ci" } }; | ||
61 | static const TCGTargetOpDef r_L = { .args_ct_str = { "r", "L" } }; | ||
62 | @@ -XXX,XX +XXX,XX @@ static const TCGTargetOpDef *tcg_target_op_def(TCGOpcode op) | ||
63 | case INDEX_op_ctpop_i32: | ||
64 | case INDEX_op_ctpop_i64: | ||
65 | return &r_r; | ||
66 | + case INDEX_op_extract2_i32: | ||
67 | + case INDEX_op_extract2_i64: | ||
68 | + return &r_0_r; | ||
69 | |||
70 | case INDEX_op_deposit_i32: | ||
71 | case INDEX_op_deposit_i64: | ||
72 | -- | ||
73 | 2.17.1 | ||
74 | |||
75 | diff view generated by jsdifflib |
Deleted patch | |||
---|---|---|---|
1 | Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org> | ||
2 | Signed-off-by: Richard Henderson <richard.henderson@linaro.org> | ||
3 | --- | ||
4 | tcg/arm/tcg-target.h | 2 +- | ||
5 | tcg/arm/tcg-target.inc.c | 25 +++++++++++++++++++++++++ | ||
6 | 2 files changed, 26 insertions(+), 1 deletion(-) | ||
7 | 1 | ||
8 | diff --git a/tcg/arm/tcg-target.h b/tcg/arm/tcg-target.h | ||
9 | index XXXXXXX..XXXXXXX 100644 | ||
10 | --- a/tcg/arm/tcg-target.h | ||
11 | +++ b/tcg/arm/tcg-target.h | ||
12 | @@ -XXX,XX +XXX,XX @@ extern bool use_idiv_instructions; | ||
13 | #define TCG_TARGET_HAS_deposit_i32 use_armv7_instructions | ||
14 | #define TCG_TARGET_HAS_extract_i32 use_armv7_instructions | ||
15 | #define TCG_TARGET_HAS_sextract_i32 use_armv7_instructions | ||
16 | -#define TCG_TARGET_HAS_extract2_i32 0 | ||
17 | +#define TCG_TARGET_HAS_extract2_i32 1 | ||
18 | #define TCG_TARGET_HAS_movcond_i32 1 | ||
19 | #define TCG_TARGET_HAS_mulu2_i32 1 | ||
20 | #define TCG_TARGET_HAS_muls2_i32 1 | ||
21 | diff --git a/tcg/arm/tcg-target.inc.c b/tcg/arm/tcg-target.inc.c | ||
22 | index XXXXXXX..XXXXXXX 100644 | ||
23 | --- a/tcg/arm/tcg-target.inc.c | ||
24 | +++ b/tcg/arm/tcg-target.inc.c | ||
25 | @@ -XXX,XX +XXX,XX @@ static inline void tcg_out_op(TCGContext *s, TCGOpcode opc, | ||
26 | case INDEX_op_sextract_i32: | ||
27 | tcg_out_sextract(s, COND_AL, args[0], args[1], args[2], args[3]); | ||
28 | break; | ||
29 | + case INDEX_op_extract2_i32: | ||
30 | + /* ??? These optimization vs zero should be generic. */ | ||
31 | + /* ??? But we can't substitute 2 for 1 in the opcode stream yet. */ | ||
32 | + if (const_args[1]) { | ||
33 | + if (const_args[2]) { | ||
34 | + tcg_out_movi(s, TCG_TYPE_REG, args[0], 0); | ||
35 | + } else { | ||
36 | + tcg_out_dat_reg(s, COND_AL, ARITH_MOV, args[0], 0, | ||
37 | + args[2], SHIFT_IMM_LSL(32 - args[3])); | ||
38 | + } | ||
39 | + } else if (const_args[2]) { | ||
40 | + tcg_out_dat_reg(s, COND_AL, ARITH_MOV, args[0], 0, | ||
41 | + args[1], SHIFT_IMM_LSR(args[3])); | ||
42 | + } else { | ||
43 | + /* We can do extract2 in 2 insns, vs the 3 required otherwise. */ | ||
44 | + tcg_out_dat_reg(s, COND_AL, ARITH_MOV, TCG_REG_TMP, 0, | ||
45 | + args[2], SHIFT_IMM_LSL(32 - args[3])); | ||
46 | + tcg_out_dat_reg(s, COND_AL, ARITH_ORR, args[0], TCG_REG_TMP, | ||
47 | + args[1], SHIFT_IMM_LSR(args[3])); | ||
48 | + } | ||
49 | + break; | ||
50 | |||
51 | case INDEX_op_div_i32: | ||
52 | tcg_out_sdiv(s, COND_AL, args[0], args[1], args[2]); | ||
53 | @@ -XXX,XX +XXX,XX @@ static const TCGTargetOpDef *tcg_target_op_def(TCGOpcode op) | ||
54 | = { .args_ct_str = { "s", "s", "s", "s" } }; | ||
55 | static const TCGTargetOpDef br | ||
56 | = { .args_ct_str = { "r", "rIN" } }; | ||
57 | + static const TCGTargetOpDef ext2 | ||
58 | + = { .args_ct_str = { "r", "rZ", "rZ" } }; | ||
59 | static const TCGTargetOpDef dep | ||
60 | = { .args_ct_str = { "r", "0", "rZ" } }; | ||
61 | static const TCGTargetOpDef movc | ||
62 | @@ -XXX,XX +XXX,XX @@ static const TCGTargetOpDef *tcg_target_op_def(TCGOpcode op) | ||
63 | return &br; | ||
64 | case INDEX_op_deposit_i32: | ||
65 | return &dep; | ||
66 | + case INDEX_op_extract2_i32: | ||
67 | + return &ext2; | ||
68 | case INDEX_op_movcond_i32: | ||
69 | return &movc; | ||
70 | case INDEX_op_add2_i32: | ||
71 | -- | ||
72 | 2.17.1 | ||
73 | |||
74 | diff view generated by jsdifflib |
Deleted patch | |||
---|---|---|---|
1 | Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org> | ||
2 | Signed-off-by: Richard Henderson <richard.henderson@linaro.org> | ||
3 | --- | ||
4 | tcg/aarch64/tcg-target.h | 4 ++-- | ||
5 | tcg/aarch64/tcg-target.inc.c | 11 +++++++++++ | ||
6 | 2 files changed, 13 insertions(+), 2 deletions(-) | ||
7 | 1 | ||
8 | diff --git a/tcg/aarch64/tcg-target.h b/tcg/aarch64/tcg-target.h | ||
9 | index XXXXXXX..XXXXXXX 100644 | ||
10 | --- a/tcg/aarch64/tcg-target.h | ||
11 | +++ b/tcg/aarch64/tcg-target.h | ||
12 | @@ -XXX,XX +XXX,XX @@ typedef enum { | ||
13 | #define TCG_TARGET_HAS_deposit_i32 1 | ||
14 | #define TCG_TARGET_HAS_extract_i32 1 | ||
15 | #define TCG_TARGET_HAS_sextract_i32 1 | ||
16 | -#define TCG_TARGET_HAS_extract2_i32 0 | ||
17 | +#define TCG_TARGET_HAS_extract2_i32 1 | ||
18 | #define TCG_TARGET_HAS_movcond_i32 1 | ||
19 | #define TCG_TARGET_HAS_add2_i32 1 | ||
20 | #define TCG_TARGET_HAS_sub2_i32 1 | ||
21 | @@ -XXX,XX +XXX,XX @@ typedef enum { | ||
22 | #define TCG_TARGET_HAS_deposit_i64 1 | ||
23 | #define TCG_TARGET_HAS_extract_i64 1 | ||
24 | #define TCG_TARGET_HAS_sextract_i64 1 | ||
25 | -#define TCG_TARGET_HAS_extract2_i64 0 | ||
26 | +#define TCG_TARGET_HAS_extract2_i64 1 | ||
27 | #define TCG_TARGET_HAS_movcond_i64 1 | ||
28 | #define TCG_TARGET_HAS_add2_i64 1 | ||
29 | #define TCG_TARGET_HAS_sub2_i64 1 | ||
30 | diff --git a/tcg/aarch64/tcg-target.inc.c b/tcg/aarch64/tcg-target.inc.c | ||
31 | index XXXXXXX..XXXXXXX 100644 | ||
32 | --- a/tcg/aarch64/tcg-target.inc.c | ||
33 | +++ b/tcg/aarch64/tcg-target.inc.c | ||
34 | @@ -XXX,XX +XXX,XX @@ static void tcg_out_op(TCGContext *s, TCGOpcode opc, | ||
35 | tcg_out_sbfm(s, ext, a0, a1, a2, a2 + args[3] - 1); | ||
36 | break; | ||
37 | |||
38 | + case INDEX_op_extract2_i64: | ||
39 | + case INDEX_op_extract2_i32: | ||
40 | + tcg_out_extr(s, ext, a0, a1, a2, args[3]); | ||
41 | + break; | ||
42 | + | ||
43 | case INDEX_op_add2_i32: | ||
44 | tcg_out_addsub2(s, TCG_TYPE_I32, a0, a1, REG0(2), REG0(3), | ||
45 | (int32_t)args[4], args[5], const_args[4], | ||
46 | @@ -XXX,XX +XXX,XX @@ static const TCGTargetOpDef *tcg_target_op_def(TCGOpcode op) | ||
47 | = { .args_ct_str = { "r", "r", "rAL" } }; | ||
48 | static const TCGTargetOpDef dep | ||
49 | = { .args_ct_str = { "r", "0", "rZ" } }; | ||
50 | + static const TCGTargetOpDef ext2 | ||
51 | + = { .args_ct_str = { "r", "rZ", "rZ" } }; | ||
52 | static const TCGTargetOpDef movc | ||
53 | = { .args_ct_str = { "r", "r", "rA", "rZ", "rZ" } }; | ||
54 | static const TCGTargetOpDef add2 | ||
55 | @@ -XXX,XX +XXX,XX @@ static const TCGTargetOpDef *tcg_target_op_def(TCGOpcode op) | ||
56 | case INDEX_op_deposit_i64: | ||
57 | return &dep; | ||
58 | |||
59 | + case INDEX_op_extract2_i32: | ||
60 | + case INDEX_op_extract2_i64: | ||
61 | + return &ext2; | ||
62 | + | ||
63 | case INDEX_op_add2_i32: | ||
64 | case INDEX_op_add2_i64: | ||
65 | case INDEX_op_sub2_i32: | ||
66 | -- | ||
67 | 2.17.1 | ||
68 | |||
69 | diff view generated by jsdifflib |
Deleted patch | |||
---|---|---|---|
1 | In order to handle TB's that translate to too much code, we | ||
2 | need to place the control of the length of the translation | ||
3 | in the hands of the code gen master loop. | ||
4 | 1 | ||
5 | Reviewed-by: Alistair Francis <alistair.francis@wdc.com> | ||
6 | Reviewed-by: Philippe Mathieu-Daudé <philmd@redhat.com> | ||
7 | Signed-off-by: Richard Henderson <richard.henderson@linaro.org> | ||
8 | --- | ||
9 | include/exec/exec-all.h | 4 ++-- | ||
10 | include/exec/translator.h | 3 ++- | ||
11 | accel/tcg/translate-all.c | 15 +++++++++++++-- | ||
12 | accel/tcg/translator.c | 15 ++------------- | ||
13 | target/alpha/translate.c | 4 ++-- | ||
14 | target/arm/translate.c | 4 ++-- | ||
15 | target/cris/translate.c | 10 +--------- | ||
16 | target/hppa/translate.c | 5 ++--- | ||
17 | target/i386/translate.c | 4 ++-- | ||
18 | target/lm32/translate.c | 10 +--------- | ||
19 | target/m68k/translate.c | 4 ++-- | ||
20 | target/microblaze/translate.c | 10 +--------- | ||
21 | target/mips/translate.c | 4 ++-- | ||
22 | target/moxie/translate.c | 11 ++--------- | ||
23 | target/nios2/translate.c | 14 ++------------ | ||
24 | target/openrisc/translate.c | 4 ++-- | ||
25 | target/ppc/translate.c | 4 ++-- | ||
26 | target/riscv/translate.c | 4 ++-- | ||
27 | target/s390x/translate.c | 4 ++-- | ||
28 | target/sh4/translate.c | 4 ++-- | ||
29 | target/sparc/translate.c | 4 ++-- | ||
30 | target/tilegx/translate.c | 12 +----------- | ||
31 | target/tricore/translate.c | 16 ++-------------- | ||
32 | target/unicore32/translate.c | 10 +--------- | ||
33 | target/xtensa/translate.c | 4 ++-- | ||
34 | 25 files changed, 56 insertions(+), 127 deletions(-) | ||
35 | |||
36 | diff --git a/include/exec/exec-all.h b/include/exec/exec-all.h | ||
37 | index XXXXXXX..XXXXXXX 100644 | ||
38 | --- a/include/exec/exec-all.h | ||
39 | +++ b/include/exec/exec-all.h | ||
40 | @@ -XXX,XX +XXX,XX @@ typedef ram_addr_t tb_page_addr_t; | ||
41 | |||
42 | #include "qemu/log.h" | ||
43 | |||
44 | -void gen_intermediate_code(CPUState *cpu, struct TranslationBlock *tb); | ||
45 | -void restore_state_to_opc(CPUArchState *env, struct TranslationBlock *tb, | ||
46 | +void gen_intermediate_code(CPUState *cpu, TranslationBlock *tb, int max_insns); | ||
47 | +void restore_state_to_opc(CPUArchState *env, TranslationBlock *tb, | ||
48 | target_ulong *data); | ||
49 | |||
50 | void cpu_gen_init(void); | ||
51 | diff --git a/include/exec/translator.h b/include/exec/translator.h | ||
52 | index XXXXXXX..XXXXXXX 100644 | ||
53 | --- a/include/exec/translator.h | ||
54 | +++ b/include/exec/translator.h | ||
55 | @@ -XXX,XX +XXX,XX @@ typedef struct TranslatorOps { | ||
56 | * @db: Disassembly context. | ||
57 | * @cpu: Target vCPU. | ||
58 | * @tb: Translation block. | ||
59 | + * @max_insns: Maximum number of insns to translate. | ||
60 | * | ||
61 | * Generic translator loop. | ||
62 | * | ||
63 | @@ -XXX,XX +XXX,XX @@ typedef struct TranslatorOps { | ||
64 | * - When too many instructions have been translated. | ||
65 | */ | ||
66 | void translator_loop(const TranslatorOps *ops, DisasContextBase *db, | ||
67 | - CPUState *cpu, TranslationBlock *tb); | ||
68 | + CPUState *cpu, TranslationBlock *tb, int max_insns); | ||
69 | |||
70 | void translator_loop_temp_check(DisasContextBase *db); | ||
71 | |||
72 | diff --git a/accel/tcg/translate-all.c b/accel/tcg/translate-all.c | ||
73 | index XXXXXXX..XXXXXXX 100644 | ||
74 | --- a/accel/tcg/translate-all.c | ||
75 | +++ b/accel/tcg/translate-all.c | ||
76 | @@ -XXX,XX +XXX,XX @@ TranslationBlock *tb_gen_code(CPUState *cpu, | ||
77 | tb_page_addr_t phys_pc, phys_page2; | ||
78 | target_ulong virt_page2; | ||
79 | tcg_insn_unit *gen_code_buf; | ||
80 | - int gen_code_size, search_size; | ||
81 | + int gen_code_size, search_size, max_insns; | ||
82 | #ifdef CONFIG_PROFILER | ||
83 | TCGProfile *prof = &tcg_ctx->prof; | ||
84 | int64_t ti; | ||
85 | @@ -XXX,XX +XXX,XX @@ TranslationBlock *tb_gen_code(CPUState *cpu, | ||
86 | cflags &= ~CF_CLUSTER_MASK; | ||
87 | cflags |= cpu->cluster_index << CF_CLUSTER_SHIFT; | ||
88 | |||
89 | + max_insns = cflags & CF_COUNT_MASK; | ||
90 | + if (max_insns == 0) { | ||
91 | + max_insns = CF_COUNT_MASK; | ||
92 | + } | ||
93 | + if (max_insns > TCG_MAX_INSNS) { | ||
94 | + max_insns = TCG_MAX_INSNS; | ||
95 | + } | ||
96 | + if (cpu->singlestep_enabled || singlestep) { | ||
97 | + max_insns = 1; | ||
98 | + } | ||
99 | + | ||
100 | buffer_overflow: | ||
101 | tb = tb_alloc(pc); | ||
102 | if (unlikely(!tb)) { | ||
103 | @@ -XXX,XX +XXX,XX @@ TranslationBlock *tb_gen_code(CPUState *cpu, | ||
104 | tcg_func_start(tcg_ctx); | ||
105 | |||
106 | tcg_ctx->cpu = ENV_GET_CPU(env); | ||
107 | - gen_intermediate_code(cpu, tb); | ||
108 | + gen_intermediate_code(cpu, tb, max_insns); | ||
109 | tcg_ctx->cpu = NULL; | ||
110 | |||
111 | trace_translate_block(tb, tb->pc, tb->tc.ptr); | ||
112 | diff --git a/accel/tcg/translator.c b/accel/tcg/translator.c | ||
113 | index XXXXXXX..XXXXXXX 100644 | ||
114 | --- a/accel/tcg/translator.c | ||
115 | +++ b/accel/tcg/translator.c | ||
116 | @@ -XXX,XX +XXX,XX @@ void translator_loop_temp_check(DisasContextBase *db) | ||
117 | } | ||
118 | |||
119 | void translator_loop(const TranslatorOps *ops, DisasContextBase *db, | ||
120 | - CPUState *cpu, TranslationBlock *tb) | ||
121 | + CPUState *cpu, TranslationBlock *tb, int max_insns) | ||
122 | { | ||
123 | int bp_insn = 0; | ||
124 | |||
125 | @@ -XXX,XX +XXX,XX @@ void translator_loop(const TranslatorOps *ops, DisasContextBase *db, | ||
126 | db->pc_next = db->pc_first; | ||
127 | db->is_jmp = DISAS_NEXT; | ||
128 | db->num_insns = 0; | ||
129 | + db->max_insns = max_insns; | ||
130 | db->singlestep_enabled = cpu->singlestep_enabled; | ||
131 | |||
132 | - /* Instruction counting */ | ||
133 | - db->max_insns = tb_cflags(db->tb) & CF_COUNT_MASK; | ||
134 | - if (db->max_insns == 0) { | ||
135 | - db->max_insns = CF_COUNT_MASK; | ||
136 | - } | ||
137 | - if (db->max_insns > TCG_MAX_INSNS) { | ||
138 | - db->max_insns = TCG_MAX_INSNS; | ||
139 | - } | ||
140 | - if (db->singlestep_enabled || singlestep) { | ||
141 | - db->max_insns = 1; | ||
142 | - } | ||
143 | - | ||
144 | ops->init_disas_context(db, cpu); | ||
145 | tcg_debug_assert(db->is_jmp == DISAS_NEXT); /* no early exit */ | ||
146 | |||
147 | diff --git a/target/alpha/translate.c b/target/alpha/translate.c | ||
148 | index XXXXXXX..XXXXXXX 100644 | ||
149 | --- a/target/alpha/translate.c | ||
150 | +++ b/target/alpha/translate.c | ||
151 | @@ -XXX,XX +XXX,XX @@ static const TranslatorOps alpha_tr_ops = { | ||
152 | .disas_log = alpha_tr_disas_log, | ||
153 | }; | ||
154 | |||
155 | -void gen_intermediate_code(CPUState *cpu, TranslationBlock *tb) | ||
156 | +void gen_intermediate_code(CPUState *cpu, TranslationBlock *tb, int max_insns) | ||
157 | { | ||
158 | DisasContext dc; | ||
159 | - translator_loop(&alpha_tr_ops, &dc.base, cpu, tb); | ||
160 | + translator_loop(&alpha_tr_ops, &dc.base, cpu, tb, max_insns); | ||
161 | } | ||
162 | |||
163 | void restore_state_to_opc(CPUAlphaState *env, TranslationBlock *tb, | ||
164 | diff --git a/target/arm/translate.c b/target/arm/translate.c | ||
165 | index XXXXXXX..XXXXXXX 100644 | ||
166 | --- a/target/arm/translate.c | ||
167 | +++ b/target/arm/translate.c | ||
168 | @@ -XXX,XX +XXX,XX @@ static const TranslatorOps thumb_translator_ops = { | ||
169 | }; | ||
170 | |||
171 | /* generate intermediate code for basic block 'tb'. */ | ||
172 | -void gen_intermediate_code(CPUState *cpu, TranslationBlock *tb) | ||
173 | +void gen_intermediate_code(CPUState *cpu, TranslationBlock *tb, int max_insns) | ||
174 | { | ||
175 | DisasContext dc; | ||
176 | const TranslatorOps *ops = &arm_translator_ops; | ||
177 | @@ -XXX,XX +XXX,XX @@ void gen_intermediate_code(CPUState *cpu, TranslationBlock *tb) | ||
178 | } | ||
179 | #endif | ||
180 | |||
181 | - translator_loop(ops, &dc.base, cpu, tb); | ||
182 | + translator_loop(ops, &dc.base, cpu, tb, max_insns); | ||
183 | } | ||
184 | |||
185 | void arm_cpu_dump_state(CPUState *cs, FILE *f, int flags) | ||
186 | diff --git a/target/cris/translate.c b/target/cris/translate.c | ||
187 | index XXXXXXX..XXXXXXX 100644 | ||
188 | --- a/target/cris/translate.c | ||
189 | +++ b/target/cris/translate.c | ||
190 | @@ -XXX,XX +XXX,XX @@ static unsigned int crisv32_decoder(CPUCRISState *env, DisasContext *dc) | ||
191 | */ | ||
192 | |||
193 | /* generate intermediate code for basic block 'tb'. */ | ||
194 | -void gen_intermediate_code(CPUState *cs, struct TranslationBlock *tb) | ||
195 | +void gen_intermediate_code(CPUState *cs, TranslationBlock *tb, int max_insns) | ||
196 | { | ||
197 | CPUCRISState *env = cs->env_ptr; | ||
198 | uint32_t pc_start; | ||
199 | @@ -XXX,XX +XXX,XX @@ void gen_intermediate_code(CPUState *cs, struct TranslationBlock *tb) | ||
200 | uint32_t page_start; | ||
201 | target_ulong npc; | ||
202 | int num_insns; | ||
203 | - int max_insns; | ||
204 | |||
205 | if (env->pregs[PR_VR] == 32) { | ||
206 | dc->decoder = crisv32_decoder; | ||
207 | @@ -XXX,XX +XXX,XX @@ void gen_intermediate_code(CPUState *cs, struct TranslationBlock *tb) | ||
208 | |||
209 | page_start = pc_start & TARGET_PAGE_MASK; | ||
210 | num_insns = 0; | ||
211 | - max_insns = tb_cflags(tb) & CF_COUNT_MASK; | ||
212 | - if (max_insns == 0) { | ||
213 | - max_insns = CF_COUNT_MASK; | ||
214 | - } | ||
215 | - if (max_insns > TCG_MAX_INSNS) { | ||
216 | - max_insns = TCG_MAX_INSNS; | ||
217 | - } | ||
218 | |||
219 | gen_tb_start(tb); | ||
220 | do { | ||
221 | diff --git a/target/hppa/translate.c b/target/hppa/translate.c | ||
222 | index XXXXXXX..XXXXXXX 100644 | ||
223 | --- a/target/hppa/translate.c | ||
224 | +++ b/target/hppa/translate.c | ||
225 | @@ -XXX,XX +XXX,XX @@ static const TranslatorOps hppa_tr_ops = { | ||
226 | .disas_log = hppa_tr_disas_log, | ||
227 | }; | ||
228 | |||
229 | -void gen_intermediate_code(CPUState *cs, struct TranslationBlock *tb) | ||
230 | - | ||
231 | +void gen_intermediate_code(CPUState *cs, TranslationBlock *tb, int max_insns) | ||
232 | { | ||
233 | DisasContext ctx; | ||
234 | - translator_loop(&hppa_tr_ops, &ctx.base, cs, tb); | ||
235 | + translator_loop(&hppa_tr_ops, &ctx.base, cs, tb, max_insns); | ||
236 | } | ||
237 | |||
238 | void restore_state_to_opc(CPUHPPAState *env, TranslationBlock *tb, | ||
239 | diff --git a/target/i386/translate.c b/target/i386/translate.c | ||
240 | index XXXXXXX..XXXXXXX 100644 | ||
241 | --- a/target/i386/translate.c | ||
242 | +++ b/target/i386/translate.c | ||
243 | @@ -XXX,XX +XXX,XX @@ static const TranslatorOps i386_tr_ops = { | ||
244 | }; | ||
245 | |||
246 | /* generate intermediate code for basic block 'tb'. */ | ||
247 | -void gen_intermediate_code(CPUState *cpu, TranslationBlock *tb) | ||
248 | +void gen_intermediate_code(CPUState *cpu, TranslationBlock *tb, int max_insns) | ||
249 | { | ||
250 | DisasContext dc; | ||
251 | |||
252 | - translator_loop(&i386_tr_ops, &dc.base, cpu, tb); | ||
253 | + translator_loop(&i386_tr_ops, &dc.base, cpu, tb, max_insns); | ||
254 | } | ||
255 | |||
256 | void restore_state_to_opc(CPUX86State *env, TranslationBlock *tb, | ||
257 | diff --git a/target/lm32/translate.c b/target/lm32/translate.c | ||
258 | index XXXXXXX..XXXXXXX 100644 | ||
259 | --- a/target/lm32/translate.c | ||
260 | +++ b/target/lm32/translate.c | ||
261 | @@ -XXX,XX +XXX,XX @@ static inline void decode(DisasContext *dc, uint32_t ir) | ||
262 | } | ||
263 | |||
264 | /* generate intermediate code for basic block 'tb'. */ | ||
265 | -void gen_intermediate_code(CPUState *cs, struct TranslationBlock *tb) | ||
266 | +void gen_intermediate_code(CPUState *cs, TranslationBlock *tb, int max_insns) | ||
267 | { | ||
268 | CPULM32State *env = cs->env_ptr; | ||
269 | LM32CPU *cpu = lm32_env_get_cpu(env); | ||
270 | @@ -XXX,XX +XXX,XX @@ void gen_intermediate_code(CPUState *cs, struct TranslationBlock *tb) | ||
271 | uint32_t pc_start; | ||
272 | uint32_t page_start; | ||
273 | int num_insns; | ||
274 | - int max_insns; | ||
275 | |||
276 | pc_start = tb->pc; | ||
277 | dc->features = cpu->features; | ||
278 | @@ -XXX,XX +XXX,XX @@ void gen_intermediate_code(CPUState *cs, struct TranslationBlock *tb) | ||
279 | |||
280 | page_start = pc_start & TARGET_PAGE_MASK; | ||
281 | num_insns = 0; | ||
282 | - max_insns = tb_cflags(tb) & CF_COUNT_MASK; | ||
283 | - if (max_insns == 0) { | ||
284 | - max_insns = CF_COUNT_MASK; | ||
285 | - } | ||
286 | - if (max_insns > TCG_MAX_INSNS) { | ||
287 | - max_insns = TCG_MAX_INSNS; | ||
288 | - } | ||
289 | |||
290 | gen_tb_start(tb); | ||
291 | do { | ||
292 | diff --git a/target/m68k/translate.c b/target/m68k/translate.c | ||
293 | index XXXXXXX..XXXXXXX 100644 | ||
294 | --- a/target/m68k/translate.c | ||
295 | +++ b/target/m68k/translate.c | ||
296 | @@ -XXX,XX +XXX,XX @@ static const TranslatorOps m68k_tr_ops = { | ||
297 | .disas_log = m68k_tr_disas_log, | ||
298 | }; | ||
299 | |||
300 | -void gen_intermediate_code(CPUState *cpu, TranslationBlock *tb) | ||
301 | +void gen_intermediate_code(CPUState *cpu, TranslationBlock *tb, int max_insns) | ||
302 | { | ||
303 | DisasContext dc; | ||
304 | - translator_loop(&m68k_tr_ops, &dc.base, cpu, tb); | ||
305 | + translator_loop(&m68k_tr_ops, &dc.base, cpu, tb, max_insns); | ||
306 | } | ||
307 | |||
308 | static double floatx80_to_double(CPUM68KState *env, uint16_t high, uint64_t low) | ||
309 | diff --git a/target/microblaze/translate.c b/target/microblaze/translate.c | ||
310 | index XXXXXXX..XXXXXXX 100644 | ||
311 | --- a/target/microblaze/translate.c | ||
312 | +++ b/target/microblaze/translate.c | ||
313 | @@ -XXX,XX +XXX,XX @@ static inline void decode(DisasContext *dc, uint32_t ir) | ||
314 | } | ||
315 | |||
316 | /* generate intermediate code for basic block 'tb'. */ | ||
317 | -void gen_intermediate_code(CPUState *cs, struct TranslationBlock *tb) | ||
318 | +void gen_intermediate_code(CPUState *cs, TranslationBlock *tb, int max_insns) | ||
319 | { | ||
320 | CPUMBState *env = cs->env_ptr; | ||
321 | MicroBlazeCPU *cpu = mb_env_get_cpu(env); | ||
322 | @@ -XXX,XX +XXX,XX @@ void gen_intermediate_code(CPUState *cs, struct TranslationBlock *tb) | ||
323 | uint32_t page_start, org_flags; | ||
324 | uint32_t npc; | ||
325 | int num_insns; | ||
326 | - int max_insns; | ||
327 | |||
328 | pc_start = tb->pc; | ||
329 | dc->cpu = cpu; | ||
330 | @@ -XXX,XX +XXX,XX @@ void gen_intermediate_code(CPUState *cs, struct TranslationBlock *tb) | ||
331 | |||
332 | page_start = pc_start & TARGET_PAGE_MASK; | ||
333 | num_insns = 0; | ||
334 | - max_insns = tb_cflags(tb) & CF_COUNT_MASK; | ||
335 | - if (max_insns == 0) { | ||
336 | - max_insns = CF_COUNT_MASK; | ||
337 | - } | ||
338 | - if (max_insns > TCG_MAX_INSNS) { | ||
339 | - max_insns = TCG_MAX_INSNS; | ||
340 | - } | ||
341 | |||
342 | gen_tb_start(tb); | ||
343 | do | ||
344 | diff --git a/target/mips/translate.c b/target/mips/translate.c | ||
345 | index XXXXXXX..XXXXXXX 100644 | ||
346 | --- a/target/mips/translate.c | ||
347 | +++ b/target/mips/translate.c | ||
348 | @@ -XXX,XX +XXX,XX @@ static const TranslatorOps mips_tr_ops = { | ||
349 | .disas_log = mips_tr_disas_log, | ||
350 | }; | ||
351 | |||
352 | -void gen_intermediate_code(CPUState *cs, struct TranslationBlock *tb) | ||
353 | +void gen_intermediate_code(CPUState *cs, TranslationBlock *tb, int max_insns) | ||
354 | { | ||
355 | DisasContext ctx; | ||
356 | |||
357 | - translator_loop(&mips_tr_ops, &ctx.base, cs, tb); | ||
358 | + translator_loop(&mips_tr_ops, &ctx.base, cs, tb, max_insns); | ||
359 | } | ||
360 | |||
361 | static void fpu_dump_state(CPUMIPSState *env, FILE *f, int flags) | ||
362 | diff --git a/target/moxie/translate.c b/target/moxie/translate.c | ||
363 | index XXXXXXX..XXXXXXX 100644 | ||
364 | --- a/target/moxie/translate.c | ||
365 | +++ b/target/moxie/translate.c | ||
366 | @@ -XXX,XX +XXX,XX @@ static int decode_opc(MoxieCPU *cpu, DisasContext *ctx) | ||
367 | } | ||
368 | |||
369 | /* generate intermediate code for basic block 'tb'. */ | ||
370 | -void gen_intermediate_code(CPUState *cs, struct TranslationBlock *tb) | ||
371 | +void gen_intermediate_code(CPUState *cs, TranslationBlock *tb, int max_insns) | ||
372 | { | ||
373 | CPUMoxieState *env = cs->env_ptr; | ||
374 | MoxieCPU *cpu = moxie_env_get_cpu(env); | ||
375 | DisasContext ctx; | ||
376 | target_ulong pc_start; | ||
377 | - int num_insns, max_insns; | ||
378 | + int num_insns; | ||
379 | |||
380 | pc_start = tb->pc; | ||
381 | ctx.pc = pc_start; | ||
382 | @@ -XXX,XX +XXX,XX @@ void gen_intermediate_code(CPUState *cs, struct TranslationBlock *tb) | ||
383 | ctx.singlestep_enabled = 0; | ||
384 | ctx.bstate = BS_NONE; | ||
385 | num_insns = 0; | ||
386 | - max_insns = tb_cflags(tb) & CF_COUNT_MASK; | ||
387 | - if (max_insns == 0) { | ||
388 | - max_insns = CF_COUNT_MASK; | ||
389 | - } | ||
390 | - if (max_insns > TCG_MAX_INSNS) { | ||
391 | - max_insns = TCG_MAX_INSNS; | ||
392 | - } | ||
393 | |||
394 | gen_tb_start(tb); | ||
395 | do { | ||
396 | diff --git a/target/nios2/translate.c b/target/nios2/translate.c | ||
397 | index XXXXXXX..XXXXXXX 100644 | ||
398 | --- a/target/nios2/translate.c | ||
399 | +++ b/target/nios2/translate.c | ||
400 | @@ -XXX,XX +XXX,XX @@ static void gen_exception(DisasContext *dc, uint32_t excp) | ||
401 | } | ||
402 | |||
403 | /* generate intermediate code for basic block 'tb'. */ | ||
404 | -void gen_intermediate_code(CPUState *cs, TranslationBlock *tb) | ||
405 | +void gen_intermediate_code(CPUState *cs, TranslationBlock *tb, int max_insns) | ||
406 | { | ||
407 | CPUNios2State *env = cs->env_ptr; | ||
408 | DisasContext dc1, *dc = &dc1; | ||
409 | int num_insns; | ||
410 | - int max_insns; | ||
411 | |||
412 | /* Initialize DC */ | ||
413 | dc->cpu_env = cpu_env; | ||
414 | @@ -XXX,XX +XXX,XX @@ void gen_intermediate_code(CPUState *cs, TranslationBlock *tb) | ||
415 | |||
416 | /* Set up instruction counts */ | ||
417 | num_insns = 0; | ||
418 | - if (cs->singlestep_enabled || singlestep) { | ||
419 | - max_insns = 1; | ||
420 | - } else { | ||
421 | + if (max_insns > 1) { | ||
422 | int page_insns = (TARGET_PAGE_SIZE - (tb->pc & TARGET_PAGE_MASK)) / 4; | ||
423 | - max_insns = tb_cflags(tb) & CF_COUNT_MASK; | ||
424 | - if (max_insns == 0) { | ||
425 | - max_insns = CF_COUNT_MASK; | ||
426 | - } | ||
427 | if (max_insns > page_insns) { | ||
428 | max_insns = page_insns; | ||
429 | } | ||
430 | - if (max_insns > TCG_MAX_INSNS) { | ||
431 | - max_insns = TCG_MAX_INSNS; | ||
432 | - } | ||
433 | } | ||
434 | |||
435 | gen_tb_start(tb); | ||
436 | diff --git a/target/openrisc/translate.c b/target/openrisc/translate.c | ||
437 | index XXXXXXX..XXXXXXX 100644 | ||
438 | --- a/target/openrisc/translate.c | ||
439 | +++ b/target/openrisc/translate.c | ||
440 | @@ -XXX,XX +XXX,XX @@ static const TranslatorOps openrisc_tr_ops = { | ||
441 | .disas_log = openrisc_tr_disas_log, | ||
442 | }; | ||
443 | |||
444 | -void gen_intermediate_code(CPUState *cs, struct TranslationBlock *tb) | ||
445 | +void gen_intermediate_code(CPUState *cs, TranslationBlock *tb, int max_insns) | ||
446 | { | ||
447 | DisasContext ctx; | ||
448 | |||
449 | - translator_loop(&openrisc_tr_ops, &ctx.base, cs, tb); | ||
450 | + translator_loop(&openrisc_tr_ops, &ctx.base, cs, tb, max_insns); | ||
451 | } | ||
452 | |||
453 | void openrisc_cpu_dump_state(CPUState *cs, FILE *f, int flags) | ||
454 | diff --git a/target/ppc/translate.c b/target/ppc/translate.c | ||
455 | index XXXXXXX..XXXXXXX 100644 | ||
456 | --- a/target/ppc/translate.c | ||
457 | +++ b/target/ppc/translate.c | ||
458 | @@ -XXX,XX +XXX,XX @@ static const TranslatorOps ppc_tr_ops = { | ||
459 | .disas_log = ppc_tr_disas_log, | ||
460 | }; | ||
461 | |||
462 | -void gen_intermediate_code(CPUState *cs, struct TranslationBlock *tb) | ||
463 | +void gen_intermediate_code(CPUState *cs, TranslationBlock *tb, int max_insns) | ||
464 | { | ||
465 | DisasContext ctx; | ||
466 | |||
467 | - translator_loop(&ppc_tr_ops, &ctx.base, cs, tb); | ||
468 | + translator_loop(&ppc_tr_ops, &ctx.base, cs, tb, max_insns); | ||
469 | } | ||
470 | |||
471 | void restore_state_to_opc(CPUPPCState *env, TranslationBlock *tb, | ||
472 | diff --git a/target/riscv/translate.c b/target/riscv/translate.c | ||
473 | index XXXXXXX..XXXXXXX 100644 | ||
474 | --- a/target/riscv/translate.c | ||
475 | +++ b/target/riscv/translate.c | ||
476 | @@ -XXX,XX +XXX,XX @@ static const TranslatorOps riscv_tr_ops = { | ||
477 | .disas_log = riscv_tr_disas_log, | ||
478 | }; | ||
479 | |||
480 | -void gen_intermediate_code(CPUState *cs, TranslationBlock *tb) | ||
481 | +void gen_intermediate_code(CPUState *cs, TranslationBlock *tb, int max_insns) | ||
482 | { | ||
483 | DisasContext ctx; | ||
484 | |||
485 | - translator_loop(&riscv_tr_ops, &ctx.base, cs, tb); | ||
486 | + translator_loop(&riscv_tr_ops, &ctx.base, cs, tb, max_insns); | ||
487 | } | ||
488 | |||
489 | void riscv_translate_init(void) | ||
490 | diff --git a/target/s390x/translate.c b/target/s390x/translate.c | ||
491 | index XXXXXXX..XXXXXXX 100644 | ||
492 | --- a/target/s390x/translate.c | ||
493 | +++ b/target/s390x/translate.c | ||
494 | @@ -XXX,XX +XXX,XX @@ static const TranslatorOps s390x_tr_ops = { | ||
495 | .disas_log = s390x_tr_disas_log, | ||
496 | }; | ||
497 | |||
498 | -void gen_intermediate_code(CPUState *cs, TranslationBlock *tb) | ||
499 | +void gen_intermediate_code(CPUState *cs, TranslationBlock *tb, int max_insns) | ||
500 | { | ||
501 | DisasContext dc; | ||
502 | |||
503 | - translator_loop(&s390x_tr_ops, &dc.base, cs, tb); | ||
504 | + translator_loop(&s390x_tr_ops, &dc.base, cs, tb, max_insns); | ||
505 | } | ||
506 | |||
507 | void restore_state_to_opc(CPUS390XState *env, TranslationBlock *tb, | ||
508 | diff --git a/target/sh4/translate.c b/target/sh4/translate.c | ||
509 | index XXXXXXX..XXXXXXX 100644 | ||
510 | --- a/target/sh4/translate.c | ||
511 | +++ b/target/sh4/translate.c | ||
512 | @@ -XXX,XX +XXX,XX @@ static const TranslatorOps sh4_tr_ops = { | ||
513 | .disas_log = sh4_tr_disas_log, | ||
514 | }; | ||
515 | |||
516 | -void gen_intermediate_code(CPUState *cs, TranslationBlock *tb) | ||
517 | +void gen_intermediate_code(CPUState *cs, TranslationBlock *tb, int max_insns) | ||
518 | { | ||
519 | DisasContext ctx; | ||
520 | |||
521 | - translator_loop(&sh4_tr_ops, &ctx.base, cs, tb); | ||
522 | + translator_loop(&sh4_tr_ops, &ctx.base, cs, tb, max_insns); | ||
523 | } | ||
524 | |||
525 | void restore_state_to_opc(CPUSH4State *env, TranslationBlock *tb, | ||
526 | diff --git a/target/sparc/translate.c b/target/sparc/translate.c | ||
527 | index XXXXXXX..XXXXXXX 100644 | ||
528 | --- a/target/sparc/translate.c | ||
529 | +++ b/target/sparc/translate.c | ||
530 | @@ -XXX,XX +XXX,XX @@ static const TranslatorOps sparc_tr_ops = { | ||
531 | .disas_log = sparc_tr_disas_log, | ||
532 | }; | ||
533 | |||
534 | -void gen_intermediate_code(CPUState *cs, TranslationBlock *tb) | ||
535 | +void gen_intermediate_code(CPUState *cs, TranslationBlock *tb, int max_insns) | ||
536 | { | ||
537 | DisasContext dc = {}; | ||
538 | |||
539 | - translator_loop(&sparc_tr_ops, &dc.base, cs, tb); | ||
540 | + translator_loop(&sparc_tr_ops, &dc.base, cs, tb, max_insns); | ||
541 | } | ||
542 | |||
543 | void sparc_tcg_init(void) | ||
544 | diff --git a/target/tilegx/translate.c b/target/tilegx/translate.c | ||
545 | index XXXXXXX..XXXXXXX 100644 | ||
546 | --- a/target/tilegx/translate.c | ||
547 | +++ b/target/tilegx/translate.c | ||
548 | @@ -XXX,XX +XXX,XX @@ static void translate_one_bundle(DisasContext *dc, uint64_t bundle) | ||
549 | } | ||
550 | } | ||
551 | |||
552 | -void gen_intermediate_code(CPUState *cs, struct TranslationBlock *tb) | ||
553 | +void gen_intermediate_code(CPUState *cs, TranslationBlock *tb, int max_insns) | ||
554 | { | ||
555 | CPUTLGState *env = cs->env_ptr; | ||
556 | DisasContext ctx; | ||
557 | @@ -XXX,XX +XXX,XX @@ void gen_intermediate_code(CPUState *cs, struct TranslationBlock *tb) | ||
558 | uint64_t pc_start = tb->pc; | ||
559 | uint64_t page_start = pc_start & TARGET_PAGE_MASK; | ||
560 | int num_insns = 0; | ||
561 | - int max_insns = tb_cflags(tb) & CF_COUNT_MASK; | ||
562 | |||
563 | dc->pc = pc_start; | ||
564 | dc->mmuidx = 0; | ||
565 | @@ -XXX,XX +XXX,XX @@ void gen_intermediate_code(CPUState *cs, struct TranslationBlock *tb) | ||
566 | qemu_log_lock(); | ||
567 | qemu_log("IN: %s\n", lookup_symbol(pc_start)); | ||
568 | } | ||
569 | - if (!max_insns) { | ||
570 | - max_insns = CF_COUNT_MASK; | ||
571 | - } | ||
572 | - if (cs->singlestep_enabled || singlestep) { | ||
573 | - max_insns = 1; | ||
574 | - } | ||
575 | - if (max_insns > TCG_MAX_INSNS) { | ||
576 | - max_insns = TCG_MAX_INSNS; | ||
577 | - } | ||
578 | gen_tb_start(tb); | ||
579 | |||
580 | while (1) { | ||
581 | diff --git a/target/tricore/translate.c b/target/tricore/translate.c | ||
582 | index XXXXXXX..XXXXXXX 100644 | ||
583 | --- a/target/tricore/translate.c | ||
584 | +++ b/target/tricore/translate.c | ||
585 | @@ -XXX,XX +XXX,XX @@ static void decode_opc(CPUTriCoreState *env, DisasContext *ctx, int *is_branch) | ||
586 | } | ||
587 | } | ||
588 | |||
589 | -void gen_intermediate_code(CPUState *cs, struct TranslationBlock *tb) | ||
590 | +void gen_intermediate_code(CPUState *cs, TranslationBlock *tb, int max_insns) | ||
591 | { | ||
592 | CPUTriCoreState *env = cs->env_ptr; | ||
593 | DisasContext ctx; | ||
594 | target_ulong pc_start; | ||
595 | - int num_insns, max_insns; | ||
596 | - | ||
597 | - num_insns = 0; | ||
598 | - max_insns = tb_cflags(tb) & CF_COUNT_MASK; | ||
599 | - if (max_insns == 0) { | ||
600 | - max_insns = CF_COUNT_MASK; | ||
601 | - } | ||
602 | - if (singlestep) { | ||
603 | - max_insns = 1; | ||
604 | - } | ||
605 | - if (max_insns > TCG_MAX_INSNS) { | ||
606 | - max_insns = TCG_MAX_INSNS; | ||
607 | - } | ||
608 | + int num_insns = 0; | ||
609 | |||
610 | pc_start = tb->pc; | ||
611 | ctx.pc = pc_start; | ||
612 | diff --git a/target/unicore32/translate.c b/target/unicore32/translate.c | ||
613 | index XXXXXXX..XXXXXXX 100644 | ||
614 | --- a/target/unicore32/translate.c | ||
615 | +++ b/target/unicore32/translate.c | ||
616 | @@ -XXX,XX +XXX,XX @@ static void disas_uc32_insn(CPUUniCore32State *env, DisasContext *s) | ||
617 | } | ||
618 | |||
619 | /* generate intermediate code for basic block 'tb'. */ | ||
620 | -void gen_intermediate_code(CPUState *cs, TranslationBlock *tb) | ||
621 | +void gen_intermediate_code(CPUState *cs, TranslationBlock *tb, int max_insns) | ||
622 | { | ||
623 | CPUUniCore32State *env = cs->env_ptr; | ||
624 | DisasContext dc1, *dc = &dc1; | ||
625 | target_ulong pc_start; | ||
626 | uint32_t page_start; | ||
627 | int num_insns; | ||
628 | - int max_insns; | ||
629 | |||
630 | /* generate intermediate code */ | ||
631 | num_temps = 0; | ||
632 | @@ -XXX,XX +XXX,XX @@ void gen_intermediate_code(CPUState *cs, TranslationBlock *tb) | ||
633 | cpu_F1d = tcg_temp_new_i64(); | ||
634 | page_start = pc_start & TARGET_PAGE_MASK; | ||
635 | num_insns = 0; | ||
636 | - max_insns = tb_cflags(tb) & CF_COUNT_MASK; | ||
637 | - if (max_insns == 0) { | ||
638 | - max_insns = CF_COUNT_MASK; | ||
639 | - } | ||
640 | - if (max_insns > TCG_MAX_INSNS) { | ||
641 | - max_insns = TCG_MAX_INSNS; | ||
642 | - } | ||
643 | |||
644 | #ifndef CONFIG_USER_ONLY | ||
645 | if ((env->uncached_asr & ASR_M) == ASR_MODE_USER) { | ||
646 | diff --git a/target/xtensa/translate.c b/target/xtensa/translate.c | ||
647 | index XXXXXXX..XXXXXXX 100644 | ||
648 | --- a/target/xtensa/translate.c | ||
649 | +++ b/target/xtensa/translate.c | ||
650 | @@ -XXX,XX +XXX,XX @@ static const TranslatorOps xtensa_translator_ops = { | ||
651 | .disas_log = xtensa_tr_disas_log, | ||
652 | }; | ||
653 | |||
654 | -void gen_intermediate_code(CPUState *cpu, TranslationBlock *tb) | ||
655 | +void gen_intermediate_code(CPUState *cpu, TranslationBlock *tb, int max_insns) | ||
656 | { | ||
657 | DisasContext dc = {}; | ||
658 | - translator_loop(&xtensa_translator_ops, &dc.base, cpu, tb); | ||
659 | + translator_loop(&xtensa_translator_ops, &dc.base, cpu, tb, max_insns); | ||
660 | } | ||
661 | |||
662 | void xtensa_cpu_dump_state(CPUState *cs, FILE *f, int flags) | ||
663 | -- | ||
664 | 2.17.1 | ||
665 | |||
666 | diff view generated by jsdifflib |
Deleted patch | |||
---|---|---|---|
1 | If a TB generates too much code, try again with fewer insns. | ||
2 | 1 | ||
3 | Fixes: https://bugs.launchpad.net/bugs/1824853 | ||
4 | Reviewed-by: Philippe Mathieu-Daudé <philmd@redhat.com> | ||
5 | Signed-off-by: Richard Henderson <richard.henderson@linaro.org> | ||
6 | --- | ||
7 | accel/tcg/translate-all.c | 38 ++++++++++++++++++++++++++++++++------ | ||
8 | tcg/tcg.c | 4 ++++ | ||
9 | 2 files changed, 36 insertions(+), 6 deletions(-) | ||
10 | |||
11 | diff --git a/accel/tcg/translate-all.c b/accel/tcg/translate-all.c | ||
12 | index XXXXXXX..XXXXXXX 100644 | ||
13 | --- a/accel/tcg/translate-all.c | ||
14 | +++ b/accel/tcg/translate-all.c | ||
15 | @@ -XXX,XX +XXX,XX @@ TranslationBlock *tb_gen_code(CPUState *cpu, | ||
16 | tb->cflags = cflags; | ||
17 | tb->trace_vcpu_dstate = *cpu->trace_dstate; | ||
18 | tcg_ctx->tb_cflags = cflags; | ||
19 | + tb_overflow: | ||
20 | |||
21 | #ifdef CONFIG_PROFILER | ||
22 | /* includes aborted translations because of exceptions */ | ||
23 | @@ -XXX,XX +XXX,XX @@ TranslationBlock *tb_gen_code(CPUState *cpu, | ||
24 | ti = profile_getclock(); | ||
25 | #endif | ||
26 | |||
27 | - /* ??? Overflow could be handled better here. In particular, we | ||
28 | - don't need to re-do gen_intermediate_code, nor should we re-do | ||
29 | - the tcg optimization currently hidden inside tcg_gen_code. All | ||
30 | - that should be required is to flush the TBs, allocate a new TB, | ||
31 | - re-initialize it per above, and re-do the actual code generation. */ | ||
32 | gen_code_size = tcg_gen_code(tcg_ctx, tb); | ||
33 | if (unlikely(gen_code_size < 0)) { | ||
34 | - goto buffer_overflow; | ||
35 | + switch (gen_code_size) { | ||
36 | + case -1: | ||
37 | + /* | ||
38 | + * Overflow of code_gen_buffer, or the current slice of it. | ||
39 | + * | ||
40 | + * TODO: We don't need to re-do gen_intermediate_code, nor | ||
41 | + * should we re-do the tcg optimization currently hidden | ||
42 | + * inside tcg_gen_code. All that should be required is to | ||
43 | + * flush the TBs, allocate a new TB, re-initialize it per | ||
44 | + * above, and re-do the actual code generation. | ||
45 | + */ | ||
46 | + goto buffer_overflow; | ||
47 | + | ||
48 | + case -2: | ||
49 | + /* | ||
50 | + * The code generated for the TranslationBlock is too large. | ||
51 | + * The maximum size allowed by the unwind info is 64k. | ||
52 | + * There may be stricter constraints from relocations | ||
53 | + * in the tcg backend. | ||
54 | + * | ||
55 | + * Try again with half as many insns as we attempted this time. | ||
56 | + * If a single insn overflows, there's a bug somewhere... | ||
57 | + */ | ||
58 | + max_insns = tb->icount; | ||
59 | + assert(max_insns > 1); | ||
60 | + max_insns /= 2; | ||
61 | + goto tb_overflow; | ||
62 | + | ||
63 | + default: | ||
64 | + g_assert_not_reached(); | ||
65 | + } | ||
66 | } | ||
67 | search_size = encode_search(tb, (void *)gen_code_buf + gen_code_size); | ||
68 | if (unlikely(search_size < 0)) { | ||
69 | diff --git a/tcg/tcg.c b/tcg/tcg.c | ||
70 | index XXXXXXX..XXXXXXX 100644 | ||
71 | --- a/tcg/tcg.c | ||
72 | +++ b/tcg/tcg.c | ||
73 | @@ -XXX,XX +XXX,XX @@ int tcg_gen_code(TCGContext *s, TranslationBlock *tb) | ||
74 | if (unlikely((void *)s->code_ptr > s->code_gen_highwater)) { | ||
75 | return -1; | ||
76 | } | ||
77 | + /* Test for TB overflow, as seen by gen_insn_end_off. */ | ||
78 | + if (unlikely(tcg_current_code_size(s) > UINT16_MAX)) { | ||
79 | + return -2; | ||
80 | + } | ||
81 | } | ||
82 | tcg_debug_assert(num_insns >= 0); | ||
83 | s->gen_insn_end_off[num_insns] = tcg_current_code_size(s); | ||
84 | -- | ||
85 | 2.17.1 | ||
86 | |||
87 | diff view generated by jsdifflib |
Deleted patch | |||
---|---|---|---|
1 | If the TB generates too much code, such that backend relocations | ||
2 | overflow, try again with a smaller TB. In support of this, move | ||
3 | relocation processing from a random place within tcg_out_op, in | ||
4 | the handling of branch opcodes, to a new function at the end of | ||
5 | tcg_gen_code. | ||
6 | 1 | ||
7 | This is not a complete solution, as there are additional relocs | ||
8 | generated for out-of-line ldst handling and constant pools. | ||
9 | |||
10 | Signed-off-by: Richard Henderson <richard.henderson@linaro.org> | ||
11 | --- | ||
12 | tcg/tcg.h | 15 +++++++------- | ||
13 | tcg/tcg.c | 61 ++++++++++++++++++++++++++----------------------------- | ||
14 | 2 files changed, 36 insertions(+), 40 deletions(-) | ||
15 | |||
16 | diff --git a/tcg/tcg.h b/tcg/tcg.h | ||
17 | index XXXXXXX..XXXXXXX 100644 | ||
18 | --- a/tcg/tcg.h | ||
19 | +++ b/tcg/tcg.h | ||
20 | @@ -XXX,XX +XXX,XX @@ typedef uint64_t tcg_insn_unit; | ||
21 | do { if (!(X)) { __builtin_unreachable(); } } while (0) | ||
22 | #endif | ||
23 | |||
24 | -typedef struct TCGRelocation { | ||
25 | - struct TCGRelocation *next; | ||
26 | - int type; | ||
27 | +typedef struct TCGRelocation TCGRelocation; | ||
28 | +struct TCGRelocation { | ||
29 | + QSIMPLEQ_ENTRY(TCGRelocation) next; | ||
30 | tcg_insn_unit *ptr; | ||
31 | intptr_t addend; | ||
32 | -} TCGRelocation; | ||
33 | + int type; | ||
34 | +}; | ||
35 | |||
36 | typedef struct TCGLabel TCGLabel; | ||
37 | struct TCGLabel { | ||
38 | @@ -XXX,XX +XXX,XX @@ struct TCGLabel { | ||
39 | union { | ||
40 | uintptr_t value; | ||
41 | tcg_insn_unit *value_ptr; | ||
42 | - TCGRelocation *first_reloc; | ||
43 | } u; | ||
44 | -#ifdef CONFIG_DEBUG_TCG | ||
45 | + QSIMPLEQ_HEAD(, TCGRelocation) relocs; | ||
46 | QSIMPLEQ_ENTRY(TCGLabel) next; | ||
47 | -#endif | ||
48 | }; | ||
49 | |||
50 | typedef struct TCGPool { | ||
51 | @@ -XXX,XX +XXX,XX @@ struct TCGContext { | ||
52 | #endif | ||
53 | |||
54 | #ifdef CONFIG_DEBUG_TCG | ||
55 | - QSIMPLEQ_HEAD(, TCGLabel) labels; | ||
56 | int temps_in_use; | ||
57 | int goto_tb_issue_mask; | ||
58 | #endif | ||
59 | @@ -XXX,XX +XXX,XX @@ struct TCGContext { | ||
60 | TCGTemp temps[TCG_MAX_TEMPS]; /* globals first, temps after */ | ||
61 | |||
62 | QTAILQ_HEAD(, TCGOp) ops, free_ops; | ||
63 | + QSIMPLEQ_HEAD(, TCGLabel) labels; | ||
64 | |||
65 | /* Tells which temporary holds a given register. | ||
66 | It does not take into account fixed registers */ | ||
67 | diff --git a/tcg/tcg.c b/tcg/tcg.c | ||
68 | index XXXXXXX..XXXXXXX 100644 | ||
69 | --- a/tcg/tcg.c | ||
70 | +++ b/tcg/tcg.c | ||
71 | @@ -XXX,XX +XXX,XX @@ static __attribute__((unused)) inline void tcg_patch64(tcg_insn_unit *p, | ||
72 | static void tcg_out_reloc(TCGContext *s, tcg_insn_unit *code_ptr, int type, | ||
73 | TCGLabel *l, intptr_t addend) | ||
74 | { | ||
75 | - TCGRelocation *r; | ||
76 | + TCGRelocation *r = tcg_malloc(sizeof(TCGRelocation)); | ||
77 | |||
78 | - if (l->has_value) { | ||
79 | - /* FIXME: This may break relocations on RISC targets that | ||
80 | - modify instruction fields in place. The caller may not have | ||
81 | - written the initial value. */ | ||
82 | - bool ok = patch_reloc(code_ptr, type, l->u.value, addend); | ||
83 | - tcg_debug_assert(ok); | ||
84 | - } else { | ||
85 | - /* add a new relocation entry */ | ||
86 | - r = tcg_malloc(sizeof(TCGRelocation)); | ||
87 | - r->type = type; | ||
88 | - r->ptr = code_ptr; | ||
89 | - r->addend = addend; | ||
90 | - r->next = l->u.first_reloc; | ||
91 | - l->u.first_reloc = r; | ||
92 | - } | ||
93 | + r->type = type; | ||
94 | + r->ptr = code_ptr; | ||
95 | + r->addend = addend; | ||
96 | + QSIMPLEQ_INSERT_TAIL(&l->relocs, r, next); | ||
97 | } | ||
98 | |||
99 | static void tcg_out_label(TCGContext *s, TCGLabel *l, tcg_insn_unit *ptr) | ||
100 | { | ||
101 | - intptr_t value = (intptr_t)ptr; | ||
102 | - TCGRelocation *r; | ||
103 | - | ||
104 | tcg_debug_assert(!l->has_value); | ||
105 | - | ||
106 | - for (r = l->u.first_reloc; r != NULL; r = r->next) { | ||
107 | - bool ok = patch_reloc(r->ptr, r->type, value, r->addend); | ||
108 | - tcg_debug_assert(ok); | ||
109 | - } | ||
110 | - | ||
111 | l->has_value = 1; | ||
112 | l->u.value_ptr = ptr; | ||
113 | } | ||
114 | @@ -XXX,XX +XXX,XX @@ TCGLabel *gen_new_label(void) | ||
115 | TCGContext *s = tcg_ctx; | ||
116 | TCGLabel *l = tcg_malloc(sizeof(TCGLabel)); | ||
117 | |||
118 | - *l = (TCGLabel){ | ||
119 | - .id = s->nb_labels++ | ||
120 | - }; | ||
121 | -#ifdef CONFIG_DEBUG_TCG | ||
122 | + memset(l, 0, sizeof(TCGLabel)); | ||
123 | + l->id = s->nb_labels++; | ||
124 | + QSIMPLEQ_INIT(&l->relocs); | ||
125 | + | ||
126 | QSIMPLEQ_INSERT_TAIL(&s->labels, l, next); | ||
127 | -#endif | ||
128 | |||
129 | return l; | ||
130 | } | ||
131 | |||
132 | +static bool tcg_resolve_relocs(TCGContext *s) | ||
133 | +{ | ||
134 | + TCGLabel *l; | ||
135 | + | ||
136 | + QSIMPLEQ_FOREACH(l, &s->labels, next) { | ||
137 | + TCGRelocation *r; | ||
138 | + uintptr_t value = l->u.value; | ||
139 | + | ||
140 | + QSIMPLEQ_FOREACH(r, &l->relocs, next) { | ||
141 | + if (!patch_reloc(r->ptr, r->type, value, r->addend)) { | ||
142 | + return false; | ||
143 | + } | ||
144 | + } | ||
145 | + } | ||
146 | + return true; | ||
147 | +} | ||
148 | + | ||
149 | static void set_jmp_reset_offset(TCGContext *s, int which) | ||
150 | { | ||
151 | size_t off = tcg_current_code_size(s); | ||
152 | @@ -XXX,XX +XXX,XX @@ void tcg_func_start(TCGContext *s) | ||
153 | |||
154 | QTAILQ_INIT(&s->ops); | ||
155 | QTAILQ_INIT(&s->free_ops); | ||
156 | -#ifdef CONFIG_DEBUG_TCG | ||
157 | QSIMPLEQ_INIT(&s->labels); | ||
158 | -#endif | ||
159 | } | ||
160 | |||
161 | static inline TCGTemp *tcg_temp_alloc(TCGContext *s) | ||
162 | @@ -XXX,XX +XXX,XX @@ int tcg_gen_code(TCGContext *s, TranslationBlock *tb) | ||
163 | return -1; | ||
164 | } | ||
165 | #endif | ||
166 | + if (!tcg_resolve_relocs(s)) { | ||
167 | + return -2; | ||
168 | + } | ||
169 | |||
170 | /* flush instruction cache */ | ||
171 | flush_icache_range((uintptr_t)s->code_buf, (uintptr_t)s->code_ptr); | ||
172 | -- | ||
173 | 2.17.1 | ||
174 | |||
175 | diff view generated by jsdifflib |
1 | This is part b of relocation overflow handling. | 1 | When allocating new temps during tcg_optmize, do not re-use |
---|---|---|---|
2 | any EBB temps that were used within the TB. We do not have | ||
3 | any idea what span of the TB in which the temp was live. | ||
2 | 4 | ||
5 | Introduce tcg_temp_ebb_reset_freed and use before tcg_optimize, | ||
6 | as well as replacing the equivalent in plugin_gen_inject and | ||
7 | tcg_func_start. | ||
8 | |||
9 | Cc: qemu-stable@nongnu.org | ||
10 | Fixes: fb04ab7ddd8 ("tcg/optimize: Lower TCG_COND_TST{EQ,NE} if unsupported") | ||
11 | Resolves: https://gitlab.com/qemu-project/qemu/-/issues/2711 | ||
12 | Reported-by: wannacu <wannacu2049@gmail.com> | ||
3 | Signed-off-by: Richard Henderson <richard.henderson@linaro.org> | 13 | Signed-off-by: Richard Henderson <richard.henderson@linaro.org> |
14 | Reviewed-by: Pierrick Bouvier <pierrick.bouvier@linaro.org> | ||
15 | Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org> | ||
4 | --- | 16 | --- |
5 | tcg/tcg-pool.inc.c | 12 +++++++----- | 17 | include/tcg/tcg-temp-internal.h | 6 ++++++ |
6 | tcg/tcg.c | 9 +++++---- | 18 | accel/tcg/plugin-gen.c | 2 +- |
7 | 2 files changed, 12 insertions(+), 9 deletions(-) | 19 | tcg/tcg.c | 5 ++++- |
20 | 3 files changed, 11 insertions(+), 2 deletions(-) | ||
8 | 21 | ||
9 | diff --git a/tcg/tcg-pool.inc.c b/tcg/tcg-pool.inc.c | 22 | diff --git a/include/tcg/tcg-temp-internal.h b/include/tcg/tcg-temp-internal.h |
10 | index XXXXXXX..XXXXXXX 100644 | 23 | index XXXXXXX..XXXXXXX 100644 |
11 | --- a/tcg/tcg-pool.inc.c | 24 | --- a/include/tcg/tcg-temp-internal.h |
12 | +++ b/tcg/tcg-pool.inc.c | 25 | +++ b/include/tcg/tcg-temp-internal.h |
13 | @@ -XXX,XX +XXX,XX @@ static inline void new_pool_l8(TCGContext *s, int rtype, tcg_insn_unit *label, | 26 | @@ -XXX,XX +XXX,XX @@ TCGv_i64 tcg_temp_ebb_new_i64(void); |
14 | /* To be provided by cpu/tcg-target.inc.c. */ | 27 | TCGv_ptr tcg_temp_ebb_new_ptr(void); |
15 | static void tcg_out_nop_fill(tcg_insn_unit *p, int count); | 28 | TCGv_i128 tcg_temp_ebb_new_i128(void); |
16 | 29 | ||
17 | -static bool tcg_out_pool_finalize(TCGContext *s) | 30 | +/* Forget all freed EBB temps, so that new allocations produce new temps. */ |
18 | +static int tcg_out_pool_finalize(TCGContext *s) | 31 | +static inline void tcg_temp_ebb_reset_freed(TCGContext *s) |
19 | { | 32 | +{ |
20 | TCGLabelPoolData *p = s->pool_labels; | 33 | + memset(s->free_temps, 0, sizeof(s->free_temps)); |
21 | TCGLabelPoolData *l = NULL; | 34 | +} |
22 | void *a; | 35 | + |
23 | 36 | #endif /* TCG_TEMP_FREE_H */ | |
24 | if (p == NULL) { | 37 | diff --git a/accel/tcg/plugin-gen.c b/accel/tcg/plugin-gen.c |
25 | - return true; | 38 | index XXXXXXX..XXXXXXX 100644 |
26 | + return 0; | 39 | --- a/accel/tcg/plugin-gen.c |
27 | } | 40 | +++ b/accel/tcg/plugin-gen.c |
28 | 41 | @@ -XXX,XX +XXX,XX @@ static void plugin_gen_inject(struct qemu_plugin_tb *plugin_tb) | |
29 | /* ??? Round up to qemu_icache_linesize, but then do not round | 42 | * that might be live within the existing opcode stream. |
30 | @@ -XXX,XX +XXX,XX @@ static bool tcg_out_pool_finalize(TCGContext *s) | 43 | * The simplest solution is to release them all and create new. |
31 | size_t size = sizeof(tcg_target_ulong) * p->nlong; | 44 | */ |
32 | if (!l || l->nlong != p->nlong || memcmp(l->data, p->data, size)) { | 45 | - memset(tcg_ctx->free_temps, 0, sizeof(tcg_ctx->free_temps)); |
33 | if (unlikely(a > s->code_gen_highwater)) { | 46 | + tcg_temp_ebb_reset_freed(tcg_ctx); |
34 | - return false; | 47 | |
35 | + return -1; | 48 | QTAILQ_FOREACH_SAFE(op, &tcg_ctx->ops, link, next) { |
36 | } | 49 | switch (op->opc) { |
37 | memcpy(a, p->data, size); | ||
38 | a += size; | ||
39 | l = p; | ||
40 | } | ||
41 | - patch_reloc(p->label, p->rtype, (intptr_t)a - size, p->addend); | ||
42 | + if (!patch_reloc(p->label, p->rtype, (intptr_t)a - size, p->addend)) { | ||
43 | + return -2; | ||
44 | + } | ||
45 | } | ||
46 | |||
47 | s->code_ptr = a; | ||
48 | - return true; | ||
49 | + return 0; | ||
50 | } | ||
51 | diff --git a/tcg/tcg.c b/tcg/tcg.c | 50 | diff --git a/tcg/tcg.c b/tcg/tcg.c |
52 | index XXXXXXX..XXXXXXX 100644 | 51 | index XXXXXXX..XXXXXXX 100644 |
53 | --- a/tcg/tcg.c | 52 | --- a/tcg/tcg.c |
54 | +++ b/tcg/tcg.c | 53 | +++ b/tcg/tcg.c |
55 | @@ -XXX,XX +XXX,XX @@ void tcg_prologue_init(TCGContext *s) | 54 | @@ -XXX,XX +XXX,XX @@ void tcg_func_start(TCGContext *s) |
56 | #ifdef TCG_TARGET_NEED_POOL_LABELS | 55 | s->nb_temps = s->nb_globals; |
57 | /* Allow the prologue to put e.g. guest_base into a pool entry. */ | 56 | |
58 | { | 57 | /* No temps have been previously allocated for size or locality. */ |
59 | - bool ok = tcg_out_pool_finalize(s); | 58 | - memset(s->free_temps, 0, sizeof(s->free_temps)); |
60 | - tcg_debug_assert(ok); | 59 | + tcg_temp_ebb_reset_freed(s); |
61 | + int result = tcg_out_pool_finalize(s); | 60 | |
62 | + tcg_debug_assert(result == 0); | 61 | /* No constant temps have been previously allocated. */ |
62 | for (int i = 0; i < TCG_TYPE_COUNT; ++i) { | ||
63 | @@ -XXX,XX +XXX,XX @@ int tcg_gen_code(TCGContext *s, TranslationBlock *tb, uint64_t pc_start) | ||
63 | } | 64 | } |
64 | #endif | 65 | #endif |
65 | 66 | ||
66 | @@ -XXX,XX +XXX,XX @@ int tcg_gen_code(TCGContext *s, TranslationBlock *tb) | 67 | + /* Do not reuse any EBB that may be allocated within the TB. */ |
67 | } | 68 | + tcg_temp_ebb_reset_freed(s); |
68 | #endif | 69 | + |
69 | #ifdef TCG_TARGET_NEED_POOL_LABELS | 70 | tcg_optimize(s); |
70 | - if (!tcg_out_pool_finalize(s)) { | 71 | |
71 | - return -1; | 72 | reachable_code_pass(s); |
72 | + i = tcg_out_pool_finalize(s); | ||
73 | + if (i < 0) { | ||
74 | + return i; | ||
75 | } | ||
76 | #endif | ||
77 | if (!tcg_resolve_relocs(s)) { | ||
78 | -- | 73 | -- |
79 | 2.17.1 | 74 | 2.43.0 |
80 | 75 | ||
81 | 76 | diff view generated by jsdifflib |
1 | This will not necessarily restrict the size of the TB, since for v7 | 1 | From: Roman Artemev <roman.artemev@syntacore.com> |
---|---|---|---|
2 | the majority of constant pool usage is for calls from the out-of-line | ||
3 | ldst code, which is already at the end of the TB. But this does | ||
4 | allow us to save one insn per reference on the off-chance. | ||
5 | 2 | ||
3 | On RISC-V to StoreStore barrier corresponds | ||
4 | `fence w, w` not `fence r, r` | ||
5 | |||
6 | Cc: qemu-stable@nongnu.org | ||
7 | Fixes: efbea94c76b ("tcg/riscv: Add slowpath load and store instructions") | ||
8 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> | ||
9 | Signed-off-by: Denis Tomashev <denis.tomashev@syntacore.com> | ||
10 | Signed-off-by: Roman Artemev <roman.artemev@syntacore.com> | ||
11 | Message-ID: <e2f2131e294a49e79959d4fa9ec02cf4@syntacore.com> | ||
6 | Signed-off-by: Richard Henderson <richard.henderson@linaro.org> | 12 | Signed-off-by: Richard Henderson <richard.henderson@linaro.org> |
7 | --- | 13 | --- |
8 | tcg/arm/tcg-target.inc.c | 57 +++++++++++++++------------------------- | 14 | tcg/riscv/tcg-target.c.inc | 2 +- |
9 | 1 file changed, 21 insertions(+), 36 deletions(-) | 15 | 1 file changed, 1 insertion(+), 1 deletion(-) |
10 | 16 | ||
11 | diff --git a/tcg/arm/tcg-target.inc.c b/tcg/arm/tcg-target.inc.c | 17 | diff --git a/tcg/riscv/tcg-target.c.inc b/tcg/riscv/tcg-target.c.inc |
12 | index XXXXXXX..XXXXXXX 100644 | 18 | index XXXXXXX..XXXXXXX 100644 |
13 | --- a/tcg/arm/tcg-target.inc.c | 19 | --- a/tcg/riscv/tcg-target.c.inc |
14 | +++ b/tcg/arm/tcg-target.inc.c | 20 | +++ b/tcg/riscv/tcg-target.c.inc |
15 | @@ -XXX,XX +XXX,XX @@ static inline bool reloc_pc24(tcg_insn_unit *code_ptr, tcg_insn_unit *target) | 21 | @@ -XXX,XX +XXX,XX @@ static void tcg_out_mb(TCGContext *s, TCGArg a0) |
16 | return false; | 22 | insn |= 0x02100000; |
17 | } | ||
18 | |||
19 | +static inline bool reloc_pc13(tcg_insn_unit *code_ptr, tcg_insn_unit *target) | ||
20 | +{ | ||
21 | + ptrdiff_t offset = tcg_ptr_byte_diff(target, code_ptr) - 8; | ||
22 | + | ||
23 | + if (offset >= -0xfff && offset <= 0xfff) { | ||
24 | + tcg_insn_unit insn = *code_ptr; | ||
25 | + bool u = (offset >= 0); | ||
26 | + if (!u) { | ||
27 | + offset = -offset; | ||
28 | + } | ||
29 | + insn = deposit32(insn, 23, 1, u); | ||
30 | + insn = deposit32(insn, 0, 12, offset); | ||
31 | + *code_ptr = insn; | ||
32 | + return true; | ||
33 | + } | ||
34 | + return false; | ||
35 | +} | ||
36 | + | ||
37 | static bool patch_reloc(tcg_insn_unit *code_ptr, int type, | ||
38 | intptr_t value, intptr_t addend) | ||
39 | { | ||
40 | @@ -XXX,XX +XXX,XX @@ static bool patch_reloc(tcg_insn_unit *code_ptr, int type, | ||
41 | if (type == R_ARM_PC24) { | ||
42 | return reloc_pc24(code_ptr, (tcg_insn_unit *)value); | ||
43 | } else if (type == R_ARM_PC13) { | ||
44 | - intptr_t diff = value - (uintptr_t)(code_ptr + 2); | ||
45 | - tcg_insn_unit insn = *code_ptr; | ||
46 | - bool u; | ||
47 | - | ||
48 | - if (diff >= -0xfff && diff <= 0xfff) { | ||
49 | - u = (diff >= 0); | ||
50 | - if (!u) { | ||
51 | - diff = -diff; | ||
52 | - } | ||
53 | - } else { | ||
54 | - int rd = extract32(insn, 12, 4); | ||
55 | - int rt = rd == TCG_REG_PC ? TCG_REG_TMP : rd; | ||
56 | - | ||
57 | - if (diff < 0x1000 || diff >= 0x100000) { | ||
58 | - return false; | ||
59 | - } | ||
60 | - | ||
61 | - /* add rt, pc, #high */ | ||
62 | - *code_ptr++ = ((insn & 0xf0000000) | (1 << 25) | ARITH_ADD | ||
63 | - | (TCG_REG_PC << 16) | (rt << 12) | ||
64 | - | (20 << 7) | (diff >> 12)); | ||
65 | - /* ldr rd, [rt, #low] */ | ||
66 | - insn = deposit32(insn, 12, 4, rt); | ||
67 | - diff &= 0xfff; | ||
68 | - u = 1; | ||
69 | - } | ||
70 | - insn = deposit32(insn, 23, 1, u); | ||
71 | - insn = deposit32(insn, 0, 12, diff); | ||
72 | - *code_ptr = insn; | ||
73 | + return reloc_pc13(code_ptr, (tcg_insn_unit *)value); | ||
74 | } else { | ||
75 | g_assert_not_reached(); | ||
76 | } | 23 | } |
77 | - return true; | 24 | if (a0 & TCG_MO_ST_ST) { |
78 | } | 25 | - insn |= 0x02200000; |
79 | 26 | + insn |= 0x01100000; | |
80 | #define TCG_CT_CONST_ARM 0x100 | ||
81 | @@ -XXX,XX +XXX,XX @@ static inline void tcg_out_ld8s_r(TCGContext *s, int cond, TCGReg rt, | ||
82 | |||
83 | static void tcg_out_movi_pool(TCGContext *s, int cond, int rd, uint32_t arg) | ||
84 | { | ||
85 | - /* The 12-bit range on the ldr insn is sometimes a bit too small. | ||
86 | - In order to get around that we require two insns, one of which | ||
87 | - will usually be a nop, but may be replaced in patch_reloc. */ | ||
88 | new_pool_label(s, arg, R_ARM_PC13, s->code_ptr, 0); | ||
89 | tcg_out_ld32_12(s, cond, rd, TCG_REG_PC, 0); | ||
90 | - tcg_out_nop(s); | ||
91 | } | ||
92 | |||
93 | static void tcg_out_movi32(TCGContext *s, int cond, int rd, uint32_t arg) | ||
94 | @@ -XXX,XX +XXX,XX @@ static void tcg_out_call(TCGContext *s, tcg_insn_unit *addr) | ||
95 | tcg_out_movi32(s, COND_AL, TCG_REG_TMP, addri); | ||
96 | tcg_out_blx(s, COND_AL, TCG_REG_TMP); | ||
97 | } else { | ||
98 | - /* ??? Know that movi_pool emits exactly 2 insns. */ | ||
99 | - tcg_out_dat_imm(s, COND_AL, ARITH_ADD, TCG_REG_R14, TCG_REG_PC, 4); | ||
100 | + /* ??? Know that movi_pool emits exactly 1 insn. */ | ||
101 | + tcg_out_dat_imm(s, COND_AL, ARITH_ADD, TCG_REG_R14, TCG_REG_PC, 0); | ||
102 | tcg_out_movi_pool(s, COND_AL, TCG_REG_PC, addri); | ||
103 | } | 27 | } |
28 | tcg_out32(s, insn); | ||
104 | } | 29 | } |
105 | -- | 30 | -- |
106 | 2.17.1 | 31 | 2.43.0 |
107 | |||
108 | diff view generated by jsdifflib |
1 | From: Shahab Vahedi <shahab.vahedi@gmail.com> | 1 | This allows targets to declare that the helper requires a |
---|---|---|---|
2 | float_status pointer and instead of a generic void pointer. | ||
2 | 3 | ||
3 | This change adapts io_readx() to its input access_type. Currently | 4 | Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org> |
4 | io_readx() treats any memory access as a read, although it has an | ||
5 | input argument "MMUAccessType access_type". This results in: | ||
6 | |||
7 | 1) Calling the tlb_fill() only with MMU_DATA_LOAD | ||
8 | 2) Considering only entry->addr_read as the tlb_addr | ||
9 | |||
10 | Buglink: https://bugs.launchpad.net/qemu/+bug/1825359 | ||
11 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> | ||
12 | Signed-off-by: Shahab Vahedi <shahab.vahedi@gmail.com> | ||
13 | Message-Id: <20190420072236.12347-1-shahab.vahedi@gmail.com> | ||
14 | [rth: Remove assert; fix expression formatting.] | ||
15 | Signed-off-by: Richard Henderson <richard.henderson@linaro.org> | 5 | Signed-off-by: Richard Henderson <richard.henderson@linaro.org> |
16 | --- | 6 | --- |
17 | accel/tcg/cputlb.c | 5 +++-- | 7 | include/exec/helper-head.h.inc | 3 +++ |
18 | 1 file changed, 3 insertions(+), 2 deletions(-) | 8 | 1 file changed, 3 insertions(+) |
19 | 9 | ||
20 | diff --git a/accel/tcg/cputlb.c b/accel/tcg/cputlb.c | 10 | diff --git a/include/exec/helper-head.h.inc b/include/exec/helper-head.h.inc |
21 | index XXXXXXX..XXXXXXX 100644 | 11 | index XXXXXXX..XXXXXXX 100644 |
22 | --- a/accel/tcg/cputlb.c | 12 | --- a/include/exec/helper-head.h.inc |
23 | +++ b/accel/tcg/cputlb.c | 13 | +++ b/include/exec/helper-head.h.inc |
24 | @@ -XXX,XX +XXX,XX @@ static uint64_t io_readx(CPUArchState *env, CPUIOTLBEntry *iotlbentry, | 14 | @@ -XXX,XX +XXX,XX @@ |
25 | CPUTLBEntry *entry; | 15 | #define dh_alias_ptr ptr |
26 | target_ulong tlb_addr; | 16 | #define dh_alias_cptr ptr |
27 | 17 | #define dh_alias_env ptr | |
28 | - tlb_fill(cpu, addr, size, MMU_DATA_LOAD, mmu_idx, retaddr); | 18 | +#define dh_alias_fpst ptr |
29 | + tlb_fill(cpu, addr, size, access_type, mmu_idx, retaddr); | 19 | #define dh_alias_void void |
30 | 20 | #define dh_alias_noreturn noreturn | |
31 | entry = tlb_entry(env, mmu_idx, addr); | 21 | #define dh_alias(t) glue(dh_alias_, t) |
32 | - tlb_addr = entry->addr_read; | 22 | @@ -XXX,XX +XXX,XX @@ |
33 | + tlb_addr = (access_type == MMU_DATA_LOAD ? | 23 | #define dh_ctype_ptr void * |
34 | + entry->addr_read : entry->addr_code); | 24 | #define dh_ctype_cptr const void * |
35 | if (!(tlb_addr & ~(TARGET_PAGE_MASK | TLB_RECHECK))) { | 25 | #define dh_ctype_env CPUArchState * |
36 | /* RAM access */ | 26 | +#define dh_ctype_fpst float_status * |
37 | uintptr_t haddr = addr + entry->addend; | 27 | #define dh_ctype_void void |
28 | #define dh_ctype_noreturn G_NORETURN void | ||
29 | #define dh_ctype(t) dh_ctype_##t | ||
30 | @@ -XXX,XX +XXX,XX @@ | ||
31 | #define dh_typecode_f64 dh_typecode_i64 | ||
32 | #define dh_typecode_cptr dh_typecode_ptr | ||
33 | #define dh_typecode_env dh_typecode_ptr | ||
34 | +#define dh_typecode_fpst dh_typecode_ptr | ||
35 | #define dh_typecode(t) dh_typecode_##t | ||
36 | |||
37 | #define dh_callflag_i32 0 | ||
38 | -- | 38 | -- |
39 | 2.17.1 | 39 | 2.43.0 |
40 | 40 | ||
41 | 41 | diff view generated by jsdifflib |
1 | This is part c of relocation overflow handling. | 1 | From: Philippe Mathieu-Daudé <philmd@linaro.org> |
---|---|---|---|
2 | 2 | ||
3 | Rather than manually copying each register, use | ||
4 | the libc memcpy(), which is well optimized nowadays. | ||
5 | |||
6 | Suggested-by: Pierrick Bouvier <pierrick.bouvier@linaro.org> | ||
7 | Reviewed-by: Pierrick Bouvier <pierrick.bouvier@linaro.org> | ||
8 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> | ||
9 | Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org> | ||
10 | Message-ID: <20241205205418.67613-1-philmd@linaro.org> | ||
3 | Signed-off-by: Richard Henderson <richard.henderson@linaro.org> | 11 | Signed-off-by: Richard Henderson <richard.henderson@linaro.org> |
4 | --- | 12 | --- |
5 | tcg/aarch64/tcg-target.inc.c | 16 ++++++++++------ | 13 | target/sparc/win_helper.c | 26 ++++++++------------------ |
6 | tcg/arm/tcg-target.inc.c | 16 ++++++++++------ | 14 | 1 file changed, 8 insertions(+), 18 deletions(-) |
7 | tcg/i386/tcg-target.inc.c | 6 ++++-- | ||
8 | tcg/mips/tcg-target.inc.c | 6 ++++-- | ||
9 | tcg/ppc/tcg-target.inc.c | 14 ++++++++++---- | ||
10 | tcg/riscv/tcg-target.inc.c | 16 ++++++++++++---- | ||
11 | tcg/s390/tcg-target.inc.c | 20 ++++++++++++-------- | ||
12 | tcg/tcg-ldst.inc.c | 18 +++++++++--------- | ||
13 | tcg/tcg.c | 7 ++++--- | ||
14 | 9 files changed, 75 insertions(+), 44 deletions(-) | ||
15 | 15 | ||
16 | diff --git a/tcg/aarch64/tcg-target.inc.c b/tcg/aarch64/tcg-target.inc.c | 16 | diff --git a/target/sparc/win_helper.c b/target/sparc/win_helper.c |
17 | index XXXXXXX..XXXXXXX 100644 | 17 | index XXXXXXX..XXXXXXX 100644 |
18 | --- a/tcg/aarch64/tcg-target.inc.c | 18 | --- a/target/sparc/win_helper.c |
19 | +++ b/tcg/aarch64/tcg-target.inc.c | 19 | +++ b/target/sparc/win_helper.c |
20 | @@ -XXX,XX +XXX,XX @@ static inline void tcg_out_adr(TCGContext *s, TCGReg rd, void *target) | 20 | @@ -XXX,XX +XXX,XX @@ |
21 | tcg_out_insn(s, 3406, ADR, rd, offset); | 21 | #include "exec/helper-proto.h" |
22 | #include "trace.h" | ||
23 | |||
24 | -static inline void memcpy32(target_ulong *dst, const target_ulong *src) | ||
25 | -{ | ||
26 | - dst[0] = src[0]; | ||
27 | - dst[1] = src[1]; | ||
28 | - dst[2] = src[2]; | ||
29 | - dst[3] = src[3]; | ||
30 | - dst[4] = src[4]; | ||
31 | - dst[5] = src[5]; | ||
32 | - dst[6] = src[6]; | ||
33 | - dst[7] = src[7]; | ||
34 | -} | ||
35 | - | ||
36 | void cpu_set_cwp(CPUSPARCState *env, int new_cwp) | ||
37 | { | ||
38 | /* put the modified wrap registers at their proper location */ | ||
39 | if (env->cwp == env->nwindows - 1) { | ||
40 | - memcpy32(env->regbase, env->regbase + env->nwindows * 16); | ||
41 | + memcpy(env->regbase, env->regbase + env->nwindows * 16, | ||
42 | + sizeof(env->gregs)); | ||
43 | } | ||
44 | env->cwp = new_cwp; | ||
45 | |||
46 | /* put the wrap registers at their temporary location */ | ||
47 | if (new_cwp == env->nwindows - 1) { | ||
48 | - memcpy32(env->regbase + env->nwindows * 16, env->regbase); | ||
49 | + memcpy(env->regbase + env->nwindows * 16, env->regbase, | ||
50 | + sizeof(env->gregs)); | ||
51 | } | ||
52 | env->regwptr = env->regbase + (new_cwp * 16); | ||
22 | } | 53 | } |
23 | 54 | @@ -XXX,XX +XXX,XX @@ void cpu_gl_switch_gregs(CPUSPARCState *env, uint32_t new_gl) | |
24 | -static void tcg_out_qemu_ld_slow_path(TCGContext *s, TCGLabelQemuLdst *lb) | 55 | dst = get_gl_gregset(env, env->gl); |
25 | +static bool tcg_out_qemu_ld_slow_path(TCGContext *s, TCGLabelQemuLdst *lb) | 56 | |
26 | { | 57 | if (src != dst) { |
27 | TCGMemOpIdx oi = lb->oi; | 58 | - memcpy32(dst, env->gregs); |
28 | TCGMemOp opc = get_memop(oi); | 59 | - memcpy32(env->gregs, src); |
29 | TCGMemOp size = opc & MO_SIZE; | 60 | + memcpy(dst, env->gregs, sizeof(env->gregs)); |
30 | 61 | + memcpy(env->gregs, src, sizeof(env->gregs)); | |
31 | - bool ok = reloc_pc19(lb->label_ptr[0], s->code_ptr); | ||
32 | - tcg_debug_assert(ok); | ||
33 | + if (!reloc_pc19(lb->label_ptr[0], s->code_ptr)) { | ||
34 | + return false; | ||
35 | + } | ||
36 | |||
37 | tcg_out_mov(s, TCG_TYPE_PTR, TCG_REG_X0, TCG_AREG0); | ||
38 | tcg_out_mov(s, TARGET_LONG_BITS == 64, TCG_REG_X1, lb->addrlo_reg); | ||
39 | @@ -XXX,XX +XXX,XX @@ static void tcg_out_qemu_ld_slow_path(TCGContext *s, TCGLabelQemuLdst *lb) | ||
40 | } | ||
41 | |||
42 | tcg_out_goto(s, lb->raddr); | ||
43 | + return true; | ||
44 | } | ||
45 | |||
46 | -static void tcg_out_qemu_st_slow_path(TCGContext *s, TCGLabelQemuLdst *lb) | ||
47 | +static bool tcg_out_qemu_st_slow_path(TCGContext *s, TCGLabelQemuLdst *lb) | ||
48 | { | ||
49 | TCGMemOpIdx oi = lb->oi; | ||
50 | TCGMemOp opc = get_memop(oi); | ||
51 | TCGMemOp size = opc & MO_SIZE; | ||
52 | |||
53 | - bool ok = reloc_pc19(lb->label_ptr[0], s->code_ptr); | ||
54 | - tcg_debug_assert(ok); | ||
55 | + if (!reloc_pc19(lb->label_ptr[0], s->code_ptr)) { | ||
56 | + return false; | ||
57 | + } | ||
58 | |||
59 | tcg_out_mov(s, TCG_TYPE_PTR, TCG_REG_X0, TCG_AREG0); | ||
60 | tcg_out_mov(s, TARGET_LONG_BITS == 64, TCG_REG_X1, lb->addrlo_reg); | ||
61 | @@ -XXX,XX +XXX,XX @@ static void tcg_out_qemu_st_slow_path(TCGContext *s, TCGLabelQemuLdst *lb) | ||
62 | tcg_out_adr(s, TCG_REG_X4, lb->raddr); | ||
63 | tcg_out_call(s, qemu_st_helpers[opc & (MO_BSWAP | MO_SIZE)]); | ||
64 | tcg_out_goto(s, lb->raddr); | ||
65 | + return true; | ||
66 | } | ||
67 | |||
68 | static void add_qemu_ldst_label(TCGContext *s, bool is_ld, TCGMemOpIdx oi, | ||
69 | diff --git a/tcg/arm/tcg-target.inc.c b/tcg/arm/tcg-target.inc.c | ||
70 | index XXXXXXX..XXXXXXX 100644 | ||
71 | --- a/tcg/arm/tcg-target.inc.c | ||
72 | +++ b/tcg/arm/tcg-target.inc.c | ||
73 | @@ -XXX,XX +XXX,XX @@ static void add_qemu_ldst_label(TCGContext *s, bool is_ld, TCGMemOpIdx oi, | ||
74 | label->label_ptr[0] = label_ptr; | ||
75 | } | ||
76 | |||
77 | -static void tcg_out_qemu_ld_slow_path(TCGContext *s, TCGLabelQemuLdst *lb) | ||
78 | +static bool tcg_out_qemu_ld_slow_path(TCGContext *s, TCGLabelQemuLdst *lb) | ||
79 | { | ||
80 | TCGReg argreg, datalo, datahi; | ||
81 | TCGMemOpIdx oi = lb->oi; | ||
82 | TCGMemOp opc = get_memop(oi); | ||
83 | void *func; | ||
84 | |||
85 | - bool ok = reloc_pc24(lb->label_ptr[0], s->code_ptr); | ||
86 | - tcg_debug_assert(ok); | ||
87 | + if (!reloc_pc24(lb->label_ptr[0], s->code_ptr)) { | ||
88 | + return false; | ||
89 | + } | ||
90 | |||
91 | argreg = tcg_out_arg_reg32(s, TCG_REG_R0, TCG_AREG0); | ||
92 | if (TARGET_LONG_BITS == 64) { | ||
93 | @@ -XXX,XX +XXX,XX @@ static void tcg_out_qemu_ld_slow_path(TCGContext *s, TCGLabelQemuLdst *lb) | ||
94 | } | ||
95 | |||
96 | tcg_out_goto(s, COND_AL, lb->raddr); | ||
97 | + return true; | ||
98 | } | ||
99 | |||
100 | -static void tcg_out_qemu_st_slow_path(TCGContext *s, TCGLabelQemuLdst *lb) | ||
101 | +static bool tcg_out_qemu_st_slow_path(TCGContext *s, TCGLabelQemuLdst *lb) | ||
102 | { | ||
103 | TCGReg argreg, datalo, datahi; | ||
104 | TCGMemOpIdx oi = lb->oi; | ||
105 | TCGMemOp opc = get_memop(oi); | ||
106 | |||
107 | - bool ok = reloc_pc24(lb->label_ptr[0], s->code_ptr); | ||
108 | - tcg_debug_assert(ok); | ||
109 | + if (!reloc_pc24(lb->label_ptr[0], s->code_ptr)) { | ||
110 | + return false; | ||
111 | + } | ||
112 | |||
113 | argreg = TCG_REG_R0; | ||
114 | argreg = tcg_out_arg_reg32(s, argreg, TCG_AREG0); | ||
115 | @@ -XXX,XX +XXX,XX @@ static void tcg_out_qemu_st_slow_path(TCGContext *s, TCGLabelQemuLdst *lb) | ||
116 | |||
117 | /* Tail-call to the helper, which will return to the fast path. */ | ||
118 | tcg_out_goto(s, COND_AL, qemu_st_helpers[opc & (MO_BSWAP | MO_SIZE)]); | ||
119 | + return true; | ||
120 | } | ||
121 | #endif /* SOFTMMU */ | ||
122 | |||
123 | diff --git a/tcg/i386/tcg-target.inc.c b/tcg/i386/tcg-target.inc.c | ||
124 | index XXXXXXX..XXXXXXX 100644 | ||
125 | --- a/tcg/i386/tcg-target.inc.c | ||
126 | +++ b/tcg/i386/tcg-target.inc.c | ||
127 | @@ -XXX,XX +XXX,XX @@ static void add_qemu_ldst_label(TCGContext *s, bool is_ld, bool is_64, | ||
128 | /* | ||
129 | * Generate code for the slow path for a load at the end of block | ||
130 | */ | ||
131 | -static void tcg_out_qemu_ld_slow_path(TCGContext *s, TCGLabelQemuLdst *l) | ||
132 | +static bool tcg_out_qemu_ld_slow_path(TCGContext *s, TCGLabelQemuLdst *l) | ||
133 | { | ||
134 | TCGMemOpIdx oi = l->oi; | ||
135 | TCGMemOp opc = get_memop(oi); | ||
136 | @@ -XXX,XX +XXX,XX @@ static void tcg_out_qemu_ld_slow_path(TCGContext *s, TCGLabelQemuLdst *l) | ||
137 | |||
138 | /* Jump to the code corresponding to next IR of qemu_st */ | ||
139 | tcg_out_jmp(s, l->raddr); | ||
140 | + return true; | ||
141 | } | ||
142 | |||
143 | /* | ||
144 | * Generate code for the slow path for a store at the end of block | ||
145 | */ | ||
146 | -static void tcg_out_qemu_st_slow_path(TCGContext *s, TCGLabelQemuLdst *l) | ||
147 | +static bool tcg_out_qemu_st_slow_path(TCGContext *s, TCGLabelQemuLdst *l) | ||
148 | { | ||
149 | TCGMemOpIdx oi = l->oi; | ||
150 | TCGMemOp opc = get_memop(oi); | ||
151 | @@ -XXX,XX +XXX,XX @@ static void tcg_out_qemu_st_slow_path(TCGContext *s, TCGLabelQemuLdst *l) | ||
152 | /* "Tail call" to the helper, with the return address back inline. */ | ||
153 | tcg_out_push(s, retaddr); | ||
154 | tcg_out_jmp(s, qemu_st_helpers[opc & (MO_BSWAP | MO_SIZE)]); | ||
155 | + return true; | ||
156 | } | ||
157 | #elif TCG_TARGET_REG_BITS == 32 | ||
158 | # define x86_guest_base_seg 0 | ||
159 | diff --git a/tcg/mips/tcg-target.inc.c b/tcg/mips/tcg-target.inc.c | ||
160 | index XXXXXXX..XXXXXXX 100644 | ||
161 | --- a/tcg/mips/tcg-target.inc.c | ||
162 | +++ b/tcg/mips/tcg-target.inc.c | ||
163 | @@ -XXX,XX +XXX,XX @@ static void add_qemu_ldst_label(TCGContext *s, int is_ld, TCGMemOpIdx oi, | ||
164 | } | 62 | } |
165 | } | 63 | } |
166 | 64 | ||
167 | -static void tcg_out_qemu_ld_slow_path(TCGContext *s, TCGLabelQemuLdst *l) | 65 | @@ -XXX,XX +XXX,XX @@ void cpu_change_pstate(CPUSPARCState *env, uint32_t new_pstate) |
168 | +static bool tcg_out_qemu_ld_slow_path(TCGContext *s, TCGLabelQemuLdst *l) | 66 | /* Switch global register bank */ |
169 | { | 67 | src = get_gregset(env, new_pstate_regs); |
170 | TCGMemOpIdx oi = l->oi; | 68 | dst = get_gregset(env, pstate_regs); |
171 | TCGMemOp opc = get_memop(oi); | 69 | - memcpy32(dst, env->gregs); |
172 | @@ -XXX,XX +XXX,XX @@ static void tcg_out_qemu_ld_slow_path(TCGContext *s, TCGLabelQemuLdst *l) | 70 | - memcpy32(env->gregs, src); |
71 | + memcpy(dst, env->gregs, sizeof(env->gregs)); | ||
72 | + memcpy(env->gregs, src, sizeof(env->gregs)); | ||
173 | } else { | 73 | } else { |
174 | tcg_out_opc_reg(s, OPC_OR, v0, TCG_REG_V0, TCG_REG_ZERO); | 74 | trace_win_helper_no_switch_pstate(new_pstate_regs); |
175 | } | 75 | } |
176 | + return true; | ||
177 | } | ||
178 | |||
179 | -static void tcg_out_qemu_st_slow_path(TCGContext *s, TCGLabelQemuLdst *l) | ||
180 | +static bool tcg_out_qemu_st_slow_path(TCGContext *s, TCGLabelQemuLdst *l) | ||
181 | { | ||
182 | TCGMemOpIdx oi = l->oi; | ||
183 | TCGMemOp opc = get_memop(oi); | ||
184 | @@ -XXX,XX +XXX,XX @@ static void tcg_out_qemu_st_slow_path(TCGContext *s, TCGLabelQemuLdst *l) | ||
185 | tcg_out_call_int(s, qemu_st_helpers[opc & (MO_BSWAP | MO_SIZE)], true); | ||
186 | /* delay slot */ | ||
187 | tcg_out_mov(s, TCG_TYPE_PTR, tcg_target_call_iarg_regs[0], TCG_AREG0); | ||
188 | + return true; | ||
189 | } | ||
190 | #endif | ||
191 | |||
192 | diff --git a/tcg/ppc/tcg-target.inc.c b/tcg/ppc/tcg-target.inc.c | ||
193 | index XXXXXXX..XXXXXXX 100644 | ||
194 | --- a/tcg/ppc/tcg-target.inc.c | ||
195 | +++ b/tcg/ppc/tcg-target.inc.c | ||
196 | @@ -XXX,XX +XXX,XX @@ static void add_qemu_ldst_label(TCGContext *s, bool is_ld, TCGMemOpIdx oi, | ||
197 | label->label_ptr[0] = lptr; | ||
198 | } | ||
199 | |||
200 | -static void tcg_out_qemu_ld_slow_path(TCGContext *s, TCGLabelQemuLdst *lb) | ||
201 | +static bool tcg_out_qemu_ld_slow_path(TCGContext *s, TCGLabelQemuLdst *lb) | ||
202 | { | ||
203 | TCGMemOpIdx oi = lb->oi; | ||
204 | TCGMemOp opc = get_memop(oi); | ||
205 | TCGReg hi, lo, arg = TCG_REG_R3; | ||
206 | |||
207 | - **lb->label_ptr |= reloc_pc14_val(*lb->label_ptr, s->code_ptr); | ||
208 | + if (!reloc_pc14(lb->label_ptr[0], s->code_ptr)) { | ||
209 | + return false; | ||
210 | + } | ||
211 | |||
212 | tcg_out_mov(s, TCG_TYPE_PTR, arg++, TCG_AREG0); | ||
213 | |||
214 | @@ -XXX,XX +XXX,XX @@ static void tcg_out_qemu_ld_slow_path(TCGContext *s, TCGLabelQemuLdst *lb) | ||
215 | } | ||
216 | |||
217 | tcg_out_b(s, 0, lb->raddr); | ||
218 | + return true; | ||
219 | } | ||
220 | |||
221 | -static void tcg_out_qemu_st_slow_path(TCGContext *s, TCGLabelQemuLdst *lb) | ||
222 | +static bool tcg_out_qemu_st_slow_path(TCGContext *s, TCGLabelQemuLdst *lb) | ||
223 | { | ||
224 | TCGMemOpIdx oi = lb->oi; | ||
225 | TCGMemOp opc = get_memop(oi); | ||
226 | TCGMemOp s_bits = opc & MO_SIZE; | ||
227 | TCGReg hi, lo, arg = TCG_REG_R3; | ||
228 | |||
229 | - **lb->label_ptr |= reloc_pc14_val(*lb->label_ptr, s->code_ptr); | ||
230 | + if (!reloc_pc14(lb->label_ptr[0], s->code_ptr)) { | ||
231 | + return false; | ||
232 | + } | ||
233 | |||
234 | tcg_out_mov(s, TCG_TYPE_PTR, arg++, TCG_AREG0); | ||
235 | |||
236 | @@ -XXX,XX +XXX,XX @@ static void tcg_out_qemu_st_slow_path(TCGContext *s, TCGLabelQemuLdst *lb) | ||
237 | tcg_out_call(s, qemu_st_helpers[opc & (MO_BSWAP | MO_SIZE)]); | ||
238 | |||
239 | tcg_out_b(s, 0, lb->raddr); | ||
240 | + return true; | ||
241 | } | ||
242 | #endif /* SOFTMMU */ | ||
243 | |||
244 | diff --git a/tcg/riscv/tcg-target.inc.c b/tcg/riscv/tcg-target.inc.c | ||
245 | index XXXXXXX..XXXXXXX 100644 | ||
246 | --- a/tcg/riscv/tcg-target.inc.c | ||
247 | +++ b/tcg/riscv/tcg-target.inc.c | ||
248 | @@ -XXX,XX +XXX,XX @@ static void add_qemu_ldst_label(TCGContext *s, int is_ld, TCGMemOpIdx oi, | ||
249 | label->label_ptr[0] = label_ptr[0]; | ||
250 | } | ||
251 | |||
252 | -static void tcg_out_qemu_ld_slow_path(TCGContext *s, TCGLabelQemuLdst *l) | ||
253 | +static bool tcg_out_qemu_ld_slow_path(TCGContext *s, TCGLabelQemuLdst *l) | ||
254 | { | ||
255 | TCGMemOpIdx oi = l->oi; | ||
256 | TCGMemOp opc = get_memop(oi); | ||
257 | @@ -XXX,XX +XXX,XX @@ static void tcg_out_qemu_ld_slow_path(TCGContext *s, TCGLabelQemuLdst *l) | ||
258 | } | ||
259 | |||
260 | /* resolve label address */ | ||
261 | - patch_reloc(l->label_ptr[0], R_RISCV_BRANCH, (intptr_t) s->code_ptr, 0); | ||
262 | + if (!patch_reloc(l->label_ptr[0], R_RISCV_BRANCH, | ||
263 | + (intptr_t) s->code_ptr, 0)) { | ||
264 | + return false; | ||
265 | + } | ||
266 | |||
267 | /* call load helper */ | ||
268 | tcg_out_mov(s, TCG_TYPE_PTR, a0, TCG_AREG0); | ||
269 | @@ -XXX,XX +XXX,XX @@ static void tcg_out_qemu_ld_slow_path(TCGContext *s, TCGLabelQemuLdst *l) | ||
270 | tcg_out_mov(s, (opc & MO_SIZE) == MO_64, l->datalo_reg, a0); | ||
271 | |||
272 | tcg_out_goto(s, l->raddr); | ||
273 | + return true; | ||
274 | } | ||
275 | |||
276 | -static void tcg_out_qemu_st_slow_path(TCGContext *s, TCGLabelQemuLdst *l) | ||
277 | +static bool tcg_out_qemu_st_slow_path(TCGContext *s, TCGLabelQemuLdst *l) | ||
278 | { | ||
279 | TCGMemOpIdx oi = l->oi; | ||
280 | TCGMemOp opc = get_memop(oi); | ||
281 | @@ -XXX,XX +XXX,XX @@ static void tcg_out_qemu_st_slow_path(TCGContext *s, TCGLabelQemuLdst *l) | ||
282 | } | ||
283 | |||
284 | /* resolve label address */ | ||
285 | - patch_reloc(l->label_ptr[0], R_RISCV_BRANCH, (intptr_t) s->code_ptr, 0); | ||
286 | + if (!patch_reloc(l->label_ptr[0], R_RISCV_BRANCH, | ||
287 | + (intptr_t) s->code_ptr, 0)) { | ||
288 | + return false; | ||
289 | + } | ||
290 | |||
291 | /* call store helper */ | ||
292 | tcg_out_mov(s, TCG_TYPE_PTR, a0, TCG_AREG0); | ||
293 | @@ -XXX,XX +XXX,XX @@ static void tcg_out_qemu_st_slow_path(TCGContext *s, TCGLabelQemuLdst *l) | ||
294 | tcg_out_call(s, qemu_st_helpers[opc & (MO_BSWAP | MO_SSIZE)]); | ||
295 | |||
296 | tcg_out_goto(s, l->raddr); | ||
297 | + return true; | ||
298 | } | ||
299 | #endif /* CONFIG_SOFTMMU */ | ||
300 | |||
301 | diff --git a/tcg/s390/tcg-target.inc.c b/tcg/s390/tcg-target.inc.c | ||
302 | index XXXXXXX..XXXXXXX 100644 | ||
303 | --- a/tcg/s390/tcg-target.inc.c | ||
304 | +++ b/tcg/s390/tcg-target.inc.c | ||
305 | @@ -XXX,XX +XXX,XX @@ static void add_qemu_ldst_label(TCGContext *s, bool is_ld, TCGMemOpIdx oi, | ||
306 | label->label_ptr[0] = label_ptr; | ||
307 | } | ||
308 | |||
309 | -static void tcg_out_qemu_ld_slow_path(TCGContext *s, TCGLabelQemuLdst *lb) | ||
310 | +static bool tcg_out_qemu_ld_slow_path(TCGContext *s, TCGLabelQemuLdst *lb) | ||
311 | { | ||
312 | TCGReg addr_reg = lb->addrlo_reg; | ||
313 | TCGReg data_reg = lb->datalo_reg; | ||
314 | TCGMemOpIdx oi = lb->oi; | ||
315 | TCGMemOp opc = get_memop(oi); | ||
316 | |||
317 | - bool ok = patch_reloc(lb->label_ptr[0], R_390_PC16DBL, | ||
318 | - (intptr_t)s->code_ptr, 2); | ||
319 | - tcg_debug_assert(ok); | ||
320 | + if (!patch_reloc(lb->label_ptr[0], R_390_PC16DBL, | ||
321 | + (intptr_t)s->code_ptr, 2)) { | ||
322 | + return false; | ||
323 | + } | ||
324 | |||
325 | tcg_out_mov(s, TCG_TYPE_PTR, TCG_REG_R2, TCG_AREG0); | ||
326 | if (TARGET_LONG_BITS == 64) { | ||
327 | @@ -XXX,XX +XXX,XX @@ static void tcg_out_qemu_ld_slow_path(TCGContext *s, TCGLabelQemuLdst *lb) | ||
328 | tcg_out_mov(s, TCG_TYPE_I64, data_reg, TCG_REG_R2); | ||
329 | |||
330 | tgen_gotoi(s, S390_CC_ALWAYS, lb->raddr); | ||
331 | + return true; | ||
332 | } | ||
333 | |||
334 | -static void tcg_out_qemu_st_slow_path(TCGContext *s, TCGLabelQemuLdst *lb) | ||
335 | +static bool tcg_out_qemu_st_slow_path(TCGContext *s, TCGLabelQemuLdst *lb) | ||
336 | { | ||
337 | TCGReg addr_reg = lb->addrlo_reg; | ||
338 | TCGReg data_reg = lb->datalo_reg; | ||
339 | TCGMemOpIdx oi = lb->oi; | ||
340 | TCGMemOp opc = get_memop(oi); | ||
341 | |||
342 | - bool ok = patch_reloc(lb->label_ptr[0], R_390_PC16DBL, | ||
343 | - (intptr_t)s->code_ptr, 2); | ||
344 | - tcg_debug_assert(ok); | ||
345 | + if (!patch_reloc(lb->label_ptr[0], R_390_PC16DBL, | ||
346 | + (intptr_t)s->code_ptr, 2)) { | ||
347 | + return false; | ||
348 | + } | ||
349 | |||
350 | tcg_out_mov(s, TCG_TYPE_PTR, TCG_REG_R2, TCG_AREG0); | ||
351 | if (TARGET_LONG_BITS == 64) { | ||
352 | @@ -XXX,XX +XXX,XX @@ static void tcg_out_qemu_st_slow_path(TCGContext *s, TCGLabelQemuLdst *lb) | ||
353 | tcg_out_call(s, qemu_st_helpers[opc & (MO_BSWAP | MO_SIZE)]); | ||
354 | |||
355 | tgen_gotoi(s, S390_CC_ALWAYS, lb->raddr); | ||
356 | + return true; | ||
357 | } | ||
358 | #else | ||
359 | static void tcg_prepare_user_ldst(TCGContext *s, TCGReg *addr_reg, | ||
360 | diff --git a/tcg/tcg-ldst.inc.c b/tcg/tcg-ldst.inc.c | ||
361 | index XXXXXXX..XXXXXXX 100644 | ||
362 | --- a/tcg/tcg-ldst.inc.c | ||
363 | +++ b/tcg/tcg-ldst.inc.c | ||
364 | @@ -XXX,XX +XXX,XX @@ typedef struct TCGLabelQemuLdst { | ||
365 | * Generate TB finalization at the end of block | ||
366 | */ | ||
367 | |||
368 | -static void tcg_out_qemu_ld_slow_path(TCGContext *s, TCGLabelQemuLdst *l); | ||
369 | -static void tcg_out_qemu_st_slow_path(TCGContext *s, TCGLabelQemuLdst *l); | ||
370 | +static bool tcg_out_qemu_ld_slow_path(TCGContext *s, TCGLabelQemuLdst *l); | ||
371 | +static bool tcg_out_qemu_st_slow_path(TCGContext *s, TCGLabelQemuLdst *l); | ||
372 | |||
373 | -static bool tcg_out_ldst_finalize(TCGContext *s) | ||
374 | +static int tcg_out_ldst_finalize(TCGContext *s) | ||
375 | { | ||
376 | TCGLabelQemuLdst *lb; | ||
377 | |||
378 | /* qemu_ld/st slow paths */ | ||
379 | QSIMPLEQ_FOREACH(lb, &s->ldst_labels, next) { | ||
380 | - if (lb->is_ld) { | ||
381 | - tcg_out_qemu_ld_slow_path(s, lb); | ||
382 | - } else { | ||
383 | - tcg_out_qemu_st_slow_path(s, lb); | ||
384 | + if (lb->is_ld | ||
385 | + ? !tcg_out_qemu_ld_slow_path(s, lb) | ||
386 | + : !tcg_out_qemu_st_slow_path(s, lb)) { | ||
387 | + return -2; | ||
388 | } | ||
389 | |||
390 | /* Test for (pending) buffer overflow. The assumption is that any | ||
391 | @@ -XXX,XX +XXX,XX @@ static bool tcg_out_ldst_finalize(TCGContext *s) | ||
392 | the buffer completely. Thus we can test for overflow after | ||
393 | generating code without having to check during generation. */ | ||
394 | if (unlikely((void *)s->code_ptr > s->code_gen_highwater)) { | ||
395 | - return false; | ||
396 | + return -1; | ||
397 | } | ||
398 | } | ||
399 | - return true; | ||
400 | + return 0; | ||
401 | } | ||
402 | |||
403 | /* | ||
404 | diff --git a/tcg/tcg.c b/tcg/tcg.c | ||
405 | index XXXXXXX..XXXXXXX 100644 | ||
406 | --- a/tcg/tcg.c | ||
407 | +++ b/tcg/tcg.c | ||
408 | @@ -XXX,XX +XXX,XX @@ static void tcg_out_call(TCGContext *s, tcg_insn_unit *target); | ||
409 | static int tcg_target_const_match(tcg_target_long val, TCGType type, | ||
410 | const TCGArgConstraint *arg_ct); | ||
411 | #ifdef TCG_TARGET_NEED_LDST_LABELS | ||
412 | -static bool tcg_out_ldst_finalize(TCGContext *s); | ||
413 | +static int tcg_out_ldst_finalize(TCGContext *s); | ||
414 | #endif | ||
415 | |||
416 | #define TCG_HIGHWATER 1024 | ||
417 | @@ -XXX,XX +XXX,XX @@ int tcg_gen_code(TCGContext *s, TranslationBlock *tb) | ||
418 | |||
419 | /* Generate TB finalization at the end of block */ | ||
420 | #ifdef TCG_TARGET_NEED_LDST_LABELS | ||
421 | - if (!tcg_out_ldst_finalize(s)) { | ||
422 | - return -1; | ||
423 | + i = tcg_out_ldst_finalize(s); | ||
424 | + if (i < 0) { | ||
425 | + return i; | ||
426 | } | ||
427 | #endif | ||
428 | #ifdef TCG_TARGET_NEED_POOL_LABELS | ||
429 | -- | 76 | -- |
430 | 2.17.1 | 77 | 2.43.0 |
431 | 78 | ||
432 | 79 | diff view generated by jsdifflib |
Deleted patch | |||
---|---|---|---|
1 | There is no point in coding for a 2GB offset when the max TB size | ||
2 | is already limited to 64k. If we further restrict to 32k then we | ||
3 | can eliminate the extra ADDIS instruction. | ||
4 | 1 | ||
5 | Signed-off-by: Richard Henderson <richard.henderson@linaro.org> | ||
6 | --- | ||
7 | tcg/ppc/tcg-target.inc.c | 28 ++++++++++------------------ | ||
8 | 1 file changed, 10 insertions(+), 18 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 bool patch_reloc(tcg_insn_unit *code_ptr, int type, | ||
15 | intptr_t value, intptr_t addend) | ||
16 | { | ||
17 | tcg_insn_unit *target; | ||
18 | - tcg_insn_unit old; | ||
19 | |||
20 | value += addend; | ||
21 | target = (tcg_insn_unit *)value; | ||
22 | @@ -XXX,XX +XXX,XX @@ static bool patch_reloc(tcg_insn_unit *code_ptr, int type, | ||
23 | case R_PPC_REL24: | ||
24 | return reloc_pc24(code_ptr, target); | ||
25 | case R_PPC_ADDR16: | ||
26 | - /* We are abusing this relocation type. This points to a pair | ||
27 | - of insns, addis + load. If the displacement is small, we | ||
28 | - can nop out the addis. */ | ||
29 | - if (value == (int16_t)value) { | ||
30 | - code_ptr[0] = NOP; | ||
31 | - old = deposit32(code_ptr[1], 0, 16, value); | ||
32 | - code_ptr[1] = deposit32(old, 16, 5, TCG_REG_TB); | ||
33 | - } else { | ||
34 | - int16_t lo = value; | ||
35 | - int hi = value - lo; | ||
36 | - if (hi + lo != value) { | ||
37 | - return false; | ||
38 | - } | ||
39 | - code_ptr[0] = deposit32(code_ptr[0], 0, 16, hi >> 16); | ||
40 | - code_ptr[1] = deposit32(code_ptr[1], 0, 16, lo); | ||
41 | + /* | ||
42 | + * We are (slightly) abusing this relocation type. In particular, | ||
43 | + * assert that the low 2 bits are zero, and do not modify them. | ||
44 | + * That way we can use this with LD et al that have opcode bits | ||
45 | + * in the low 2 bits of the insn. | ||
46 | + */ | ||
47 | + if ((value & 3) || value != (int16_t)value) { | ||
48 | + return false; | ||
49 | } | ||
50 | + *code_ptr = (*code_ptr & ~0xfffc) | (value & 0xfffc); | ||
51 | break; | ||
52 | default: | ||
53 | g_assert_not_reached(); | ||
54 | @@ -XXX,XX +XXX,XX @@ static void tcg_out_movi_int(TCGContext *s, TCGType type, TCGReg ret, | ||
55 | if (!in_prologue && USE_REG_TB) { | ||
56 | new_pool_label(s, arg, R_PPC_ADDR16, s->code_ptr, | ||
57 | -(intptr_t)s->code_gen_ptr); | ||
58 | - tcg_out32(s, ADDIS | TAI(ret, TCG_REG_TB, 0)); | ||
59 | - tcg_out32(s, LD | TAI(ret, ret, 0)); | ||
60 | + tcg_out32(s, LD | TAI(ret, TCG_REG_TB, 0)); | ||
61 | return; | ||
62 | } | ||
63 | |||
64 | -- | ||
65 | 2.17.1 | ||
66 | |||
67 | diff view generated by jsdifflib |