diff mbox series

[09/33] target/mips: Introduce generic TRANS_CHECK() for decodetree helpers

Message ID 20211023214803.522078-10-f4bug@amsat.org
State New
Headers show
Series target/mips: Fully convert MSA opcodes to decodetree | expand

Commit Message

Philippe Mathieu-Daudé Oct. 23, 2021, 9:47 p.m. UTC
Similar to the TRANS() macro introduced in commit fb3164e412d,
introduce TRANS_CHECK() which takes a boolean expression as
argument.

Signed-off-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
---
 target/mips/tcg/translate.h | 9 +++++++++
 1 file changed, 9 insertions(+)

Comments

Richard Henderson Oct. 24, 2021, 1:58 a.m. UTC | #1
On 10/23/21 2:47 PM, Philippe Mathieu-Daudé wrote:
> Similar to the TRANS() macro introduced in commit fb3164e412d,
> introduce TRANS_CHECK() which takes a boolean expression as
> argument.
> 
> Signed-off-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
> ---
>   target/mips/tcg/translate.h | 9 +++++++++
>   1 file changed, 9 insertions(+)
> 
> diff --git a/target/mips/tcg/translate.h b/target/mips/tcg/translate.h
> index 6111493651f..3ef09cc50c9 100644
> --- a/target/mips/tcg/translate.h
> +++ b/target/mips/tcg/translate.h
> @@ -224,6 +224,15 @@ bool decode_ext_vr54xx(DisasContext *ctx, uint32_t insn);
>       static bool trans_##NAME(DisasContext *ctx, arg_##NAME *a) \
>       { return FUNC(ctx, a, __VA_ARGS__); }
>   
> +#define TRANS_CHECK(NAME, CHECK_EXPR, FUNC, ...) \
> +    static bool trans_##NAME(DisasContext *ctx, arg_##NAME *a) \
> +    { \
> +        if (!(CHECK_EXPR)) { \
> +            return false; \
> +        } \
> +        return FUNC(ctx, a, __VA_ARGS__); \
> +    }

So... if you're going to do this generically, you may want to adjust check_msa_access. 
OTOH, perhaps all you want is a more local TRANS_MSA, with the CHECK_EXPR built in.


r~
diff mbox series

Patch

diff --git a/target/mips/tcg/translate.h b/target/mips/tcg/translate.h
index 6111493651f..3ef09cc50c9 100644
--- a/target/mips/tcg/translate.h
+++ b/target/mips/tcg/translate.h
@@ -224,6 +224,15 @@  bool decode_ext_vr54xx(DisasContext *ctx, uint32_t insn);
     static bool trans_##NAME(DisasContext *ctx, arg_##NAME *a) \
     { return FUNC(ctx, a, __VA_ARGS__); }
 
+#define TRANS_CHECK(NAME, CHECK_EXPR, FUNC, ...) \
+    static bool trans_##NAME(DisasContext *ctx, arg_##NAME *a) \
+    { \
+        if (!(CHECK_EXPR)) { \
+            return false; \
+        } \
+        return FUNC(ctx, a, __VA_ARGS__); \
+    }
+
 static inline bool cpu_is_bigendian(DisasContext *ctx)
 {
     return extract32(ctx->CP0_Config0, CP0C0_BE, 1);