Richard Henderson
3cdfd68e4e
tcg/optimize: Fix sign_mask for logical right-shift
...
The 'sign' computation is attempting to locate the sign bit that has
been repeated, so that we can test if that bit is known zero. That
computation can be zero if there are no known sign repetitions.
Cc: qemu-stable@nongnu.org
Fixes: 93a967fbb5 ("tcg/optimize: Propagate sign info for shifting")
Resolves: https://gitlab.com/qemu-project/qemu/-/issues/2248
Signed-off-by: Richard Henderson <richard.henderson@linaro.org >
Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org >
(cherry picked from commit 2911e9b95f )
Signed-off-by: Michael Tokarev <mjt@tls.msk.ru >
2024-03-31 22:14:59 +03:00
Richard Henderson
151d593c7d
tcg/aarch64: Apple does not align __int128_t in even registers
...
From https://developer.apple.com/documentation/xcode/writing-arm64-code-for-apple-platforms
When passing an argument with 16-byte alignment in integer registers,
Apple platforms allow the argument to start in an odd-numbered xN
register. The standard ABI requires it to begin in an even-numbered
xN register.
Cc: qemu-stable@nongnu.org
Fixes: 5427a9a760 ("tcg: Add TCG_TARGET_CALL_{RET,ARG}_I128")
Resolves: https://gitlab.com/qemu-project/qemu/-/issues/2169
Signed-off-by: Richard Henderson <richard.henderson@linaro.org >
Message-Id: <9fc0c2c7-dd57-459e-aecb-528edb74b4a7@linaro.org >
Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org >
(cherry picked from commit 7f89fdf8eb )
Signed-off-by: Michael Tokarev <mjt@tls.msk.ru >
2024-03-05 17:38:26 +03:00
Richard Henderson
181e548715
tcg/arm: Fix goto_tb for large translation blocks
...
Correct arithmetic for separating high and low
on a large negative number.
Cc: qemu-stable@nongnu.org
Fixes: 79ffece444 ("tcg/arm: Implement direct branch for goto_tb")
Resolves: https://gitlab.com/qemu-project/qemu/-/issues/1714
Signed-off-by: Richard Henderson <richard.henderson@linaro.org >
Reviewed-by: Michael Tokarev <mjt@tls.msk.ru >
(cherry picked from commit e41f1825b4 )
Signed-off-by: Michael Tokarev <mjt@tls.msk.ru >
2024-02-14 21:17:26 +03:00
Richard Henderson
8b7750c66f
tcg/loongarch64: Set vector registers call clobbered
...
Because there are more call clobbered registers than
call saved registers, we begin with all registers as
call clobbered and then reset those that are saved.
This was missed when we introduced the LSX support.
Cc: qemu-stable@nongnu.org
Fixes: 16288ded94 ("tcg/loongarch64: Lower basic tcg vec ops to LSX")
Resolves: https://gitlab.com/qemu-project/qemu/-/issues/2136
Signed-off-by: Richard Henderson <richard.henderson@linaro.org >
Reviewed-by: Song Gao <gaosong@loongson.cn >
Message-Id: <20240201233414.500588-1-richard.henderson@linaro.org >
(cherry picked from commit 45bf0e7aa6 )
Signed-off-by: Michael Tokarev <mjt@tls.msk.ru >
2024-02-09 10:44:49 +03:00
Joseph Burt
6f6492ab07
tcg/arm: Fix SIGILL in tcg_out_qemu_st_direct
...
When tcg_out_qemu_st_{index,direct} were merged, the direct case for
MO_64 was omitted, causing qemu_st_i64 to be encoded as 0xffffffff due
to underflow when adding h.base and h.index.
Fixes: 1df6d611bd ("tcg/arm: Introduce HostAddress")
Signed-off-by: Joseph Burt <caseorum@gmail.com >
Message-Id: <20240121211439.100829-1-caseorum@gmail.com >
Reviewed-by: Richard Henderson <richard.henderson@linaro.org >
Signed-off-by: Richard Henderson <richard.henderson@linaro.org >
(cherry picked from commit 9f6523e8e4 )
Signed-off-by: Michael Tokarev <mjt@tls.msk.ru >
2024-01-25 19:13:41 +03:00
Richard Henderson
005d7236db
tcg/s390x: Fix encoding of VRIc, VRSa, VRSc insns
...
While the format names the second vector register 'v3',
it is still in the second position (bits 12-15) and
the argument to RXB must match.
Example error:
- e7 00 00 10 2a 33 verllf %v16,%v0,16
+ e7 00 00 10 2c 33 verllf %v16,%v16,16
Cc: qemu-stable@nongnu.org
Reported-by: Michael Tokarev <mjt@tls.msk.ru >
Fixes: 22cb37b417 ("tcg/s390x: Implement vector shift operations")
Fixes: 79cada8693 ("tcg/s390x: Implement tcg_out_dup*_vec")
Resolves: https://gitlab.com/qemu-project/qemu/-/issues/2054
Reviewed-by: Thomas Huth <thuth@redhat.com >
Tested-by: Michael Tokarev <mjt@tls.msk.ru >
Message-Id: <20240117213646.159697-2-richard.henderson@linaro.org >
Signed-off-by: Richard Henderson <richard.henderson@linaro.org >
(cherry picked from commit c1ddc18f37 )
Signed-off-by: Michael Tokarev <mjt@tls.msk.ru >
2024-01-25 19:13:41 +03:00
Richard Henderson
b881910859
tcg/ppc: Use new registers for LQ destination
...
LQ has a constraint that RTp != RA, else SIGILL.
Therefore, force the destination of INDEX_op_qemu_*_ld128 to be a
new register pair, so that it cannot overlap the input address.
This requires new support in process_op_defs and tcg_reg_alloc_op.
Cc: qemu-stable@nongnu.org
Fixes: 526cd4ec01 ("tcg/ppc: Support 128-bit load/store")
Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org >
Message-Id: <20240102013456.131846-1-richard.henderson@linaro.org >
Signed-off-by: Richard Henderson <richard.henderson@linaro.org >
(cherry picked from commit ca5bed07d0 )
Signed-off-by: Michael Tokarev <mjt@tls.msk.ru >
2024-01-11 21:02:11 +03:00
Richard Henderson
cbb145567c
tcg: Reduce serial context atomicity earlier
...
Reduce atomicity while emitting opcodes, instead of later
during code generation. This ensures that any helper called
also sees the reduced atomicity requirement.
Resolves: https://gitlab.com/qemu-project/qemu/-/issues/2034
Signed-off-by: Richard Henderson <richard.henderson@linaro.org >
Tested-by: Alex Bennée <alex.bennee@linaro.org >
Message-Id: <20231212193542.149117-1-richard.henderson@linaro.org >
2023-12-12 13:35:19 -08:00
Song Gao
85d57a37be
tcg/loongarch64: Fix tcg_out_mov() Aborted
...
On LoongArch host, we got an Aborted from tcg_out_mov().
qemu-x86_64 configure with '--enable-debug'.
> (gdb) b /home1/gaosong/code/qemu/tcg/loongarch64/tcg-target.c.inc:312
> Breakpoint 1 at 0x2576f0: file /home1/gaosong/code/qemu/tcg/loongarch64/tcg-target.c.inc, line 312.
> (gdb) run hello
[...]
> Thread 1 "qemu-x86_64" hit Breakpoint 1, tcg_out_mov (s=0xaaaae91760 <tcg_init_ctx>, type=TCG_TYPE_V128, ret=TCG_REG_V2,
> arg=TCG_REG_V0) at /home1/gaosong/code/qemu/tcg/loongarch64/tcg-target.c.inc:312
> 312 g_assert_not_reached();
> (gdb) bt
> #0 tcg_out_mov (s=0xaaaae91760 <tcg_init_ctx>, type=TCG_TYPE_V128, ret=TCG_REG_V2, arg=TCG_REG_V0)
> at /home1/gaosong/code/qemu/tcg/loongarch64/tcg-target.c.inc:312
> #1 0x000000aaaad0fee0 in tcg_reg_alloc_mov (s=0xaaaae91760 <tcg_init_ctx>, op=0xaaaaf67c20) at ../tcg/tcg.c:4632
> #2 0x000000aaaad142f4 in tcg_gen_code (s=0xaaaae91760 <tcg_init_ctx>, tb=0xffe8030340 <code_gen_buffer+197328>,
> pc_start=4346094) at ../tcg/tcg.c:6135
[...]
> (gdb) c
> Continuing.
> **
> ERROR:/home1/gaosong/code/qemu/tcg/loongarch64/tcg-target.c.inc:312:tcg_out_mov: code should not be reached
> Bail out! ERROR:/home1/gaosong/code/qemu/tcg/loongarch64/tcg-target.c.inc:312:tcg_out_mov: code should not be reached
>
> Thread 1 "qemu-x86_64" received signal SIGABRT, Aborted.
> 0x000000fff7b1c390 in raise () from /lib64/libc.so.6
> (gdb) q
Fixes: 16288ded94 ("tcg/loongarch64: Lower basic tcg vec ops to LSX")
Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org >
Reviewed-by: Richard Henderson <richard.henderson@linaro.org >
Signed-off-by: Song Gao <gaosong@loongson.cn >
Message-Id: <20231120065916.374045-1-gaosong@loongson.cn >
2023-11-21 10:32:42 +08:00
Richard Henderson
d36ce28be4
tcg/sparc64: Implement tcg_out_extrl_i64_i32
...
Build fix for missing symbol.
Cc: qemu-stable@nongnu.org
Fixes: dad2f2f5af ("tcg/sparc64: Disable TCG_TARGET_HAS_extr_i64_i32")
Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org >
Signed-off-by: Richard Henderson <richard.henderson@linaro.org >
2023-11-06 10:48:46 -08:00
Richard Henderson
f245757701
tcg/optimize: Canonicalize sub2 with constants to add2
...
Signed-off-by: Richard Henderson <richard.henderson@linaro.org >
Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org >
Message-Id: <20231026013945.1152174-4-richard.henderson@linaro.org >
2023-11-06 10:43:04 -08:00
Richard Henderson
6334a968ee
tcg/optimize: Canonicalize subi to addi during optimization
...
Signed-off-by: Richard Henderson <richard.henderson@linaro.org >
Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org >
Message-Id: <20231026013945.1152174-3-richard.henderson@linaro.org >
2023-11-06 10:43:04 -08:00
Richard Henderson
1551004eeb
tcg: Canonicalize subi to addi during opcode generation
...
Suggested-by: Paolo Bonzini <pbonzini@redhat.com >
Signed-off-by: Richard Henderson <richard.henderson@linaro.org >
Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org >
Message-Id: <20231026013945.1152174-2-richard.henderson@linaro.org >
2023-11-06 10:43:04 -08:00
Richard Henderson
26aac97c84
tcg/optimize: Split out arg_new_constant
...
Fixes a bug wherein raw uses of tcg_constant_internal
do not have their TempOptInfo initialized.
Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org >
Signed-off-by: Richard Henderson <richard.henderson@linaro.org >
2023-11-06 10:36:56 -08:00
Richard Henderson
3eaadaeb4e
tcg: Eliminate duplicate env store operations
...
Notice when a constant is stored to the same location twice.
Reviewed-by: Song Gao <gaosong@loongson.cn >
Signed-off-by: Richard Henderson <richard.henderson@linaro.org >
2023-11-06 08:27:21 -08:00
Richard Henderson
ab84dc398b
tcg/optimize: Optimize env memory operations
...
Propagate stores to loads, loads to loads.
Reviewed-by: Song Gao <gaosong@loongson.cn >
Signed-off-by: Richard Henderson <richard.henderson@linaro.org >
2023-11-06 08:27:21 -08:00
Richard Henderson
9f75e52828
tcg/optimize: Split out cmp_better_copy
...
Compare two temps for "better", split out from finding
the best from a whole list. Use TCGKind, which already
gives the proper priority.
Signed-off-by: Richard Henderson <richard.henderson@linaro.org >
2023-11-06 08:27:21 -08:00
Richard Henderson
986cac1d2a
tcg/optimize: Pipe OptContext into reset_ts
...
Will be needed in the next patch.
Reviewed-by: Song Gao <gaosong@loongson.cn >
Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org >
Signed-off-by: Richard Henderson <richard.henderson@linaro.org >
2023-11-06 08:27:21 -08:00
Richard Henderson
9628d008bd
tcg: Don't free vector results
...
Avoid reusing vector temporaries so that we may re-use them
when propagating stores to loads.
Reviewed-by: Song Gao <gaosong@loongson.cn >
Signed-off-by: Richard Henderson <richard.henderson@linaro.org >
2023-11-06 08:27:21 -08:00
Richard Henderson
b701f195d3
tcg: Remove TCG_TARGET_HAS_neg_{i32,i64}
...
The movcond opcode is now mandatory for backends to implement.
Signed-off-by: Richard Henderson <richard.henderson@linaro.org >
Message-Id: <20231026041404.1229328-7-richard.henderson@linaro.org >
2023-11-06 08:27:21 -08:00
Richard Henderson
0fbee2b764
tcg/loongarch64: Implement neg opcodes
...
Signed-off-by: Richard Henderson <richard.henderson@linaro.org >
Message-Id: <20231026041404.1229328-6-richard.henderson@linaro.org >
2023-11-06 08:27:21 -08:00
Richard Henderson
e0448a8b71
tcg/mips: Implement neg opcodes
...
Signed-off-by: Richard Henderson <richard.henderson@linaro.org >
Message-Id: <20231026041404.1229328-5-richard.henderson@linaro.org >
2023-11-06 08:27:21 -08:00
Richard Henderson
3871be753f
tcg: Remove TCG_TARGET_HAS_movcond_{i32,i64}
...
The movcond opcode is now mandatory for backends to implement.
Signed-off-by: Richard Henderson <richard.henderson@linaro.org >
Message-Id: <20231026041404.1229328-4-richard.henderson@linaro.org >
2023-11-06 08:27:21 -08:00
Richard Henderson
2cff741da8
tcg/mips: Always implement movcond
...
Expand as branch over move if not supported in the ISA.
Signed-off-by: Richard Henderson <richard.henderson@linaro.org >
Message-Id: <20231026041404.1229328-3-richard.henderson@linaro.org >
2023-11-06 08:27:21 -08:00
Richard Henderson
42221a64da
tcg/mips: Split out tcg_out_setcond_int
...
Return the temp and a set of flags, to be used as a
primitive for setcond, brcond, movcond.
Signed-off-by: Richard Henderson <richard.henderson@linaro.org >
Message-Id: <20231026041404.1229328-2-richard.henderson@linaro.org >
2023-11-06 08:27:21 -08:00
Richard Henderson
58b797130c
tcg: Move tcg_temp_free_* out of line
...
Signed-off-by: Richard Henderson <richard.henderson@linaro.org >
Message-Id: <20231029210848.78234-12-richard.henderson@linaro.org >
2023-11-06 08:27:21 -08:00
Richard Henderson
4643f3e07e
tcg: Move tcg_temp_new_*, tcg_global_mem_new_* out of line
...
Signed-off-by: Richard Henderson <richard.henderson@linaro.org >
Message-Id: <20231029210848.78234-11-richard.henderson@linaro.org >
2023-11-06 08:27:21 -08:00
Richard Henderson
16edaee720
tcg: Move tcg_constant_* out of line
...
Signed-off-by: Richard Henderson <richard.henderson@linaro.org >
Message-Id: <20231029210848.78234-10-richard.henderson@linaro.org >
2023-11-06 08:27:21 -08:00
Richard Henderson
17b9fadb1d
tcg: Unexport tcg_gen_op*_{i32,i64}
...
These functions are no longer used outside tcg-op.c.
There are several that are completely unused, so remove them.
Signed-off-by: Richard Henderson <richard.henderson@linaro.org >
Message-Id: <20231029210848.78234-9-richard.henderson@linaro.org >
2023-11-06 08:27:21 -08:00
Richard Henderson
1d67bf545f
tcg: Move tcg_gen_opN declarations to tcg-internal.h
...
These are used within tcg-op.c and tcg-op-ldst.c.
There are no uses outside tcg/.
Signed-off-by: Richard Henderson <richard.henderson@linaro.org >
Message-Id: <20231029210848.78234-8-richard.henderson@linaro.org >
2023-11-06 08:27:21 -08:00
Richard Henderson
27c758fd22
tcg: Move vec_gen_* declarations to tcg-internal.h
...
These are used within tcg-op-vec.c and tcg/host/tcg-target.c.inc.
There are no uses outside tcg/.
Signed-off-by: Richard Henderson <richard.henderson@linaro.org >
Message-Id: <20231029210848.78234-7-richard.henderson@linaro.org >
2023-11-06 08:27:21 -08:00
Richard Henderson
e0de2f5580
tcg: Move 64-bit expanders out of line
...
This one is more complicated, combining 32-bit and 64-bit
expansion with C if instead of preprocessor #if.
Signed-off-by: Richard Henderson <richard.henderson@linaro.org >
Message-Id: <20231029210848.78234-6-richard.henderson@linaro.org >
2023-11-06 08:27:21 -08:00
Richard Henderson
09607d35f5
tcg: Move 32-bit expanders out of line
...
Signed-off-by: Richard Henderson <richard.henderson@linaro.org >
Message-Id: <20231029210848.78234-5-richard.henderson@linaro.org >
2023-11-06 08:27:21 -08:00
Richard Henderson
01bbb6e3eb
tcg: Move generic expanders out of line
...
Signed-off-by: Richard Henderson <richard.henderson@linaro.org >
Message-Id: <20231029210848.78234-4-richard.henderson@linaro.org >
2023-11-06 08:27:21 -08:00
Richard Henderson
6fc75d50a5
tcg: Move tcg_gen_op* out of line
...
In addition to moving out of line, with CONFIG_DEBUG_TCG
mark them all noinline.
Signed-off-by: Richard Henderson <richard.henderson@linaro.org >
Message-Id: <20231029210848.78234-3-richard.henderson@linaro.org >
2023-11-06 08:27:21 -08:00
Richard Henderson
ecfa1877f7
tcg: Mark tcg_gen_op* as noinline
...
Encourage the compiler to tail-call rather than inline
across the dozens of opcode expanders.
Signed-off-by: Richard Henderson <richard.henderson@linaro.org >
Message-Id: <20231029210848.78234-2-richard.henderson@linaro.org >
2023-11-06 08:27:21 -08:00
Richard Henderson
f2a553481e
tcg/loongarch64: Use cpuinfo.h
...
Signed-off-by: Richard Henderson <richard.henderson@linaro.org >
Reviewed-by: Jiajie Chen <c@jia.je >
Message-Id: <20230916220151.526140-5-richard.henderson@linaro.org >
2023-11-06 08:27:21 -08:00
Richard Henderson
2b2ae0a42e
tcg/loongarch64: Use C_N2_I1 for INDEX_op_qemu_ld_a*_i128
...
Use new registers for the output, so that we never overlap
the input address, which could happen for user-only.
This avoids a "tmp = addr + 0" in that case.
Signed-off-by: Richard Henderson <richard.henderson@linaro.org >
Reviewed-by: Jiajie Chen <c@jia.je >
Message-Id: <20230916220151.526140-3-richard.henderson@linaro.org >
2023-11-06 08:27:21 -08:00
Richard Henderson
fa645b48d3
tcg: Add C_N2_I1
...
Constraint with two outputs, both in new registers.
Signed-off-by: Richard Henderson <richard.henderson@linaro.org >
Reviewed-by: Jiajie Chen <c@jia.je >
Message-Id: <20230916220151.526140-2-richard.henderson@linaro.org >
2023-11-06 08:27:21 -08:00
Richard Henderson
24a4d59aa7
accel/tcg: Move HMP info jit and info opcount code
...
Move all of it into accel/tcg/monitor.c. This puts everything
about tcg that is only used by the monitor in the same place.
Tested-by: Philippe Mathieu-Daudé <philmd@linaro.org >
Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org >
Reviewed-by: Alex Bennée <alex.bennee@linaro.org >
Signed-off-by: Richard Henderson <richard.henderson@linaro.org >
2023-11-06 08:27:21 -08:00
Richard Henderson
f1c29532e7
tcg: Export tcg_gen_ext_{i32,i64,tl}
...
The two concrete type functions already existed, merely needing
a bit of hardening to invalid inputs.
Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org >
Signed-off-by: Richard Henderson <richard.henderson@linaro.org >
2023-10-22 16:32:28 -07:00
Paolo Bonzini
93c86ecd77
tcg: add negsetcondi
...
This can be useful to write a shift bit extraction that does not
depend on TARGET_LONG_BITS.
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com >
Message-Id: <20231019104648.389942-15-pbonzini@redhat.com >
Signed-off-by: Richard Henderson <richard.henderson@linaro.org >
2023-10-22 16:32:28 -07:00
Richard Henderson
a01d9792a7
tcg: Add tcg_gen_{ld,st}_i128
...
Do not require the translators to jump through concat and
extract of i64 in order to move values to and from env.
Tested-by: Song Gao <gaosong@loongson.cn >
Reviewed-by: Song Gao <gaosong@loongson.cn >
Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org >
Signed-off-by: Richard Henderson <richard.henderson@linaro.org >
2023-10-22 16:32:28 -07:00
Richard Henderson
d97f8f3941
tcg: Optimize past conditional branches
...
We already register allocate through extended basic blocks,
optimize through extended basic blocks as well.
Signed-off-by: Richard Henderson <richard.henderson@linaro.org >
2023-10-22 16:32:28 -07:00
Richard Henderson
bfefdbea9e
tcg: Use constant zero when expanding with divu2
...
Signed-off-by: Richard Henderson <richard.henderson@linaro.org >
2023-10-22 16:32:28 -07:00
Richard Henderson
2e486b5901
tcg/s390x: Use tcg_use_softmmu
...
Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org >
Signed-off-by: Richard Henderson <richard.henderson@linaro.org >
2023-10-22 16:32:28 -07:00
Richard Henderson
4944d35910
tcg/riscv: Use tcg_use_softmmu
...
Signed-off-by: Richard Henderson <richard.henderson@linaro.org >
2023-10-22 16:32:28 -07:00
Richard Henderson
cf0ed30eb1
tcg/riscv: Do not reserve TCG_GUEST_BASE_REG for guest_base zero
...
Fixes: 92c041c59b ("tcg/riscv: Add the prologue generation and register the JIT")
Signed-off-by: Richard Henderson <richard.henderson@linaro.org >
2023-10-22 16:32:28 -07:00
Richard Henderson
5b5bd4a9b1
tcg/ppc: Use tcg_use_softmmu
...
Fix TCG_GUEST_BASE_REG to use 'TCG_REG_R30' instead of '30'.
Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org >
Signed-off-by: Richard Henderson <richard.henderson@linaro.org >
2023-10-22 16:32:28 -07:00
Richard Henderson
e3a650cd9d
tcg/mips: Use tcg_use_softmmu
...
Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org >
Signed-off-by: Richard Henderson <richard.henderson@linaro.org >
2023-10-22 16:32:28 -07:00