1
The following changes since commit 8f860d2633baf9c2b6261f703f86e394c6bc22ca:
1
Pretty small still, but there are two patches that ought
2
to get backported to stable, so no point in delaying.
2
3
3
Merge remote-tracking branch 'remotes/armbru/tags/pull-qapi-2021-04-30' into staging (2021-04-30 16:02:00 +0100)
4
r~
5
6
The following changes since commit a5ba0a7e4e150d1350a041f0d0ef9ca6c8d7c307:
7
8
Merge tag 'pull-aspeed-20241211' of https://github.com/legoater/qemu into staging (2024-12-11 15:16:47 +0000)
4
9
5
are available in the Git repository at:
10
are available in the Git repository at:
6
11
7
https://gitlab.com/rth7680/qemu.git tags/pull-tcg-20210501
12
https://gitlab.com/rth7680/qemu.git tags/pull-tcg-20241212
8
13
9
for you to fetch changes up to af93ccacc772019298be4c3e47251cdaa60d0c21:
14
for you to fetch changes up to 7ac87b14a92234b6a89b701b4043ad6cf8bdcccf:
10
15
11
decodetree: Extend argument set syntax to allow types (2021-05-01 11:45:35 -0700)
16
target/sparc: Use memcpy() and remove memcpy32() (2024-12-12 14:28:38 -0600)
12
17
13
----------------------------------------------------------------
18
----------------------------------------------------------------
14
Include cleanups.
19
tcg: Reset free_temps before tcg_optimize
15
Decodetree enhancements for power10.
20
tcg/riscv: Fix StoreStore barrier generation
21
include/exec: Introduce fpst alias in helper-head.h.inc
22
target/sparc: Use memcpy() and remove memcpy32()
16
23
17
----------------------------------------------------------------
24
----------------------------------------------------------------
18
Luis Fernando Fujita Pires (1):
25
Philippe Mathieu-Daudé (1):
19
decodetree: Add support for 64-bit instructions
26
target/sparc: Use memcpy() and remove memcpy32()
20
27
21
Philippe Mathieu-Daudé (1):
28
Richard Henderson (2):
22
exec: Remove accel/tcg/ from include paths
29
tcg: Reset free_temps before tcg_optimize
30
include/exec: Introduce fpst alias in helper-head.h.inc
23
31
24
Richard Henderson (3):
32
Roman Artemev (1):
25
decodetree: Introduce whex and whexC helpers
33
tcg/riscv: Fix StoreStore barrier generation
26
decodetree: More use of f-strings
27
decodetree: Extend argument set syntax to allow types
28
34
29
docs/devel/decodetree.rst | 11 ++-
35
include/tcg/tcg-temp-internal.h | 6 ++++++
30
meson.build | 1 -
36
accel/tcg/plugin-gen.c | 2 +-
31
include/exec/helper-gen.h | 4 +-
37
target/sparc/win_helper.c | 26 ++++++++------------------
32
include/exec/helper-proto.h | 4 +-
38
tcg/tcg.c | 5 ++++-
33
include/exec/helper-tcg.h | 4 +-
39
include/exec/helper-head.h.inc | 3 +++
34
tests/decode/succ_argset_type1.decode | 1 +
40
tcg/riscv/tcg-target.c.inc | 2 +-
35
scripts/decodetree.py | 172 +++++++++++++++++++---------------
41
6 files changed, 23 insertions(+), 21 deletions(-)
36
7 files changed, 112 insertions(+), 85 deletions(-)
37
create mode 100644 tests/decode/succ_argset_type1.decode
38
42
diff view generated by jsdifflib
Deleted patch
1
From: Philippe Mathieu-Daudé <f4bug@amsat.org>
2
1
3
When TCG is enabled, the accel/tcg/ include path is added to the
4
project global include search list. This accel/tcg/ directory
5
contains a header named "internal.h" which, while intented to
6
be internal to accel/tcg/, is accessible by all files compiled
7
when TCG is enabled. This might lead to problem with other
8
directories using the same "internal.h" header name:
9
10
$ git ls-files | fgrep /internal.h
11
accel/tcg/internal.h
12
include/hw/ide/internal.h
13
target/hexagon/internal.h
14
target/mips/internal.h
15
target/ppc/internal.h
16
target/s390x/internal.h
17
18
As we don't need to expose accel/tcg/ internals to the rest of
19
the code base, simplify by removing it from the include search
20
list, and include the accel/tcg/ public headers relative to the
21
project root search path (which is already in the generic include
22
search path).
23
24
Signed-off-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
25
Reviewed-by: Claudio Fontana <cfontana@suse.de>
26
Message-Id: <20210413081008.3409459-1-f4bug@amsat.org>
27
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
28
---
29
meson.build | 1 -
30
include/exec/helper-gen.h | 4 ++--
31
include/exec/helper-proto.h | 4 ++--
32
include/exec/helper-tcg.h | 4 ++--
33
4 files changed, 6 insertions(+), 7 deletions(-)
34
35
diff --git a/meson.build b/meson.build
36
index XXXXXXX..XXXXXXX 100644
37
--- a/meson.build
38
+++ b/meson.build
39
@@ -XXX,XX +XXX,XX @@ if not get_option('tcg').disabled()
40
tcg_arch = 'riscv'
41
endif
42
add_project_arguments('-iquote', meson.current_source_dir() / 'tcg' / tcg_arch,
43
- '-iquote', meson.current_source_dir() / 'accel/tcg',
44
language: ['c', 'cpp', 'objc'])
45
46
accelerators += 'CONFIG_TCG'
47
diff --git a/include/exec/helper-gen.h b/include/exec/helper-gen.h
48
index XXXXXXX..XXXXXXX 100644
49
--- a/include/exec/helper-gen.h
50
+++ b/include/exec/helper-gen.h
51
@@ -XXX,XX +XXX,XX @@ static inline void glue(gen_helper_, name)(dh_retvar_decl(ret) \
52
#include "helper.h"
53
#include "trace/generated-helpers.h"
54
#include "trace/generated-helpers-wrappers.h"
55
-#include "tcg-runtime.h"
56
-#include "plugin-helpers.h"
57
+#include "accel/tcg/tcg-runtime.h"
58
+#include "accel/tcg/plugin-helpers.h"
59
60
#undef DEF_HELPER_FLAGS_0
61
#undef DEF_HELPER_FLAGS_1
62
diff --git a/include/exec/helper-proto.h b/include/exec/helper-proto.h
63
index XXXXXXX..XXXXXXX 100644
64
--- a/include/exec/helper-proto.h
65
+++ b/include/exec/helper-proto.h
66
@@ -XXX,XX +XXX,XX @@ dh_ctype(ret) HELPER(name) (dh_ctype(t1), dh_ctype(t2), dh_ctype(t3), \
67
68
#include "helper.h"
69
#include "trace/generated-helpers.h"
70
-#include "tcg-runtime.h"
71
-#include "plugin-helpers.h"
72
+#include "accel/tcg/tcg-runtime.h"
73
+#include "accel/tcg/plugin-helpers.h"
74
75
#undef IN_HELPER_PROTO
76
77
diff --git a/include/exec/helper-tcg.h b/include/exec/helper-tcg.h
78
index XXXXXXX..XXXXXXX 100644
79
--- a/include/exec/helper-tcg.h
80
+++ b/include/exec/helper-tcg.h
81
@@ -XXX,XX +XXX,XX @@
82
83
#include "helper.h"
84
#include "trace/generated-helpers.h"
85
-#include "tcg-runtime.h"
86
-#include "plugin-helpers.h"
87
+#include "accel/tcg/tcg-runtime.h"
88
+#include "accel/tcg/plugin-helpers.h"
89
90
#undef str
91
#undef DEF_HELPER_FLAGS_0
92
--
93
2.25.1
94
95
diff view generated by jsdifflib
1
Rather than force all structure members to be 'int',
1
When allocating new temps during tcg_optmize, do not re-use
2
allow the type of the member to be specified.
2
any EBB temps that were used within the TB. We do not have
3
any idea what span of the TB in which the temp was live.
3
4
4
Reviewed-by: Luis Pires <luis.pires@eldorado.org.br>
5
Introduce tcg_temp_ebb_reset_freed and use before tcg_optimize,
6
as well as replacing the equivalent in plugin_gen_inject and
7
tcg_func_start.
8
9
Cc: qemu-stable@nongnu.org
10
Fixes: fb04ab7ddd8 ("tcg/optimize: Lower TCG_COND_TST{EQ,NE} if unsupported")
11
Resolves: https://gitlab.com/qemu-project/qemu/-/issues/2711
12
Reported-by: wannacu <wannacu2049@gmail.com>
5
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
13
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
14
Reviewed-by: Pierrick Bouvier <pierrick.bouvier@linaro.org>
15
Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org>
6
---
16
---
7
docs/devel/decodetree.rst | 11 ++++---
17
include/tcg/tcg-temp-internal.h | 6 ++++++
8
tests/decode/succ_argset_type1.decode | 1 +
18
accel/tcg/plugin-gen.c | 2 +-
9
scripts/decodetree.py | 45 +++++++++++++++++----------
19
tcg/tcg.c | 5 ++++-
10
3 files changed, 36 insertions(+), 21 deletions(-)
20
3 files changed, 11 insertions(+), 2 deletions(-)
11
create mode 100644 tests/decode/succ_argset_type1.decode
12
21
13
diff --git a/docs/devel/decodetree.rst b/docs/devel/decodetree.rst
22
diff --git a/include/tcg/tcg-temp-internal.h b/include/tcg/tcg-temp-internal.h
14
index XXXXXXX..XXXXXXX 100644
23
index XXXXXXX..XXXXXXX 100644
15
--- a/docs/devel/decodetree.rst
24
--- a/include/tcg/tcg-temp-internal.h
16
+++ b/docs/devel/decodetree.rst
25
+++ b/include/tcg/tcg-temp-internal.h
17
@@ -XXX,XX +XXX,XX @@ and returns an integral value extracted from there.
26
@@ -XXX,XX +XXX,XX @@ TCGv_i64 tcg_temp_ebb_new_i64(void);
18
27
TCGv_ptr tcg_temp_ebb_new_ptr(void);
19
A field with no ``unnamed_fields`` and no ``!function`` is in error.
28
TCGv_i128 tcg_temp_ebb_new_i128(void);
20
29
21
-FIXME: the fields of the structure into which this result will be stored
30
+/* Forget all freed EBB temps, so that new allocations produce new temps. */
22
-is restricted to ``int``. Which means that we cannot expand 64-bit items.
31
+static inline void tcg_temp_ebb_reset_freed(TCGContext *s)
23
-
32
+{
24
Field examples:
33
+ memset(s->free_temps, 0, sizeof(s->free_temps));
25
34
+}
26
+---------------------------+---------------------------------------------+
27
@@ -XXX,XX +XXX,XX @@ Argument Sets
28
Syntax::
29
30
args_def := '&' identifier ( args_elt )+ ( !extern )?
31
- args_elt := identifier
32
+ args_elt := identifier (':' identifier)?
33
34
Each *args_elt* defines an argument within the argument set.
35
+If the form of the *args_elt* contains a colon, the first
36
+identifier is the argument name and the second identifier is
37
+the argument type. If the colon is missing, the argument
38
+type will be ``int``.
39
+
35
+
40
Each argument set will be rendered as a C structure "arg_$name"
36
#endif /* TCG_TEMP_FREE_H */
41
with each of the fields being one of the member arguments.
37
diff --git a/accel/tcg/plugin-gen.c b/accel/tcg/plugin-gen.c
42
43
@@ -XXX,XX +XXX,XX @@ Argument set examples::
44
45
&reg3 ra rb rc
46
&loadstore reg base offset
47
+ &longldst reg base offset:int64_t
48
49
50
Formats
51
diff --git a/tests/decode/succ_argset_type1.decode b/tests/decode/succ_argset_type1.decode
52
new file mode 100644
53
index XXXXXXX..XXXXXXX
54
--- /dev/null
55
+++ b/tests/decode/succ_argset_type1.decode
56
@@ -0,0 +1 @@
57
+&asdf b:bool c:uint64_t a
58
diff --git a/scripts/decodetree.py b/scripts/decodetree.py
59
index XXXXXXX..XXXXXXX 100644
38
index XXXXXXX..XXXXXXX 100644
60
--- a/scripts/decodetree.py
39
--- a/accel/tcg/plugin-gen.c
61
+++ b/scripts/decodetree.py
40
+++ b/accel/tcg/plugin-gen.c
62
@@ -XXX,XX +XXX,XX @@ def is_contiguous(bits):
41
@@ -XXX,XX +XXX,XX @@ static void plugin_gen_inject(struct qemu_plugin_tb *plugin_tb)
63
return -1
42
* that might be live within the existing opcode stream.
64
43
* The simplest solution is to release them all and create new.
65
44
*/
66
-def eq_fields_for_args(flds_a, flds_b):
45
- memset(tcg_ctx->free_temps, 0, sizeof(tcg_ctx->free_temps));
67
- if len(flds_a) != len(flds_b):
46
+ tcg_temp_ebb_reset_freed(tcg_ctx);
68
+def eq_fields_for_args(flds_a, arg):
47
69
+ if len(flds_a) != len(arg.fields):
48
QTAILQ_FOREACH_SAFE(op, &tcg_ctx->ops, link, next) {
70
return False
49
switch (op->opc) {
71
+ # Only allow inference on default types
50
diff --git a/tcg/tcg.c b/tcg/tcg.c
72
+ for t in arg.types:
51
index XXXXXXX..XXXXXXX 100644
73
+ if t != 'int':
52
--- a/tcg/tcg.c
74
+ return False
53
+++ b/tcg/tcg.c
75
for k, a in flds_a.items():
54
@@ -XXX,XX +XXX,XX @@ void tcg_func_start(TCGContext *s)
76
- if k not in flds_b:
55
s->nb_temps = s->nb_globals;
77
+ if k not in arg.fields:
56
78
return False
57
/* No temps have been previously allocated for size or locality. */
79
return True
58
- memset(s->free_temps, 0, sizeof(s->free_temps));
80
59
+ tcg_temp_ebb_reset_freed(s);
81
@@ -XXX,XX +XXX,XX @@ def __ne__(self, other):
60
82
61
/* No constant temps have been previously allocated. */
83
class Arguments:
62
for (int i = 0; i < TCG_TYPE_COUNT; ++i) {
84
"""Class representing the extracted fields of a format"""
63
@@ -XXX,XX +XXX,XX @@ int tcg_gen_code(TCGContext *s, TranslationBlock *tb, uint64_t pc_start)
85
- def __init__(self, nm, flds, extern):
64
}
86
+ def __init__(self, nm, flds, types, extern):
65
#endif
87
self.name = nm
66
88
self.extern = extern
67
+ /* Do not reuse any EBB that may be allocated within the TB. */
89
- self.fields = sorted(flds)
68
+ tcg_temp_ebb_reset_freed(s);
90
+ self.fields = flds
69
+
91
+ self.types = types
70
tcg_optimize(s);
92
71
93
def __str__(self):
72
reachable_code_pass(s);
94
return self.name + ' ' + str(self.fields)
95
@@ -XXX,XX +XXX,XX @@ def struct_name(self):
96
def output_def(self):
97
if not self.extern:
98
output('typedef struct {\n')
99
- for n in self.fields:
100
- output(' int ', n, ';\n')
101
+ for (n, t) in zip(self.fields, self.types):
102
+ output(f' {t} {n};\n')
103
output('} ', self.struct_name(), ';\n\n')
104
# end Arguments
105
106
@@ -XXX,XX +XXX,XX @@ def parse_arguments(lineno, name, toks):
107
global anyextern
108
109
flds = []
110
+ types = []
111
extern = False
112
- for t in toks:
113
- if re.fullmatch('!extern', t):
114
+ for n in toks:
115
+ if re.fullmatch('!extern', n):
116
extern = True
117
anyextern = True
118
continue
119
- if not re.fullmatch(re_C_ident, t):
120
- error(lineno, f'invalid argument set token "{t}"')
121
- if t in flds:
122
- error(lineno, f'duplicate argument "{t}"')
123
- flds.append(t)
124
+ if re.fullmatch(re_C_ident + ':' + re_C_ident, n):
125
+ (n, t) = n.split(':')
126
+ elif re.fullmatch(re_C_ident, n):
127
+ t = 'int'
128
+ else:
129
+ error(lineno, f'invalid argument set token "{n}"')
130
+ if n in flds:
131
+ error(lineno, f'duplicate argument "{n}"')
132
+ flds.append(n)
133
+ types.append(t)
134
135
if name in arguments:
136
error(lineno, 'duplicate argument set', name)
137
- arguments[name] = Arguments(name, flds, extern)
138
+ arguments[name] = Arguments(name, flds, types, extern)
139
# end parse_arguments
140
141
142
@@ -XXX,XX +XXX,XX @@ def infer_argument_set(flds):
143
global decode_function
144
145
for arg in arguments.values():
146
- if eq_fields_for_args(flds, arg.fields):
147
+ if eq_fields_for_args(flds, arg):
148
return arg
149
150
name = decode_function + str(len(arguments))
151
- arg = Arguments(name, flds.keys(), False)
152
+ arg = Arguments(name, flds.keys(), ['int'] * len(flds), False)
153
arguments[name] = arg
154
return arg
155
156
--
73
--
157
2.25.1
74
2.43.0
158
75
159
76
diff view generated by jsdifflib
1
From: Luis Fernando Fujita Pires <luis.pires@eldorado.org.br>
1
From: Roman Artemev <roman.artemev@syntacore.com>
2
2
3
Allow '64' to be specified for the instruction width command line params
3
On RISC-V to StoreStore barrier corresponds
4
and use the appropriate extract and deposit functions in that case.
4
`fence w, w` not `fence r, r`
5
5
6
This will be used to implement the new 64-bit Power ISA 3.1 instructions.
6
Cc: qemu-stable@nongnu.org
7
7
Fixes: efbea94c76b ("tcg/riscv: Add slowpath load and store instructions")
8
Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
8
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
9
Signed-off-by: Luis Pires <luis.pires@eldorado.org.br>
9
Signed-off-by: Denis Tomashev <denis.tomashev@syntacore.com>
10
Message-Id: <CP2PR80MB3668E123E2EFDB0ACD3A46F1DA759@CP2PR80MB3668.lamprd80.prod.outlook.com>
10
Signed-off-by: Roman Artemev <roman.artemev@syntacore.com>
11
[rth: Drop the change to the field type; use bitop_width instead of separate
11
Message-ID: <e2f2131e294a49e79959d4fa9ec02cf4@syntacore.com>
12
variables for extract/deposit; use "ull" for 64-bit constants.]
13
Reviewed-by: Luis Pires <luis.pires@eldorado.org.br>
14
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
12
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
15
---
13
---
16
scripts/decodetree.py | 21 ++++++++++++++-------
14
tcg/riscv/tcg-target.c.inc | 2 +-
17
1 file changed, 14 insertions(+), 7 deletions(-)
15
1 file changed, 1 insertion(+), 1 deletion(-)
18
16
19
diff --git a/scripts/decodetree.py b/scripts/decodetree.py
17
diff --git a/tcg/riscv/tcg-target.c.inc b/tcg/riscv/tcg-target.c.inc
20
index XXXXXXX..XXXXXXX 100644
18
index XXXXXXX..XXXXXXX 100644
21
--- a/scripts/decodetree.py
19
--- a/tcg/riscv/tcg-target.c.inc
22
+++ b/scripts/decodetree.py
20
+++ b/tcg/riscv/tcg-target.c.inc
23
@@ -XXX,XX +XXX,XX @@
21
@@ -XXX,XX +XXX,XX @@ static void tcg_out_mb(TCGContext *s, TCGArg a0)
24
import getopt
22
insn |= 0x02100000;
25
23
}
26
insnwidth = 32
24
if (a0 & TCG_MO_ST_ST) {
27
+bitop_width = 32
25
- insn |= 0x02200000;
28
insnmask = 0xffffffff
26
+ insn |= 0x01100000;
29
variablewidth = False
27
}
30
fields = {}
28
tcg_out32(s, insn);
31
@@ -XXX,XX +XXX,XX @@ def whexC(val):
29
}
32
"""Return a hex string for val padded for insnwidth,
33
and with the proper suffix for a C constant."""
34
suffix = ''
35
- if val >= 0x80000000:
36
+ if val >= 0x100000000:
37
+ suffix = 'ull'
38
+ elif val >= 0x80000000:
39
suffix = 'u'
40
return whex(val) + suffix
41
42
@@ -XXX,XX +XXX,XX @@ def __str__(self):
43
return str(self.pos) + ':' + s + str(self.len)
44
45
def str_extract(self):
46
- if self.sign:
47
- extr = 'sextract32'
48
- else:
49
- extr = 'extract32'
50
- return f'{extr}(insn, {self.pos}, {self.len})'
51
+ global bitop_width
52
+ s = 's' if self.sign else ''
53
+ return f'{s}extract{bitop_width}(insn, {self.pos}, {self.len})'
54
55
def __eq__(self, other):
56
return self.sign == other.sign and self.mask == other.mask
57
@@ -XXX,XX +XXX,XX @@ def __str__(self):
58
return str(self.subs)
59
60
def str_extract(self):
61
+ global bitop_width
62
ret = '0'
63
pos = 0
64
for f in reversed(self.subs):
65
@@ -XXX,XX +XXX,XX @@ def str_extract(self):
66
if pos == 0:
67
ret = ext
68
else:
69
- ret = f'deposit32({ret}, {pos}, {32 - pos}, {ext})'
70
+ ret = f'deposit{bitop_width}({ret}, {pos}, {bitop_width - pos}, {ext})'
71
pos += f.len
72
return ret
73
74
@@ -XXX,XX +XXX,XX @@ def main():
75
global insntype
76
global insnmask
77
global decode_function
78
+ global bitop_width
79
global variablewidth
80
global anyextern
81
82
@@ -XXX,XX +XXX,XX @@ def main():
83
if insnwidth == 16:
84
insntype = 'uint16_t'
85
insnmask = 0xffff
86
+ elif insnwidth == 64:
87
+ insntype = 'uint64_t'
88
+ insnmask = 0xffffffffffffffff
89
+ bitop_width = 64
90
elif insnwidth != 32:
91
error(0, 'cannot handle insns of width', insnwidth)
92
else:
93
--
30
--
94
2.25.1
31
2.43.0
95
96
diff view generated by jsdifflib
1
Reviewed-by: Luis Pires <luis.pires@eldorado.org.br>
1
This allows targets to declare that the helper requires a
2
float_status pointer and instead of a generic void pointer.
3
4
Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org>
2
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
5
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
3
---
6
---
4
scripts/decodetree.py | 50 ++++++++++++++++++++-----------------------
7
include/exec/helper-head.h.inc | 3 +++
5
1 file changed, 23 insertions(+), 27 deletions(-)
8
1 file changed, 3 insertions(+)
6
9
7
diff --git a/scripts/decodetree.py b/scripts/decodetree.py
10
diff --git a/include/exec/helper-head.h.inc b/include/exec/helper-head.h.inc
8
index XXXXXXX..XXXXXXX 100644
11
index XXXXXXX..XXXXXXX 100644
9
--- a/scripts/decodetree.py
12
--- a/include/exec/helper-head.h.inc
10
+++ b/scripts/decodetree.py
13
+++ b/include/exec/helper-head.h.inc
11
@@ -XXX,XX +XXX,XX @@ def error_with_file(file, lineno, *args):
14
@@ -XXX,XX +XXX,XX @@
12
15
#define dh_alias_ptr ptr
13
prefix = ''
16
#define dh_alias_cptr ptr
14
if file:
17
#define dh_alias_env ptr
15
- prefix += '{0}:'.format(file)
18
+#define dh_alias_fpst ptr
16
+ prefix += f'{file}:'
19
#define dh_alias_void void
17
if lineno:
20
#define dh_alias_noreturn noreturn
18
- prefix += '{0}:'.format(lineno)
21
#define dh_alias(t) glue(dh_alias_, t)
19
+ prefix += f'{lineno}:'
22
@@ -XXX,XX +XXX,XX @@
20
if prefix:
23
#define dh_ctype_ptr void *
21
prefix += ' '
24
#define dh_ctype_cptr const void *
22
print(prefix, end='error: ', file=sys.stderr)
25
#define dh_ctype_env CPUArchState *
23
@@ -XXX,XX +XXX,XX @@ def str_extract(self):
26
+#define dh_ctype_fpst float_status *
24
extr = 'sextract32'
27
#define dh_ctype_void void
25
else:
28
#define dh_ctype_noreturn G_NORETURN void
26
extr = 'extract32'
29
#define dh_ctype(t) dh_ctype_##t
27
- return '{0}(insn, {1}, {2})'.format(extr, self.pos, self.len)
30
@@ -XXX,XX +XXX,XX @@
28
+ return f'{extr}(insn, {self.pos}, {self.len})'
31
#define dh_typecode_f64 dh_typecode_i64
29
32
#define dh_typecode_cptr dh_typecode_ptr
30
def __eq__(self, other):
33
#define dh_typecode_env dh_typecode_ptr
31
return self.sign == other.sign and self.mask == other.mask
34
+#define dh_typecode_fpst dh_typecode_ptr
32
@@ -XXX,XX +XXX,XX @@ def str_extract(self):
35
#define dh_typecode(t) dh_typecode_##t
33
ret = '0'
36
34
pos = 0
37
#define dh_callflag_i32 0
35
for f in reversed(self.subs):
36
+ ext = f.str_extract()
37
if pos == 0:
38
- ret = f.str_extract()
39
+ ret = ext
40
else:
41
- ret = 'deposit32({0}, {1}, {2}, {3})' \
42
- .format(ret, pos, 32 - pos, f.str_extract())
43
+ ret = f'deposit32({ret}, {pos}, {32 - pos}, {ext})'
44
pos += f.len
45
return ret
46
47
@@ -XXX,XX +XXX,XX @@ def parse_field(lineno, name, toks):
48
subtoks = t.split(':')
49
sign = False
50
else:
51
- error(lineno, 'invalid field token "{0}"'.format(t))
52
+ error(lineno, f'invalid field token "{t}"')
53
po = int(subtoks[0])
54
le = int(subtoks[1])
55
if po + le > insnwidth:
56
- error(lineno, 'field {0} too large'.format(t))
57
+ error(lineno, f'field {t} too large')
58
f = Field(sign, po, le)
59
subs.append(f)
60
width += le
61
@@ -XXX,XX +XXX,XX @@ def parse_arguments(lineno, name, toks):
62
anyextern = True
63
continue
64
if not re.fullmatch(re_C_ident, t):
65
- error(lineno, 'invalid argument set token "{0}"'.format(t))
66
+ error(lineno, f'invalid argument set token "{t}"')
67
if t in flds:
68
- error(lineno, 'duplicate argument "{0}"'.format(t))
69
+ error(lineno, f'duplicate argument "{t}"')
70
flds.append(t)
71
72
if name in arguments:
73
@@ -XXX,XX +XXX,XX @@ def parse_generic(lineno, parent_pat, name, toks):
74
flen = flen[1:]
75
shift = int(flen, 10)
76
if shift + width > insnwidth:
77
- error(lineno, 'field {0} exceeds insnwidth'.format(fname))
78
+ error(lineno, f'field {fname} exceeds insnwidth')
79
f = Field(sign, insnwidth - width - shift, shift)
80
flds = add_field(lineno, flds, fname, f)
81
fixedbits <<= shift
82
fixedmask <<= shift
83
undefmask <<= shift
84
else:
85
- error(lineno, 'invalid token "{0}"'.format(t))
86
+ error(lineno, f'invalid token "{t}"')
87
width += shift
88
89
if variablewidth and width < insnwidth and width % 8 == 0:
90
@@ -XXX,XX +XXX,XX @@ def parse_generic(lineno, parent_pat, name, toks):
91
92
# We should have filled in all of the bits of the instruction.
93
elif not (is_format and width == 0) and width != insnwidth:
94
- error(lineno, 'definition has {0} bits'.format(width))
95
+ error(lineno, f'definition has {width} bits')
96
97
# Do not check for fields overlapping fields; one valid usage
98
# is to be able to duplicate fields via import.
99
@@ -XXX,XX +XXX,XX @@ def parse_generic(lineno, parent_pat, name, toks):
100
if arg:
101
for f in flds.keys():
102
if f not in arg.fields:
103
- error(lineno, 'field {0} not in argument set {1}'
104
- .format(f, arg.name))
105
+ error(lineno, f'field {f} not in argument set {arg.name}')
106
else:
107
arg = infer_argument_set(flds)
108
if name in formats:
109
@@ -XXX,XX +XXX,XX @@ def parse_generic(lineno, parent_pat, name, toks):
110
arg = fmt.base
111
for f in flds.keys():
112
if f not in arg.fields:
113
- error(lineno, 'field {0} not in argument set {1}'
114
- .format(f, arg.name))
115
+ error(lineno, f'field {f} not in argument set {arg.name}')
116
if f in fmt.fields.keys():
117
- error(lineno, 'field {0} set by format and pattern'.format(f))
118
+ error(lineno, f'field {f} set by format and pattern')
119
for f in arg.fields:
120
if f not in flds.keys() and f not in fmt.fields.keys():
121
- error(lineno, 'field {0} not initialized'.format(f))
122
+ error(lineno, f'field {f} not initialized')
123
pat = Pattern(name, lineno, fmt, fixedbits, fixedmask,
124
undefmask, fieldmask, flds, width)
125
parent_pat.pats.append(pat)
126
@@ -XXX,XX +XXX,XX @@ def parse_file(f, parent_pat):
127
elif re.fullmatch(re_pat_ident, name):
128
parse_generic(start_lineno, parent_pat, name, toks)
129
else:
130
- error(lineno, 'invalid token "{0}"'.format(name))
131
+ error(lineno, f'invalid token "{name}"')
132
toks = []
133
134
if nesting != 0:
135
@@ -XXX,XX +XXX,XX @@ def output_code(self, i, extracted, outerbits, outermask):
136
137
# If we need to load more bytes to test, do so now.
138
if extracted < self.width:
139
- output(ind, 'insn = ', decode_function,
140
- '_load_bytes(ctx, insn, {0}, {1});\n'
141
- .format(extracted // 8, self.width // 8));
142
+ output(ind, f'insn = {decode_function}_load_bytes',
143
+ f'(ctx, insn, {extracted // 8}, {self.width // 8});\n')
144
extracted = self.width
145
146
# Attempt to aid the compiler in producing compact switch statements.
147
@@ -XXX,XX +XXX,XX @@ def output_code(self, i, extracted, outerbits, outermask):
148
149
# If we need to load more bytes, do so now.
150
if extracted < self.width:
151
- output(ind, 'insn = ', decode_function,
152
- '_load_bytes(ctx, insn, {0}, {1});\n'
153
- .format(extracted // 8, self.width // 8));
154
+ output(ind, f'insn = {decode_function}_load_bytes',
155
+ f'(ctx, insn, {extracted // 8}, {self.width // 8});\n')
156
extracted = self.width
157
output(ind, 'return insn;\n')
158
# end SizeLeaf
159
@@ -XXX,XX +XXX,XX @@ def build_size_tree(pats, width, outerbits, outermask):
160
for p in pats:
161
pnames.append(p.name + ':' + p.file + ':' + str(p.lineno))
162
error_with_file(pats[0].file, pats[0].lineno,
163
- 'overlapping patterns size {0}:'.format(width), pnames)
164
+ f'overlapping patterns size {width}:', pnames)
165
166
bins = {}
167
for i in pats:
168
--
38
--
169
2.25.1
39
2.43.0
170
40
171
41
diff view generated by jsdifflib
1
Form a hex constant of the appropriate insnwidth.
1
From: Philippe Mathieu-Daudé <philmd@linaro.org>
2
Begin using f-strings on changed lines.
3
2
4
Reviewed-by: Luis Pires <luis.pires@eldorado.org.br>
3
Rather than manually copying each register, use
4
the libc memcpy(), which is well optimized nowadays.
5
6
Suggested-by: Pierrick Bouvier <pierrick.bouvier@linaro.org>
7
Reviewed-by: Pierrick Bouvier <pierrick.bouvier@linaro.org>
8
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
9
Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
10
Message-ID: <20241205205418.67613-1-philmd@linaro.org>
5
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
11
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
6
---
12
---
7
scripts/decodetree.py | 66 +++++++++++++++++++++++++------------------
13
target/sparc/win_helper.c | 26 ++++++++------------------
8
1 file changed, 38 insertions(+), 28 deletions(-)
14
1 file changed, 8 insertions(+), 18 deletions(-)
9
15
10
diff --git a/scripts/decodetree.py b/scripts/decodetree.py
16
diff --git a/target/sparc/win_helper.c b/target/sparc/win_helper.c
11
index XXXXXXX..XXXXXXX 100644
17
index XXXXXXX..XXXXXXX 100644
12
--- a/scripts/decodetree.py
18
--- a/target/sparc/win_helper.c
13
+++ b/scripts/decodetree.py
19
+++ b/target/sparc/win_helper.c
14
@@ -XXX,XX +XXX,XX @@ def str_fields(fields):
20
@@ -XXX,XX +XXX,XX @@
15
return r[1:]
21
#include "exec/helper-proto.h"
16
22
#include "trace.h"
17
23
18
+def whex(val):
24
-static inline void memcpy32(target_ulong *dst, const target_ulong *src)
19
+ """Return a hex string for val padded for insnwidth"""
25
-{
20
+ global insnwidth
26
- dst[0] = src[0];
21
+ return f'0x{val:0{insnwidth // 4}x}'
27
- dst[1] = src[1];
22
+
28
- dst[2] = src[2];
23
+
29
- dst[3] = src[3];
24
+def whexC(val):
30
- dst[4] = src[4];
25
+ """Return a hex string for val padded for insnwidth,
31
- dst[5] = src[5];
26
+ and with the proper suffix for a C constant."""
32
- dst[6] = src[6];
27
+ suffix = ''
33
- dst[7] = src[7];
28
+ if val >= 0x80000000:
34
-}
29
+ suffix = 'u'
35
-
30
+ return whex(val) + suffix
36
void cpu_set_cwp(CPUSPARCState *env, int new_cwp)
31
+
37
{
32
+
38
/* put the modified wrap registers at their proper location */
33
def str_match_bits(bits, mask):
39
if (env->cwp == env->nwindows - 1) {
34
"""Return a string pretty-printing BITS/MASK"""
40
- memcpy32(env->regbase, env->regbase + env->nwindows * 16);
35
global insnwidth
41
+ memcpy(env->regbase, env->regbase + env->nwindows * 16,
36
@@ -XXX,XX +XXX,XX @@ def output_code(self, i, extracted, outerbits, outermask):
42
+ sizeof(env->gregs));
37
if outermask != p.fixedmask:
43
}
38
innermask = p.fixedmask & ~outermask
44
env->cwp = new_cwp;
39
innerbits = p.fixedbits & ~outermask
45
40
- output(ind, 'if ((insn & ',
46
/* put the wrap registers at their temporary location */
41
- '0x{0:08x}) == 0x{1:08x}'.format(innermask, innerbits),
47
if (new_cwp == env->nwindows - 1) {
42
- ') {\n')
48
- memcpy32(env->regbase + env->nwindows * 16, env->regbase);
43
- output(ind, ' /* ',
49
+ memcpy(env->regbase + env->nwindows * 16, env->regbase,
44
- str_match_bits(p.fixedbits, p.fixedmask), ' */\n')
50
+ sizeof(env->gregs));
45
+ output(ind, f'if ((insn & {whexC(innermask)}) == {whexC(innerbits)}) {{\n')
51
}
46
+ output(ind, f' /* {str_match_bits(p.fixedbits, p.fixedmask)} */\n')
52
env->regwptr = env->regbase + (new_cwp * 16);
47
p.output_code(i + 4, extracted, p.fixedbits, p.fixedmask)
53
}
48
output(ind, '}\n')
54
@@ -XXX,XX +XXX,XX @@ void cpu_gl_switch_gregs(CPUSPARCState *env, uint32_t new_gl)
49
else:
55
dst = get_gl_gregset(env, env->gl);
50
@@ -XXX,XX +XXX,XX @@ def __init__(self, fm, tm):
56
51
57
if (src != dst) {
52
def str1(self, i):
58
- memcpy32(dst, env->gregs);
53
ind = str_indent(i)
59
- memcpy32(env->gregs, src);
54
- r = '{0}{1:08x}'.format(ind, self.fixedmask)
60
+ memcpy(dst, env->gregs, sizeof(env->gregs));
55
+ r = ind + whex(self.fixedmask)
61
+ memcpy(env->gregs, src, sizeof(env->gregs));
56
if self.format:
62
}
57
r += ' ' + self.format.name
63
}
58
r += ' [\n'
64
59
for (b, s) in self.subs:
65
@@ -XXX,XX +XXX,XX @@ void cpu_change_pstate(CPUSPARCState *env, uint32_t new_pstate)
60
- r += '{0} {1:08x}:\n'.format(ind, b)
66
/* Switch global register bank */
61
+ r += ind + f' {whex(b)}:\n'
67
src = get_gregset(env, new_pstate_regs);
62
r += s.str1(i + 4) + '\n'
68
dst = get_gregset(env, pstate_regs);
63
r += ind + ']'
69
- memcpy32(dst, env->gregs);
64
return r
70
- memcpy32(env->gregs, src);
65
@@ -XXX,XX +XXX,XX @@ def output_code(self, i, extracted, outerbits, outermask):
71
+ memcpy(dst, env->gregs, sizeof(env->gregs));
66
if sh > 0:
72
+ memcpy(env->gregs, src, sizeof(env->gregs));
67
# Propagate SH down into the local functions.
73
} else {
68
def str_switch(b, sh=sh):
74
trace_win_helper_no_switch_pstate(new_pstate_regs);
69
- return '(insn >> {0}) & 0x{1:x}'.format(sh, b >> sh)
75
}
70
+ return f'(insn >> {sh}) & {b >> sh:#x}'
71
72
def str_case(b, sh=sh):
73
- return '0x{0:x}'.format(b >> sh)
74
+ return hex(b >> sh)
75
else:
76
def str_switch(b):
77
- return 'insn & 0x{0:08x}'.format(b)
78
+ return f'insn & {whexC(b)}'
79
80
def str_case(b):
81
- return '0x{0:08x}'.format(b)
82
+ return whexC(b)
83
84
output(ind, 'switch (', str_switch(self.thismask), ') {\n')
85
for b, s in sorted(self.subs):
86
@@ -XXX,XX +XXX,XX @@ def parse_generic(lineno, parent_pat, name, toks):
87
88
# Validate the masks that we have assembled.
89
if fieldmask & fixedmask:
90
- error(lineno, 'fieldmask overlaps fixedmask (0x{0:08x} & 0x{1:08x})'
91
- .format(fieldmask, fixedmask))
92
+ error(lineno, 'fieldmask overlaps fixedmask ',
93
+ f'({whex(fieldmask)} & {whex(fixedmask)})')
94
if fieldmask & undefmask:
95
- error(lineno, 'fieldmask overlaps undefmask (0x{0:08x} & 0x{1:08x})'
96
- .format(fieldmask, undefmask))
97
+ error(lineno, 'fieldmask overlaps undefmask ',
98
+ f'({whex(fieldmask)} & {whex(undefmask)})')
99
if fixedmask & undefmask:
100
- error(lineno, 'fixedmask overlaps undefmask (0x{0:08x} & 0x{1:08x})'
101
- .format(fixedmask, undefmask))
102
+ error(lineno, 'fixedmask overlaps undefmask ',
103
+ f'({whex(fixedmask)} & {whex(undefmask)})')
104
if not is_format:
105
allbits = fieldmask | fixedmask | undefmask
106
if allbits != insnmask:
107
- error(lineno, 'bits left unspecified (0x{0:08x})'
108
- .format(allbits ^ insnmask))
109
+ error(lineno, 'bits left unspecified ',
110
+ f'({whex(allbits ^ insnmask)})')
111
# end parse_general
112
113
114
@@ -XXX,XX +XXX,XX @@ def __init__(self, m, w):
115
116
def str1(self, i):
117
ind = str_indent(i)
118
- r = '{0}{1:08x}'.format(ind, self.mask)
119
- r += ' [\n'
120
+ r = ind + whex(self.mask) + ' [\n'
121
for (b, s) in self.subs:
122
- r += '{0} {1:08x}:\n'.format(ind, b)
123
+ r += ind + f' {whex(b)}:\n'
124
r += s.str1(i + 4) + '\n'
125
r += ind + ']'
126
return r
127
@@ -XXX,XX +XXX,XX @@ def output_code(self, i, extracted, outerbits, outermask):
128
if sh > 0:
129
# Propagate SH down into the local functions.
130
def str_switch(b, sh=sh):
131
- return '(insn >> {0}) & 0x{1:x}'.format(sh, b >> sh)
132
+ return f'(insn >> {sh}) & {b >> sh:#x}'
133
134
def str_case(b, sh=sh):
135
- return '0x{0:x}'.format(b >> sh)
136
+ return hex(b >> sh)
137
else:
138
def str_switch(b):
139
- return 'insn & 0x{0:08x}'.format(b)
140
+ return f'insn & {whexC(b)}'
141
142
def str_case(b):
143
- return '0x{0:08x}'.format(b)
144
+ return whexC(b)
145
146
output(ind, 'switch (', str_switch(self.mask), ') {\n')
147
for b, s in sorted(self.subs):
148
@@ -XXX,XX +XXX,XX @@ def __init__(self, m, w):
149
self.width = w
150
151
def str1(self, i):
152
- ind = str_indent(i)
153
- return '{0}{1:08x}'.format(ind, self.mask)
154
+ return str_indent(i) + whex(self.mask)
155
156
def __str__(self):
157
return self.str1(0)
158
--
76
--
159
2.25.1
77
2.43.0
160
78
161
79
diff view generated by jsdifflib