diff mbox series

[v3,05/14] tcg/arm: Examine QEMU_TCG_DEBUG environment variable

Message ID 20210818212912.396794-6-richard.henderson@linaro.org
State New
Headers show
Series tcg/arm: Unaligned access and other cleanup | expand

Commit Message

Richard Henderson Aug. 18, 2021, 9:29 p.m. UTC
Use the environment variable to test an older ISA from
the one supported by the host.

Signed-off-by: Richard Henderson <richard.henderson@linaro.org>

---
 tcg/arm/tcg-target.h     |  8 +++++++-
 tcg/arm/tcg-target.c.inc | 32 ++++++++++++++++++++++++++++++++
 2 files changed, 39 insertions(+), 1 deletion(-)

-- 
2.25.1

Comments

Peter Maydell Aug. 20, 2021, 11:01 a.m. UTC | #1
On Wed, 18 Aug 2021 at 22:42, Richard Henderson
<richard.henderson@linaro.org> wrote:
>

> Use the environment variable to test an older ISA from

> the one supported by the host.

>

> Signed-off-by: Richard Henderson <richard.henderson@linaro.org>


I think we should document this environment variable somewhere...



> +    /*

> +     * For debugging/testing purposes, allow the ISA to be reduced

> +     * (but not extended) from the set detected above.

> +     */

> +#ifdef CONFIG_DEBUG_TCG

> +    {

> +        char *opt = g_strdup(getenv("QEMU_TCG_DEBUG"));


Consider g_autofree ?

> +        if (opt) {

> +            for (char *o = strtok(opt, ","); o ; o = strtok(NULL, ",")) {

> +                if (o[0] == 'v' &&

> +                    o[1] >= '4' &&

> +                    o[1] <= '0' + arm_arch &&

> +                    o[2] == 0) {

> +                    arm_arch = o[1] - '0';

> +                    continue;

> +                }

> +                if (strcmp(o, "!neon") == 0) {

> +                    use_neon_instructions = false;

> +                    continue;

> +                }

> +                if (strcmp(o, "help") == 0) {

> +                    printf("QEMU_TCG_DEBUG=<opt>{,<opt>} where <opt> is\n"

> +                           "  v<N>   select ARMv<N>\n"

> +                           "  !neon  disable ARM NEON\n");

> +                    exit(0);

> +                }


We should complain about something in the variable we don't understand,
rather than just ignoring it.

> +            }

> +            g_free(opt);

> +        }

> +    }

> +#endif

> +


-- PMM
diff mbox series

Patch

diff --git a/tcg/arm/tcg-target.h b/tcg/arm/tcg-target.h
index f41b809554..e47720a85b 100644
--- a/tcg/arm/tcg-target.h
+++ b/tcg/arm/tcg-target.h
@@ -28,9 +28,15 @@ 
 
 extern int arm_arch;
 
+#ifdef CONFIG_DEBUG_TCG
+#define use_armv5t_instructions (arm_arch >= 5)
+#define use_armv6_instructions  (arm_arch >= 6)
+#define use_armv7_instructions  (arm_arch >= 7)
+#else
 #define use_armv5t_instructions (__ARM_ARCH >= 5 || arm_arch >= 5)
 #define use_armv6_instructions  (__ARM_ARCH >= 6 || arm_arch >= 6)
 #define use_armv7_instructions  (__ARM_ARCH >= 7 || arm_arch >= 7)
+#endif
 
 #undef TCG_TARGET_STACK_GROWSUP
 #define TCG_TARGET_INSN_UNIT_SIZE 4
@@ -83,7 +89,7 @@  typedef enum {
 #else
 extern bool use_idiv_instructions;
 #endif
-#ifdef __ARM_NEON__
+#if defined(__ARM_NEON__) && !defined(CONFIG_DEBUG_TCG)
 #define use_neon_instructions  1
 #else
 extern bool use_neon_instructions;
diff --git a/tcg/arm/tcg-target.c.inc b/tcg/arm/tcg-target.c.inc
index 87df812bb5..0c7e4f8411 100644
--- a/tcg/arm/tcg-target.c.inc
+++ b/tcg/arm/tcg-target.c.inc
@@ -2455,6 +2455,38 @@  static void tcg_target_init(TCGContext *s)
         }
     }
 
+    /*
+     * For debugging/testing purposes, allow the ISA to be reduced
+     * (but not extended) from the set detected above.
+     */
+#ifdef CONFIG_DEBUG_TCG
+    {
+        char *opt = g_strdup(getenv("QEMU_TCG_DEBUG"));
+        if (opt) {
+            for (char *o = strtok(opt, ","); o ; o = strtok(NULL, ",")) {
+                if (o[0] == 'v' &&
+                    o[1] >= '4' &&
+                    o[1] <= '0' + arm_arch &&
+                    o[2] == 0) {
+                    arm_arch = o[1] - '0';
+                    continue;
+                }
+                if (strcmp(o, "!neon") == 0) {
+                    use_neon_instructions = false;
+                    continue;
+                }
+                if (strcmp(o, "help") == 0) {
+                    printf("QEMU_TCG_DEBUG=<opt>{,<opt>} where <opt> is\n"
+                           "  v<N>   select ARMv<N>\n"
+                           "  !neon  disable ARM NEON\n");
+                    exit(0);
+                }
+            }
+            g_free(opt);
+        }
+    }
+#endif
+
     tcg_target_available_regs[TCG_TYPE_I32] = ALL_GENERAL_REGS;
 
     tcg_target_call_clobber_regs = 0;