1
The following changes since commit 035eed4c0d257c905a556fa0f4865a0c077b4e7f:
1
The following changes since commit aa3a285b5bc56a4208b3b57d4a55291e9c260107:
2
2
3
Merge remote-tracking branch 'remotes/vivier/tags/q800-for-5.0-pull-request' into staging (2020-01-07 17:08:21 +0000)
3
Merge tag 'mem-2024-12-21' of https://github.com/davidhildenbrand/qemu into staging (2024-12-22 14:33:27 -0500)
4
4
5
are available in the Git repository at:
5
are available in the Git repository at:
6
6
7
https://github.com/rth7680/qemu.git tags/pull-tcg-20200108
7
https://gitlab.com/rth7680/qemu.git tags/pull-tcg-20241224
8
8
9
for you to fetch changes up to 5e7ef51cbe47e726f76bfbc208e167085cf398c4:
9
for you to fetch changes up to e4a8e093dc74be049f4829831dce76e5edab0003:
10
10
11
MAINTAINERS: Replace Claudio Fontana for tcg/aarch64 (2020-01-08 11:54:12 +1100)
11
accel/tcg: Move gen_intermediate_code to TCGCPUOps.translate_core (2024-12-24 08:32:15 -0800)
12
12
13
----------------------------------------------------------------
13
----------------------------------------------------------------
14
Improve -static and -pie linking
14
tcg/optimize: Remove in-flight mask data from OptContext
15
Add cpu_{ld,st}*_mmuidx_ra
15
fpu: Add float*_muladd_scalbn
16
Remove MMU_MODE*_SUFFIX
16
fpu: Remove float_muladd_halve_result
17
Move tcg headers under include/
17
fpu: Add float_round_nearest_even_max
18
fpu: Add float_muladd_suppress_add_product_zero
19
target/hexagon: Use float32_muladd
20
accel/tcg: Move gen_intermediate_code to TCGCPUOps.translate_core
18
21
19
----------------------------------------------------------------
22
----------------------------------------------------------------
20
Philippe Mathieu-Daudé (4):
23
Ilya Leoshkevich (1):
21
tcg: Search includes from the project root source directory
24
tests/tcg: Do not use inttypes.h in multiarch/system/memory.c
22
tcg: Search includes in the parent source directory
23
tcg: Move TCG headers to include/tcg/
24
configure: Remove tcg/ from the preprocessor include search list
25
25
26
Richard Henderson (37):
26
Pierrick Bouvier (1):
27
configure: Drop adjustment of textseg
27
plugins: optimize cpu_index code generation
28
tcg: Remove softmmu code_gen_buffer fixed address
29
configure: Do not force pie=no for non-x86
30
configure: Always detect -no-pie toolchain support
31
configure: Unnest detection of -z,relro and -z,now
32
configure: Override the os default with --disable-pie
33
configure: Support -static-pie if requested
34
target/xtensa: Use probe_access for itlb_hit_test
35
cputlb: Use trace_mem_get_info instead of trace_mem_build_info
36
trace: Remove trace_mem_build_info_no_se_[bl]e
37
target/s390x: Include tcg.h in mem_helper.c
38
target/arm: Include tcg.h in sve_helper.c
39
accel/tcg: Include tcg.h in tcg-runtime.c
40
linux-user: Include tcg.h in syscall.c
41
linux-user: Include trace-root.h in syscall-trace.h
42
plugins: Include trace/mem.h in api.c
43
cputlb: Move body of cpu_ldst_template.h out of line
44
translator: Use cpu_ld*_code instead of open-coding
45
cputlb: Rename helper_ret_ld*_cmmu to cpu_ld*_code
46
cputlb: Provide cpu_(ld,st}*_mmuidx_ra for user-only
47
target/i386: Use cpu_*_mmuidx_ra instead of templates
48
cputlb: Expand cpu_ldst_useronly_template.h in user-exec.c
49
target/nios2: Remove MMU_MODE{0,1}_SUFFIX
50
target/alpha: Remove MMU_MODE{0,1}_SUFFIX
51
target/cris: Remove MMU_MODE{0,1}_SUFFIX
52
target/i386: Remove MMU_MODE{0,1,2}_SUFFIX
53
target/microblaze: Remove MMU_MODE{0,1,2}_SUFFIX
54
target/sh4: Remove MMU_MODE{0,1}_SUFFIX
55
target/unicore32: Remove MMU_MODE{0,1}_SUFFIX
56
target/xtensa: Remove MMU_MODE{0,1,2,3}_SUFFIX
57
target/m68k: Use cpu_*_mmuidx_ra instead of MMU_MODE{0,1}_SUFFIX
58
target/mips: Use cpu_*_mmuidx_ra instead of MMU_MODE*_SUFFIX
59
target/s390x: Use cpu_*_mmuidx_ra instead of MMU_MODE*_SUFFIX
60
target/ppc: Use cpu_*_mmuidx_ra instead of MMU_MODE*_SUFFIX
61
cputlb: Remove support for MMU_MODE*_SUFFIX
62
cputlb: Expand cpu_ldst_template.h in cputlb.c
63
MAINTAINERS: Replace Claudio Fontana for tcg/aarch64
64
28
65
Makefile | 2 +-
29
Richard Henderson (70):
66
accel/tcg/atomic_template.h | 67 ++---
30
tcg/optimize: Split out finish_bb, finish_ebb
67
include/exec/cpu_ldst.h | 446 +++++++++---------------------
31
tcg/optimize: Split out fold_affected_mask
68
include/exec/cpu_ldst_template.h | 211 --------------
32
tcg/optimize: Copy mask writeback to fold_masks
69
include/exec/cpu_ldst_useronly_template.h | 159 -----------
33
tcg/optimize: Split out fold_masks_zs
70
include/exec/translator.h | 48 +---
34
tcg/optimize: Augment s_mask from z_mask in fold_masks_zs
71
{tcg => include/tcg}/tcg-gvec-desc.h | 0
35
tcg/optimize: Change representation of s_mask
72
{tcg => include/tcg}/tcg-mo.h | 0
36
tcg/optimize: Use finish_folding in fold_add, fold_add_vec, fold_addsub2
73
{tcg => include/tcg}/tcg-op-gvec.h | 0
37
tcg/optimize: Introduce const value accessors for TempOptInfo
74
{tcg => include/tcg}/tcg-op.h | 2 +-
38
tcg/optimize: Use fold_masks_zs in fold_and
75
{tcg => include/tcg}/tcg-opc.h | 0
39
tcg/optimize: Use fold_masks_zs in fold_andc
76
{tcg => include/tcg}/tcg.h | 33 +--
40
tcg/optimize: Use fold_masks_zs in fold_bswap
77
include/user/syscall-trace.h | 2 +
41
tcg/optimize: Use fold_masks_zs in fold_count_zeros
78
target/alpha/cpu.h | 2 -
42
tcg/optimize: Use fold_masks_z in fold_ctpop
79
target/cris/cpu.h | 2 -
43
tcg/optimize: Use fold_and and fold_masks_z in fold_deposit
80
target/i386/cpu.h | 3 -
44
tcg/optimize: Compute sign mask in fold_deposit
81
target/m68k/cpu.h | 2 -
45
tcg/optimize: Use finish_folding in fold_divide
82
target/microblaze/cpu.h | 3 -
46
tcg/optimize: Use finish_folding in fold_dup, fold_dup2
83
target/mips/cpu.h | 4 -
47
tcg/optimize: Use fold_masks_s in fold_eqv
84
target/nios2/cpu.h | 2 -
48
tcg/optimize: Use fold_masks_z in fold_extract
85
target/ppc/cpu.h | 2 -
49
tcg/optimize: Use finish_folding in fold_extract2
86
target/s390x/cpu.h | 5 -
50
tcg/optimize: Use fold_masks_zs in fold_exts
87
target/sh4/cpu.h | 2 -
51
tcg/optimize: Use fold_masks_z in fold_extu
88
target/unicore32/cpu.h | 2 -
52
tcg/optimize: Use fold_masks_zs in fold_movcond
89
target/xtensa/cpu.h | 4 -
53
tcg/optimize: Use finish_folding in fold_mul*
90
tcg/i386/tcg-target.h | 2 +-
54
tcg/optimize: Use fold_masks_s in fold_nand
91
trace/mem-internal.h | 17 --
55
tcg/optimize: Use fold_masks_z in fold_neg_no_const
92
accel/tcg/cpu-exec.c | 2 +-
56
tcg/optimize: Use fold_masks_s in fold_nor
93
accel/tcg/cputlb.c | 315 ++++++++++++++++-----
57
tcg/optimize: Use fold_masks_s in fold_not
94
accel/tcg/tcg-runtime-gvec.c | 2 +-
58
tcg/optimize: Use fold_masks_zs in fold_or
95
accel/tcg/tcg-runtime.c | 1 +
59
tcg/optimize: Use fold_masks_zs in fold_orc
96
accel/tcg/translate-all.c | 39 +--
60
tcg/optimize: Use fold_masks_zs in fold_qemu_ld
97
accel/tcg/user-exec.c | 238 +++++++++++++++-
61
tcg/optimize: Return true from fold_qemu_st, fold_tcg_st
98
bsd-user/main.c | 2 +-
62
tcg/optimize: Use finish_folding in fold_remainder
99
cpus.c | 2 +-
63
tcg/optimize: Distinguish simplification in fold_setcond_zmask
100
exec.c | 2 +-
64
tcg/optimize: Use fold_masks_z in fold_setcond
101
linux-user/main.c | 2 +-
65
tcg/optimize: Use fold_masks_s in fold_negsetcond
102
linux-user/syscall.c | 1 +
66
tcg/optimize: Use fold_masks_z in fold_setcond2
103
plugins/api.c | 1 +
67
tcg/optimize: Use finish_folding in fold_cmp_vec
104
target/alpha/translate.c | 2 +-
68
tcg/optimize: Use finish_folding in fold_cmpsel_vec
105
target/arm/helper-a64.c | 2 +-
69
tcg/optimize: Use fold_masks_zs in fold_sextract
106
target/arm/sve_helper.c | 1 +
70
tcg/optimize: Use fold_masks_zs, fold_masks_s in fold_shift
107
target/arm/translate-a64.c | 4 +-
71
tcg/optimize: Simplify sign bit test in fold_shift
108
target/arm/translate-sve.c | 6 +-
72
tcg/optimize: Use finish_folding in fold_sub, fold_sub_vec
109
target/arm/translate.c | 4 +-
73
tcg/optimize: Use fold_masks_zs in fold_tcg_ld
110
target/cris/translate.c | 2 +-
74
tcg/optimize: Use finish_folding in fold_tcg_ld_memcopy
111
target/hppa/translate.c | 2 +-
75
tcg/optimize: Use fold_masks_zs in fold_xor
112
target/i386/mem_helper.c | 2 +-
76
tcg/optimize: Use finish_folding in fold_bitsel_vec
113
target/i386/seg_helper.c | 56 ++--
77
tcg/optimize: Use finish_folding as default in tcg_optimize
114
target/i386/translate.c | 2 +-
78
tcg/optimize: Remove z_mask, s_mask from OptContext
115
target/lm32/translate.c | 2 +-
79
tcg/optimize: Re-enable sign-mask optimizations
116
target/m68k/op_helper.c | 77 ++++--
80
tcg/optimize: Move fold_bitsel_vec into alphabetic sort
117
target/m68k/translate.c | 2 +-
81
tcg/optimize: Move fold_cmp_vec, fold_cmpsel_vec into alphabetic sort
118
target/microblaze/translate.c | 2 +-
82
softfloat: Add float{16,32,64}_muladd_scalbn
119
target/mips/op_helper.c | 182 ++++--------
83
target/arm: Use float*_muladd_scalbn
120
target/mips/translate.c | 2 +-
84
target/sparc: Use float*_muladd_scalbn
121
target/moxie/translate.c | 2 +-
85
softfloat: Remove float_muladd_halve_result
122
target/nios2/translate.c | 2 +-
86
softfloat: Add float_round_nearest_even_max
123
target/openrisc/translate.c | 2 +-
87
softfloat: Add float_muladd_suppress_add_product_zero
124
target/ppc/mem_helper.c | 13 +-
88
target/hexagon: Use float32_mul in helper_sfmpy
125
target/ppc/translate.c | 4 +-
89
target/hexagon: Use float32_muladd for helper_sffma
126
target/riscv/cpu_helper.c | 2 +-
90
target/hexagon: Use float32_muladd for helper_sffms
127
target/riscv/translate.c | 2 +-
91
target/hexagon: Use float32_muladd_scalbn for helper_sffma_sc
128
target/s390x/mem_helper.c | 11 +-
92
target/hexagon: Use float32_muladd for helper_sffm[as]_lib
129
target/s390x/translate.c | 4 +-
93
target/hexagon: Remove internal_fmafx
130
target/sh4/translate.c | 2 +-
94
target/hexagon: Expand GEN_XF_ROUND
131
target/sparc/ldst_helper.c | 2 +-
95
target/hexagon: Remove Float
132
target/sparc/translate.c | 2 +-
96
target/hexagon: Remove Double
133
target/tilegx/translate.c | 2 +-
97
target/hexagon: Use mulu64 for int128_mul_6464
134
target/tricore/translate.c | 2 +-
98
target/hexagon: Simplify internal_mpyhh setup
135
target/unicore32/translate.c | 2 +-
99
accel/tcg: Move gen_intermediate_code to TCGCPUOps.translate_core
136
target/xtensa/mmu_helper.c | 5 +-
137
target/xtensa/translate.c | 2 +-
138
tcg/aarch64/tcg-target.inc.c | 4 +-
139
tcg/arm/tcg-target.inc.c | 4 +-
140
tcg/i386/tcg-target.inc.c | 4 +-
141
tcg/mips/tcg-target.inc.c | 2 +-
142
tcg/optimize.c | 2 +-
143
tcg/ppc/tcg-target.inc.c | 4 +-
144
tcg/riscv/tcg-target.inc.c | 4 +-
145
tcg/s390/tcg-target.inc.c | 4 +-
146
tcg/sparc/tcg-target.inc.c | 2 +-
147
tcg/tcg-common.c | 2 +-
148
tcg/tcg-op-gvec.c | 8 +-
149
tcg/tcg-op-vec.c | 6 +-
150
tcg/tcg-op.c | 6 +-
151
tcg/tcg.c | 2 +-
152
tcg/tci.c | 2 +-
153
MAINTAINERS | 4 +-
154
configure | 117 +++-----
155
docs/devel/loads-stores.rst | 215 ++++++++++----
156
91 files changed, 1075 insertions(+), 1357 deletions(-)
157
delete mode 100644 include/exec/cpu_ldst_template.h
158
delete mode 100644 include/exec/cpu_ldst_useronly_template.h
159
rename {tcg => include/tcg}/tcg-gvec-desc.h (100%)
160
rename {tcg => include/tcg}/tcg-mo.h (100%)
161
rename {tcg => include/tcg}/tcg-op-gvec.h (100%)
162
rename {tcg => include/tcg}/tcg-op.h (99%)
163
rename {tcg => include/tcg}/tcg-opc.h (100%)
164
rename {tcg => include/tcg}/tcg.h (96%)
165
100
101
include/exec/translator.h | 14 -
102
include/fpu/softfloat-types.h | 2 +
103
include/fpu/softfloat.h | 14 +-
104
include/hw/core/tcg-cpu-ops.h | 13 +
105
target/alpha/cpu.h | 2 +
106
target/arm/internals.h | 2 +
107
target/avr/cpu.h | 2 +
108
target/hexagon/cpu.h | 2 +
109
target/hexagon/fma_emu.h | 3 -
110
target/hppa/cpu.h | 2 +
111
target/i386/tcg/helper-tcg.h | 2 +
112
target/loongarch/internals.h | 2 +
113
target/m68k/cpu.h | 2 +
114
target/microblaze/cpu.h | 2 +
115
target/mips/tcg/tcg-internal.h | 2 +
116
target/openrisc/cpu.h | 2 +
117
target/ppc/cpu.h | 2 +
118
target/riscv/cpu.h | 3 +
119
target/rx/cpu.h | 2 +
120
target/s390x/s390x-internal.h | 2 +
121
target/sh4/cpu.h | 2 +
122
target/sparc/cpu.h | 2 +
123
target/sparc/helper.h | 4 +-
124
target/tricore/cpu.h | 2 +
125
target/xtensa/cpu.h | 2 +
126
accel/tcg/cpu-exec.c | 8 +-
127
accel/tcg/plugin-gen.c | 9 +
128
accel/tcg/translate-all.c | 8 +-
129
fpu/softfloat.c | 63 +--
130
target/alpha/cpu.c | 1 +
131
target/alpha/translate.c | 4 +-
132
target/arm/cpu.c | 1 +
133
target/arm/tcg/cpu-v7m.c | 1 +
134
target/arm/tcg/helper-a64.c | 6 +-
135
target/arm/tcg/translate.c | 5 +-
136
target/avr/cpu.c | 1 +
137
target/avr/translate.c | 6 +-
138
target/hexagon/cpu.c | 1 +
139
target/hexagon/fma_emu.c | 496 ++++++---------------
140
target/hexagon/op_helper.c | 125 ++----
141
target/hexagon/translate.c | 4 +-
142
target/hppa/cpu.c | 1 +
143
target/hppa/translate.c | 4 +-
144
target/i386/tcg/tcg-cpu.c | 1 +
145
target/i386/tcg/translate.c | 5 +-
146
target/loongarch/cpu.c | 1 +
147
target/loongarch/tcg/translate.c | 4 +-
148
target/m68k/cpu.c | 1 +
149
target/m68k/translate.c | 4 +-
150
target/microblaze/cpu.c | 1 +
151
target/microblaze/translate.c | 4 +-
152
target/mips/cpu.c | 1 +
153
target/mips/tcg/translate.c | 4 +-
154
target/openrisc/cpu.c | 1 +
155
target/openrisc/translate.c | 4 +-
156
target/ppc/cpu_init.c | 1 +
157
target/ppc/translate.c | 4 +-
158
target/riscv/tcg/tcg-cpu.c | 1 +
159
target/riscv/translate.c | 4 +-
160
target/rx/cpu.c | 1 +
161
target/rx/translate.c | 4 +-
162
target/s390x/cpu.c | 1 +
163
target/s390x/tcg/translate.c | 4 +-
164
target/sh4/cpu.c | 1 +
165
target/sh4/translate.c | 4 +-
166
target/sparc/cpu.c | 1 +
167
target/sparc/fop_helper.c | 8 +-
168
target/sparc/translate.c | 84 ++--
169
target/tricore/cpu.c | 1 +
170
target/tricore/translate.c | 5 +-
171
target/xtensa/cpu.c | 1 +
172
target/xtensa/translate.c | 4 +-
173
tcg/optimize.c | 857 +++++++++++++++++++-----------------
174
tests/tcg/multiarch/system/memory.c | 9 +-
175
fpu/softfloat-parts.c.inc | 16 +-
176
75 files changed, 866 insertions(+), 1009 deletions(-)
diff view generated by jsdifflib
New patch
1
From: Ilya Leoshkevich <iii@linux.ibm.com>
1
2
3
make check-tcg fails on Fedora with the following error message:
4
5
alpha-linux-gnu-gcc [...] qemu/tests/tcg/multiarch/system/memory.c -o memory [...]
6
qemu/tests/tcg/multiarch/system/memory.c:17:10: fatal error: inttypes.h: No such file or directory
7
17 | #include <inttypes.h>
8
| ^~~~~~~~~~~~
9
compilation terminated.
10
11
The reason is that Fedora has cross-compilers, but no cross-glibc
12
headers. Fix by hardcoding the format specifiers and dropping the
13
include.
14
15
An alternative fix would be to introduce a configure check for
16
inttypes.h. But this would make it impossible to use Fedora
17
cross-compilers for softmmu tests, which used to work so far.
18
19
Fixes: ecbcc9ead2f8 ("tests/tcg: add a system test to check memory instrumentation")
20
Signed-off-by: Ilya Leoshkevich <iii@linux.ibm.com>
21
Reviewed-by: Paolo Bonzini <pbonzini@redhat.com>
22
Message-ID: <20241010085906.226249-1-iii@linux.ibm.com>
23
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
24
---
25
tests/tcg/multiarch/system/memory.c | 9 ++++-----
26
1 file changed, 4 insertions(+), 5 deletions(-)
27
28
diff --git a/tests/tcg/multiarch/system/memory.c b/tests/tcg/multiarch/system/memory.c
29
index XXXXXXX..XXXXXXX 100644
30
--- a/tests/tcg/multiarch/system/memory.c
31
+++ b/tests/tcg/multiarch/system/memory.c
32
@@ -XXX,XX +XXX,XX @@
33
34
#include <stdint.h>
35
#include <stdbool.h>
36
-#include <inttypes.h>
37
#include <minilib.h>
38
39
#ifndef CHECK_UNALIGNED
40
@@ -XXX,XX +XXX,XX @@ int main(void)
41
int i;
42
bool ok = true;
43
44
- ml_printf("Test data start: 0x%"PRIxPTR"\n", &test_data[0]);
45
- ml_printf("Test data end: 0x%"PRIxPTR"\n", &test_data[TEST_SIZE]);
46
+ ml_printf("Test data start: 0x%lx\n", (unsigned long)&test_data[0]);
47
+ ml_printf("Test data end: 0x%lx\n", (unsigned long)&test_data[TEST_SIZE]);
48
49
/* Run through the unsigned tests first */
50
for (i = 0; i < ARRAY_SIZE(init_ufns) && ok; i++) {
51
@@ -XXX,XX +XXX,XX @@ int main(void)
52
ok = do_signed_reads(true);
53
}
54
55
- ml_printf("Test data read: %"PRId32"\n", test_read_count);
56
- ml_printf("Test data write: %"PRId32"\n", test_write_count);
57
+ ml_printf("Test data read: %lu\n", (unsigned long)test_read_count);
58
+ ml_printf("Test data write: %lu\n", (unsigned long)test_write_count);
59
ml_printf("Test complete: %s\n", ok ? "PASSED" : "FAILED");
60
return ok ? 0 : -1;
61
}
62
--
63
2.43.0
diff view generated by jsdifflib
New patch
1
From: Pierrick Bouvier <pierrick.bouvier@linaro.org>
1
2
3
When running with a single vcpu, we can return a constant instead of a
4
load when accessing cpu_index.
5
A side effect is that all tcg operations using it are optimized, most
6
notably scoreboard access.
7
When running a simple loop in user-mode, the speedup is around 20%.
8
9
Signed-off-by: Pierrick Bouvier <pierrick.bouvier@linaro.org>
10
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
11
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
12
Message-ID: <20241128213843.1023080-1-pierrick.bouvier@linaro.org>
13
---
14
accel/tcg/plugin-gen.c | 9 +++++++++
15
1 file changed, 9 insertions(+)
16
17
diff --git a/accel/tcg/plugin-gen.c b/accel/tcg/plugin-gen.c
18
index XXXXXXX..XXXXXXX 100644
19
--- a/accel/tcg/plugin-gen.c
20
+++ b/accel/tcg/plugin-gen.c
21
@@ -XXX,XX +XXX,XX @@ static void gen_disable_mem_helper(void)
22
23
static TCGv_i32 gen_cpu_index(void)
24
{
25
+ /*
26
+ * Optimize when we run with a single vcpu. All values using cpu_index,
27
+ * including scoreboard index, will be optimized out.
28
+ * User-mode calls tb_flush when setting this flag. In system-mode, all
29
+ * vcpus are created before generating code.
30
+ */
31
+ if (!tcg_cflags_has(current_cpu, CF_PARALLEL)) {
32
+ return tcg_constant_i32(current_cpu->cpu_index);
33
+ }
34
TCGv_i32 cpu_index = tcg_temp_ebb_new_i32();
35
tcg_gen_ld_i32(cpu_index, tcg_env,
36
-offsetof(ArchCPU, env) + offsetof(CPUState, cpu_index));
37
--
38
2.43.0
diff view generated by jsdifflib
1
With the tracing hooks, the inline functions are no longer
1
Call them directly from the opcode switch statement in tcg_optimize,
2
so simple. Reduce the amount of preprocessor obfuscation
2
rather than in finish_folding based on opcode flags. Adjust folding
3
by expanding the text of each of the functions generated.
3
of conditional branches to match.
4
4
5
Tested-by: Philippe Mathieu-Daudé <philmd@redhat.com>
5
Reviewed-by: Pierrick Bouvier <pierrick.bouvier@linaro.org>
6
Reviewed-by: Alex Bennée <alex.bennee@linaro.org>
7
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
6
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
8
---
7
---
9
include/exec/cpu_ldst.h | 54 +++--
8
tcg/optimize.c | 47 +++++++++++++++++++++++++++++++----------------
10
include/exec/cpu_ldst_useronly_template.h | 159 ---------------
9
1 file changed, 31 insertions(+), 16 deletions(-)
11
accel/tcg/user-exec.c | 236 ++++++++++++++++++++++
12
3 files changed, 262 insertions(+), 187 deletions(-)
13
delete mode 100644 include/exec/cpu_ldst_useronly_template.h
14
10
15
diff --git a/include/exec/cpu_ldst.h b/include/exec/cpu_ldst.h
11
diff --git a/tcg/optimize.c b/tcg/optimize.c
16
index XXXXXXX..XXXXXXX 100644
12
index XXXXXXX..XXXXXXX 100644
17
--- a/include/exec/cpu_ldst.h
13
--- a/tcg/optimize.c
18
+++ b/include/exec/cpu_ldst.h
14
+++ b/tcg/optimize.c
19
@@ -XXX,XX +XXX,XX @@ static inline void clear_helper_retaddr(void)
15
@@ -XXX,XX +XXX,XX @@ static void copy_propagate(OptContext *ctx, TCGOp *op,
20
16
}
21
/* In user-only mode we provide only the _code and _data accessors. */
22
23
-#define MEMSUFFIX _data
24
-#define DATA_SIZE 1
25
-#include "exec/cpu_ldst_useronly_template.h"
26
+uint32_t cpu_ldub_data(CPUArchState *env, abi_ptr ptr);
27
+uint32_t cpu_lduw_data(CPUArchState *env, abi_ptr ptr);
28
+uint32_t cpu_ldl_data(CPUArchState *env, abi_ptr ptr);
29
+uint64_t cpu_ldq_data(CPUArchState *env, abi_ptr ptr);
30
+int cpu_ldsb_data(CPUArchState *env, abi_ptr ptr);
31
+int cpu_ldsw_data(CPUArchState *env, abi_ptr ptr);
32
33
-#define DATA_SIZE 2
34
-#include "exec/cpu_ldst_useronly_template.h"
35
+uint32_t cpu_ldub_data_ra(CPUArchState *env, abi_ptr ptr, uintptr_t retaddr);
36
+uint32_t cpu_lduw_data_ra(CPUArchState *env, abi_ptr ptr, uintptr_t retaddr);
37
+uint32_t cpu_ldl_data_ra(CPUArchState *env, abi_ptr ptr, uintptr_t retaddr);
38
+uint64_t cpu_ldq_data_ra(CPUArchState *env, abi_ptr ptr, uintptr_t retaddr);
39
+int cpu_ldsb_data_ra(CPUArchState *env, abi_ptr ptr, uintptr_t retaddr);
40
+int cpu_ldsw_data_ra(CPUArchState *env, abi_ptr ptr, uintptr_t retaddr);
41
42
-#define DATA_SIZE 4
43
-#include "exec/cpu_ldst_useronly_template.h"
44
+void cpu_stb_data(CPUArchState *env, abi_ptr ptr, uint32_t val);
45
+void cpu_stw_data(CPUArchState *env, abi_ptr ptr, uint32_t val);
46
+void cpu_stl_data(CPUArchState *env, abi_ptr ptr, uint32_t val);
47
+void cpu_stq_data(CPUArchState *env, abi_ptr ptr, uint64_t val);
48
49
-#define DATA_SIZE 8
50
-#include "exec/cpu_ldst_useronly_template.h"
51
-#undef MEMSUFFIX
52
-
53
-#define MEMSUFFIX _code
54
-#define CODE_ACCESS
55
-#define DATA_SIZE 1
56
-#include "exec/cpu_ldst_useronly_template.h"
57
-
58
-#define DATA_SIZE 2
59
-#include "exec/cpu_ldst_useronly_template.h"
60
-
61
-#define DATA_SIZE 4
62
-#include "exec/cpu_ldst_useronly_template.h"
63
-
64
-#define DATA_SIZE 8
65
-#include "exec/cpu_ldst_useronly_template.h"
66
-#undef MEMSUFFIX
67
-#undef CODE_ACCESS
68
+void cpu_stb_data_ra(CPUArchState *env, abi_ptr ptr,
69
+ uint32_t val, uintptr_t retaddr);
70
+void cpu_stw_data_ra(CPUArchState *env, abi_ptr ptr,
71
+ uint32_t val, uintptr_t retaddr);
72
+void cpu_stl_data_ra(CPUArchState *env, abi_ptr ptr,
73
+ uint32_t val, uintptr_t retaddr);
74
+void cpu_stq_data_ra(CPUArchState *env, abi_ptr ptr,
75
+ uint64_t val, uintptr_t retaddr);
76
77
/*
78
* Provide the same *_mmuidx_ra interface as for softmmu.
79
@@ -XXX,XX +XXX,XX @@ void cpu_stq_mmuidx_ra(CPUArchState *env, abi_ptr addr, uint64_t val,
80
#undef CPU_MMU_INDEX
81
#undef MEMSUFFIX
82
83
+#endif /* defined(CONFIG_USER_ONLY) */
84
+
85
uint32_t cpu_ldub_code(CPUArchState *env, abi_ptr addr);
86
uint32_t cpu_lduw_code(CPUArchState *env, abi_ptr addr);
87
uint32_t cpu_ldl_code(CPUArchState *env, abi_ptr addr);
88
@@ -XXX,XX +XXX,XX @@ static inline int cpu_ldsw_code(CPUArchState *env, abi_ptr addr)
89
return (int16_t)cpu_lduw_code(env, addr);
90
}
17
}
91
18
92
-#endif /* defined(CONFIG_USER_ONLY) */
19
+static void finish_bb(OptContext *ctx)
93
-
94
/**
95
* tlb_vaddr_to_host:
96
* @env: CPUArchState
97
diff --git a/include/exec/cpu_ldst_useronly_template.h b/include/exec/cpu_ldst_useronly_template.h
98
deleted file mode 100644
99
index XXXXXXX..XXXXXXX
100
--- a/include/exec/cpu_ldst_useronly_template.h
101
+++ /dev/null
102
@@ -XXX,XX +XXX,XX @@
103
-/*
104
- * User-only accessor function support
105
- *
106
- * Generate inline load/store functions for one data size.
107
- *
108
- * Generate a store function as well as signed and unsigned loads.
109
- *
110
- * Not used directly but included from cpu_ldst.h.
111
- *
112
- * Copyright (c) 2015 Linaro Limited
113
- *
114
- * This library is free software; you can redistribute it and/or
115
- * modify it under the terms of the GNU Lesser General Public
116
- * License as published by the Free Software Foundation; either
117
- * version 2 of the License, or (at your option) any later version.
118
- *
119
- * This library is distributed in the hope that it will be useful,
120
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
121
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
122
- * Lesser General Public License for more details.
123
- *
124
- * You should have received a copy of the GNU Lesser General Public
125
- * License along with this library; if not, see <http://www.gnu.org/licenses/>.
126
- */
127
-
128
-#if !defined(CODE_ACCESS)
129
-#include "trace-root.h"
130
-#endif
131
-
132
-#include "trace/mem.h"
133
-
134
-#if DATA_SIZE == 8
135
-#define SUFFIX q
136
-#define USUFFIX q
137
-#define DATA_TYPE uint64_t
138
-#define SHIFT 3
139
-#elif DATA_SIZE == 4
140
-#define SUFFIX l
141
-#define USUFFIX l
142
-#define DATA_TYPE uint32_t
143
-#define SHIFT 2
144
-#elif DATA_SIZE == 2
145
-#define SUFFIX w
146
-#define USUFFIX uw
147
-#define DATA_TYPE uint16_t
148
-#define DATA_STYPE int16_t
149
-#define SHIFT 1
150
-#elif DATA_SIZE == 1
151
-#define SUFFIX b
152
-#define USUFFIX ub
153
-#define DATA_TYPE uint8_t
154
-#define DATA_STYPE int8_t
155
-#define SHIFT 0
156
-#else
157
-#error unsupported data size
158
-#endif
159
-
160
-#if DATA_SIZE == 8
161
-#define RES_TYPE uint64_t
162
-#else
163
-#define RES_TYPE uint32_t
164
-#endif
165
-
166
-static inline RES_TYPE
167
-glue(glue(cpu_ld, USUFFIX), MEMSUFFIX)(CPUArchState *env, abi_ptr ptr)
168
-{
169
- RES_TYPE ret;
170
-#ifdef CODE_ACCESS
171
- set_helper_retaddr(1);
172
- ret = glue(glue(ld, USUFFIX), _p)(g2h(ptr));
173
- clear_helper_retaddr();
174
-#else
175
- MemOp op = MO_TE | SHIFT;
176
- uint16_t meminfo = trace_mem_get_info(op, MMU_USER_IDX, false);
177
- trace_guest_mem_before_exec(env_cpu(env), ptr, meminfo);
178
- ret = glue(glue(ld, USUFFIX), _p)(g2h(ptr));
179
-#endif
180
- return ret;
181
-}
182
-
183
-#ifndef CODE_ACCESS
184
-static inline RES_TYPE
185
-glue(glue(glue(cpu_ld, USUFFIX), MEMSUFFIX), _ra)(CPUArchState *env,
186
- abi_ptr ptr,
187
- uintptr_t retaddr)
188
-{
189
- RES_TYPE ret;
190
- set_helper_retaddr(retaddr);
191
- ret = glue(glue(cpu_ld, USUFFIX), MEMSUFFIX)(env, ptr);
192
- clear_helper_retaddr();
193
- return ret;
194
-}
195
-#endif
196
-
197
-#if DATA_SIZE <= 2
198
-static inline int
199
-glue(glue(cpu_lds, SUFFIX), MEMSUFFIX)(CPUArchState *env, abi_ptr ptr)
200
-{
201
- int ret;
202
-#ifdef CODE_ACCESS
203
- set_helper_retaddr(1);
204
- ret = glue(glue(lds, SUFFIX), _p)(g2h(ptr));
205
- clear_helper_retaddr();
206
-#else
207
- MemOp op = MO_TE | MO_SIGN | SHIFT;
208
- uint16_t meminfo = trace_mem_get_info(op, MMU_USER_IDX, false);
209
- trace_guest_mem_before_exec(env_cpu(env), ptr, meminfo);
210
- ret = glue(glue(lds, SUFFIX), _p)(g2h(ptr));
211
- qemu_plugin_vcpu_mem_cb(env_cpu(env), ptr, meminfo);
212
-#endif
213
- return ret;
214
-}
215
-
216
-#ifndef CODE_ACCESS
217
-static inline int
218
-glue(glue(glue(cpu_lds, SUFFIX), MEMSUFFIX), _ra)(CPUArchState *env,
219
- abi_ptr ptr,
220
- uintptr_t retaddr)
221
-{
222
- int ret;
223
- set_helper_retaddr(retaddr);
224
- ret = glue(glue(cpu_lds, SUFFIX), MEMSUFFIX)(env, ptr);
225
- clear_helper_retaddr();
226
- return ret;
227
-}
228
-#endif /* CODE_ACCESS */
229
-#endif /* DATA_SIZE <= 2 */
230
-
231
-#ifndef CODE_ACCESS
232
-static inline void
233
-glue(glue(cpu_st, SUFFIX), MEMSUFFIX)(CPUArchState *env, abi_ptr ptr,
234
- RES_TYPE v)
235
-{
236
- MemOp op = MO_TE | SHIFT;
237
- uint16_t meminfo = trace_mem_get_info(op, MMU_USER_IDX, true);
238
- trace_guest_mem_before_exec(env_cpu(env), ptr, meminfo);
239
- glue(glue(st, SUFFIX), _p)(g2h(ptr), v);
240
- qemu_plugin_vcpu_mem_cb(env_cpu(env), ptr, meminfo);
241
-}
242
-
243
-static inline void
244
-glue(glue(glue(cpu_st, SUFFIX), MEMSUFFIX), _ra)(CPUArchState *env,
245
- abi_ptr ptr,
246
- RES_TYPE v,
247
- uintptr_t retaddr)
248
-{
249
- set_helper_retaddr(retaddr);
250
- glue(glue(cpu_st, SUFFIX), MEMSUFFIX)(env, ptr, v);
251
- clear_helper_retaddr();
252
-}
253
-#endif
254
-
255
-#undef RES_TYPE
256
-#undef DATA_TYPE
257
-#undef DATA_STYPE
258
-#undef SUFFIX
259
-#undef USUFFIX
260
-#undef DATA_SIZE
261
-#undef SHIFT
262
diff --git a/accel/tcg/user-exec.c b/accel/tcg/user-exec.c
263
index XXXXXXX..XXXXXXX 100644
264
--- a/accel/tcg/user-exec.c
265
+++ b/accel/tcg/user-exec.c
266
@@ -XXX,XX +XXX,XX @@
267
#include "translate-all.h"
268
#include "exec/helper-proto.h"
269
#include "qemu/atomic128.h"
270
+#include "trace-root.h"
271
+#include "trace/mem.h"
272
273
#undef EAX
274
#undef ECX
275
@@ -XXX,XX +XXX,XX @@ int cpu_signal_handler(int host_signum, void *pinfo,
276
277
/* The softmmu versions of these helpers are in cputlb.c. */
278
279
+uint32_t cpu_ldub_data(CPUArchState *env, abi_ptr ptr)
280
+{
20
+{
281
+ uint32_t ret;
21
+ /* We only optimize memory barriers across basic blocks. */
282
+ uint16_t meminfo = trace_mem_get_info(MO_UB, MMU_USER_IDX, false);
22
+ ctx->prev_mb = NULL;
283
+
284
+ trace_guest_mem_before_exec(env_cpu(env), ptr, meminfo);
285
+ ret = ldub_p(g2h(ptr));
286
+ qemu_plugin_vcpu_mem_cb(env_cpu(env), ptr, meminfo);
287
+ return ret;
288
+}
23
+}
289
+
24
+
290
+int cpu_ldsb_data(CPUArchState *env, abi_ptr ptr)
25
+static void finish_ebb(OptContext *ctx)
291
+{
26
+{
292
+ int ret;
27
+ finish_bb(ctx);
293
+ uint16_t meminfo = trace_mem_get_info(MO_SB, MMU_USER_IDX, false);
28
+ /* We only optimize across extended basic blocks. */
294
+
29
+ memset(&ctx->temps_used, 0, sizeof(ctx->temps_used));
295
+ trace_guest_mem_before_exec(env_cpu(env), ptr, meminfo);
30
+ remove_mem_copy_all(ctx);
296
+ ret = ldsb_p(g2h(ptr));
297
+ qemu_plugin_vcpu_mem_cb(env_cpu(env), ptr, meminfo);
298
+ return ret;
299
+}
31
+}
300
+
32
+
301
+uint32_t cpu_lduw_data(CPUArchState *env, abi_ptr ptr)
33
static void finish_folding(OptContext *ctx, TCGOp *op)
302
+{
34
{
303
+ uint32_t ret;
35
const TCGOpDef *def = &tcg_op_defs[op->opc];
304
+ uint16_t meminfo = trace_mem_get_info(MO_TEUW, MMU_USER_IDX, false);
36
int i, nb_oargs;
37
38
- /*
39
- * We only optimize extended basic blocks. If the opcode ends a BB
40
- * and is not a conditional branch, reset all temp data.
41
- */
42
- if (def->flags & TCG_OPF_BB_END) {
43
- ctx->prev_mb = NULL;
44
- if (!(def->flags & TCG_OPF_COND_BRANCH)) {
45
- memset(&ctx->temps_used, 0, sizeof(ctx->temps_used));
46
- remove_mem_copy_all(ctx);
47
- }
48
- return;
49
- }
50
-
51
nb_oargs = def->nb_oargs;
52
for (i = 0; i < nb_oargs; i++) {
53
TCGTemp *ts = arg_temp(op->args[i]);
54
@@ -XXX,XX +XXX,XX @@ static bool fold_brcond(OptContext *ctx, TCGOp *op)
55
if (i > 0) {
56
op->opc = INDEX_op_br;
57
op->args[0] = op->args[3];
58
+ finish_ebb(ctx);
59
+ } else {
60
+ finish_bb(ctx);
61
}
62
- return false;
63
+ return true;
64
}
65
66
static bool fold_brcond2(OptContext *ctx, TCGOp *op)
67
@@ -XXX,XX +XXX,XX @@ static bool fold_brcond2(OptContext *ctx, TCGOp *op)
68
}
69
op->opc = INDEX_op_br;
70
op->args[0] = label;
71
- break;
72
+ finish_ebb(ctx);
73
+ return true;
74
}
75
- return false;
305
+
76
+
306
+ trace_guest_mem_before_exec(env_cpu(env), ptr, meminfo);
77
+ finish_bb(ctx);
307
+ ret = lduw_p(g2h(ptr));
78
+ return true;
308
+ qemu_plugin_vcpu_mem_cb(env_cpu(env), ptr, meminfo);
79
}
309
+ return ret;
80
310
+}
81
static bool fold_bswap(OptContext *ctx, TCGOp *op)
311
+
82
@@ -XXX,XX +XXX,XX @@ void tcg_optimize(TCGContext *s)
312
+int cpu_ldsw_data(CPUArchState *env, abi_ptr ptr)
83
CASE_OP_32_64_VEC(xor):
313
+{
84
done = fold_xor(&ctx, op);
314
+ int ret;
85
break;
315
+ uint16_t meminfo = trace_mem_get_info(MO_TESW, MMU_USER_IDX, false);
86
+ case INDEX_op_set_label:
316
+
87
+ case INDEX_op_br:
317
+ trace_guest_mem_before_exec(env_cpu(env), ptr, meminfo);
88
+ case INDEX_op_exit_tb:
318
+ ret = ldsw_p(g2h(ptr));
89
+ case INDEX_op_goto_tb:
319
+ qemu_plugin_vcpu_mem_cb(env_cpu(env), ptr, meminfo);
90
+ case INDEX_op_goto_ptr:
320
+ return ret;
91
+ finish_ebb(&ctx);
321
+}
92
+ done = true;
322
+
93
+ break;
323
+uint32_t cpu_ldl_data(CPUArchState *env, abi_ptr ptr)
94
default:
324
+{
95
break;
325
+ uint32_t ret;
96
}
326
+ uint16_t meminfo = trace_mem_get_info(MO_TEUL, MMU_USER_IDX, false);
327
+
328
+ trace_guest_mem_before_exec(env_cpu(env), ptr, meminfo);
329
+ ret = ldl_p(g2h(ptr));
330
+ qemu_plugin_vcpu_mem_cb(env_cpu(env), ptr, meminfo);
331
+ return ret;
332
+}
333
+
334
+uint64_t cpu_ldq_data(CPUArchState *env, abi_ptr ptr)
335
+{
336
+ uint64_t ret;
337
+ uint16_t meminfo = trace_mem_get_info(MO_TEQ, MMU_USER_IDX, false);
338
+
339
+ trace_guest_mem_before_exec(env_cpu(env), ptr, meminfo);
340
+ ret = ldq_p(g2h(ptr));
341
+ qemu_plugin_vcpu_mem_cb(env_cpu(env), ptr, meminfo);
342
+ return ret;
343
+}
344
+
345
+uint32_t cpu_ldub_data_ra(CPUArchState *env, abi_ptr ptr, uintptr_t retaddr)
346
+{
347
+ uint32_t ret;
348
+
349
+ set_helper_retaddr(retaddr);
350
+ ret = cpu_ldub_data(env, ptr);
351
+ clear_helper_retaddr();
352
+ return ret;
353
+}
354
+
355
+int cpu_ldsb_data_ra(CPUArchState *env, abi_ptr ptr, uintptr_t retaddr)
356
+{
357
+ int ret;
358
+
359
+ set_helper_retaddr(retaddr);
360
+ ret = cpu_ldsb_data(env, ptr);
361
+ clear_helper_retaddr();
362
+ return ret;
363
+}
364
+
365
+uint32_t cpu_lduw_data_ra(CPUArchState *env, abi_ptr ptr, uintptr_t retaddr)
366
+{
367
+ uint32_t ret;
368
+
369
+ set_helper_retaddr(retaddr);
370
+ ret = cpu_lduw_data(env, ptr);
371
+ clear_helper_retaddr();
372
+ return ret;
373
+}
374
+
375
+int cpu_ldsw_data_ra(CPUArchState *env, abi_ptr ptr, uintptr_t retaddr)
376
+{
377
+ int ret;
378
+
379
+ set_helper_retaddr(retaddr);
380
+ ret = cpu_ldsw_data(env, ptr);
381
+ clear_helper_retaddr();
382
+ return ret;
383
+}
384
+
385
+uint32_t cpu_ldl_data_ra(CPUArchState *env, abi_ptr ptr, uintptr_t retaddr)
386
+{
387
+ uint32_t ret;
388
+
389
+ set_helper_retaddr(retaddr);
390
+ ret = cpu_ldl_data(env, ptr);
391
+ clear_helper_retaddr();
392
+ return ret;
393
+}
394
+
395
+uint64_t cpu_ldq_data_ra(CPUArchState *env, abi_ptr ptr, uintptr_t retaddr)
396
+{
397
+ uint64_t ret;
398
+
399
+ set_helper_retaddr(retaddr);
400
+ ret = cpu_ldq_data(env, ptr);
401
+ clear_helper_retaddr();
402
+ return ret;
403
+}
404
+
405
+void cpu_stb_data(CPUArchState *env, abi_ptr ptr, uint32_t val)
406
+{
407
+ uint16_t meminfo = trace_mem_get_info(MO_UB, MMU_USER_IDX, true);
408
+
409
+ trace_guest_mem_before_exec(env_cpu(env), ptr, meminfo);
410
+ stb_p(g2h(ptr), val);
411
+ qemu_plugin_vcpu_mem_cb(env_cpu(env), ptr, meminfo);
412
+}
413
+
414
+void cpu_stw_data(CPUArchState *env, abi_ptr ptr, uint32_t val)
415
+{
416
+ uint16_t meminfo = trace_mem_get_info(MO_TEUW, MMU_USER_IDX, true);
417
+
418
+ trace_guest_mem_before_exec(env_cpu(env), ptr, meminfo);
419
+ stw_p(g2h(ptr), val);
420
+ qemu_plugin_vcpu_mem_cb(env_cpu(env), ptr, meminfo);
421
+}
422
+
423
+void cpu_stl_data(CPUArchState *env, abi_ptr ptr, uint32_t val)
424
+{
425
+ uint16_t meminfo = trace_mem_get_info(MO_TEUL, MMU_USER_IDX, true);
426
+
427
+ trace_guest_mem_before_exec(env_cpu(env), ptr, meminfo);
428
+ stl_p(g2h(ptr), val);
429
+ qemu_plugin_vcpu_mem_cb(env_cpu(env), ptr, meminfo);
430
+}
431
+
432
+void cpu_stq_data(CPUArchState *env, abi_ptr ptr, uint64_t val)
433
+{
434
+ uint16_t meminfo = trace_mem_get_info(MO_TEQ, MMU_USER_IDX, true);
435
+
436
+ trace_guest_mem_before_exec(env_cpu(env), ptr, meminfo);
437
+ stq_p(g2h(ptr), val);
438
+ qemu_plugin_vcpu_mem_cb(env_cpu(env), ptr, meminfo);
439
+}
440
+
441
+void cpu_stb_data_ra(CPUArchState *env, abi_ptr ptr,
442
+ uint32_t val, uintptr_t retaddr)
443
+{
444
+ set_helper_retaddr(retaddr);
445
+ cpu_stb_data(env, ptr, val);
446
+ clear_helper_retaddr();
447
+}
448
+
449
+void cpu_stw_data_ra(CPUArchState *env, abi_ptr ptr,
450
+ uint32_t val, uintptr_t retaddr)
451
+{
452
+ set_helper_retaddr(retaddr);
453
+ cpu_stw_data(env, ptr, val);
454
+ clear_helper_retaddr();
455
+}
456
+
457
+void cpu_stl_data_ra(CPUArchState *env, abi_ptr ptr,
458
+ uint32_t val, uintptr_t retaddr)
459
+{
460
+ set_helper_retaddr(retaddr);
461
+ cpu_stl_data(env, ptr, val);
462
+ clear_helper_retaddr();
463
+}
464
+
465
+void cpu_stq_data_ra(CPUArchState *env, abi_ptr ptr,
466
+ uint64_t val, uintptr_t retaddr)
467
+{
468
+ set_helper_retaddr(retaddr);
469
+ cpu_stq_data(env, ptr, val);
470
+ clear_helper_retaddr();
471
+}
472
+
473
+uint32_t cpu_ldub_code(CPUArchState *env, abi_ptr ptr)
474
+{
475
+ uint32_t ret;
476
+
477
+ set_helper_retaddr(1);
478
+ ret = ldub_p(g2h(ptr));
479
+ clear_helper_retaddr();
480
+ return ret;
481
+}
482
+
483
+uint32_t cpu_lduw_code(CPUArchState *env, abi_ptr ptr)
484
+{
485
+ uint32_t ret;
486
+
487
+ set_helper_retaddr(1);
488
+ ret = lduw_p(g2h(ptr));
489
+ clear_helper_retaddr();
490
+ return ret;
491
+}
492
+
493
+uint32_t cpu_ldl_code(CPUArchState *env, abi_ptr ptr)
494
+{
495
+ uint32_t ret;
496
+
497
+ set_helper_retaddr(1);
498
+ ret = ldl_p(g2h(ptr));
499
+ clear_helper_retaddr();
500
+ return ret;
501
+}
502
+
503
+uint64_t cpu_ldq_code(CPUArchState *env, abi_ptr ptr)
504
+{
505
+ uint64_t ret;
506
+
507
+ set_helper_retaddr(1);
508
+ ret = ldq_p(g2h(ptr));
509
+ clear_helper_retaddr();
510
+ return ret;
511
+}
512
+
513
/* Do not allow unaligned operations to proceed. Return the host address. */
514
static void *atomic_mmu_lookup(CPUArchState *env, target_ulong addr,
515
int size, uintptr_t retaddr)
516
--
97
--
517
2.20.1
98
2.43.0
518
519
diff view generated by jsdifflib
1
The functions generated by these macros are unused.
1
There are only a few logical operations which can compute
2
an "affected" mask. Split out handling of this optimization
3
to a separate function, only to be called when applicable.
2
4
3
Cc: Chris Wulff <crwulff@gmail.com>
5
Remove the a_mask field from OptContext, as the mask is
4
Cc: Marek Vasut <marex@denx.de>
6
no longer stored anywhere.
5
Tested-by: Philippe Mathieu-Daudé <philmd@redhat.com>
7
6
Reviewed-by: Alex Bennée <alex.bennee@linaro.org>
8
Reviewed-by: Pierrick Bouvier <pierrick.bouvier@linaro.org>
7
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
9
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
8
---
10
---
9
target/nios2/cpu.h | 2 --
11
tcg/optimize.c | 42 +++++++++++++++++++++++++++---------------
10
1 file changed, 2 deletions(-)
12
1 file changed, 27 insertions(+), 15 deletions(-)
11
13
12
diff --git a/target/nios2/cpu.h b/target/nios2/cpu.h
14
diff --git a/tcg/optimize.c b/tcg/optimize.c
13
index XXXXXXX..XXXXXXX 100644
15
index XXXXXXX..XXXXXXX 100644
14
--- a/target/nios2/cpu.h
16
--- a/tcg/optimize.c
15
+++ b/target/nios2/cpu.h
17
+++ b/tcg/optimize.c
16
@@ -XXX,XX +XXX,XX @@ void do_nios2_semihosting(CPUNios2State *env);
18
@@ -XXX,XX +XXX,XX @@ typedef struct OptContext {
17
#define CPU_SAVE_VERSION 1
19
QSIMPLEQ_HEAD(, MemCopyInfo) mem_free;
18
20
19
/* MMU modes definitions */
21
/* In flight values from optimization. */
20
-#define MMU_MODE0_SUFFIX _kernel
22
- uint64_t a_mask; /* mask bit is 0 iff value identical to first input */
21
-#define MMU_MODE1_SUFFIX _user
23
uint64_t z_mask; /* mask bit is 0 iff value bit is 0 */
22
#define MMU_SUPERVISOR_IDX 0
24
uint64_t s_mask; /* mask of clrsb(value) bits */
23
#define MMU_USER_IDX 1
25
TCGType type;
26
@@ -XXX,XX +XXX,XX @@ static bool fold_const2_commutative(OptContext *ctx, TCGOp *op)
27
28
static bool fold_masks(OptContext *ctx, TCGOp *op)
29
{
30
- uint64_t a_mask = ctx->a_mask;
31
uint64_t z_mask = ctx->z_mask;
32
uint64_t s_mask = ctx->s_mask;
33
34
@@ -XXX,XX +XXX,XX @@ static bool fold_masks(OptContext *ctx, TCGOp *op)
35
* type changing opcodes.
36
*/
37
if (ctx->type == TCG_TYPE_I32) {
38
- a_mask = (int32_t)a_mask;
39
z_mask = (int32_t)z_mask;
40
s_mask |= MAKE_64BIT_MASK(32, 32);
41
ctx->z_mask = z_mask;
42
@@ -XXX,XX +XXX,XX @@ static bool fold_masks(OptContext *ctx, TCGOp *op)
43
if (z_mask == 0) {
44
return tcg_opt_gen_movi(ctx, op, op->args[0], 0);
45
}
46
+ return false;
47
+}
48
+
49
+/*
50
+ * An "affected" mask bit is 0 if and only if the result is identical
51
+ * to the first input. Thus if the entire mask is 0, the operation
52
+ * is equivalent to a copy.
53
+ */
54
+static bool fold_affected_mask(OptContext *ctx, TCGOp *op, uint64_t a_mask)
55
+{
56
+ if (ctx->type == TCG_TYPE_I32) {
57
+ a_mask = (uint32_t)a_mask;
58
+ }
59
if (a_mask == 0) {
60
return tcg_opt_gen_mov(ctx, op, op->args[0], op->args[1]);
61
}
62
@@ -XXX,XX +XXX,XX @@ static bool fold_and(OptContext *ctx, TCGOp *op)
63
* Known-zeros does not imply known-ones. Therefore unless
64
* arg2 is constant, we can't infer affected bits from it.
65
*/
66
- if (arg_is_const(op->args[2])) {
67
- ctx->a_mask = z1 & ~z2;
68
+ if (arg_is_const(op->args[2]) &&
69
+ fold_affected_mask(ctx, op, z1 & ~z2)) {
70
+ return true;
71
}
72
73
return fold_masks(ctx, op);
74
@@ -XXX,XX +XXX,XX @@ static bool fold_andc(OptContext *ctx, TCGOp *op)
75
*/
76
if (arg_is_const(op->args[2])) {
77
uint64_t z2 = ~arg_info(op->args[2])->z_mask;
78
- ctx->a_mask = z1 & ~z2;
79
+ if (fold_affected_mask(ctx, op, z1 & ~z2)) {
80
+ return true;
81
+ }
82
z1 &= z2;
83
}
84
ctx->z_mask = z1;
85
@@ -XXX,XX +XXX,XX @@ static bool fold_extract(OptContext *ctx, TCGOp *op)
86
87
z_mask_old = arg_info(op->args[1])->z_mask;
88
z_mask = extract64(z_mask_old, pos, len);
89
- if (pos == 0) {
90
- ctx->a_mask = z_mask_old ^ z_mask;
91
+ if (pos == 0 && fold_affected_mask(ctx, op, z_mask_old ^ z_mask)) {
92
+ return true;
93
}
94
ctx->z_mask = z_mask;
95
ctx->s_mask = smask_from_zmask(z_mask);
96
@@ -XXX,XX +XXX,XX @@ static bool fold_exts(OptContext *ctx, TCGOp *op)
97
98
ctx->z_mask = z_mask;
99
ctx->s_mask = s_mask;
100
- if (!type_change) {
101
- ctx->a_mask = s_mask & ~s_mask_old;
102
+ if (!type_change && fold_affected_mask(ctx, op, s_mask & ~s_mask_old)) {
103
+ return true;
104
}
105
106
return fold_masks(ctx, op);
107
@@ -XXX,XX +XXX,XX @@ static bool fold_extu(OptContext *ctx, TCGOp *op)
108
109
ctx->z_mask = z_mask;
110
ctx->s_mask = smask_from_zmask(z_mask);
111
- if (!type_change) {
112
- ctx->a_mask = z_mask_old ^ z_mask;
113
+ if (!type_change && fold_affected_mask(ctx, op, z_mask_old ^ z_mask)) {
114
+ return true;
115
}
116
return fold_masks(ctx, op);
117
}
118
@@ -XXX,XX +XXX,XX @@ static bool fold_sextract(OptContext *ctx, TCGOp *op)
119
s_mask |= MAKE_64BIT_MASK(len, 64 - len);
120
ctx->s_mask = s_mask;
121
122
- if (pos == 0) {
123
- ctx->a_mask = s_mask & ~s_mask_old;
124
+ if (pos == 0 && fold_affected_mask(ctx, op, s_mask & ~s_mask_old)) {
125
+ return true;
126
}
127
128
return fold_masks(ctx, op);
129
@@ -XXX,XX +XXX,XX @@ void tcg_optimize(TCGContext *s)
130
}
131
132
/* Assume all bits affected, no bits known zero, no sign reps. */
133
- ctx.a_mask = -1;
134
ctx.z_mask = -1;
135
ctx.s_mask = 0;
24
136
25
--
137
--
26
2.20.1
138
2.43.0
27
28
diff view generated by jsdifflib
New patch
1
Use of fold_masks should be restricted to those opcodes that
2
can reliably make use of it -- those with a single output,
3
and from higher-level folders that set up the masks.
4
Prepare for conversion of each folder in turn.
1
5
6
Reviewed-by: Pierrick Bouvier <pierrick.bouvier@linaro.org>
7
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
8
---
9
tcg/optimize.c | 17 ++++++++++++++---
10
1 file changed, 14 insertions(+), 3 deletions(-)
11
12
diff --git a/tcg/optimize.c b/tcg/optimize.c
13
index XXXXXXX..XXXXXXX 100644
14
--- a/tcg/optimize.c
15
+++ b/tcg/optimize.c
16
@@ -XXX,XX +XXX,XX @@ static bool fold_masks(OptContext *ctx, TCGOp *op)
17
{
18
uint64_t z_mask = ctx->z_mask;
19
uint64_t s_mask = ctx->s_mask;
20
+ const TCGOpDef *def = &tcg_op_defs[op->opc];
21
+ TCGTemp *ts;
22
+ TempOptInfo *ti;
23
+
24
+ /* Only single-output opcodes are supported here. */
25
+ tcg_debug_assert(def->nb_oargs == 1);
26
27
/*
28
* 32-bit ops generate 32-bit results, which for the purpose of
29
@@ -XXX,XX +XXX,XX @@ static bool fold_masks(OptContext *ctx, TCGOp *op)
30
if (ctx->type == TCG_TYPE_I32) {
31
z_mask = (int32_t)z_mask;
32
s_mask |= MAKE_64BIT_MASK(32, 32);
33
- ctx->z_mask = z_mask;
34
- ctx->s_mask = s_mask;
35
}
36
37
if (z_mask == 0) {
38
return tcg_opt_gen_movi(ctx, op, op->args[0], 0);
39
}
40
- return false;
41
+
42
+ ts = arg_temp(op->args[0]);
43
+ reset_ts(ctx, ts);
44
+
45
+ ti = ts_info(ts);
46
+ ti->z_mask = z_mask;
47
+ ti->s_mask = s_mask;
48
+ return true;
49
}
50
51
/*
52
--
53
2.43.0
diff view generated by jsdifflib
1
Code movement in an upcoming patch will show that this file
1
Add a routine to which masks can be passed directly, rather than
2
was implicitly depending on trace-root.h being included beforehand.
2
storing them into OptContext. To be used in upcoming patches.
3
3
4
Tested-by: Philippe Mathieu-Daudé <philmd@redhat.com>
4
Reviewed-by: Pierrick Bouvier <pierrick.bouvier@linaro.org>
5
Reviewed-by: Philippe Mathieu-Daudé <philmd@redhat.com>
6
Reviewed-by: Alex Bennée <alex.bennee@linaro.org>
7
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
5
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
8
---
6
---
9
include/user/syscall-trace.h | 2 ++
7
tcg/optimize.c | 15 ++++++++++++---
10
1 file changed, 2 insertions(+)
8
1 file changed, 12 insertions(+), 3 deletions(-)
11
9
12
diff --git a/include/user/syscall-trace.h b/include/user/syscall-trace.h
10
diff --git a/tcg/optimize.c b/tcg/optimize.c
13
index XXXXXXX..XXXXXXX 100644
11
index XXXXXXX..XXXXXXX 100644
14
--- a/include/user/syscall-trace.h
12
--- a/tcg/optimize.c
15
+++ b/include/user/syscall-trace.h
13
+++ b/tcg/optimize.c
16
@@ -XXX,XX +XXX,XX @@
14
@@ -XXX,XX +XXX,XX @@ static bool fold_const2_commutative(OptContext *ctx, TCGOp *op)
17
#ifndef _SYSCALL_TRACE_H_
15
return fold_const2(ctx, op);
18
#define _SYSCALL_TRACE_H_
16
}
19
17
20
+#include "trace-root.h"
18
-static bool fold_masks(OptContext *ctx, TCGOp *op)
19
+/*
20
+ * Record "zero" and "sign" masks for the single output of @op.
21
+ * See TempOptInfo definition of z_mask and s_mask.
22
+ * If z_mask allows, fold the output to constant zero.
23
+ */
24
+static bool fold_masks_zs(OptContext *ctx, TCGOp *op,
25
+ uint64_t z_mask, uint64_t s_mask)
26
{
27
- uint64_t z_mask = ctx->z_mask;
28
- uint64_t s_mask = ctx->s_mask;
29
const TCGOpDef *def = &tcg_op_defs[op->opc];
30
TCGTemp *ts;
31
TempOptInfo *ti;
32
@@ -XXX,XX +XXX,XX @@ static bool fold_masks(OptContext *ctx, TCGOp *op)
33
return true;
34
}
35
36
+static bool fold_masks(OptContext *ctx, TCGOp *op)
37
+{
38
+ return fold_masks_zs(ctx, op, ctx->z_mask, ctx->s_mask);
39
+}
21
+
40
+
22
/*
41
/*
23
* These helpers just provide a common place for the various
42
* An "affected" mask bit is 0 if and only if the result is identical
24
* subsystems that want to track syscalls to put their hooks in. We
43
* to the first input. Thus if the entire mask is 0, the operation
25
--
44
--
26
2.20.1
45
2.43.0
27
28
diff view generated by jsdifflib
New patch
1
Consider the passed s_mask to be a minimum deduced from
2
either existing s_mask or from a sign-extension operation.
3
We may be able to deduce more from the set of known zeros.
4
Remove identical logic from several opcode folders.
1
5
6
Reviewed-by: Pierrick Bouvier <pierrick.bouvier@linaro.org>
7
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
8
---
9
tcg/optimize.c | 21 ++++++---------------
10
1 file changed, 6 insertions(+), 15 deletions(-)
11
12
diff --git a/tcg/optimize.c b/tcg/optimize.c
13
index XXXXXXX..XXXXXXX 100644
14
--- a/tcg/optimize.c
15
+++ b/tcg/optimize.c
16
@@ -XXX,XX +XXX,XX @@ static bool fold_const2_commutative(OptContext *ctx, TCGOp *op)
17
* Record "zero" and "sign" masks for the single output of @op.
18
* See TempOptInfo definition of z_mask and s_mask.
19
* If z_mask allows, fold the output to constant zero.
20
+ * The passed s_mask may be augmented by z_mask.
21
*/
22
static bool fold_masks_zs(OptContext *ctx, TCGOp *op,
23
uint64_t z_mask, uint64_t s_mask)
24
@@ -XXX,XX +XXX,XX @@ static bool fold_masks_zs(OptContext *ctx, TCGOp *op,
25
26
ti = ts_info(ts);
27
ti->z_mask = z_mask;
28
- ti->s_mask = s_mask;
29
+ ti->s_mask = s_mask | smask_from_zmask(z_mask);
30
return true;
31
}
32
33
@@ -XXX,XX +XXX,XX @@ static bool fold_bswap(OptContext *ctx, TCGOp *op)
34
default:
35
g_assert_not_reached();
36
}
37
- s_mask = smask_from_zmask(z_mask);
38
39
+ s_mask = 0;
40
switch (op->args[2] & (TCG_BSWAP_OZ | TCG_BSWAP_OS)) {
41
case TCG_BSWAP_OZ:
42
break;
43
@@ -XXX,XX +XXX,XX @@ static bool fold_bswap(OptContext *ctx, TCGOp *op)
44
default:
45
/* The high bits are undefined: force all bits above the sign to 1. */
46
z_mask |= sign << 1;
47
- s_mask = 0;
48
break;
49
}
50
ctx->z_mask = z_mask;
51
@@ -XXX,XX +XXX,XX @@ static bool fold_count_zeros(OptContext *ctx, TCGOp *op)
52
g_assert_not_reached();
53
}
54
ctx->z_mask = arg_info(op->args[2])->z_mask | z_mask;
55
- ctx->s_mask = smask_from_zmask(ctx->z_mask);
56
return false;
57
}
58
59
@@ -XXX,XX +XXX,XX @@ static bool fold_ctpop(OptContext *ctx, TCGOp *op)
60
default:
61
g_assert_not_reached();
62
}
63
- ctx->s_mask = smask_from_zmask(ctx->z_mask);
64
return false;
65
}
66
67
@@ -XXX,XX +XXX,XX @@ static bool fold_extract(OptContext *ctx, TCGOp *op)
68
return true;
69
}
70
ctx->z_mask = z_mask;
71
- ctx->s_mask = smask_from_zmask(z_mask);
72
73
return fold_masks(ctx, op);
74
}
75
@@ -XXX,XX +XXX,XX @@ static bool fold_extu(OptContext *ctx, TCGOp *op)
76
}
77
78
ctx->z_mask = z_mask;
79
- ctx->s_mask = smask_from_zmask(z_mask);
80
if (!type_change && fold_affected_mask(ctx, op, z_mask_old ^ z_mask)) {
81
return true;
82
}
83
@@ -XXX,XX +XXX,XX @@ static bool fold_qemu_ld(OptContext *ctx, TCGOp *op)
84
int width = 8 * memop_size(mop);
85
86
if (width < 64) {
87
- ctx->s_mask = MAKE_64BIT_MASK(width, 64 - width);
88
- if (!(mop & MO_SIGN)) {
89
+ if (mop & MO_SIGN) {
90
+ ctx->s_mask = MAKE_64BIT_MASK(width, 64 - width);
91
+ } else {
92
ctx->z_mask = MAKE_64BIT_MASK(0, width);
93
- ctx->s_mask <<= 1;
94
}
95
}
96
97
@@ -XXX,XX +XXX,XX @@ static bool fold_setcond(OptContext *ctx, TCGOp *op)
98
fold_setcond_tst_pow2(ctx, op, false);
99
100
ctx->z_mask = 1;
101
- ctx->s_mask = smask_from_zmask(1);
102
return false;
103
}
104
105
@@ -XXX,XX +XXX,XX @@ static bool fold_setcond2(OptContext *ctx, TCGOp *op)
106
}
107
108
ctx->z_mask = 1;
109
- ctx->s_mask = smask_from_zmask(1);
110
return false;
111
112
do_setcond_const:
113
@@ -XXX,XX +XXX,XX @@ static bool fold_tcg_ld(OptContext *ctx, TCGOp *op)
114
break;
115
CASE_OP_32_64(ld8u):
116
ctx->z_mask = MAKE_64BIT_MASK(0, 8);
117
- ctx->s_mask = MAKE_64BIT_MASK(9, 55);
118
break;
119
CASE_OP_32_64(ld16s):
120
ctx->s_mask = MAKE_64BIT_MASK(16, 48);
121
break;
122
CASE_OP_32_64(ld16u):
123
ctx->z_mask = MAKE_64BIT_MASK(0, 16);
124
- ctx->s_mask = MAKE_64BIT_MASK(17, 47);
125
break;
126
case INDEX_op_ld32s_i64:
127
ctx->s_mask = MAKE_64BIT_MASK(32, 32);
128
break;
129
case INDEX_op_ld32u_i64:
130
ctx->z_mask = MAKE_64BIT_MASK(0, 32);
131
- ctx->s_mask = MAKE_64BIT_MASK(33, 31);
132
break;
133
default:
134
g_assert_not_reached();
135
--
136
2.43.0
diff view generated by jsdifflib
1
Reduce the amount of preprocessor obfuscation by expanding
1
Change the representation from sign bit repetitions to all bits equal
2
the text of each of the functions generated. The result is
2
to the sign bit, including the sign bit itself.
3
only slightly smaller than the original.
4
3
5
Tested-by: Philippe Mathieu-Daudé <philmd@redhat.com>
4
The previous format has a problem in that it is difficult to recreate
6
Reviewed-by: Alex Bennée <alex.bennee@linaro.org>
5
a valid sign mask after a shift operation: the "repetitions" part of
7
Reviewed-by: Aleksandar Markovic <amarkovic@wavecomp.com>
6
the previous format meant that applying the same shift as for the value
7
lead to an off-by-one value.
8
9
The new format, including the sign bit itself, means that the sign mask
10
can be manipulated in exactly the same way as the value, canonicalization
11
is easier.
12
13
Canonicalize the s_mask in fold_masks_zs, rather than requiring callers
14
to do so. Treat 0 as a non-canonical but typeless input for no sign
15
information, which will be reset as appropriate for the data type.
16
We can easily fold in the data from z_mask while canonicalizing.
17
18
Temporarily disable optimizations using s_mask while each operation is
19
converted to use fold_masks_zs and to the new form.
20
21
Reviewed-by: Pierrick Bouvier <pierrick.bouvier@linaro.org>
8
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
22
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
9
---
23
---
10
include/exec/cpu_ldst.h | 67 +++++++-----------
24
tcg/optimize.c | 64 ++++++++++++--------------------------------------
11
include/exec/cpu_ldst_template.h | 117 -------------------------------
25
1 file changed, 15 insertions(+), 49 deletions(-)
12
accel/tcg/cputlb.c | 107 +++++++++++++++++++++++++++-
13
3 files changed, 130 insertions(+), 161 deletions(-)
14
delete mode 100644 include/exec/cpu_ldst_template.h
15
26
16
diff --git a/include/exec/cpu_ldst.h b/include/exec/cpu_ldst.h
27
diff --git a/tcg/optimize.c b/tcg/optimize.c
17
index XXXXXXX..XXXXXXX 100644
28
index XXXXXXX..XXXXXXX 100644
18
--- a/include/exec/cpu_ldst.h
29
--- a/tcg/optimize.c
19
+++ b/include/exec/cpu_ldst.h
30
+++ b/tcg/optimize.c
20
@@ -XXX,XX +XXX,XX @@ typedef target_ulong abi_ptr;
31
@@ -XXX,XX +XXX,XX @@ typedef struct TempOptInfo {
21
#define TARGET_ABI_FMT_ptr TARGET_ABI_FMT_lx
32
QSIMPLEQ_HEAD(, MemCopyInfo) mem_copy;
22
#endif
33
uint64_t val;
23
34
uint64_t z_mask; /* mask bit is 0 if and only if value bit is 0 */
24
-#if defined(CONFIG_USER_ONLY)
35
- uint64_t s_mask; /* a left-aligned mask of clrsb(value) bits. */
25
-
36
+ uint64_t s_mask; /* mask bit is 1 if value bit matches msb */
26
-extern __thread uintptr_t helper_retaddr;
37
} TempOptInfo;
27
-
38
28
-static inline void set_helper_retaddr(uintptr_t ra)
39
typedef struct OptContext {
40
@@ -XXX,XX +XXX,XX @@ typedef struct OptContext {
41
42
/* In flight values from optimization. */
43
uint64_t z_mask; /* mask bit is 0 iff value bit is 0 */
44
- uint64_t s_mask; /* mask of clrsb(value) bits */
45
+ uint64_t s_mask; /* mask bit is 1 if value bit matches msb */
46
TCGType type;
47
} OptContext;
48
49
-/* Calculate the smask for a specific value. */
50
-static uint64_t smask_from_value(uint64_t value)
29
-{
51
-{
30
- helper_retaddr = ra;
52
- int rep = clrsb64(value);
31
- /*
53
- return ~(~0ull >> rep);
32
- * Ensure that this write is visible to the SIGSEGV handler that
33
- * may be invoked due to a subsequent invalid memory operation.
34
- */
35
- signal_barrier();
36
-}
54
-}
37
-
55
-
38
-static inline void clear_helper_retaddr(void)
56
-/*
57
- * Calculate the smask for a given set of known-zeros.
58
- * If there are lots of zeros on the left, we can consider the remainder
59
- * an unsigned field, and thus the corresponding signed field is one bit
60
- * larger.
61
- */
62
-static uint64_t smask_from_zmask(uint64_t zmask)
39
-{
63
-{
40
- /*
64
- /*
41
- * Ensure that previous memory operations have succeeded before
65
- * Only the 0 bits are significant for zmask, thus the msb itself
42
- * removing the data visible to the signal handler.
66
- * must be zero, else we have no sign information.
43
- */
67
- */
44
- signal_barrier();
68
- int rep = clz64(zmask);
45
- helper_retaddr = 0;
69
- if (rep == 0) {
70
- return 0;
71
- }
72
- rep -= 1;
73
- return ~(~0ull >> rep);
46
-}
74
-}
47
-
75
-
48
-/* In user-only mode we provide only the _code and _data accessors. */
49
-
50
uint32_t cpu_ldub_data(CPUArchState *env, abi_ptr ptr);
51
uint32_t cpu_lduw_data(CPUArchState *env, abi_ptr ptr);
52
uint32_t cpu_ldl_data(CPUArchState *env, abi_ptr ptr);
53
@@ -XXX,XX +XXX,XX @@ void cpu_stl_data_ra(CPUArchState *env, abi_ptr ptr,
54
void cpu_stq_data_ra(CPUArchState *env, abi_ptr ptr,
55
uint64_t val, uintptr_t retaddr);
56
57
+#if defined(CONFIG_USER_ONLY)
58
+
59
+extern __thread uintptr_t helper_retaddr;
60
+
61
+static inline void set_helper_retaddr(uintptr_t ra)
62
+{
63
+ helper_retaddr = ra;
64
+ /*
65
+ * Ensure that this write is visible to the SIGSEGV handler that
66
+ * may be invoked due to a subsequent invalid memory operation.
67
+ */
68
+ signal_barrier();
69
+}
70
+
71
+static inline void clear_helper_retaddr(void)
72
+{
73
+ /*
74
+ * Ensure that previous memory operations have succeeded before
75
+ * removing the data visible to the signal handler.
76
+ */
77
+ signal_barrier();
78
+ helper_retaddr = 0;
79
+}
80
+
81
/*
82
* Provide the same *_mmuidx_ra interface as for softmmu.
83
* The mmu_idx argument is ignored.
84
@@ -XXX,XX +XXX,XX @@ void cpu_stl_mmuidx_ra(CPUArchState *env, abi_ptr addr, uint32_t val,
85
void cpu_stq_mmuidx_ra(CPUArchState *env, abi_ptr addr, uint64_t val,
86
int mmu_idx, uintptr_t retaddr);
87
88
-/* these access are slower, they must be as rare as possible */
89
-#define CPU_MMU_INDEX (cpu_mmu_index(env, false))
90
-#define MEMSUFFIX _data
91
-#define DATA_SIZE 1
92
-#include "exec/cpu_ldst_template.h"
93
-
94
-#define DATA_SIZE 2
95
-#include "exec/cpu_ldst_template.h"
96
-
97
-#define DATA_SIZE 4
98
-#include "exec/cpu_ldst_template.h"
99
-
100
-#define DATA_SIZE 8
101
-#include "exec/cpu_ldst_template.h"
102
-#undef CPU_MMU_INDEX
103
-#undef MEMSUFFIX
104
-
105
#endif /* defined(CONFIG_USER_ONLY) */
106
107
uint32_t cpu_ldub_code(CPUArchState *env, abi_ptr addr);
108
diff --git a/include/exec/cpu_ldst_template.h b/include/exec/cpu_ldst_template.h
109
deleted file mode 100644
110
index XXXXXXX..XXXXXXX
111
--- a/include/exec/cpu_ldst_template.h
112
+++ /dev/null
113
@@ -XXX,XX +XXX,XX @@
114
-/*
76
-/*
115
- * Software MMU support
77
- * Recreate a properly left-aligned smask after manipulation.
116
- *
78
- * Some bit-shuffling, particularly shifts and rotates, may
117
- * Generate inline load/store functions for one MMU mode and data
79
- * retain sign bits on the left, but may scatter disconnected
118
- * size.
80
- * sign bits on the right. Retain only what remains to the left.
119
- *
120
- * Generate a store function as well as signed and unsigned loads.
121
- *
122
- * Not used directly but included from cpu_ldst.h.
123
- *
124
- * Copyright (c) 2003 Fabrice Bellard
125
- *
126
- * This library is free software; you can redistribute it and/or
127
- * modify it under the terms of the GNU Lesser General Public
128
- * License as published by the Free Software Foundation; either
129
- * version 2 of the License, or (at your option) any later version.
130
- *
131
- * This library is distributed in the hope that it will be useful,
132
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
133
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
134
- * Lesser General Public License for more details.
135
- *
136
- * You should have received a copy of the GNU Lesser General Public
137
- * License along with this library; if not, see <http://www.gnu.org/licenses/>.
138
- */
81
- */
139
-
82
-static uint64_t smask_from_smask(int64_t smask)
140
-#if DATA_SIZE == 8
141
-#define SUFFIX q
142
-#define USUFFIX q
143
-#define DATA_TYPE uint64_t
144
-#define SHIFT 3
145
-#elif DATA_SIZE == 4
146
-#define SUFFIX l
147
-#define USUFFIX l
148
-#define DATA_TYPE uint32_t
149
-#define SHIFT 2
150
-#elif DATA_SIZE == 2
151
-#define SUFFIX w
152
-#define USUFFIX uw
153
-#define DATA_TYPE uint16_t
154
-#define DATA_STYPE int16_t
155
-#define SHIFT 1
156
-#elif DATA_SIZE == 1
157
-#define SUFFIX b
158
-#define USUFFIX ub
159
-#define DATA_TYPE uint8_t
160
-#define DATA_STYPE int8_t
161
-#define SHIFT 0
162
-#else
163
-#error unsupported data size
164
-#endif
165
-
166
-#if DATA_SIZE == 8
167
-#define RES_TYPE uint64_t
168
-#else
169
-#define RES_TYPE uint32_t
170
-#endif
171
-
172
-/* generic load/store macros */
173
-
174
-static inline RES_TYPE
175
-glue(glue(glue(cpu_ld, USUFFIX), MEMSUFFIX), _ra)(CPUArchState *env,
176
- target_ulong ptr,
177
- uintptr_t retaddr)
178
-{
83
-{
179
- return glue(glue(cpu_ld, USUFFIX), _mmuidx_ra)(env, ptr, CPU_MMU_INDEX,
84
- /* Only the 1 bits are significant for smask */
180
- retaddr);
85
- return smask_from_zmask(~smask);
181
-}
86
-}
182
-
87
-
183
-static inline RES_TYPE
88
static inline TempOptInfo *ts_info(TCGTemp *ts)
184
-glue(glue(cpu_ld, USUFFIX), MEMSUFFIX)(CPUArchState *env, target_ulong ptr)
89
{
185
-{
90
return ts->state_ptr;
186
- return glue(glue(cpu_ld, USUFFIX), _mmuidx_ra)(env, ptr, CPU_MMU_INDEX, 0);
91
@@ -XXX,XX +XXX,XX @@ static void init_ts_info(OptContext *ctx, TCGTemp *ts)
187
-}
92
ti->is_const = true;
188
-
93
ti->val = ts->val;
189
-#if DATA_SIZE <= 2
94
ti->z_mask = ts->val;
190
-static inline int
95
- ti->s_mask = smask_from_value(ts->val);
191
-glue(glue(glue(cpu_lds, SUFFIX), MEMSUFFIX), _ra)(CPUArchState *env,
96
+ ti->s_mask = INT64_MIN >> clrsb64(ts->val);
192
- target_ulong ptr,
97
} else {
193
- uintptr_t retaddr)
98
ti->is_const = false;
194
-{
99
ti->z_mask = -1;
195
- return glue(glue(cpu_lds, SUFFIX), _mmuidx_ra)(env, ptr, CPU_MMU_INDEX,
100
@@ -XXX,XX +XXX,XX @@ static void finish_folding(OptContext *ctx, TCGOp *op)
196
- retaddr);
101
*/
197
-}
102
if (i == 0) {
198
-
103
ts_info(ts)->z_mask = ctx->z_mask;
199
-static inline int
104
- ts_info(ts)->s_mask = ctx->s_mask;
200
-glue(glue(cpu_lds, SUFFIX), MEMSUFFIX)(CPUArchState *env, target_ulong ptr)
105
}
201
-{
106
}
202
- return glue(glue(cpu_lds, SUFFIX), _mmuidx_ra)(env, ptr, CPU_MMU_INDEX, 0);
203
-}
204
-#endif
205
-
206
-/* generic store macro */
207
-
208
-static inline void
209
-glue(glue(glue(cpu_st, SUFFIX), MEMSUFFIX), _ra)(CPUArchState *env,
210
- target_ulong ptr,
211
- RES_TYPE v, uintptr_t retaddr)
212
-{
213
- glue(glue(cpu_st, SUFFIX), _mmuidx_ra)(env, ptr, v, CPU_MMU_INDEX,
214
- retaddr);
215
-}
216
-
217
-static inline void
218
-glue(glue(cpu_st, SUFFIX), MEMSUFFIX)(CPUArchState *env, target_ulong ptr,
219
- RES_TYPE v)
220
-{
221
- glue(glue(cpu_st, SUFFIX), _mmuidx_ra)(env, ptr, v, CPU_MMU_INDEX, 0);
222
-}
223
-
224
-#undef RES_TYPE
225
-#undef DATA_TYPE
226
-#undef DATA_STYPE
227
-#undef SUFFIX
228
-#undef USUFFIX
229
-#undef DATA_SIZE
230
-#undef SHIFT
231
diff --git a/accel/tcg/cputlb.c b/accel/tcg/cputlb.c
232
index XXXXXXX..XXXXXXX 100644
233
--- a/accel/tcg/cputlb.c
234
+++ b/accel/tcg/cputlb.c
235
@@ -XXX,XX +XXX,XX @@
236
#include "qemu/atomic128.h"
237
#include "translate-all.h"
238
#include "trace-root.h"
239
-#include "qemu/plugin.h"
240
#include "trace/mem.h"
241
#ifdef CONFIG_PLUGIN
242
#include "qemu/plugin-memory.h"
243
@@ -XXX,XX +XXX,XX @@ uint64_t cpu_ldq_mmuidx_ra(CPUArchState *env, abi_ptr addr,
244
? helper_le_ldq_mmu : helper_be_ldq_mmu);
245
}
107
}
246
108
@@ -XXX,XX +XXX,XX @@ static bool fold_const2_commutative(OptContext *ctx, TCGOp *op)
247
+uint32_t cpu_ldub_data_ra(CPUArchState *env, target_ulong ptr,
109
* The passed s_mask may be augmented by z_mask.
248
+ uintptr_t retaddr)
110
*/
249
+{
111
static bool fold_masks_zs(OptContext *ctx, TCGOp *op,
250
+ return cpu_ldub_mmuidx_ra(env, ptr, cpu_mmu_index(env, false), retaddr);
112
- uint64_t z_mask, uint64_t s_mask)
251
+}
113
+ uint64_t z_mask, int64_t s_mask)
114
{
115
const TCGOpDef *def = &tcg_op_defs[op->opc];
116
TCGTemp *ts;
117
TempOptInfo *ti;
118
+ int rep;
119
120
/* Only single-output opcodes are supported here. */
121
tcg_debug_assert(def->nb_oargs == 1);
122
@@ -XXX,XX +XXX,XX @@ static bool fold_masks_zs(OptContext *ctx, TCGOp *op,
123
*/
124
if (ctx->type == TCG_TYPE_I32) {
125
z_mask = (int32_t)z_mask;
126
- s_mask |= MAKE_64BIT_MASK(32, 32);
127
+ s_mask |= INT32_MIN;
128
}
129
130
if (z_mask == 0) {
131
@@ -XXX,XX +XXX,XX @@ static bool fold_masks_zs(OptContext *ctx, TCGOp *op,
132
133
ti = ts_info(ts);
134
ti->z_mask = z_mask;
135
- ti->s_mask = s_mask | smask_from_zmask(z_mask);
252
+
136
+
253
+int cpu_ldsb_data_ra(CPUArchState *env, target_ulong ptr, uintptr_t retaddr)
137
+ /* Canonicalize s_mask and incorporate data from z_mask. */
254
+{
138
+ rep = clz64(~s_mask);
255
+ return cpu_ldsb_mmuidx_ra(env, ptr, cpu_mmu_index(env, false), retaddr);
139
+ rep = MAX(rep, clz64(z_mask));
256
+}
140
+ rep = MAX(rep - 1, 0);
141
+ ti->s_mask = INT64_MIN >> rep;
257
+
142
+
258
+uint32_t cpu_lduw_data_ra(CPUArchState *env, target_ulong ptr,
143
return true;
259
+ uintptr_t retaddr)
260
+{
261
+ return cpu_lduw_mmuidx_ra(env, ptr, cpu_mmu_index(env, false), retaddr);
262
+}
263
+
264
+int cpu_ldsw_data_ra(CPUArchState *env, target_ulong ptr, uintptr_t retaddr)
265
+{
266
+ return cpu_ldsw_mmuidx_ra(env, ptr, cpu_mmu_index(env, false), retaddr);
267
+}
268
+
269
+uint32_t cpu_ldl_data_ra(CPUArchState *env, target_ulong ptr, uintptr_t retaddr)
270
+{
271
+ return cpu_ldl_mmuidx_ra(env, ptr, cpu_mmu_index(env, false), retaddr);
272
+}
273
+
274
+uint64_t cpu_ldq_data_ra(CPUArchState *env, target_ulong ptr, uintptr_t retaddr)
275
+{
276
+ return cpu_ldq_mmuidx_ra(env, ptr, cpu_mmu_index(env, false), retaddr);
277
+}
278
+
279
+uint32_t cpu_ldub_data(CPUArchState *env, target_ulong ptr)
280
+{
281
+ return cpu_ldub_data_ra(env, ptr, 0);
282
+}
283
+
284
+int cpu_ldsb_data(CPUArchState *env, target_ulong ptr)
285
+{
286
+ return cpu_ldsb_data_ra(env, ptr, 0);
287
+}
288
+
289
+uint32_t cpu_lduw_data(CPUArchState *env, target_ulong ptr)
290
+{
291
+ return cpu_lduw_data_ra(env, ptr, 0);
292
+}
293
+
294
+int cpu_ldsw_data(CPUArchState *env, target_ulong ptr)
295
+{
296
+ return cpu_ldsw_data_ra(env, ptr, 0);
297
+}
298
+
299
+uint32_t cpu_ldl_data(CPUArchState *env, target_ulong ptr)
300
+{
301
+ return cpu_ldl_data_ra(env, ptr, 0);
302
+}
303
+
304
+uint64_t cpu_ldq_data(CPUArchState *env, target_ulong ptr)
305
+{
306
+ return cpu_ldq_data_ra(env, ptr, 0);
307
+}
308
+
309
/*
310
* Store Helpers
311
*/
312
@@ -XXX,XX +XXX,XX @@ void cpu_stq_mmuidx_ra(CPUArchState *env, target_ulong addr, uint64_t val,
313
cpu_store_helper(env, addr, val, mmu_idx, retaddr, MO_TEQ);
314
}
144
}
315
145
316
+void cpu_stb_data_ra(CPUArchState *env, target_ulong ptr,
146
@@ -XXX,XX +XXX,XX @@ static bool fold_exts(OptContext *ctx, TCGOp *op)
317
+ uint32_t val, uintptr_t retaddr)
147
318
+{
148
ctx->z_mask = z_mask;
319
+ cpu_stb_mmuidx_ra(env, ptr, val, cpu_mmu_index(env, false), retaddr);
149
ctx->s_mask = s_mask;
320
+}
150
- if (!type_change && fold_affected_mask(ctx, op, s_mask & ~s_mask_old)) {
321
+
151
+ if (0 && !type_change && fold_affected_mask(ctx, op, s_mask & ~s_mask_old)) {
322
+void cpu_stw_data_ra(CPUArchState *env, target_ulong ptr,
152
return true;
323
+ uint32_t val, uintptr_t retaddr)
153
}
324
+{
154
325
+ cpu_stw_mmuidx_ra(env, ptr, val, cpu_mmu_index(env, false), retaddr);
155
@@ -XXX,XX +XXX,XX @@ static bool fold_sextract(OptContext *ctx, TCGOp *op)
326
+}
156
s_mask |= MAKE_64BIT_MASK(len, 64 - len);
327
+
157
ctx->s_mask = s_mask;
328
+void cpu_stl_data_ra(CPUArchState *env, target_ulong ptr,
158
329
+ uint32_t val, uintptr_t retaddr)
159
- if (pos == 0 && fold_affected_mask(ctx, op, s_mask & ~s_mask_old)) {
330
+{
160
+ if (0 && pos == 0 && fold_affected_mask(ctx, op, s_mask & ~s_mask_old)) {
331
+ cpu_stl_mmuidx_ra(env, ptr, val, cpu_mmu_index(env, false), retaddr);
161
return true;
332
+}
162
}
333
+
163
334
+void cpu_stq_data_ra(CPUArchState *env, target_ulong ptr,
164
@@ -XXX,XX +XXX,XX @@ static bool fold_shift(OptContext *ctx, TCGOp *op)
335
+ uint64_t val, uintptr_t retaddr)
165
ctx->z_mask = do_constant_folding(op->opc, ctx->type, z_mask, sh);
336
+{
166
337
+ cpu_stq_mmuidx_ra(env, ptr, val, cpu_mmu_index(env, false), retaddr);
167
s_mask = do_constant_folding(op->opc, ctx->type, s_mask, sh);
338
+}
168
- ctx->s_mask = smask_from_smask(s_mask);
339
+
169
340
+void cpu_stb_data(CPUArchState *env, target_ulong ptr, uint32_t val)
170
return fold_masks(ctx, op);
341
+{
171
}
342
+ cpu_stb_data_ra(env, ptr, val, 0);
343
+}
344
+
345
+void cpu_stw_data(CPUArchState *env, target_ulong ptr, uint32_t val)
346
+{
347
+ cpu_stw_data_ra(env, ptr, val, 0);
348
+}
349
+
350
+void cpu_stl_data(CPUArchState *env, target_ulong ptr, uint32_t val)
351
+{
352
+ cpu_stl_data_ra(env, ptr, val, 0);
353
+}
354
+
355
+void cpu_stq_data(CPUArchState *env, target_ulong ptr, uint64_t val)
356
+{
357
+ cpu_stq_data_ra(env, ptr, val, 0);
358
+}
359
+
360
/* First set of helpers allows passing in of OI and RETADDR. This makes
361
them callable from other helpers. */
362
363
--
172
--
364
2.20.1
173
2.43.0
365
366
diff view generated by jsdifflib
1
There are no uses of the *_cmmu names other than the bare wrapping
1
Reviewed-by: Pierrick Bouvier <pierrick.bouvier@linaro.org>
2
within the *_code inlines. Therefore rename the functions so we
3
can drop the inlines.
4
5
Use abi_ptr instead of target_ulong in preparation for user-only;
6
the two types are identical for softmmu.
7
8
Tested-by: Philippe Mathieu-Daudé <philmd@redhat.com>
9
Reviewed-by: Aleksandar Markovic <amarkovic@wavecomp.com>
10
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
2
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
11
---
3
---
12
include/exec/cpu_ldst.h | 29 ++++------
4
tcg/optimize.c | 9 +++++----
13
include/exec/cpu_ldst_template.h | 21 -------
5
1 file changed, 5 insertions(+), 4 deletions(-)
14
tcg/tcg.h | 29 ----------
15
accel/tcg/cputlb.c | 94 ++++++++------------------------
16
docs/devel/loads-stores.rst | 4 +-
17
5 files changed, 36 insertions(+), 141 deletions(-)
18
6
19
diff --git a/include/exec/cpu_ldst.h b/include/exec/cpu_ldst.h
7
diff --git a/tcg/optimize.c b/tcg/optimize.c
20
index XXXXXXX..XXXXXXX 100644
8
index XXXXXXX..XXXXXXX 100644
21
--- a/include/exec/cpu_ldst.h
9
--- a/tcg/optimize.c
22
+++ b/include/exec/cpu_ldst.h
10
+++ b/tcg/optimize.c
23
@@ -XXX,XX +XXX,XX @@ void cpu_stq_mmuidx_ra(CPUArchState *env, abi_ptr addr, uint64_t val,
11
@@ -XXX,XX +XXX,XX @@ static void finish_ebb(OptContext *ctx)
24
#undef CPU_MMU_INDEX
12
remove_mem_copy_all(ctx);
25
#undef MEMSUFFIX
26
27
-#define CPU_MMU_INDEX (cpu_mmu_index(env, true))
28
-#define MEMSUFFIX _code
29
-#define SOFTMMU_CODE_ACCESS
30
+uint32_t cpu_ldub_code(CPUArchState *env, abi_ptr addr);
31
+uint32_t cpu_lduw_code(CPUArchState *env, abi_ptr addr);
32
+uint32_t cpu_ldl_code(CPUArchState *env, abi_ptr addr);
33
+uint64_t cpu_ldq_code(CPUArchState *env, abi_ptr addr);
34
35
-#define DATA_SIZE 1
36
-#include "exec/cpu_ldst_template.h"
37
+static inline int cpu_ldsb_code(CPUArchState *env, abi_ptr addr)
38
+{
39
+ return (int8_t)cpu_ldub_code(env, addr);
40
+}
41
42
-#define DATA_SIZE 2
43
-#include "exec/cpu_ldst_template.h"
44
-
45
-#define DATA_SIZE 4
46
-#include "exec/cpu_ldst_template.h"
47
-
48
-#define DATA_SIZE 8
49
-#include "exec/cpu_ldst_template.h"
50
-
51
-#undef CPU_MMU_INDEX
52
-#undef MEMSUFFIX
53
-#undef SOFTMMU_CODE_ACCESS
54
+static inline int cpu_ldsw_code(CPUArchState *env, abi_ptr addr)
55
+{
56
+ return (int16_t)cpu_lduw_code(env, addr);
57
+}
58
59
#endif /* defined(CONFIG_USER_ONLY) */
60
61
diff --git a/include/exec/cpu_ldst_template.h b/include/exec/cpu_ldst_template.h
62
index XXXXXXX..XXXXXXX 100644
63
--- a/include/exec/cpu_ldst_template.h
64
+++ b/include/exec/cpu_ldst_template.h
65
@@ -XXX,XX +XXX,XX @@
66
67
/* generic load/store macros */
68
69
-#ifdef SOFTMMU_CODE_ACCESS
70
-
71
-static inline RES_TYPE
72
-glue(glue(cpu_ld, USUFFIX), _code)(CPUArchState *env, target_ulong ptr)
73
-{
74
- TCGMemOpIdx oi = make_memop_idx(MO_TE | SHIFT, CPU_MMU_INDEX);
75
- return glue(glue(helper_ret_ld, USUFFIX), _cmmu)(env, ptr, oi, 0);
76
-}
77
-
78
-#if DATA_SIZE <= 2
79
-static inline int
80
-glue(glue(cpu_lds, SUFFIX), _code)(CPUArchState *env, target_ulong ptr)
81
-{
82
- return (DATA_STYPE)glue(glue(cpu_ld, USUFFIX), _code)(env, ptr);
83
-}
84
-#endif
85
-
86
-#else
87
-
88
static inline RES_TYPE
89
glue(glue(glue(cpu_ld, USUFFIX), MEMSUFFIX), _ra)(CPUArchState *env,
90
target_ulong ptr,
91
@@ -XXX,XX +XXX,XX @@ glue(glue(cpu_st, SUFFIX), MEMSUFFIX)(CPUArchState *env, target_ulong ptr,
92
glue(glue(cpu_st, SUFFIX), _mmuidx_ra)(env, ptr, v, CPU_MMU_INDEX, 0);
93
}
13
}
94
14
95
-#endif /* !SOFTMMU_CODE_ACCESS */
15
-static void finish_folding(OptContext *ctx, TCGOp *op)
96
-
16
+static bool finish_folding(OptContext *ctx, TCGOp *op)
97
#undef RES_TYPE
98
#undef DATA_TYPE
99
#undef DATA_STYPE
100
diff --git a/tcg/tcg.h b/tcg/tcg.h
101
index XXXXXXX..XXXXXXX 100644
102
--- a/tcg/tcg.h
103
+++ b/tcg/tcg.h
104
@@ -XXX,XX +XXX,XX @@ void helper_be_stl_mmu(CPUArchState *env, target_ulong addr, uint32_t val,
105
void helper_be_stq_mmu(CPUArchState *env, target_ulong addr, uint64_t val,
106
TCGMemOpIdx oi, uintptr_t retaddr);
107
108
-uint8_t helper_ret_ldub_cmmu(CPUArchState *env, target_ulong addr,
109
- TCGMemOpIdx oi, uintptr_t retaddr);
110
-int8_t helper_ret_ldsb_cmmu(CPUArchState *env, target_ulong addr,
111
- TCGMemOpIdx oi, uintptr_t retaddr);
112
-uint16_t helper_le_lduw_cmmu(CPUArchState *env, target_ulong addr,
113
- TCGMemOpIdx oi, uintptr_t retaddr);
114
-int16_t helper_le_ldsw_cmmu(CPUArchState *env, target_ulong addr,
115
- TCGMemOpIdx oi, uintptr_t retaddr);
116
-uint32_t helper_le_ldl_cmmu(CPUArchState *env, target_ulong addr,
117
- TCGMemOpIdx oi, uintptr_t retaddr);
118
-uint64_t helper_le_ldq_cmmu(CPUArchState *env, target_ulong addr,
119
- TCGMemOpIdx oi, uintptr_t retaddr);
120
-uint16_t helper_be_lduw_cmmu(CPUArchState *env, target_ulong addr,
121
- TCGMemOpIdx oi, uintptr_t retaddr);
122
-int16_t helper_be_ldsw_cmmu(CPUArchState *env, target_ulong addr,
123
- TCGMemOpIdx oi, uintptr_t retaddr);
124
-uint32_t helper_be_ldl_cmmu(CPUArchState *env, target_ulong addr,
125
- TCGMemOpIdx oi, uintptr_t retaddr);
126
-uint64_t helper_be_ldq_cmmu(CPUArchState *env, target_ulong addr,
127
- TCGMemOpIdx oi, uintptr_t retaddr);
128
-
129
/* Temporary aliases until backends are converted. */
130
#ifdef TARGET_WORDS_BIGENDIAN
131
# define helper_ret_ldsw_mmu helper_be_ldsw_mmu
132
@@ -XXX,XX +XXX,XX @@ uint64_t helper_be_ldq_cmmu(CPUArchState *env, target_ulong addr,
133
# define helper_ret_stw_mmu helper_be_stw_mmu
134
# define helper_ret_stl_mmu helper_be_stl_mmu
135
# define helper_ret_stq_mmu helper_be_stq_mmu
136
-# define helper_ret_lduw_cmmu helper_be_lduw_cmmu
137
-# define helper_ret_ldsw_cmmu helper_be_ldsw_cmmu
138
-# define helper_ret_ldl_cmmu helper_be_ldl_cmmu
139
-# define helper_ret_ldq_cmmu helper_be_ldq_cmmu
140
#else
141
# define helper_ret_ldsw_mmu helper_le_ldsw_mmu
142
# define helper_ret_lduw_mmu helper_le_lduw_mmu
143
@@ -XXX,XX +XXX,XX @@ uint64_t helper_be_ldq_cmmu(CPUArchState *env, target_ulong addr,
144
# define helper_ret_stw_mmu helper_le_stw_mmu
145
# define helper_ret_stl_mmu helper_le_stl_mmu
146
# define helper_ret_stq_mmu helper_le_stq_mmu
147
-# define helper_ret_lduw_cmmu helper_le_lduw_cmmu
148
-# define helper_ret_ldsw_cmmu helper_le_ldsw_cmmu
149
-# define helper_ret_ldl_cmmu helper_le_ldl_cmmu
150
-# define helper_ret_ldq_cmmu helper_le_ldq_cmmu
151
#endif
152
153
uint32_t helper_atomic_cmpxchgb_mmu(CPUArchState *env, target_ulong addr,
154
diff --git a/accel/tcg/cputlb.c b/accel/tcg/cputlb.c
155
index XXXXXXX..XXXXXXX 100644
156
--- a/accel/tcg/cputlb.c
157
+++ b/accel/tcg/cputlb.c
158
@@ -XXX,XX +XXX,XX @@ void cpu_stq_mmuidx_ra(CPUArchState *env, target_ulong addr, uint64_t val,
159
160
/* Code access functions. */
161
162
-static uint64_t full_ldub_cmmu(CPUArchState *env, target_ulong addr,
163
+static uint64_t full_ldub_code(CPUArchState *env, target_ulong addr,
164
TCGMemOpIdx oi, uintptr_t retaddr)
165
{
17
{
166
- return load_helper(env, addr, oi, retaddr, MO_8, true, full_ldub_cmmu);
18
const TCGOpDef *def = &tcg_op_defs[op->opc];
167
+ return load_helper(env, addr, oi, retaddr, MO_8, true, full_ldub_code);
19
int i, nb_oargs;
20
@@ -XXX,XX +XXX,XX @@ static void finish_folding(OptContext *ctx, TCGOp *op)
21
ts_info(ts)->z_mask = ctx->z_mask;
22
}
23
}
24
+ return true;
168
}
25
}
169
26
170
-uint8_t helper_ret_ldub_cmmu(CPUArchState *env, target_ulong addr,
27
/*
171
- TCGMemOpIdx oi, uintptr_t retaddr)
28
@@ -XXX,XX +XXX,XX @@ static bool fold_add(OptContext *ctx, TCGOp *op)
172
+uint32_t cpu_ldub_code(CPUArchState *env, abi_ptr addr)
29
fold_xi_to_x(ctx, op, 0)) {
173
{
30
return true;
174
- return full_ldub_cmmu(env, addr, oi, retaddr);
31
}
175
+ TCGMemOpIdx oi = make_memop_idx(MO_UB, cpu_mmu_index(env, true));
32
- return false;
176
+ return full_ldub_code(env, addr, oi, 0);
33
+ return finish_folding(ctx, op);
177
}
34
}
178
35
179
-int8_t helper_ret_ldsb_cmmu(CPUArchState *env, target_ulong addr,
36
/* We cannot as yet do_constant_folding with vectors. */
180
- TCGMemOpIdx oi, uintptr_t retaddr)
37
@@ -XXX,XX +XXX,XX @@ static bool fold_add_vec(OptContext *ctx, TCGOp *op)
181
+static uint64_t full_lduw_code(CPUArchState *env, target_ulong addr,
38
fold_xi_to_x(ctx, op, 0)) {
182
+ TCGMemOpIdx oi, uintptr_t retaddr)
39
return true;
183
{
40
}
184
- return (int8_t) full_ldub_cmmu(env, addr, oi, retaddr);
41
- return false;
185
+ return load_helper(env, addr, oi, retaddr, MO_TEUW, true, full_lduw_code);
42
+ return finish_folding(ctx, op);
186
}
43
}
187
44
188
-static uint64_t full_le_lduw_cmmu(CPUArchState *env, target_ulong addr,
45
static bool fold_addsub2(OptContext *ctx, TCGOp *op, bool add)
189
- TCGMemOpIdx oi, uintptr_t retaddr)
46
@@ -XXX,XX +XXX,XX @@ static bool fold_addsub2(OptContext *ctx, TCGOp *op, bool add)
190
+uint32_t cpu_lduw_code(CPUArchState *env, abi_ptr addr)
47
op->args[4] = arg_new_constant(ctx, bl);
191
{
48
op->args[5] = arg_new_constant(ctx, bh);
192
- return load_helper(env, addr, oi, retaddr, MO_LEUW, true,
49
}
193
- full_le_lduw_cmmu);
50
- return false;
194
+ TCGMemOpIdx oi = make_memop_idx(MO_TEUW, cpu_mmu_index(env, true));
51
+ return finish_folding(ctx, op);
195
+ return full_lduw_code(env, addr, oi, 0);
196
}
52
}
197
53
198
-uint16_t helper_le_lduw_cmmu(CPUArchState *env, target_ulong addr,
54
static bool fold_add2(OptContext *ctx, TCGOp *op)
199
- TCGMemOpIdx oi, uintptr_t retaddr)
200
+static uint64_t full_ldl_code(CPUArchState *env, target_ulong addr,
201
+ TCGMemOpIdx oi, uintptr_t retaddr)
202
{
203
- return full_le_lduw_cmmu(env, addr, oi, retaddr);
204
+ return load_helper(env, addr, oi, retaddr, MO_TEUL, true, full_ldl_code);
205
}
206
207
-int16_t helper_le_ldsw_cmmu(CPUArchState *env, target_ulong addr,
208
- TCGMemOpIdx oi, uintptr_t retaddr)
209
+uint32_t cpu_ldl_code(CPUArchState *env, abi_ptr addr)
210
{
211
- return (int16_t) full_le_lduw_cmmu(env, addr, oi, retaddr);
212
+ TCGMemOpIdx oi = make_memop_idx(MO_TEUL, cpu_mmu_index(env, true));
213
+ return full_ldl_code(env, addr, oi, 0);
214
}
215
216
-static uint64_t full_be_lduw_cmmu(CPUArchState *env, target_ulong addr,
217
- TCGMemOpIdx oi, uintptr_t retaddr)
218
+static uint64_t full_ldq_code(CPUArchState *env, target_ulong addr,
219
+ TCGMemOpIdx oi, uintptr_t retaddr)
220
{
221
- return load_helper(env, addr, oi, retaddr, MO_BEUW, true,
222
- full_be_lduw_cmmu);
223
+ return load_helper(env, addr, oi, retaddr, MO_TEQ, true, full_ldq_code);
224
}
225
226
-uint16_t helper_be_lduw_cmmu(CPUArchState *env, target_ulong addr,
227
- TCGMemOpIdx oi, uintptr_t retaddr)
228
+uint64_t cpu_ldq_code(CPUArchState *env, abi_ptr addr)
229
{
230
- return full_be_lduw_cmmu(env, addr, oi, retaddr);
231
-}
232
-
233
-int16_t helper_be_ldsw_cmmu(CPUArchState *env, target_ulong addr,
234
- TCGMemOpIdx oi, uintptr_t retaddr)
235
-{
236
- return (int16_t) full_be_lduw_cmmu(env, addr, oi, retaddr);
237
-}
238
-
239
-static uint64_t full_le_ldul_cmmu(CPUArchState *env, target_ulong addr,
240
- TCGMemOpIdx oi, uintptr_t retaddr)
241
-{
242
- return load_helper(env, addr, oi, retaddr, MO_LEUL, true,
243
- full_le_ldul_cmmu);
244
-}
245
-
246
-uint32_t helper_le_ldl_cmmu(CPUArchState *env, target_ulong addr,
247
- TCGMemOpIdx oi, uintptr_t retaddr)
248
-{
249
- return full_le_ldul_cmmu(env, addr, oi, retaddr);
250
-}
251
-
252
-static uint64_t full_be_ldul_cmmu(CPUArchState *env, target_ulong addr,
253
- TCGMemOpIdx oi, uintptr_t retaddr)
254
-{
255
- return load_helper(env, addr, oi, retaddr, MO_BEUL, true,
256
- full_be_ldul_cmmu);
257
-}
258
-
259
-uint32_t helper_be_ldl_cmmu(CPUArchState *env, target_ulong addr,
260
- TCGMemOpIdx oi, uintptr_t retaddr)
261
-{
262
- return full_be_ldul_cmmu(env, addr, oi, retaddr);
263
-}
264
-
265
-uint64_t helper_le_ldq_cmmu(CPUArchState *env, target_ulong addr,
266
- TCGMemOpIdx oi, uintptr_t retaddr)
267
-{
268
- return load_helper(env, addr, oi, retaddr, MO_LEQ, true,
269
- helper_le_ldq_cmmu);
270
-}
271
-
272
-uint64_t helper_be_ldq_cmmu(CPUArchState *env, target_ulong addr,
273
- TCGMemOpIdx oi, uintptr_t retaddr)
274
-{
275
- return load_helper(env, addr, oi, retaddr, MO_BEQ, true,
276
- helper_be_ldq_cmmu);
277
+ TCGMemOpIdx oi = make_memop_idx(MO_TEQ, cpu_mmu_index(env, true));
278
+ return full_ldq_code(env, addr, oi, 0);
279
}
280
diff --git a/docs/devel/loads-stores.rst b/docs/devel/loads-stores.rst
281
index XXXXXXX..XXXXXXX 100644
282
--- a/docs/devel/loads-stores.rst
283
+++ b/docs/devel/loads-stores.rst
284
@@ -XXX,XX +XXX,XX @@ more in line with the other memory access functions.
285
286
load: ``helper_{endian}_ld{sign}{size}_mmu(env, addr, opindex, retaddr)``
287
288
-load (code): ``helper_{endian}_ld{sign}{size}_cmmu(env, addr, opindex, retaddr)``
289
-
290
store: ``helper_{endian}_st{size}_mmu(env, addr, val, opindex, retaddr)``
291
292
``sign``
293
@@ -XXX,XX +XXX,XX @@ store: ``helper_{endian}_st{size}_mmu(env, addr, val, opindex, retaddr)``
294
- ``ret`` : target endianness
295
296
Regexes for git grep
297
- - ``\<helper_\(le\|be\|ret\)_ld[us]\?[bwlq]_c\?mmu\>``
298
+ - ``\<helper_\(le\|be\|ret\)_ld[us]\?[bwlq]_mmu\>``
299
- ``\<helper_\(le\|be\|ret\)_st[bwlq]_mmu\>``
300
301
``address_space_*``
302
--
55
--
303
2.20.1
56
2.43.0
304
305
diff view generated by jsdifflib
1
With the tracing hooks, the inline functions are no longer
1
Introduce ti_is_const, ti_const_val, ti_is_const_val.
2
so simple. Once out-of-line, the current tlb_entry lookup
3
is redundant with the one in the main load/store_helper.
4
2
5
This also begins the introduction of a new target facing
6
interface, with suffix *_mmuidx_ra. This is not yet
7
official because the interface is not done for user-only.
8
9
Use abi_ptr instead of target_ulong in preparation for
10
user-only; the two types are identical for softmmu.
11
12
What remains in cpu_ldst_template.h are the expansions
13
for _code, _data, and MMU_MODE<N>_SUFFIX.
14
15
Tested-by: Philippe Mathieu-Daudé <philmd@redhat.com>
16
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
3
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
17
---
4
---
18
include/exec/cpu_ldst.h | 25 ++++++-
5
tcg/optimize.c | 20 +++++++++++++++++---
19
include/exec/cpu_ldst_template.h | 125 +++++++------------------------
6
1 file changed, 17 insertions(+), 3 deletions(-)
20
accel/tcg/cputlb.c | 116 ++++++++++++++++++++++++++++
21
3 files changed, 166 insertions(+), 100 deletions(-)
22
7
23
diff --git a/include/exec/cpu_ldst.h b/include/exec/cpu_ldst.h
8
diff --git a/tcg/optimize.c b/tcg/optimize.c
24
index XXXXXXX..XXXXXXX 100644
9
index XXXXXXX..XXXXXXX 100644
25
--- a/include/exec/cpu_ldst.h
10
--- a/tcg/optimize.c
26
+++ b/include/exec/cpu_ldst.h
11
+++ b/tcg/optimize.c
27
@@ -XXX,XX +XXX,XX @@ static inline void clear_helper_retaddr(void)
12
@@ -XXX,XX +XXX,XX @@ static inline TempOptInfo *arg_info(TCGArg arg)
28
13
return ts_info(arg_temp(arg));
29
#else
30
31
-/* The memory helpers for tcg-generated code need tcg_target_long etc. */
32
+/* Needed for TCG_OVERSIZED_GUEST */
33
#include "tcg.h"
34
35
static inline target_ulong tlb_addr_write(const CPUTLBEntry *entry)
36
@@ -XXX,XX +XXX,XX @@ static inline CPUTLBEntry *tlb_entry(CPUArchState *env, uintptr_t mmu_idx,
37
return &env_tlb(env)->f[mmu_idx].table[tlb_index(env, mmu_idx, addr)];
38
}
14
}
39
15
40
+uint32_t cpu_ldub_mmuidx_ra(CPUArchState *env, abi_ptr addr,
16
+static inline bool ti_is_const(TempOptInfo *ti)
41
+ int mmu_idx, uintptr_t ra);
42
+uint32_t cpu_lduw_mmuidx_ra(CPUArchState *env, abi_ptr addr,
43
+ int mmu_idx, uintptr_t ra);
44
+uint32_t cpu_ldl_mmuidx_ra(CPUArchState *env, abi_ptr addr,
45
+ int mmu_idx, uintptr_t ra);
46
+uint64_t cpu_ldq_mmuidx_ra(CPUArchState *env, abi_ptr addr,
47
+ int mmu_idx, uintptr_t ra);
48
+
49
+int cpu_ldsb_mmuidx_ra(CPUArchState *env, abi_ptr addr,
50
+ int mmu_idx, uintptr_t ra);
51
+int cpu_ldsw_mmuidx_ra(CPUArchState *env, abi_ptr addr,
52
+ int mmu_idx, uintptr_t ra);
53
+
54
+void cpu_stb_mmuidx_ra(CPUArchState *env, abi_ptr addr, uint32_t val,
55
+ int mmu_idx, uintptr_t retaddr);
56
+void cpu_stw_mmuidx_ra(CPUArchState *env, abi_ptr addr, uint32_t val,
57
+ int mmu_idx, uintptr_t retaddr);
58
+void cpu_stl_mmuidx_ra(CPUArchState *env, abi_ptr addr, uint32_t val,
59
+ int mmu_idx, uintptr_t retaddr);
60
+void cpu_stq_mmuidx_ra(CPUArchState *env, abi_ptr addr, uint64_t val,
61
+ int mmu_idx, uintptr_t retaddr);
62
+
63
#ifdef MMU_MODE0_SUFFIX
64
#define CPU_MMU_INDEX 0
65
#define MEMSUFFIX MMU_MODE0_SUFFIX
66
diff --git a/include/exec/cpu_ldst_template.h b/include/exec/cpu_ldst_template.h
67
index XXXXXXX..XXXXXXX 100644
68
--- a/include/exec/cpu_ldst_template.h
69
+++ b/include/exec/cpu_ldst_template.h
70
@@ -XXX,XX +XXX,XX @@
71
* License along with this library; if not, see <http://www.gnu.org/licenses/>.
72
*/
73
74
-#if !defined(SOFTMMU_CODE_ACCESS)
75
-#include "trace-root.h"
76
-#endif
77
-
78
-#include "qemu/plugin.h"
79
-#include "trace/mem.h"
80
-
81
#if DATA_SIZE == 8
82
#define SUFFIX q
83
#define USUFFIX q
84
@@ -XXX,XX +XXX,XX @@
85
#define RES_TYPE uint32_t
86
#endif
87
88
+/* generic load/store macros */
89
+
90
#ifdef SOFTMMU_CODE_ACCESS
91
-#define ADDR_READ addr_code
92
-#define MMUSUFFIX _cmmu
93
-#define URETSUFFIX USUFFIX
94
-#define SRETSUFFIX glue(s, SUFFIX)
95
-#else
96
-#define ADDR_READ addr_read
97
-#define MMUSUFFIX _mmu
98
-#define URETSUFFIX USUFFIX
99
-#define SRETSUFFIX glue(s, SUFFIX)
100
+
101
+static inline RES_TYPE
102
+glue(glue(cpu_ld, USUFFIX), _code)(CPUArchState *env, target_ulong ptr)
103
+{
17
+{
104
+ TCGMemOpIdx oi = make_memop_idx(MO_TE | SHIFT, CPU_MMU_INDEX);
18
+ return ti->is_const;
105
+ return glue(glue(helper_ret_ld, USUFFIX), _cmmu)(env, ptr, oi, 0);
106
+}
19
+}
107
+
20
+
108
+#if DATA_SIZE <= 2
21
+static inline uint64_t ti_const_val(TempOptInfo *ti)
109
+static inline int
110
+glue(glue(cpu_lds, SUFFIX), _code)(CPUArchState *env, target_ulong ptr)
111
+{
22
+{
112
+ return (DATA_STYPE)glue(glue(cpu_ld, USUFFIX), _code)(env, ptr);
23
+ return ti->val;
113
+}
114
#endif
115
116
-/* generic load/store macros */
117
+#else
118
119
static inline RES_TYPE
120
glue(glue(glue(cpu_ld, USUFFIX), MEMSUFFIX), _ra)(CPUArchState *env,
121
target_ulong ptr,
122
uintptr_t retaddr)
123
{
124
- CPUTLBEntry *entry;
125
- RES_TYPE res;
126
- target_ulong addr;
127
- int mmu_idx = CPU_MMU_INDEX;
128
- MemOp op = MO_TE | SHIFT;
129
-#if !defined(SOFTMMU_CODE_ACCESS)
130
- uint16_t meminfo = trace_mem_get_info(op, mmu_idx, false);
131
- trace_guest_mem_before_exec(env_cpu(env), ptr, meminfo);
132
-#endif
133
-
134
- addr = ptr;
135
- entry = tlb_entry(env, mmu_idx, addr);
136
- if (unlikely(entry->ADDR_READ !=
137
- (addr & (TARGET_PAGE_MASK | (DATA_SIZE - 1))))) {
138
- TCGMemOpIdx oi = make_memop_idx(op, mmu_idx);
139
- res = glue(glue(helper_ret_ld, URETSUFFIX), MMUSUFFIX)(env, addr,
140
- oi, retaddr);
141
- } else {
142
- uintptr_t hostaddr = addr + entry->addend;
143
- res = glue(glue(ld, USUFFIX), _p)((uint8_t *)hostaddr);
144
- }
145
-#ifndef SOFTMMU_CODE_ACCESS
146
- qemu_plugin_vcpu_mem_cb(env_cpu(env), ptr, meminfo);
147
-#endif
148
- return res;
149
+ return glue(glue(cpu_ld, USUFFIX), _mmuidx_ra)(env, ptr, CPU_MMU_INDEX,
150
+ retaddr);
151
}
152
153
static inline RES_TYPE
154
glue(glue(cpu_ld, USUFFIX), MEMSUFFIX)(CPUArchState *env, target_ulong ptr)
155
{
156
- return glue(glue(glue(cpu_ld, USUFFIX), MEMSUFFIX), _ra)(env, ptr, 0);
157
+ return glue(glue(cpu_ld, USUFFIX), _mmuidx_ra)(env, ptr, CPU_MMU_INDEX, 0);
158
}
159
160
#if DATA_SIZE <= 2
161
@@ -XXX,XX +XXX,XX @@ glue(glue(glue(cpu_lds, SUFFIX), MEMSUFFIX), _ra)(CPUArchState *env,
162
target_ulong ptr,
163
uintptr_t retaddr)
164
{
165
- CPUTLBEntry *entry;
166
- int res;
167
- target_ulong addr;
168
- int mmu_idx = CPU_MMU_INDEX;
169
- MemOp op = MO_TE | MO_SIGN | SHIFT;
170
-#ifndef SOFTMMU_CODE_ACCESS
171
- uint16_t meminfo = trace_mem_get_info(op, mmu_idx, false);
172
- trace_guest_mem_before_exec(env_cpu(env), ptr, meminfo);
173
-#endif
174
-
175
- addr = ptr;
176
- entry = tlb_entry(env, mmu_idx, addr);
177
- if (unlikely(entry->ADDR_READ !=
178
- (addr & (TARGET_PAGE_MASK | (DATA_SIZE - 1))))) {
179
- TCGMemOpIdx oi = make_memop_idx(op & ~MO_SIGN, mmu_idx);
180
- res = (DATA_STYPE)glue(glue(helper_ret_ld, SRETSUFFIX),
181
- MMUSUFFIX)(env, addr, oi, retaddr);
182
- } else {
183
- uintptr_t hostaddr = addr + entry->addend;
184
- res = glue(glue(lds, SUFFIX), _p)((uint8_t *)hostaddr);
185
- }
186
-#ifndef SOFTMMU_CODE_ACCESS
187
- qemu_plugin_vcpu_mem_cb(env_cpu(env), ptr, meminfo);
188
-#endif
189
- return res;
190
+ return glue(glue(cpu_lds, SUFFIX), _mmuidx_ra)(env, ptr, CPU_MMU_INDEX,
191
+ retaddr);
192
}
193
194
static inline int
195
glue(glue(cpu_lds, SUFFIX), MEMSUFFIX)(CPUArchState *env, target_ulong ptr)
196
{
197
- return glue(glue(glue(cpu_lds, SUFFIX), MEMSUFFIX), _ra)(env, ptr, 0);
198
+ return glue(glue(cpu_lds, SUFFIX), _mmuidx_ra)(env, ptr, CPU_MMU_INDEX, 0);
199
}
200
#endif
201
202
-#ifndef SOFTMMU_CODE_ACCESS
203
-
204
/* generic store macro */
205
206
static inline void
207
@@ -XXX,XX +XXX,XX @@ glue(glue(glue(cpu_st, SUFFIX), MEMSUFFIX), _ra)(CPUArchState *env,
208
target_ulong ptr,
209
RES_TYPE v, uintptr_t retaddr)
210
{
211
- CPUTLBEntry *entry;
212
- target_ulong addr;
213
- int mmu_idx = CPU_MMU_INDEX;
214
- MemOp op = MO_TE | SHIFT;
215
-#if !defined(SOFTMMU_CODE_ACCESS)
216
- uint16_t meminfo = trace_mem_get_info(op, mmu_idx, true);
217
- trace_guest_mem_before_exec(env_cpu(env), ptr, meminfo);
218
-#endif
219
-
220
- addr = ptr;
221
- entry = tlb_entry(env, mmu_idx, addr);
222
- if (unlikely(tlb_addr_write(entry) !=
223
- (addr & (TARGET_PAGE_MASK | (DATA_SIZE - 1))))) {
224
- TCGMemOpIdx oi = make_memop_idx(op, mmu_idx);
225
- glue(glue(helper_ret_st, SUFFIX), MMUSUFFIX)(env, addr, v, oi,
226
- retaddr);
227
- } else {
228
- uintptr_t hostaddr = addr + entry->addend;
229
- glue(glue(st, SUFFIX), _p)((uint8_t *)hostaddr, v);
230
- }
231
-#ifndef SOFTMMU_CODE_ACCESS
232
- qemu_plugin_vcpu_mem_cb(env_cpu(env), ptr, meminfo);
233
-#endif
234
+ glue(glue(cpu_st, SUFFIX), _mmuidx_ra)(env, ptr, v, CPU_MMU_INDEX,
235
+ retaddr);
236
}
237
238
static inline void
239
glue(glue(cpu_st, SUFFIX), MEMSUFFIX)(CPUArchState *env, target_ulong ptr,
240
RES_TYPE v)
241
{
242
- glue(glue(glue(cpu_st, SUFFIX), MEMSUFFIX), _ra)(env, ptr, v, 0);
243
+ glue(glue(cpu_st, SUFFIX), _mmuidx_ra)(env, ptr, v, CPU_MMU_INDEX, 0);
244
}
245
246
#endif /* !SOFTMMU_CODE_ACCESS */
247
@@ -XXX,XX +XXX,XX @@ glue(glue(cpu_st, SUFFIX), MEMSUFFIX)(CPUArchState *env, target_ulong ptr,
248
#undef SUFFIX
249
#undef USUFFIX
250
#undef DATA_SIZE
251
-#undef MMUSUFFIX
252
-#undef ADDR_READ
253
-#undef URETSUFFIX
254
-#undef SRETSUFFIX
255
#undef SHIFT
256
diff --git a/accel/tcg/cputlb.c b/accel/tcg/cputlb.c
257
index XXXXXXX..XXXXXXX 100644
258
--- a/accel/tcg/cputlb.c
259
+++ b/accel/tcg/cputlb.c
260
@@ -XXX,XX +XXX,XX @@
261
#include "qemu/atomic.h"
262
#include "qemu/atomic128.h"
263
#include "translate-all.h"
264
+#include "trace-root.h"
265
+#include "qemu/plugin.h"
266
+#include "trace/mem.h"
267
#ifdef CONFIG_PLUGIN
268
#include "qemu/plugin-memory.h"
269
#endif
270
@@ -XXX,XX +XXX,XX @@ tcg_target_ulong helper_be_ldsl_mmu(CPUArchState *env, target_ulong addr,
271
return (int32_t)helper_be_ldul_mmu(env, addr, oi, retaddr);
272
}
273
274
+/*
275
+ * Load helpers for cpu_ldst.h.
276
+ */
277
+
278
+static inline uint64_t cpu_load_helper(CPUArchState *env, abi_ptr addr,
279
+ int mmu_idx, uintptr_t retaddr,
280
+ MemOp op, FullLoadHelper *full_load)
281
+{
282
+ uint16_t meminfo;
283
+ TCGMemOpIdx oi;
284
+ uint64_t ret;
285
+
286
+ meminfo = trace_mem_get_info(op, mmu_idx, false);
287
+ trace_guest_mem_before_exec(env_cpu(env), addr, meminfo);
288
+
289
+ op &= ~MO_SIGN;
290
+ oi = make_memop_idx(op, mmu_idx);
291
+ ret = full_load(env, addr, oi, retaddr);
292
+
293
+ qemu_plugin_vcpu_mem_cb(env_cpu(env), addr, meminfo);
294
+
295
+ return ret;
296
+}
24
+}
297
+
25
+
298
+uint32_t cpu_ldub_mmuidx_ra(CPUArchState *env, abi_ptr addr,
26
+static inline bool ti_is_const_val(TempOptInfo *ti, uint64_t val)
299
+ int mmu_idx, uintptr_t ra)
300
+{
27
+{
301
+ return cpu_load_helper(env, addr, mmu_idx, ra, MO_UB, full_ldub_mmu);
28
+ return ti_is_const(ti) && ti_const_val(ti) == val;
302
+}
29
+}
303
+
30
+
304
+int cpu_ldsb_mmuidx_ra(CPUArchState *env, abi_ptr addr,
31
static inline bool ts_is_const(TCGTemp *ts)
305
+ int mmu_idx, uintptr_t ra)
32
{
306
+{
33
- return ts_info(ts)->is_const;
307
+ return (int8_t)cpu_load_helper(env, addr, mmu_idx, ra, MO_SB,
34
+ return ti_is_const(ts_info(ts));
308
+ full_ldub_mmu);
309
+}
310
+
311
+uint32_t cpu_lduw_mmuidx_ra(CPUArchState *env, abi_ptr addr,
312
+ int mmu_idx, uintptr_t ra)
313
+{
314
+ return cpu_load_helper(env, addr, mmu_idx, ra, MO_TEUW,
315
+ MO_TE == MO_LE
316
+ ? full_le_lduw_mmu : full_be_lduw_mmu);
317
+}
318
+
319
+int cpu_ldsw_mmuidx_ra(CPUArchState *env, abi_ptr addr,
320
+ int mmu_idx, uintptr_t ra)
321
+{
322
+ return (int16_t)cpu_load_helper(env, addr, mmu_idx, ra, MO_TESW,
323
+ MO_TE == MO_LE
324
+ ? full_le_lduw_mmu : full_be_lduw_mmu);
325
+}
326
+
327
+uint32_t cpu_ldl_mmuidx_ra(CPUArchState *env, abi_ptr addr,
328
+ int mmu_idx, uintptr_t ra)
329
+{
330
+ return cpu_load_helper(env, addr, mmu_idx, ra, MO_TEUL,
331
+ MO_TE == MO_LE
332
+ ? full_le_ldul_mmu : full_be_ldul_mmu);
333
+}
334
+
335
+uint64_t cpu_ldq_mmuidx_ra(CPUArchState *env, abi_ptr addr,
336
+ int mmu_idx, uintptr_t ra)
337
+{
338
+ return cpu_load_helper(env, addr, mmu_idx, ra, MO_TEQ,
339
+ MO_TE == MO_LE
340
+ ? helper_le_ldq_mmu : helper_be_ldq_mmu);
341
+}
342
+
343
/*
344
* Store Helpers
345
*/
346
@@ -XXX,XX +XXX,XX @@ void helper_be_stq_mmu(CPUArchState *env, target_ulong addr, uint64_t val,
347
store_helper(env, addr, val, oi, retaddr, MO_BEQ);
348
}
35
}
349
36
350
+/*
37
static inline bool ts_is_const_val(TCGTemp *ts, uint64_t val)
351
+ * Store Helpers for cpu_ldst.h
38
{
352
+ */
39
- TempOptInfo *ti = ts_info(ts);
353
+
40
- return ti->is_const && ti->val == val;
354
+static inline void QEMU_ALWAYS_INLINE
41
+ return ti_is_const_val(ts_info(ts), val);
355
+cpu_store_helper(CPUArchState *env, target_ulong addr, uint64_t val,
42
}
356
+ int mmu_idx, uintptr_t retaddr, MemOp op)
43
357
+{
44
static inline bool arg_is_const(TCGArg arg)
358
+ TCGMemOpIdx oi;
359
+ uint16_t meminfo;
360
+
361
+ meminfo = trace_mem_get_info(op, mmu_idx, true);
362
+ trace_guest_mem_before_exec(env_cpu(env), addr, meminfo);
363
+
364
+ oi = make_memop_idx(op, mmu_idx);
365
+ store_helper(env, addr, val, oi, retaddr, op);
366
+
367
+ qemu_plugin_vcpu_mem_cb(env_cpu(env), addr, meminfo);
368
+}
369
+
370
+void cpu_stb_mmuidx_ra(CPUArchState *env, target_ulong addr, uint32_t val,
371
+ int mmu_idx, uintptr_t retaddr)
372
+{
373
+ cpu_store_helper(env, addr, val, mmu_idx, retaddr, MO_UB);
374
+}
375
+
376
+void cpu_stw_mmuidx_ra(CPUArchState *env, target_ulong addr, uint32_t val,
377
+ int mmu_idx, uintptr_t retaddr)
378
+{
379
+ cpu_store_helper(env, addr, val, mmu_idx, retaddr, MO_TEUW);
380
+}
381
+
382
+void cpu_stl_mmuidx_ra(CPUArchState *env, target_ulong addr, uint32_t val,
383
+ int mmu_idx, uintptr_t retaddr)
384
+{
385
+ cpu_store_helper(env, addr, val, mmu_idx, retaddr, MO_TEUL);
386
+}
387
+
388
+void cpu_stq_mmuidx_ra(CPUArchState *env, target_ulong addr, uint64_t val,
389
+ int mmu_idx, uintptr_t retaddr)
390
+{
391
+ cpu_store_helper(env, addr, val, mmu_idx, retaddr, MO_TEQ);
392
+}
393
+
394
/* First set of helpers allows passing in of OI and RETADDR. This makes
395
them callable from other helpers. */
396
397
--
45
--
398
2.20.1
46
2.43.0
399
400
diff view generated by jsdifflib
New patch
1
Avoid the use of the OptContext slots. Find TempOptInfo once.
2
Sink mask computation below fold_affected_mask early exit.
1
3
4
Reviewed-by: Pierrick Bouvier <pierrick.bouvier@linaro.org>
5
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
6
---
7
tcg/optimize.c | 30 ++++++++++++++++--------------
8
1 file changed, 16 insertions(+), 14 deletions(-)
9
10
diff --git a/tcg/optimize.c b/tcg/optimize.c
11
index XXXXXXX..XXXXXXX 100644
12
--- a/tcg/optimize.c
13
+++ b/tcg/optimize.c
14
@@ -XXX,XX +XXX,XX @@ static bool fold_add2(OptContext *ctx, TCGOp *op)
15
16
static bool fold_and(OptContext *ctx, TCGOp *op)
17
{
18
- uint64_t z1, z2;
19
+ uint64_t z1, z2, z_mask, s_mask;
20
+ TempOptInfo *t1, *t2;
21
22
if (fold_const2_commutative(ctx, op) ||
23
fold_xi_to_i(ctx, op, 0) ||
24
@@ -XXX,XX +XXX,XX @@ static bool fold_and(OptContext *ctx, TCGOp *op)
25
return true;
26
}
27
28
- z1 = arg_info(op->args[1])->z_mask;
29
- z2 = arg_info(op->args[2])->z_mask;
30
- ctx->z_mask = z1 & z2;
31
-
32
- /*
33
- * Sign repetitions are perforce all identical, whether they are 1 or 0.
34
- * Bitwise operations preserve the relative quantity of the repetitions.
35
- */
36
- ctx->s_mask = arg_info(op->args[1])->s_mask
37
- & arg_info(op->args[2])->s_mask;
38
+ t1 = arg_info(op->args[1]);
39
+ t2 = arg_info(op->args[2]);
40
+ z1 = t1->z_mask;
41
+ z2 = t2->z_mask;
42
43
/*
44
* Known-zeros does not imply known-ones. Therefore unless
45
* arg2 is constant, we can't infer affected bits from it.
46
*/
47
- if (arg_is_const(op->args[2]) &&
48
- fold_affected_mask(ctx, op, z1 & ~z2)) {
49
+ if (ti_is_const(t2) && fold_affected_mask(ctx, op, z1 & ~z2)) {
50
return true;
51
}
52
53
- return fold_masks(ctx, op);
54
+ z_mask = z1 & z2;
55
+
56
+ /*
57
+ * Sign repetitions are perforce all identical, whether they are 1 or 0.
58
+ * Bitwise operations preserve the relative quantity of the repetitions.
59
+ */
60
+ s_mask = t1->s_mask & t2->s_mask;
61
+
62
+ return fold_masks_zs(ctx, op, z_mask, s_mask);
63
}
64
65
static bool fold_andc(OptContext *ctx, TCGOp *op)
66
--
67
2.43.0
diff view generated by jsdifflib
New patch
1
Avoid the use of the OptContext slots. Find TempOptInfo once.
2
Avoid double inversion of the value of second const operand.
1
3
4
Reviewed-by: Pierrick Bouvier <pierrick.bouvier@linaro.org>
5
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
6
---
7
tcg/optimize.c | 21 +++++++++++----------
8
1 file changed, 11 insertions(+), 10 deletions(-)
9
10
diff --git a/tcg/optimize.c b/tcg/optimize.c
11
index XXXXXXX..XXXXXXX 100644
12
--- a/tcg/optimize.c
13
+++ b/tcg/optimize.c
14
@@ -XXX,XX +XXX,XX @@ static bool fold_and(OptContext *ctx, TCGOp *op)
15
16
static bool fold_andc(OptContext *ctx, TCGOp *op)
17
{
18
- uint64_t z1;
19
+ uint64_t z_mask, s_mask;
20
+ TempOptInfo *t1, *t2;
21
22
if (fold_const2(ctx, op) ||
23
fold_xx_to_i(ctx, op, 0) ||
24
@@ -XXX,XX +XXX,XX @@ static bool fold_andc(OptContext *ctx, TCGOp *op)
25
return true;
26
}
27
28
- z1 = arg_info(op->args[1])->z_mask;
29
+ t1 = arg_info(op->args[1]);
30
+ t2 = arg_info(op->args[2]);
31
+ z_mask = t1->z_mask;
32
33
/*
34
* Known-zeros does not imply known-ones. Therefore unless
35
* arg2 is constant, we can't infer anything from it.
36
*/
37
- if (arg_is_const(op->args[2])) {
38
- uint64_t z2 = ~arg_info(op->args[2])->z_mask;
39
- if (fold_affected_mask(ctx, op, z1 & ~z2)) {
40
+ if (ti_is_const(t2)) {
41
+ uint64_t v2 = ti_const_val(t2);
42
+ if (fold_affected_mask(ctx, op, z_mask & v2)) {
43
return true;
44
}
45
- z1 &= z2;
46
+ z_mask &= ~v2;
47
}
48
- ctx->z_mask = z1;
49
50
- ctx->s_mask = arg_info(op->args[1])->s_mask
51
- & arg_info(op->args[2])->s_mask;
52
- return fold_masks(ctx, op);
53
+ s_mask = t1->s_mask & t2->s_mask;
54
+ return fold_masks_zs(ctx, op, z_mask, s_mask);
55
}
56
57
static bool fold_brcond(OptContext *ctx, TCGOp *op)
58
--
59
2.43.0
diff view generated by jsdifflib
New patch
1
Avoid the use of the OptContext slots. Find TempOptInfo once.
2
Always set s_mask along the BSWAP_OS path, since the result is
3
being explicitly sign-extended.
1
4
5
Reviewed-by: Pierrick Bouvier <pierrick.bouvier@linaro.org>
6
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
7
---
8
tcg/optimize.c | 21 ++++++++++-----------
9
1 file changed, 10 insertions(+), 11 deletions(-)
10
11
diff --git a/tcg/optimize.c b/tcg/optimize.c
12
index XXXXXXX..XXXXXXX 100644
13
--- a/tcg/optimize.c
14
+++ b/tcg/optimize.c
15
@@ -XXX,XX +XXX,XX @@ static bool fold_brcond2(OptContext *ctx, TCGOp *op)
16
static bool fold_bswap(OptContext *ctx, TCGOp *op)
17
{
18
uint64_t z_mask, s_mask, sign;
19
+ TempOptInfo *t1 = arg_info(op->args[1]);
20
21
- if (arg_is_const(op->args[1])) {
22
- uint64_t t = arg_info(op->args[1])->val;
23
-
24
- t = do_constant_folding(op->opc, ctx->type, t, op->args[2]);
25
- return tcg_opt_gen_movi(ctx, op, op->args[0], t);
26
+ if (ti_is_const(t1)) {
27
+ return tcg_opt_gen_movi(ctx, op, op->args[0],
28
+ do_constant_folding(op->opc, ctx->type,
29
+ ti_const_val(t1),
30
+ op->args[2]));
31
}
32
33
- z_mask = arg_info(op->args[1])->z_mask;
34
-
35
+ z_mask = t1->z_mask;
36
switch (op->opc) {
37
case INDEX_op_bswap16_i32:
38
case INDEX_op_bswap16_i64:
39
@@ -XXX,XX +XXX,XX @@ static bool fold_bswap(OptContext *ctx, TCGOp *op)
40
/* If the sign bit may be 1, force all the bits above to 1. */
41
if (z_mask & sign) {
42
z_mask |= sign;
43
- s_mask = sign << 1;
44
}
45
+ /* The value and therefore s_mask is explicitly sign-extended. */
46
+ s_mask = sign;
47
break;
48
default:
49
/* The high bits are undefined: force all bits above the sign to 1. */
50
z_mask |= sign << 1;
51
break;
52
}
53
- ctx->z_mask = z_mask;
54
- ctx->s_mask = s_mask;
55
56
- return fold_masks(ctx, op);
57
+ return fold_masks_zs(ctx, op, z_mask, s_mask);
58
}
59
60
static bool fold_call(OptContext *ctx, TCGOp *op)
61
--
62
2.43.0
diff view generated by jsdifflib
New patch
1
Avoid the use of the OptContext slots. Find TempOptInfo once.
2
Compute s_mask from the union of the maximum count and the
3
op2 fallback for op1 being zero.
1
4
5
Reviewed-by: Pierrick Bouvier <pierrick.bouvier@linaro.org>
6
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
7
---
8
tcg/optimize.c | 15 ++++++++++-----
9
1 file changed, 10 insertions(+), 5 deletions(-)
10
11
diff --git a/tcg/optimize.c b/tcg/optimize.c
12
index XXXXXXX..XXXXXXX 100644
13
--- a/tcg/optimize.c
14
+++ b/tcg/optimize.c
15
@@ -XXX,XX +XXX,XX @@ static bool fold_call(OptContext *ctx, TCGOp *op)
16
17
static bool fold_count_zeros(OptContext *ctx, TCGOp *op)
18
{
19
- uint64_t z_mask;
20
+ uint64_t z_mask, s_mask;
21
+ TempOptInfo *t1 = arg_info(op->args[1]);
22
+ TempOptInfo *t2 = arg_info(op->args[2]);
23
24
- if (arg_is_const(op->args[1])) {
25
- uint64_t t = arg_info(op->args[1])->val;
26
+ if (ti_is_const(t1)) {
27
+ uint64_t t = ti_const_val(t1);
28
29
if (t != 0) {
30
t = do_constant_folding(op->opc, ctx->type, t, 0);
31
@@ -XXX,XX +XXX,XX @@ static bool fold_count_zeros(OptContext *ctx, TCGOp *op)
32
default:
33
g_assert_not_reached();
34
}
35
- ctx->z_mask = arg_info(op->args[2])->z_mask | z_mask;
36
- return false;
37
+ s_mask = ~z_mask;
38
+ z_mask |= t2->z_mask;
39
+ s_mask &= t2->s_mask;
40
+
41
+ return fold_masks_zs(ctx, op, z_mask, s_mask);
42
}
43
44
static bool fold_ctpop(OptContext *ctx, TCGOp *op)
45
--
46
2.43.0
diff view generated by jsdifflib
New patch
1
Add fold_masks_z as a trivial wrapper around fold_masks_zs.
2
Avoid the use of the OptContext slots.
1
3
4
Reviewed-by: Pierrick Bouvier <pierrick.bouvier@linaro.org>
5
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
6
---
7
tcg/optimize.c | 13 ++++++++++---
8
1 file changed, 10 insertions(+), 3 deletions(-)
9
10
diff --git a/tcg/optimize.c b/tcg/optimize.c
11
index XXXXXXX..XXXXXXX 100644
12
--- a/tcg/optimize.c
13
+++ b/tcg/optimize.c
14
@@ -XXX,XX +XXX,XX @@ static bool fold_masks_zs(OptContext *ctx, TCGOp *op,
15
return true;
16
}
17
18
+static bool fold_masks_z(OptContext *ctx, TCGOp *op, uint64_t z_mask)
19
+{
20
+ return fold_masks_zs(ctx, op, z_mask, 0);
21
+}
22
+
23
static bool fold_masks(OptContext *ctx, TCGOp *op)
24
{
25
return fold_masks_zs(ctx, op, ctx->z_mask, ctx->s_mask);
26
@@ -XXX,XX +XXX,XX @@ static bool fold_count_zeros(OptContext *ctx, TCGOp *op)
27
28
static bool fold_ctpop(OptContext *ctx, TCGOp *op)
29
{
30
+ uint64_t z_mask;
31
+
32
if (fold_const1(ctx, op)) {
33
return true;
34
}
35
36
switch (ctx->type) {
37
case TCG_TYPE_I32:
38
- ctx->z_mask = 32 | 31;
39
+ z_mask = 32 | 31;
40
break;
41
case TCG_TYPE_I64:
42
- ctx->z_mask = 64 | 63;
43
+ z_mask = 64 | 63;
44
break;
45
default:
46
g_assert_not_reached();
47
}
48
- return false;
49
+ return fold_masks_z(ctx, op, z_mask);
50
}
51
52
static bool fold_deposit(OptContext *ctx, TCGOp *op)
53
--
54
2.43.0
diff view generated by jsdifflib
New patch
1
Avoid the use of the OptContext slots. Find TempOptInfo once.
2
When we fold to and, use fold_and.
1
3
4
Reviewed-by: Pierrick Bouvier <pierrick.bouvier@linaro.org>
5
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
6
---
7
tcg/optimize.c | 35 +++++++++++++++++------------------
8
1 file changed, 17 insertions(+), 18 deletions(-)
9
10
diff --git a/tcg/optimize.c b/tcg/optimize.c
11
index XXXXXXX..XXXXXXX 100644
12
--- a/tcg/optimize.c
13
+++ b/tcg/optimize.c
14
@@ -XXX,XX +XXX,XX @@ static bool fold_ctpop(OptContext *ctx, TCGOp *op)
15
16
static bool fold_deposit(OptContext *ctx, TCGOp *op)
17
{
18
+ TempOptInfo *t1 = arg_info(op->args[1]);
19
+ TempOptInfo *t2 = arg_info(op->args[2]);
20
+ int ofs = op->args[3];
21
+ int len = op->args[4];
22
TCGOpcode and_opc;
23
+ uint64_t z_mask;
24
25
- if (arg_is_const(op->args[1]) && arg_is_const(op->args[2])) {
26
- uint64_t t1 = arg_info(op->args[1])->val;
27
- uint64_t t2 = arg_info(op->args[2])->val;
28
-
29
- t1 = deposit64(t1, op->args[3], op->args[4], t2);
30
- return tcg_opt_gen_movi(ctx, op, op->args[0], t1);
31
+ if (ti_is_const(t1) && ti_is_const(t2)) {
32
+ return tcg_opt_gen_movi(ctx, op, op->args[0],
33
+ deposit64(ti_const_val(t1), ofs, len,
34
+ ti_const_val(t2)));
35
}
36
37
switch (ctx->type) {
38
@@ -XXX,XX +XXX,XX @@ static bool fold_deposit(OptContext *ctx, TCGOp *op)
39
}
40
41
/* Inserting a value into zero at offset 0. */
42
- if (arg_is_const_val(op->args[1], 0) && op->args[3] == 0) {
43
- uint64_t mask = MAKE_64BIT_MASK(0, op->args[4]);
44
+ if (ti_is_const_val(t1, 0) && ofs == 0) {
45
+ uint64_t mask = MAKE_64BIT_MASK(0, len);
46
47
op->opc = and_opc;
48
op->args[1] = op->args[2];
49
op->args[2] = arg_new_constant(ctx, mask);
50
- ctx->z_mask = mask & arg_info(op->args[1])->z_mask;
51
- return false;
52
+ return fold_and(ctx, op);
53
}
54
55
/* Inserting zero into a value. */
56
- if (arg_is_const_val(op->args[2], 0)) {
57
- uint64_t mask = deposit64(-1, op->args[3], op->args[4], 0);
58
+ if (ti_is_const_val(t2, 0)) {
59
+ uint64_t mask = deposit64(-1, ofs, len, 0);
60
61
op->opc = and_opc;
62
op->args[2] = arg_new_constant(ctx, mask);
63
- ctx->z_mask = mask & arg_info(op->args[1])->z_mask;
64
- return false;
65
+ return fold_and(ctx, op);
66
}
67
68
- ctx->z_mask = deposit64(arg_info(op->args[1])->z_mask,
69
- op->args[3], op->args[4],
70
- arg_info(op->args[2])->z_mask);
71
- return false;
72
+ z_mask = deposit64(t1->z_mask, ofs, len, t2->z_mask);
73
+ return fold_masks_z(ctx, op, z_mask);
74
}
75
76
static bool fold_divide(OptContext *ctx, TCGOp *op)
77
--
78
2.43.0
diff view generated by jsdifflib
New patch
1
The input which overlaps the sign bit of the output can
2
have its input s_mask propagated to the output s_mask.
1
3
4
Reviewed-by: Pierrick Bouvier <pierrick.bouvier@linaro.org>
5
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
6
---
7
tcg/optimize.c | 14 ++++++++++++--
8
1 file changed, 12 insertions(+), 2 deletions(-)
9
10
diff --git a/tcg/optimize.c b/tcg/optimize.c
11
index XXXXXXX..XXXXXXX 100644
12
--- a/tcg/optimize.c
13
+++ b/tcg/optimize.c
14
@@ -XXX,XX +XXX,XX @@ static bool fold_deposit(OptContext *ctx, TCGOp *op)
15
TempOptInfo *t2 = arg_info(op->args[2]);
16
int ofs = op->args[3];
17
int len = op->args[4];
18
+ int width;
19
TCGOpcode and_opc;
20
- uint64_t z_mask;
21
+ uint64_t z_mask, s_mask;
22
23
if (ti_is_const(t1) && ti_is_const(t2)) {
24
return tcg_opt_gen_movi(ctx, op, op->args[0],
25
@@ -XXX,XX +XXX,XX @@ static bool fold_deposit(OptContext *ctx, TCGOp *op)
26
switch (ctx->type) {
27
case TCG_TYPE_I32:
28
and_opc = INDEX_op_and_i32;
29
+ width = 32;
30
break;
31
case TCG_TYPE_I64:
32
and_opc = INDEX_op_and_i64;
33
+ width = 64;
34
break;
35
default:
36
g_assert_not_reached();
37
@@ -XXX,XX +XXX,XX @@ static bool fold_deposit(OptContext *ctx, TCGOp *op)
38
return fold_and(ctx, op);
39
}
40
41
+ /* The s_mask from the top portion of the deposit is still valid. */
42
+ if (ofs + len == width) {
43
+ s_mask = t2->s_mask << ofs;
44
+ } else {
45
+ s_mask = t1->s_mask & ~MAKE_64BIT_MASK(0, ofs + len);
46
+ }
47
+
48
z_mask = deposit64(t1->z_mask, ofs, len, t2->z_mask);
49
- return fold_masks_z(ctx, op, z_mask);
50
+ return fold_masks_zs(ctx, op, z_mask, s_mask);
51
}
52
53
static bool fold_divide(OptContext *ctx, TCGOp *op)
54
--
55
2.43.0
diff view generated by jsdifflib
New patch
1
Reviewed-by: Pierrick Bouvier <pierrick.bouvier@linaro.org>
2
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
3
---
4
tcg/optimize.c | 2 +-
5
1 file changed, 1 insertion(+), 1 deletion(-)
1
6
7
diff --git a/tcg/optimize.c b/tcg/optimize.c
8
index XXXXXXX..XXXXXXX 100644
9
--- a/tcg/optimize.c
10
+++ b/tcg/optimize.c
11
@@ -XXX,XX +XXX,XX @@ static bool fold_divide(OptContext *ctx, TCGOp *op)
12
fold_xi_to_x(ctx, op, 1)) {
13
return true;
14
}
15
- return false;
16
+ return finish_folding(ctx, op);
17
}
18
19
static bool fold_dup(OptContext *ctx, TCGOp *op)
20
--
21
2.43.0
diff view generated by jsdifflib
New patch
1
Reviewed-by: Pierrick Bouvier <pierrick.bouvier@linaro.org>
2
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
3
---
4
tcg/optimize.c | 4 ++--
5
1 file changed, 2 insertions(+), 2 deletions(-)
1
6
7
diff --git a/tcg/optimize.c b/tcg/optimize.c
8
index XXXXXXX..XXXXXXX 100644
9
--- a/tcg/optimize.c
10
+++ b/tcg/optimize.c
11
@@ -XXX,XX +XXX,XX @@ static bool fold_dup(OptContext *ctx, TCGOp *op)
12
t = dup_const(TCGOP_VECE(op), t);
13
return tcg_opt_gen_movi(ctx, op, op->args[0], t);
14
}
15
- return false;
16
+ return finish_folding(ctx, op);
17
}
18
19
static bool fold_dup2(OptContext *ctx, TCGOp *op)
20
@@ -XXX,XX +XXX,XX @@ static bool fold_dup2(OptContext *ctx, TCGOp *op)
21
op->opc = INDEX_op_dup_vec;
22
TCGOP_VECE(op) = MO_32;
23
}
24
- return false;
25
+ return finish_folding(ctx, op);
26
}
27
28
static bool fold_eqv(OptContext *ctx, TCGOp *op)
29
--
30
2.43.0
diff view generated by jsdifflib
New patch
1
Add fold_masks_s as a trivial wrapper around fold_masks_zs.
2
Avoid the use of the OptContext slots.
1
3
4
Reviewed-by: Pierrick Bouvier <pierrick.bouvier@linaro.org>
5
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
6
---
7
tcg/optimize.c | 13 ++++++++++---
8
1 file changed, 10 insertions(+), 3 deletions(-)
9
10
diff --git a/tcg/optimize.c b/tcg/optimize.c
11
index XXXXXXX..XXXXXXX 100644
12
--- a/tcg/optimize.c
13
+++ b/tcg/optimize.c
14
@@ -XXX,XX +XXX,XX @@ static bool fold_masks_z(OptContext *ctx, TCGOp *op, uint64_t z_mask)
15
return fold_masks_zs(ctx, op, z_mask, 0);
16
}
17
18
+static bool fold_masks_s(OptContext *ctx, TCGOp *op, uint64_t s_mask)
19
+{
20
+ return fold_masks_zs(ctx, op, -1, s_mask);
21
+}
22
+
23
static bool fold_masks(OptContext *ctx, TCGOp *op)
24
{
25
return fold_masks_zs(ctx, op, ctx->z_mask, ctx->s_mask);
26
@@ -XXX,XX +XXX,XX @@ static bool fold_dup2(OptContext *ctx, TCGOp *op)
27
28
static bool fold_eqv(OptContext *ctx, TCGOp *op)
29
{
30
+ uint64_t s_mask;
31
+
32
if (fold_const2_commutative(ctx, op) ||
33
fold_xi_to_x(ctx, op, -1) ||
34
fold_xi_to_not(ctx, op, 0)) {
35
return true;
36
}
37
38
- ctx->s_mask = arg_info(op->args[1])->s_mask
39
- & arg_info(op->args[2])->s_mask;
40
- return false;
41
+ s_mask = arg_info(op->args[1])->s_mask
42
+ & arg_info(op->args[2])->s_mask;
43
+ return fold_masks_s(ctx, op, s_mask);
44
}
45
46
static bool fold_extract(OptContext *ctx, TCGOp *op)
47
--
48
2.43.0
diff view generated by jsdifflib
New patch
1
Avoid the use of the OptContext slots. Find TempOptInfo once.
1
2
3
Reviewed-by: Pierrick Bouvier <pierrick.bouvier@linaro.org>
4
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
5
---
6
tcg/optimize.c | 15 ++++++---------
7
1 file changed, 6 insertions(+), 9 deletions(-)
8
9
diff --git a/tcg/optimize.c b/tcg/optimize.c
10
index XXXXXXX..XXXXXXX 100644
11
--- a/tcg/optimize.c
12
+++ b/tcg/optimize.c
13
@@ -XXX,XX +XXX,XX @@ static bool fold_eqv(OptContext *ctx, TCGOp *op)
14
static bool fold_extract(OptContext *ctx, TCGOp *op)
15
{
16
uint64_t z_mask_old, z_mask;
17
+ TempOptInfo *t1 = arg_info(op->args[1]);
18
int pos = op->args[2];
19
int len = op->args[3];
20
21
- if (arg_is_const(op->args[1])) {
22
- uint64_t t;
23
-
24
- t = arg_info(op->args[1])->val;
25
- t = extract64(t, pos, len);
26
- return tcg_opt_gen_movi(ctx, op, op->args[0], t);
27
+ if (ti_is_const(t1)) {
28
+ return tcg_opt_gen_movi(ctx, op, op->args[0],
29
+ extract64(ti_const_val(t1), pos, len));
30
}
31
32
- z_mask_old = arg_info(op->args[1])->z_mask;
33
+ z_mask_old = t1->z_mask;
34
z_mask = extract64(z_mask_old, pos, len);
35
if (pos == 0 && fold_affected_mask(ctx, op, z_mask_old ^ z_mask)) {
36
return true;
37
}
38
- ctx->z_mask = z_mask;
39
40
- return fold_masks(ctx, op);
41
+ return fold_masks_z(ctx, op, z_mask);
42
}
43
44
static bool fold_extract2(OptContext *ctx, TCGOp *op)
45
--
46
2.43.0
diff view generated by jsdifflib
New patch
1
Reviewed-by: Pierrick Bouvier <pierrick.bouvier@linaro.org>
2
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
3
---
4
tcg/optimize.c | 2 +-
5
1 file changed, 1 insertion(+), 1 deletion(-)
1
6
7
diff --git a/tcg/optimize.c b/tcg/optimize.c
8
index XXXXXXX..XXXXXXX 100644
9
--- a/tcg/optimize.c
10
+++ b/tcg/optimize.c
11
@@ -XXX,XX +XXX,XX @@ static bool fold_extract2(OptContext *ctx, TCGOp *op)
12
}
13
return tcg_opt_gen_movi(ctx, op, op->args[0], v1 | v2);
14
}
15
- return false;
16
+ return finish_folding(ctx, op);
17
}
18
19
static bool fold_exts(OptContext *ctx, TCGOp *op)
20
--
21
2.43.0
diff view generated by jsdifflib
New patch
1
Avoid the use of the OptContext slots. Find TempOptInfo once.
2
Explicitly sign-extend z_mask instead of doing that manually.
1
3
4
Reviewed-by: Pierrick Bouvier <pierrick.bouvier@linaro.org>
5
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
6
---
7
tcg/optimize.c | 29 ++++++++++++-----------------
8
1 file changed, 12 insertions(+), 17 deletions(-)
9
10
diff --git a/tcg/optimize.c b/tcg/optimize.c
11
index XXXXXXX..XXXXXXX 100644
12
--- a/tcg/optimize.c
13
+++ b/tcg/optimize.c
14
@@ -XXX,XX +XXX,XX @@ static bool fold_extract2(OptContext *ctx, TCGOp *op)
15
16
static bool fold_exts(OptContext *ctx, TCGOp *op)
17
{
18
- uint64_t s_mask_old, s_mask, z_mask, sign;
19
+ uint64_t s_mask_old, s_mask, z_mask;
20
bool type_change = false;
21
+ TempOptInfo *t1;
22
23
if (fold_const1(ctx, op)) {
24
return true;
25
}
26
27
- z_mask = arg_info(op->args[1])->z_mask;
28
- s_mask = arg_info(op->args[1])->s_mask;
29
+ t1 = arg_info(op->args[1]);
30
+ z_mask = t1->z_mask;
31
+ s_mask = t1->s_mask;
32
s_mask_old = s_mask;
33
34
switch (op->opc) {
35
CASE_OP_32_64(ext8s):
36
- sign = INT8_MIN;
37
- z_mask = (uint8_t)z_mask;
38
+ s_mask |= INT8_MIN;
39
+ z_mask = (int8_t)z_mask;
40
break;
41
CASE_OP_32_64(ext16s):
42
- sign = INT16_MIN;
43
- z_mask = (uint16_t)z_mask;
44
+ s_mask |= INT16_MIN;
45
+ z_mask = (int16_t)z_mask;
46
break;
47
case INDEX_op_ext_i32_i64:
48
type_change = true;
49
QEMU_FALLTHROUGH;
50
case INDEX_op_ext32s_i64:
51
- sign = INT32_MIN;
52
- z_mask = (uint32_t)z_mask;
53
+ s_mask |= INT32_MIN;
54
+ z_mask = (int32_t)z_mask;
55
break;
56
default:
57
g_assert_not_reached();
58
}
59
60
- if (z_mask & sign) {
61
- z_mask |= sign;
62
- }
63
- s_mask |= sign << 1;
64
-
65
- ctx->z_mask = z_mask;
66
- ctx->s_mask = s_mask;
67
if (0 && !type_change && fold_affected_mask(ctx, op, s_mask & ~s_mask_old)) {
68
return true;
69
}
70
71
- return fold_masks(ctx, op);
72
+ return fold_masks_zs(ctx, op, z_mask, s_mask);
73
}
74
75
static bool fold_extu(OptContext *ctx, TCGOp *op)
76
--
77
2.43.0
diff view generated by jsdifflib
New patch
1
Avoid the use of the OptContext slots.
1
2
3
Reviewed-by: Pierrick Bouvier <pierrick.bouvier@linaro.org>
4
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
5
---
6
tcg/optimize.c | 4 ++--
7
1 file changed, 2 insertions(+), 2 deletions(-)
8
9
diff --git a/tcg/optimize.c b/tcg/optimize.c
10
index XXXXXXX..XXXXXXX 100644
11
--- a/tcg/optimize.c
12
+++ b/tcg/optimize.c
13
@@ -XXX,XX +XXX,XX @@ static bool fold_extu(OptContext *ctx, TCGOp *op)
14
g_assert_not_reached();
15
}
16
17
- ctx->z_mask = z_mask;
18
if (!type_change && fold_affected_mask(ctx, op, z_mask_old ^ z_mask)) {
19
return true;
20
}
21
- return fold_masks(ctx, op);
22
+
23
+ return fold_masks_z(ctx, op, z_mask);
24
}
25
26
static bool fold_mb(OptContext *ctx, TCGOp *op)
27
--
28
2.43.0
diff view generated by jsdifflib
1
The generated functions aside from *_real are unused.
1
Avoid the use of the OptContext slots. Find TempOptInfo once.
2
The *_real functions have a couple of users in mem_helper.c;
3
use *_mmuidx_ra instead, with MMU_REAL_IDX.
4
2
5
Tested-by: Philippe Mathieu-Daudé <philmd@redhat.com>
3
Reviewed-by: Pierrick Bouvier <pierrick.bouvier@linaro.org>
6
Reviewed-by: David Hildenbrand <david@redhat.com>
7
Reviewed-by: Alex Bennée <alex.bennee@linaro.org>
8
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
4
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
9
---
5
---
10
v2: Use *_mmuidx_ra directly, without intermediate macros.
6
tcg/optimize.c | 19 +++++++++++--------
11
---
7
1 file changed, 11 insertions(+), 8 deletions(-)
12
target/s390x/cpu.h | 5 -----
13
target/s390x/mem_helper.c | 10 +++++-----
14
2 files changed, 5 insertions(+), 10 deletions(-)
15
8
16
diff --git a/target/s390x/cpu.h b/target/s390x/cpu.h
9
diff --git a/tcg/optimize.c b/tcg/optimize.c
17
index XXXXXXX..XXXXXXX 100644
10
index XXXXXXX..XXXXXXX 100644
18
--- a/target/s390x/cpu.h
11
--- a/tcg/optimize.c
19
+++ b/target/s390x/cpu.h
12
+++ b/tcg/optimize.c
20
@@ -XXX,XX +XXX,XX @@
13
@@ -XXX,XX +XXX,XX @@ static bool fold_mov(OptContext *ctx, TCGOp *op)
21
14
22
#define TARGET_INSN_START_EXTRA_WORDS 2
15
static bool fold_movcond(OptContext *ctx, TCGOp *op)
23
16
{
24
-#define MMU_MODE0_SUFFIX _primary
17
+ uint64_t z_mask, s_mask;
25
-#define MMU_MODE1_SUFFIX _secondary
18
+ TempOptInfo *tt, *ft;
26
-#define MMU_MODE2_SUFFIX _home
19
int i;
27
-#define MMU_MODE3_SUFFIX _real
20
28
-
21
/* If true and false values are the same, eliminate the cmp. */
29
#define MMU_USER_IDX 0
22
@@ -XXX,XX +XXX,XX @@ static bool fold_movcond(OptContext *ctx, TCGOp *op)
30
23
return tcg_opt_gen_mov(ctx, op, op->args[0], op->args[4 - i]);
31
#define S390_MAX_CPUS 248
32
diff --git a/target/s390x/mem_helper.c b/target/s390x/mem_helper.c
33
index XXXXXXX..XXXXXXX 100644
34
--- a/target/s390x/mem_helper.c
35
+++ b/target/s390x/mem_helper.c
36
@@ -XXX,XX +XXX,XX @@ uint32_t HELPER(testblock)(CPUS390XState *env, uint64_t real_addr)
37
real_addr = wrap_address(env, real_addr) & TARGET_PAGE_MASK;
38
39
for (i = 0; i < TARGET_PAGE_SIZE; i += 8) {
40
- cpu_stq_real_ra(env, real_addr + i, 0, ra);
41
+ cpu_stq_mmuidx_ra(env, real_addr + i, 0, MMU_REAL_IDX, ra);
42
}
24
}
43
25
44
return 0;
26
- ctx->z_mask = arg_info(op->args[3])->z_mask
45
@@ -XXX,XX +XXX,XX @@ void HELPER(idte)(CPUS390XState *env, uint64_t r1, uint64_t r2, uint32_t m4)
27
- | arg_info(op->args[4])->z_mask;
46
for (i = 0; i < entries; i++) {
28
- ctx->s_mask = arg_info(op->args[3])->s_mask
47
/* addresses are not wrapped in 24/31bit mode but table index is */
29
- & arg_info(op->args[4])->s_mask;
48
raddr = table + ((index + i) & 0x7ff) * sizeof(entry);
30
+ tt = arg_info(op->args[3]);
49
- entry = cpu_ldq_real_ra(env, raddr, ra);
31
+ ft = arg_info(op->args[4]);
50
+ entry = cpu_ldq_mmuidx_ra(env, raddr, MMU_REAL_IDX, ra);
32
+ z_mask = tt->z_mask | ft->z_mask;
51
if (!(entry & REGION_ENTRY_I)) {
33
+ s_mask = tt->s_mask & ft->s_mask;
52
/* we are allowed to not store if already invalid */
34
53
entry |= REGION_ENTRY_I;
35
- if (arg_is_const(op->args[3]) && arg_is_const(op->args[4])) {
54
- cpu_stq_real_ra(env, raddr, entry, ra);
36
- uint64_t tv = arg_info(op->args[3])->val;
55
+ cpu_stq_mmuidx_ra(env, raddr, entry, MMU_REAL_IDX, ra);
37
- uint64_t fv = arg_info(op->args[4])->val;
38
+ if (ti_is_const(tt) && ti_is_const(ft)) {
39
+ uint64_t tv = ti_const_val(tt);
40
+ uint64_t fv = ti_const_val(ft);
41
TCGOpcode opc, negopc = 0;
42
TCGCond cond = op->args[5];
43
44
@@ -XXX,XX +XXX,XX @@ static bool fold_movcond(OptContext *ctx, TCGOp *op)
56
}
45
}
57
}
46
}
58
}
47
}
59
@@ -XXX,XX +XXX,XX @@ void HELPER(ipte)(CPUS390XState *env, uint64_t pto, uint64_t vaddr,
48
- return false;
60
pte_addr += VADDR_PAGE_TX(vaddr) * 8;
49
+
61
50
+ return fold_masks_zs(ctx, op, z_mask, s_mask);
62
/* Mark the page table entry as invalid */
51
}
63
- pte = cpu_ldq_real_ra(env, pte_addr, ra);
52
64
+ pte = cpu_ldq_mmuidx_ra(env, pte_addr, MMU_REAL_IDX, ra);
53
static bool fold_mul(OptContext *ctx, TCGOp *op)
65
pte |= PAGE_ENTRY_I;
66
- cpu_stq_real_ra(env, pte_addr, pte, ra);
67
+ cpu_stq_mmuidx_ra(env, pte_addr, pte, MMU_REAL_IDX, ra);
68
69
/* XXX we exploit the fact that Linux passes the exact virtual
70
address here - it's not obliged to! */
71
--
54
--
72
2.20.1
55
2.43.0
73
74
diff view generated by jsdifflib
New patch
1
Reviewed-by: Pierrick Bouvier <pierrick.bouvier@linaro.org>
2
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
3
---
4
tcg/optimize.c | 6 +++---
5
1 file changed, 3 insertions(+), 3 deletions(-)
1
6
7
diff --git a/tcg/optimize.c b/tcg/optimize.c
8
index XXXXXXX..XXXXXXX 100644
9
--- a/tcg/optimize.c
10
+++ b/tcg/optimize.c
11
@@ -XXX,XX +XXX,XX @@ static bool fold_mul(OptContext *ctx, TCGOp *op)
12
fold_xi_to_x(ctx, op, 1)) {
13
return true;
14
}
15
- return false;
16
+ return finish_folding(ctx, op);
17
}
18
19
static bool fold_mul_highpart(OptContext *ctx, TCGOp *op)
20
@@ -XXX,XX +XXX,XX @@ static bool fold_mul_highpart(OptContext *ctx, TCGOp *op)
21
fold_xi_to_i(ctx, op, 0)) {
22
return true;
23
}
24
- return false;
25
+ return finish_folding(ctx, op);
26
}
27
28
static bool fold_multiply2(OptContext *ctx, TCGOp *op)
29
@@ -XXX,XX +XXX,XX @@ static bool fold_multiply2(OptContext *ctx, TCGOp *op)
30
tcg_opt_gen_movi(ctx, op2, rh, h);
31
return true;
32
}
33
- return false;
34
+ return finish_folding(ctx, op);
35
}
36
37
static bool fold_nand(OptContext *ctx, TCGOp *op)
38
--
39
2.43.0
diff view generated by jsdifflib
New patch
1
Avoid the use of the OptContext slots.
1
2
3
Reviewed-by: Pierrick Bouvier <pierrick.bouvier@linaro.org>
4
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
5
---
6
tcg/optimize.c | 8 +++++---
7
1 file changed, 5 insertions(+), 3 deletions(-)
8
9
diff --git a/tcg/optimize.c b/tcg/optimize.c
10
index XXXXXXX..XXXXXXX 100644
11
--- a/tcg/optimize.c
12
+++ b/tcg/optimize.c
13
@@ -XXX,XX +XXX,XX @@ static bool fold_multiply2(OptContext *ctx, TCGOp *op)
14
15
static bool fold_nand(OptContext *ctx, TCGOp *op)
16
{
17
+ uint64_t s_mask;
18
+
19
if (fold_const2_commutative(ctx, op) ||
20
fold_xi_to_not(ctx, op, -1)) {
21
return true;
22
}
23
24
- ctx->s_mask = arg_info(op->args[1])->s_mask
25
- & arg_info(op->args[2])->s_mask;
26
- return false;
27
+ s_mask = arg_info(op->args[1])->s_mask
28
+ & arg_info(op->args[2])->s_mask;
29
+ return fold_masks_s(ctx, op, s_mask);
30
}
31
32
static bool fold_neg_no_const(OptContext *ctx, TCGOp *op)
33
--
34
2.43.0
diff view generated by jsdifflib
New patch
1
Avoid the use of the OptContext slots.
1
2
3
Reviewed-by: Pierrick Bouvier <pierrick.bouvier@linaro.org>
4
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
5
---
6
tcg/optimize.c | 9 ++-------
7
1 file changed, 2 insertions(+), 7 deletions(-)
8
9
diff --git a/tcg/optimize.c b/tcg/optimize.c
10
index XXXXXXX..XXXXXXX 100644
11
--- a/tcg/optimize.c
12
+++ b/tcg/optimize.c
13
@@ -XXX,XX +XXX,XX @@ static bool fold_neg_no_const(OptContext *ctx, TCGOp *op)
14
{
15
/* Set to 1 all bits to the left of the rightmost. */
16
uint64_t z_mask = arg_info(op->args[1])->z_mask;
17
- ctx->z_mask = -(z_mask & -z_mask);
18
+ z_mask = -(z_mask & -z_mask);
19
20
- /*
21
- * Because of fold_sub_to_neg, we want to always return true,
22
- * via finish_folding.
23
- */
24
- finish_folding(ctx, op);
25
- return true;
26
+ return fold_masks_z(ctx, op, z_mask);
27
}
28
29
static bool fold_neg(OptContext *ctx, TCGOp *op)
30
--
31
2.43.0
diff view generated by jsdifflib
New patch
1
Avoid the use of the OptContext slots.
1
2
3
Reviewed-by: Pierrick Bouvier <pierrick.bouvier@linaro.org>
4
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
5
---
6
tcg/optimize.c | 8 +++++---
7
1 file changed, 5 insertions(+), 3 deletions(-)
8
9
diff --git a/tcg/optimize.c b/tcg/optimize.c
10
index XXXXXXX..XXXXXXX 100644
11
--- a/tcg/optimize.c
12
+++ b/tcg/optimize.c
13
@@ -XXX,XX +XXX,XX @@ static bool fold_neg(OptContext *ctx, TCGOp *op)
14
15
static bool fold_nor(OptContext *ctx, TCGOp *op)
16
{
17
+ uint64_t s_mask;
18
+
19
if (fold_const2_commutative(ctx, op) ||
20
fold_xi_to_not(ctx, op, 0)) {
21
return true;
22
}
23
24
- ctx->s_mask = arg_info(op->args[1])->s_mask
25
- & arg_info(op->args[2])->s_mask;
26
- return false;
27
+ s_mask = arg_info(op->args[1])->s_mask
28
+ & arg_info(op->args[2])->s_mask;
29
+ return fold_masks_s(ctx, op, s_mask);
30
}
31
32
static bool fold_not(OptContext *ctx, TCGOp *op)
33
--
34
2.43.0
diff view generated by jsdifflib
New patch
1
Avoid the use of the OptContext slots.
1
2
3
Reviewed-by: Pierrick Bouvier <pierrick.bouvier@linaro.org>
4
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
5
---
6
tcg/optimize.c | 7 +------
7
1 file changed, 1 insertion(+), 6 deletions(-)
8
9
diff --git a/tcg/optimize.c b/tcg/optimize.c
10
index XXXXXXX..XXXXXXX 100644
11
--- a/tcg/optimize.c
12
+++ b/tcg/optimize.c
13
@@ -XXX,XX +XXX,XX @@ static bool fold_not(OptContext *ctx, TCGOp *op)
14
if (fold_const1(ctx, op)) {
15
return true;
16
}
17
-
18
- ctx->s_mask = arg_info(op->args[1])->s_mask;
19
-
20
- /* Because of fold_to_not, we want to always return true, via finish. */
21
- finish_folding(ctx, op);
22
- return true;
23
+ return fold_masks_s(ctx, op, arg_info(op->args[1])->s_mask);
24
}
25
26
static bool fold_or(OptContext *ctx, TCGOp *op)
27
--
28
2.43.0
diff view generated by jsdifflib
New patch
1
Avoid the use of the OptContext slots. Find TempOptInfo once.
1
2
3
Reviewed-by: Pierrick Bouvier <pierrick.bouvier@linaro.org>
4
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
5
---
6
tcg/optimize.c | 13 ++++++++-----
7
1 file changed, 8 insertions(+), 5 deletions(-)
8
9
diff --git a/tcg/optimize.c b/tcg/optimize.c
10
index XXXXXXX..XXXXXXX 100644
11
--- a/tcg/optimize.c
12
+++ b/tcg/optimize.c
13
@@ -XXX,XX +XXX,XX @@ static bool fold_not(OptContext *ctx, TCGOp *op)
14
15
static bool fold_or(OptContext *ctx, TCGOp *op)
16
{
17
+ uint64_t z_mask, s_mask;
18
+ TempOptInfo *t1, *t2;
19
+
20
if (fold_const2_commutative(ctx, op) ||
21
fold_xi_to_x(ctx, op, 0) ||
22
fold_xx_to_x(ctx, op)) {
23
return true;
24
}
25
26
- ctx->z_mask = arg_info(op->args[1])->z_mask
27
- | arg_info(op->args[2])->z_mask;
28
- ctx->s_mask = arg_info(op->args[1])->s_mask
29
- & arg_info(op->args[2])->s_mask;
30
- return fold_masks(ctx, op);
31
+ t1 = arg_info(op->args[1]);
32
+ t2 = arg_info(op->args[2]);
33
+ z_mask = t1->z_mask | t2->z_mask;
34
+ s_mask = t1->s_mask & t2->s_mask;
35
+ return fold_masks_zs(ctx, op, z_mask, s_mask);
36
}
37
38
static bool fold_orc(OptContext *ctx, TCGOp *op)
39
--
40
2.43.0
diff view generated by jsdifflib
New patch
1
Avoid the use of the OptContext slots.
1
2
3
Reviewed-by: Pierrick Bouvier <pierrick.bouvier@linaro.org>
4
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
5
---
6
tcg/optimize.c | 8 +++++---
7
1 file changed, 5 insertions(+), 3 deletions(-)
8
9
diff --git a/tcg/optimize.c b/tcg/optimize.c
10
index XXXXXXX..XXXXXXX 100644
11
--- a/tcg/optimize.c
12
+++ b/tcg/optimize.c
13
@@ -XXX,XX +XXX,XX @@ static bool fold_or(OptContext *ctx, TCGOp *op)
14
15
static bool fold_orc(OptContext *ctx, TCGOp *op)
16
{
17
+ uint64_t s_mask;
18
+
19
if (fold_const2(ctx, op) ||
20
fold_xx_to_i(ctx, op, -1) ||
21
fold_xi_to_x(ctx, op, -1) ||
22
@@ -XXX,XX +XXX,XX @@ static bool fold_orc(OptContext *ctx, TCGOp *op)
23
return true;
24
}
25
26
- ctx->s_mask = arg_info(op->args[1])->s_mask
27
- & arg_info(op->args[2])->s_mask;
28
- return false;
29
+ s_mask = arg_info(op->args[1])->s_mask
30
+ & arg_info(op->args[2])->s_mask;
31
+ return fold_masks_s(ctx, op, s_mask);
32
}
33
34
static bool fold_qemu_ld(OptContext *ctx, TCGOp *op)
35
--
36
2.43.0
diff view generated by jsdifflib
1
The separate suffixed functions were used to construct
1
Avoid the use of the OptContext slots.
2
some do_##insn function switched on mmu_idx. The interface
3
is exactly identical to the *_mmuidx_ra functions. Replace
4
them directly and remove the constructions.
5
2
6
Cc: Aurelien Jarno <aurelien@aurel32.net>
3
Be careful not to call fold_masks_zs when the memory operation
7
Cc: Aleksandar Rikalo <aleksandar.rikalo@rt-rk.com>
4
is wide enough to require multiple outputs, so split into two
8
Tested-by: Philippe Mathieu-Daudé <philmd@redhat.com>
5
functions: fold_qemu_ld_1reg and fold_qemu_ld_2reg.
9
Reviewed-by: Aleksandar Markovic <amarkovic@wavecomp.com>
6
10
Reviewed-by: Alex Bennée <alex.bennee@linaro.org>
7
Reviewed-by: Pierrick Bouvier <pierrick.bouvier@linaro.org>
11
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
8
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
12
---
9
---
13
target/mips/cpu.h | 4 -
10
tcg/optimize.c | 26 +++++++++++++++++++++-----
14
target/mips/op_helper.c | 182 +++++++++++++---------------------------
11
1 file changed, 21 insertions(+), 5 deletions(-)
15
2 files changed, 60 insertions(+), 126 deletions(-)
16
12
17
diff --git a/target/mips/cpu.h b/target/mips/cpu.h
13
diff --git a/tcg/optimize.c b/tcg/optimize.c
18
index XXXXXXX..XXXXXXX 100644
14
index XXXXXXX..XXXXXXX 100644
19
--- a/target/mips/cpu.h
15
--- a/tcg/optimize.c
20
+++ b/target/mips/cpu.h
16
+++ b/tcg/optimize.c
21
@@ -XXX,XX +XXX,XX @@ extern uint32_t cpu_rddsp(uint32_t mask_num, CPUMIPSState *env);
17
@@ -XXX,XX +XXX,XX @@ static bool fold_orc(OptContext *ctx, TCGOp *op)
22
* MMU modes definitions. We carefully match the indices with our
18
return fold_masks_s(ctx, op, s_mask);
23
* hflags layout.
24
*/
25
-#define MMU_MODE0_SUFFIX _kernel
26
-#define MMU_MODE1_SUFFIX _super
27
-#define MMU_MODE2_SUFFIX _user
28
-#define MMU_MODE3_SUFFIX _error
29
#define MMU_USER_IDX 2
30
31
static inline int hflags_mmu_index(uint32_t hflags)
32
diff --git a/target/mips/op_helper.c b/target/mips/op_helper.c
33
index XXXXXXX..XXXXXXX 100644
34
--- a/target/mips/op_helper.c
35
+++ b/target/mips/op_helper.c
36
@@ -XXX,XX +XXX,XX @@ static void raise_exception(CPUMIPSState *env, uint32_t exception)
37
do_raise_exception(env, exception, 0);
38
}
19
}
39
20
40
-#if defined(CONFIG_USER_ONLY)
21
-static bool fold_qemu_ld(OptContext *ctx, TCGOp *op)
41
-#define HELPER_LD(name, insn, type) \
22
+static bool fold_qemu_ld_1reg(OptContext *ctx, TCGOp *op)
42
-static inline type do_##name(CPUMIPSState *env, target_ulong addr, \
43
- int mem_idx, uintptr_t retaddr) \
44
-{ \
45
- return (type) cpu_##insn##_data_ra(env, addr, retaddr); \
46
-}
47
-#else
48
-#define HELPER_LD(name, insn, type) \
49
-static inline type do_##name(CPUMIPSState *env, target_ulong addr, \
50
- int mem_idx, uintptr_t retaddr) \
51
-{ \
52
- switch (mem_idx) { \
53
- case 0: return (type) cpu_##insn##_kernel_ra(env, addr, retaddr); \
54
- case 1: return (type) cpu_##insn##_super_ra(env, addr, retaddr); \
55
- default: \
56
- case 2: return (type) cpu_##insn##_user_ra(env, addr, retaddr); \
57
- case 3: return (type) cpu_##insn##_error_ra(env, addr, retaddr); \
58
- } \
59
-}
60
-#endif
61
-HELPER_LD(lw, ldl, int32_t)
62
-#if defined(TARGET_MIPS64)
63
-HELPER_LD(ld, ldq, int64_t)
64
-#endif
65
-#undef HELPER_LD
66
-
67
-#if defined(CONFIG_USER_ONLY)
68
-#define HELPER_ST(name, insn, type) \
69
-static inline void do_##name(CPUMIPSState *env, target_ulong addr, \
70
- type val, int mem_idx, uintptr_t retaddr) \
71
-{ \
72
- cpu_##insn##_data_ra(env, addr, val, retaddr); \
73
-}
74
-#else
75
-#define HELPER_ST(name, insn, type) \
76
-static inline void do_##name(CPUMIPSState *env, target_ulong addr, \
77
- type val, int mem_idx, uintptr_t retaddr) \
78
-{ \
79
- switch (mem_idx) { \
80
- case 0: \
81
- cpu_##insn##_kernel_ra(env, addr, val, retaddr); \
82
- break; \
83
- case 1: \
84
- cpu_##insn##_super_ra(env, addr, val, retaddr); \
85
- break; \
86
- default: \
87
- case 2: \
88
- cpu_##insn##_user_ra(env, addr, val, retaddr); \
89
- break; \
90
- case 3: \
91
- cpu_##insn##_error_ra(env, addr, val, retaddr); \
92
- break; \
93
- } \
94
-}
95
-#endif
96
-HELPER_ST(sb, stb, uint8_t)
97
-HELPER_ST(sw, stl, uint32_t)
98
-#if defined(TARGET_MIPS64)
99
-HELPER_ST(sd, stq, uint64_t)
100
-#endif
101
-#undef HELPER_ST
102
-
103
/* 64 bits arithmetic for 32 bits hosts */
104
static inline uint64_t get_HILO(CPUMIPSState *env)
105
{
23
{
106
@@ -XXX,XX +XXX,XX @@ target_ulong helper_##name(CPUMIPSState *env, target_ulong arg, int mem_idx) \
24
const TCGOpDef *def = &tcg_op_defs[op->opc];
107
} \
25
MemOpIdx oi = op->args[def->nb_oargs + def->nb_iargs];
108
env->CP0_LLAddr = do_translate_address(env, arg, 0, GETPC()); \
26
MemOp mop = get_memop(oi);
109
env->lladdr = arg; \
27
int width = 8 * memop_size(mop);
110
- env->llval = do_##insn(env, arg, mem_idx, GETPC()); \
28
+ uint64_t z_mask = -1, s_mask = 0;
111
+ env->llval = cpu_##insn##_mmuidx_ra(env, arg, mem_idx, GETPC()); \
29
112
return env->llval; \
30
if (width < 64) {
113
}
31
if (mop & MO_SIGN) {
114
-HELPER_LD_ATOMIC(ll, lw, 0x3)
32
- ctx->s_mask = MAKE_64BIT_MASK(width, 64 - width);
115
+HELPER_LD_ATOMIC(ll, ldl, 0x3)
33
+ s_mask = MAKE_64BIT_MASK(width - 1, 64 - (width - 1));
116
#ifdef TARGET_MIPS64
34
} else {
117
-HELPER_LD_ATOMIC(lld, ld, 0x7)
35
- ctx->z_mask = MAKE_64BIT_MASK(0, width);
118
+HELPER_LD_ATOMIC(lld, ldq, 0x7)
36
+ z_mask = MAKE_64BIT_MASK(0, width);
119
#endif
120
#undef HELPER_LD_ATOMIC
121
#endif
122
@@ -XXX,XX +XXX,XX @@ HELPER_LD_ATOMIC(lld, ld, 0x7)
123
void helper_swl(CPUMIPSState *env, target_ulong arg1, target_ulong arg2,
124
int mem_idx)
125
{
126
- do_sb(env, arg2, (uint8_t)(arg1 >> 24), mem_idx, GETPC());
127
+ cpu_stb_mmuidx_ra(env, arg2, (uint8_t)(arg1 >> 24), mem_idx, GETPC());
128
129
if (GET_LMASK(arg2) <= 2) {
130
- do_sb(env, GET_OFFSET(arg2, 1), (uint8_t)(arg1 >> 16), mem_idx,
131
- GETPC());
132
+ cpu_stb_mmuidx_ra(env, GET_OFFSET(arg2, 1), (uint8_t)(arg1 >> 16),
133
+ mem_idx, GETPC());
134
}
135
136
if (GET_LMASK(arg2) <= 1) {
137
- do_sb(env, GET_OFFSET(arg2, 2), (uint8_t)(arg1 >> 8), mem_idx,
138
- GETPC());
139
+ cpu_stb_mmuidx_ra(env, GET_OFFSET(arg2, 2), (uint8_t)(arg1 >> 8),
140
+ mem_idx, GETPC());
141
}
142
143
if (GET_LMASK(arg2) == 0) {
144
- do_sb(env, GET_OFFSET(arg2, 3), (uint8_t)arg1, mem_idx,
145
- GETPC());
146
+ cpu_stb_mmuidx_ra(env, GET_OFFSET(arg2, 3), (uint8_t)arg1,
147
+ mem_idx, GETPC());
148
}
149
}
150
151
void helper_swr(CPUMIPSState *env, target_ulong arg1, target_ulong arg2,
152
int mem_idx)
153
{
154
- do_sb(env, arg2, (uint8_t)arg1, mem_idx, GETPC());
155
+ cpu_stb_mmuidx_ra(env, arg2, (uint8_t)arg1, mem_idx, GETPC());
156
157
if (GET_LMASK(arg2) >= 1) {
158
- do_sb(env, GET_OFFSET(arg2, -1), (uint8_t)(arg1 >> 8), mem_idx,
159
- GETPC());
160
+ cpu_stb_mmuidx_ra(env, GET_OFFSET(arg2, -1), (uint8_t)(arg1 >> 8),
161
+ mem_idx, GETPC());
162
}
163
164
if (GET_LMASK(arg2) >= 2) {
165
- do_sb(env, GET_OFFSET(arg2, -2), (uint8_t)(arg1 >> 16), mem_idx,
166
- GETPC());
167
+ cpu_stb_mmuidx_ra(env, GET_OFFSET(arg2, -2), (uint8_t)(arg1 >> 16),
168
+ mem_idx, GETPC());
169
}
170
171
if (GET_LMASK(arg2) == 3) {
172
- do_sb(env, GET_OFFSET(arg2, -3), (uint8_t)(arg1 >> 24), mem_idx,
173
- GETPC());
174
+ cpu_stb_mmuidx_ra(env, GET_OFFSET(arg2, -3), (uint8_t)(arg1 >> 24),
175
+ mem_idx, GETPC());
176
}
177
}
178
179
@@ -XXX,XX +XXX,XX @@ void helper_swr(CPUMIPSState *env, target_ulong arg1, target_ulong arg2,
180
void helper_sdl(CPUMIPSState *env, target_ulong arg1, target_ulong arg2,
181
int mem_idx)
182
{
183
- do_sb(env, arg2, (uint8_t)(arg1 >> 56), mem_idx, GETPC());
184
+ cpu_stb_mmuidx_ra(env, arg2, (uint8_t)(arg1 >> 56), mem_idx, GETPC());
185
186
if (GET_LMASK64(arg2) <= 6) {
187
- do_sb(env, GET_OFFSET(arg2, 1), (uint8_t)(arg1 >> 48), mem_idx,
188
- GETPC());
189
+ cpu_stb_mmuidx_ra(env, GET_OFFSET(arg2, 1), (uint8_t)(arg1 >> 48),
190
+ mem_idx, GETPC());
191
}
192
193
if (GET_LMASK64(arg2) <= 5) {
194
- do_sb(env, GET_OFFSET(arg2, 2), (uint8_t)(arg1 >> 40), mem_idx,
195
- GETPC());
196
+ cpu_stb_mmuidx_ra(env, GET_OFFSET(arg2, 2), (uint8_t)(arg1 >> 40),
197
+ mem_idx, GETPC());
198
}
199
200
if (GET_LMASK64(arg2) <= 4) {
201
- do_sb(env, GET_OFFSET(arg2, 3), (uint8_t)(arg1 >> 32), mem_idx,
202
- GETPC());
203
+ cpu_stb_mmuidx_ra(env, GET_OFFSET(arg2, 3), (uint8_t)(arg1 >> 32),
204
+ mem_idx, GETPC());
205
}
206
207
if (GET_LMASK64(arg2) <= 3) {
208
- do_sb(env, GET_OFFSET(arg2, 4), (uint8_t)(arg1 >> 24), mem_idx,
209
- GETPC());
210
+ cpu_stb_mmuidx_ra(env, GET_OFFSET(arg2, 4), (uint8_t)(arg1 >> 24),
211
+ mem_idx, GETPC());
212
}
213
214
if (GET_LMASK64(arg2) <= 2) {
215
- do_sb(env, GET_OFFSET(arg2, 5), (uint8_t)(arg1 >> 16), mem_idx,
216
- GETPC());
217
+ cpu_stb_mmuidx_ra(env, GET_OFFSET(arg2, 5), (uint8_t)(arg1 >> 16),
218
+ mem_idx, GETPC());
219
}
220
221
if (GET_LMASK64(arg2) <= 1) {
222
- do_sb(env, GET_OFFSET(arg2, 6), (uint8_t)(arg1 >> 8), mem_idx,
223
- GETPC());
224
+ cpu_stb_mmuidx_ra(env, GET_OFFSET(arg2, 6), (uint8_t)(arg1 >> 8),
225
+ mem_idx, GETPC());
226
}
227
228
if (GET_LMASK64(arg2) <= 0) {
229
- do_sb(env, GET_OFFSET(arg2, 7), (uint8_t)arg1, mem_idx,
230
- GETPC());
231
+ cpu_stb_mmuidx_ra(env, GET_OFFSET(arg2, 7), (uint8_t)arg1,
232
+ mem_idx, GETPC());
233
}
234
}
235
236
void helper_sdr(CPUMIPSState *env, target_ulong arg1, target_ulong arg2,
237
int mem_idx)
238
{
239
- do_sb(env, arg2, (uint8_t)arg1, mem_idx, GETPC());
240
+ cpu_stb_mmuidx_ra(env, arg2, (uint8_t)arg1, mem_idx, GETPC());
241
242
if (GET_LMASK64(arg2) >= 1) {
243
- do_sb(env, GET_OFFSET(arg2, -1), (uint8_t)(arg1 >> 8), mem_idx,
244
- GETPC());
245
+ cpu_stb_mmuidx_ra(env, GET_OFFSET(arg2, -1), (uint8_t)(arg1 >> 8),
246
+ mem_idx, GETPC());
247
}
248
249
if (GET_LMASK64(arg2) >= 2) {
250
- do_sb(env, GET_OFFSET(arg2, -2), (uint8_t)(arg1 >> 16), mem_idx,
251
- GETPC());
252
+ cpu_stb_mmuidx_ra(env, GET_OFFSET(arg2, -2), (uint8_t)(arg1 >> 16),
253
+ mem_idx, GETPC());
254
}
255
256
if (GET_LMASK64(arg2) >= 3) {
257
- do_sb(env, GET_OFFSET(arg2, -3), (uint8_t)(arg1 >> 24), mem_idx,
258
- GETPC());
259
+ cpu_stb_mmuidx_ra(env, GET_OFFSET(arg2, -3), (uint8_t)(arg1 >> 24),
260
+ mem_idx, GETPC());
261
}
262
263
if (GET_LMASK64(arg2) >= 4) {
264
- do_sb(env, GET_OFFSET(arg2, -4), (uint8_t)(arg1 >> 32), mem_idx,
265
- GETPC());
266
+ cpu_stb_mmuidx_ra(env, GET_OFFSET(arg2, -4), (uint8_t)(arg1 >> 32),
267
+ mem_idx, GETPC());
268
}
269
270
if (GET_LMASK64(arg2) >= 5) {
271
- do_sb(env, GET_OFFSET(arg2, -5), (uint8_t)(arg1 >> 40), mem_idx,
272
- GETPC());
273
+ cpu_stb_mmuidx_ra(env, GET_OFFSET(arg2, -5), (uint8_t)(arg1 >> 40),
274
+ mem_idx, GETPC());
275
}
276
277
if (GET_LMASK64(arg2) >= 6) {
278
- do_sb(env, GET_OFFSET(arg2, -6), (uint8_t)(arg1 >> 48), mem_idx,
279
- GETPC());
280
+ cpu_stb_mmuidx_ra(env, GET_OFFSET(arg2, -6), (uint8_t)(arg1 >> 48),
281
+ mem_idx, GETPC());
282
}
283
284
if (GET_LMASK64(arg2) == 7) {
285
- do_sb(env, GET_OFFSET(arg2, -7), (uint8_t)(arg1 >> 56), mem_idx,
286
- GETPC());
287
+ cpu_stb_mmuidx_ra(env, GET_OFFSET(arg2, -7), (uint8_t)(arg1 >> 56),
288
+ mem_idx, GETPC());
289
}
290
}
291
#endif /* TARGET_MIPS64 */
292
@@ -XXX,XX +XXX,XX @@ void helper_lwm(CPUMIPSState *env, target_ulong addr, target_ulong reglist,
293
294
for (i = 0; i < base_reglist; i++) {
295
env->active_tc.gpr[multiple_regs[i]] =
296
- (target_long)do_lw(env, addr, mem_idx, GETPC());
297
+ (target_long)cpu_ldl_mmuidx_ra(env, addr, mem_idx, GETPC());
298
addr += 4;
299
}
37
}
300
}
38
}
301
39
302
if (do_r31) {
40
/* Opcodes that touch guest memory stop the mb optimization. */
303
- env->active_tc.gpr[31] = (target_long)do_lw(env, addr, mem_idx,
41
ctx->prev_mb = NULL;
304
- GETPC());
42
- return false;
305
+ env->active_tc.gpr[31] =
43
+
306
+ (target_long)cpu_ldl_mmuidx_ra(env, addr, mem_idx, GETPC());
44
+ return fold_masks_zs(ctx, op, z_mask, s_mask);
307
}
45
+}
46
+
47
+static bool fold_qemu_ld_2reg(OptContext *ctx, TCGOp *op)
48
+{
49
+ /* Opcodes that touch guest memory stop the mb optimization. */
50
+ ctx->prev_mb = NULL;
51
+ return finish_folding(ctx, op);
308
}
52
}
309
53
310
@@ -XXX,XX +XXX,XX @@ void helper_swm(CPUMIPSState *env, target_ulong addr, target_ulong reglist,
54
static bool fold_qemu_st(OptContext *ctx, TCGOp *op)
311
target_ulong i;
55
@@ -XXX,XX +XXX,XX @@ void tcg_optimize(TCGContext *s)
312
56
break;
313
for (i = 0; i < base_reglist; i++) {
57
case INDEX_op_qemu_ld_a32_i32:
314
- do_sw(env, addr, env->active_tc.gpr[multiple_regs[i]], mem_idx,
58
case INDEX_op_qemu_ld_a64_i32:
315
- GETPC());
59
+ done = fold_qemu_ld_1reg(&ctx, op);
316
+ cpu_stw_mmuidx_ra(env, addr, env->active_tc.gpr[multiple_regs[i]],
60
+ break;
317
+ mem_idx, GETPC());
61
case INDEX_op_qemu_ld_a32_i64:
318
addr += 4;
62
case INDEX_op_qemu_ld_a64_i64:
319
}
63
+ if (TCG_TARGET_REG_BITS == 64) {
320
}
64
+ done = fold_qemu_ld_1reg(&ctx, op);
321
65
+ break;
322
if (do_r31) {
66
+ }
323
- do_sw(env, addr, env->active_tc.gpr[31], mem_idx, GETPC());
67
+ QEMU_FALLTHROUGH;
324
+ cpu_stw_mmuidx_ra(env, addr, env->active_tc.gpr[31], mem_idx, GETPC());
68
case INDEX_op_qemu_ld_a32_i128:
325
}
69
case INDEX_op_qemu_ld_a64_i128:
326
}
70
- done = fold_qemu_ld(&ctx, op);
327
71
+ done = fold_qemu_ld_2reg(&ctx, op);
328
@@ -XXX,XX +XXX,XX @@ void helper_ldm(CPUMIPSState *env, target_ulong addr, target_ulong reglist,
72
break;
329
target_ulong i;
73
case INDEX_op_qemu_st8_a32_i32:
330
74
case INDEX_op_qemu_st8_a64_i32:
331
for (i = 0; i < base_reglist; i++) {
332
- env->active_tc.gpr[multiple_regs[i]] = do_ld(env, addr, mem_idx,
333
- GETPC());
334
+ env->active_tc.gpr[multiple_regs[i]] =
335
+ cpu_ldq_mmuidx_ra(env, addr, mem_idx, GETPC());
336
addr += 8;
337
}
338
}
339
340
if (do_r31) {
341
- env->active_tc.gpr[31] = do_ld(env, addr, mem_idx, GETPC());
342
+ env->active_tc.gpr[31] =
343
+ cpu_ldq_mmuidx_ra(env, addr, mem_idx, GETPC());
344
}
345
}
346
347
@@ -XXX,XX +XXX,XX @@ void helper_sdm(CPUMIPSState *env, target_ulong addr, target_ulong reglist,
348
target_ulong i;
349
350
for (i = 0; i < base_reglist; i++) {
351
- do_sd(env, addr, env->active_tc.gpr[multiple_regs[i]], mem_idx,
352
- GETPC());
353
+ cpu_stq_mmuidx_ra(env, addr, env->active_tc.gpr[multiple_regs[i]],
354
+ mem_idx, GETPC());
355
addr += 8;
356
}
357
}
358
359
if (do_r31) {
360
- do_sd(env, addr, env->active_tc.gpr[31], mem_idx, GETPC());
361
+ cpu_stq_mmuidx_ra(env, addr, env->active_tc.gpr[31], mem_idx, GETPC());
362
}
363
}
364
#endif
365
--
75
--
366
2.20.1
76
2.43.0
367
368
diff view generated by jsdifflib
New patch
1
Stores have no output operands, and so need no further work.
1
2
3
Reviewed-by: Pierrick Bouvier <pierrick.bouvier@linaro.org>
4
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
5
---
6
tcg/optimize.c | 11 +++++------
7
1 file changed, 5 insertions(+), 6 deletions(-)
8
9
diff --git a/tcg/optimize.c b/tcg/optimize.c
10
index XXXXXXX..XXXXXXX 100644
11
--- a/tcg/optimize.c
12
+++ b/tcg/optimize.c
13
@@ -XXX,XX +XXX,XX @@ static bool fold_qemu_st(OptContext *ctx, TCGOp *op)
14
{
15
/* Opcodes that touch guest memory stop the mb optimization. */
16
ctx->prev_mb = NULL;
17
- return false;
18
+ return true;
19
}
20
21
static bool fold_remainder(OptContext *ctx, TCGOp *op)
22
@@ -XXX,XX +XXX,XX @@ static bool fold_tcg_st(OptContext *ctx, TCGOp *op)
23
24
if (op->args[1] != tcgv_ptr_arg(tcg_env)) {
25
remove_mem_copy_all(ctx);
26
- return false;
27
+ return true;
28
}
29
30
switch (op->opc) {
31
@@ -XXX,XX +XXX,XX @@ static bool fold_tcg_st(OptContext *ctx, TCGOp *op)
32
g_assert_not_reached();
33
}
34
remove_mem_copy_in(ctx, ofs, ofs + lm1);
35
- return false;
36
+ return true;
37
}
38
39
static bool fold_tcg_st_memcopy(OptContext *ctx, TCGOp *op)
40
@@ -XXX,XX +XXX,XX @@ static bool fold_tcg_st_memcopy(OptContext *ctx, TCGOp *op)
41
TCGType type;
42
43
if (op->args[1] != tcgv_ptr_arg(tcg_env)) {
44
- fold_tcg_st(ctx, op);
45
- return false;
46
+ return fold_tcg_st(ctx, op);
47
}
48
49
src = arg_temp(op->args[0]);
50
@@ -XXX,XX +XXX,XX @@ static bool fold_tcg_st_memcopy(OptContext *ctx, TCGOp *op)
51
last = ofs + tcg_type_size(type) - 1;
52
remove_mem_copy_in(ctx, ofs, last);
53
record_mem_copy(ctx, type, src, ofs, last);
54
- return false;
55
+ return true;
56
}
57
58
static bool fold_xor(OptContext *ctx, TCGOp *op)
59
--
60
2.43.0
diff view generated by jsdifflib
New patch
1
Reviewed-by: Pierrick Bouvier <pierrick.bouvier@linaro.org>
2
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
3
---
4
tcg/optimize.c | 2 +-
5
1 file changed, 1 insertion(+), 1 deletion(-)
1
6
7
diff --git a/tcg/optimize.c b/tcg/optimize.c
8
index XXXXXXX..XXXXXXX 100644
9
--- a/tcg/optimize.c
10
+++ b/tcg/optimize.c
11
@@ -XXX,XX +XXX,XX @@ static bool fold_remainder(OptContext *ctx, TCGOp *op)
12
fold_xx_to_i(ctx, op, 0)) {
13
return true;
14
}
15
- return false;
16
+ return finish_folding(ctx, op);
17
}
18
19
static bool fold_setcond_zmask(OptContext *ctx, TCGOp *op, bool neg)
20
--
21
2.43.0
diff view generated by jsdifflib
New patch
1
Change return from bool to int; distinguish between
2
complete folding, simplification, and no change.
1
3
4
Reviewed-by: Pierrick Bouvier <pierrick.bouvier@linaro.org>
5
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
6
---
7
tcg/optimize.c | 22 ++++++++++++++--------
8
1 file changed, 14 insertions(+), 8 deletions(-)
9
10
diff --git a/tcg/optimize.c b/tcg/optimize.c
11
index XXXXXXX..XXXXXXX 100644
12
--- a/tcg/optimize.c
13
+++ b/tcg/optimize.c
14
@@ -XXX,XX +XXX,XX @@ static bool fold_remainder(OptContext *ctx, TCGOp *op)
15
return finish_folding(ctx, op);
16
}
17
18
-static bool fold_setcond_zmask(OptContext *ctx, TCGOp *op, bool neg)
19
+/* Return 1 if finished, -1 if simplified, 0 if unchanged. */
20
+static int fold_setcond_zmask(OptContext *ctx, TCGOp *op, bool neg)
21
{
22
uint64_t a_zmask, b_val;
23
TCGCond cond;
24
@@ -XXX,XX +XXX,XX @@ static bool fold_setcond_zmask(OptContext *ctx, TCGOp *op, bool neg)
25
op->opc = xor_opc;
26
op->args[2] = arg_new_constant(ctx, 1);
27
}
28
- return false;
29
+ return -1;
30
}
31
}
32
-
33
- return false;
34
+ return 0;
35
}
36
37
static void fold_setcond_tst_pow2(OptContext *ctx, TCGOp *op, bool neg)
38
@@ -XXX,XX +XXX,XX @@ static bool fold_setcond(OptContext *ctx, TCGOp *op)
39
return tcg_opt_gen_movi(ctx, op, op->args[0], i);
40
}
41
42
- if (fold_setcond_zmask(ctx, op, false)) {
43
+ i = fold_setcond_zmask(ctx, op, false);
44
+ if (i > 0) {
45
return true;
46
}
47
- fold_setcond_tst_pow2(ctx, op, false);
48
+ if (i == 0) {
49
+ fold_setcond_tst_pow2(ctx, op, false);
50
+ }
51
52
ctx->z_mask = 1;
53
return false;
54
@@ -XXX,XX +XXX,XX @@ static bool fold_negsetcond(OptContext *ctx, TCGOp *op)
55
return tcg_opt_gen_movi(ctx, op, op->args[0], -i);
56
}
57
58
- if (fold_setcond_zmask(ctx, op, true)) {
59
+ i = fold_setcond_zmask(ctx, op, true);
60
+ if (i > 0) {
61
return true;
62
}
63
- fold_setcond_tst_pow2(ctx, op, true);
64
+ if (i == 0) {
65
+ fold_setcond_tst_pow2(ctx, op, true);
66
+ }
67
68
/* Value is {0,-1} so all bits are repetitions of the sign. */
69
ctx->s_mask = -1;
70
--
71
2.43.0
diff view generated by jsdifflib
New patch
1
Avoid the use of the OptContext slots.
1
2
3
Reviewed-by: Pierrick Bouvier <pierrick.bouvier@linaro.org>
4
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
5
---
6
tcg/optimize.c | 3 +--
7
1 file changed, 1 insertion(+), 2 deletions(-)
8
9
diff --git a/tcg/optimize.c b/tcg/optimize.c
10
index XXXXXXX..XXXXXXX 100644
11
--- a/tcg/optimize.c
12
+++ b/tcg/optimize.c
13
@@ -XXX,XX +XXX,XX @@ static bool fold_setcond(OptContext *ctx, TCGOp *op)
14
fold_setcond_tst_pow2(ctx, op, false);
15
}
16
17
- ctx->z_mask = 1;
18
- return false;
19
+ return fold_masks_z(ctx, op, 1);
20
}
21
22
static bool fold_negsetcond(OptContext *ctx, TCGOp *op)
23
--
24
2.43.0
diff view generated by jsdifflib
New patch
1
Avoid the use of the OptContext slots.
1
2
3
Reviewed-by: Pierrick Bouvier <pierrick.bouvier@linaro.org>
4
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
5
---
6
tcg/optimize.c | 3 +--
7
1 file changed, 1 insertion(+), 2 deletions(-)
8
9
diff --git a/tcg/optimize.c b/tcg/optimize.c
10
index XXXXXXX..XXXXXXX 100644
11
--- a/tcg/optimize.c
12
+++ b/tcg/optimize.c
13
@@ -XXX,XX +XXX,XX @@ static bool fold_negsetcond(OptContext *ctx, TCGOp *op)
14
}
15
16
/* Value is {0,-1} so all bits are repetitions of the sign. */
17
- ctx->s_mask = -1;
18
- return false;
19
+ return fold_masks_s(ctx, op, -1);
20
}
21
22
static bool fold_setcond2(OptContext *ctx, TCGOp *op)
23
--
24
2.43.0
diff view generated by jsdifflib
1
Claudio's Huawei address has been defunct for quite a while. In
1
Avoid the use of the OptContext slots.
2
2
3
https://lists.gnu.org/archive/html/qemu-devel/2019-05/msg06872.html
3
Reviewed-by: Pierrick Bouvier <pierrick.bouvier@linaro.org>
4
5
he asked for his personal address to be removed as well.
6
7
I will take over officially.
8
9
Cc: Claudio Fontana <claudio.fontana@gmail.com>
10
Reviewed-by: Alex Bennée <alex.bennee@linaro.org>
11
Reviewed-by: Philippe Mathieu-Daudé <philmd@redhat.com>
12
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
4
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
13
---
5
---
14
MAINTAINERS | 3 +--
6
tcg/optimize.c | 3 +--
15
1 file changed, 1 insertion(+), 2 deletions(-)
7
1 file changed, 1 insertion(+), 2 deletions(-)
16
8
17
diff --git a/MAINTAINERS b/MAINTAINERS
9
diff --git a/tcg/optimize.c b/tcg/optimize.c
18
index XXXXXXX..XXXXXXX 100644
10
index XXXXXXX..XXXXXXX 100644
19
--- a/MAINTAINERS
11
--- a/tcg/optimize.c
20
+++ b/MAINTAINERS
12
+++ b/tcg/optimize.c
21
@@ -XXX,XX +XXX,XX @@ F: plugins/
13
@@ -XXX,XX +XXX,XX @@ static bool fold_setcond2(OptContext *ctx, TCGOp *op)
22
F: tests/plugin
14
return fold_setcond(ctx, op);
23
15
}
24
AArch64 TCG target
16
25
-M: Claudio Fontana <claudio.fontana@huawei.com>
17
- ctx->z_mask = 1;
26
-M: Claudio Fontana <claudio.fontana@gmail.com>
18
- return false;
27
+M: Richard Henderson <richard.henderson@linaro.org>
19
+ return fold_masks_z(ctx, op, 1);
28
S: Maintained
20
29
L: qemu-arm@nongnu.org
21
do_setcond_const:
30
F: tcg/aarch64/
22
return tcg_opt_gen_movi(ctx, op, op->args[0], i);
31
--
23
--
32
2.20.1
24
2.43.0
33
34
diff view generated by jsdifflib
New patch
1
Reviewed-by: Pierrick Bouvier <pierrick.bouvier@linaro.org>
2
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
3
---
4
tcg/optimize.c | 2 +-
5
1 file changed, 1 insertion(+), 1 deletion(-)
1
6
7
diff --git a/tcg/optimize.c b/tcg/optimize.c
8
index XXXXXXX..XXXXXXX 100644
9
--- a/tcg/optimize.c
10
+++ b/tcg/optimize.c
11
@@ -XXX,XX +XXX,XX @@ static bool fold_cmp_vec(OptContext *ctx, TCGOp *op)
12
if (swap_commutative(NO_DEST, &op->args[1], &op->args[2])) {
13
op->args[3] = tcg_swap_cond(op->args[3]);
14
}
15
- return false;
16
+ return finish_folding(ctx, op);
17
}
18
19
static bool fold_cmpsel_vec(OptContext *ctx, TCGOp *op)
20
--
21
2.43.0
diff view generated by jsdifflib
1
From: Philippe Mathieu-Daudé <philmd@redhat.com>
1
Reviewed-by: Pierrick Bouvier <pierrick.bouvier@linaro.org>
2
3
All tcg includes are relative to the repository root directory,
4
we can safely remove the tcg/ directory from the include search
5
path list.
6
7
Reviewed-by: Paolo Bonzini <pbonzini@redhat.com>
8
Reviewed-by: Alistair Francis <alistair.francis@wdc.com>
9
Reviewed-by: Stefan Weil <sw@weilnetz.de>
10
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
11
Signed-off-by: Philippe Mathieu-Daudé <philmd@redhat.com>
12
Message-Id: <20200101112303.20724-5-philmd@redhat.com>
13
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
2
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
14
---
3
---
15
configure | 1 -
4
tcg/optimize.c | 2 +-
16
1 file changed, 1 deletion(-)
5
1 file changed, 1 insertion(+), 1 deletion(-)
17
6
18
diff --git a/configure b/configure
7
diff --git a/tcg/optimize.c b/tcg/optimize.c
19
index XXXXXXX..XXXXXXX 100755
8
index XXXXXXX..XXXXXXX 100644
20
--- a/configure
9
--- a/tcg/optimize.c
21
+++ b/configure
10
+++ b/tcg/optimize.c
22
@@ -XXX,XX +XXX,XX @@ elif test "$ARCH" = "riscv32" || test "$ARCH" = "riscv64" ; then
11
@@ -XXX,XX +XXX,XX @@ static bool fold_cmpsel_vec(OptContext *ctx, TCGOp *op)
23
else
12
if (swap_commutative(op->args[0], &op->args[4], &op->args[3])) {
24
QEMU_INCLUDES="-iquote \$(SRC_PATH)/tcg/\$(ARCH) $QEMU_INCLUDES"
13
op->args[5] = tcg_invert_cond(op->args[5]);
25
fi
14
}
26
-QEMU_INCLUDES="-iquote \$(SRC_PATH)/tcg $QEMU_INCLUDES"
15
- return false;
27
16
+ return finish_folding(ctx, op);
28
echo "TOOLS=$tools" >> $config_host_mak
17
}
29
echo "ROMS=$roms" >> $config_host_mak
18
19
static bool fold_sextract(OptContext *ctx, TCGOp *op)
30
--
20
--
31
2.20.1
21
2.43.0
32
33
diff view generated by jsdifflib
1
From: Philippe Mathieu-Daudé <philmd@redhat.com>
1
Avoid the use of the OptContext slots. Find TempOptInfo once.
2
2
3
Reviewed-by: Paolo Bonzini <pbonzini@redhat.com>
3
Reviewed-by: Pierrick Bouvier <pierrick.bouvier@linaro.org>
4
Reviewed-by: Alistair Francis <alistair.francis@wdc.com>
5
Reviewed-by: Stefan Weil <sw@weilnetz.de>
6
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
7
Signed-off-by: Philippe Mathieu-Daudé <philmd@redhat.com>
8
Message-Id: <20200101112303.20724-4-philmd@redhat.com>
9
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
4
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
10
---
5
---
11
{tcg => include/tcg}/tcg-gvec-desc.h | 0
6
tcg/optimize.c | 24 +++++++++---------------
12
{tcg => include/tcg}/tcg-mo.h | 0
7
1 file changed, 9 insertions(+), 15 deletions(-)
13
{tcg => include/tcg}/tcg-op-gvec.h | 0
14
{tcg => include/tcg}/tcg-op.h | 0
15
{tcg => include/tcg}/tcg-opc.h | 0
16
{tcg => include/tcg}/tcg.h | 0
17
MAINTAINERS | 1 +
18
7 files changed, 1 insertion(+)
19
rename {tcg => include/tcg}/tcg-gvec-desc.h (100%)
20
rename {tcg => include/tcg}/tcg-mo.h (100%)
21
rename {tcg => include/tcg}/tcg-op-gvec.h (100%)
22
rename {tcg => include/tcg}/tcg-op.h (100%)
23
rename {tcg => include/tcg}/tcg-opc.h (100%)
24
rename {tcg => include/tcg}/tcg.h (100%)
25
8
26
diff --git a/tcg/tcg-gvec-desc.h b/include/tcg/tcg-gvec-desc.h
9
diff --git a/tcg/optimize.c b/tcg/optimize.c
27
similarity index 100%
28
rename from tcg/tcg-gvec-desc.h
29
rename to include/tcg/tcg-gvec-desc.h
30
diff --git a/tcg/tcg-mo.h b/include/tcg/tcg-mo.h
31
similarity index 100%
32
rename from tcg/tcg-mo.h
33
rename to include/tcg/tcg-mo.h
34
diff --git a/tcg/tcg-op-gvec.h b/include/tcg/tcg-op-gvec.h
35
similarity index 100%
36
rename from tcg/tcg-op-gvec.h
37
rename to include/tcg/tcg-op-gvec.h
38
diff --git a/tcg/tcg-op.h b/include/tcg/tcg-op.h
39
similarity index 100%
40
rename from tcg/tcg-op.h
41
rename to include/tcg/tcg-op.h
42
diff --git a/tcg/tcg-opc.h b/include/tcg/tcg-opc.h
43
similarity index 100%
44
rename from tcg/tcg-opc.h
45
rename to include/tcg/tcg-opc.h
46
diff --git a/tcg/tcg.h b/include/tcg/tcg.h
47
similarity index 100%
48
rename from tcg/tcg.h
49
rename to include/tcg/tcg.h
50
diff --git a/MAINTAINERS b/MAINTAINERS
51
index XXXXXXX..XXXXXXX 100644
10
index XXXXXXX..XXXXXXX 100644
52
--- a/MAINTAINERS
11
--- a/tcg/optimize.c
53
+++ b/MAINTAINERS
12
+++ b/tcg/optimize.c
54
@@ -XXX,XX +XXX,XX @@ Common TCG code
13
@@ -XXX,XX +XXX,XX @@ static bool fold_cmpsel_vec(OptContext *ctx, TCGOp *op)
55
M: Richard Henderson <rth@twiddle.net>
14
static bool fold_sextract(OptContext *ctx, TCGOp *op)
56
S: Maintained
15
{
57
F: tcg/
16
uint64_t z_mask, s_mask, s_mask_old;
58
+F: include/tcg/
17
+ TempOptInfo *t1 = arg_info(op->args[1]);
59
18
int pos = op->args[2];
60
TCG Plugins
19
int len = op->args[3];
61
M: Alex Bennée <alex.bennee@linaro.org>
20
21
- if (arg_is_const(op->args[1])) {
22
- uint64_t t;
23
-
24
- t = arg_info(op->args[1])->val;
25
- t = sextract64(t, pos, len);
26
- return tcg_opt_gen_movi(ctx, op, op->args[0], t);
27
+ if (ti_is_const(t1)) {
28
+ return tcg_opt_gen_movi(ctx, op, op->args[0],
29
+ sextract64(ti_const_val(t1), pos, len));
30
}
31
32
- z_mask = arg_info(op->args[1])->z_mask;
33
- z_mask = sextract64(z_mask, pos, len);
34
- ctx->z_mask = z_mask;
35
-
36
- s_mask_old = arg_info(op->args[1])->s_mask;
37
- s_mask = sextract64(s_mask_old, pos, len);
38
- s_mask |= MAKE_64BIT_MASK(len, 64 - len);
39
- ctx->s_mask = s_mask;
40
+ s_mask_old = t1->s_mask;
41
+ s_mask = s_mask_old >> pos;
42
+ s_mask |= -1ull << (len - 1);
43
44
if (0 && pos == 0 && fold_affected_mask(ctx, op, s_mask & ~s_mask_old)) {
45
return true;
46
}
47
48
- return fold_masks(ctx, op);
49
+ z_mask = sextract64(t1->z_mask, pos, len);
50
+ return fold_masks_zs(ctx, op, z_mask, s_mask);
51
}
52
53
static bool fold_shift(OptContext *ctx, TCGOp *op)
62
--
54
--
63
2.20.1
55
2.43.0
64
65
diff view generated by jsdifflib
1
All users have now been converted to cpu_*_mmuidx_ra.
1
Avoid the use of the OptContext slots. Find TempOptInfo once.
2
2
3
Tested-by: Philippe Mathieu-Daudé <philmd@redhat.com>
3
Reviewed-by: Pierrick Bouvier <pierrick.bouvier@linaro.org>
4
Reviewed-by: Alex Bennée <alex.bennee@linaro.org>
5
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
4
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
6
---
5
---
7
include/exec/cpu_ldst.h | 230 ----------------------------------------
6
tcg/optimize.c | 27 ++++++++++++++-------------
8
1 file changed, 230 deletions(-)
7
1 file changed, 14 insertions(+), 13 deletions(-)
9
8
10
diff --git a/include/exec/cpu_ldst.h b/include/exec/cpu_ldst.h
9
diff --git a/tcg/optimize.c b/tcg/optimize.c
11
index XXXXXXX..XXXXXXX 100644
10
index XXXXXXX..XXXXXXX 100644
12
--- a/include/exec/cpu_ldst.h
11
--- a/tcg/optimize.c
13
+++ b/include/exec/cpu_ldst.h
12
+++ b/tcg/optimize.c
14
@@ -XXX,XX +XXX,XX @@ void cpu_stl_mmuidx_ra(CPUArchState *env, abi_ptr addr, uint32_t val,
13
@@ -XXX,XX +XXX,XX @@ static bool fold_sextract(OptContext *ctx, TCGOp *op)
15
void cpu_stq_mmuidx_ra(CPUArchState *env, abi_ptr addr, uint64_t val,
14
static bool fold_shift(OptContext *ctx, TCGOp *op)
16
int mmu_idx, uintptr_t retaddr);
15
{
17
16
uint64_t s_mask, z_mask, sign;
18
-#ifdef MMU_MODE0_SUFFIX
17
+ TempOptInfo *t1, *t2;
19
-#define CPU_MMU_INDEX 0
18
20
-#define MEMSUFFIX MMU_MODE0_SUFFIX
19
if (fold_const2(ctx, op) ||
21
-#define DATA_SIZE 1
20
fold_ix_to_i(ctx, op, 0) ||
22
-#include "exec/cpu_ldst_template.h"
21
@@ -XXX,XX +XXX,XX @@ static bool fold_shift(OptContext *ctx, TCGOp *op)
22
return true;
23
}
24
25
- s_mask = arg_info(op->args[1])->s_mask;
26
- z_mask = arg_info(op->args[1])->z_mask;
27
+ t1 = arg_info(op->args[1]);
28
+ t2 = arg_info(op->args[2]);
29
+ s_mask = t1->s_mask;
30
+ z_mask = t1->z_mask;
31
32
- if (arg_is_const(op->args[2])) {
33
- int sh = arg_info(op->args[2])->val;
23
-
34
-
24
-#define DATA_SIZE 2
35
- ctx->z_mask = do_constant_folding(op->opc, ctx->type, z_mask, sh);
25
-#include "exec/cpu_ldst_template.h"
36
+ if (ti_is_const(t2)) {
26
-
37
+ int sh = ti_const_val(t2);
27
-#define DATA_SIZE 4
38
28
-#include "exec/cpu_ldst_template.h"
39
+ z_mask = do_constant_folding(op->opc, ctx->type, z_mask, sh);
29
-
40
s_mask = do_constant_folding(op->opc, ctx->type, s_mask, sh);
30
-#define DATA_SIZE 8
41
31
-#include "exec/cpu_ldst_template.h"
42
- return fold_masks(ctx, op);
32
-#undef CPU_MMU_INDEX
43
+ return fold_masks_zs(ctx, op, z_mask, s_mask);
33
-#undef MEMSUFFIX
44
}
34
-#endif
45
35
-
46
switch (op->opc) {
36
-#if (NB_MMU_MODES >= 2) && defined(MMU_MODE1_SUFFIX)
47
@@ -XXX,XX +XXX,XX @@ static bool fold_shift(OptContext *ctx, TCGOp *op)
37
-#define CPU_MMU_INDEX 1
48
* Arithmetic right shift will not reduce the number of
38
-#define MEMSUFFIX MMU_MODE1_SUFFIX
49
* input sign repetitions.
39
-#define DATA_SIZE 1
50
*/
40
-#include "exec/cpu_ldst_template.h"
51
- ctx->s_mask = s_mask;
41
-
52
- break;
42
-#define DATA_SIZE 2
53
+ return fold_masks_s(ctx, op, s_mask);
43
-#include "exec/cpu_ldst_template.h"
54
CASE_OP_32_64(shr):
44
-
55
/*
45
-#define DATA_SIZE 4
56
* If the sign bit is known zero, then logical right shift
46
-#include "exec/cpu_ldst_template.h"
57
- * will not reduced the number of input sign repetitions.
47
-
58
+ * will not reduce the number of input sign repetitions.
48
-#define DATA_SIZE 8
59
*/
49
-#include "exec/cpu_ldst_template.h"
60
- sign = (s_mask & -s_mask) >> 1;
50
-#undef CPU_MMU_INDEX
61
+ sign = -s_mask;
51
-#undef MEMSUFFIX
62
if (sign && !(z_mask & sign)) {
52
-#endif
63
- ctx->s_mask = s_mask;
53
-
64
+ return fold_masks_s(ctx, op, s_mask);
54
-#if (NB_MMU_MODES >= 3) && defined(MMU_MODE2_SUFFIX)
65
}
55
-
66
break;
56
-#define CPU_MMU_INDEX 2
67
default:
57
-#define MEMSUFFIX MMU_MODE2_SUFFIX
68
break;
58
-#define DATA_SIZE 1
69
}
59
-#include "exec/cpu_ldst_template.h"
70
60
-
71
- return false;
61
-#define DATA_SIZE 2
72
+ return finish_folding(ctx, op);
62
-#include "exec/cpu_ldst_template.h"
73
}
63
-
74
64
-#define DATA_SIZE 4
75
static bool fold_sub_to_neg(OptContext *ctx, TCGOp *op)
65
-#include "exec/cpu_ldst_template.h"
66
-
67
-#define DATA_SIZE 8
68
-#include "exec/cpu_ldst_template.h"
69
-#undef CPU_MMU_INDEX
70
-#undef MEMSUFFIX
71
-#endif /* (NB_MMU_MODES >= 3) */
72
-
73
-#if (NB_MMU_MODES >= 4) && defined(MMU_MODE3_SUFFIX)
74
-
75
-#define CPU_MMU_INDEX 3
76
-#define MEMSUFFIX MMU_MODE3_SUFFIX
77
-#define DATA_SIZE 1
78
-#include "exec/cpu_ldst_template.h"
79
-
80
-#define DATA_SIZE 2
81
-#include "exec/cpu_ldst_template.h"
82
-
83
-#define DATA_SIZE 4
84
-#include "exec/cpu_ldst_template.h"
85
-
86
-#define DATA_SIZE 8
87
-#include "exec/cpu_ldst_template.h"
88
-#undef CPU_MMU_INDEX
89
-#undef MEMSUFFIX
90
-#endif /* (NB_MMU_MODES >= 4) */
91
-
92
-#if (NB_MMU_MODES >= 5) && defined(MMU_MODE4_SUFFIX)
93
-
94
-#define CPU_MMU_INDEX 4
95
-#define MEMSUFFIX MMU_MODE4_SUFFIX
96
-#define DATA_SIZE 1
97
-#include "exec/cpu_ldst_template.h"
98
-
99
-#define DATA_SIZE 2
100
-#include "exec/cpu_ldst_template.h"
101
-
102
-#define DATA_SIZE 4
103
-#include "exec/cpu_ldst_template.h"
104
-
105
-#define DATA_SIZE 8
106
-#include "exec/cpu_ldst_template.h"
107
-#undef CPU_MMU_INDEX
108
-#undef MEMSUFFIX
109
-#endif /* (NB_MMU_MODES >= 5) */
110
-
111
-#if (NB_MMU_MODES >= 6) && defined(MMU_MODE5_SUFFIX)
112
-
113
-#define CPU_MMU_INDEX 5
114
-#define MEMSUFFIX MMU_MODE5_SUFFIX
115
-#define DATA_SIZE 1
116
-#include "exec/cpu_ldst_template.h"
117
-
118
-#define DATA_SIZE 2
119
-#include "exec/cpu_ldst_template.h"
120
-
121
-#define DATA_SIZE 4
122
-#include "exec/cpu_ldst_template.h"
123
-
124
-#define DATA_SIZE 8
125
-#include "exec/cpu_ldst_template.h"
126
-#undef CPU_MMU_INDEX
127
-#undef MEMSUFFIX
128
-#endif /* (NB_MMU_MODES >= 6) */
129
-
130
-#if (NB_MMU_MODES >= 7) && defined(MMU_MODE6_SUFFIX)
131
-
132
-#define CPU_MMU_INDEX 6
133
-#define MEMSUFFIX MMU_MODE6_SUFFIX
134
-#define DATA_SIZE 1
135
-#include "exec/cpu_ldst_template.h"
136
-
137
-#define DATA_SIZE 2
138
-#include "exec/cpu_ldst_template.h"
139
-
140
-#define DATA_SIZE 4
141
-#include "exec/cpu_ldst_template.h"
142
-
143
-#define DATA_SIZE 8
144
-#include "exec/cpu_ldst_template.h"
145
-#undef CPU_MMU_INDEX
146
-#undef MEMSUFFIX
147
-#endif /* (NB_MMU_MODES >= 7) */
148
-
149
-#if (NB_MMU_MODES >= 8) && defined(MMU_MODE7_SUFFIX)
150
-
151
-#define CPU_MMU_INDEX 7
152
-#define MEMSUFFIX MMU_MODE7_SUFFIX
153
-#define DATA_SIZE 1
154
-#include "exec/cpu_ldst_template.h"
155
-
156
-#define DATA_SIZE 2
157
-#include "exec/cpu_ldst_template.h"
158
-
159
-#define DATA_SIZE 4
160
-#include "exec/cpu_ldst_template.h"
161
-
162
-#define DATA_SIZE 8
163
-#include "exec/cpu_ldst_template.h"
164
-#undef CPU_MMU_INDEX
165
-#undef MEMSUFFIX
166
-#endif /* (NB_MMU_MODES >= 8) */
167
-
168
-#if (NB_MMU_MODES >= 9) && defined(MMU_MODE8_SUFFIX)
169
-
170
-#define CPU_MMU_INDEX 8
171
-#define MEMSUFFIX MMU_MODE8_SUFFIX
172
-#define DATA_SIZE 1
173
-#include "exec/cpu_ldst_template.h"
174
-
175
-#define DATA_SIZE 2
176
-#include "exec/cpu_ldst_template.h"
177
-
178
-#define DATA_SIZE 4
179
-#include "exec/cpu_ldst_template.h"
180
-
181
-#define DATA_SIZE 8
182
-#include "exec/cpu_ldst_template.h"
183
-#undef CPU_MMU_INDEX
184
-#undef MEMSUFFIX
185
-#endif /* (NB_MMU_MODES >= 9) */
186
-
187
-#if (NB_MMU_MODES >= 10) && defined(MMU_MODE9_SUFFIX)
188
-
189
-#define CPU_MMU_INDEX 9
190
-#define MEMSUFFIX MMU_MODE9_SUFFIX
191
-#define DATA_SIZE 1
192
-#include "exec/cpu_ldst_template.h"
193
-
194
-#define DATA_SIZE 2
195
-#include "exec/cpu_ldst_template.h"
196
-
197
-#define DATA_SIZE 4
198
-#include "exec/cpu_ldst_template.h"
199
-
200
-#define DATA_SIZE 8
201
-#include "exec/cpu_ldst_template.h"
202
-#undef CPU_MMU_INDEX
203
-#undef MEMSUFFIX
204
-#endif /* (NB_MMU_MODES >= 10) */
205
-
206
-#if (NB_MMU_MODES >= 11) && defined(MMU_MODE10_SUFFIX)
207
-
208
-#define CPU_MMU_INDEX 10
209
-#define MEMSUFFIX MMU_MODE10_SUFFIX
210
-#define DATA_SIZE 1
211
-#include "exec/cpu_ldst_template.h"
212
-
213
-#define DATA_SIZE 2
214
-#include "exec/cpu_ldst_template.h"
215
-
216
-#define DATA_SIZE 4
217
-#include "exec/cpu_ldst_template.h"
218
-
219
-#define DATA_SIZE 8
220
-#include "exec/cpu_ldst_template.h"
221
-#undef CPU_MMU_INDEX
222
-#undef MEMSUFFIX
223
-#endif /* (NB_MMU_MODES >= 11) */
224
-
225
-#if (NB_MMU_MODES >= 12) && defined(MMU_MODE11_SUFFIX)
226
-
227
-#define CPU_MMU_INDEX 11
228
-#define MEMSUFFIX MMU_MODE11_SUFFIX
229
-#define DATA_SIZE 1
230
-#include "exec/cpu_ldst_template.h"
231
-
232
-#define DATA_SIZE 2
233
-#include "exec/cpu_ldst_template.h"
234
-
235
-#define DATA_SIZE 4
236
-#include "exec/cpu_ldst_template.h"
237
-
238
-#define DATA_SIZE 8
239
-#include "exec/cpu_ldst_template.h"
240
-#undef CPU_MMU_INDEX
241
-#undef MEMSUFFIX
242
-#endif /* (NB_MMU_MODES >= 12) */
243
-
244
-#if (NB_MMU_MODES > 12)
245
-#error "NB_MMU_MODES > 12 is not supported for now"
246
-#endif /* (NB_MMU_MODES > 12) */
247
-
248
/* these access are slower, they must be as rare as possible */
249
#define CPU_MMU_INDEX (cpu_mmu_index(env, false))
250
#define MEMSUFFIX _data
251
--
76
--
252
2.20.1
77
2.43.0
253
254
diff view generated by jsdifflib
1
The functions generated by these macros are unused.
1
Merge the two conditions, sign != 0 && !(z_mask & sign),
2
by testing ~z_mask & sign. If sign == 0, the logical and
3
will produce false.
2
4
3
Cc: Guan Xuetao <gxt@mprc.pku.edu.cn>
5
Reviewed-by: Pierrick Bouvier <pierrick.bouvier@linaro.org>
4
Tested-by: Philippe Mathieu-Daudé <philmd@redhat.com>
5
Reviewed-by: Alex Bennée <alex.bennee@linaro.org>
6
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
6
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
7
---
7
---
8
target/unicore32/cpu.h | 2 --
8
tcg/optimize.c | 5 ++---
9
1 file changed, 2 deletions(-)
9
1 file changed, 2 insertions(+), 3 deletions(-)
10
10
11
diff --git a/target/unicore32/cpu.h b/target/unicore32/cpu.h
11
diff --git a/tcg/optimize.c b/tcg/optimize.c
12
index XXXXXXX..XXXXXXX 100644
12
index XXXXXXX..XXXXXXX 100644
13
--- a/target/unicore32/cpu.h
13
--- a/tcg/optimize.c
14
+++ b/target/unicore32/cpu.h
14
+++ b/tcg/optimize.c
15
@@ -XXX,XX +XXX,XX @@ void cpu_asr_write(CPUUniCore32State *env1, target_ulong val, target_ulong mask)
15
@@ -XXX,XX +XXX,XX @@ static bool fold_sextract(OptContext *ctx, TCGOp *op)
16
int uc32_cpu_signal_handler(int host_signum, void *pinfo, void *puc);
16
17
17
static bool fold_shift(OptContext *ctx, TCGOp *op)
18
/* MMU modes definitions */
19
-#define MMU_MODE0_SUFFIX _kernel
20
-#define MMU_MODE1_SUFFIX _user
21
#define MMU_USER_IDX 1
22
static inline int cpu_mmu_index(CPUUniCore32State *env, bool ifetch)
23
{
18
{
19
- uint64_t s_mask, z_mask, sign;
20
+ uint64_t s_mask, z_mask;
21
TempOptInfo *t1, *t2;
22
23
if (fold_const2(ctx, op) ||
24
@@ -XXX,XX +XXX,XX @@ static bool fold_shift(OptContext *ctx, TCGOp *op)
25
* If the sign bit is known zero, then logical right shift
26
* will not reduce the number of input sign repetitions.
27
*/
28
- sign = -s_mask;
29
- if (sign && !(z_mask & sign)) {
30
+ if (~z_mask & -s_mask) {
31
return fold_masks_s(ctx, op, s_mask);
32
}
33
break;
24
--
34
--
25
2.20.1
35
2.43.0
26
27
diff view generated by jsdifflib
1
There is nothing about these options that is related to PIE.
1
Duplicate fold_sub_vec into fold_sub instead of calling it,
2
Use them unconditionally.
2
now that fold_sub_vec always returns true.
3
3
4
Reviewed-by: Alex Bennée <alex.bennee@linaro.org>
4
Reviewed-by: Pierrick Bouvier <pierrick.bouvier@linaro.org>
5
Reviewed-by: Fangrui Song <i@maskray.me>
6
Reviewed-by: Philippe Mathieu-Daudé <philmd@redhat.com>
7
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
5
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
8
---
6
---
9
v2: Do not split into two tests.
7
tcg/optimize.c | 9 ++++++---
10
---
11
configure | 9 ++++++---
12
1 file changed, 6 insertions(+), 3 deletions(-)
8
1 file changed, 6 insertions(+), 3 deletions(-)
13
9
14
diff --git a/configure b/configure
10
diff --git a/tcg/optimize.c b/tcg/optimize.c
15
index XXXXXXX..XXXXXXX 100755
11
index XXXXXXX..XXXXXXX 100644
16
--- a/configure
12
--- a/tcg/optimize.c
17
+++ b/configure
13
+++ b/tcg/optimize.c
18
@@ -XXX,XX +XXX,XX @@ if test "$pie" != "no" ; then
14
@@ -XXX,XX +XXX,XX @@ static bool fold_sub_vec(OptContext *ctx, TCGOp *op)
19
QEMU_CFLAGS="-fPIE -DPIE $QEMU_CFLAGS"
15
fold_sub_to_neg(ctx, op)) {
20
LDFLAGS="-pie $LDFLAGS"
16
return true;
21
pie="yes"
17
}
22
- if compile_prog "" "-Wl,-z,relro -Wl,-z,now" ; then
18
- return false;
23
- LDFLAGS="-Wl,-z,relro -Wl,-z,now $LDFLAGS"
19
+ return finish_folding(ctx, op);
24
- fi
20
}
25
else
21
26
if test "$pie" = "yes"; then
22
static bool fold_sub(OptContext *ctx, TCGOp *op)
27
error_exit "PIE not available due to missing toolchain support"
23
{
28
@@ -XXX,XX +XXX,XX @@ if test "$pie" != "no" ; then
24
- if (fold_const2(ctx, op) || fold_sub_vec(ctx, op)) {
29
fi
25
+ if (fold_const2(ctx, op) ||
30
fi
26
+ fold_xx_to_i(ctx, op, 0) ||
31
27
+ fold_xi_to_x(ctx, op, 0) ||
32
+# Detect support for PT_GNU_RELRO + DT_BIND_NOW.
28
+ fold_sub_to_neg(ctx, op)) {
33
+# The combination is known as "full relro", because .got.plt is read-only too.
29
return true;
34
+if compile_prog "" "-Wl,-z,relro -Wl,-z,now" ; then
30
}
35
+ LDFLAGS="-Wl,-z,relro -Wl,-z,now $LDFLAGS"
31
36
+fi
32
@@ -XXX,XX +XXX,XX @@ static bool fold_sub(OptContext *ctx, TCGOp *op)
37
+
33
? INDEX_op_add_i32 : INDEX_op_add_i64);
38
##########################################
34
op->args[2] = arg_new_constant(ctx, -val);
39
# __sync_fetch_and_and requires at least -march=i486. Many toolchains
35
}
40
# use i686 as default anyway, but for those that don't, an explicit
36
- return false;
37
+ return finish_folding(ctx, op);
38
}
39
40
static bool fold_sub2(OptContext *ctx, TCGOp *op)
41
--
41
--
42
2.20.1
42
2.43.0
43
44
diff view generated by jsdifflib
1
The functions generated by these macros are unused.
1
Avoid the use of the OptContext slots.
2
2
3
Tested-by: Philippe Mathieu-Daudé <philmd@redhat.com>
3
Reviewed-by: Pierrick Bouvier <pierrick.bouvier@linaro.org>
4
Acked-by: Max Filippov <jcmvbkbc@gmail.com>
5
Reviewed-by: Alex Bennée <alex.bennee@linaro.org>
6
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
4
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
7
---
5
---
8
target/xtensa/cpu.h | 4 ----
6
tcg/optimize.c | 16 +++++++++-------
9
1 file changed, 4 deletions(-)
7
1 file changed, 9 insertions(+), 7 deletions(-)
10
8
11
diff --git a/target/xtensa/cpu.h b/target/xtensa/cpu.h
9
diff --git a/tcg/optimize.c b/tcg/optimize.c
12
index XXXXXXX..XXXXXXX 100644
10
index XXXXXXX..XXXXXXX 100644
13
--- a/target/xtensa/cpu.h
11
--- a/tcg/optimize.c
14
+++ b/target/xtensa/cpu.h
12
+++ b/tcg/optimize.c
15
@@ -XXX,XX +XXX,XX @@ static inline uint32_t xtensa_replicate_windowstart(CPUXtensaState *env)
13
@@ -XXX,XX +XXX,XX @@ static bool fold_sub2(OptContext *ctx, TCGOp *op)
14
15
static bool fold_tcg_ld(OptContext *ctx, TCGOp *op)
16
{
17
+ uint64_t z_mask = -1, s_mask = 0;
18
+
19
/* We can't do any folding with a load, but we can record bits. */
20
switch (op->opc) {
21
CASE_OP_32_64(ld8s):
22
- ctx->s_mask = MAKE_64BIT_MASK(8, 56);
23
+ s_mask = INT8_MIN;
24
break;
25
CASE_OP_32_64(ld8u):
26
- ctx->z_mask = MAKE_64BIT_MASK(0, 8);
27
+ z_mask = MAKE_64BIT_MASK(0, 8);
28
break;
29
CASE_OP_32_64(ld16s):
30
- ctx->s_mask = MAKE_64BIT_MASK(16, 48);
31
+ s_mask = INT16_MIN;
32
break;
33
CASE_OP_32_64(ld16u):
34
- ctx->z_mask = MAKE_64BIT_MASK(0, 16);
35
+ z_mask = MAKE_64BIT_MASK(0, 16);
36
break;
37
case INDEX_op_ld32s_i64:
38
- ctx->s_mask = MAKE_64BIT_MASK(32, 32);
39
+ s_mask = INT32_MIN;
40
break;
41
case INDEX_op_ld32u_i64:
42
- ctx->z_mask = MAKE_64BIT_MASK(0, 32);
43
+ z_mask = MAKE_64BIT_MASK(0, 32);
44
break;
45
default:
46
g_assert_not_reached();
47
}
48
- return false;
49
+ return fold_masks_zs(ctx, op, z_mask, s_mask);
16
}
50
}
17
51
18
/* MMU modes definitions */
52
static bool fold_tcg_ld_memcopy(OptContext *ctx, TCGOp *op)
19
-#define MMU_MODE0_SUFFIX _ring0
20
-#define MMU_MODE1_SUFFIX _ring1
21
-#define MMU_MODE2_SUFFIX _ring2
22
-#define MMU_MODE3_SUFFIX _ring3
23
#define MMU_USER_IDX 3
24
25
static inline int cpu_mmu_index(CPUXtensaState *env, bool ifetch)
26
--
53
--
27
2.20.1
54
2.43.0
28
29
diff view generated by jsdifflib
1
The commentary talks about "in concert with the addresses
1
Reviewed-by: Pierrick Bouvier <pierrick.bouvier@linaro.org>
2
assigned in the relevant linker script", except there is no
3
linker script for softmmu, nor has there been for some time.
4
5
(Do not confuse the user-only linker script editing that was
6
removed in the previous patch, because user-only does not
7
use this code_gen_buffer allocation method.)
8
9
Reviewed-by: Alex Bennée <alex.bennee@linaro.org>
10
Reviewed-by: Thomas Huth <thuth@redhat.com>
11
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
2
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
12
---
3
---
13
accel/tcg/translate-all.c | 37 +++++--------------------------------
4
tcg/optimize.c | 2 +-
14
1 file changed, 5 insertions(+), 32 deletions(-)
5
1 file changed, 1 insertion(+), 1 deletion(-)
15
6
16
diff --git a/accel/tcg/translate-all.c b/accel/tcg/translate-all.c
7
diff --git a/tcg/optimize.c b/tcg/optimize.c
17
index XXXXXXX..XXXXXXX 100644
8
index XXXXXXX..XXXXXXX 100644
18
--- a/accel/tcg/translate-all.c
9
--- a/tcg/optimize.c
19
+++ b/accel/tcg/translate-all.c
10
+++ b/tcg/optimize.c
20
@@ -XXX,XX +XXX,XX @@ static inline void *alloc_code_gen_buffer(void)
11
@@ -XXX,XX +XXX,XX @@ static bool fold_tcg_ld_memcopy(OptContext *ctx, TCGOp *op)
21
{
12
TCGType type;
22
int prot = PROT_WRITE | PROT_READ | PROT_EXEC;
13
23
int flags = MAP_PRIVATE | MAP_ANONYMOUS;
14
if (op->args[1] != tcgv_ptr_arg(tcg_env)) {
24
- uintptr_t start = 0;
15
- return false;
25
size_t size = tcg_ctx->code_gen_buffer_size;
16
+ return finish_folding(ctx, op);
26
void *buf;
27
28
- /* Constrain the position of the buffer based on the host cpu.
29
- Note that these addresses are chosen in concert with the
30
- addresses assigned in the relevant linker script file. */
31
-# if defined(__PIE__) || defined(__PIC__)
32
- /* Don't bother setting a preferred location if we're building
33
- a position-independent executable. We're more likely to get
34
- an address near the main executable if we let the kernel
35
- choose the address. */
36
-# elif defined(__x86_64__) && defined(MAP_32BIT)
37
- /* Force the memory down into low memory with the executable.
38
- Leave the choice of exact location with the kernel. */
39
- flags |= MAP_32BIT;
40
- /* Cannot expect to map more than 800MB in low memory. */
41
- if (size > 800u * 1024 * 1024) {
42
- tcg_ctx->code_gen_buffer_size = size = 800u * 1024 * 1024;
43
- }
44
-# elif defined(__sparc__)
45
- start = 0x40000000ul;
46
-# elif defined(__s390x__)
47
- start = 0x90000000ul;
48
-# elif defined(__mips__)
49
-# if _MIPS_SIM == _ABI64
50
- start = 0x128000000ul;
51
-# else
52
- start = 0x08000000ul;
53
-# endif
54
-# endif
55
-
56
- buf = mmap((void *)start, size, prot, flags, -1, 0);
57
+ buf = mmap(NULL, size, prot, flags, -1, 0);
58
if (buf == MAP_FAILED) {
59
return NULL;
60
}
17
}
61
18
62
#ifdef __mips__
19
type = ctx->type;
63
if (cross_256mb(buf, size)) {
64
- /* Try again, with the original still mapped, to avoid re-acquiring
65
- that 256mb crossing. This time don't specify an address. */
66
+ /*
67
+ * Try again, with the original still mapped, to avoid re-acquiring
68
+ * the same 256mb crossing.
69
+ */
70
size_t size2;
71
void *buf2 = mmap(NULL, size, prot, flags, -1, 0);
72
switch ((int)(buf2 != MAP_FAILED)) {
73
--
20
--
74
2.20.1
21
2.43.0
75
76
diff view generated by jsdifflib
1
The CFLAGS_NOPIE and LDFLAGS_NOPIE variables are used
1
Avoid the use of the OptContext slots. Find TempOptInfo once.
2
in pc-bios/optionrom/Makefile, which has nothing to do
2
Remove fold_masks as the function becomes unused.
3
with the PIE setting of the main qemu executables.
4
3
5
This overrides any operating system default to build
4
Reviewed-by: Pierrick Bouvier <pierrick.bouvier@linaro.org>
6
all executables as PIE, which is important for ROMs.
7
8
Reviewed-by: Philippe Mathieu-Daudé <philmd@redhat.com>
9
Reviewed-by: Thomas Huth <thuth@redhat.com>
10
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
5
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
11
---
6
---
12
configure | 18 ++++++++----------
7
tcg/optimize.c | 18 ++++++++----------
13
1 file changed, 8 insertions(+), 10 deletions(-)
8
1 file changed, 8 insertions(+), 10 deletions(-)
14
9
15
diff --git a/configure b/configure
10
diff --git a/tcg/optimize.c b/tcg/optimize.c
16
index XXXXXXX..XXXXXXX 100755
11
index XXXXXXX..XXXXXXX 100644
17
--- a/configure
12
--- a/tcg/optimize.c
18
+++ b/configure
13
+++ b/tcg/optimize.c
19
@@ -XXX,XX +XXX,XX @@ if ! compile_prog "-Werror" "" ; then
14
@@ -XXX,XX +XXX,XX @@ static bool fold_masks_s(OptContext *ctx, TCGOp *op, uint64_t s_mask)
20
    "Thread-Local Storage (TLS). Please upgrade to a version that does."
15
return fold_masks_zs(ctx, op, -1, s_mask);
21
fi
16
}
22
17
23
-if test "$pie" != "no" ; then
18
-static bool fold_masks(OptContext *ctx, TCGOp *op)
24
- cat > $TMPC << EOF
19
-{
25
+cat > $TMPC << EOF
20
- return fold_masks_zs(ctx, op, ctx->z_mask, ctx->s_mask);
26
21
-}
27
#ifdef __linux__
28
# define THREAD __thread
29
#else
30
# define THREAD
31
#endif
32
-
22
-
33
static THREAD int tls_var;
23
/*
34
-
24
* An "affected" mask bit is 0 if and only if the result is identical
35
int main(void) { return tls_var; }
25
* to the first input. Thus if the entire mask is 0, the operation
36
-
26
@@ -XXX,XX +XXX,XX @@ static bool fold_tcg_st_memcopy(OptContext *ctx, TCGOp *op)
37
EOF
27
38
- # check we support --no-pie first...
28
static bool fold_xor(OptContext *ctx, TCGOp *op)
39
- if compile_prog "-Werror -fno-pie" "-no-pie"; then
29
{
40
- CFLAGS_NOPIE="-fno-pie"
30
+ uint64_t z_mask, s_mask;
41
- LDFLAGS_NOPIE="-nopie"
31
+ TempOptInfo *t1, *t2;
42
- fi
43
44
+# Check we support --no-pie first; we will need this for building ROMs.
45
+if compile_prog "-Werror -fno-pie" "-no-pie"; then
46
+ CFLAGS_NOPIE="-fno-pie"
47
+ LDFLAGS_NOPIE="-no-pie"
48
+fi
49
+
32
+
50
+if test "$pie" != "no" ; then
33
if (fold_const2_commutative(ctx, op) ||
51
if compile_prog "-fPIE -DPIE" "-pie"; then
34
fold_xx_to_i(ctx, op, 0) ||
52
QEMU_CFLAGS="-fPIE -DPIE $QEMU_CFLAGS"
35
fold_xi_to_x(ctx, op, 0) ||
53
LDFLAGS="-pie $LDFLAGS"
36
@@ -XXX,XX +XXX,XX @@ static bool fold_xor(OptContext *ctx, TCGOp *op)
37
return true;
38
}
39
40
- ctx->z_mask = arg_info(op->args[1])->z_mask
41
- | arg_info(op->args[2])->z_mask;
42
- ctx->s_mask = arg_info(op->args[1])->s_mask
43
- & arg_info(op->args[2])->s_mask;
44
- return fold_masks(ctx, op);
45
+ t1 = arg_info(op->args[1]);
46
+ t2 = arg_info(op->args[2]);
47
+ z_mask = t1->z_mask | t2->z_mask;
48
+ s_mask = t1->s_mask & t2->s_mask;
49
+ return fold_masks_zs(ctx, op, z_mask, s_mask);
50
}
51
52
static bool fold_bitsel_vec(OptContext *ctx, TCGOp *op)
54
--
53
--
55
2.20.1
54
2.43.0
56
57
diff view generated by jsdifflib
1
The functions generated by these macros are unused.
1
Reviewed-by: Pierrick Bouvier <pierrick.bouvier@linaro.org>
2
3
Cc: Aurelien Jarno <aurelien@aurel32.net>
4
Tested-by: Philippe Mathieu-Daudé <philmd@redhat.com>
5
Reviewed-by: Alex Bennée <alex.bennee@linaro.org>
6
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
2
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
7
---
3
---
8
target/sh4/cpu.h | 2 --
4
tcg/optimize.c | 2 +-
9
1 file changed, 2 deletions(-)
5
1 file changed, 1 insertion(+), 1 deletion(-)
10
6
11
diff --git a/target/sh4/cpu.h b/target/sh4/cpu.h
7
diff --git a/tcg/optimize.c b/tcg/optimize.c
12
index XXXXXXX..XXXXXXX 100644
8
index XXXXXXX..XXXXXXX 100644
13
--- a/target/sh4/cpu.h
9
--- a/tcg/optimize.c
14
+++ b/target/sh4/cpu.h
10
+++ b/tcg/optimize.c
15
@@ -XXX,XX +XXX,XX @@ void cpu_load_tlb(CPUSH4State * env);
11
@@ -XXX,XX +XXX,XX @@ static bool fold_bitsel_vec(OptContext *ctx, TCGOp *op)
16
#define cpu_list sh4_cpu_list
12
return fold_orc(ctx, op);
17
13
}
18
/* MMU modes definitions */
14
}
19
-#define MMU_MODE0_SUFFIX _kernel
15
- return false;
20
-#define MMU_MODE1_SUFFIX _user
16
+ return finish_folding(ctx, op);
21
#define MMU_USER_IDX 1
17
}
22
static inline int cpu_mmu_index (CPUSH4State *env, bool ifetch)
18
23
{
19
/* Propagate constants and copies, fold constant expressions. */
24
--
20
--
25
2.20.1
21
2.43.0
26
27
diff view generated by jsdifflib
1
There are only two uses. Within dcbz_common, the local variable
1
All non-default cases now finish folding within each function.
2
mmu_idx already contains the epid computation, and we can avoid
2
Do the same with the default case and assert it is done after.
3
repeating it for the store. Within helper_icbiep, the usage is
4
trivially expanded using PPC_TLB_EPID_LOAD.
5
3
6
Tested-by: Philippe Mathieu-Daudé <philmd@redhat.com>
4
Reviewed-by: Pierrick Bouvier <pierrick.bouvier@linaro.org>
7
Acked-by: David Gibson <david@gibson.dropbear.id.au>
8
Reviewed-by: Alex Bennée <alex.bennee@linaro.org>
9
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
5
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
10
---
6
---
11
target/ppc/cpu.h | 2 --
7
tcg/optimize.c | 6 ++----
12
target/ppc/mem_helper.c | 11 ++---------
8
1 file changed, 2 insertions(+), 4 deletions(-)
13
2 files changed, 2 insertions(+), 11 deletions(-)
14
9
15
diff --git a/target/ppc/cpu.h b/target/ppc/cpu.h
10
diff --git a/tcg/optimize.c b/tcg/optimize.c
16
index XXXXXXX..XXXXXXX 100644
11
index XXXXXXX..XXXXXXX 100644
17
--- a/target/ppc/cpu.h
12
--- a/tcg/optimize.c
18
+++ b/target/ppc/cpu.h
13
+++ b/tcg/optimize.c
19
@@ -XXX,XX +XXX,XX @@ struct ppc_radix_page_info {
14
@@ -XXX,XX +XXX,XX @@ void tcg_optimize(TCGContext *s)
20
* + real/paged mode combinations. The other two modes are for
15
done = true;
21
* external PID load/store.
16
break;
22
*/
17
default:
23
-#define MMU_MODE8_SUFFIX _epl
18
+ done = finish_folding(&ctx, op);
24
-#define MMU_MODE9_SUFFIX _eps
19
break;
25
#define PPC_TLB_EPID_LOAD 8
26
#define PPC_TLB_EPID_STORE 9
27
28
diff --git a/target/ppc/mem_helper.c b/target/ppc/mem_helper.c
29
index XXXXXXX..XXXXXXX 100644
30
--- a/target/ppc/mem_helper.c
31
+++ b/target/ppc/mem_helper.c
32
@@ -XXX,XX +XXX,XX @@ static void dcbz_common(CPUPPCState *env, target_ulong addr,
33
} else {
34
/* Slow path */
35
for (i = 0; i < dcbz_size; i += 8) {
36
- if (epid) {
37
-#if !defined(CONFIG_USER_ONLY)
38
- /* Does not make sense on USER_ONLY config */
39
- cpu_stq_eps_ra(env, addr + i, 0, retaddr);
40
-#endif
41
- } else {
42
- cpu_stq_data_ra(env, addr + i, 0, retaddr);
43
- }
44
+ cpu_stq_mmuidx_ra(env, addr + i, 0, mmu_idx, retaddr);
45
}
20
}
21
-
22
- if (!done) {
23
- finish_folding(&ctx, op);
24
- }
25
+ tcg_debug_assert(done);
46
}
26
}
47
}
27
}
48
@@ -XXX,XX +XXX,XX @@ void helper_icbiep(CPUPPCState *env, target_ulong addr)
49
#if !defined(CONFIG_USER_ONLY)
50
/* See comments above */
51
addr &= ~(env->dcache_line_size - 1);
52
- cpu_ldl_epl_ra(env, addr, GETPC());
53
+ cpu_ldl_mmuidx_ra(env, addr, PPC_TLB_EPID_LOAD, GETPC());
54
#endif
55
}
56
57
--
28
--
58
2.20.1
29
2.43.0
59
60
diff view generated by jsdifflib
1
The functions generated by these macros are unused.
1
All mask setting is now done with parameters via fold_masks_*.
2
2
3
Cc: Edgar E. Iglesias <edgar.iglesias@gmail.com>
3
Reviewed-by: Pierrick Bouvier <pierrick.bouvier@linaro.org>
4
Tested-by: Philippe Mathieu-Daudé <philmd@redhat.com>
5
Reviewed-by: Alex Bennée <alex.bennee@linaro.org>
6
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
4
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
7
---
5
---
8
target/microblaze/cpu.h | 3 ---
6
tcg/optimize.c | 13 -------------
9
1 file changed, 3 deletions(-)
7
1 file changed, 13 deletions(-)
10
8
11
diff --git a/target/microblaze/cpu.h b/target/microblaze/cpu.h
9
diff --git a/tcg/optimize.c b/tcg/optimize.c
12
index XXXXXXX..XXXXXXX 100644
10
index XXXXXXX..XXXXXXX 100644
13
--- a/target/microblaze/cpu.h
11
--- a/tcg/optimize.c
14
+++ b/target/microblaze/cpu.h
12
+++ b/tcg/optimize.c
15
@@ -XXX,XX +XXX,XX @@ int cpu_mb_signal_handler(int host_signum, void *pinfo,
13
@@ -XXX,XX +XXX,XX @@ typedef struct OptContext {
16
#define cpu_signal_handler cpu_mb_signal_handler
14
QSIMPLEQ_HEAD(, MemCopyInfo) mem_free;
17
15
18
/* MMU modes definitions */
16
/* In flight values from optimization. */
19
-#define MMU_MODE0_SUFFIX _nommu
17
- uint64_t z_mask; /* mask bit is 0 iff value bit is 0 */
20
-#define MMU_MODE1_SUFFIX _kernel
18
- uint64_t s_mask; /* mask bit is 1 if value bit matches msb */
21
-#define MMU_MODE2_SUFFIX _user
19
TCGType type;
22
#define MMU_NOMMU_IDX 0
20
} OptContext;
23
#define MMU_KERNEL_IDX 1
21
24
#define MMU_USER_IDX 2
22
@@ -XXX,XX +XXX,XX @@ static bool finish_folding(OptContext *ctx, TCGOp *op)
23
for (i = 0; i < nb_oargs; i++) {
24
TCGTemp *ts = arg_temp(op->args[i]);
25
reset_ts(ctx, ts);
26
- /*
27
- * Save the corresponding known-zero/sign bits mask for the
28
- * first output argument (only one supported so far).
29
- */
30
- if (i == 0) {
31
- ts_info(ts)->z_mask = ctx->z_mask;
32
- }
33
}
34
return true;
35
}
36
@@ -XXX,XX +XXX,XX @@ void tcg_optimize(TCGContext *s)
37
ctx.type = TCG_TYPE_I32;
38
}
39
40
- /* Assume all bits affected, no bits known zero, no sign reps. */
41
- ctx.z_mask = -1;
42
- ctx.s_mask = 0;
43
-
44
/*
45
* Process each opcode.
46
* Sorted alphabetically by opcode as much as possible.
25
--
47
--
26
2.20.1
48
2.43.0
27
28
diff view generated by jsdifflib
1
Code movement in an upcoming patch will show that this file
1
All instances of s_mask have been converted to the new
2
was implicitly depending on trace/mem.h being included beforehand.
2
representation. We can now re-enable usage.
3
3
4
Tested-by: Philippe Mathieu-Daudé <philmd@redhat.com>
4
Reviewed-by: Pierrick Bouvier <pierrick.bouvier@linaro.org>
5
Reviewed-by: Philippe Mathieu-Daudé <philmd@redhat.com>
6
Reported-by: Alex Bennée <alex.bennee@linaro.org>
7
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
5
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
8
---
6
---
9
plugins/api.c | 1 +
7
tcg/optimize.c | 4 ++--
10
1 file changed, 1 insertion(+)
8
1 file changed, 2 insertions(+), 2 deletions(-)
11
9
12
diff --git a/plugins/api.c b/plugins/api.c
10
diff --git a/tcg/optimize.c b/tcg/optimize.c
13
index XXXXXXX..XXXXXXX 100644
11
index XXXXXXX..XXXXXXX 100644
14
--- a/plugins/api.c
12
--- a/tcg/optimize.c
15
+++ b/plugins/api.c
13
+++ b/tcg/optimize.c
16
@@ -XXX,XX +XXX,XX @@
14
@@ -XXX,XX +XXX,XX @@ static bool fold_exts(OptContext *ctx, TCGOp *op)
17
#include "qemu/plugin-memory.h"
15
g_assert_not_reached();
18
#include "hw/boards.h"
16
}
19
#endif
17
20
+#include "trace/mem.h"
18
- if (0 && !type_change && fold_affected_mask(ctx, op, s_mask & ~s_mask_old)) {
21
19
+ if (!type_change && fold_affected_mask(ctx, op, s_mask & ~s_mask_old)) {
22
/* Uninstall and Reset handlers */
20
return true;
21
}
22
23
@@ -XXX,XX +XXX,XX @@ static bool fold_sextract(OptContext *ctx, TCGOp *op)
24
s_mask = s_mask_old >> pos;
25
s_mask |= -1ull << (len - 1);
26
27
- if (0 && pos == 0 && fold_affected_mask(ctx, op, s_mask & ~s_mask_old)) {
28
+ if (pos == 0 && fold_affected_mask(ctx, op, s_mask & ~s_mask_old)) {
29
return true;
30
}
23
31
24
--
32
--
25
2.20.1
33
2.43.0
26
27
diff view generated by jsdifflib
1
The functions generated by these macros are unused.
1
The big comment just above says functions should be sorted.
2
Add forward declarations as needed.
2
3
3
Cc: Edgar E. Iglesias <edgar.iglesias@gmail.com>
4
Reviewed-by: Pierrick Bouvier <pierrick.bouvier@linaro.org>
4
Tested-by: Philippe Mathieu-Daudé <philmd@redhat.com>
5
Reviewed-by: Alex Bennée <alex.bennee@linaro.org>
6
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
5
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
7
---
6
---
8
target/cris/cpu.h | 2 --
7
tcg/optimize.c | 114 +++++++++++++++++++++++++------------------------
9
1 file changed, 2 deletions(-)
8
1 file changed, 59 insertions(+), 55 deletions(-)
10
9
11
diff --git a/target/cris/cpu.h b/target/cris/cpu.h
10
diff --git a/tcg/optimize.c b/tcg/optimize.c
12
index XXXXXXX..XXXXXXX 100644
11
index XXXXXXX..XXXXXXX 100644
13
--- a/target/cris/cpu.h
12
--- a/tcg/optimize.c
14
+++ b/target/cris/cpu.h
13
+++ b/tcg/optimize.c
15
@@ -XXX,XX +XXX,XX @@ enum {
14
@@ -XXX,XX +XXX,XX @@ static bool fold_xx_to_x(OptContext *ctx, TCGOp *op)
16
#define cpu_signal_handler cpu_cris_signal_handler
15
* 3) those that produce information about the result value.
17
16
*/
18
/* MMU modes definitions */
17
19
-#define MMU_MODE0_SUFFIX _kernel
18
+static bool fold_or(OptContext *ctx, TCGOp *op);
20
-#define MMU_MODE1_SUFFIX _user
19
+static bool fold_orc(OptContext *ctx, TCGOp *op);
21
#define MMU_USER_IDX 1
20
+static bool fold_xor(OptContext *ctx, TCGOp *op);
22
static inline int cpu_mmu_index (CPUCRISState *env, bool ifetch)
21
+
22
static bool fold_add(OptContext *ctx, TCGOp *op)
23
{
24
if (fold_const2_commutative(ctx, op) ||
25
@@ -XXX,XX +XXX,XX @@ static bool fold_andc(OptContext *ctx, TCGOp *op)
26
return fold_masks_zs(ctx, op, z_mask, s_mask);
27
}
28
29
+static bool fold_bitsel_vec(OptContext *ctx, TCGOp *op)
30
+{
31
+ /* If true and false values are the same, eliminate the cmp. */
32
+ if (args_are_copies(op->args[2], op->args[3])) {
33
+ return tcg_opt_gen_mov(ctx, op, op->args[0], op->args[2]);
34
+ }
35
+
36
+ if (arg_is_const(op->args[2]) && arg_is_const(op->args[3])) {
37
+ uint64_t tv = arg_info(op->args[2])->val;
38
+ uint64_t fv = arg_info(op->args[3])->val;
39
+
40
+ if (tv == -1 && fv == 0) {
41
+ return tcg_opt_gen_mov(ctx, op, op->args[0], op->args[1]);
42
+ }
43
+ if (tv == 0 && fv == -1) {
44
+ if (TCG_TARGET_HAS_not_vec) {
45
+ op->opc = INDEX_op_not_vec;
46
+ return fold_not(ctx, op);
47
+ } else {
48
+ op->opc = INDEX_op_xor_vec;
49
+ op->args[2] = arg_new_constant(ctx, -1);
50
+ return fold_xor(ctx, op);
51
+ }
52
+ }
53
+ }
54
+ if (arg_is_const(op->args[2])) {
55
+ uint64_t tv = arg_info(op->args[2])->val;
56
+ if (tv == -1) {
57
+ op->opc = INDEX_op_or_vec;
58
+ op->args[2] = op->args[3];
59
+ return fold_or(ctx, op);
60
+ }
61
+ if (tv == 0 && TCG_TARGET_HAS_andc_vec) {
62
+ op->opc = INDEX_op_andc_vec;
63
+ op->args[2] = op->args[1];
64
+ op->args[1] = op->args[3];
65
+ return fold_andc(ctx, op);
66
+ }
67
+ }
68
+ if (arg_is_const(op->args[3])) {
69
+ uint64_t fv = arg_info(op->args[3])->val;
70
+ if (fv == 0) {
71
+ op->opc = INDEX_op_and_vec;
72
+ return fold_and(ctx, op);
73
+ }
74
+ if (fv == -1 && TCG_TARGET_HAS_orc_vec) {
75
+ op->opc = INDEX_op_orc_vec;
76
+ op->args[2] = op->args[1];
77
+ op->args[1] = op->args[3];
78
+ return fold_orc(ctx, op);
79
+ }
80
+ }
81
+ return finish_folding(ctx, op);
82
+}
83
+
84
static bool fold_brcond(OptContext *ctx, TCGOp *op)
85
{
86
int i = do_constant_folding_cond1(ctx, op, NO_DEST, &op->args[0],
87
@@ -XXX,XX +XXX,XX @@ static bool fold_xor(OptContext *ctx, TCGOp *op)
88
return fold_masks_zs(ctx, op, z_mask, s_mask);
89
}
90
91
-static bool fold_bitsel_vec(OptContext *ctx, TCGOp *op)
92
-{
93
- /* If true and false values are the same, eliminate the cmp. */
94
- if (args_are_copies(op->args[2], op->args[3])) {
95
- return tcg_opt_gen_mov(ctx, op, op->args[0], op->args[2]);
96
- }
97
-
98
- if (arg_is_const(op->args[2]) && arg_is_const(op->args[3])) {
99
- uint64_t tv = arg_info(op->args[2])->val;
100
- uint64_t fv = arg_info(op->args[3])->val;
101
-
102
- if (tv == -1 && fv == 0) {
103
- return tcg_opt_gen_mov(ctx, op, op->args[0], op->args[1]);
104
- }
105
- if (tv == 0 && fv == -1) {
106
- if (TCG_TARGET_HAS_not_vec) {
107
- op->opc = INDEX_op_not_vec;
108
- return fold_not(ctx, op);
109
- } else {
110
- op->opc = INDEX_op_xor_vec;
111
- op->args[2] = arg_new_constant(ctx, -1);
112
- return fold_xor(ctx, op);
113
- }
114
- }
115
- }
116
- if (arg_is_const(op->args[2])) {
117
- uint64_t tv = arg_info(op->args[2])->val;
118
- if (tv == -1) {
119
- op->opc = INDEX_op_or_vec;
120
- op->args[2] = op->args[3];
121
- return fold_or(ctx, op);
122
- }
123
- if (tv == 0 && TCG_TARGET_HAS_andc_vec) {
124
- op->opc = INDEX_op_andc_vec;
125
- op->args[2] = op->args[1];
126
- op->args[1] = op->args[3];
127
- return fold_andc(ctx, op);
128
- }
129
- }
130
- if (arg_is_const(op->args[3])) {
131
- uint64_t fv = arg_info(op->args[3])->val;
132
- if (fv == 0) {
133
- op->opc = INDEX_op_and_vec;
134
- return fold_and(ctx, op);
135
- }
136
- if (fv == -1 && TCG_TARGET_HAS_orc_vec) {
137
- op->opc = INDEX_op_orc_vec;
138
- op->args[2] = op->args[1];
139
- op->args[1] = op->args[3];
140
- return fold_orc(ctx, op);
141
- }
142
- }
143
- return finish_folding(ctx, op);
144
-}
145
-
146
/* Propagate constants and copies, fold constant expressions. */
147
void tcg_optimize(TCGContext *s)
23
{
148
{
24
--
149
--
25
2.20.1
150
2.43.0
26
27
diff view generated by jsdifflib
1
This finishes the new interface began with the previous patch.
1
The big comment just above says functions should be sorted.
2
Document the interface and deprecate MMU_MODE<N>_SUFFIX.
3
2
4
Tested-by: Philippe Mathieu-Daudé <philmd@redhat.com>
3
Reviewed-by: Pierrick Bouvier <pierrick.bouvier@linaro.org>
5
Reviewed-by: Aleksandar Markovic <amarkovic@wavecomp.com>
6
Reviewed-by: Alex Bennée <alex.bennee@linaro.org>
7
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
4
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
8
---
5
---
9
include/exec/cpu_ldst.h | 80 +++++++++++++-
6
tcg/optimize.c | 60 +++++++++++++++++++++++++-------------------------
10
docs/devel/loads-stores.rst | 211 ++++++++++++++++++++++++++----------
7
1 file changed, 30 insertions(+), 30 deletions(-)
11
2 files changed, 230 insertions(+), 61 deletions(-)
12
8
13
diff --git a/include/exec/cpu_ldst.h b/include/exec/cpu_ldst.h
9
diff --git a/tcg/optimize.c b/tcg/optimize.c
14
index XXXXXXX..XXXXXXX 100644
10
index XXXXXXX..XXXXXXX 100644
15
--- a/include/exec/cpu_ldst.h
11
--- a/tcg/optimize.c
16
+++ b/include/exec/cpu_ldst.h
12
+++ b/tcg/optimize.c
17
@@ -XXX,XX +XXX,XX @@
13
@@ -XXX,XX +XXX,XX @@ static bool fold_call(OptContext *ctx, TCGOp *op)
18
*
14
return true;
19
* The syntax for the accessors is:
15
}
20
*
16
21
- * load: cpu_ld{sign}{size}_{mmusuffix}(env, ptr)
17
+static bool fold_cmp_vec(OptContext *ctx, TCGOp *op)
22
+ * load: cpu_ld{sign}{size}_{mmusuffix}(env, ptr)
23
+ * cpu_ld{sign}{size}_{mmusuffix}_ra(env, ptr, retaddr)
24
+ * cpu_ld{sign}{size}_mmuidx_ra(env, ptr, mmu_idx, retaddr)
25
*
26
- * store: cpu_st{sign}{size}_{mmusuffix}(env, ptr, val)
27
+ * store: cpu_st{size}_{mmusuffix}(env, ptr, val)
28
+ * cpu_st{size}_{mmusuffix}_ra(env, ptr, val, retaddr)
29
+ * cpu_st{size}_mmuidx_ra(env, ptr, val, mmu_idx, retaddr)
30
*
31
* sign is:
32
* (empty): for 32 and 64 bit sizes
33
@@ -XXX,XX +XXX,XX @@
34
* l: 32 bits
35
* q: 64 bits
36
*
37
- * mmusuffix is one of the generic suffixes "data" or "code", or
38
- * (for softmmu configs) a target-specific MMU mode suffix as defined
39
- * in target cpu.h.
40
+ * mmusuffix is one of the generic suffixes "data" or "code", or "mmuidx".
41
+ * The "mmuidx" suffix carries an extra mmu_idx argument that specifies
42
+ * the index to use; the "data" and "code" suffixes take the index from
43
+ * cpu_mmu_index().
44
*/
45
#ifndef CPU_LDST_H
46
#define CPU_LDST_H
47
@@ -XXX,XX +XXX,XX @@ static inline void clear_helper_retaddr(void)
48
#undef MEMSUFFIX
49
#undef CODE_ACCESS
50
51
+/*
52
+ * Provide the same *_mmuidx_ra interface as for softmmu.
53
+ * The mmu_idx argument is ignored.
54
+ */
55
+
56
+static inline uint32_t cpu_ldub_mmuidx_ra(CPUArchState *env, abi_ptr addr,
57
+ int mmu_idx, uintptr_t ra)
58
+{
18
+{
59
+ return cpu_ldub_data_ra(env, addr, ra);
19
+ /* Canonicalize the comparison to put immediate second. */
20
+ if (swap_commutative(NO_DEST, &op->args[1], &op->args[2])) {
21
+ op->args[3] = tcg_swap_cond(op->args[3]);
22
+ }
23
+ return finish_folding(ctx, op);
60
+}
24
+}
61
+
25
+
62
+static inline uint32_t cpu_lduw_mmuidx_ra(CPUArchState *env, abi_ptr addr,
26
+static bool fold_cmpsel_vec(OptContext *ctx, TCGOp *op)
63
+ int mmu_idx, uintptr_t ra)
64
+{
27
+{
65
+ return cpu_lduw_data_ra(env, addr, ra);
28
+ /* If true and false values are the same, eliminate the cmp. */
29
+ if (args_are_copies(op->args[3], op->args[4])) {
30
+ return tcg_opt_gen_mov(ctx, op, op->args[0], op->args[3]);
31
+ }
32
+
33
+ /* Canonicalize the comparison to put immediate second. */
34
+ if (swap_commutative(NO_DEST, &op->args[1], &op->args[2])) {
35
+ op->args[5] = tcg_swap_cond(op->args[5]);
36
+ }
37
+ /*
38
+ * Canonicalize the "false" input reg to match the destination,
39
+ * so that the tcg backend can implement "move if true".
40
+ */
41
+ if (swap_commutative(op->args[0], &op->args[4], &op->args[3])) {
42
+ op->args[5] = tcg_invert_cond(op->args[5]);
43
+ }
44
+ return finish_folding(ctx, op);
66
+}
45
+}
67
+
46
+
68
+static inline uint32_t cpu_ldl_mmuidx_ra(CPUArchState *env, abi_ptr addr,
47
static bool fold_count_zeros(OptContext *ctx, TCGOp *op)
69
+ int mmu_idx, uintptr_t ra)
48
{
70
+{
49
uint64_t z_mask, s_mask;
71
+ return cpu_ldl_data_ra(env, addr, ra);
50
@@ -XXX,XX +XXX,XX @@ static bool fold_setcond2(OptContext *ctx, TCGOp *op)
72
+}
51
return tcg_opt_gen_movi(ctx, op, op->args[0], i);
73
+
52
}
74
+static inline uint64_t cpu_ldq_mmuidx_ra(CPUArchState *env, abi_ptr addr,
53
75
+ int mmu_idx, uintptr_t ra)
54
-static bool fold_cmp_vec(OptContext *ctx, TCGOp *op)
76
+{
55
-{
77
+ return cpu_ldq_data_ra(env, addr, ra);
56
- /* Canonicalize the comparison to put immediate second. */
78
+}
57
- if (swap_commutative(NO_DEST, &op->args[1], &op->args[2])) {
79
+
58
- op->args[3] = tcg_swap_cond(op->args[3]);
80
+static inline int cpu_ldsb_mmuidx_ra(CPUArchState *env, abi_ptr addr,
59
- }
81
+ int mmu_idx, uintptr_t ra)
60
- return finish_folding(ctx, op);
82
+{
61
-}
83
+ return cpu_ldsb_data_ra(env, addr, ra);
84
+}
85
+
86
+static inline int cpu_ldsw_mmuidx_ra(CPUArchState *env, abi_ptr addr,
87
+ int mmu_idx, uintptr_t ra)
88
+{
89
+ return cpu_ldsw_data_ra(env, addr, ra);
90
+}
91
+
92
+static inline void cpu_stb_mmuidx_ra(CPUArchState *env, abi_ptr addr,
93
+ uint32_t val, int mmu_idx, uintptr_t ra)
94
+{
95
+ cpu_stb_data_ra(env, addr, val, ra);
96
+}
97
+
98
+static inline void cpu_stw_mmuidx_ra(CPUArchState *env, abi_ptr addr,
99
+ uint32_t val, int mmu_idx, uintptr_t ra)
100
+{
101
+ cpu_stw_data_ra(env, addr, val, ra);
102
+}
103
+
104
+static inline void cpu_stl_mmuidx_ra(CPUArchState *env, abi_ptr addr,
105
+ uint32_t val, int mmu_idx, uintptr_t ra)
106
+{
107
+ cpu_stl_data_ra(env, addr, val, ra);
108
+}
109
+
110
+static inline void cpu_stq_mmuidx_ra(CPUArchState *env, abi_ptr addr,
111
+ uint64_t val, int mmu_idx, uintptr_t ra)
112
+{
113
+ cpu_stq_data_ra(env, addr, val, ra);
114
+}
115
+
116
#else
117
118
/* Needed for TCG_OVERSIZED_GUEST */
119
diff --git a/docs/devel/loads-stores.rst b/docs/devel/loads-stores.rst
120
index XXXXXXX..XXXXXXX 100644
121
--- a/docs/devel/loads-stores.rst
122
+++ b/docs/devel/loads-stores.rst
123
@@ -XXX,XX +XXX,XX @@ Regexes for git grep
124
- ``\<ldn_\([hbl]e\)?_p\>``
125
- ``\<stn_\([hbl]e\)?_p\>``
126
127
-``cpu_{ld,st}_*``
128
-~~~~~~~~~~~~~~~~~
129
+``cpu_{ld,st}*_mmuidx_ra``
130
+~~~~~~~~~~~~~~~~~~~~~~~~~~
131
132
-These functions operate on a guest virtual address. Be aware
133
-that these functions may cause a guest CPU exception to be
134
-taken (e.g. for an alignment fault or MMU fault) which will
135
-result in guest CPU state being updated and control longjumping
136
-out of the function call. They should therefore only be used
137
-in code that is implementing emulation of the target CPU.
138
+These functions operate on a guest virtual address plus a context,
139
+known as a "mmu index" or ``mmuidx``, which controls how that virtual
140
+address is translated. The meaning of the indexes are target specific,
141
+but specifying a particular index might be necessary if, for instance,
142
+the helper requires an "always as non-privileged" access rather that
143
+the default access for the current state of the guest CPU.
144
145
-These functions may throw an exception (longjmp() back out
146
-to the top level TCG loop). This means they must only be used
147
-from helper functions where the translator has saved all
148
-necessary CPU state before generating the helper function call.
149
-It's usually better to use the ``_ra`` variants described below
150
-from helper functions, but these functions are the right choice
151
-for calls made from hooks like the CPU do_interrupt hook or
152
-when you know for certain that the translator had to save all
153
-the CPU state that ``cpu_restore_state()`` would restore anyway.
154
+These functions may cause a guest CPU exception to be taken
155
+(e.g. for an alignment fault or MMU fault) which will result in
156
+guest CPU state being updated and control longjmp'ing out of the
157
+function call. They should therefore only be used in code that is
158
+implementing emulation of the guest CPU.
159
+
160
+The ``retaddr`` parameter is used to control unwinding of the
161
+guest CPU state in case of a guest CPU exception. This is passed
162
+to ``cpu_restore_state()``. Therefore the value should either be 0,
163
+to indicate that the guest CPU state is already synchronized, or
164
+the result of ``GETPC()`` from the top level ``HELPER(foo)``
165
+function, which is a return address into the generated code.
166
167
Function names follow the pattern:
168
169
-load: ``cpu_ld{sign}{size}_{mmusuffix}(env, ptr)``
170
+load: ``cpu_ld{sign}{size}_mmuidx_ra(env, ptr, mmuidx, retaddr)``
171
172
-store: ``cpu_st{size}_{mmusuffix}(env, ptr, val)``
173
+store: ``cpu_st{size}_mmuidx_ra(env, ptr, val, mmuidx, retaddr)``
174
175
``sign``
176
- (empty) : for 32 or 64 bit sizes
177
@@ -XXX,XX +XXX,XX @@ store: ``cpu_st{size}_{mmusuffix}(env, ptr, val)``
178
- ``l`` : 32 bits
179
- ``q`` : 64 bits
180
181
-``mmusuffix`` is one of the generic suffixes ``data`` or ``code``, or
182
-(for softmmu configs) a target-specific MMU mode suffix as defined
183
-in the target's ``cpu.h``.
184
+Regexes for git grep:
185
+ - ``\<cpu_ld[us]\?[bwlq]_mmuidx_ra\>``
186
+ - ``\<cpu_st[bwlq]_mmuidx_ra\>``
187
188
-Regexes for git grep
189
- - ``\<cpu_ld[us]\?[bwlq]_[a-zA-Z0-9]\+\>``
190
- - ``\<cpu_st[bwlq]_[a-zA-Z0-9]\+\>``
191
+``cpu_{ld,st}*_data_ra``
192
+~~~~~~~~~~~~~~~~~~~~~~~~
193
194
-``cpu_{ld,st}_*_ra``
195
-~~~~~~~~~~~~~~~~~~~~
196
-
62
-
197
-These functions work like the ``cpu_{ld,st}_*`` functions except
63
-static bool fold_cmpsel_vec(OptContext *ctx, TCGOp *op)
198
-that they also take a ``retaddr`` argument. This extra argument
64
-{
199
-allows for correct unwinding of any exception that is taken,
65
- /* If true and false values are the same, eliminate the cmp. */
200
-and should generally be the result of GETPC() called directly
66
- if (args_are_copies(op->args[3], op->args[4])) {
201
-from the top level HELPER(foo) function (i.e. the return address
67
- return tcg_opt_gen_mov(ctx, op, op->args[0], op->args[3]);
202
-in the generated code).
68
- }
203
+These functions work like the ``cpu_{ld,st}_mmuidx_ra`` functions
204
+except that the ``mmuidx`` parameter is taken from the current mode
205
+of the guest CPU, as determined by ``cpu_mmu_index(env, false)``.
206
207
These are generally the preferred way to do accesses by guest
208
-virtual address from helper functions; see the documentation
209
-of the non-``_ra`` variants for when those would be better.
210
-
69
-
211
-Calling these functions with a ``retaddr`` argument of 0 is
70
- /* Canonicalize the comparison to put immediate second. */
212
-equivalent to calling the non-``_ra`` version of the function.
71
- if (swap_commutative(NO_DEST, &op->args[1], &op->args[2])) {
213
+virtual address from helper functions, unless the access should
72
- op->args[5] = tcg_swap_cond(op->args[5]);
214
+be performed with a context other than the default.
73
- }
215
74
- /*
216
Function names follow the pattern:
75
- * Canonicalize the "false" input reg to match the destination,
217
76
- * so that the tcg backend can implement "move if true".
218
-load: ``cpu_ld{sign}{size}_{mmusuffix}_ra(env, ptr, retaddr)``
77
- */
219
+load: ``cpu_ld{sign}{size}_data_ra(env, ptr, ra)``
78
- if (swap_commutative(op->args[0], &op->args[4], &op->args[3])) {
220
79
- op->args[5] = tcg_invert_cond(op->args[5]);
221
-store: ``cpu_st{sign}{size}_{mmusuffix}_ra(env, ptr, val, retaddr)``
80
- }
222
+store: ``cpu_st{size}_data_ra(env, ptr, val, ra)``
81
- return finish_folding(ctx, op);
223
+
82
-}
224
+``sign``
83
-
225
+ - (empty) : for 32 or 64 bit sizes
84
static bool fold_sextract(OptContext *ctx, TCGOp *op)
226
+ - ``u`` : unsigned
85
{
227
+ - ``s`` : signed
86
uint64_t z_mask, s_mask, s_mask_old;
228
+
229
+``size``
230
+ - ``b`` : 8 bits
231
+ - ``w`` : 16 bits
232
+ - ``l`` : 32 bits
233
+ - ``q`` : 64 bits
234
+
235
+Regexes for git grep:
236
+ - ``\<cpu_ld[us]\?[bwlq]_data_ra\>``
237
+ - ``\<cpu_st[bwlq]_data_ra\>``
238
+
239
+``cpu_{ld,st}*_data``
240
+~~~~~~~~~~~~~~~~~~~~~
241
+
242
+These functions work like the ``cpu_{ld,st}_data_ra`` functions
243
+except that the ``retaddr`` parameter is 0, and thus does not
244
+unwind guest CPU state.
245
+
246
+This means they must only be used from helper functions where the
247
+translator has saved all necessary CPU state. These functions are
248
+the right choice for calls made from hooks like the CPU ``do_interrupt``
249
+hook or when you know for certain that the translator had to save all
250
+the CPU state anyway.
251
+
252
+Function names follow the pattern:
253
+
254
+load: ``cpu_ld{sign}{size}_data(env, ptr)``
255
+
256
+store: ``cpu_st{size}_data(env, ptr, val)``
257
+
258
+``sign``
259
+ - (empty) : for 32 or 64 bit sizes
260
+ - ``u`` : unsigned
261
+ - ``s`` : signed
262
+
263
+``size``
264
+ - ``b`` : 8 bits
265
+ - ``w`` : 16 bits
266
+ - ``l`` : 32 bits
267
+ - ``q`` : 64 bits
268
269
Regexes for git grep
270
- - ``\<cpu_ld[us]\?[bwlq]_[a-zA-Z0-9]\+_ra\>``
271
- - ``\<cpu_st[bwlq]_[a-zA-Z0-9]\+_ra\>``
272
+ - ``\<cpu_ld[us]\?[bwlq]_data\>``
273
+ - ``\<cpu_st[bwlq]_data\+\>``
274
275
-``helper_*_{ld,st}*mmu``
276
-~~~~~~~~~~~~~~~~~~~~~~~~
277
+``cpu_ld*_code``
278
+~~~~~~~~~~~~~~~~
279
+
280
+These functions perform a read for instruction execution. The ``mmuidx``
281
+parameter is taken from the current mode of the guest CPU, as determined
282
+by ``cpu_mmu_index(env, true)``. The ``retaddr`` parameter is 0, and
283
+thus does not unwind guest CPU state, because CPU state is always
284
+synchronized while translating instructions. Any guest CPU exception
285
+that is raised will indicate an instruction execution fault rather than
286
+a data read fault.
287
+
288
+In general these functions should not be used directly during translation.
289
+There are wrapper functions that are to be used which also take care of
290
+plugins for tracing.
291
+
292
+Function names follow the pattern:
293
+
294
+load: ``cpu_ld{sign}{size}_code(env, ptr)``
295
+
296
+``sign``
297
+ - (empty) : for 32 or 64 bit sizes
298
+ - ``u`` : unsigned
299
+ - ``s`` : signed
300
+
301
+``size``
302
+ - ``b`` : 8 bits
303
+ - ``w`` : 16 bits
304
+ - ``l`` : 32 bits
305
+ - ``q`` : 64 bits
306
+
307
+Regexes for git grep:
308
+ - ``\<cpu_ld[us]\?[bwlq]_code\>``
309
+
310
+``translator_ld*``
311
+~~~~~~~~~~~~~~~~~~
312
+
313
+These functions are a wrapper for ``cpu_ld*_code`` which also perform
314
+any actions required by any tracing plugins. They are only to be
315
+called during the translator callback ``translate_insn``.
316
+
317
+There is a set of functions ending in ``_swap`` which, if the parameter
318
+is true, returns the value in the endianness that is the reverse of
319
+the guest native endianness, as determined by ``TARGET_WORDS_BIGENDIAN``.
320
+
321
+Function names follow the pattern:
322
+
323
+load: ``translator_ld{sign}{size}(env, ptr)``
324
+
325
+swap: ``translator_ld{sign}{size}_swap(env, ptr, swap)``
326
+
327
+``sign``
328
+ - (empty) : for 32 or 64 bit sizes
329
+ - ``u`` : unsigned
330
+ - ``s`` : signed
331
+
332
+``size``
333
+ - ``b`` : 8 bits
334
+ - ``w`` : 16 bits
335
+ - ``l`` : 32 bits
336
+ - ``q`` : 64 bits
337
+
338
+Regexes for git grep
339
+ - ``\<translator_ld[us]\?[bwlq]\(_swap\)\?\>``
340
+
341
+``helper_*_{ld,st}*_mmu``
342
+~~~~~~~~~~~~~~~~~~~~~~~~~
343
344
These functions are intended primarily to be called by the code
345
generated by the TCG backend. They may also be called by target
346
-CPU helper function code. Like the ``cpu_{ld,st}_*_ra`` functions
347
-they perform accesses by guest virtual address; the difference is
348
-that these functions allow you to specify an ``opindex`` parameter
349
-which encodes (among other things) the mmu index to use for the
350
-access. This is necessary if your helper needs to make an access
351
-via a specific mmu index (for instance, an "always as non-privileged"
352
-access) rather than using the default mmu index for the current state
353
-of the guest CPU.
354
+CPU helper function code. Like the ``cpu_{ld,st}_mmuidx_ra`` functions
355
+they perform accesses by guest virtual address, with a given ``mmuidx``.
356
357
-The ``opindex`` parameter should be created by calling ``make_memop_idx()``.
358
+These functions specify an ``opindex`` parameter which encodes
359
+(among other things) the mmu index to use for the access. This parameter
360
+should be created by calling ``make_memop_idx()``.
361
362
The ``retaddr`` parameter should be the result of GETPC() called directly
363
from the top level HELPER(foo) function (or 0 if no guest CPU state
364
@@ -XXX,XX +XXX,XX @@ unwinding is required).
365
366
**TODO** The names of these functions are a bit odd for historical
367
reasons because they were originally expected to be called only from
368
-within generated code. We should rename them to bring them
369
-more in line with the other memory access functions.
370
+within generated code. We should rename them to bring them more in
371
+line with the other memory access functions. The explicit endianness
372
+is the only feature they have beyond ``*_mmuidx_ra``.
373
374
load: ``helper_{endian}_ld{sign}{size}_mmu(env, addr, opindex, retaddr)``
375
376
--
87
--
377
2.20.1
88
2.43.0
378
379
diff view generated by jsdifflib
1
The DO_LOAD macros replicate the distinction already performed
1
We currently have a flag, float_muladd_halve_result, to scale
2
by the cpu_ldst.h functions. Use them.
2
the result by 2**-1. Extend this to handle arbitrary scaling.
3
3
4
Tested-by: Philippe Mathieu-Daudé <philmd@redhat.com>
4
Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org>
5
Reviewed-by: Alex Bennée <alex.bennee@linaro.org>
6
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
5
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
7
---
6
---
8
include/exec/cpu_ldst.h | 11 ---------
7
include/fpu/softfloat.h | 6 ++++
9
include/exec/translator.h | 48 +++++++++++----------------------------
8
fpu/softfloat.c | 58 ++++++++++++++++++++++-----------------
10
2 files changed, 13 insertions(+), 46 deletions(-)
9
fpu/softfloat-parts.c.inc | 7 +++--
11
10
3 files changed, 44 insertions(+), 27 deletions(-)
12
diff --git a/include/exec/cpu_ldst.h b/include/exec/cpu_ldst.h
11
12
diff --git a/include/fpu/softfloat.h b/include/fpu/softfloat.h
13
index XXXXXXX..XXXXXXX 100644
13
index XXXXXXX..XXXXXXX 100644
14
--- a/include/exec/cpu_ldst.h
14
--- a/include/fpu/softfloat.h
15
+++ b/include/exec/cpu_ldst.h
15
+++ b/include/fpu/softfloat.h
16
@@ -XXX,XX +XXX,XX @@ static inline void clear_helper_retaddr(void)
16
@@ -XXX,XX +XXX,XX @@ float16 float16_add(float16, float16, float_status *status);
17
#include "exec/cpu_ldst_useronly_template.h"
17
float16 float16_sub(float16, float16, float_status *status);
18
#undef MEMSUFFIX
18
float16 float16_mul(float16, float16, float_status *status);
19
19
float16 float16_muladd(float16, float16, float16, int, float_status *status);
20
-/*
20
+float16 float16_muladd_scalbn(float16, float16, float16,
21
- * Code access is deprecated in favour of translator_ld* functions
21
+ int, int, float_status *status);
22
- * (see translator.h). However there are still users that need to
22
float16 float16_div(float16, float16, float_status *status);
23
- * converted so for now these stay.
23
float16 float16_scalbn(float16, int, float_status *status);
24
- */
24
float16 float16_min(float16, float16, float_status *status);
25
#define MEMSUFFIX _code
25
@@ -XXX,XX +XXX,XX @@ float32 float32_mul(float32, float32, float_status *status);
26
#define CODE_ACCESS
26
float32 float32_div(float32, float32, float_status *status);
27
#define DATA_SIZE 1
27
float32 float32_rem(float32, float32, float_status *status);
28
@@ -XXX,XX +XXX,XX @@ void cpu_stq_mmuidx_ra(CPUArchState *env, abi_ptr addr, uint64_t val,
28
float32 float32_muladd(float32, float32, float32, int, float_status *status);
29
#undef CPU_MMU_INDEX
29
+float32 float32_muladd_scalbn(float32, float32, float32,
30
#undef MEMSUFFIX
30
+ int, int, float_status *status);
31
31
float32 float32_sqrt(float32, float_status *status);
32
-/*
32
float32 float32_exp2(float32, float_status *status);
33
- * Code access is deprecated in favour of translator_ld* functions
33
float32 float32_log2(float32, float_status *status);
34
- * (see translator.h). However there are still users that need to
34
@@ -XXX,XX +XXX,XX @@ float64 float64_mul(float64, float64, float_status *status);
35
- * converted so for now these stay.
35
float64 float64_div(float64, float64, float_status *status);
36
- */
36
float64 float64_rem(float64, float64, float_status *status);
37
-
37
float64 float64_muladd(float64, float64, float64, int, float_status *status);
38
#define CPU_MMU_INDEX (cpu_mmu_index(env, true))
38
+float64 float64_muladd_scalbn(float64, float64, float64,
39
#define MEMSUFFIX _code
39
+ int, int, float_status *status);
40
#define SOFTMMU_CODE_ACCESS
40
float64 float64_sqrt(float64, float_status *status);
41
diff --git a/include/exec/translator.h b/include/exec/translator.h
41
float64 float64_log2(float64, float_status *status);
42
FloatRelation float64_compare(float64, float64, float_status *status);
43
diff --git a/fpu/softfloat.c b/fpu/softfloat.c
42
index XXXXXXX..XXXXXXX 100644
44
index XXXXXXX..XXXXXXX 100644
43
--- a/include/exec/translator.h
45
--- a/fpu/softfloat.c
44
+++ b/include/exec/translator.h
46
+++ b/fpu/softfloat.c
45
@@ -XXX,XX +XXX,XX @@ void translator_loop_temp_check(DisasContextBase *db);
47
@@ -XXX,XX +XXX,XX @@ static FloatParts128 *parts128_mul(FloatParts128 *a, FloatParts128 *b,
46
/*
48
#define parts_mul(A, B, S) \
47
* Translator Load Functions
49
PARTS_GENERIC_64_128(mul, A)(A, B, S)
48
*
50
49
- * These are intended to replace the old cpu_ld*_code functions and
51
-static FloatParts64 *parts64_muladd(FloatParts64 *a, FloatParts64 *b,
50
- * are mandatory for front-ends that have been migrated to the common
52
- FloatParts64 *c, int flags,
51
- * translator_loop. These functions are only intended to be called
53
- float_status *s);
52
- * from the translation stage and should not be called from helper
54
-static FloatParts128 *parts128_muladd(FloatParts128 *a, FloatParts128 *b,
53
- * functions. Those functions should be converted to encode the
55
- FloatParts128 *c, int flags,
54
- * relevant information at translation time.
56
- float_status *s);
55
+ * These are intended to replace the direct usage of the cpu_ld*_code
57
+static FloatParts64 *parts64_muladd_scalbn(FloatParts64 *a, FloatParts64 *b,
56
+ * functions and are mandatory for front-ends that have been migrated
58
+ FloatParts64 *c, int scale,
57
+ * to the common translator_loop. These functions are only intended
59
+ int flags, float_status *s);
58
+ * to be called from the translation stage and should not be called
60
+static FloatParts128 *parts128_muladd_scalbn(FloatParts128 *a, FloatParts128 *b,
59
+ * from helper functions. Those functions should be converted to encode
61
+ FloatParts128 *c, int scale,
60
+ * the relevant information at translation time.
62
+ int flags, float_status *s);
63
64
-#define parts_muladd(A, B, C, Z, S) \
65
- PARTS_GENERIC_64_128(muladd, A)(A, B, C, Z, S)
66
+#define parts_muladd_scalbn(A, B, C, Z, Y, S) \
67
+ PARTS_GENERIC_64_128(muladd_scalbn, A)(A, B, C, Z, Y, S)
68
69
static FloatParts64 *parts64_div(FloatParts64 *a, FloatParts64 *b,
70
float_status *s);
71
@@ -XXX,XX +XXX,XX @@ floatx80_mul(floatx80 a, floatx80 b, float_status *status)
72
* Fused multiply-add
61
*/
73
*/
62
74
63
-#ifdef CONFIG_USER_ONLY
75
-float16 QEMU_FLATTEN float16_muladd(float16 a, float16 b, float16 c,
64
-
76
- int flags, float_status *status)
65
-#define DO_LOAD(type, name, shift) \
77
+float16 QEMU_FLATTEN
66
- do { \
78
+float16_muladd_scalbn(float16 a, float16 b, float16 c,
67
- set_helper_retaddr(1); \
79
+ int scale, int flags, float_status *status)
68
- ret = name ## _p(g2h(pc)); \
80
{
69
- clear_helper_retaddr(); \
81
FloatParts64 pa, pb, pc, *pr;
70
- } while (0)
82
71
-
83
float16_unpack_canonical(&pa, a, status);
72
-#else
84
float16_unpack_canonical(&pb, b, status);
73
-
85
float16_unpack_canonical(&pc, c, status);
74
-#define DO_LOAD(type, name, shift) \
86
- pr = parts_muladd(&pa, &pb, &pc, flags, status);
75
- do { \
87
+ pr = parts_muladd_scalbn(&pa, &pb, &pc, scale, flags, status);
76
- int mmu_idx = cpu_mmu_index(env, true); \
88
77
- TCGMemOpIdx oi = make_memop_idx(shift, mmu_idx); \
89
return float16_round_pack_canonical(pr, status);
78
- ret = helper_ret_ ## name ## _cmmu(env, pc, oi, 0); \
90
}
79
- } while (0)
91
80
-
92
-static float32 QEMU_SOFTFLOAT_ATTR
81
-#endif
93
-soft_f32_muladd(float32 a, float32 b, float32 c, int flags,
82
-
94
- float_status *status)
83
-#define GEN_TRANSLATOR_LD(fullname, name, type, shift, swap_fn) \
95
+float16 float16_muladd(float16 a, float16 b, float16 c,
84
+#define GEN_TRANSLATOR_LD(fullname, type, load_fn, swap_fn) \
96
+ int flags, float_status *status)
85
static inline type \
97
+{
86
fullname ## _swap(CPUArchState *env, abi_ptr pc, bool do_swap) \
98
+ return float16_muladd_scalbn(a, b, c, 0, flags, status);
87
{ \
99
+}
88
- type ret; \
100
+
89
- DO_LOAD(type, name, shift); \
101
+float32 QEMU_SOFTFLOAT_ATTR
90
- \
102
+float32_muladd_scalbn(float32 a, float32 b, float32 c,
91
+ type ret = load_fn(env, pc); \
103
+ int scale, int flags, float_status *status)
92
if (do_swap) { \
104
{
93
ret = swap_fn(ret); \
105
FloatParts64 pa, pb, pc, *pr;
94
} \
106
95
@@ -XXX,XX +XXX,XX @@ void translator_loop_temp_check(DisasContextBase *db);
107
float32_unpack_canonical(&pa, a, status);
96
return fullname ## _swap(env, pc, false); \
108
float32_unpack_canonical(&pb, b, status);
109
float32_unpack_canonical(&pc, c, status);
110
- pr = parts_muladd(&pa, &pb, &pc, flags, status);
111
+ pr = parts_muladd_scalbn(&pa, &pb, &pc, scale, flags, status);
112
113
return float32_round_pack_canonical(pr, status);
114
}
115
116
-static float64 QEMU_SOFTFLOAT_ATTR
117
-soft_f64_muladd(float64 a, float64 b, float64 c, int flags,
118
- float_status *status)
119
+float64 QEMU_SOFTFLOAT_ATTR
120
+float64_muladd_scalbn(float64 a, float64 b, float64 c,
121
+ int scale, int flags, float_status *status)
122
{
123
FloatParts64 pa, pb, pc, *pr;
124
125
float64_unpack_canonical(&pa, a, status);
126
float64_unpack_canonical(&pb, b, status);
127
float64_unpack_canonical(&pc, c, status);
128
- pr = parts_muladd(&pa, &pb, &pc, flags, status);
129
+ pr = parts_muladd_scalbn(&pa, &pb, &pc, scale, flags, status);
130
131
return float64_round_pack_canonical(pr, status);
132
}
133
@@ -XXX,XX +XXX,XX @@ float32_muladd(float32 xa, float32 xb, float32 xc, int flags, float_status *s)
134
return ur.s;
135
136
soft:
137
- return soft_f32_muladd(ua.s, ub.s, uc.s, flags, s);
138
+ return float32_muladd_scalbn(ua.s, ub.s, uc.s, 0, flags, s);
139
}
140
141
float64 QEMU_FLATTEN
142
@@ -XXX,XX +XXX,XX @@ float64_muladd(float64 xa, float64 xb, float64 xc, int flags, float_status *s)
143
return ur.s;
144
145
soft:
146
- return soft_f64_muladd(ua.s, ub.s, uc.s, flags, s);
147
+ return float64_muladd_scalbn(ua.s, ub.s, uc.s, 0, flags, s);
148
}
149
150
float64 float64r32_muladd(float64 a, float64 b, float64 c,
151
@@ -XXX,XX +XXX,XX @@ float64 float64r32_muladd(float64 a, float64 b, float64 c,
152
float64_unpack_canonical(&pa, a, status);
153
float64_unpack_canonical(&pb, b, status);
154
float64_unpack_canonical(&pc, c, status);
155
- pr = parts_muladd(&pa, &pb, &pc, flags, status);
156
+ pr = parts_muladd_scalbn(&pa, &pb, &pc, 0, flags, status);
157
158
return float64r32_round_pack_canonical(pr, status);
159
}
160
@@ -XXX,XX +XXX,XX @@ bfloat16 QEMU_FLATTEN bfloat16_muladd(bfloat16 a, bfloat16 b, bfloat16 c,
161
bfloat16_unpack_canonical(&pa, a, status);
162
bfloat16_unpack_canonical(&pb, b, status);
163
bfloat16_unpack_canonical(&pc, c, status);
164
- pr = parts_muladd(&pa, &pb, &pc, flags, status);
165
+ pr = parts_muladd_scalbn(&pa, &pb, &pc, 0, flags, status);
166
167
return bfloat16_round_pack_canonical(pr, status);
168
}
169
@@ -XXX,XX +XXX,XX @@ float128 QEMU_FLATTEN float128_muladd(float128 a, float128 b, float128 c,
170
float128_unpack_canonical(&pa, a, status);
171
float128_unpack_canonical(&pb, b, status);
172
float128_unpack_canonical(&pc, c, status);
173
- pr = parts_muladd(&pa, &pb, &pc, flags, status);
174
+ pr = parts_muladd_scalbn(&pa, &pb, &pc, 0, flags, status);
175
176
return float128_round_pack_canonical(pr, status);
177
}
178
@@ -XXX,XX +XXX,XX @@ float32 float32_exp2(float32 a, float_status *status)
179
180
float64_unpack_canonical(&rp, float64_one, status);
181
for (i = 0 ; i < 15 ; i++) {
182
+
183
float64_unpack_canonical(&tp, float32_exp2_coefficients[i], status);
184
- rp = *parts_muladd(&tp, &xnp, &rp, 0, status);
185
+ rp = *parts_muladd_scalbn(&tp, &xnp, &rp, 0, 0, status);
186
xnp = *parts_mul(&xnp, &xp, status);
97
}
187
}
98
188
99
-GEN_TRANSLATOR_LD(translator_ldub, ldub, uint8_t, 0, /* no swap */ )
189
diff --git a/fpu/softfloat-parts.c.inc b/fpu/softfloat-parts.c.inc
100
-GEN_TRANSLATOR_LD(translator_ldsw, ldsw, int16_t, 1, bswap16)
190
index XXXXXXX..XXXXXXX 100644
101
-GEN_TRANSLATOR_LD(translator_lduw, lduw, uint16_t, 1, bswap16)
191
--- a/fpu/softfloat-parts.c.inc
102
-GEN_TRANSLATOR_LD(translator_ldl, ldl, uint32_t, 2, bswap32)
192
+++ b/fpu/softfloat-parts.c.inc
103
-GEN_TRANSLATOR_LD(translator_ldq, ldq, uint64_t, 3, bswap64)
193
@@ -XXX,XX +XXX,XX @@ static FloatPartsN *partsN(mul)(FloatPartsN *a, FloatPartsN *b,
104
+GEN_TRANSLATOR_LD(translator_ldub, uint8_t, cpu_ldub_code, /* no swap */)
194
* Requires A and C extracted into a double-sized structure to provide the
105
+GEN_TRANSLATOR_LD(translator_ldsw, int16_t, cpu_ldsw_code, bswap16)
195
* extra space for the widening multiply.
106
+GEN_TRANSLATOR_LD(translator_lduw, uint16_t, cpu_lduw_code, bswap16)
196
*/
107
+GEN_TRANSLATOR_LD(translator_ldl, uint32_t, cpu_ldl_code, bswap32)
197
-static FloatPartsN *partsN(muladd)(FloatPartsN *a, FloatPartsN *b,
108
+GEN_TRANSLATOR_LD(translator_ldq, uint64_t, cpu_ldq_code, bswap64)
198
- FloatPartsN *c, int flags, float_status *s)
109
#undef GEN_TRANSLATOR_LD
199
+static FloatPartsN *partsN(muladd_scalbn)(FloatPartsN *a, FloatPartsN *b,
110
200
+ FloatPartsN *c, int scale,
111
#endif /* EXEC__TRANSLATOR_H */
201
+ int flags, float_status *s)
202
{
203
int ab_mask, abc_mask;
204
FloatPartsW p_widen, c_widen;
205
@@ -XXX,XX +XXX,XX @@ static FloatPartsN *partsN(muladd)(FloatPartsN *a, FloatPartsN *b,
206
a->exp = p_widen.exp;
207
208
return_normal:
209
+ /* TODO: Replace all use of float_muladd_halve_result with scale. */
210
if (flags & float_muladd_halve_result) {
211
a->exp -= 1;
212
}
213
+ a->exp += scale;
214
finish_sign:
215
if (flags & float_muladd_negate_result) {
216
a->sign ^= 1;
112
--
217
--
113
2.20.1
218
2.43.0
114
219
115
220
diff view generated by jsdifflib
1
The generated *_user functions are unused. The *_kernel functions
1
Use the scalbn interface instead of float_muladd_halve_result.
2
have a couple of users in op_helper.c; use *_mmuidx_ra instead,
3
with MMU_KERNEL_IDX.
4
2
5
Tested-by: Philippe Mathieu-Daudé <philmd@redhat.com>
3
Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org>
6
Reviewed-by: Laurent Vivier <laurent@vivier.eu>
7
Reviewed-by: Alex Bennée <alex.bennee@linaro.org>
8
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
4
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
9
---
5
---
10
v2: Use *_mmuidx_ra directly, without intermediate macros.
6
target/arm/tcg/helper-a64.c | 6 +++---
11
---
7
1 file changed, 3 insertions(+), 3 deletions(-)
12
target/m68k/cpu.h | 2 --
13
target/m68k/op_helper.c | 77 +++++++++++++++++++++++++----------------
14
2 files changed, 47 insertions(+), 32 deletions(-)
15
8
16
diff --git a/target/m68k/cpu.h b/target/m68k/cpu.h
9
diff --git a/target/arm/tcg/helper-a64.c b/target/arm/tcg/helper-a64.c
17
index XXXXXXX..XXXXXXX 100644
10
index XXXXXXX..XXXXXXX 100644
18
--- a/target/m68k/cpu.h
11
--- a/target/arm/tcg/helper-a64.c
19
+++ b/target/m68k/cpu.h
12
+++ b/target/arm/tcg/helper-a64.c
20
@@ -XXX,XX +XXX,XX @@ enum {
13
@@ -XXX,XX +XXX,XX @@ uint32_t HELPER(rsqrtsf_f16)(uint32_t a, uint32_t b, float_status *fpst)
21
#define cpu_list m68k_cpu_list
14
(float16_is_infinity(b) && float16_is_zero(a))) {
22
15
return float16_one_point_five;
23
/* MMU modes definitions */
16
}
24
-#define MMU_MODE0_SUFFIX _kernel
17
- return float16_muladd(a, b, float16_three, float_muladd_halve_result, fpst);
25
-#define MMU_MODE1_SUFFIX _user
18
+ return float16_muladd_scalbn(a, b, float16_three, -1, 0, fpst);
26
#define MMU_KERNEL_IDX 0
27
#define MMU_USER_IDX 1
28
static inline int cpu_mmu_index (CPUM68KState *env, bool ifetch)
29
diff --git a/target/m68k/op_helper.c b/target/m68k/op_helper.c
30
index XXXXXXX..XXXXXXX 100644
31
--- a/target/m68k/op_helper.c
32
+++ b/target/m68k/op_helper.c
33
@@ -XXX,XX +XXX,XX @@ static void cf_rte(CPUM68KState *env)
34
uint32_t fmt;
35
36
sp = env->aregs[7];
37
- fmt = cpu_ldl_kernel(env, sp);
38
- env->pc = cpu_ldl_kernel(env, sp + 4);
39
+ fmt = cpu_ldl_mmuidx_ra(env, sp, MMU_KERNEL_IDX, 0);
40
+ env->pc = cpu_ldl_mmuidx_ra(env, sp + 4, MMU_KERNEL_IDX, 0);
41
sp |= (fmt >> 28) & 3;
42
env->aregs[7] = sp + 8;
43
44
@@ -XXX,XX +XXX,XX @@ static void m68k_rte(CPUM68KState *env)
45
46
sp = env->aregs[7];
47
throwaway:
48
- sr = cpu_lduw_kernel(env, sp);
49
+ sr = cpu_lduw_mmuidx_ra(env, sp, MMU_KERNEL_IDX, 0);
50
sp += 2;
51
- env->pc = cpu_ldl_kernel(env, sp);
52
+ env->pc = cpu_ldl_mmuidx_ra(env, sp, MMU_KERNEL_IDX, 0);
53
sp += 4;
54
if (m68k_feature(env, M68K_FEATURE_QUAD_MULDIV)) {
55
/* all except 68000 */
56
- fmt = cpu_lduw_kernel(env, sp);
57
+ fmt = cpu_lduw_mmuidx_ra(env, sp, MMU_KERNEL_IDX, 0);
58
sp += 2;
59
switch (fmt >> 12) {
60
case 0:
61
@@ -XXX,XX +XXX,XX @@ static void cf_interrupt_all(CPUM68KState *env, int is_hw)
62
/* ??? This could cause MMU faults. */
63
sp &= ~3;
64
sp -= 4;
65
- cpu_stl_kernel(env, sp, retaddr);
66
+ cpu_stl_mmuidx_ra(env, sp, retaddr, MMU_KERNEL_IDX, 0);
67
sp -= 4;
68
- cpu_stl_kernel(env, sp, fmt);
69
+ cpu_stl_mmuidx_ra(env, sp, fmt, MMU_KERNEL_IDX, 0);
70
env->aregs[7] = sp;
71
/* Jump to vector. */
72
- env->pc = cpu_ldl_kernel(env, env->vbr + vector);
73
+ env->pc = cpu_ldl_mmuidx_ra(env, env->vbr + vector, MMU_KERNEL_IDX, 0);
74
}
19
}
75
20
76
static inline void do_stack_frame(CPUM68KState *env, uint32_t *sp,
21
float32 HELPER(rsqrtsf_f32)(float32 a, float32 b, float_status *fpst)
77
@@ -XXX,XX +XXX,XX @@ static inline void do_stack_frame(CPUM68KState *env, uint32_t *sp,
22
@@ -XXX,XX +XXX,XX @@ float32 HELPER(rsqrtsf_f32)(float32 a, float32 b, float_status *fpst)
78
switch (format) {
23
(float32_is_infinity(b) && float32_is_zero(a))) {
79
case 4:
24
return float32_one_point_five;
80
*sp -= 4;
81
- cpu_stl_kernel(env, *sp, env->pc);
82
+ cpu_stl_mmuidx_ra(env, *sp, env->pc, MMU_KERNEL_IDX, 0);
83
*sp -= 4;
84
- cpu_stl_kernel(env, *sp, addr);
85
+ cpu_stl_mmuidx_ra(env, *sp, addr, MMU_KERNEL_IDX, 0);
86
break;
87
case 3:
88
case 2:
89
*sp -= 4;
90
- cpu_stl_kernel(env, *sp, addr);
91
+ cpu_stl_mmuidx_ra(env, *sp, addr, MMU_KERNEL_IDX, 0);
92
break;
93
}
94
*sp -= 2;
95
- cpu_stw_kernel(env, *sp, (format << 12) + (cs->exception_index << 2));
96
+ cpu_stw_mmuidx_ra(env, *sp, (format << 12) + (cs->exception_index << 2),
97
+ MMU_KERNEL_IDX, 0);
98
}
25
}
99
*sp -= 4;
26
- return float32_muladd(a, b, float32_three, float_muladd_halve_result, fpst);
100
- cpu_stl_kernel(env, *sp, retaddr);
27
+ return float32_muladd_scalbn(a, b, float32_three, -1, 0, fpst);
101
+ cpu_stl_mmuidx_ra(env, *sp, retaddr, MMU_KERNEL_IDX, 0);
102
*sp -= 2;
103
- cpu_stw_kernel(env, *sp, sr);
104
+ cpu_stw_mmuidx_ra(env, *sp, sr, MMU_KERNEL_IDX, 0);
105
}
28
}
106
29
107
static void m68k_interrupt_all(CPUM68KState *env, int is_hw)
30
float64 HELPER(rsqrtsf_f64)(float64 a, float64 b, float_status *fpst)
108
@@ -XXX,XX +XXX,XX @@ static void m68k_interrupt_all(CPUM68KState *env, int is_hw)
31
@@ -XXX,XX +XXX,XX @@ float64 HELPER(rsqrtsf_f64)(float64 a, float64 b, float_status *fpst)
109
cpu_abort(cs, "DOUBLE MMU FAULT\n");
32
(float64_is_infinity(b) && float64_is_zero(a))) {
110
}
33
return float64_one_point_five;
111
env->mmu.fault = true;
34
}
112
+ /* push data 3 */
35
- return float64_muladd(a, b, float64_three, float_muladd_halve_result, fpst);
113
sp -= 4;
36
+ return float64_muladd_scalbn(a, b, float64_three, -1, 0, fpst);
114
- cpu_stl_kernel(env, sp, 0); /* push data 3 */
115
+ cpu_stl_mmuidx_ra(env, sp, 0, MMU_KERNEL_IDX, 0);
116
+ /* push data 2 */
117
sp -= 4;
118
- cpu_stl_kernel(env, sp, 0); /* push data 2 */
119
+ cpu_stl_mmuidx_ra(env, sp, 0, MMU_KERNEL_IDX, 0);
120
+ /* push data 1 */
121
sp -= 4;
122
- cpu_stl_kernel(env, sp, 0); /* push data 1 */
123
+ cpu_stl_mmuidx_ra(env, sp, 0, MMU_KERNEL_IDX, 0);
124
+ /* write back 1 / push data 0 */
125
sp -= 4;
126
- cpu_stl_kernel(env, sp, 0); /* write back 1 / push data 0 */
127
+ cpu_stl_mmuidx_ra(env, sp, 0, MMU_KERNEL_IDX, 0);
128
+ /* write back 1 address */
129
sp -= 4;
130
- cpu_stl_kernel(env, sp, 0); /* write back 1 address */
131
+ cpu_stl_mmuidx_ra(env, sp, 0, MMU_KERNEL_IDX, 0);
132
+ /* write back 2 data */
133
sp -= 4;
134
- cpu_stl_kernel(env, sp, 0); /* write back 2 data */
135
+ cpu_stl_mmuidx_ra(env, sp, 0, MMU_KERNEL_IDX, 0);
136
+ /* write back 2 address */
137
sp -= 4;
138
- cpu_stl_kernel(env, sp, 0); /* write back 2 address */
139
+ cpu_stl_mmuidx_ra(env, sp, 0, MMU_KERNEL_IDX, 0);
140
+ /* write back 3 data */
141
sp -= 4;
142
- cpu_stl_kernel(env, sp, 0); /* write back 3 data */
143
+ cpu_stl_mmuidx_ra(env, sp, 0, MMU_KERNEL_IDX, 0);
144
+ /* write back 3 address */
145
sp -= 4;
146
- cpu_stl_kernel(env, sp, env->mmu.ar); /* write back 3 address */
147
+ cpu_stl_mmuidx_ra(env, sp, env->mmu.ar, MMU_KERNEL_IDX, 0);
148
+ /* fault address */
149
sp -= 4;
150
- cpu_stl_kernel(env, sp, env->mmu.ar); /* fault address */
151
+ cpu_stl_mmuidx_ra(env, sp, env->mmu.ar, MMU_KERNEL_IDX, 0);
152
+ /* write back 1 status */
153
sp -= 2;
154
- cpu_stw_kernel(env, sp, 0); /* write back 1 status */
155
+ cpu_stw_mmuidx_ra(env, sp, 0, MMU_KERNEL_IDX, 0);
156
+ /* write back 2 status */
157
sp -= 2;
158
- cpu_stw_kernel(env, sp, 0); /* write back 2 status */
159
+ cpu_stw_mmuidx_ra(env, sp, 0, MMU_KERNEL_IDX, 0);
160
+ /* write back 3 status */
161
sp -= 2;
162
- cpu_stw_kernel(env, sp, 0); /* write back 3 status */
163
+ cpu_stw_mmuidx_ra(env, sp, 0, MMU_KERNEL_IDX, 0);
164
+ /* special status word */
165
sp -= 2;
166
- cpu_stw_kernel(env, sp, env->mmu.ssw); /* special status word */
167
+ cpu_stw_mmuidx_ra(env, sp, env->mmu.ssw, MMU_KERNEL_IDX, 0);
168
+ /* effective address */
169
sp -= 4;
170
- cpu_stl_kernel(env, sp, env->mmu.ar); /* effective address */
171
+ cpu_stl_mmuidx_ra(env, sp, env->mmu.ar, MMU_KERNEL_IDX, 0);
172
+
173
do_stack_frame(env, &sp, 7, oldsr, 0, retaddr);
174
env->mmu.fault = false;
175
if (qemu_loglevel_mask(CPU_LOG_INT)) {
176
@@ -XXX,XX +XXX,XX @@ static void m68k_interrupt_all(CPUM68KState *env, int is_hw)
177
178
env->aregs[7] = sp;
179
/* Jump to vector. */
180
- env->pc = cpu_ldl_kernel(env, env->vbr + vector);
181
+ env->pc = cpu_ldl_mmuidx_ra(env, env->vbr + vector, MMU_KERNEL_IDX, 0);
182
}
37
}
183
38
184
static void do_interrupt_all(CPUM68KState *env, int is_hw)
39
/* Floating-point reciprocal exponent - see FPRecpX in ARM ARM */
185
--
40
--
186
2.20.1
41
2.43.0
187
42
188
43
diff view generated by jsdifflib
1
The functions generated by these macros are unused.
1
Use the scalbn interface instead of float_muladd_halve_result.
2
2
3
Cc: Eduardo Habkost <ehabkost@redhat.com>
3
Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org>
4
Tested-by: Philippe Mathieu-Daudé <philmd@redhat.com>
5
Acked-by: Paolo Bonzini <pbonzini@redhat.com>
6
Reviewed-by: Alex Bennée <alex.bennee@linaro.org>
7
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
4
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
8
---
5
---
9
target/i386/cpu.h | 3 ---
6
target/sparc/helper.h | 4 +-
10
1 file changed, 3 deletions(-)
7
target/sparc/fop_helper.c | 8 ++--
11
8
target/sparc/translate.c | 80 +++++++++++++++++++++++----------------
12
diff --git a/target/i386/cpu.h b/target/i386/cpu.h
9
3 files changed, 54 insertions(+), 38 deletions(-)
10
11
diff --git a/target/sparc/helper.h b/target/sparc/helper.h
13
index XXXXXXX..XXXXXXX 100644
12
index XXXXXXX..XXXXXXX 100644
14
--- a/target/i386/cpu.h
13
--- a/target/sparc/helper.h
15
+++ b/target/i386/cpu.h
14
+++ b/target/sparc/helper.h
16
@@ -XXX,XX +XXX,XX @@ uint64_t cpu_get_tsc(CPUX86State *env);
15
@@ -XXX,XX +XXX,XX @@ DEF_HELPER_FLAGS_3(faddd, TCG_CALL_NO_WG, f64, env, f64, f64)
17
#define cpu_list x86_cpu_list
16
DEF_HELPER_FLAGS_3(fsubd, TCG_CALL_NO_WG, f64, env, f64, f64)
18
17
DEF_HELPER_FLAGS_3(fmuld, TCG_CALL_NO_WG, f64, env, f64, f64)
19
/* MMU modes definitions */
18
DEF_HELPER_FLAGS_3(fdivd, TCG_CALL_NO_WG, f64, env, f64, f64)
20
-#define MMU_MODE0_SUFFIX _ksmap
19
-DEF_HELPER_FLAGS_5(fmaddd, TCG_CALL_NO_WG, f64, env, f64, f64, f64, i32)
21
-#define MMU_MODE1_SUFFIX _user
20
+DEF_HELPER_FLAGS_6(fmaddd, TCG_CALL_NO_WG, f64, env, f64, f64, f64, s32, i32)
22
-#define MMU_MODE2_SUFFIX _knosmap /* SMAP disabled or CPL<3 && AC=1 */
21
DEF_HELPER_FLAGS_3(fnaddd, TCG_CALL_NO_WG, f64, env, f64, f64)
23
#define MMU_KSMAP_IDX 0
22
DEF_HELPER_FLAGS_3(fnmuld, TCG_CALL_NO_WG, f64, env, f64, f64)
24
#define MMU_USER_IDX 1
23
25
#define MMU_KNOSMAP_IDX 2
24
@@ -XXX,XX +XXX,XX @@ DEF_HELPER_FLAGS_3(fadds, TCG_CALL_NO_WG, f32, env, f32, f32)
25
DEF_HELPER_FLAGS_3(fsubs, TCG_CALL_NO_WG, f32, env, f32, f32)
26
DEF_HELPER_FLAGS_3(fmuls, TCG_CALL_NO_WG, f32, env, f32, f32)
27
DEF_HELPER_FLAGS_3(fdivs, TCG_CALL_NO_WG, f32, env, f32, f32)
28
-DEF_HELPER_FLAGS_5(fmadds, TCG_CALL_NO_WG, f32, env, f32, f32, f32, i32)
29
+DEF_HELPER_FLAGS_6(fmadds, TCG_CALL_NO_WG, f32, env, f32, f32, f32, s32, i32)
30
DEF_HELPER_FLAGS_3(fnadds, TCG_CALL_NO_WG, f32, env, f32, f32)
31
DEF_HELPER_FLAGS_3(fnmuls, TCG_CALL_NO_WG, f32, env, f32, f32)
32
33
diff --git a/target/sparc/fop_helper.c b/target/sparc/fop_helper.c
34
index XXXXXXX..XXXXXXX 100644
35
--- a/target/sparc/fop_helper.c
36
+++ b/target/sparc/fop_helper.c
37
@@ -XXX,XX +XXX,XX @@ Int128 helper_fsqrtq(CPUSPARCState *env, Int128 src)
38
}
39
40
float32 helper_fmadds(CPUSPARCState *env, float32 s1,
41
- float32 s2, float32 s3, uint32_t op)
42
+ float32 s2, float32 s3, int32_t sc, uint32_t op)
43
{
44
- float32 ret = float32_muladd(s1, s2, s3, op, &env->fp_status);
45
+ float32 ret = float32_muladd_scalbn(s1, s2, s3, sc, op, &env->fp_status);
46
check_ieee_exceptions(env, GETPC());
47
return ret;
48
}
49
50
float64 helper_fmaddd(CPUSPARCState *env, float64 s1,
51
- float64 s2, float64 s3, uint32_t op)
52
+ float64 s2, float64 s3, int32_t sc, uint32_t op)
53
{
54
- float64 ret = float64_muladd(s1, s2, s3, op, &env->fp_status);
55
+ float64 ret = float64_muladd_scalbn(s1, s2, s3, sc, op, &env->fp_status);
56
check_ieee_exceptions(env, GETPC());
57
return ret;
58
}
59
diff --git a/target/sparc/translate.c b/target/sparc/translate.c
60
index XXXXXXX..XXXXXXX 100644
61
--- a/target/sparc/translate.c
62
+++ b/target/sparc/translate.c
63
@@ -XXX,XX +XXX,XX @@ static void gen_op_fabsq(TCGv_i128 dst, TCGv_i128 src)
64
65
static void gen_op_fmadds(TCGv_i32 d, TCGv_i32 s1, TCGv_i32 s2, TCGv_i32 s3)
66
{
67
- gen_helper_fmadds(d, tcg_env, s1, s2, s3, tcg_constant_i32(0));
68
+ TCGv_i32 z = tcg_constant_i32(0);
69
+ gen_helper_fmadds(d, tcg_env, s1, s2, s3, z, z);
70
}
71
72
static void gen_op_fmaddd(TCGv_i64 d, TCGv_i64 s1, TCGv_i64 s2, TCGv_i64 s3)
73
{
74
- gen_helper_fmaddd(d, tcg_env, s1, s2, s3, tcg_constant_i32(0));
75
+ TCGv_i32 z = tcg_constant_i32(0);
76
+ gen_helper_fmaddd(d, tcg_env, s1, s2, s3, z, z);
77
}
78
79
static void gen_op_fmsubs(TCGv_i32 d, TCGv_i32 s1, TCGv_i32 s2, TCGv_i32 s3)
80
{
81
- int op = float_muladd_negate_c;
82
- gen_helper_fmadds(d, tcg_env, s1, s2, s3, tcg_constant_i32(op));
83
+ TCGv_i32 z = tcg_constant_i32(0);
84
+ TCGv_i32 op = tcg_constant_i32(float_muladd_negate_c);
85
+ gen_helper_fmadds(d, tcg_env, s1, s2, s3, z, op);
86
}
87
88
static void gen_op_fmsubd(TCGv_i64 d, TCGv_i64 s1, TCGv_i64 s2, TCGv_i64 s3)
89
{
90
- int op = float_muladd_negate_c;
91
- gen_helper_fmaddd(d, tcg_env, s1, s2, s3, tcg_constant_i32(op));
92
+ TCGv_i32 z = tcg_constant_i32(0);
93
+ TCGv_i32 op = tcg_constant_i32(float_muladd_negate_c);
94
+ gen_helper_fmaddd(d, tcg_env, s1, s2, s3, z, op);
95
}
96
97
static void gen_op_fnmsubs(TCGv_i32 d, TCGv_i32 s1, TCGv_i32 s2, TCGv_i32 s3)
98
{
99
- int op = float_muladd_negate_c | float_muladd_negate_result;
100
- gen_helper_fmadds(d, tcg_env, s1, s2, s3, tcg_constant_i32(op));
101
+ TCGv_i32 z = tcg_constant_i32(0);
102
+ TCGv_i32 op = tcg_constant_i32(float_muladd_negate_c |
103
+ float_muladd_negate_result);
104
+ gen_helper_fmadds(d, tcg_env, s1, s2, s3, z, op);
105
}
106
107
static void gen_op_fnmsubd(TCGv_i64 d, TCGv_i64 s1, TCGv_i64 s2, TCGv_i64 s3)
108
{
109
- int op = float_muladd_negate_c | float_muladd_negate_result;
110
- gen_helper_fmaddd(d, tcg_env, s1, s2, s3, tcg_constant_i32(op));
111
+ TCGv_i32 z = tcg_constant_i32(0);
112
+ TCGv_i32 op = tcg_constant_i32(float_muladd_negate_c |
113
+ float_muladd_negate_result);
114
+ gen_helper_fmaddd(d, tcg_env, s1, s2, s3, z, op);
115
}
116
117
static void gen_op_fnmadds(TCGv_i32 d, TCGv_i32 s1, TCGv_i32 s2, TCGv_i32 s3)
118
{
119
- int op = float_muladd_negate_result;
120
- gen_helper_fmadds(d, tcg_env, s1, s2, s3, tcg_constant_i32(op));
121
+ TCGv_i32 z = tcg_constant_i32(0);
122
+ TCGv_i32 op = tcg_constant_i32(float_muladd_negate_result);
123
+ gen_helper_fmadds(d, tcg_env, s1, s2, s3, z, op);
124
}
125
126
static void gen_op_fnmaddd(TCGv_i64 d, TCGv_i64 s1, TCGv_i64 s2, TCGv_i64 s3)
127
{
128
- int op = float_muladd_negate_result;
129
- gen_helper_fmaddd(d, tcg_env, s1, s2, s3, tcg_constant_i32(op));
130
+ TCGv_i32 z = tcg_constant_i32(0);
131
+ TCGv_i32 op = tcg_constant_i32(float_muladd_negate_result);
132
+ gen_helper_fmaddd(d, tcg_env, s1, s2, s3, z, op);
133
}
134
135
/* Use muladd to compute (1 * src1) + src2 / 2 with one rounding. */
136
static void gen_op_fhadds(TCGv_i32 d, TCGv_i32 s1, TCGv_i32 s2)
137
{
138
- TCGv_i32 one = tcg_constant_i32(float32_one);
139
- int op = float_muladd_halve_result;
140
- gen_helper_fmadds(d, tcg_env, one, s1, s2, tcg_constant_i32(op));
141
+ TCGv_i32 fone = tcg_constant_i32(float32_one);
142
+ TCGv_i32 mone = tcg_constant_i32(-1);
143
+ TCGv_i32 op = tcg_constant_i32(0);
144
+ gen_helper_fmadds(d, tcg_env, fone, s1, s2, mone, op);
145
}
146
147
static void gen_op_fhaddd(TCGv_i64 d, TCGv_i64 s1, TCGv_i64 s2)
148
{
149
- TCGv_i64 one = tcg_constant_i64(float64_one);
150
- int op = float_muladd_halve_result;
151
- gen_helper_fmaddd(d, tcg_env, one, s1, s2, tcg_constant_i32(op));
152
+ TCGv_i64 fone = tcg_constant_i64(float64_one);
153
+ TCGv_i32 mone = tcg_constant_i32(-1);
154
+ TCGv_i32 op = tcg_constant_i32(0);
155
+ gen_helper_fmaddd(d, tcg_env, fone, s1, s2, mone, op);
156
}
157
158
/* Use muladd to compute (1 * src1) - src2 / 2 with one rounding. */
159
static void gen_op_fhsubs(TCGv_i32 d, TCGv_i32 s1, TCGv_i32 s2)
160
{
161
- TCGv_i32 one = tcg_constant_i32(float32_one);
162
- int op = float_muladd_negate_c | float_muladd_halve_result;
163
- gen_helper_fmadds(d, tcg_env, one, s1, s2, tcg_constant_i32(op));
164
+ TCGv_i32 fone = tcg_constant_i32(float32_one);
165
+ TCGv_i32 mone = tcg_constant_i32(-1);
166
+ TCGv_i32 op = tcg_constant_i32(float_muladd_negate_c);
167
+ gen_helper_fmadds(d, tcg_env, fone, s1, s2, mone, op);
168
}
169
170
static void gen_op_fhsubd(TCGv_i64 d, TCGv_i64 s1, TCGv_i64 s2)
171
{
172
- TCGv_i64 one = tcg_constant_i64(float64_one);
173
- int op = float_muladd_negate_c | float_muladd_halve_result;
174
- gen_helper_fmaddd(d, tcg_env, one, s1, s2, tcg_constant_i32(op));
175
+ TCGv_i64 fone = tcg_constant_i64(float64_one);
176
+ TCGv_i32 mone = tcg_constant_i32(-1);
177
+ TCGv_i32 op = tcg_constant_i32(float_muladd_negate_c);
178
+ gen_helper_fmaddd(d, tcg_env, fone, s1, s2, mone, op);
179
}
180
181
/* Use muladd to compute -((1 * src1) + src2 / 2) with one rounding. */
182
static void gen_op_fnhadds(TCGv_i32 d, TCGv_i32 s1, TCGv_i32 s2)
183
{
184
- TCGv_i32 one = tcg_constant_i32(float32_one);
185
- int op = float_muladd_negate_result | float_muladd_halve_result;
186
- gen_helper_fmadds(d, tcg_env, one, s1, s2, tcg_constant_i32(op));
187
+ TCGv_i32 fone = tcg_constant_i32(float32_one);
188
+ TCGv_i32 mone = tcg_constant_i32(-1);
189
+ TCGv_i32 op = tcg_constant_i32(float_muladd_negate_result);
190
+ gen_helper_fmadds(d, tcg_env, fone, s1, s2, mone, op);
191
}
192
193
static void gen_op_fnhaddd(TCGv_i64 d, TCGv_i64 s1, TCGv_i64 s2)
194
{
195
- TCGv_i64 one = tcg_constant_i64(float64_one);
196
- int op = float_muladd_negate_result | float_muladd_halve_result;
197
- gen_helper_fmaddd(d, tcg_env, one, s1, s2, tcg_constant_i32(op));
198
+ TCGv_i64 fone = tcg_constant_i64(float64_one);
199
+ TCGv_i32 mone = tcg_constant_i32(-1);
200
+ TCGv_i32 op = tcg_constant_i32(float_muladd_negate_result);
201
+ gen_helper_fmaddd(d, tcg_env, fone, s1, s2, mone, op);
202
}
203
204
static void gen_op_fpexception_im(DisasContext *dc, int ftt)
26
--
205
--
27
2.20.1
206
2.43.0
28
207
29
208
diff view generated by jsdifflib
1
The functions generated by these macros are unused.
1
All uses have been convered to float*_muladd_scalbn.
2
2
3
Tested-by: Philippe Mathieu-Daudé <philmd@redhat.com>
3
Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org>
4
Reviewed-by: Alex Bennée <alex.bennee@linaro.org>
5
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
4
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
6
---
5
---
7
target/alpha/cpu.h | 2 --
6
include/fpu/softfloat.h | 3 ---
8
1 file changed, 2 deletions(-)
7
fpu/softfloat.c | 6 ------
8
fpu/softfloat-parts.c.inc | 4 ----
9
3 files changed, 13 deletions(-)
9
10
10
diff --git a/target/alpha/cpu.h b/target/alpha/cpu.h
11
diff --git a/include/fpu/softfloat.h b/include/fpu/softfloat.h
11
index XXXXXXX..XXXXXXX 100644
12
index XXXXXXX..XXXXXXX 100644
12
--- a/target/alpha/cpu.h
13
--- a/include/fpu/softfloat.h
13
+++ b/target/alpha/cpu.h
14
+++ b/include/fpu/softfloat.h
14
@@ -XXX,XX +XXX,XX @@ enum {
15
@@ -XXX,XX +XXX,XX @@ bfloat16 bfloat16_squash_input_denormal(bfloat16 a, float_status *status);
15
PALcode cheats and usees the KSEG mapping for its code+data rather than
16
| Using these differs from negating an input or output before calling
16
physical addresses. */
17
| the muladd function in that this means that a NaN doesn't have its
17
18
| sign bit inverted before it is propagated.
18
-#define MMU_MODE0_SUFFIX _kernel
19
-| We also support halving the result before rounding, as a special
19
-#define MMU_MODE1_SUFFIX _user
20
-| case to support the ARM fused-sqrt-step instruction FRSQRTS.
20
#define MMU_KERNEL_IDX 0
21
*----------------------------------------------------------------------------*/
21
#define MMU_USER_IDX 1
22
enum {
22
#define MMU_PHYS_IDX 2
23
float_muladd_negate_c = 1,
24
float_muladd_negate_product = 2,
25
float_muladd_negate_result = 4,
26
- float_muladd_halve_result = 8,
27
};
28
29
/*----------------------------------------------------------------------------
30
diff --git a/fpu/softfloat.c b/fpu/softfloat.c
31
index XXXXXXX..XXXXXXX 100644
32
--- a/fpu/softfloat.c
33
+++ b/fpu/softfloat.c
34
@@ -XXX,XX +XXX,XX @@ float32_muladd(float32 xa, float32 xb, float32 xc, int flags, float_status *s)
35
if (unlikely(!can_use_fpu(s))) {
36
goto soft;
37
}
38
- if (unlikely(flags & float_muladd_halve_result)) {
39
- goto soft;
40
- }
41
42
float32_input_flush3(&ua.s, &ub.s, &uc.s, s);
43
if (unlikely(!f32_is_zon3(ua, ub, uc))) {
44
@@ -XXX,XX +XXX,XX @@ float64_muladd(float64 xa, float64 xb, float64 xc, int flags, float_status *s)
45
if (unlikely(!can_use_fpu(s))) {
46
goto soft;
47
}
48
- if (unlikely(flags & float_muladd_halve_result)) {
49
- goto soft;
50
- }
51
52
float64_input_flush3(&ua.s, &ub.s, &uc.s, s);
53
if (unlikely(!f64_is_zon3(ua, ub, uc))) {
54
diff --git a/fpu/softfloat-parts.c.inc b/fpu/softfloat-parts.c.inc
55
index XXXXXXX..XXXXXXX 100644
56
--- a/fpu/softfloat-parts.c.inc
57
+++ b/fpu/softfloat-parts.c.inc
58
@@ -XXX,XX +XXX,XX @@ static FloatPartsN *partsN(muladd_scalbn)(FloatPartsN *a, FloatPartsN *b,
59
a->exp = p_widen.exp;
60
61
return_normal:
62
- /* TODO: Replace all use of float_muladd_halve_result with scale. */
63
- if (flags & float_muladd_halve_result) {
64
- a->exp -= 1;
65
- }
66
a->exp += scale;
67
finish_sign:
68
if (flags & float_muladd_negate_result) {
23
--
69
--
24
2.20.1
70
2.43.0
25
71
26
72
diff view generated by jsdifflib
1
Do not use exec/cpu_ldst_{,useronly_}template.h directly,
1
This rounding mode is used by Hexagon.
2
but instead use the functional interface.
3
2
4
Cc: Eduardo Habkost <ehabkost@redhat.com>
5
Tested-by: Philippe Mathieu-Daudé <philmd@redhat.com>
6
Acked-by: Paolo Bonzini <pbonzini@redhat.com>
7
Reviewed-by: Alex Bennée <alex.bennee@linaro.org>
8
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
3
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
9
---
4
---
10
target/i386/seg_helper.c | 56 ++++++++++++++++++++--------------------
5
include/fpu/softfloat-types.h | 2 ++
11
1 file changed, 28 insertions(+), 28 deletions(-)
6
fpu/softfloat-parts.c.inc | 3 +++
7
2 files changed, 5 insertions(+)
12
8
13
diff --git a/target/i386/seg_helper.c b/target/i386/seg_helper.c
9
diff --git a/include/fpu/softfloat-types.h b/include/fpu/softfloat-types.h
14
index XXXXXXX..XXXXXXX 100644
10
index XXXXXXX..XXXXXXX 100644
15
--- a/target/i386/seg_helper.c
11
--- a/include/fpu/softfloat-types.h
16
+++ b/target/i386/seg_helper.c
12
+++ b/include/fpu/softfloat-types.h
17
@@ -XXX,XX +XXX,XX @@
13
@@ -XXX,XX +XXX,XX @@ typedef enum __attribute__((__packed__)) {
18
# define LOG_PCALL_STATE(cpu) do { } while (0)
14
float_round_to_odd = 5,
19
#endif
15
/* Not an IEEE rounding mode: round to closest odd, overflow to inf */
20
16
float_round_to_odd_inf = 6,
21
-#ifdef CONFIG_USER_ONLY
17
+ /* Not an IEEE rounding mode: round to nearest even, overflow to max */
22
-#define MEMSUFFIX _kernel
18
+ float_round_nearest_even_max = 7,
23
-#define DATA_SIZE 1
19
} FloatRoundMode;
24
-#include "exec/cpu_ldst_useronly_template.h"
20
25
+/*
21
/*
26
+ * TODO: Convert callers to compute cpu_mmu_index_kernel once
22
diff --git a/fpu/softfloat-parts.c.inc b/fpu/softfloat-parts.c.inc
27
+ * and use *_mmuidx_ra directly.
23
index XXXXXXX..XXXXXXX 100644
28
+ */
24
--- a/fpu/softfloat-parts.c.inc
29
+#define cpu_ldub_kernel_ra(e, p, r) \
25
+++ b/fpu/softfloat-parts.c.inc
30
+ cpu_ldub_mmuidx_ra(e, p, cpu_mmu_index_kernel(e), r)
26
@@ -XXX,XX +XXX,XX @@ static void partsN(uncanon_normal)(FloatPartsN *p, float_status *s,
31
+#define cpu_lduw_kernel_ra(e, p, r) \
27
int exp, flags = 0;
32
+ cpu_lduw_mmuidx_ra(e, p, cpu_mmu_index_kernel(e), r)
28
33
+#define cpu_ldl_kernel_ra(e, p, r) \
29
switch (s->float_rounding_mode) {
34
+ cpu_ldl_mmuidx_ra(e, p, cpu_mmu_index_kernel(e), r)
30
+ case float_round_nearest_even_max:
35
+#define cpu_ldq_kernel_ra(e, p, r) \
31
+ overflow_norm = true;
36
+ cpu_ldq_mmuidx_ra(e, p, cpu_mmu_index_kernel(e), r)
32
+ /* fall through */
37
33
case float_round_nearest_even:
38
-#define DATA_SIZE 2
34
if (N > 64 && frac_lsb == 0) {
39
-#include "exec/cpu_ldst_useronly_template.h"
35
inc = ((p->frac_hi & 1) || (p->frac_lo & round_mask) != frac_lsbm1
40
+#define cpu_stb_kernel_ra(e, p, v, r) \
41
+ cpu_stb_mmuidx_ra(e, p, v, cpu_mmu_index_kernel(e), r)
42
+#define cpu_stw_kernel_ra(e, p, v, r) \
43
+ cpu_stw_mmuidx_ra(e, p, v, cpu_mmu_index_kernel(e), r)
44
+#define cpu_stl_kernel_ra(e, p, v, r) \
45
+ cpu_stl_mmuidx_ra(e, p, v, cpu_mmu_index_kernel(e), r)
46
+#define cpu_stq_kernel_ra(e, p, v, r) \
47
+ cpu_stq_mmuidx_ra(e, p, v, cpu_mmu_index_kernel(e), r)
48
49
-#define DATA_SIZE 4
50
-#include "exec/cpu_ldst_useronly_template.h"
51
+#define cpu_ldub_kernel(e, p) cpu_ldub_kernel_ra(e, p, 0)
52
+#define cpu_lduw_kernel(e, p) cpu_lduw_kernel_ra(e, p, 0)
53
+#define cpu_ldl_kernel(e, p) cpu_ldl_kernel_ra(e, p, 0)
54
+#define cpu_ldq_kernel(e, p) cpu_ldq_kernel_ra(e, p, 0)
55
56
-#define DATA_SIZE 8
57
-#include "exec/cpu_ldst_useronly_template.h"
58
-#undef MEMSUFFIX
59
-#else
60
-#define CPU_MMU_INDEX (cpu_mmu_index_kernel(env))
61
-#define MEMSUFFIX _kernel
62
-#define DATA_SIZE 1
63
-#include "exec/cpu_ldst_template.h"
64
-
65
-#define DATA_SIZE 2
66
-#include "exec/cpu_ldst_template.h"
67
-
68
-#define DATA_SIZE 4
69
-#include "exec/cpu_ldst_template.h"
70
-
71
-#define DATA_SIZE 8
72
-#include "exec/cpu_ldst_template.h"
73
-#undef CPU_MMU_INDEX
74
-#undef MEMSUFFIX
75
-#endif
76
+#define cpu_stb_kernel(e, p, v) cpu_stb_kernel_ra(e, p, v, 0)
77
+#define cpu_stw_kernel(e, p, v) cpu_stw_kernel_ra(e, p, v, 0)
78
+#define cpu_stl_kernel(e, p, v) cpu_stl_kernel_ra(e, p, v, 0)
79
+#define cpu_stq_kernel(e, p, v) cpu_stq_kernel_ra(e, p, v, 0)
80
81
/* return non zero if error */
82
static inline int load_segment_ra(CPUX86State *env, uint32_t *e1_ptr,
83
--
36
--
84
2.20.1
37
2.43.0
85
86
diff view generated by jsdifflib
1
Code movement in an upcoming patch will show that this file
1
Certain Hexagon instructions suppress changes to the result
2
was implicitly depending on tcg.h being included indirectly.
2
when the product of fma() is a true zero.
3
3
4
Tested-by: Philippe Mathieu-Daudé <philmd@redhat.com>
5
Reviewed-by: Philippe Mathieu-Daudé <philmd@redhat.com>
6
Reviewed-by: Alex Bennée <alex.bennee@linaro.org>
7
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
4
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
8
---
5
---
9
linux-user/syscall.c | 1 +
6
include/fpu/softfloat.h | 5 +++++
10
1 file changed, 1 insertion(+)
7
fpu/softfloat.c | 3 +++
8
fpu/softfloat-parts.c.inc | 4 +++-
9
3 files changed, 11 insertions(+), 1 deletion(-)
11
10
12
diff --git a/linux-user/syscall.c b/linux-user/syscall.c
11
diff --git a/include/fpu/softfloat.h b/include/fpu/softfloat.h
13
index XXXXXXX..XXXXXXX 100644
12
index XXXXXXX..XXXXXXX 100644
14
--- a/linux-user/syscall.c
13
--- a/include/fpu/softfloat.h
15
+++ b/linux-user/syscall.c
14
+++ b/include/fpu/softfloat.h
16
@@ -XXX,XX +XXX,XX @@
15
@@ -XXX,XX +XXX,XX @@ bfloat16 bfloat16_squash_input_denormal(bfloat16 a, float_status *status);
17
#include "user/syscall-trace.h"
16
| Using these differs from negating an input or output before calling
18
#include "qapi/error.h"
17
| the muladd function in that this means that a NaN doesn't have its
19
#include "fd-trans.h"
18
| sign bit inverted before it is propagated.
20
+#include "tcg.h"
19
+|
21
20
+| With float_muladd_suppress_add_product_zero, if A or B is zero
22
#ifndef CLONE_IO
21
+| such that the product is a true zero, then return C without addition.
23
#define CLONE_IO 0x80000000 /* Clone io context */
22
+| This preserves the sign of C when C is +/- 0. Used for Hexagon.
23
*----------------------------------------------------------------------------*/
24
enum {
25
float_muladd_negate_c = 1,
26
float_muladd_negate_product = 2,
27
float_muladd_negate_result = 4,
28
+ float_muladd_suppress_add_product_zero = 8,
29
};
30
31
/*----------------------------------------------------------------------------
32
diff --git a/fpu/softfloat.c b/fpu/softfloat.c
33
index XXXXXXX..XXXXXXX 100644
34
--- a/fpu/softfloat.c
35
+++ b/fpu/softfloat.c
36
@@ -XXX,XX +XXX,XX @@ float32_muladd(float32 xa, float32 xb, float32 xc, int flags, float_status *s)
37
if (unlikely(!can_use_fpu(s))) {
38
goto soft;
39
}
40
+ if (unlikely(flags & float_muladd_suppress_add_product_zero)) {
41
+ goto soft;
42
+ }
43
44
float32_input_flush3(&ua.s, &ub.s, &uc.s, s);
45
if (unlikely(!f32_is_zon3(ua, ub, uc))) {
46
diff --git a/fpu/softfloat-parts.c.inc b/fpu/softfloat-parts.c.inc
47
index XXXXXXX..XXXXXXX 100644
48
--- a/fpu/softfloat-parts.c.inc
49
+++ b/fpu/softfloat-parts.c.inc
50
@@ -XXX,XX +XXX,XX @@ static FloatPartsN *partsN(muladd_scalbn)(FloatPartsN *a, FloatPartsN *b,
51
goto return_normal;
52
}
53
if (c->cls == float_class_zero) {
54
- if (a->sign != c->sign) {
55
+ if (flags & float_muladd_suppress_add_product_zero) {
56
+ a->sign = c->sign;
57
+ } else if (a->sign != c->sign) {
58
goto return_sub_zero;
59
}
60
goto return_zero;
24
--
61
--
25
2.20.1
62
2.43.0
26
27
diff view generated by jsdifflib
1
Code movement in an upcoming patch will show that this file
1
There are no special cases for this instruction.
2
was implicitly depending on tcg.h being included indirectly.
2
Remove internal_mpyf as unused.
3
3
4
Tested-by: Philippe Mathieu-Daudé <philmd@redhat.com>
4
Reviewed-by: Brian Cain <brian.cain@oss.qualcomm.com>
5
Reviewed-by: Alex Bennée <alex.bennee@linaro.org>
6
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
5
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
7
---
6
---
8
accel/tcg/tcg-runtime.c | 1 +
7
target/hexagon/fma_emu.h | 1 -
9
1 file changed, 1 insertion(+)
8
target/hexagon/fma_emu.c | 8 --------
9
target/hexagon/op_helper.c | 2 +-
10
3 files changed, 1 insertion(+), 10 deletions(-)
10
11
11
diff --git a/accel/tcg/tcg-runtime.c b/accel/tcg/tcg-runtime.c
12
diff --git a/target/hexagon/fma_emu.h b/target/hexagon/fma_emu.h
12
index XXXXXXX..XXXXXXX 100644
13
index XXXXXXX..XXXXXXX 100644
13
--- a/accel/tcg/tcg-runtime.c
14
--- a/target/hexagon/fma_emu.h
14
+++ b/accel/tcg/tcg-runtime.c
15
+++ b/target/hexagon/fma_emu.h
15
@@ -XXX,XX +XXX,XX @@
16
@@ -XXX,XX +XXX,XX @@ int32_t float32_getexp(float32 f32);
16
#include "exec/tb-lookup.h"
17
float32 infinite_float32(uint8_t sign);
17
#include "disas/disas.h"
18
float32 internal_fmafx(float32 a, float32 b, float32 c,
18
#include "exec/log.h"
19
int scale, float_status *fp_status);
19
+#include "tcg.h"
20
-float32 internal_mpyf(float32 a, float32 b, float_status *fp_status);
20
21
float64 internal_mpyhh(float64 a, float64 b,
21
/* 32-bit helpers */
22
unsigned long long int accumulated,
22
23
float_status *fp_status);
24
diff --git a/target/hexagon/fma_emu.c b/target/hexagon/fma_emu.c
25
index XXXXXXX..XXXXXXX 100644
26
--- a/target/hexagon/fma_emu.c
27
+++ b/target/hexagon/fma_emu.c
28
@@ -XXX,XX +XXX,XX @@ float32 internal_fmafx(float32 a, float32 b, float32 c, int scale,
29
return accum_round_float32(result, fp_status);
30
}
31
32
-float32 internal_mpyf(float32 a, float32 b, float_status *fp_status)
33
-{
34
- if (float32_is_zero(a) || float32_is_zero(b)) {
35
- return float32_mul(a, b, fp_status);
36
- }
37
- return internal_fmafx(a, b, float32_zero, 0, fp_status);
38
-}
39
-
40
float64 internal_mpyhh(float64 a, float64 b,
41
unsigned long long int accumulated,
42
float_status *fp_status)
43
diff --git a/target/hexagon/op_helper.c b/target/hexagon/op_helper.c
44
index XXXXXXX..XXXXXXX 100644
45
--- a/target/hexagon/op_helper.c
46
+++ b/target/hexagon/op_helper.c
47
@@ -XXX,XX +XXX,XX @@ float32 HELPER(sfmpy)(CPUHexagonState *env, float32 RsV, float32 RtV)
48
{
49
float32 RdV;
50
arch_fpop_start(env);
51
- RdV = internal_mpyf(RsV, RtV, &env->fp_status);
52
+ RdV = float32_mul(RsV, RtV, &env->fp_status);
53
arch_fpop_end(env);
54
return RdV;
55
}
23
--
56
--
24
2.20.1
57
2.43.0
25
26
diff view generated by jsdifflib
1
Code movement in an upcoming patch will show that this file
1
There are no special cases for this instruction.
2
was implicitly depending on tcg.h being included indirectly.
3
2
4
Cc: Peter Maydell <peter.maydell@linaro.org>
3
Reviewed-by: Brian Cain <brian.cain@oss.qualcomm.com>
5
Tested-by: Philippe Mathieu-Daudé <philmd@redhat.com>
6
Reviewed-by: Alex Bennée <alex.bennee@linaro.org>
7
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
4
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
8
---
5
---
9
target/arm/sve_helper.c | 1 +
6
target/hexagon/op_helper.c | 2 +-
10
1 file changed, 1 insertion(+)
7
1 file changed, 1 insertion(+), 1 deletion(-)
11
8
12
diff --git a/target/arm/sve_helper.c b/target/arm/sve_helper.c
9
diff --git a/target/hexagon/op_helper.c b/target/hexagon/op_helper.c
13
index XXXXXXX..XXXXXXX 100644
10
index XXXXXXX..XXXXXXX 100644
14
--- a/target/arm/sve_helper.c
11
--- a/target/hexagon/op_helper.c
15
+++ b/target/arm/sve_helper.c
12
+++ b/target/hexagon/op_helper.c
16
@@ -XXX,XX +XXX,XX @@
13
@@ -XXX,XX +XXX,XX @@ float32 HELPER(sffma)(CPUHexagonState *env, float32 RxV,
17
#include "exec/helper-proto.h"
14
float32 RsV, float32 RtV)
18
#include "tcg/tcg-gvec-desc.h"
15
{
19
#include "fpu/softfloat.h"
16
arch_fpop_start(env);
20
+#include "tcg.h"
17
- RxV = internal_fmafx(RsV, RtV, RxV, 0, &env->fp_status);
21
18
+ RxV = float32_muladd(RsV, RtV, RxV, 0, &env->fp_status);
22
19
arch_fpop_end(env);
23
/* Note that vector data is stored in host-endian 64-bit chunks,
20
return RxV;
21
}
24
--
22
--
25
2.20.1
23
2.43.0
26
27
diff view generated by jsdifflib
1
Code movement in an upcoming patch will show that this file
1
There are no special cases for this instruction. Since hexagon
2
was implicitly depending on tcg.h being included indirectly.
2
always uses default-nan mode, explicitly negating the first
3
input is unnecessary. Use float_muladd_negate_product instead.
3
4
4
Tested-by: Philippe Mathieu-Daudé <philmd@redhat.com>
5
Reviewed-by: Brian Cain <brian.cain@oss.qualcomm.com>
5
Reviewed-by: David Hildenbrand <david@redhat.com>
6
Reviewed-by: Alex Bennée <alex.bennee@linaro.org>
7
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
6
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
8
---
7
---
9
target/s390x/mem_helper.c | 1 +
8
target/hexagon/op_helper.c | 5 ++---
10
1 file changed, 1 insertion(+)
9
1 file changed, 2 insertions(+), 3 deletions(-)
11
10
12
diff --git a/target/s390x/mem_helper.c b/target/s390x/mem_helper.c
11
diff --git a/target/hexagon/op_helper.c b/target/hexagon/op_helper.c
13
index XXXXXXX..XXXXXXX 100644
12
index XXXXXXX..XXXXXXX 100644
14
--- a/target/s390x/mem_helper.c
13
--- a/target/hexagon/op_helper.c
15
+++ b/target/s390x/mem_helper.c
14
+++ b/target/hexagon/op_helper.c
16
@@ -XXX,XX +XXX,XX @@
15
@@ -XXX,XX +XXX,XX @@ float32 HELPER(sffma_sc)(CPUHexagonState *env, float32 RxV,
17
#include "exec/cpu_ldst.h"
16
float32 HELPER(sffms)(CPUHexagonState *env, float32 RxV,
18
#include "qemu/int128.h"
17
float32 RsV, float32 RtV)
19
#include "qemu/atomic128.h"
18
{
20
+#include "tcg.h"
19
- float32 neg_RsV;
21
20
arch_fpop_start(env);
22
#if !defined(CONFIG_USER_ONLY)
21
- neg_RsV = float32_set_sign(RsV, float32_is_neg(RsV) ? 0 : 1);
23
#include "hw/s390x/storage-keys.h"
22
- RxV = internal_fmafx(neg_RsV, RtV, RxV, 0, &env->fp_status);
23
+ RxV = float32_muladd(RsV, RtV, RxV, float_muladd_negate_product,
24
+ &env->fp_status);
25
arch_fpop_end(env);
26
return RxV;
27
}
24
--
28
--
25
2.20.1
29
2.43.0
26
27
diff view generated by jsdifflib
1
In the cpu_ldst templates, we already require a MemOp, and it
1
This instruction has a special case that 0 * x + c returns c
2
is cleaner and clearer to pass that instead of 3 separate
2
without the normal sign folding that comes with 0 + -0.
3
arguments describing the memory operation.
3
Use the new float_muladd_suppress_add_product_zero to
4
describe this.
4
5
5
Tested-by: Philippe Mathieu-Daudé <philmd@redhat.com>
6
Reviewed-by: Brian Cain <brian.cain@oss.qualcomm.com>
6
Reviewed-by: Alex Bennée <alex.bennee@linaro.org>
7
Reviewed-by: Philippe Mathieu-Daudé <philmd@redhat.com>
8
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
7
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
9
---
8
---
10
include/exec/cpu_ldst_template.h | 22 +++++++++++-----------
9
target/hexagon/op_helper.c | 11 +++--------
11
include/exec/cpu_ldst_useronly_template.h | 12 ++++++------
10
1 file changed, 3 insertions(+), 8 deletions(-)
12
2 files changed, 17 insertions(+), 17 deletions(-)
13
11
14
diff --git a/include/exec/cpu_ldst_template.h b/include/exec/cpu_ldst_template.h
12
diff --git a/target/hexagon/op_helper.c b/target/hexagon/op_helper.c
15
index XXXXXXX..XXXXXXX 100644
13
index XXXXXXX..XXXXXXX 100644
16
--- a/include/exec/cpu_ldst_template.h
14
--- a/target/hexagon/op_helper.c
17
+++ b/include/exec/cpu_ldst_template.h
15
+++ b/target/hexagon/op_helper.c
18
@@ -XXX,XX +XXX,XX @@ glue(glue(glue(cpu_ld, USUFFIX), MEMSUFFIX), _ra)(CPUArchState *env,
16
@@ -XXX,XX +XXX,XX @@ static float32 check_nan(float32 dst, float32 x, float_status *fp_status)
19
RES_TYPE res;
17
float32 HELPER(sffma_sc)(CPUHexagonState *env, float32 RxV,
20
target_ulong addr;
18
float32 RsV, float32 RtV, float32 PuV)
21
int mmu_idx = CPU_MMU_INDEX;
22
- TCGMemOpIdx oi;
23
+ MemOp op = MO_TE | SHIFT;
24
#if !defined(SOFTMMU_CODE_ACCESS)
25
- uint16_t meminfo = trace_mem_build_info(SHIFT, false, MO_TE, false, mmu_idx);
26
+ uint16_t meminfo = trace_mem_get_info(op, mmu_idx, false);
27
trace_guest_mem_before_exec(env_cpu(env), ptr, meminfo);
28
#endif
29
30
@@ -XXX,XX +XXX,XX @@ glue(glue(glue(cpu_ld, USUFFIX), MEMSUFFIX), _ra)(CPUArchState *env,
31
entry = tlb_entry(env, mmu_idx, addr);
32
if (unlikely(entry->ADDR_READ !=
33
(addr & (TARGET_PAGE_MASK | (DATA_SIZE - 1))))) {
34
- oi = make_memop_idx(SHIFT, mmu_idx);
35
+ TCGMemOpIdx oi = make_memop_idx(op, mmu_idx);
36
res = glue(glue(helper_ret_ld, URETSUFFIX), MMUSUFFIX)(env, addr,
37
- oi, retaddr);
38
+ oi, retaddr);
39
} else {
40
uintptr_t hostaddr = addr + entry->addend;
41
res = glue(glue(ld, USUFFIX), _p)((uint8_t *)hostaddr);
42
@@ -XXX,XX +XXX,XX @@ glue(glue(glue(cpu_lds, SUFFIX), MEMSUFFIX), _ra)(CPUArchState *env,
43
int res;
44
target_ulong addr;
45
int mmu_idx = CPU_MMU_INDEX;
46
- TCGMemOpIdx oi;
47
-#if !defined(SOFTMMU_CODE_ACCESS)
48
- uint16_t meminfo = trace_mem_build_info(SHIFT, true, MO_TE, false, mmu_idx);
49
+ MemOp op = MO_TE | MO_SIGN | SHIFT;
50
+#ifndef SOFTMMU_CODE_ACCESS
51
+ uint16_t meminfo = trace_mem_get_info(op, mmu_idx, false);
52
trace_guest_mem_before_exec(env_cpu(env), ptr, meminfo);
53
#endif
54
55
@@ -XXX,XX +XXX,XX @@ glue(glue(glue(cpu_lds, SUFFIX), MEMSUFFIX), _ra)(CPUArchState *env,
56
entry = tlb_entry(env, mmu_idx, addr);
57
if (unlikely(entry->ADDR_READ !=
58
(addr & (TARGET_PAGE_MASK | (DATA_SIZE - 1))))) {
59
- oi = make_memop_idx(SHIFT, mmu_idx);
60
+ TCGMemOpIdx oi = make_memop_idx(op & ~MO_SIGN, mmu_idx);
61
res = (DATA_STYPE)glue(glue(helper_ret_ld, SRETSUFFIX),
62
MMUSUFFIX)(env, addr, oi, retaddr);
63
} else {
64
@@ -XXX,XX +XXX,XX @@ glue(glue(glue(cpu_st, SUFFIX), MEMSUFFIX), _ra)(CPUArchState *env,
65
CPUTLBEntry *entry;
66
target_ulong addr;
67
int mmu_idx = CPU_MMU_INDEX;
68
- TCGMemOpIdx oi;
69
+ MemOp op = MO_TE | SHIFT;
70
#if !defined(SOFTMMU_CODE_ACCESS)
71
- uint16_t meminfo = trace_mem_build_info(SHIFT, false, MO_TE, true, mmu_idx);
72
+ uint16_t meminfo = trace_mem_get_info(op, mmu_idx, true);
73
trace_guest_mem_before_exec(env_cpu(env), ptr, meminfo);
74
#endif
75
76
@@ -XXX,XX +XXX,XX @@ glue(glue(glue(cpu_st, SUFFIX), MEMSUFFIX), _ra)(CPUArchState *env,
77
entry = tlb_entry(env, mmu_idx, addr);
78
if (unlikely(tlb_addr_write(entry) !=
79
(addr & (TARGET_PAGE_MASK | (DATA_SIZE - 1))))) {
80
- oi = make_memop_idx(SHIFT, mmu_idx);
81
+ TCGMemOpIdx oi = make_memop_idx(op, mmu_idx);
82
glue(glue(helper_ret_st, SUFFIX), MMUSUFFIX)(env, addr, v, oi,
83
retaddr);
84
} else {
85
diff --git a/include/exec/cpu_ldst_useronly_template.h b/include/exec/cpu_ldst_useronly_template.h
86
index XXXXXXX..XXXXXXX 100644
87
--- a/include/exec/cpu_ldst_useronly_template.h
88
+++ b/include/exec/cpu_ldst_useronly_template.h
89
@@ -XXX,XX +XXX,XX @@ glue(glue(cpu_ld, USUFFIX), MEMSUFFIX)(CPUArchState *env, abi_ptr ptr)
90
ret = glue(glue(ld, USUFFIX), _p)(g2h(ptr));
91
clear_helper_retaddr();
92
#else
93
- uint16_t meminfo = trace_mem_build_info(SHIFT, false, MO_TE, false,
94
- MMU_USER_IDX);
95
+ MemOp op = MO_TE | SHIFT;
96
+ uint16_t meminfo = trace_mem_get_info(op, MMU_USER_IDX, false);
97
trace_guest_mem_before_exec(env_cpu(env), ptr, meminfo);
98
ret = glue(glue(ld, USUFFIX), _p)(g2h(ptr));
99
#endif
100
@@ -XXX,XX +XXX,XX @@ glue(glue(cpu_lds, SUFFIX), MEMSUFFIX)(CPUArchState *env, abi_ptr ptr)
101
ret = glue(glue(lds, SUFFIX), _p)(g2h(ptr));
102
clear_helper_retaddr();
103
#else
104
- uint16_t meminfo = trace_mem_build_info(SHIFT, true, MO_TE, false,
105
- MMU_USER_IDX);
106
+ MemOp op = MO_TE | MO_SIGN | SHIFT;
107
+ uint16_t meminfo = trace_mem_get_info(op, MMU_USER_IDX, false);
108
trace_guest_mem_before_exec(env_cpu(env), ptr, meminfo);
109
ret = glue(glue(lds, SUFFIX), _p)(g2h(ptr));
110
qemu_plugin_vcpu_mem_cb(env_cpu(env), ptr, meminfo);
111
@@ -XXX,XX +XXX,XX @@ static inline void
112
glue(glue(cpu_st, SUFFIX), MEMSUFFIX)(CPUArchState *env, abi_ptr ptr,
113
RES_TYPE v)
114
{
19
{
115
- uint16_t meminfo = trace_mem_build_info(SHIFT, false, MO_TE, true,
20
- size4s_t tmp;
116
- MMU_USER_IDX);
21
arch_fpop_start(env);
117
+ MemOp op = MO_TE | SHIFT;
22
- RxV = check_nan(RxV, RxV, &env->fp_status);
118
+ uint16_t meminfo = trace_mem_get_info(op, MMU_USER_IDX, true);
23
- RxV = check_nan(RxV, RsV, &env->fp_status);
119
trace_guest_mem_before_exec(env_cpu(env), ptr, meminfo);
24
- RxV = check_nan(RxV, RtV, &env->fp_status);
120
glue(glue(st, SUFFIX), _p)(g2h(ptr), v);
25
- tmp = internal_fmafx(RsV, RtV, RxV, fSXTN(8, 64, PuV), &env->fp_status);
121
qemu_plugin_vcpu_mem_cb(env_cpu(env), ptr, meminfo);
26
- if (!(float32_is_zero(RxV) && is_zero_prod(RsV, RtV))) {
27
- RxV = tmp;
28
- }
29
+ RxV = float32_muladd_scalbn(RsV, RtV, RxV, fSXTN(8, 64, PuV),
30
+ float_muladd_suppress_add_product_zero,
31
+ &env->fp_status);
32
arch_fpop_end(env);
33
return RxV;
34
}
122
--
35
--
123
2.20.1
36
2.43.0
124
125
diff view generated by jsdifflib
1
From: Philippe Mathieu-Daudé <philmd@redhat.com>
1
There are multiple special cases for this instruction.
2
(1) The saturate to normal maximum instead of overflow to infinity is
3
handled by the new float_round_nearest_even_max rounding mode.
4
(2) The 0 * n + c special case is handled by the new
5
float_muladd_suppress_add_product_zero flag.
6
(3) The Inf - Inf -> 0 special case can be detected after the fact
7
by examining float_flag_invalid_isi.
2
8
3
All the *.inc.c files included by tcg/$TARGET/tcg-target.inc.c
9
Reviewed-by: Brian Cain <brian.cain@oss.qualcomm.com>
4
are in tcg/, their parent directory. To simplify the preprocessor
5
search path, include the relative parent path: '..'.
6
7
Patch created mechanically by running:
8
9
$ for x in tcg-pool.inc.c tcg-ldst.inc.c; do \
10
sed -i "s,#include \"$x\",#include \"../$x\"," \
11
$(git grep -l "#include \"$x\""); \
12
done
13
14
Acked-by: David Gibson <david@gibson.dropbear.id.au> (ppc parts)
15
Reviewed-by: Paolo Bonzini <pbonzini@redhat.com>
16
Reviewed-by: Alistair Francis <alistair.francis@wdc.com>
17
Reviewed-by: Stefan Weil <sw@weilnetz.de>
18
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
19
Signed-off-by: Philippe Mathieu-Daudé <philmd@redhat.com>
20
Message-Id: <20200101112303.20724-3-philmd@redhat.com>
21
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
10
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
22
---
11
---
23
tcg/aarch64/tcg-target.inc.c | 4 ++--
12
target/hexagon/op_helper.c | 105 +++++++++----------------------------
24
tcg/arm/tcg-target.inc.c | 4 ++--
13
1 file changed, 26 insertions(+), 79 deletions(-)
25
tcg/i386/tcg-target.inc.c | 4 ++--
26
tcg/mips/tcg-target.inc.c | 2 +-
27
tcg/ppc/tcg-target.inc.c | 4 ++--
28
tcg/riscv/tcg-target.inc.c | 4 ++--
29
tcg/s390/tcg-target.inc.c | 4 ++--
30
tcg/sparc/tcg-target.inc.c | 2 +-
31
8 files changed, 14 insertions(+), 14 deletions(-)
32
14
33
diff --git a/tcg/aarch64/tcg-target.inc.c b/tcg/aarch64/tcg-target.inc.c
15
diff --git a/target/hexagon/op_helper.c b/target/hexagon/op_helper.c
34
index XXXXXXX..XXXXXXX 100644
16
index XXXXXXX..XXXXXXX 100644
35
--- a/tcg/aarch64/tcg-target.inc.c
17
--- a/target/hexagon/op_helper.c
36
+++ b/tcg/aarch64/tcg-target.inc.c
18
+++ b/target/hexagon/op_helper.c
37
@@ -XXX,XX +XXX,XX @@
19
@@ -XXX,XX +XXX,XX @@ float32 HELPER(sffma)(CPUHexagonState *env, float32 RxV,
38
* See the COPYING file in the top-level directory for details.
20
return RxV;
39
*/
40
41
-#include "tcg-pool.inc.c"
42
+#include "../tcg-pool.inc.c"
43
#include "qemu/bitops.h"
44
45
/* We're going to re-use TCGType in setting of the SF bit, which controls
46
@@ -XXX,XX +XXX,XX @@ static void tcg_out_cltz(TCGContext *s, TCGType ext, TCGReg d,
47
}
21
}
48
22
49
#ifdef CONFIG_SOFTMMU
23
-static bool is_zero_prod(float32 a, float32 b)
50
-#include "tcg-ldst.inc.c"
24
-{
51
+#include "../tcg-ldst.inc.c"
25
- return ((float32_is_zero(a) && is_finite(b)) ||
52
26
- (float32_is_zero(b) && is_finite(a)));
53
/* helper signature: helper_ret_ld_mmu(CPUState *env, target_ulong addr,
27
-}
54
* TCGMemOpIdx oi, uintptr_t ra)
28
-
55
diff --git a/tcg/arm/tcg-target.inc.c b/tcg/arm/tcg-target.inc.c
29
-static float32 check_nan(float32 dst, float32 x, float_status *fp_status)
56
index XXXXXXX..XXXXXXX 100644
30
-{
57
--- a/tcg/arm/tcg-target.inc.c
31
- float32 ret = dst;
58
+++ b/tcg/arm/tcg-target.inc.c
32
- if (float32_is_any_nan(x)) {
59
@@ -XXX,XX +XXX,XX @@
33
- if (extract32(x, 22, 1) == 0) {
60
*/
34
- float_raise(float_flag_invalid, fp_status);
61
35
- }
62
#include "elf.h"
36
- ret = make_float32(0xffffffff); /* nan */
63
-#include "tcg-pool.inc.c"
37
- }
64
+#include "../tcg-pool.inc.c"
38
- return ret;
65
39
-}
66
int arm_arch = __ARM_ARCH;
40
-
67
41
float32 HELPER(sffma_sc)(CPUHexagonState *env, float32 RxV,
68
@@ -XXX,XX +XXX,XX @@ static TCGCond tcg_out_cmp2(TCGContext *s, const TCGArg *args,
42
float32 RsV, float32 RtV, float32 PuV)
43
{
44
@@ -XXX,XX +XXX,XX @@ float32 HELPER(sffms)(CPUHexagonState *env, float32 RxV,
45
return RxV;
69
}
46
}
70
47
71
#ifdef CONFIG_SOFTMMU
48
-static bool is_inf_prod(int32_t a, int32_t b)
72
-#include "tcg-ldst.inc.c"
49
+static float32 do_sffma_lib(CPUHexagonState *env, float32 RxV,
73
+#include "../tcg-ldst.inc.c"
50
+ float32 RsV, float32 RtV, int negate)
74
51
{
75
/* helper signature: helper_ret_ld_mmu(CPUState *env, target_ulong addr,
52
- return (float32_is_infinity(a) && float32_is_infinity(b)) ||
76
* int mmu_idx, uintptr_t ra)
53
- (float32_is_infinity(a) && is_finite(b) && !float32_is_zero(b)) ||
77
diff --git a/tcg/i386/tcg-target.inc.c b/tcg/i386/tcg-target.inc.c
54
- (float32_is_infinity(b) && is_finite(a) && !float32_is_zero(a));
78
index XXXXXXX..XXXXXXX 100644
55
+ int flags;
79
--- a/tcg/i386/tcg-target.inc.c
56
+
80
+++ b/tcg/i386/tcg-target.inc.c
57
+ arch_fpop_start(env);
81
@@ -XXX,XX +XXX,XX @@
58
+
82
* THE SOFTWARE.
59
+ set_float_rounding_mode(float_round_nearest_even_max, &env->fp_status);
83
*/
60
+ RxV = float32_muladd(RsV, RtV, RxV,
84
61
+ negate | float_muladd_suppress_add_product_zero,
85
-#include "tcg-pool.inc.c"
62
+ &env->fp_status);
86
+#include "../tcg-pool.inc.c"
63
+
87
64
+ flags = get_float_exception_flags(&env->fp_status);
88
#ifdef CONFIG_DEBUG_TCG
65
+ if (flags) {
89
static const char * const tcg_target_reg_names[TCG_TARGET_NB_REGS] = {
66
+ /* Flags are suppressed by this instruction. */
90
@@ -XXX,XX +XXX,XX @@ static void tcg_out_nopn(TCGContext *s, int n)
67
+ set_float_exception_flags(0, &env->fp_status);
68
+
69
+ /* Return 0 for Inf - Inf. */
70
+ if (flags & float_flag_invalid_isi) {
71
+ RxV = 0;
72
+ }
73
+ }
74
+
75
+ arch_fpop_end(env);
76
+ return RxV;
91
}
77
}
92
78
93
#if defined(CONFIG_SOFTMMU)
79
float32 HELPER(sffma_lib)(CPUHexagonState *env, float32 RxV,
94
-#include "tcg-ldst.inc.c"
80
float32 RsV, float32 RtV)
95
+#include "../tcg-ldst.inc.c"
81
{
96
82
- bool infinp;
97
/* helper signature: helper_ret_ld_mmu(CPUState *env, target_ulong addr,
83
- bool infminusinf;
98
* int mmu_idx, uintptr_t ra)
84
- float32 tmp;
99
diff --git a/tcg/mips/tcg-target.inc.c b/tcg/mips/tcg-target.inc.c
85
-
100
index XXXXXXX..XXXXXXX 100644
86
- arch_fpop_start(env);
101
--- a/tcg/mips/tcg-target.inc.c
87
- set_float_rounding_mode(float_round_nearest_even, &env->fp_status);
102
+++ b/tcg/mips/tcg-target.inc.c
88
- infminusinf = float32_is_infinity(RxV) &&
103
@@ -XXX,XX +XXX,XX @@ static void tcg_out_call(TCGContext *s, tcg_insn_unit *arg)
89
- is_inf_prod(RsV, RtV) &&
90
- (fGETBIT(31, RsV ^ RxV ^ RtV) != 0);
91
- infinp = float32_is_infinity(RxV) ||
92
- float32_is_infinity(RtV) ||
93
- float32_is_infinity(RsV);
94
- RxV = check_nan(RxV, RxV, &env->fp_status);
95
- RxV = check_nan(RxV, RsV, &env->fp_status);
96
- RxV = check_nan(RxV, RtV, &env->fp_status);
97
- tmp = internal_fmafx(RsV, RtV, RxV, 0, &env->fp_status);
98
- if (!(float32_is_zero(RxV) && is_zero_prod(RsV, RtV))) {
99
- RxV = tmp;
100
- }
101
- set_float_exception_flags(0, &env->fp_status);
102
- if (float32_is_infinity(RxV) && !infinp) {
103
- RxV = RxV - 1;
104
- }
105
- if (infminusinf) {
106
- RxV = 0;
107
- }
108
- arch_fpop_end(env);
109
- return RxV;
110
+ return do_sffma_lib(env, RxV, RsV, RtV, 0);
104
}
111
}
105
112
106
#if defined(CONFIG_SOFTMMU)
113
float32 HELPER(sffms_lib)(CPUHexagonState *env, float32 RxV,
107
-#include "tcg-ldst.inc.c"
114
float32 RsV, float32 RtV)
108
+#include "../tcg-ldst.inc.c"
115
{
109
116
- bool infinp;
110
static void * const qemu_ld_helpers[16] = {
117
- bool infminusinf;
111
[MO_UB] = helper_ret_ldub_mmu,
118
- float32 tmp;
112
diff --git a/tcg/ppc/tcg-target.inc.c b/tcg/ppc/tcg-target.inc.c
119
-
113
index XXXXXXX..XXXXXXX 100644
120
- arch_fpop_start(env);
114
--- a/tcg/ppc/tcg-target.inc.c
121
- set_float_rounding_mode(float_round_nearest_even, &env->fp_status);
115
+++ b/tcg/ppc/tcg-target.inc.c
122
- infminusinf = float32_is_infinity(RxV) &&
116
@@ -XXX,XX +XXX,XX @@
123
- is_inf_prod(RsV, RtV) &&
117
*/
124
- (fGETBIT(31, RsV ^ RxV ^ RtV) == 0);
118
125
- infinp = float32_is_infinity(RxV) ||
119
#include "elf.h"
126
- float32_is_infinity(RtV) ||
120
-#include "tcg-pool.inc.c"
127
- float32_is_infinity(RsV);
121
+#include "../tcg-pool.inc.c"
128
- RxV = check_nan(RxV, RxV, &env->fp_status);
122
129
- RxV = check_nan(RxV, RsV, &env->fp_status);
123
#if defined _CALL_DARWIN || defined __APPLE__
130
- RxV = check_nan(RxV, RtV, &env->fp_status);
124
#define TCG_TARGET_CALL_DARWIN
131
- float32 minus_RsV = float32_sub(float32_zero, RsV, &env->fp_status);
125
@@ -XXX,XX +XXX,XX @@ static const uint32_t qemu_exts_opc[4] = {
132
- tmp = internal_fmafx(minus_RsV, RtV, RxV, 0, &env->fp_status);
126
};
133
- if (!(float32_is_zero(RxV) && is_zero_prod(RsV, RtV))) {
127
134
- RxV = tmp;
128
#if defined (CONFIG_SOFTMMU)
135
- }
129
-#include "tcg-ldst.inc.c"
136
- set_float_exception_flags(0, &env->fp_status);
130
+#include "../tcg-ldst.inc.c"
137
- if (float32_is_infinity(RxV) && !infinp) {
131
138
- RxV = RxV - 1;
132
/* helper signature: helper_ld_mmu(CPUState *env, target_ulong addr,
139
- }
133
* int mmu_idx, uintptr_t ra)
140
- if (infminusinf) {
134
diff --git a/tcg/riscv/tcg-target.inc.c b/tcg/riscv/tcg-target.inc.c
141
- RxV = 0;
135
index XXXXXXX..XXXXXXX 100644
142
- }
136
--- a/tcg/riscv/tcg-target.inc.c
143
- arch_fpop_end(env);
137
+++ b/tcg/riscv/tcg-target.inc.c
144
- return RxV;
138
@@ -XXX,XX +XXX,XX @@
145
+ return do_sffma_lib(env, RxV, RsV, RtV, float_muladd_negate_product);
139
* THE SOFTWARE.
140
*/
141
142
-#include "tcg-pool.inc.c"
143
+#include "../tcg-pool.inc.c"
144
145
#ifdef CONFIG_DEBUG_TCG
146
static const char * const tcg_target_reg_names[TCG_TARGET_NB_REGS] = {
147
@@ -XXX,XX +XXX,XX @@ static void tcg_out_mb(TCGContext *s, TCGArg a0)
148
*/
149
150
#if defined(CONFIG_SOFTMMU)
151
-#include "tcg-ldst.inc.c"
152
+#include "../tcg-ldst.inc.c"
153
154
/* helper signature: helper_ret_ld_mmu(CPUState *env, target_ulong addr,
155
* TCGMemOpIdx oi, uintptr_t ra)
156
diff --git a/tcg/s390/tcg-target.inc.c b/tcg/s390/tcg-target.inc.c
157
index XXXXXXX..XXXXXXX 100644
158
--- a/tcg/s390/tcg-target.inc.c
159
+++ b/tcg/s390/tcg-target.inc.c
160
@@ -XXX,XX +XXX,XX @@
161
#error "unsupported code generation mode"
162
#endif
163
164
-#include "tcg-pool.inc.c"
165
+#include "../tcg-pool.inc.c"
166
#include "elf.h"
167
168
/* ??? The translation blocks produced by TCG are generally small enough to
169
@@ -XXX,XX +XXX,XX @@ static void tcg_out_qemu_st_direct(TCGContext *s, MemOp opc, TCGReg data,
170
}
146
}
171
147
172
#if defined(CONFIG_SOFTMMU)
148
float64 HELPER(dfmpyfix)(CPUHexagonState *env, float64 RssV, float64 RttV)
173
-#include "tcg-ldst.inc.c"
174
+#include "../tcg-ldst.inc.c"
175
176
/* We're expecting to use a 20-bit negative offset on the tlb memory ops. */
177
QEMU_BUILD_BUG_ON(TLB_MASK_TABLE_OFS(0) > 0);
178
diff --git a/tcg/sparc/tcg-target.inc.c b/tcg/sparc/tcg-target.inc.c
179
index XXXXXXX..XXXXXXX 100644
180
--- a/tcg/sparc/tcg-target.inc.c
181
+++ b/tcg/sparc/tcg-target.inc.c
182
@@ -XXX,XX +XXX,XX @@
183
* THE SOFTWARE.
184
*/
185
186
-#include "tcg-pool.inc.c"
187
+#include "../tcg-pool.inc.c"
188
189
#ifdef CONFIG_DEBUG_TCG
190
static const char * const tcg_target_reg_names[TCG_TARGET_NB_REGS] = {
191
--
149
--
192
2.20.1
150
2.43.0
193
194
diff view generated by jsdifflib
1
Recent toolchains support static and pie at the same time.
1
The function is now unused.
2
2
3
As with normal dynamic builds, allow --static to default to PIE
3
Reviewed-by: Brian Cain <brian.cain@oss.qualcomm.com>
4
if supported by the toolchain. Allow --enable/--disable-pie to
5
override the default.
6
7
Reviewed-by: Alex Bennée <alex.bennee@linaro.org>
8
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
4
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
9
---
5
---
10
v2: Fix --disable-pie --static
6
target/hexagon/fma_emu.h | 2 -
11
---
7
target/hexagon/fma_emu.c | 171 ---------------------------------------
12
configure | 19 ++++++++++++-------
8
2 files changed, 173 deletions(-)
13
1 file changed, 12 insertions(+), 7 deletions(-)
14
9
15
diff --git a/configure b/configure
10
diff --git a/target/hexagon/fma_emu.h b/target/hexagon/fma_emu.h
16
index XXXXXXX..XXXXXXX 100755
11
index XXXXXXX..XXXXXXX 100644
17
--- a/configure
12
--- a/target/hexagon/fma_emu.h
18
+++ b/configure
13
+++ b/target/hexagon/fma_emu.h
19
@@ -XXX,XX +XXX,XX @@ for opt do
14
@@ -XXX,XX +XXX,XX @@ static inline uint32_t float32_getexp_raw(float32 f32)
20
;;
15
}
21
--static)
16
int32_t float32_getexp(float32 f32);
22
static="yes"
17
float32 infinite_float32(uint8_t sign);
23
- LDFLAGS="-static $LDFLAGS"
18
-float32 internal_fmafx(float32 a, float32 b, float32 c,
24
QEMU_PKG_CONFIG_FLAGS="--static $QEMU_PKG_CONFIG_FLAGS"
19
- int scale, float_status *fp_status);
25
;;
20
float64 internal_mpyhh(float64 a, float64 b,
26
--mandir=*) mandir="$optarg"
21
unsigned long long int accumulated,
27
@@ -XXX,XX +XXX,XX @@ if test "$static" = "yes" ; then
22
float_status *fp_status);
28
if test "$modules" = "yes" ; then
23
diff --git a/target/hexagon/fma_emu.c b/target/hexagon/fma_emu.c
29
error_exit "static and modules are mutually incompatible"
24
index XXXXXXX..XXXXXXX 100644
30
fi
25
--- a/target/hexagon/fma_emu.c
31
- if test "$pie" = "yes" ; then
26
+++ b/target/hexagon/fma_emu.c
32
- error_exit "static and pie are mutually incompatible"
27
@@ -XXX,XX +XXX,XX @@ int32_t float64_getexp(float64 f64)
33
- else
28
return -1;
34
- pie="no"
29
}
35
- fi
30
36
fi
31
-static uint64_t float32_getmant(float32 f32)
37
32
-{
38
# Unconditional check for compiler __thread support
33
- Float a = { .i = f32 };
39
@@ -XXX,XX +XXX,XX @@ if compile_prog "-Werror -fno-pie" "-no-pie"; then
34
- if (float32_is_normal(f32)) {
40
LDFLAGS_NOPIE="-no-pie"
35
- return a.mant | 1ULL << 23;
41
fi
36
- }
42
37
- if (float32_is_zero(f32)) {
43
-if test "$pie" = "no"; then
38
- return 0;
44
+if test "$static" = "yes"; then
39
- }
45
+ if test "$pie" != "no" && compile_prog "-fPIE -DPIE" "-static-pie"; then
40
- if (float32_is_denormal(f32)) {
46
+ QEMU_CFLAGS="-fPIE -DPIE $QEMU_CFLAGS"
41
- return a.mant;
47
+ LDFLAGS="-static-pie $LDFLAGS"
42
- }
48
+ pie="yes"
43
- return ~0ULL;
49
+ elif test "$pie" = "yes"; then
44
-}
50
+ error_exit "-static-pie not available due to missing toolchain support"
45
-
51
+ else
46
int32_t float32_getexp(float32 f32)
52
+ LDFLAGS="-static $LDFLAGS"
47
{
53
+ pie="no"
48
Float a = { .i = f32 };
54
+ fi
49
@@ -XXX,XX +XXX,XX @@ float32 infinite_float32(uint8_t sign)
55
+elif test "$pie" = "no"; then
50
}
56
QEMU_CFLAGS="$CFLAGS_NOPIE $QEMU_CFLAGS"
51
57
LDFLAGS="$LDFLAGS_NOPIE $LDFLAGS"
52
/* Return a maximum finite value with the requested sign */
58
elif compile_prog "-fPIE -DPIE" "-pie"; then
53
-static float32 maxfinite_float32(uint8_t sign)
54
-{
55
- if (sign) {
56
- return make_float32(SF_MINUS_MAXF);
57
- } else {
58
- return make_float32(SF_MAXF);
59
- }
60
-}
61
-
62
-/* Return a zero value with requested sign */
63
-static float32 zero_float32(uint8_t sign)
64
-{
65
- if (sign) {
66
- return make_float32(0x80000000);
67
- } else {
68
- return float32_zero;
69
- }
70
-}
71
-
72
#define GEN_XF_ROUND(SUFFIX, MANTBITS, INF_EXP, INTERNAL_TYPE) \
73
static SUFFIX accum_round_##SUFFIX(Accum a, float_status * fp_status) \
74
{ \
75
@@ -XXX,XX +XXX,XX @@ static SUFFIX accum_round_##SUFFIX(Accum a, float_status * fp_status) \
76
}
77
78
GEN_XF_ROUND(float64, DF_MANTBITS, DF_INF_EXP, Double)
79
-GEN_XF_ROUND(float32, SF_MANTBITS, SF_INF_EXP, Float)
80
-
81
-static bool is_inf_prod(float64 a, float64 b)
82
-{
83
- return ((float64_is_infinity(a) && float64_is_infinity(b)) ||
84
- (float64_is_infinity(a) && is_finite(b) && (!float64_is_zero(b))) ||
85
- (float64_is_infinity(b) && is_finite(a) && (!float64_is_zero(a))));
86
-}
87
-
88
-static float64 special_fma(float64 a, float64 b, float64 c,
89
- float_status *fp_status)
90
-{
91
- float64 ret = make_float64(0);
92
-
93
- /*
94
- * If A multiplied by B is an exact infinity and C is also an infinity
95
- * but with the opposite sign, FMA returns NaN and raises invalid.
96
- */
97
- uint8_t a_sign = float64_is_neg(a);
98
- uint8_t b_sign = float64_is_neg(b);
99
- uint8_t c_sign = float64_is_neg(c);
100
- if (is_inf_prod(a, b) && float64_is_infinity(c)) {
101
- if ((a_sign ^ b_sign) != c_sign) {
102
- ret = make_float64(DF_NAN);
103
- float_raise(float_flag_invalid, fp_status);
104
- return ret;
105
- }
106
- }
107
- if ((float64_is_infinity(a) && float64_is_zero(b)) ||
108
- (float64_is_zero(a) && float64_is_infinity(b))) {
109
- ret = make_float64(DF_NAN);
110
- float_raise(float_flag_invalid, fp_status);
111
- return ret;
112
- }
113
- /*
114
- * If none of the above checks are true and C is a NaN,
115
- * a NaN shall be returned
116
- * If A or B are NaN, a NAN shall be returned.
117
- */
118
- if (float64_is_any_nan(a) ||
119
- float64_is_any_nan(b) ||
120
- float64_is_any_nan(c)) {
121
- if (float64_is_any_nan(a) && (fGETBIT(51, a) == 0)) {
122
- float_raise(float_flag_invalid, fp_status);
123
- }
124
- if (float64_is_any_nan(b) && (fGETBIT(51, b) == 0)) {
125
- float_raise(float_flag_invalid, fp_status);
126
- }
127
- if (float64_is_any_nan(c) && (fGETBIT(51, c) == 0)) {
128
- float_raise(float_flag_invalid, fp_status);
129
- }
130
- ret = make_float64(DF_NAN);
131
- return ret;
132
- }
133
- /*
134
- * We have checked for adding opposite-signed infinities.
135
- * Other infinities return infinity with the correct sign
136
- */
137
- if (float64_is_infinity(c)) {
138
- ret = infinite_float64(c_sign);
139
- return ret;
140
- }
141
- if (float64_is_infinity(a) || float64_is_infinity(b)) {
142
- ret = infinite_float64(a_sign ^ b_sign);
143
- return ret;
144
- }
145
- g_assert_not_reached();
146
-}
147
-
148
-static float32 special_fmaf(float32 a, float32 b, float32 c,
149
- float_status *fp_status)
150
-{
151
- float64 aa, bb, cc;
152
- aa = float32_to_float64(a, fp_status);
153
- bb = float32_to_float64(b, fp_status);
154
- cc = float32_to_float64(c, fp_status);
155
- return float64_to_float32(special_fma(aa, bb, cc, fp_status), fp_status);
156
-}
157
-
158
-float32 internal_fmafx(float32 a, float32 b, float32 c, int scale,
159
- float_status *fp_status)
160
-{
161
- Accum prod;
162
- Accum acc;
163
- Accum result;
164
- accum_init(&prod);
165
- accum_init(&acc);
166
- accum_init(&result);
167
-
168
- uint8_t a_sign = float32_is_neg(a);
169
- uint8_t b_sign = float32_is_neg(b);
170
- uint8_t c_sign = float32_is_neg(c);
171
- if (float32_is_infinity(a) ||
172
- float32_is_infinity(b) ||
173
- float32_is_infinity(c)) {
174
- return special_fmaf(a, b, c, fp_status);
175
- }
176
- if (float32_is_any_nan(a) ||
177
- float32_is_any_nan(b) ||
178
- float32_is_any_nan(c)) {
179
- return special_fmaf(a, b, c, fp_status);
180
- }
181
- if ((scale == 0) && (float32_is_zero(a) || float32_is_zero(b))) {
182
- float32 tmp = float32_mul(a, b, fp_status);
183
- tmp = float32_add(tmp, c, fp_status);
184
- return tmp;
185
- }
186
-
187
- /* (a * 2**b) * (c * 2**d) == a*c * 2**(b+d) */
188
- prod.mant = int128_mul_6464(float32_getmant(a), float32_getmant(b));
189
-
190
- /*
191
- * Note: extracting the mantissa into an int is multiplying by
192
- * 2**23, so adjust here
193
- */
194
- prod.exp = float32_getexp(a) + float32_getexp(b) - SF_BIAS - 23;
195
- prod.sign = a_sign ^ b_sign;
196
- if (float32_is_zero(a) || float32_is_zero(b)) {
197
- prod.exp = -2 * WAY_BIG_EXP;
198
- }
199
- if ((scale > 0) && float32_is_denormal(c)) {
200
- acc.mant = int128_mul_6464(0, 0);
201
- acc.exp = -WAY_BIG_EXP;
202
- acc.sign = c_sign;
203
- acc.sticky = 1;
204
- result = accum_add(prod, acc);
205
- } else if (!float32_is_zero(c)) {
206
- acc.mant = int128_mul_6464(float32_getmant(c), 1);
207
- acc.exp = float32_getexp(c);
208
- acc.sign = c_sign;
209
- result = accum_add(prod, acc);
210
- } else {
211
- result = prod;
212
- }
213
- result.exp += scale;
214
- return accum_round_float32(result, fp_status);
215
-}
216
217
float64 internal_mpyhh(float64 a, float64 b,
218
unsigned long long int accumulated,
59
--
219
--
60
2.20.1
220
2.43.0
61
62
diff view generated by jsdifflib
1
PIE is supported on many other hosts besides x86.
1
This massive macro is now only used once.
2
Expand it for use only by float64.
2
3
3
The default for non-x86 is now the same as x86: pie is used
4
Reviewed-by: Brian Cain <brian.cain@oss.qualcomm.com>
4
if supported, and may be forced via --enable/--disable-pie.
5
6
The original commit (40d6444e91c) said:
7
8
"Non-x86 are not changed, as they require TCG changes"
9
10
but I think that's wrong -- there's nothing about PIE that
11
affects TCG one way or another.
12
13
Tested on aarch64 (bionic) and ppc64le (centos 7) hosts.
14
15
Tested-by: Alex Bennée <alex.bennee@linaro.org>
16
Reviewed-by: Alex Bennée <alex.bennee@linaro.org>
17
Reviewed-by: Philippe Mathieu-Daudé <philmd@redhat.com>
18
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
5
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
19
---
6
---
20
configure | 10 ----------
7
target/hexagon/fma_emu.c | 255 +++++++++++++++++++--------------------
21
1 file changed, 10 deletions(-)
8
1 file changed, 127 insertions(+), 128 deletions(-)
22
9
23
diff --git a/configure b/configure
10
diff --git a/target/hexagon/fma_emu.c b/target/hexagon/fma_emu.c
24
index XXXXXXX..XXXXXXX 100755
11
index XXXXXXX..XXXXXXX 100644
25
--- a/configure
12
--- a/target/hexagon/fma_emu.c
26
+++ b/configure
13
+++ b/target/hexagon/fma_emu.c
27
@@ -XXX,XX +XXX,XX @@ if ! compile_prog "-Werror" "" ; then
14
@@ -XXX,XX +XXX,XX @@ float32 infinite_float32(uint8_t sign)
28
    "Thread-Local Storage (TLS). Please upgrade to a version that does."
15
}
29
fi
16
30
17
/* Return a maximum finite value with the requested sign */
31
-if test "$pie" = ""; then
18
-#define GEN_XF_ROUND(SUFFIX, MANTBITS, INF_EXP, INTERNAL_TYPE) \
32
- case "$cpu-$targetos" in
19
-static SUFFIX accum_round_##SUFFIX(Accum a, float_status * fp_status) \
33
- i386-Linux|x86_64-Linux|x32-Linux|i386-OpenBSD|x86_64-OpenBSD)
20
-{ \
34
- ;;
21
- if ((int128_gethi(a.mant) == 0) && (int128_getlo(a.mant) == 0) \
35
- *)
22
- && ((a.guard | a.round | a.sticky) == 0)) { \
36
- pie="no"
23
- /* result zero */ \
37
- ;;
24
- switch (fp_status->float_rounding_mode) { \
38
- esac
25
- case float_round_down: \
39
-fi
26
- return zero_##SUFFIX(1); \
27
- default: \
28
- return zero_##SUFFIX(0); \
29
- } \
30
- } \
31
- /* Normalize right */ \
32
- /* We want MANTBITS bits of mantissa plus the leading one. */ \
33
- /* That means that we want MANTBITS+1 bits, or 0x000000000000FF_FFFF */ \
34
- /* So we need to normalize right while the high word is non-zero and \
35
- * while the low word is nonzero when masked with 0xffe0_0000_0000_0000 */ \
36
- while ((int128_gethi(a.mant) != 0) || \
37
- ((int128_getlo(a.mant) >> (MANTBITS + 1)) != 0)) { \
38
- a = accum_norm_right(a, 1); \
39
- } \
40
- /* \
41
- * OK, now normalize left \
42
- * We want to normalize left until we have a leading one in bit 24 \
43
- * Theoretically, we only need to shift a maximum of one to the left if we \
44
- * shifted out lots of bits from B, or if we had no shift / 1 shift sticky \
45
- * should be 0 \
46
- */ \
47
- while ((int128_getlo(a.mant) & (1ULL << MANTBITS)) == 0) { \
48
- a = accum_norm_left(a); \
49
- } \
50
- /* \
51
- * OK, now we might need to denormalize because of potential underflow. \
52
- * We need to do this before rounding, and rounding might make us normal \
53
- * again \
54
- */ \
55
- while (a.exp <= 0) { \
56
- a = accum_norm_right(a, 1 - a.exp); \
57
- /* \
58
- * Do we have underflow? \
59
- * That's when we get an inexact answer because we ran out of bits \
60
- * in a denormal. \
61
- */ \
62
- if (a.guard || a.round || a.sticky) { \
63
- float_raise(float_flag_underflow, fp_status); \
64
- } \
65
- } \
66
- /* OK, we're relatively canonical... now we need to round */ \
67
- if (a.guard || a.round || a.sticky) { \
68
- float_raise(float_flag_inexact, fp_status); \
69
- switch (fp_status->float_rounding_mode) { \
70
- case float_round_to_zero: \
71
- /* Chop and we're done */ \
72
- break; \
73
- case float_round_up: \
74
- if (a.sign == 0) { \
75
- a.mant = int128_add(a.mant, int128_one()); \
76
- } \
77
- break; \
78
- case float_round_down: \
79
- if (a.sign != 0) { \
80
- a.mant = int128_add(a.mant, int128_one()); \
81
- } \
82
- break; \
83
- default: \
84
- if (a.round || a.sticky) { \
85
- /* round up if guard is 1, down if guard is zero */ \
86
- a.mant = int128_add(a.mant, int128_make64(a.guard)); \
87
- } else if (a.guard) { \
88
- /* exactly .5, round up if odd */ \
89
- a.mant = int128_add(a.mant, int128_and(a.mant, int128_one())); \
90
- } \
91
- break; \
92
- } \
93
- } \
94
- /* \
95
- * OK, now we might have carried all the way up. \
96
- * So we might need to shr once \
97
- * at least we know that the lsb should be zero if we rounded and \
98
- * got a carry out... \
99
- */ \
100
- if ((int128_getlo(a.mant) >> (MANTBITS + 1)) != 0) { \
101
- a = accum_norm_right(a, 1); \
102
- } \
103
- /* Overflow? */ \
104
- if (a.exp >= INF_EXP) { \
105
- /* Yep, inf result */ \
106
- float_raise(float_flag_overflow, fp_status); \
107
- float_raise(float_flag_inexact, fp_status); \
108
- switch (fp_status->float_rounding_mode) { \
109
- case float_round_to_zero: \
110
- return maxfinite_##SUFFIX(a.sign); \
111
- case float_round_up: \
112
- if (a.sign == 0) { \
113
- return infinite_##SUFFIX(a.sign); \
114
- } else { \
115
- return maxfinite_##SUFFIX(a.sign); \
116
- } \
117
- case float_round_down: \
118
- if (a.sign != 0) { \
119
- return infinite_##SUFFIX(a.sign); \
120
- } else { \
121
- return maxfinite_##SUFFIX(a.sign); \
122
- } \
123
- default: \
124
- return infinite_##SUFFIX(a.sign); \
125
- } \
126
- } \
127
- /* Underflow? */ \
128
- if (int128_getlo(a.mant) & (1ULL << MANTBITS)) { \
129
- /* Leading one means: No, we're normal. So, we should be done... */ \
130
- INTERNAL_TYPE ret; \
131
- ret.i = 0; \
132
- ret.sign = a.sign; \
133
- ret.exp = a.exp; \
134
- ret.mant = int128_getlo(a.mant); \
135
- return ret.i; \
136
- } \
137
- assert(a.exp == 1); \
138
- INTERNAL_TYPE ret; \
139
- ret.i = 0; \
140
- ret.sign = a.sign; \
141
- ret.exp = 0; \
142
- ret.mant = int128_getlo(a.mant); \
143
- return ret.i; \
144
+static float64 accum_round_float64(Accum a, float_status *fp_status)
145
+{
146
+ if ((int128_gethi(a.mant) == 0) && (int128_getlo(a.mant) == 0)
147
+ && ((a.guard | a.round | a.sticky) == 0)) {
148
+ /* result zero */
149
+ switch (fp_status->float_rounding_mode) {
150
+ case float_round_down:
151
+ return zero_float64(1);
152
+ default:
153
+ return zero_float64(0);
154
+ }
155
+ }
156
+ /*
157
+ * Normalize right
158
+ * We want DF_MANTBITS bits of mantissa plus the leading one.
159
+ * That means that we want DF_MANTBITS+1 bits, or 0x000000000000FF_FFFF
160
+ * So we need to normalize right while the high word is non-zero and
161
+ * while the low word is nonzero when masked with 0xffe0_0000_0000_0000
162
+ */
163
+ while ((int128_gethi(a.mant) != 0) ||
164
+ ((int128_getlo(a.mant) >> (DF_MANTBITS + 1)) != 0)) {
165
+ a = accum_norm_right(a, 1);
166
+ }
167
+ /*
168
+ * OK, now normalize left
169
+ * We want to normalize left until we have a leading one in bit 24
170
+ * Theoretically, we only need to shift a maximum of one to the left if we
171
+ * shifted out lots of bits from B, or if we had no shift / 1 shift sticky
172
+ * should be 0
173
+ */
174
+ while ((int128_getlo(a.mant) & (1ULL << DF_MANTBITS)) == 0) {
175
+ a = accum_norm_left(a);
176
+ }
177
+ /*
178
+ * OK, now we might need to denormalize because of potential underflow.
179
+ * We need to do this before rounding, and rounding might make us normal
180
+ * again
181
+ */
182
+ while (a.exp <= 0) {
183
+ a = accum_norm_right(a, 1 - a.exp);
184
+ /*
185
+ * Do we have underflow?
186
+ * That's when we get an inexact answer because we ran out of bits
187
+ * in a denormal.
188
+ */
189
+ if (a.guard || a.round || a.sticky) {
190
+ float_raise(float_flag_underflow, fp_status);
191
+ }
192
+ }
193
+ /* OK, we're relatively canonical... now we need to round */
194
+ if (a.guard || a.round || a.sticky) {
195
+ float_raise(float_flag_inexact, fp_status);
196
+ switch (fp_status->float_rounding_mode) {
197
+ case float_round_to_zero:
198
+ /* Chop and we're done */
199
+ break;
200
+ case float_round_up:
201
+ if (a.sign == 0) {
202
+ a.mant = int128_add(a.mant, int128_one());
203
+ }
204
+ break;
205
+ case float_round_down:
206
+ if (a.sign != 0) {
207
+ a.mant = int128_add(a.mant, int128_one());
208
+ }
209
+ break;
210
+ default:
211
+ if (a.round || a.sticky) {
212
+ /* round up if guard is 1, down if guard is zero */
213
+ a.mant = int128_add(a.mant, int128_make64(a.guard));
214
+ } else if (a.guard) {
215
+ /* exactly .5, round up if odd */
216
+ a.mant = int128_add(a.mant, int128_and(a.mant, int128_one()));
217
+ }
218
+ break;
219
+ }
220
+ }
221
+ /*
222
+ * OK, now we might have carried all the way up.
223
+ * So we might need to shr once
224
+ * at least we know that the lsb should be zero if we rounded and
225
+ * got a carry out...
226
+ */
227
+ if ((int128_getlo(a.mant) >> (DF_MANTBITS + 1)) != 0) {
228
+ a = accum_norm_right(a, 1);
229
+ }
230
+ /* Overflow? */
231
+ if (a.exp >= DF_INF_EXP) {
232
+ /* Yep, inf result */
233
+ float_raise(float_flag_overflow, fp_status);
234
+ float_raise(float_flag_inexact, fp_status);
235
+ switch (fp_status->float_rounding_mode) {
236
+ case float_round_to_zero:
237
+ return maxfinite_float64(a.sign);
238
+ case float_round_up:
239
+ if (a.sign == 0) {
240
+ return infinite_float64(a.sign);
241
+ } else {
242
+ return maxfinite_float64(a.sign);
243
+ }
244
+ case float_round_down:
245
+ if (a.sign != 0) {
246
+ return infinite_float64(a.sign);
247
+ } else {
248
+ return maxfinite_float64(a.sign);
249
+ }
250
+ default:
251
+ return infinite_float64(a.sign);
252
+ }
253
+ }
254
+ /* Underflow? */
255
+ if (int128_getlo(a.mant) & (1ULL << DF_MANTBITS)) {
256
+ /* Leading one means: No, we're normal. So, we should be done... */
257
+ Double ret;
258
+ ret.i = 0;
259
+ ret.sign = a.sign;
260
+ ret.exp = a.exp;
261
+ ret.mant = int128_getlo(a.mant);
262
+ return ret.i;
263
+ }
264
+ assert(a.exp == 1);
265
+ Double ret;
266
+ ret.i = 0;
267
+ ret.sign = a.sign;
268
+ ret.exp = 0;
269
+ ret.mant = int128_getlo(a.mant);
270
+ return ret.i;
271
}
272
273
-GEN_XF_ROUND(float64, DF_MANTBITS, DF_INF_EXP, Double)
40
-
274
-
41
if test "$pie" != "no" ; then
275
float64 internal_mpyhh(float64 a, float64 b,
42
cat > $TMPC << EOF
276
unsigned long long int accumulated,
43
277
float_status *fp_status)
44
--
278
--
45
2.20.1
279
2.43.0
46
47
diff view generated by jsdifflib
1
Some distributions, e.g. Ubuntu 19.10, enable PIE by default.
1
This structure, with bitfields, is incorrect for big-endian.
2
If for some reason one wishes to build a non-pie binary, we
2
Use the existing float32_getexp_raw which uses extract32.
3
must provide additional options to override.
4
3
5
At the same time, reorg the code to an elif chain.
4
Reviewed-by: Brian Cain <brian.cain@oss.qualcomm.com>
6
7
Reviewed-by: Alex Bennée <alex.bennee@linaro.org>
8
Reviewed-by: Philippe Mathieu-Daudé <philmd@redhat.com>
9
Reviewed-by: Thomas Huth <thuth@redhat.com>
10
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
5
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
11
---
6
---
12
configure | 25 ++++++++++++-------------
7
target/hexagon/fma_emu.c | 16 +++-------------
13
1 file changed, 12 insertions(+), 13 deletions(-)
8
1 file changed, 3 insertions(+), 13 deletions(-)
14
9
15
diff --git a/configure b/configure
10
diff --git a/target/hexagon/fma_emu.c b/target/hexagon/fma_emu.c
16
index XXXXXXX..XXXXXXX 100755
11
index XXXXXXX..XXXXXXX 100644
17
--- a/configure
12
--- a/target/hexagon/fma_emu.c
18
+++ b/configure
13
+++ b/target/hexagon/fma_emu.c
19
@@ -XXX,XX +XXX,XX @@ if compile_prog "-Werror -fno-pie" "-no-pie"; then
14
@@ -XXX,XX +XXX,XX @@ typedef union {
20
LDFLAGS_NOPIE="-no-pie"
15
};
21
fi
16
} Double;
22
17
23
-if test "$pie" != "no" ; then
18
-typedef union {
24
- if compile_prog "-fPIE -DPIE" "-pie"; then
19
- float f;
25
- QEMU_CFLAGS="-fPIE -DPIE $QEMU_CFLAGS"
20
- uint32_t i;
26
- LDFLAGS="-pie $LDFLAGS"
21
- struct {
27
- pie="yes"
22
- uint32_t mant:23;
28
- else
23
- uint32_t exp:8;
29
- if test "$pie" = "yes"; then
24
- uint32_t sign:1;
30
- error_exit "PIE not available due to missing toolchain support"
25
- };
31
- else
26
-} Float;
32
- echo "Disabling PIE due to missing toolchain support"
27
-
33
- pie="no"
28
static uint64_t float64_getmant(float64 f64)
34
- fi
29
{
35
- fi
30
Double a = { .i = f64 };
36
+if test "$pie" = "no"; then
31
@@ -XXX,XX +XXX,XX @@ int32_t float64_getexp(float64 f64)
37
+ QEMU_CFLAGS="$CFLAGS_NOPIE $QEMU_CFLAGS"
32
38
+ LDFLAGS="$LDFLAGS_NOPIE $LDFLAGS"
33
int32_t float32_getexp(float32 f32)
39
+elif compile_prog "-fPIE -DPIE" "-pie"; then
34
{
40
+ QEMU_CFLAGS="-fPIE -DPIE $QEMU_CFLAGS"
35
- Float a = { .i = f32 };
41
+ LDFLAGS="-pie $LDFLAGS"
36
+ int exp = float32_getexp_raw(f32);
42
+ pie="yes"
37
if (float32_is_normal(f32)) {
43
+elif test "$pie" = "yes"; then
38
- return a.exp;
44
+ error_exit "PIE not available due to missing toolchain support"
39
+ return exp;
45
+else
40
}
46
+ echo "Disabling PIE due to missing toolchain support"
41
if (float32_is_denormal(f32)) {
47
+ pie="no"
42
- return a.exp + 1;
48
fi
43
+ return exp + 1;
49
44
}
50
# Detect support for PT_GNU_RELRO + DT_BIND_NOW.
45
return -1;
46
}
51
--
47
--
52
2.20.1
48
2.43.0
53
54
diff view generated by jsdifflib
1
We don't actually need the result of the read, only to probe that the
1
This structure, with bitfields, is incorrect for big-endian.
2
memory mapping exists. This is exactly what probe_access does.
2
Use extract64 and deposit64 instead.
3
3
4
This is also the only user of any cpu_ld*_code_ra function.
4
Reviewed-by: Brian Cain <brian.cain@oss.qualcomm.com>
5
Removing this allows the interface to be removed shortly.
6
7
Tested-by: Philippe Mathieu-Daudé <philmd@redhat.com>
8
Acked-by: Max Filippov <jcmvbkbc@gmail.com>
9
Reviewed-by: Alex Bennée <alex.bennee@linaro.org>
10
Reviewed-by: Philippe Mathieu-Daudé <philmd@redhat.com>
11
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
5
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
12
---
6
---
13
target/xtensa/mmu_helper.c | 5 +++--
7
target/hexagon/fma_emu.c | 46 ++++++++++++++--------------------------
14
1 file changed, 3 insertions(+), 2 deletions(-)
8
1 file changed, 16 insertions(+), 30 deletions(-)
15
9
16
diff --git a/target/xtensa/mmu_helper.c b/target/xtensa/mmu_helper.c
10
diff --git a/target/hexagon/fma_emu.c b/target/hexagon/fma_emu.c
17
index XXXXXXX..XXXXXXX 100644
11
index XXXXXXX..XXXXXXX 100644
18
--- a/target/xtensa/mmu_helper.c
12
--- a/target/hexagon/fma_emu.c
19
+++ b/target/xtensa/mmu_helper.c
13
+++ b/target/hexagon/fma_emu.c
20
@@ -XXX,XX +XXX,XX @@
14
@@ -XXX,XX +XXX,XX @@
21
void HELPER(itlb_hit_test)(CPUXtensaState *env, uint32_t vaddr)
15
16
#define WAY_BIG_EXP 4096
17
18
-typedef union {
19
- double f;
20
- uint64_t i;
21
- struct {
22
- uint64_t mant:52;
23
- uint64_t exp:11;
24
- uint64_t sign:1;
25
- };
26
-} Double;
27
-
28
static uint64_t float64_getmant(float64 f64)
22
{
29
{
23
/*
30
- Double a = { .i = f64 };
24
- * Attempt the memory load; we don't care about the result but
31
+ uint64_t mant = extract64(f64, 0, 52);
25
+ * Probe the memory; we don't care about the result but
32
if (float64_is_normal(f64)) {
26
* only the side-effects (ie any MMU or other exception)
33
- return a.mant | 1ULL << 52;
27
*/
34
+ return mant | 1ULL << 52;
28
- cpu_ldub_code_ra(env, vaddr, GETPC());
35
}
29
+ probe_access(env, vaddr, 1, MMU_INST_FETCH,
36
if (float64_is_zero(f64)) {
30
+ cpu_mmu_index(env, true), GETPC());
37
return 0;
38
}
39
if (float64_is_denormal(f64)) {
40
- return a.mant;
41
+ return mant;
42
}
43
return ~0ULL;
31
}
44
}
32
45
33
void HELPER(wsr_rasid)(CPUXtensaState *env, uint32_t v)
46
int32_t float64_getexp(float64 f64)
47
{
48
- Double a = { .i = f64 };
49
+ int exp = extract64(f64, 52, 11);
50
if (float64_is_normal(f64)) {
51
- return a.exp;
52
+ return exp;
53
}
54
if (float64_is_denormal(f64)) {
55
- return a.exp + 1;
56
+ return exp + 1;
57
}
58
return -1;
59
}
60
@@ -XXX,XX +XXX,XX @@ float32 infinite_float32(uint8_t sign)
61
/* Return a maximum finite value with the requested sign */
62
static float64 accum_round_float64(Accum a, float_status *fp_status)
63
{
64
+ uint64_t ret;
65
+
66
if ((int128_gethi(a.mant) == 0) && (int128_getlo(a.mant) == 0)
67
&& ((a.guard | a.round | a.sticky) == 0)) {
68
/* result zero */
69
@@ -XXX,XX +XXX,XX @@ static float64 accum_round_float64(Accum a, float_status *fp_status)
70
}
71
}
72
/* Underflow? */
73
- if (int128_getlo(a.mant) & (1ULL << DF_MANTBITS)) {
74
+ ret = int128_getlo(a.mant);
75
+ if (ret & (1ULL << DF_MANTBITS)) {
76
/* Leading one means: No, we're normal. So, we should be done... */
77
- Double ret;
78
- ret.i = 0;
79
- ret.sign = a.sign;
80
- ret.exp = a.exp;
81
- ret.mant = int128_getlo(a.mant);
82
- return ret.i;
83
+ ret = deposit64(ret, 52, 11, a.exp);
84
+ } else {
85
+ assert(a.exp == 1);
86
+ ret = deposit64(ret, 52, 11, 0);
87
}
88
- assert(a.exp == 1);
89
- Double ret;
90
- ret.i = 0;
91
- ret.sign = a.sign;
92
- ret.exp = 0;
93
- ret.mant = int128_getlo(a.mant);
94
- return ret.i;
95
+ ret = deposit64(ret, 63, 1, a.sign);
96
+ return ret;
97
}
98
99
float64 internal_mpyhh(float64 a, float64 b,
34
--
100
--
35
2.20.1
101
2.43.0
36
37
diff view generated by jsdifflib
1
It is easy for the atomic helpers to use trace_mem_build_info
1
No need to open-code 64x64->128-bit multiplication.
2
directly, without resorting to symbol pasting. For this usage,
3
we cannot use trace_mem_get_info, because the MemOp does not
4
support 16-byte accesses.
5
2
6
Tested-by: Philippe Mathieu-Daudé <philmd@redhat.com>
3
Reviewed-by: Brian Cain <brian.cain@oss.qualcomm.com>
7
Reviewed-by: Alex Bennée <alex.bennee@linaro.org>
8
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
4
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
9
---
5
---
10
accel/tcg/atomic_template.h | 67 +++++++++++++------------------------
6
target/hexagon/fma_emu.c | 32 +++-----------------------------
11
trace/mem-internal.h | 17 ----------
7
1 file changed, 3 insertions(+), 29 deletions(-)
12
2 files changed, 24 insertions(+), 60 deletions(-)
13
8
14
diff --git a/accel/tcg/atomic_template.h b/accel/tcg/atomic_template.h
9
diff --git a/target/hexagon/fma_emu.c b/target/hexagon/fma_emu.c
15
index XXXXXXX..XXXXXXX 100644
10
index XXXXXXX..XXXXXXX 100644
16
--- a/accel/tcg/atomic_template.h
11
--- a/target/hexagon/fma_emu.c
17
+++ b/accel/tcg/atomic_template.h
12
+++ b/target/hexagon/fma_emu.c
18
@@ -XXX,XX +XXX,XX @@
13
@@ -XXX,XX +XXX,XX @@ int32_t float32_getexp(float32 f32)
19
the ATOMIC_NAME macro, and redefined below. */
14
return -1;
20
#if DATA_SIZE == 1
21
# define END
22
-# define MEND _be /* either le or be would be fine */
23
#elif defined(HOST_WORDS_BIGENDIAN)
24
# define END _be
25
-# define MEND _be
26
#else
27
# define END _le
28
-# define MEND _le
29
#endif
30
31
ABI_TYPE ATOMIC_NAME(cmpxchg)(CPUArchState *env, target_ulong addr,
32
@@ -XXX,XX +XXX,XX @@ ABI_TYPE ATOMIC_NAME(cmpxchg)(CPUArchState *env, target_ulong addr,
33
ATOMIC_MMU_DECLS;
34
DATA_TYPE *haddr = ATOMIC_MMU_LOOKUP;
35
DATA_TYPE ret;
36
- uint16_t info = glue(trace_mem_build_info_no_se, MEND)(SHIFT, false,
37
- ATOMIC_MMU_IDX);
38
+ uint16_t info = trace_mem_build_info(SHIFT, false, 0, false,
39
+ ATOMIC_MMU_IDX);
40
41
atomic_trace_rmw_pre(env, addr, info);
42
#if DATA_SIZE == 16
43
@@ -XXX,XX +XXX,XX @@ ABI_TYPE ATOMIC_NAME(ld)(CPUArchState *env, target_ulong addr EXTRA_ARGS)
44
{
45
ATOMIC_MMU_DECLS;
46
DATA_TYPE val, *haddr = ATOMIC_MMU_LOOKUP;
47
- uint16_t info = glue(trace_mem_build_info_no_se, MEND)(SHIFT, false,
48
- ATOMIC_MMU_IDX);
49
+ uint16_t info = trace_mem_build_info(SHIFT, false, 0, false,
50
+ ATOMIC_MMU_IDX);
51
52
atomic_trace_ld_pre(env, addr, info);
53
val = atomic16_read(haddr);
54
@@ -XXX,XX +XXX,XX @@ void ATOMIC_NAME(st)(CPUArchState *env, target_ulong addr,
55
{
56
ATOMIC_MMU_DECLS;
57
DATA_TYPE *haddr = ATOMIC_MMU_LOOKUP;
58
- uint16_t info = glue(trace_mem_build_info_no_se, MEND)(SHIFT, true,
59
- ATOMIC_MMU_IDX);
60
+ uint16_t info = trace_mem_build_info(SHIFT, false, 0, true,
61
+ ATOMIC_MMU_IDX);
62
63
atomic_trace_st_pre(env, addr, info);
64
atomic16_set(haddr, val);
65
@@ -XXX,XX +XXX,XX @@ ABI_TYPE ATOMIC_NAME(xchg)(CPUArchState *env, target_ulong addr,
66
ATOMIC_MMU_DECLS;
67
DATA_TYPE *haddr = ATOMIC_MMU_LOOKUP;
68
DATA_TYPE ret;
69
- uint16_t info = glue(trace_mem_build_info_no_se, MEND)(SHIFT, false,
70
- ATOMIC_MMU_IDX);
71
+ uint16_t info = trace_mem_build_info(SHIFT, false, 0, false,
72
+ ATOMIC_MMU_IDX);
73
74
atomic_trace_rmw_pre(env, addr, info);
75
ret = atomic_xchg__nocheck(haddr, val);
76
@@ -XXX,XX +XXX,XX @@ ABI_TYPE ATOMIC_NAME(X)(CPUArchState *env, target_ulong addr, \
77
ATOMIC_MMU_DECLS; \
78
DATA_TYPE *haddr = ATOMIC_MMU_LOOKUP; \
79
DATA_TYPE ret; \
80
- uint16_t info = glue(trace_mem_build_info_no_se, MEND)(SHIFT, \
81
- false, \
82
- ATOMIC_MMU_IDX); \
83
- \
84
+ uint16_t info = trace_mem_build_info(SHIFT, false, 0, false, \
85
+ ATOMIC_MMU_IDX); \
86
atomic_trace_rmw_pre(env, addr, info); \
87
ret = atomic_##X(haddr, val); \
88
ATOMIC_MMU_CLEANUP; \
89
@@ -XXX,XX +XXX,XX @@ ABI_TYPE ATOMIC_NAME(X)(CPUArchState *env, target_ulong addr, \
90
ATOMIC_MMU_DECLS; \
91
XDATA_TYPE *haddr = ATOMIC_MMU_LOOKUP; \
92
XDATA_TYPE cmp, old, new, val = xval; \
93
- uint16_t info = glue(trace_mem_build_info_no_se, MEND)(SHIFT, \
94
- false, \
95
- ATOMIC_MMU_IDX); \
96
- \
97
+ uint16_t info = trace_mem_build_info(SHIFT, false, 0, false, \
98
+ ATOMIC_MMU_IDX); \
99
atomic_trace_rmw_pre(env, addr, info); \
100
smp_mb(); \
101
cmp = atomic_read__nocheck(haddr); \
102
@@ -XXX,XX +XXX,XX @@ GEN_ATOMIC_HELPER_FN(umax_fetch, MAX, DATA_TYPE, new)
103
#endif /* DATA SIZE >= 16 */
104
105
#undef END
106
-#undef MEND
107
108
#if DATA_SIZE > 1
109
110
@@ -XXX,XX +XXX,XX @@ GEN_ATOMIC_HELPER_FN(umax_fetch, MAX, DATA_TYPE, new)
111
within the ATOMIC_NAME macro. */
112
#ifdef HOST_WORDS_BIGENDIAN
113
# define END _le
114
-# define MEND _le
115
#else
116
# define END _be
117
-# define MEND _be
118
#endif
119
120
ABI_TYPE ATOMIC_NAME(cmpxchg)(CPUArchState *env, target_ulong addr,
121
@@ -XXX,XX +XXX,XX @@ ABI_TYPE ATOMIC_NAME(cmpxchg)(CPUArchState *env, target_ulong addr,
122
ATOMIC_MMU_DECLS;
123
DATA_TYPE *haddr = ATOMIC_MMU_LOOKUP;
124
DATA_TYPE ret;
125
- uint16_t info = glue(trace_mem_build_info_no_se, MEND)(SHIFT,
126
- false,
127
- ATOMIC_MMU_IDX);
128
+ uint16_t info = trace_mem_build_info(SHIFT, false, MO_BSWAP, false,
129
+ ATOMIC_MMU_IDX);
130
131
atomic_trace_rmw_pre(env, addr, info);
132
#if DATA_SIZE == 16
133
@@ -XXX,XX +XXX,XX @@ ABI_TYPE ATOMIC_NAME(ld)(CPUArchState *env, target_ulong addr EXTRA_ARGS)
134
{
135
ATOMIC_MMU_DECLS;
136
DATA_TYPE val, *haddr = ATOMIC_MMU_LOOKUP;
137
- uint16_t info = glue(trace_mem_build_info_no_se, MEND)(SHIFT,
138
- false,
139
- ATOMIC_MMU_IDX);
140
+ uint16_t info = trace_mem_build_info(SHIFT, false, MO_BSWAP, false,
141
+ ATOMIC_MMU_IDX);
142
143
atomic_trace_ld_pre(env, addr, info);
144
val = atomic16_read(haddr);
145
@@ -XXX,XX +XXX,XX @@ void ATOMIC_NAME(st)(CPUArchState *env, target_ulong addr,
146
{
147
ATOMIC_MMU_DECLS;
148
DATA_TYPE *haddr = ATOMIC_MMU_LOOKUP;
149
- uint16_t info = glue(trace_mem_build_info_no_se, MEND)(SHIFT,
150
- true,
151
- ATOMIC_MMU_IDX);
152
+ uint16_t info = trace_mem_build_info(SHIFT, false, MO_BSWAP, true,
153
+ ATOMIC_MMU_IDX);
154
155
val = BSWAP(val);
156
atomic_trace_st_pre(env, addr, info);
157
@@ -XXX,XX +XXX,XX @@ ABI_TYPE ATOMIC_NAME(xchg)(CPUArchState *env, target_ulong addr,
158
ATOMIC_MMU_DECLS;
159
DATA_TYPE *haddr = ATOMIC_MMU_LOOKUP;
160
ABI_TYPE ret;
161
- uint16_t info = glue(trace_mem_build_info_no_se, MEND)(SHIFT,
162
- false,
163
- ATOMIC_MMU_IDX);
164
+ uint16_t info = trace_mem_build_info(SHIFT, false, MO_BSWAP, false,
165
+ ATOMIC_MMU_IDX);
166
167
atomic_trace_rmw_pre(env, addr, info);
168
ret = atomic_xchg__nocheck(haddr, BSWAP(val));
169
@@ -XXX,XX +XXX,XX @@ ABI_TYPE ATOMIC_NAME(X)(CPUArchState *env, target_ulong addr, \
170
ATOMIC_MMU_DECLS; \
171
DATA_TYPE *haddr = ATOMIC_MMU_LOOKUP; \
172
DATA_TYPE ret; \
173
- uint16_t info = glue(trace_mem_build_info_no_se, MEND)(SHIFT, \
174
- false, \
175
- ATOMIC_MMU_IDX); \
176
- \
177
+ uint16_t info = trace_mem_build_info(SHIFT, false, MO_BSWAP, \
178
+ false, ATOMIC_MMU_IDX); \
179
atomic_trace_rmw_pre(env, addr, info); \
180
ret = atomic_##X(haddr, BSWAP(val)); \
181
ATOMIC_MMU_CLEANUP; \
182
@@ -XXX,XX +XXX,XX @@ ABI_TYPE ATOMIC_NAME(X)(CPUArchState *env, target_ulong addr, \
183
ATOMIC_MMU_DECLS; \
184
XDATA_TYPE *haddr = ATOMIC_MMU_LOOKUP; \
185
XDATA_TYPE ldo, ldn, old, new, val = xval; \
186
- uint16_t info = glue(trace_mem_build_info_no_se, MEND)(SHIFT, \
187
- false, \
188
- ATOMIC_MMU_IDX); \
189
- \
190
+ uint16_t info = trace_mem_build_info(SHIFT, false, MO_BSWAP, \
191
+ false, ATOMIC_MMU_IDX); \
192
atomic_trace_rmw_pre(env, addr, info); \
193
smp_mb(); \
194
ldn = atomic_read__nocheck(haddr); \
195
@@ -XXX,XX +XXX,XX @@ GEN_ATOMIC_HELPER_FN(add_fetch, ADD, DATA_TYPE, new)
196
#endif /* DATA_SIZE >= 16 */
197
198
#undef END
199
-#undef MEND
200
#endif /* DATA_SIZE > 1 */
201
202
#undef BSWAP
203
diff --git a/trace/mem-internal.h b/trace/mem-internal.h
204
index XXXXXXX..XXXXXXX 100644
205
--- a/trace/mem-internal.h
206
+++ b/trace/mem-internal.h
207
@@ -XXX,XX +XXX,XX @@ static inline uint16_t trace_mem_get_info(MemOp op,
208
mmu_idx);
209
}
15
}
210
16
211
-/* Used by the atomic helpers */
17
-static uint32_t int128_getw0(Int128 x)
212
-static inline
213
-uint16_t trace_mem_build_info_no_se_be(int size_shift, bool store,
214
- TCGMemOpIdx oi)
215
-{
18
-{
216
- return trace_mem_build_info(size_shift, false, MO_BE, store,
19
- return int128_getlo(x);
217
- get_mmuidx(oi));
218
-}
20
-}
219
-
21
-
220
-static inline
22
-static uint32_t int128_getw1(Int128 x)
221
-uint16_t trace_mem_build_info_no_se_le(int size_shift, bool store,
222
- TCGMemOpIdx oi)
223
-{
23
-{
224
- return trace_mem_build_info(size_shift, false, MO_LE, store,
24
- return int128_getlo(x) >> 32;
225
- get_mmuidx(oi));
226
-}
25
-}
227
-
26
-
228
#endif /* TRACE__MEM_INTERNAL_H */
27
static Int128 int128_mul_6464(uint64_t ai, uint64_t bi)
28
{
29
- Int128 a, b;
30
- uint64_t pp0, pp1a, pp1b, pp1s, pp2;
31
+ uint64_t l, h;
32
33
- a = int128_make64(ai);
34
- b = int128_make64(bi);
35
- pp0 = (uint64_t)int128_getw0(a) * (uint64_t)int128_getw0(b);
36
- pp1a = (uint64_t)int128_getw1(a) * (uint64_t)int128_getw0(b);
37
- pp1b = (uint64_t)int128_getw1(b) * (uint64_t)int128_getw0(a);
38
- pp2 = (uint64_t)int128_getw1(a) * (uint64_t)int128_getw1(b);
39
-
40
- pp1s = pp1a + pp1b;
41
- if ((pp1s < pp1a) || (pp1s < pp1b)) {
42
- pp2 += (1ULL << 32);
43
- }
44
- uint64_t ret_low = pp0 + (pp1s << 32);
45
- if ((ret_low < pp0) || (ret_low < (pp1s << 32))) {
46
- pp2 += 1;
47
- }
48
-
49
- return int128_make128(ret_low, pp2 + (pp1s >> 32));
50
+ mulu64(&l, &h, ai, bi);
51
+ return int128_make128(l, h);
52
}
53
54
static Int128 int128_sub_borrow(Int128 a, Int128 b, int borrow)
229
--
55
--
230
2.20.1
56
2.43.0
231
232
diff view generated by jsdifflib
1
This adjustment was random and unnecessary. The user mode
1
Initialize x with accumulated via direct assignment,
2
startup code in probe_guest_base() will choose a value for
2
rather than multiplying by 1.
3
guest_base that allows the host qemu binary to not conflict
4
with the guest binary.
5
3
6
With modern distributions, this isn't even used, as the default
4
Reviewed-by: Brian Cain <brian.cain@oss.qualcomm.com>
7
is PIE, which does the same job in a more portable way.
8
9
Reviewed-by: Alex Bennée <alex.bennee@linaro.org>
10
Reviewed-by: Thomas Huth <thuth@redhat.com>
11
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
5
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
12
---
6
---
13
v2: Remove mention of config-host.ld from make distclean
7
target/hexagon/fma_emu.c | 2 +-
14
---
8
1 file changed, 1 insertion(+), 1 deletion(-)
15
Makefile | 2 +-
16
configure | 47 -----------------------------------------------
17
2 files changed, 1 insertion(+), 48 deletions(-)
18
9
19
diff --git a/Makefile b/Makefile
10
diff --git a/target/hexagon/fma_emu.c b/target/hexagon/fma_emu.c
20
index XXXXXXX..XXXXXXX 100644
11
index XXXXXXX..XXXXXXX 100644
21
--- a/Makefile
12
--- a/target/hexagon/fma_emu.c
22
+++ b/Makefile
13
+++ b/target/hexagon/fma_emu.c
23
@@ -XXX,XX +XXX,XX @@ rm -f $(MANUAL_BUILDDIR)/$1/objects.inv $(MANUAL_BUILDDIR)/$1/searchindex.js $(M
14
@@ -XXX,XX +XXX,XX @@ float64 internal_mpyhh(float64 a, float64 b,
24
endef
15
float64_is_infinity(b)) {
25
16
return float64_mul(a, b, fp_status);
26
distclean: clean
17
}
27
-    rm -f config-host.mak config-host.h* config-host.ld $(DOCS) qemu-options.texi qemu-img-cmds.texi qemu-monitor.texi qemu-monitor-info.texi
18
- x.mant = int128_mul_6464(accumulated, 1);
28
+    rm -f config-host.mak config-host.h* $(DOCS) qemu-options.texi qemu-img-cmds.texi qemu-monitor.texi qemu-monitor-info.texi
19
+ x.mant = int128_make64(accumulated);
29
    rm -f tests/tcg/config-*.mak
20
x.sticky = sticky;
30
    rm -f config-all-devices.mak config-all-disas.mak config.status
21
prod = fGETUWORD(1, float64_getmant(a)) * fGETUWORD(1, float64_getmant(b));
31
    rm -f $(SUBDIR_DEVICES_MAK)
22
x.mant = int128_add(x.mant, int128_mul_6464(prod, 0x100000000ULL));
32
diff --git a/configure b/configure
33
index XXXXXXX..XXXXXXX 100755
34
--- a/configure
35
+++ b/configure
36
@@ -XXX,XX +XXX,XX @@ if test "$cpu" = "s390x" ; then
37
fi
38
fi
39
40
-# Probe for the need for relocating the user-only binary.
41
-if ( [ "$linux_user" = yes ] || [ "$bsd_user" = yes ] ) && [ "$pie" = no ]; then
42
- textseg_addr=
43
- case "$cpu" in
44
- arm | i386 | ppc* | s390* | sparc* | x86_64 | x32)
45
- # ??? Rationale for choosing this address
46
- textseg_addr=0x60000000
47
- ;;
48
- mips)
49
- # A 256M aligned address, high in the address space, with enough
50
- # room for the code_gen_buffer above it before the stack.
51
- textseg_addr=0x60000000
52
- ;;
53
- esac
54
- if [ -n "$textseg_addr" ]; then
55
- cat > $TMPC <<EOF
56
- int main(void) { return 0; }
57
-EOF
58
- textseg_ldflags="-Wl,-Ttext-segment=$textseg_addr"
59
- if ! compile_prog "" "$textseg_ldflags"; then
60
- # In case ld does not support -Ttext-segment, edit the default linker
61
- # script via sed to set the .text start addr. This is needed on FreeBSD
62
- # at least.
63
- if ! $ld --verbose >/dev/null 2>&1; then
64
- error_exit \
65
- "We need to link the QEMU user mode binaries at a" \
66
- "specific text address. Unfortunately your linker" \
67
- "doesn't support either the -Ttext-segment option or" \
68
- "printing the default linker script with --verbose." \
69
- "If you don't want the user mode binaries, pass the" \
70
- "--disable-user option to configure."
71
- fi
72
-
73
- $ld --verbose | sed \
74
- -e '1,/==================================================/d' \
75
- -e '/==================================================/,$d' \
76
- -e "s/[.] = [0-9a-fx]* [+] SIZEOF_HEADERS/. = $textseg_addr + SIZEOF_HEADERS/" \
77
- -e "s/__executable_start = [0-9a-fx]*/__executable_start = $textseg_addr/" > config-host.ld
78
- textseg_ldflags="-Wl,-T../config-host.ld"
79
- fi
80
- fi
81
-fi
82
-
83
# Check that the C++ compiler exists and works with the C compiler.
84
# All the QEMU_CXXFLAGS are based on QEMU_CFLAGS. Keep this at the end to don't miss any other that could be added.
85
if has $cxx; then
86
@@ -XXX,XX +XXX,XX @@ if test "$gprof" = "yes" ; then
87
fi
88
fi
89
90
-if test "$target_linux_user" = "yes" || test "$target_bsd_user" = "yes" ; then
91
- ldflags="$ldflags $textseg_ldflags"
92
-fi
93
-
94
# Newer kernels on s390 check for an S390_PGSTE program header and
95
# enable the pgste page table extensions in that case. This makes
96
# the vm.allocate_pgste sysctl unnecessary. We enable this program
97
--
23
--
98
2.20.1
24
2.43.0
99
100
diff view generated by jsdifflib
1
From: Philippe Mathieu-Daudé <philmd@redhat.com>
1
Convert all targets simultaneously, as the gen_intermediate_code
2
function disappears from the target. While there are possible
3
workarounds, they're larger than simply performing the conversion.
2
4
3
We currently search both the root and the tcg/ directories for tcg
5
Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org>
4
files:
5
6
$ git grep '#include "tcg/' | wc -l
7
28
8
9
$ git grep '#include "tcg[^/]' | wc -l
10
94
11
12
To simplify the preprocessor search path, unify by expliciting the
13
tcg/ directory.
14
15
Patch created mechanically by running:
16
17
$ for x in \
18
tcg.h tcg-mo.h tcg-op.h tcg-opc.h \
19
tcg-op-gvec.h tcg-gvec-desc.h; do \
20
sed -i "s,#include \"$x\",#include \"tcg/$x\"," \
21
$(git grep -l "#include \"$x\""); \
22
done
23
24
Acked-by: David Gibson <david@gibson.dropbear.id.au> (ppc parts)
25
Reviewed-by: Paolo Bonzini <pbonzini@redhat.com>
26
Reviewed-by: Alistair Francis <alistair.francis@wdc.com>
27
Reviewed-by: Stefan Weil <sw@weilnetz.de>
28
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
29
Signed-off-by: Philippe Mathieu-Daudé <philmd@redhat.com>
30
Message-Id: <20200101112303.20724-2-philmd@redhat.com>
31
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
6
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
32
---
7
---
33
include/exec/cpu_ldst.h | 2 +-
8
include/exec/translator.h | 14 --------------
34
tcg/i386/tcg-target.h | 2 +-
9
include/hw/core/tcg-cpu-ops.h | 13 +++++++++++++
35
tcg/tcg-op.h | 2 +-
10
target/alpha/cpu.h | 2 ++
36
tcg/tcg.h | 4 ++--
11
target/arm/internals.h | 2 ++
37
accel/tcg/cpu-exec.c | 2 +-
12
target/avr/cpu.h | 2 ++
38
accel/tcg/tcg-runtime-gvec.c | 2 +-
13
target/hexagon/cpu.h | 2 ++
39
accel/tcg/tcg-runtime.c | 2 +-
14
target/hppa/cpu.h | 2 ++
40
accel/tcg/translate-all.c | 2 +-
15
target/i386/tcg/helper-tcg.h | 2 ++
41
accel/tcg/user-exec.c | 2 +-
16
target/loongarch/internals.h | 2 ++
42
bsd-user/main.c | 2 +-
17
target/m68k/cpu.h | 2 ++
43
cpus.c | 2 +-
18
target/microblaze/cpu.h | 2 ++
44
exec.c | 2 +-
19
target/mips/tcg/tcg-internal.h | 2 ++
45
linux-user/main.c | 2 +-
20
target/openrisc/cpu.h | 2 ++
46
linux-user/syscall.c | 2 +-
21
target/ppc/cpu.h | 2 ++
47
target/alpha/translate.c | 2 +-
22
target/riscv/cpu.h | 3 +++
48
target/arm/helper-a64.c | 2 +-
23
target/rx/cpu.h | 2 ++
49
target/arm/sve_helper.c | 2 +-
24
target/s390x/s390x-internal.h | 2 ++
50
target/arm/translate-a64.c | 4 ++--
25
target/sh4/cpu.h | 2 ++
51
target/arm/translate-sve.c | 6 +++---
26
target/sparc/cpu.h | 2 ++
52
target/arm/translate.c | 4 ++--
27
target/tricore/cpu.h | 2 ++
53
target/cris/translate.c | 2 +-
28
target/xtensa/cpu.h | 2 ++
54
target/hppa/translate.c | 2 +-
29
accel/tcg/cpu-exec.c | 8 +++++---
55
target/i386/mem_helper.c | 2 +-
30
accel/tcg/translate-all.c | 8 +++++---
56
target/i386/translate.c | 2 +-
31
target/alpha/cpu.c | 1 +
57
target/lm32/translate.c | 2 +-
32
target/alpha/translate.c | 4 ++--
58
target/m68k/translate.c | 2 +-
33
target/arm/cpu.c | 1 +
59
target/microblaze/translate.c | 2 +-
34
target/arm/tcg/cpu-v7m.c | 1 +
60
target/mips/translate.c | 2 +-
35
target/arm/tcg/translate.c | 5 ++---
61
target/moxie/translate.c | 2 +-
36
target/avr/cpu.c | 1 +
62
target/nios2/translate.c | 2 +-
37
target/avr/translate.c | 6 +++---
63
target/openrisc/translate.c | 2 +-
38
target/hexagon/cpu.c | 1 +
64
target/ppc/mem_helper.c | 2 +-
39
target/hexagon/translate.c | 4 ++--
65
target/ppc/translate.c | 4 ++--
40
target/hppa/cpu.c | 1 +
66
target/riscv/cpu_helper.c | 2 +-
41
target/hppa/translate.c | 4 ++--
67
target/riscv/translate.c | 2 +-
42
target/i386/tcg/tcg-cpu.c | 1 +
68
target/s390x/mem_helper.c | 2 +-
43
target/i386/tcg/translate.c | 5 ++---
69
target/s390x/translate.c | 4 ++--
44
target/loongarch/cpu.c | 1 +
70
target/sh4/translate.c | 2 +-
45
target/loongarch/tcg/translate.c | 4 ++--
71
target/sparc/ldst_helper.c | 2 +-
46
target/m68k/cpu.c | 1 +
72
target/sparc/translate.c | 2 +-
47
target/m68k/translate.c | 4 ++--
73
target/tilegx/translate.c | 2 +-
48
target/microblaze/cpu.c | 1 +
74
target/tricore/translate.c | 2 +-
49
target/microblaze/translate.c | 4 ++--
75
target/unicore32/translate.c | 2 +-
50
target/mips/cpu.c | 1 +
76
target/xtensa/translate.c | 2 +-
51
target/mips/tcg/translate.c | 4 ++--
77
tcg/optimize.c | 2 +-
52
target/openrisc/cpu.c | 1 +
78
tcg/tcg-common.c | 2 +-
53
target/openrisc/translate.c | 4 ++--
79
tcg/tcg-op-gvec.c | 8 ++++----
54
target/ppc/cpu_init.c | 1 +
80
tcg/tcg-op-vec.c | 6 +++---
55
target/ppc/translate.c | 4 ++--
81
tcg/tcg-op.c | 6 +++---
56
target/riscv/tcg/tcg-cpu.c | 1 +
82
tcg/tcg.c | 2 +-
57
target/riscv/translate.c | 4 ++--
83
tcg/tci.c | 2 +-
58
target/rx/cpu.c | 1 +
84
51 files changed, 65 insertions(+), 65 deletions(-)
59
target/rx/translate.c | 4 ++--
60
target/s390x/cpu.c | 1 +
61
target/s390x/tcg/translate.c | 4 ++--
62
target/sh4/cpu.c | 1 +
63
target/sh4/translate.c | 4 ++--
64
target/sparc/cpu.c | 1 +
65
target/sparc/translate.c | 4 ++--
66
target/tricore/cpu.c | 1 +
67
target/tricore/translate.c | 5 ++---
68
target/xtensa/cpu.c | 1 +
69
target/xtensa/translate.c | 4 ++--
70
62 files changed, 121 insertions(+), 62 deletions(-)
85
71
86
diff --git a/include/exec/cpu_ldst.h b/include/exec/cpu_ldst.h
72
diff --git a/include/exec/translator.h b/include/exec/translator.h
87
index XXXXXXX..XXXXXXX 100644
73
index XXXXXXX..XXXXXXX 100644
88
--- a/include/exec/cpu_ldst.h
74
--- a/include/exec/translator.h
89
+++ b/include/exec/cpu_ldst.h
75
+++ b/include/exec/translator.h
90
@@ -XXX,XX +XXX,XX @@ static inline void cpu_stq_mmuidx_ra(CPUArchState *env, abi_ptr addr,
91
#else
92
93
/* Needed for TCG_OVERSIZED_GUEST */
94
-#include "tcg.h"
95
+#include "tcg/tcg.h"
96
97
static inline target_ulong tlb_addr_write(const CPUTLBEntry *entry)
98
{
99
diff --git a/tcg/i386/tcg-target.h b/tcg/i386/tcg-target.h
100
index XXXXXXX..XXXXXXX 100644
101
--- a/tcg/i386/tcg-target.h
102
+++ b/tcg/i386/tcg-target.h
103
@@ -XXX,XX +XXX,XX @@ static inline void tb_target_set_jmp_target(uintptr_t tc_ptr,
104
* The x86 has a pretty strong memory ordering which only really
105
* allows for some stores to be re-ordered after loads.
106
*/
107
-#include "tcg-mo.h"
108
+#include "tcg/tcg-mo.h"
109
110
#define TCG_TARGET_DEFAULT_MO (TCG_MO_ALL & ~TCG_MO_ST_LD)
111
112
diff --git a/tcg/tcg-op.h b/tcg/tcg-op.h
113
index XXXXXXX..XXXXXXX 100644
114
--- a/tcg/tcg-op.h
115
+++ b/tcg/tcg-op.h
116
@@ -XXX,XX +XXX,XX @@
76
@@ -XXX,XX +XXX,XX @@
117
#ifndef TCG_TCG_OP_H
77
#include "qemu/bswap.h"
118
#define TCG_TCG_OP_H
78
#include "exec/vaddr.h"
119
79
120
-#include "tcg.h"
80
-/**
121
+#include "tcg/tcg.h"
81
- * gen_intermediate_code
122
#include "exec/helper-proto.h"
82
- * @cpu: cpu context
123
#include "exec/helper-gen.h"
83
- * @tb: translation block
124
84
- * @max_insns: max number of instructions to translate
125
diff --git a/tcg/tcg.h b/tcg/tcg.h
85
- * @pc: guest virtual program counter address
126
index XXXXXXX..XXXXXXX 100644
86
- * @host_pc: host physical program counter address
127
--- a/tcg/tcg.h
87
- *
128
+++ b/tcg/tcg.h
88
- * This function must be provided by the target, which should create
89
- * the target-specific DisasContext, and then invoke translator_loop.
90
- */
91
-void gen_intermediate_code(CPUState *cpu, TranslationBlock *tb, int *max_insns,
92
- vaddr pc, void *host_pc);
93
-
94
/**
95
* DisasJumpType:
96
* @DISAS_NEXT: Next instruction in program order.
97
diff --git a/include/hw/core/tcg-cpu-ops.h b/include/hw/core/tcg-cpu-ops.h
98
index XXXXXXX..XXXXXXX 100644
99
--- a/include/hw/core/tcg-cpu-ops.h
100
+++ b/include/hw/core/tcg-cpu-ops.h
101
@@ -XXX,XX +XXX,XX @@ struct TCGCPUOps {
102
* Called when the first CPU is realized.
103
*/
104
void (*initialize)(void);
105
+ /**
106
+ * @translate_code: Translate guest instructions to TCGOps
107
+ * @cpu: cpu context
108
+ * @tb: translation block
109
+ * @max_insns: max number of instructions to translate
110
+ * @pc: guest virtual program counter address
111
+ * @host_pc: host physical program counter address
112
+ *
113
+ * This function must be provided by the target, which should create
114
+ * the target-specific DisasContext, and then invoke translator_loop.
115
+ */
116
+ void (*translate_code)(CPUState *cpu, TranslationBlock *tb,
117
+ int *max_insns, vaddr pc, void *host_pc);
118
/**
119
* @synchronize_from_tb: Synchronize state from a TCG #TranslationBlock
120
*
121
diff --git a/target/alpha/cpu.h b/target/alpha/cpu.h
122
index XXXXXXX..XXXXXXX 100644
123
--- a/target/alpha/cpu.h
124
+++ b/target/alpha/cpu.h
125
@@ -XXX,XX +XXX,XX @@ enum {
126
};
127
128
void alpha_translate_init(void);
129
+void alpha_translate_code(CPUState *cs, TranslationBlock *tb,
130
+ int *max_insns, vaddr pc, void *host_pc);
131
132
#define CPU_RESOLVING_TYPE TYPE_ALPHA_CPU
133
134
diff --git a/target/arm/internals.h b/target/arm/internals.h
135
index XXXXXXX..XXXXXXX 100644
136
--- a/target/arm/internals.h
137
+++ b/target/arm/internals.h
138
@@ -XXX,XX +XXX,XX @@ void init_cpreg_list(ARMCPU *cpu);
139
140
void arm_cpu_register_gdb_regs_for_features(ARMCPU *cpu);
141
void arm_translate_init(void);
142
+void arm_translate_code(CPUState *cs, TranslationBlock *tb,
143
+ int *max_insns, vaddr pc, void *host_pc);
144
145
void arm_cpu_register_gdb_commands(ARMCPU *cpu);
146
void aarch64_cpu_register_gdb_commands(ARMCPU *cpu, GString *,
147
diff --git a/target/avr/cpu.h b/target/avr/cpu.h
148
index XXXXXXX..XXXXXXX 100644
149
--- a/target/avr/cpu.h
150
+++ b/target/avr/cpu.h
151
@@ -XXX,XX +XXX,XX @@ static inline void set_avr_feature(CPUAVRState *env, int feature)
152
}
153
154
void avr_cpu_tcg_init(void);
155
+void avr_cpu_translate_code(CPUState *cs, TranslationBlock *tb,
156
+ int *max_insns, vaddr pc, void *host_pc);
157
158
int cpu_avr_exec(CPUState *cpu);
159
160
diff --git a/target/hexagon/cpu.h b/target/hexagon/cpu.h
161
index XXXXXXX..XXXXXXX 100644
162
--- a/target/hexagon/cpu.h
163
+++ b/target/hexagon/cpu.h
164
@@ -XXX,XX +XXX,XX @@ static inline void cpu_get_tb_cpu_state(CPUHexagonState *env, vaddr *pc,
165
typedef HexagonCPU ArchCPU;
166
167
void hexagon_translate_init(void);
168
+void hexagon_translate_code(CPUState *cs, TranslationBlock *tb,
169
+ int *max_insns, vaddr pc, void *host_pc);
170
171
#include "exec/cpu-all.h"
172
173
diff --git a/target/hppa/cpu.h b/target/hppa/cpu.h
174
index XXXXXXX..XXXXXXX 100644
175
--- a/target/hppa/cpu.h
176
+++ b/target/hppa/cpu.h
177
@@ -XXX,XX +XXX,XX @@ static inline int HPPA_BTLB_ENTRIES(CPUHPPAState *env)
178
}
179
180
void hppa_translate_init(void);
181
+void hppa_translate_code(CPUState *cs, TranslationBlock *tb,
182
+ int *max_insns, vaddr pc, void *host_pc);
183
184
#define CPU_RESOLVING_TYPE TYPE_HPPA_CPU
185
186
diff --git a/target/i386/tcg/helper-tcg.h b/target/i386/tcg/helper-tcg.h
187
index XXXXXXX..XXXXXXX 100644
188
--- a/target/i386/tcg/helper-tcg.h
189
+++ b/target/i386/tcg/helper-tcg.h
190
@@ -XXX,XX +XXX,XX @@ static inline target_long lshift(target_long x, int n)
191
192
/* translate.c */
193
void tcg_x86_init(void);
194
+void x86_translate_code(CPUState *cs, TranslationBlock *tb,
195
+ int *max_insns, vaddr pc, void *host_pc);
196
197
/* excp_helper.c */
198
G_NORETURN void raise_exception(CPUX86State *env, int exception_index);
199
diff --git a/target/loongarch/internals.h b/target/loongarch/internals.h
200
index XXXXXXX..XXXXXXX 100644
201
--- a/target/loongarch/internals.h
202
+++ b/target/loongarch/internals.h
129
@@ -XXX,XX +XXX,XX @@
203
@@ -XXX,XX +XXX,XX @@
130
#include "qemu/bitops.h"
204
#define TARGET_VIRT_MASK MAKE_64BIT_MASK(0, TARGET_VIRT_ADDR_SPACE_BITS)
131
#include "qemu/plugin.h"
205
132
#include "qemu/queue.h"
206
void loongarch_translate_init(void);
133
-#include "tcg-mo.h"
207
+void loongarch_translate_code(CPUState *cs, TranslationBlock *tb,
134
+#include "tcg/tcg-mo.h"
208
+ int *max_insns, vaddr pc, void *host_pc);
135
#include "tcg-target.h"
209
136
#include "qemu/int128.h"
210
void G_NORETURN do_raise_exception(CPULoongArchState *env,
137
211
uint32_t exception,
138
@@ -XXX,XX +XXX,XX @@ typedef uint64_t TCGRegSet;
212
diff --git a/target/m68k/cpu.h b/target/m68k/cpu.h
139
213
index XXXXXXX..XXXXXXX 100644
140
typedef enum TCGOpcode {
214
--- a/target/m68k/cpu.h
141
#define DEF(name, oargs, iargs, cargs, flags) INDEX_op_ ## name,
215
+++ b/target/m68k/cpu.h
142
-#include "tcg-opc.h"
216
@@ -XXX,XX +XXX,XX @@ int m68k_cpu_gdb_read_register(CPUState *cpu, GByteArray *buf, int reg);
143
+#include "tcg/tcg-opc.h"
217
int m68k_cpu_gdb_write_register(CPUState *cpu, uint8_t *buf, int reg);
144
#undef DEF
218
145
NB_OPS,
219
void m68k_tcg_init(void);
146
} TCGOpcode;
220
+void m68k_translate_code(CPUState *cs, TranslationBlock *tb,
221
+ int *max_insns, vaddr pc, void *host_pc);
222
void m68k_cpu_init_gdb(M68kCPU *cpu);
223
uint32_t cpu_m68k_get_ccr(CPUM68KState *env);
224
void cpu_m68k_set_ccr(CPUM68KState *env, uint32_t);
225
diff --git a/target/microblaze/cpu.h b/target/microblaze/cpu.h
226
index XXXXXXX..XXXXXXX 100644
227
--- a/target/microblaze/cpu.h
228
+++ b/target/microblaze/cpu.h
229
@@ -XXX,XX +XXX,XX @@ static inline void mb_cpu_write_msr(CPUMBState *env, uint32_t val)
230
}
231
232
void mb_tcg_init(void);
233
+void mb_translate_code(CPUState *cs, TranslationBlock *tb,
234
+ int *max_insns, vaddr pc, void *host_pc);
235
236
#define CPU_RESOLVING_TYPE TYPE_MICROBLAZE_CPU
237
238
diff --git a/target/mips/tcg/tcg-internal.h b/target/mips/tcg/tcg-internal.h
239
index XXXXXXX..XXXXXXX 100644
240
--- a/target/mips/tcg/tcg-internal.h
241
+++ b/target/mips/tcg/tcg-internal.h
242
@@ -XXX,XX +XXX,XX @@
243
#include "cpu.h"
244
245
void mips_tcg_init(void);
246
+void mips_translate_code(CPUState *cs, TranslationBlock *tb,
247
+ int *max_insns, vaddr pc, void *host_pc);
248
249
void mips_cpu_synchronize_from_tb(CPUState *cs, const TranslationBlock *tb);
250
G_NORETURN void mips_cpu_do_unaligned_access(CPUState *cpu, vaddr addr,
251
diff --git a/target/openrisc/cpu.h b/target/openrisc/cpu.h
252
index XXXXXXX..XXXXXXX 100644
253
--- a/target/openrisc/cpu.h
254
+++ b/target/openrisc/cpu.h
255
@@ -XXX,XX +XXX,XX @@ void openrisc_cpu_dump_state(CPUState *cpu, FILE *f, int flags);
256
int openrisc_cpu_gdb_read_register(CPUState *cpu, GByteArray *buf, int reg);
257
int openrisc_cpu_gdb_write_register(CPUState *cpu, uint8_t *buf, int reg);
258
void openrisc_translate_init(void);
259
+void openrisc_translate_code(CPUState *cs, TranslationBlock *tb,
260
+ int *max_insns, vaddr pc, void *host_pc);
261
int print_insn_or1k(bfd_vma addr, disassemble_info *info);
262
263
#ifndef CONFIG_USER_ONLY
264
diff --git a/target/ppc/cpu.h b/target/ppc/cpu.h
265
index XXXXXXX..XXXXXXX 100644
266
--- a/target/ppc/cpu.h
267
+++ b/target/ppc/cpu.h
268
@@ -XXX,XX +XXX,XX @@ extern const VMStateDescription vmstate_ppc_cpu;
269
270
/*****************************************************************************/
271
void ppc_translate_init(void);
272
+void ppc_translate_code(CPUState *cs, TranslationBlock *tb,
273
+ int *max_insns, vaddr pc, void *host_pc);
274
275
#if !defined(CONFIG_USER_ONLY)
276
void ppc_store_sdr1(CPUPPCState *env, target_ulong value);
277
diff --git a/target/riscv/cpu.h b/target/riscv/cpu.h
278
index XXXXXXX..XXXXXXX 100644
279
--- a/target/riscv/cpu.h
280
+++ b/target/riscv/cpu.h
281
@@ -XXX,XX +XXX,XX @@ RISCVException smstateen_acc_ok(CPURISCVState *env, int index, uint64_t bit);
282
void riscv_cpu_set_mode(CPURISCVState *env, target_ulong newpriv, bool virt_en);
283
284
void riscv_translate_init(void);
285
+void riscv_translate_code(CPUState *cs, TranslationBlock *tb,
286
+ int *max_insns, vaddr pc, void *host_pc);
287
+
288
G_NORETURN void riscv_raise_exception(CPURISCVState *env,
289
uint32_t exception, uintptr_t pc);
290
291
diff --git a/target/rx/cpu.h b/target/rx/cpu.h
292
index XXXXXXX..XXXXXXX 100644
293
--- a/target/rx/cpu.h
294
+++ b/target/rx/cpu.h
295
@@ -XXX,XX +XXX,XX @@ int rx_cpu_gdb_read_register(CPUState *cpu, GByteArray *buf, int reg);
296
int rx_cpu_gdb_write_register(CPUState *cpu, uint8_t *buf, int reg);
297
298
void rx_translate_init(void);
299
+void rx_translate_code(CPUState *cs, TranslationBlock *tb,
300
+ int *max_insns, vaddr pc, void *host_pc);
301
void rx_cpu_unpack_psw(CPURXState *env, uint32_t psw, int rte);
302
303
#include "exec/cpu-all.h"
304
diff --git a/target/s390x/s390x-internal.h b/target/s390x/s390x-internal.h
305
index XXXXXXX..XXXXXXX 100644
306
--- a/target/s390x/s390x-internal.h
307
+++ b/target/s390x/s390x-internal.h
308
@@ -XXX,XX +XXX,XX @@ void handle_diag_308(CPUS390XState *env, uint64_t r1, uint64_t r3,
309
310
/* translate.c */
311
void s390x_translate_init(void);
312
+void s390x_translate_code(CPUState *cs, TranslationBlock *tb,
313
+ int *max_insns, vaddr pc, void *host_pc);
314
void s390x_restore_state_to_opc(CPUState *cs,
315
const TranslationBlock *tb,
316
const uint64_t *data);
317
diff --git a/target/sh4/cpu.h b/target/sh4/cpu.h
318
index XXXXXXX..XXXXXXX 100644
319
--- a/target/sh4/cpu.h
320
+++ b/target/sh4/cpu.h
321
@@ -XXX,XX +XXX,XX @@ G_NORETURN void superh_cpu_do_unaligned_access(CPUState *cpu, vaddr addr,
322
uintptr_t retaddr);
323
324
void sh4_translate_init(void);
325
+void sh4_translate_code(CPUState *cs, TranslationBlock *tb,
326
+ int *max_insns, vaddr pc, void *host_pc);
327
328
#if !defined(CONFIG_USER_ONLY)
329
hwaddr superh_cpu_get_phys_page_debug(CPUState *cpu, vaddr addr);
330
diff --git a/target/sparc/cpu.h b/target/sparc/cpu.h
331
index XXXXXXX..XXXXXXX 100644
332
--- a/target/sparc/cpu.h
333
+++ b/target/sparc/cpu.h
334
@@ -XXX,XX +XXX,XX @@ int sparc_cpu_memory_rw_debug(CPUState *cpu, vaddr addr,
335
336
/* translate.c */
337
void sparc_tcg_init(void);
338
+void sparc_translate_code(CPUState *cs, TranslationBlock *tb,
339
+ int *max_insns, vaddr pc, void *host_pc);
340
341
/* fop_helper.c */
342
target_ulong cpu_get_fsr(CPUSPARCState *);
343
diff --git a/target/tricore/cpu.h b/target/tricore/cpu.h
344
index XXXXXXX..XXXXXXX 100644
345
--- a/target/tricore/cpu.h
346
+++ b/target/tricore/cpu.h
347
@@ -XXX,XX +XXX,XX @@ FIELD(TB_FLAGS, PRIV, 0, 2)
348
349
void cpu_state_reset(CPUTriCoreState *s);
350
void tricore_tcg_init(void);
351
+void tricore_translate_code(CPUState *cs, TranslationBlock *tb,
352
+ int *max_insns, vaddr pc, void *host_pc);
353
354
static inline void cpu_get_tb_cpu_state(CPUTriCoreState *env, vaddr *pc,
355
uint64_t *cs_base, uint32_t *flags)
356
diff --git a/target/xtensa/cpu.h b/target/xtensa/cpu.h
357
index XXXXXXX..XXXXXXX 100644
358
--- a/target/xtensa/cpu.h
359
+++ b/target/xtensa/cpu.h
360
@@ -XXX,XX +XXX,XX @@ G_NORETURN void xtensa_cpu_do_unaligned_access(CPUState *cpu, vaddr addr,
361
362
void xtensa_collect_sr_names(const XtensaConfig *config);
363
void xtensa_translate_init(void);
364
+void xtensa_translate_code(CPUState *cs, TranslationBlock *tb,
365
+ int *max_insns, vaddr pc, void *host_pc);
366
void **xtensa_get_regfile_by_name(const char *name, int entries, int bits);
367
void xtensa_breakpoint_handler(CPUState *cs);
368
void xtensa_register_core(XtensaConfigList *node);
147
diff --git a/accel/tcg/cpu-exec.c b/accel/tcg/cpu-exec.c
369
diff --git a/accel/tcg/cpu-exec.c b/accel/tcg/cpu-exec.c
148
index XXXXXXX..XXXXXXX 100644
370
index XXXXXXX..XXXXXXX 100644
149
--- a/accel/tcg/cpu-exec.c
371
--- a/accel/tcg/cpu-exec.c
150
+++ b/accel/tcg/cpu-exec.c
372
+++ b/accel/tcg/cpu-exec.c
151
@@ -XXX,XX +XXX,XX @@
373
@@ -XXX,XX +XXX,XX @@ bool tcg_exec_realizefn(CPUState *cpu, Error **errp)
152
#include "trace.h"
374
153
#include "disas/disas.h"
375
if (!tcg_target_initialized) {
154
#include "exec/exec-all.h"
376
/* Check mandatory TCGCPUOps handlers */
155
-#include "tcg.h"
377
+ const TCGCPUOps *tcg_ops = cpu->cc->tcg_ops;
156
+#include "tcg/tcg.h"
378
#ifndef CONFIG_USER_ONLY
157
#include "qemu/atomic.h"
379
- assert(cpu->cc->tcg_ops->cpu_exec_halt);
158
#include "sysemu/qtest.h"
380
- assert(cpu->cc->tcg_ops->cpu_exec_interrupt);
159
#include "qemu/timer.h"
381
+ assert(tcg_ops->cpu_exec_halt);
160
diff --git a/accel/tcg/tcg-runtime-gvec.c b/accel/tcg/tcg-runtime-gvec.c
382
+ assert(tcg_ops->cpu_exec_interrupt);
161
index XXXXXXX..XXXXXXX 100644
383
#endif /* !CONFIG_USER_ONLY */
162
--- a/accel/tcg/tcg-runtime-gvec.c
384
- cpu->cc->tcg_ops->initialize();
163
+++ b/accel/tcg/tcg-runtime-gvec.c
385
+ assert(tcg_ops->translate_code);
164
@@ -XXX,XX +XXX,XX @@
386
+ tcg_ops->initialize();
165
#include "qemu/host-utils.h"
387
tcg_target_initialized = true;
166
#include "cpu.h"
388
}
167
#include "exec/helper-proto.h"
168
-#include "tcg-gvec-desc.h"
169
+#include "tcg/tcg-gvec-desc.h"
170
171
172
/* Virtually all hosts support 16-byte vectors. Those that don't can emulate
173
diff --git a/accel/tcg/tcg-runtime.c b/accel/tcg/tcg-runtime.c
174
index XXXXXXX..XXXXXXX 100644
175
--- a/accel/tcg/tcg-runtime.c
176
+++ b/accel/tcg/tcg-runtime.c
177
@@ -XXX,XX +XXX,XX @@
178
#include "exec/tb-lookup.h"
179
#include "disas/disas.h"
180
#include "exec/log.h"
181
-#include "tcg.h"
182
+#include "tcg/tcg.h"
183
184
/* 32-bit helpers */
185
389
186
diff --git a/accel/tcg/translate-all.c b/accel/tcg/translate-all.c
390
diff --git a/accel/tcg/translate-all.c b/accel/tcg/translate-all.c
187
index XXXXXXX..XXXXXXX 100644
391
index XXXXXXX..XXXXXXX 100644
188
--- a/accel/tcg/translate-all.c
392
--- a/accel/tcg/translate-all.c
189
+++ b/accel/tcg/translate-all.c
393
+++ b/accel/tcg/translate-all.c
190
@@ -XXX,XX +XXX,XX @@
394
@@ -XXX,XX +XXX,XX @@ static int setjmp_gen_code(CPUArchState *env, TranslationBlock *tb,
191
#include "trace.h"
395
192
#include "disas/disas.h"
396
tcg_func_start(tcg_ctx);
193
#include "exec/exec-all.h"
397
194
-#include "tcg.h"
398
- tcg_ctx->cpu = env_cpu(env);
195
+#include "tcg/tcg.h"
399
- gen_intermediate_code(env_cpu(env), tb, max_insns, pc, host_pc);
196
#if defined(CONFIG_USER_ONLY)
400
+ CPUState *cs = env_cpu(env);
197
#include "qemu.h"
401
+ tcg_ctx->cpu = cs;
198
#if defined(__FreeBSD__) || defined(__FreeBSD_kernel__)
402
+ cs->cc->tcg_ops->translate_code(cs, tb, max_insns, pc, host_pc);
199
diff --git a/accel/tcg/user-exec.c b/accel/tcg/user-exec.c
403
+
200
index XXXXXXX..XXXXXXX 100644
404
assert(tb->size != 0);
201
--- a/accel/tcg/user-exec.c
405
tcg_ctx->cpu = NULL;
202
+++ b/accel/tcg/user-exec.c
406
*max_insns = tb->icount;
203
@@ -XXX,XX +XXX,XX @@
407
@@ -XXX,XX +XXX,XX @@ TranslationBlock *tb_gen_code(CPUState *cpu,
204
#include "cpu.h"
408
/*
205
#include "disas/disas.h"
409
* Overflow of code_gen_buffer, or the current slice of it.
206
#include "exec/exec-all.h"
410
*
207
-#include "tcg.h"
411
- * TODO: We don't need to re-do gen_intermediate_code, nor
208
+#include "tcg/tcg.h"
412
+ * TODO: We don't need to re-do tcg_ops->translate_code, nor
209
#include "qemu/bitops.h"
413
* should we re-do the tcg optimization currently hidden
210
#include "exec/cpu_ldst.h"
414
* inside tcg_gen_code. All that should be required is to
211
#include "translate-all.h"
415
* flush the TBs, allocate a new TB, re-initialize it per
212
diff --git a/bsd-user/main.c b/bsd-user/main.c
416
diff --git a/target/alpha/cpu.c b/target/alpha/cpu.c
213
index XXXXXXX..XXXXXXX 100644
417
index XXXXXXX..XXXXXXX 100644
214
--- a/bsd-user/main.c
418
--- a/target/alpha/cpu.c
215
+++ b/bsd-user/main.c
419
+++ b/target/alpha/cpu.c
216
@@ -XXX,XX +XXX,XX @@
420
@@ -XXX,XX +XXX,XX @@ static const struct SysemuCPUOps alpha_sysemu_ops = {
217
#include "qemu/module.h"
421
218
#include "cpu.h"
422
static const TCGCPUOps alpha_tcg_ops = {
219
#include "exec/exec-all.h"
423
.initialize = alpha_translate_init,
220
-#include "tcg.h"
424
+ .translate_code = alpha_translate_code,
221
+#include "tcg/tcg.h"
425
.synchronize_from_tb = alpha_cpu_synchronize_from_tb,
222
#include "qemu/timer.h"
426
.restore_state_to_opc = alpha_restore_state_to_opc,
223
#include "qemu/envlist.h"
427
224
#include "exec/log.h"
225
diff --git a/cpus.c b/cpus.c
226
index XXXXXXX..XXXXXXX 100644
227
--- a/cpus.c
228
+++ b/cpus.c
229
@@ -XXX,XX +XXX,XX @@
230
#include "qemu/bitmap.h"
231
#include "qemu/seqlock.h"
232
#include "qemu/guest-random.h"
233
-#include "tcg.h"
234
+#include "tcg/tcg.h"
235
#include "hw/nmi.h"
236
#include "sysemu/replay.h"
237
#include "sysemu/runstate.h"
238
diff --git a/exec.c b/exec.c
239
index XXXXXXX..XXXXXXX 100644
240
--- a/exec.c
241
+++ b/exec.c
242
@@ -XXX,XX +XXX,XX @@
243
#include "cpu.h"
244
#include "exec/exec-all.h"
245
#include "exec/target_page.h"
246
-#include "tcg.h"
247
+#include "tcg/tcg.h"
248
#include "hw/qdev-core.h"
249
#include "hw/qdev-properties.h"
250
#if !defined(CONFIG_USER_ONLY)
251
diff --git a/linux-user/main.c b/linux-user/main.c
252
index XXXXXXX..XXXXXXX 100644
253
--- a/linux-user/main.c
254
+++ b/linux-user/main.c
255
@@ -XXX,XX +XXX,XX @@
256
#include "qemu/plugin.h"
257
#include "cpu.h"
258
#include "exec/exec-all.h"
259
-#include "tcg.h"
260
+#include "tcg/tcg.h"
261
#include "qemu/timer.h"
262
#include "qemu/envlist.h"
263
#include "qemu/guest-random.h"
264
diff --git a/linux-user/syscall.c b/linux-user/syscall.c
265
index XXXXXXX..XXXXXXX 100644
266
--- a/linux-user/syscall.c
267
+++ b/linux-user/syscall.c
268
@@ -XXX,XX +XXX,XX @@
269
#include "user/syscall-trace.h"
270
#include "qapi/error.h"
271
#include "fd-trans.h"
272
-#include "tcg.h"
273
+#include "tcg/tcg.h"
274
275
#ifndef CLONE_IO
276
#define CLONE_IO 0x80000000 /* Clone io context */
277
diff --git a/target/alpha/translate.c b/target/alpha/translate.c
428
diff --git a/target/alpha/translate.c b/target/alpha/translate.c
278
index XXXXXXX..XXXXXXX 100644
429
index XXXXXXX..XXXXXXX 100644
279
--- a/target/alpha/translate.c
430
--- a/target/alpha/translate.c
280
+++ b/target/alpha/translate.c
431
+++ b/target/alpha/translate.c
281
@@ -XXX,XX +XXX,XX @@
432
@@ -XXX,XX +XXX,XX @@ static const TranslatorOps alpha_tr_ops = {
282
#include "disas/disas.h"
433
.tb_stop = alpha_tr_tb_stop,
283
#include "qemu/host-utils.h"
434
};
284
#include "exec/exec-all.h"
435
285
-#include "tcg-op.h"
436
-void gen_intermediate_code(CPUState *cpu, TranslationBlock *tb, int *max_insns,
286
+#include "tcg/tcg-op.h"
437
- vaddr pc, void *host_pc)
287
#include "exec/cpu_ldst.h"
438
+void alpha_translate_code(CPUState *cpu, TranslationBlock *tb,
288
#include "exec/helper-proto.h"
439
+ int *max_insns, vaddr pc, void *host_pc)
289
#include "exec/helper-gen.h"
440
{
290
diff --git a/target/arm/helper-a64.c b/target/arm/helper-a64.c
441
DisasContext dc;
291
index XXXXXXX..XXXXXXX 100644
442
translator_loop(cpu, tb, max_insns, pc, host_pc, &alpha_tr_ops, &dc.base);
292
--- a/target/arm/helper-a64.c
443
diff --git a/target/arm/cpu.c b/target/arm/cpu.c
293
+++ b/target/arm/helper-a64.c
444
index XXXXXXX..XXXXXXX 100644
294
@@ -XXX,XX +XXX,XX @@
445
--- a/target/arm/cpu.c
295
#include "exec/cpu_ldst.h"
446
+++ b/target/arm/cpu.c
296
#include "qemu/int128.h"
447
@@ -XXX,XX +XXX,XX @@ static const struct SysemuCPUOps arm_sysemu_ops = {
297
#include "qemu/atomic128.h"
448
#ifdef CONFIG_TCG
298
-#include "tcg.h"
449
static const TCGCPUOps arm_tcg_ops = {
299
+#include "tcg/tcg.h"
450
.initialize = arm_translate_init,
300
#include "fpu/softfloat.h"
451
+ .translate_code = arm_translate_code,
301
#include <zlib.h> /* For crc32 */
452
.synchronize_from_tb = arm_cpu_synchronize_from_tb,
302
453
.debug_excp_handler = arm_debug_excp_handler,
303
diff --git a/target/arm/sve_helper.c b/target/arm/sve_helper.c
454
.restore_state_to_opc = arm_restore_state_to_opc,
304
index XXXXXXX..XXXXXXX 100644
455
diff --git a/target/arm/tcg/cpu-v7m.c b/target/arm/tcg/cpu-v7m.c
305
--- a/target/arm/sve_helper.c
456
index XXXXXXX..XXXXXXX 100644
306
+++ b/target/arm/sve_helper.c
457
--- a/target/arm/tcg/cpu-v7m.c
307
@@ -XXX,XX +XXX,XX @@
458
+++ b/target/arm/tcg/cpu-v7m.c
308
#include "exec/helper-proto.h"
459
@@ -XXX,XX +XXX,XX @@ static void cortex_m55_initfn(Object *obj)
309
#include "tcg/tcg-gvec-desc.h"
460
310
#include "fpu/softfloat.h"
461
static const TCGCPUOps arm_v7m_tcg_ops = {
311
-#include "tcg.h"
462
.initialize = arm_translate_init,
312
+#include "tcg/tcg.h"
463
+ .translate_code = arm_translate_code,
313
464
.synchronize_from_tb = arm_cpu_synchronize_from_tb,
314
465
.debug_excp_handler = arm_debug_excp_handler,
315
/* Note that vector data is stored in host-endian 64-bit chunks,
466
.restore_state_to_opc = arm_restore_state_to_opc,
316
diff --git a/target/arm/translate-a64.c b/target/arm/translate-a64.c
467
diff --git a/target/arm/tcg/translate.c b/target/arm/tcg/translate.c
317
index XXXXXXX..XXXXXXX 100644
468
index XXXXXXX..XXXXXXX 100644
318
--- a/target/arm/translate-a64.c
469
--- a/target/arm/tcg/translate.c
319
+++ b/target/arm/translate-a64.c
470
+++ b/target/arm/tcg/translate.c
320
@@ -XXX,XX +XXX,XX @@
471
@@ -XXX,XX +XXX,XX @@ static const TranslatorOps thumb_translator_ops = {
321
472
.tb_stop = arm_tr_tb_stop,
322
#include "cpu.h"
473
};
323
#include "exec/exec-all.h"
474
324
-#include "tcg-op.h"
475
-/* generate intermediate code for basic block 'tb'. */
325
-#include "tcg-op-gvec.h"
476
-void gen_intermediate_code(CPUState *cpu, TranslationBlock *tb, int *max_insns,
326
+#include "tcg/tcg-op.h"
477
- vaddr pc, void *host_pc)
327
+#include "tcg/tcg-op-gvec.h"
478
+void arm_translate_code(CPUState *cpu, TranslationBlock *tb,
328
#include "qemu/log.h"
479
+ int *max_insns, vaddr pc, void *host_pc)
329
#include "arm_ldst.h"
480
{
330
#include "translate.h"
481
DisasContext dc = { };
331
diff --git a/target/arm/translate-sve.c b/target/arm/translate-sve.c
482
const TranslatorOps *ops = &arm_translator_ops;
332
index XXXXXXX..XXXXXXX 100644
483
diff --git a/target/avr/cpu.c b/target/avr/cpu.c
333
--- a/target/arm/translate-sve.c
484
index XXXXXXX..XXXXXXX 100644
334
+++ b/target/arm/translate-sve.c
485
--- a/target/avr/cpu.c
335
@@ -XXX,XX +XXX,XX @@
486
+++ b/target/avr/cpu.c
336
#include "qemu/osdep.h"
487
@@ -XXX,XX +XXX,XX @@ static const struct SysemuCPUOps avr_sysemu_ops = {
337
#include "cpu.h"
488
338
#include "exec/exec-all.h"
489
static const TCGCPUOps avr_tcg_ops = {
339
-#include "tcg-op.h"
490
.initialize = avr_cpu_tcg_init,
340
-#include "tcg-op-gvec.h"
491
+ .translate_code = avr_cpu_translate_code,
341
-#include "tcg-gvec-desc.h"
492
.synchronize_from_tb = avr_cpu_synchronize_from_tb,
342
+#include "tcg/tcg-op.h"
493
.restore_state_to_opc = avr_restore_state_to_opc,
343
+#include "tcg/tcg-op-gvec.h"
494
.cpu_exec_interrupt = avr_cpu_exec_interrupt,
344
+#include "tcg/tcg-gvec-desc.h"
495
diff --git a/target/avr/translate.c b/target/avr/translate.c
345
#include "qemu/log.h"
496
index XXXXXXX..XXXXXXX 100644
346
#include "arm_ldst.h"
497
--- a/target/avr/translate.c
347
#include "translate.h"
498
+++ b/target/avr/translate.c
348
diff --git a/target/arm/translate.c b/target/arm/translate.c
499
@@ -XXX,XX +XXX,XX @@ static bool trans_WDR(DisasContext *ctx, arg_WDR *a)
349
index XXXXXXX..XXXXXXX 100644
500
*
350
--- a/target/arm/translate.c
501
* - translate()
351
+++ b/target/arm/translate.c
502
* - canonicalize_skip()
352
@@ -XXX,XX +XXX,XX @@
503
- * - gen_intermediate_code()
353
#include "internals.h"
504
+ * - translate_code()
354
#include "disas/disas.h"
505
* - restore_state_to_opc()
355
#include "exec/exec-all.h"
506
*
356
-#include "tcg-op.h"
507
*/
357
-#include "tcg-op-gvec.h"
508
@@ -XXX,XX +XXX,XX @@ static const TranslatorOps avr_tr_ops = {
358
+#include "tcg/tcg-op.h"
509
.tb_stop = avr_tr_tb_stop,
359
+#include "tcg/tcg-op-gvec.h"
510
};
360
#include "qemu/log.h"
511
361
#include "qemu/bitops.h"
512
-void gen_intermediate_code(CPUState *cs, TranslationBlock *tb, int *max_insns,
362
#include "arm_ldst.h"
513
- vaddr pc, void *host_pc)
363
diff --git a/target/cris/translate.c b/target/cris/translate.c
514
+void avr_cpu_translate_code(CPUState *cs, TranslationBlock *tb,
364
index XXXXXXX..XXXXXXX 100644
515
+ int *max_insns, vaddr pc, void *host_pc)
365
--- a/target/cris/translate.c
516
{
366
+++ b/target/cris/translate.c
517
DisasContext dc = { };
367
@@ -XXX,XX +XXX,XX @@
518
translator_loop(cs, tb, max_insns, pc, host_pc, &avr_tr_ops, &dc.base);
368
#include "cpu.h"
519
diff --git a/target/hexagon/cpu.c b/target/hexagon/cpu.c
369
#include "disas/disas.h"
520
index XXXXXXX..XXXXXXX 100644
370
#include "exec/exec-all.h"
521
--- a/target/hexagon/cpu.c
371
-#include "tcg-op.h"
522
+++ b/target/hexagon/cpu.c
372
+#include "tcg/tcg-op.h"
523
@@ -XXX,XX +XXX,XX @@ static void hexagon_cpu_init(Object *obj)
373
#include "exec/helper-proto.h"
524
374
#include "mmu.h"
525
static const TCGCPUOps hexagon_tcg_ops = {
375
#include "exec/cpu_ldst.h"
526
.initialize = hexagon_translate_init,
527
+ .translate_code = hexagon_translate_code,
528
.synchronize_from_tb = hexagon_cpu_synchronize_from_tb,
529
.restore_state_to_opc = hexagon_restore_state_to_opc,
530
};
531
diff --git a/target/hexagon/translate.c b/target/hexagon/translate.c
532
index XXXXXXX..XXXXXXX 100644
533
--- a/target/hexagon/translate.c
534
+++ b/target/hexagon/translate.c
535
@@ -XXX,XX +XXX,XX @@ static const TranslatorOps hexagon_tr_ops = {
536
.tb_stop = hexagon_tr_tb_stop,
537
};
538
539
-void gen_intermediate_code(CPUState *cs, TranslationBlock *tb, int *max_insns,
540
- vaddr pc, void *host_pc)
541
+void hexagon_translate_code(CPUState *cs, TranslationBlock *tb,
542
+ int *max_insns, vaddr pc, void *host_pc)
543
{
544
DisasContext ctx;
545
546
diff --git a/target/hppa/cpu.c b/target/hppa/cpu.c
547
index XXXXXXX..XXXXXXX 100644
548
--- a/target/hppa/cpu.c
549
+++ b/target/hppa/cpu.c
550
@@ -XXX,XX +XXX,XX @@ static const struct SysemuCPUOps hppa_sysemu_ops = {
551
552
static const TCGCPUOps hppa_tcg_ops = {
553
.initialize = hppa_translate_init,
554
+ .translate_code = hppa_translate_code,
555
.synchronize_from_tb = hppa_cpu_synchronize_from_tb,
556
.restore_state_to_opc = hppa_restore_state_to_opc,
557
376
diff --git a/target/hppa/translate.c b/target/hppa/translate.c
558
diff --git a/target/hppa/translate.c b/target/hppa/translate.c
377
index XXXXXXX..XXXXXXX 100644
559
index XXXXXXX..XXXXXXX 100644
378
--- a/target/hppa/translate.c
560
--- a/target/hppa/translate.c
379
+++ b/target/hppa/translate.c
561
+++ b/target/hppa/translate.c
380
@@ -XXX,XX +XXX,XX @@
562
@@ -XXX,XX +XXX,XX @@ static const TranslatorOps hppa_tr_ops = {
381
#include "disas/disas.h"
563
#endif
382
#include "qemu/host-utils.h"
564
};
383
#include "exec/exec-all.h"
565
384
-#include "tcg-op.h"
566
-void gen_intermediate_code(CPUState *cs, TranslationBlock *tb, int *max_insns,
385
+#include "tcg/tcg-op.h"
567
- vaddr pc, void *host_pc)
386
#include "exec/cpu_ldst.h"
568
+void hppa_translate_code(CPUState *cs, TranslationBlock *tb,
387
#include "exec/helper-proto.h"
569
+ int *max_insns, vaddr pc, void *host_pc)
388
#include "exec/helper-gen.h"
570
{
389
diff --git a/target/i386/mem_helper.c b/target/i386/mem_helper.c
571
DisasContext ctx = { };
390
index XXXXXXX..XXXXXXX 100644
572
translator_loop(cs, tb, max_insns, pc, host_pc, &hppa_tr_ops, &ctx.base);
391
--- a/target/i386/mem_helper.c
573
diff --git a/target/i386/tcg/tcg-cpu.c b/target/i386/tcg/tcg-cpu.c
392
+++ b/target/i386/mem_helper.c
574
index XXXXXXX..XXXXXXX 100644
393
@@ -XXX,XX +XXX,XX @@
575
--- a/target/i386/tcg/tcg-cpu.c
394
#include "exec/cpu_ldst.h"
576
+++ b/target/i386/tcg/tcg-cpu.c
395
#include "qemu/int128.h"
577
@@ -XXX,XX +XXX,XX @@ static bool x86_debug_check_breakpoint(CPUState *cs)
396
#include "qemu/atomic128.h"
578
397
-#include "tcg.h"
579
static const TCGCPUOps x86_tcg_ops = {
398
+#include "tcg/tcg.h"
580
.initialize = tcg_x86_init,
399
581
+ .translate_code = x86_translate_code,
400
void helper_cmpxchg8b_unlocked(CPUX86State *env, target_ulong a0)
582
.synchronize_from_tb = x86_cpu_synchronize_from_tb,
401
{
583
.restore_state_to_opc = x86_restore_state_to_opc,
402
diff --git a/target/i386/translate.c b/target/i386/translate.c
584
.cpu_exec_enter = x86_cpu_exec_enter,
403
index XXXXXXX..XXXXXXX 100644
585
diff --git a/target/i386/tcg/translate.c b/target/i386/tcg/translate.c
404
--- a/target/i386/translate.c
586
index XXXXXXX..XXXXXXX 100644
405
+++ b/target/i386/translate.c
587
--- a/target/i386/tcg/translate.c
406
@@ -XXX,XX +XXX,XX @@
588
+++ b/target/i386/tcg/translate.c
407
#include "cpu.h"
589
@@ -XXX,XX +XXX,XX @@ static const TranslatorOps i386_tr_ops = {
408
#include "disas/disas.h"
590
.tb_stop = i386_tr_tb_stop,
409
#include "exec/exec-all.h"
591
};
410
-#include "tcg-op.h"
592
411
+#include "tcg/tcg-op.h"
593
-/* generate intermediate code for basic block 'tb'. */
412
#include "exec/cpu_ldst.h"
594
-void gen_intermediate_code(CPUState *cpu, TranslationBlock *tb, int *max_insns,
413
#include "exec/translator.h"
595
- vaddr pc, void *host_pc)
414
596
+void x86_translate_code(CPUState *cpu, TranslationBlock *tb,
415
diff --git a/target/lm32/translate.c b/target/lm32/translate.c
597
+ int *max_insns, vaddr pc, void *host_pc)
416
index XXXXXXX..XXXXXXX 100644
598
{
417
--- a/target/lm32/translate.c
599
DisasContext dc;
418
+++ b/target/lm32/translate.c
600
419
@@ -XXX,XX +XXX,XX @@
601
diff --git a/target/loongarch/cpu.c b/target/loongarch/cpu.c
420
#include "exec/helper-proto.h"
602
index XXXXXXX..XXXXXXX 100644
421
#include "exec/exec-all.h"
603
--- a/target/loongarch/cpu.c
422
#include "exec/translator.h"
604
+++ b/target/loongarch/cpu.c
423
-#include "tcg-op.h"
605
@@ -XXX,XX +XXX,XX @@ static void loongarch_cpu_dump_state(CPUState *cs, FILE *f, int flags)
424
+#include "tcg/tcg-op.h"
606
425
#include "qemu/qemu-print.h"
607
static const TCGCPUOps loongarch_tcg_ops = {
426
608
.initialize = loongarch_translate_init,
427
#include "exec/cpu_ldst.h"
609
+ .translate_code = loongarch_translate_code,
610
.synchronize_from_tb = loongarch_cpu_synchronize_from_tb,
611
.restore_state_to_opc = loongarch_restore_state_to_opc,
612
613
diff --git a/target/loongarch/tcg/translate.c b/target/loongarch/tcg/translate.c
614
index XXXXXXX..XXXXXXX 100644
615
--- a/target/loongarch/tcg/translate.c
616
+++ b/target/loongarch/tcg/translate.c
617
@@ -XXX,XX +XXX,XX @@ static const TranslatorOps loongarch_tr_ops = {
618
.tb_stop = loongarch_tr_tb_stop,
619
};
620
621
-void gen_intermediate_code(CPUState *cs, TranslationBlock *tb, int *max_insns,
622
- vaddr pc, void *host_pc)
623
+void loongarch_translate_code(CPUState *cs, TranslationBlock *tb,
624
+ int *max_insns, vaddr pc, void *host_pc)
625
{
626
DisasContext ctx;
627
628
diff --git a/target/m68k/cpu.c b/target/m68k/cpu.c
629
index XXXXXXX..XXXXXXX 100644
630
--- a/target/m68k/cpu.c
631
+++ b/target/m68k/cpu.c
632
@@ -XXX,XX +XXX,XX @@ static const struct SysemuCPUOps m68k_sysemu_ops = {
633
634
static const TCGCPUOps m68k_tcg_ops = {
635
.initialize = m68k_tcg_init,
636
+ .translate_code = m68k_translate_code,
637
.restore_state_to_opc = m68k_restore_state_to_opc,
638
639
#ifndef CONFIG_USER_ONLY
428
diff --git a/target/m68k/translate.c b/target/m68k/translate.c
640
diff --git a/target/m68k/translate.c b/target/m68k/translate.c
429
index XXXXXXX..XXXXXXX 100644
641
index XXXXXXX..XXXXXXX 100644
430
--- a/target/m68k/translate.c
642
--- a/target/m68k/translate.c
431
+++ b/target/m68k/translate.c
643
+++ b/target/m68k/translate.c
432
@@ -XXX,XX +XXX,XX @@
644
@@ -XXX,XX +XXX,XX @@ static const TranslatorOps m68k_tr_ops = {
433
#include "cpu.h"
645
.tb_stop = m68k_tr_tb_stop,
434
#include "disas/disas.h"
646
};
435
#include "exec/exec-all.h"
647
436
-#include "tcg-op.h"
648
-void gen_intermediate_code(CPUState *cpu, TranslationBlock *tb, int *max_insns,
437
+#include "tcg/tcg-op.h"
649
- vaddr pc, void *host_pc)
438
#include "qemu/log.h"
650
+void m68k_translate_code(CPUState *cpu, TranslationBlock *tb,
439
#include "qemu/qemu-print.h"
651
+ int *max_insns, vaddr pc, void *host_pc)
440
#include "exec/cpu_ldst.h"
652
{
653
DisasContext dc;
654
translator_loop(cpu, tb, max_insns, pc, host_pc, &m68k_tr_ops, &dc.base);
655
diff --git a/target/microblaze/cpu.c b/target/microblaze/cpu.c
656
index XXXXXXX..XXXXXXX 100644
657
--- a/target/microblaze/cpu.c
658
+++ b/target/microblaze/cpu.c
659
@@ -XXX,XX +XXX,XX @@ static const struct SysemuCPUOps mb_sysemu_ops = {
660
661
static const TCGCPUOps mb_tcg_ops = {
662
.initialize = mb_tcg_init,
663
+ .translate_code = mb_translate_code,
664
.synchronize_from_tb = mb_cpu_synchronize_from_tb,
665
.restore_state_to_opc = mb_restore_state_to_opc,
666
441
diff --git a/target/microblaze/translate.c b/target/microblaze/translate.c
667
diff --git a/target/microblaze/translate.c b/target/microblaze/translate.c
442
index XXXXXXX..XXXXXXX 100644
668
index XXXXXXX..XXXXXXX 100644
443
--- a/target/microblaze/translate.c
669
--- a/target/microblaze/translate.c
444
+++ b/target/microblaze/translate.c
670
+++ b/target/microblaze/translate.c
445
@@ -XXX,XX +XXX,XX @@
671
@@ -XXX,XX +XXX,XX @@ static const TranslatorOps mb_tr_ops = {
446
#include "cpu.h"
672
.tb_stop = mb_tr_tb_stop,
447
#include "disas/disas.h"
673
};
448
#include "exec/exec-all.h"
674
449
-#include "tcg-op.h"
675
-void gen_intermediate_code(CPUState *cpu, TranslationBlock *tb, int *max_insns,
450
+#include "tcg/tcg-op.h"
676
- vaddr pc, void *host_pc)
451
#include "exec/helper-proto.h"
677
+void mb_translate_code(CPUState *cpu, TranslationBlock *tb,
452
#include "microblaze-decode.h"
678
+ int *max_insns, vaddr pc, void *host_pc)
453
#include "exec/cpu_ldst.h"
679
{
454
diff --git a/target/mips/translate.c b/target/mips/translate.c
680
DisasContext dc;
455
index XXXXXXX..XXXXXXX 100644
681
translator_loop(cpu, tb, max_insns, pc, host_pc, &mb_tr_ops, &dc.base);
456
--- a/target/mips/translate.c
682
diff --git a/target/mips/cpu.c b/target/mips/cpu.c
457
+++ b/target/mips/translate.c
683
index XXXXXXX..XXXXXXX 100644
458
@@ -XXX,XX +XXX,XX @@
684
--- a/target/mips/cpu.c
459
#include "internal.h"
685
+++ b/target/mips/cpu.c
460
#include "disas/disas.h"
686
@@ -XXX,XX +XXX,XX @@ static const Property mips_cpu_properties[] = {
461
#include "exec/exec-all.h"
687
#include "hw/core/tcg-cpu-ops.h"
462
-#include "tcg-op.h"
688
static const TCGCPUOps mips_tcg_ops = {
463
+#include "tcg/tcg-op.h"
689
.initialize = mips_tcg_init,
464
#include "exec/cpu_ldst.h"
690
+ .translate_code = mips_translate_code,
465
#include "hw/mips/cpudevs.h"
691
.synchronize_from_tb = mips_cpu_synchronize_from_tb,
466
692
.restore_state_to_opc = mips_restore_state_to_opc,
467
diff --git a/target/moxie/translate.c b/target/moxie/translate.c
693
468
index XXXXXXX..XXXXXXX 100644
694
diff --git a/target/mips/tcg/translate.c b/target/mips/tcg/translate.c
469
--- a/target/moxie/translate.c
695
index XXXXXXX..XXXXXXX 100644
470
+++ b/target/moxie/translate.c
696
--- a/target/mips/tcg/translate.c
471
@@ -XXX,XX +XXX,XX @@
697
+++ b/target/mips/tcg/translate.c
472
#include "cpu.h"
698
@@ -XXX,XX +XXX,XX @@ static const TranslatorOps mips_tr_ops = {
473
#include "exec/exec-all.h"
699
.tb_stop = mips_tr_tb_stop,
474
#include "disas/disas.h"
700
};
475
-#include "tcg-op.h"
701
476
+#include "tcg/tcg-op.h"
702
-void gen_intermediate_code(CPUState *cs, TranslationBlock *tb, int *max_insns,
477
#include "exec/cpu_ldst.h"
703
- vaddr pc, void *host_pc)
478
#include "qemu/qemu-print.h"
704
+void mips_translate_code(CPUState *cs, TranslationBlock *tb,
479
705
+ int *max_insns, vaddr pc, void *host_pc)
480
diff --git a/target/nios2/translate.c b/target/nios2/translate.c
706
{
481
index XXXXXXX..XXXXXXX 100644
707
DisasContext ctx;
482
--- a/target/nios2/translate.c
708
483
+++ b/target/nios2/translate.c
709
diff --git a/target/openrisc/cpu.c b/target/openrisc/cpu.c
484
@@ -XXX,XX +XXX,XX @@
710
index XXXXXXX..XXXXXXX 100644
485
711
--- a/target/openrisc/cpu.c
486
#include "qemu/osdep.h"
712
+++ b/target/openrisc/cpu.c
487
#include "cpu.h"
713
@@ -XXX,XX +XXX,XX @@ static const struct SysemuCPUOps openrisc_sysemu_ops = {
488
-#include "tcg-op.h"
714
489
+#include "tcg/tcg-op.h"
715
static const TCGCPUOps openrisc_tcg_ops = {
490
#include "exec/exec-all.h"
716
.initialize = openrisc_translate_init,
491
#include "disas/disas.h"
717
+ .translate_code = openrisc_translate_code,
492
#include "exec/helper-proto.h"
718
.synchronize_from_tb = openrisc_cpu_synchronize_from_tb,
719
.restore_state_to_opc = openrisc_restore_state_to_opc,
720
493
diff --git a/target/openrisc/translate.c b/target/openrisc/translate.c
721
diff --git a/target/openrisc/translate.c b/target/openrisc/translate.c
494
index XXXXXXX..XXXXXXX 100644
722
index XXXXXXX..XXXXXXX 100644
495
--- a/target/openrisc/translate.c
723
--- a/target/openrisc/translate.c
496
+++ b/target/openrisc/translate.c
724
+++ b/target/openrisc/translate.c
497
@@ -XXX,XX +XXX,XX @@
725
@@ -XXX,XX +XXX,XX @@ static const TranslatorOps openrisc_tr_ops = {
498
#include "cpu.h"
726
.tb_stop = openrisc_tr_tb_stop,
499
#include "exec/exec-all.h"
727
};
500
#include "disas/disas.h"
728
501
-#include "tcg-op.h"
729
-void gen_intermediate_code(CPUState *cs, TranslationBlock *tb, int *max_insns,
502
+#include "tcg/tcg-op.h"
730
- vaddr pc, void *host_pc)
503
#include "qemu/log.h"
731
+void openrisc_translate_code(CPUState *cs, TranslationBlock *tb,
504
#include "qemu/bitops.h"
732
+ int *max_insns, vaddr pc, void *host_pc)
505
#include "qemu/qemu-print.h"
733
{
506
diff --git a/target/ppc/mem_helper.c b/target/ppc/mem_helper.c
734
DisasContext ctx;
507
index XXXXXXX..XXXXXXX 100644
735
508
--- a/target/ppc/mem_helper.c
736
diff --git a/target/ppc/cpu_init.c b/target/ppc/cpu_init.c
509
+++ b/target/ppc/mem_helper.c
737
index XXXXXXX..XXXXXXX 100644
510
@@ -XXX,XX +XXX,XX @@
738
--- a/target/ppc/cpu_init.c
511
#include "exec/helper-proto.h"
739
+++ b/target/ppc/cpu_init.c
512
#include "helper_regs.h"
740
@@ -XXX,XX +XXX,XX @@ static const struct SysemuCPUOps ppc_sysemu_ops = {
513
#include "exec/cpu_ldst.h"
741
514
-#include "tcg.h"
742
static const TCGCPUOps ppc_tcg_ops = {
515
+#include "tcg/tcg.h"
743
.initialize = ppc_translate_init,
516
#include "internal.h"
744
+ .translate_code = ppc_translate_code,
517
#include "qemu/atomic128.h"
745
.restore_state_to_opc = ppc_restore_state_to_opc,
518
746
747
#ifdef CONFIG_USER_ONLY
519
diff --git a/target/ppc/translate.c b/target/ppc/translate.c
748
diff --git a/target/ppc/translate.c b/target/ppc/translate.c
520
index XXXXXXX..XXXXXXX 100644
749
index XXXXXXX..XXXXXXX 100644
521
--- a/target/ppc/translate.c
750
--- a/target/ppc/translate.c
522
+++ b/target/ppc/translate.c
751
+++ b/target/ppc/translate.c
523
@@ -XXX,XX +XXX,XX @@
752
@@ -XXX,XX +XXX,XX @@ static const TranslatorOps ppc_tr_ops = {
524
#include "internal.h"
753
.tb_stop = ppc_tr_tb_stop,
525
#include "disas/disas.h"
754
};
526
#include "exec/exec-all.h"
755
527
-#include "tcg-op.h"
756
-void gen_intermediate_code(CPUState *cs, TranslationBlock *tb, int *max_insns,
528
-#include "tcg-op-gvec.h"
757
- vaddr pc, void *host_pc)
529
+#include "tcg/tcg-op.h"
758
+void ppc_translate_code(CPUState *cs, TranslationBlock *tb,
530
+#include "tcg/tcg-op-gvec.h"
759
+ int *max_insns, vaddr pc, void *host_pc)
531
#include "qemu/host-utils.h"
760
{
532
#include "qemu/main-loop.h"
761
DisasContext ctx;
533
#include "exec/cpu_ldst.h"
762
534
diff --git a/target/riscv/cpu_helper.c b/target/riscv/cpu_helper.c
763
diff --git a/target/riscv/tcg/tcg-cpu.c b/target/riscv/tcg/tcg-cpu.c
535
index XXXXXXX..XXXXXXX 100644
764
index XXXXXXX..XXXXXXX 100644
536
--- a/target/riscv/cpu_helper.c
765
--- a/target/riscv/tcg/tcg-cpu.c
537
+++ b/target/riscv/cpu_helper.c
766
+++ b/target/riscv/tcg/tcg-cpu.c
538
@@ -XXX,XX +XXX,XX @@
767
@@ -XXX,XX +XXX,XX @@ static void riscv_restore_state_to_opc(CPUState *cs,
539
#include "qemu/main-loop.h"
768
540
#include "cpu.h"
769
static const TCGCPUOps riscv_tcg_ops = {
541
#include "exec/exec-all.h"
770
.initialize = riscv_translate_init,
542
-#include "tcg-op.h"
771
+ .translate_code = riscv_translate_code,
543
+#include "tcg/tcg-op.h"
772
.synchronize_from_tb = riscv_cpu_synchronize_from_tb,
544
#include "trace.h"
773
.restore_state_to_opc = riscv_restore_state_to_opc,
545
774
546
int riscv_cpu_mmu_index(CPURISCVState *env, bool ifetch)
547
diff --git a/target/riscv/translate.c b/target/riscv/translate.c
775
diff --git a/target/riscv/translate.c b/target/riscv/translate.c
548
index XXXXXXX..XXXXXXX 100644
776
index XXXXXXX..XXXXXXX 100644
549
--- a/target/riscv/translate.c
777
--- a/target/riscv/translate.c
550
+++ b/target/riscv/translate.c
778
+++ b/target/riscv/translate.c
551
@@ -XXX,XX +XXX,XX @@
779
@@ -XXX,XX +XXX,XX @@ static const TranslatorOps riscv_tr_ops = {
552
#include "qemu/osdep.h"
780
.tb_stop = riscv_tr_tb_stop,
553
#include "qemu/log.h"
781
};
554
#include "cpu.h"
782
555
-#include "tcg-op.h"
783
-void gen_intermediate_code(CPUState *cs, TranslationBlock *tb, int *max_insns,
556
+#include "tcg/tcg-op.h"
784
- vaddr pc, void *host_pc)
557
#include "disas/disas.h"
785
+void riscv_translate_code(CPUState *cs, TranslationBlock *tb,
558
#include "exec/cpu_ldst.h"
786
+ int *max_insns, vaddr pc, void *host_pc)
559
#include "exec/exec-all.h"
787
{
560
diff --git a/target/s390x/mem_helper.c b/target/s390x/mem_helper.c
788
DisasContext ctx;
561
index XXXXXXX..XXXXXXX 100644
789
562
--- a/target/s390x/mem_helper.c
790
diff --git a/target/rx/cpu.c b/target/rx/cpu.c
563
+++ b/target/s390x/mem_helper.c
791
index XXXXXXX..XXXXXXX 100644
564
@@ -XXX,XX +XXX,XX @@
792
--- a/target/rx/cpu.c
565
#include "exec/cpu_ldst.h"
793
+++ b/target/rx/cpu.c
566
#include "qemu/int128.h"
794
@@ -XXX,XX +XXX,XX @@ static const struct SysemuCPUOps rx_sysemu_ops = {
567
#include "qemu/atomic128.h"
795
568
-#include "tcg.h"
796
static const TCGCPUOps rx_tcg_ops = {
569
+#include "tcg/tcg.h"
797
.initialize = rx_translate_init,
570
798
+ .translate_code = rx_translate_code,
571
#if !defined(CONFIG_USER_ONLY)
799
.synchronize_from_tb = rx_cpu_synchronize_from_tb,
572
#include "hw/s390x/storage-keys.h"
800
.restore_state_to_opc = rx_restore_state_to_opc,
573
diff --git a/target/s390x/translate.c b/target/s390x/translate.c
801
.tlb_fill = rx_cpu_tlb_fill,
574
index XXXXXXX..XXXXXXX 100644
802
diff --git a/target/rx/translate.c b/target/rx/translate.c
575
--- a/target/s390x/translate.c
803
index XXXXXXX..XXXXXXX 100644
576
+++ b/target/s390x/translate.c
804
--- a/target/rx/translate.c
577
@@ -XXX,XX +XXX,XX @@
805
+++ b/target/rx/translate.c
578
#include "internal.h"
806
@@ -XXX,XX +XXX,XX @@ static const TranslatorOps rx_tr_ops = {
579
#include "disas/disas.h"
807
.tb_stop = rx_tr_tb_stop,
580
#include "exec/exec-all.h"
808
};
581
-#include "tcg-op.h"
809
582
-#include "tcg-op-gvec.h"
810
-void gen_intermediate_code(CPUState *cs, TranslationBlock *tb, int *max_insns,
583
+#include "tcg/tcg-op.h"
811
- vaddr pc, void *host_pc)
584
+#include "tcg/tcg-op-gvec.h"
812
+void rx_translate_code(CPUState *cs, TranslationBlock *tb,
585
#include "qemu/log.h"
813
+ int *max_insns, vaddr pc, void *host_pc)
586
#include "qemu/host-utils.h"
814
{
587
#include "exec/cpu_ldst.h"
815
DisasContext dc;
816
817
diff --git a/target/s390x/cpu.c b/target/s390x/cpu.c
818
index XXXXXXX..XXXXXXX 100644
819
--- a/target/s390x/cpu.c
820
+++ b/target/s390x/cpu.c
821
@@ -XXX,XX +XXX,XX @@ void cpu_get_tb_cpu_state(CPUS390XState *env, vaddr *pc,
822
823
static const TCGCPUOps s390_tcg_ops = {
824
.initialize = s390x_translate_init,
825
+ .translate_code = s390x_translate_code,
826
.restore_state_to_opc = s390x_restore_state_to_opc,
827
828
#ifdef CONFIG_USER_ONLY
829
diff --git a/target/s390x/tcg/translate.c b/target/s390x/tcg/translate.c
830
index XXXXXXX..XXXXXXX 100644
831
--- a/target/s390x/tcg/translate.c
832
+++ b/target/s390x/tcg/translate.c
833
@@ -XXX,XX +XXX,XX @@ static const TranslatorOps s390x_tr_ops = {
834
.disas_log = s390x_tr_disas_log,
835
};
836
837
-void gen_intermediate_code(CPUState *cs, TranslationBlock *tb, int *max_insns,
838
- vaddr pc, void *host_pc)
839
+void s390x_translate_code(CPUState *cs, TranslationBlock *tb,
840
+ int *max_insns, vaddr pc, void *host_pc)
841
{
842
DisasContext dc;
843
844
diff --git a/target/sh4/cpu.c b/target/sh4/cpu.c
845
index XXXXXXX..XXXXXXX 100644
846
--- a/target/sh4/cpu.c
847
+++ b/target/sh4/cpu.c
848
@@ -XXX,XX +XXX,XX @@ static const struct SysemuCPUOps sh4_sysemu_ops = {
849
850
static const TCGCPUOps superh_tcg_ops = {
851
.initialize = sh4_translate_init,
852
+ .translate_code = sh4_translate_code,
853
.synchronize_from_tb = superh_cpu_synchronize_from_tb,
854
.restore_state_to_opc = superh_restore_state_to_opc,
855
588
diff --git a/target/sh4/translate.c b/target/sh4/translate.c
856
diff --git a/target/sh4/translate.c b/target/sh4/translate.c
589
index XXXXXXX..XXXXXXX 100644
857
index XXXXXXX..XXXXXXX 100644
590
--- a/target/sh4/translate.c
858
--- a/target/sh4/translate.c
591
+++ b/target/sh4/translate.c
859
+++ b/target/sh4/translate.c
592
@@ -XXX,XX +XXX,XX @@
860
@@ -XXX,XX +XXX,XX @@ static const TranslatorOps sh4_tr_ops = {
593
#include "cpu.h"
861
.tb_stop = sh4_tr_tb_stop,
594
#include "disas/disas.h"
862
};
595
#include "exec/exec-all.h"
863
596
-#include "tcg-op.h"
864
-void gen_intermediate_code(CPUState *cs, TranslationBlock *tb, int *max_insns,
597
+#include "tcg/tcg-op.h"
865
- vaddr pc, void *host_pc)
598
#include "exec/cpu_ldst.h"
866
+void sh4_translate_code(CPUState *cs, TranslationBlock *tb,
599
#include "exec/helper-proto.h"
867
+ int *max_insns, vaddr pc, void *host_pc)
600
#include "exec/helper-gen.h"
868
{
601
diff --git a/target/sparc/ldst_helper.c b/target/sparc/ldst_helper.c
869
DisasContext ctx;
602
index XXXXXXX..XXXXXXX 100644
870
603
--- a/target/sparc/ldst_helper.c
871
diff --git a/target/sparc/cpu.c b/target/sparc/cpu.c
604
+++ b/target/sparc/ldst_helper.c
872
index XXXXXXX..XXXXXXX 100644
605
@@ -XXX,XX +XXX,XX @@
873
--- a/target/sparc/cpu.c
606
874
+++ b/target/sparc/cpu.c
607
#include "qemu/osdep.h"
875
@@ -XXX,XX +XXX,XX @@ static const struct SysemuCPUOps sparc_sysemu_ops = {
608
#include "cpu.h"
876
609
-#include "tcg.h"
877
static const TCGCPUOps sparc_tcg_ops = {
610
+#include "tcg/tcg.h"
878
.initialize = sparc_tcg_init,
611
#include "exec/helper-proto.h"
879
+ .translate_code = sparc_translate_code,
612
#include "exec/exec-all.h"
880
.synchronize_from_tb = sparc_cpu_synchronize_from_tb,
613
#include "exec/cpu_ldst.h"
881
.restore_state_to_opc = sparc_restore_state_to_opc,
882
614
diff --git a/target/sparc/translate.c b/target/sparc/translate.c
883
diff --git a/target/sparc/translate.c b/target/sparc/translate.c
615
index XXXXXXX..XXXXXXX 100644
884
index XXXXXXX..XXXXXXX 100644
616
--- a/target/sparc/translate.c
885
--- a/target/sparc/translate.c
617
+++ b/target/sparc/translate.c
886
+++ b/target/sparc/translate.c
618
@@ -XXX,XX +XXX,XX @@
887
@@ -XXX,XX +XXX,XX @@ static const TranslatorOps sparc_tr_ops = {
619
#include "disas/disas.h"
888
.tb_stop = sparc_tr_tb_stop,
620
#include "exec/helper-proto.h"
889
};
621
#include "exec/exec-all.h"
890
622
-#include "tcg-op.h"
891
-void gen_intermediate_code(CPUState *cs, TranslationBlock *tb, int *max_insns,
623
+#include "tcg/tcg-op.h"
892
- vaddr pc, void *host_pc)
624
#include "exec/cpu_ldst.h"
893
+void sparc_translate_code(CPUState *cs, TranslationBlock *tb,
625
894
+ int *max_insns, vaddr pc, void *host_pc)
626
#include "exec/helper-gen.h"
895
{
627
diff --git a/target/tilegx/translate.c b/target/tilegx/translate.c
896
DisasContext dc = {};
628
index XXXXXXX..XXXXXXX 100644
897
629
--- a/target/tilegx/translate.c
898
diff --git a/target/tricore/cpu.c b/target/tricore/cpu.c
630
+++ b/target/tilegx/translate.c
899
index XXXXXXX..XXXXXXX 100644
631
@@ -XXX,XX +XXX,XX @@
900
--- a/target/tricore/cpu.c
632
#include "exec/log.h"
901
+++ b/target/tricore/cpu.c
633
#include "disas/disas.h"
902
@@ -XXX,XX +XXX,XX @@ static const struct SysemuCPUOps tricore_sysemu_ops = {
634
#include "exec/exec-all.h"
903
635
-#include "tcg-op.h"
904
static const TCGCPUOps tricore_tcg_ops = {
636
+#include "tcg/tcg-op.h"
905
.initialize = tricore_tcg_init,
637
#include "exec/cpu_ldst.h"
906
+ .translate_code = tricore_translate_code,
638
#include "linux-user/syscall_defs.h"
907
.synchronize_from_tb = tricore_cpu_synchronize_from_tb,
639
908
.restore_state_to_opc = tricore_restore_state_to_opc,
909
.tlb_fill = tricore_cpu_tlb_fill,
640
diff --git a/target/tricore/translate.c b/target/tricore/translate.c
910
diff --git a/target/tricore/translate.c b/target/tricore/translate.c
641
index XXXXXXX..XXXXXXX 100644
911
index XXXXXXX..XXXXXXX 100644
642
--- a/target/tricore/translate.c
912
--- a/target/tricore/translate.c
643
+++ b/target/tricore/translate.c
913
+++ b/target/tricore/translate.c
644
@@ -XXX,XX +XXX,XX @@
914
@@ -XXX,XX +XXX,XX @@ static const TranslatorOps tricore_tr_ops = {
645
#include "cpu.h"
915
.tb_stop = tricore_tr_tb_stop,
646
#include "disas/disas.h"
916
};
647
#include "exec/exec-all.h"
917
648
-#include "tcg-op.h"
918
-
649
+#include "tcg/tcg-op.h"
919
-void gen_intermediate_code(CPUState *cs, TranslationBlock *tb, int *max_insns,
650
#include "exec/cpu_ldst.h"
920
- vaddr pc, void *host_pc)
651
#include "qemu/qemu-print.h"
921
+void tricore_translate_code(CPUState *cs, TranslationBlock *tb,
652
922
+ int *max_insns, vaddr pc, void *host_pc)
653
diff --git a/target/unicore32/translate.c b/target/unicore32/translate.c
923
{
654
index XXXXXXX..XXXXXXX 100644
924
DisasContext ctx;
655
--- a/target/unicore32/translate.c
925
translator_loop(cs, tb, max_insns, pc, host_pc,
656
+++ b/target/unicore32/translate.c
926
diff --git a/target/xtensa/cpu.c b/target/xtensa/cpu.c
657
@@ -XXX,XX +XXX,XX @@
927
index XXXXXXX..XXXXXXX 100644
658
#include "cpu.h"
928
--- a/target/xtensa/cpu.c
659
#include "disas/disas.h"
929
+++ b/target/xtensa/cpu.c
660
#include "exec/exec-all.h"
930
@@ -XXX,XX +XXX,XX @@ static const struct SysemuCPUOps xtensa_sysemu_ops = {
661
-#include "tcg-op.h"
931
662
+#include "tcg/tcg-op.h"
932
static const TCGCPUOps xtensa_tcg_ops = {
663
#include "qemu/log.h"
933
.initialize = xtensa_translate_init,
664
#include "exec/cpu_ldst.h"
934
+ .translate_code = xtensa_translate_code,
665
#include "exec/translator.h"
935
.debug_excp_handler = xtensa_breakpoint_handler,
936
.restore_state_to_opc = xtensa_restore_state_to_opc,
937
666
diff --git a/target/xtensa/translate.c b/target/xtensa/translate.c
938
diff --git a/target/xtensa/translate.c b/target/xtensa/translate.c
667
index XXXXXXX..XXXXXXX 100644
939
index XXXXXXX..XXXXXXX 100644
668
--- a/target/xtensa/translate.c
940
--- a/target/xtensa/translate.c
669
+++ b/target/xtensa/translate.c
941
+++ b/target/xtensa/translate.c
670
@@ -XXX,XX +XXX,XX @@
942
@@ -XXX,XX +XXX,XX @@ static const TranslatorOps xtensa_translator_ops = {
671
#include "cpu.h"
943
.tb_stop = xtensa_tr_tb_stop,
672
#include "exec/exec-all.h"
944
};
673
#include "disas/disas.h"
945
674
-#include "tcg-op.h"
946
-void gen_intermediate_code(CPUState *cpu, TranslationBlock *tb, int *max_insns,
675
+#include "tcg/tcg-op.h"
947
- vaddr pc, void *host_pc)
676
#include "qemu/log.h"
948
+void xtensa_translate_code(CPUState *cpu, TranslationBlock *tb,
677
#include "qemu/qemu-print.h"
949
+ int *max_insns, vaddr pc, void *host_pc)
678
#include "exec/cpu_ldst.h"
950
{
679
diff --git a/tcg/optimize.c b/tcg/optimize.c
951
DisasContext dc = {};
680
index XXXXXXX..XXXXXXX 100644
952
translator_loop(cpu, tb, max_insns, pc, host_pc,
681
--- a/tcg/optimize.c
682
+++ b/tcg/optimize.c
683
@@ -XXX,XX +XXX,XX @@
684
*/
685
686
#include "qemu/osdep.h"
687
-#include "tcg-op.h"
688
+#include "tcg/tcg-op.h"
689
690
#define CASE_OP_32_64(x) \
691
glue(glue(case INDEX_op_, x), _i32): \
692
diff --git a/tcg/tcg-common.c b/tcg/tcg-common.c
693
index XXXXXXX..XXXXXXX 100644
694
--- a/tcg/tcg-common.c
695
+++ b/tcg/tcg-common.c
696
@@ -XXX,XX +XXX,XX @@ uintptr_t tci_tb_ptr;
697
TCGOpDef tcg_op_defs[] = {
698
#define DEF(s, oargs, iargs, cargs, flags) \
699
{ #s, oargs, iargs, cargs, iargs + oargs + cargs, flags },
700
-#include "tcg-opc.h"
701
+#include "tcg/tcg-opc.h"
702
#undef DEF
703
};
704
const size_t tcg_op_defs_max = ARRAY_SIZE(tcg_op_defs);
705
diff --git a/tcg/tcg-op-gvec.c b/tcg/tcg-op-gvec.c
706
index XXXXXXX..XXXXXXX 100644
707
--- a/tcg/tcg-op-gvec.c
708
+++ b/tcg/tcg-op-gvec.c
709
@@ -XXX,XX +XXX,XX @@
710
*/
711
712
#include "qemu/osdep.h"
713
-#include "tcg.h"
714
-#include "tcg-op.h"
715
-#include "tcg-op-gvec.h"
716
+#include "tcg/tcg.h"
717
+#include "tcg/tcg-op.h"
718
+#include "tcg/tcg-op-gvec.h"
719
#include "qemu/main-loop.h"
720
-#include "tcg-gvec-desc.h"
721
+#include "tcg/tcg-gvec-desc.h"
722
723
#define MAX_UNROLL 4
724
725
diff --git a/tcg/tcg-op-vec.c b/tcg/tcg-op-vec.c
726
index XXXXXXX..XXXXXXX 100644
727
--- a/tcg/tcg-op-vec.c
728
+++ b/tcg/tcg-op-vec.c
729
@@ -XXX,XX +XXX,XX @@
730
731
#include "qemu/osdep.h"
732
#include "cpu.h"
733
-#include "tcg.h"
734
-#include "tcg-op.h"
735
-#include "tcg-mo.h"
736
+#include "tcg/tcg.h"
737
+#include "tcg/tcg-op.h"
738
+#include "tcg/tcg-mo.h"
739
740
/* Reduce the number of ifdefs below. This assumes that all uses of
741
TCGV_HIGH and TCGV_LOW are properly protected by a conditional that
742
diff --git a/tcg/tcg-op.c b/tcg/tcg-op.c
743
index XXXXXXX..XXXXXXX 100644
744
--- a/tcg/tcg-op.c
745
+++ b/tcg/tcg-op.c
746
@@ -XXX,XX +XXX,XX @@
747
#include "qemu/osdep.h"
748
#include "cpu.h"
749
#include "exec/exec-all.h"
750
-#include "tcg.h"
751
-#include "tcg-op.h"
752
-#include "tcg-mo.h"
753
+#include "tcg/tcg.h"
754
+#include "tcg/tcg-op.h"
755
+#include "tcg/tcg-mo.h"
756
#include "trace-tcg.h"
757
#include "trace/mem.h"
758
#include "exec/plugin-gen.h"
759
diff --git a/tcg/tcg.c b/tcg/tcg.c
760
index XXXXXXX..XXXXXXX 100644
761
--- a/tcg/tcg.c
762
+++ b/tcg/tcg.c
763
@@ -XXX,XX +XXX,XX @@
764
#include "hw/boards.h"
765
#endif
766
767
-#include "tcg-op.h"
768
+#include "tcg/tcg-op.h"
769
770
#if UINTPTR_MAX == UINT32_MAX
771
# define ELF_CLASS ELFCLASS32
772
diff --git a/tcg/tci.c b/tcg/tci.c
773
index XXXXXXX..XXXXXXX 100644
774
--- a/tcg/tci.c
775
+++ b/tcg/tci.c
776
@@ -XXX,XX +XXX,XX @@
777
#include "qemu-common.h"
778
#include "tcg/tcg.h" /* MAX_OPC_PARAM_IARGS */
779
#include "exec/cpu_ldst.h"
780
-#include "tcg-op.h"
781
+#include "tcg/tcg-op.h"
782
783
/* Marker for missing code. */
784
#define TODO() \
785
--
953
--
786
2.20.1
954
2.43.0
787
955
788
956
diff view generated by jsdifflib