[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PATCH v3 09/57] tcg/i386: Introduce tcg_out_testi
From: |
Richard Henderson |
Subject: |
[PATCH v3 09/57] tcg/i386: Introduce tcg_out_testi |
Date: |
Mon, 24 Apr 2023 06:40:17 +0100 |
Split out a helper for choosing testb vs testl.
Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org>
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
---
tcg/i386/tcg-target.c.inc | 30 ++++++++++++++++++------------
1 file changed, 18 insertions(+), 12 deletions(-)
diff --git a/tcg/i386/tcg-target.c.inc b/tcg/i386/tcg-target.c.inc
index 7a02f79f1b..19625a7c75 100644
--- a/tcg/i386/tcg-target.c.inc
+++ b/tcg/i386/tcg-target.c.inc
@@ -1753,6 +1753,23 @@ static void tcg_out_nopn(TCGContext *s, int n)
tcg_out8(s, 0x90);
}
+/* Test register R vs immediate bits I, setting Z flag for EQ/NE. */
+static void __attribute__((unused))
+tcg_out_testi(TCGContext *s, TCGReg r, uint32_t i)
+{
+ /*
+ * This is used for testing alignment, so we can usually use testb.
+ * For i686, we have to use testl for %esi/%edi.
+ */
+ if (i <= 0xff && (TCG_TARGET_REG_BITS == 64 || r < 4)) {
+ tcg_out_modrm(s, OPC_GRP3_Eb | P_REXB_RM, EXT3_TESTi, r);
+ tcg_out8(s, i);
+ } else {
+ tcg_out_modrm(s, OPC_GRP3_Ev, EXT3_TESTi, r);
+ tcg_out32(s, i);
+ }
+}
+
typedef struct {
TCGReg base;
int index;
@@ -2053,18 +2070,7 @@ static void tcg_out_test_alignment(TCGContext *s, bool
is_ld, TCGReg addrlo,
unsigned a_mask = (1 << a_bits) - 1;
TCGLabelQemuLdst *label;
- /*
- * We are expecting a_bits to max out at 7, so we can usually use testb.
- * For i686, we have to use testl for %esi/%edi.
- */
- if (a_mask <= 0xff && (TCG_TARGET_REG_BITS == 64 || addrlo < 4)) {
- tcg_out_modrm(s, OPC_GRP3_Eb | P_REXB_RM, EXT3_TESTi, addrlo);
- tcg_out8(s, a_mask);
- } else {
- tcg_out_modrm(s, OPC_GRP3_Ev, EXT3_TESTi, addrlo);
- tcg_out32(s, a_mask);
- }
-
+ tcg_out_testi(s, addrlo, a_mask);
/* jne slow_path */
tcg_out_opc(s, OPC_JCC_long + JCC_JNE, 0, 0, 0);
--
2.34.1
- Re: [PATCH v3 01/57] tcg/loongarch64: Conditionalize tcg_out_exts_i32_i64, (continued)
- [PATCH v3 03/57] tcg/i386: Conditionalize tcg_out_extu_i32_i64, Richard Henderson, 2023/04/24
- [PATCH v3 04/57] tcg: Introduce tcg_out_movext2, Richard Henderson, 2023/04/24
- [PATCH v3 05/57] tcg/i386: Rationalize args to tcg_out_qemu_{ld,st}, Richard Henderson, 2023/04/24
- [PATCH v3 07/57] tcg/i386: Introduce HostAddress, Richard Henderson, 2023/04/24
- [PATCH v3 06/57] tcg/i386: Generalize multi-part load overlap test, Richard Henderson, 2023/04/24
- [PATCH v3 09/57] tcg/i386: Introduce tcg_out_testi,
Richard Henderson <=
- [PATCH v3 11/57] tcg/i386: Use indexed addressing for softmmu fast path, Richard Henderson, 2023/04/24
- [PATCH v3 08/57] tcg/i386: Drop r0+r1 local variables from tcg_out_tlb_load, Richard Henderson, 2023/04/24
- [PATCH v3 38/57] tcg: Add routines for calling slow-path helpers, Richard Henderson, 2023/04/24
- [PATCH v3 12/57] tcg/aarch64: Rationalize args to tcg_out_qemu_{ld, st}, Richard Henderson, 2023/04/24
- [PATCH v3 14/57] tcg/aarch64: Introduce prepare_host_addr, Richard Henderson, 2023/04/24
- [PATCH v3 15/57] tcg/arm: Rationalize args to tcg_out_qemu_{ld,st}, Richard Henderson, 2023/04/24
- [PATCH v3 21/57] tcg/mips: Rationalize args to tcg_out_qemu_{ld,st}, Richard Henderson, 2023/04/24
- [PATCH v3 24/57] tcg/ppc: Introduce HostAddress, Richard Henderson, 2023/04/24