diff mbox series

[PATCH-for-10.1,05/12] tcg: Use TCGContext::insn_start_words in tcg_gen_insn_start()

Message ID 20250319134507.45045-6-philmd@linaro.org
State New
Headers show
Series tcg: Make tcg_gen_insn_start() target-agnostic | expand

Commit Message

Philippe Mathieu-Daudé March 19, 2025, 1:44 p.m. UTC
In tb_gen_code() we set TCGContext::insn_start_words to
TARGET_INSN_START_WORDS:

290 TranslationBlock *tb_gen_code(...)
293 {
...
351     tcg_ctx->insn_start_words = TARGET_INSN_START_WORDS;

This definition is expanded to:

 11 # define TARGET_INSN_START_WORDS (1 + TARGET_INSN_START_EXTRA_WORDS)

Directly use the identical tcg_ctx->insn_start_words variable.

Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
---
 include/tcg/tcg-op.h | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

Comments

Richard Henderson March 19, 2025, 4:19 p.m. UTC | #1
On 3/19/25 06:44, Philippe Mathieu-Daudé wrote:
> In tb_gen_code() we set TCGContext::insn_start_words to
> TARGET_INSN_START_WORDS:
> 
> 290 TranslationBlock *tb_gen_code(...)
> 293 {
> ...
> 351     tcg_ctx->insn_start_words = TARGET_INSN_START_WORDS;
> 
> This definition is expanded to:
> 
>   11 # define TARGET_INSN_START_WORDS (1 + TARGET_INSN_START_EXTRA_WORDS)
> 
> Directly use the identical tcg_ctx->insn_start_words variable.
> 
> Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
> ---
>   include/tcg/tcg-op.h | 6 +++---
>   1 file changed, 3 insertions(+), 3 deletions(-)

Nack.

We are specializing the function signature to the number of arguments.
There is absolutely no point in reading that number from a variable.


r~

> 
> diff --git a/include/tcg/tcg-op.h b/include/tcg/tcg-op.h
> index e0038e70a8d..1f0d3b95304 100644
> --- a/include/tcg/tcg-op.h
> +++ b/include/tcg/tcg-op.h
> @@ -25,7 +25,7 @@
>   #if TARGET_INSN_START_EXTRA_WORDS == 0
>   static inline void tcg_gen_insn_start(uint64_t pc)
>   {
> -    unsigned insn_start_words = 1;
> +    unsigned insn_start_words = tcg_ctx->insn_start_words;
>       TCGOp *op = tcg_emit_op(INDEX_op_insn_start,
>                               insn_start_words * 64 / TCG_TARGET_REG_BITS);
>   
> @@ -34,7 +34,7 @@ static inline void tcg_gen_insn_start(uint64_t pc)
>   #elif TARGET_INSN_START_EXTRA_WORDS == 1
>   static inline void tcg_gen_insn_start(uint64_t pc, uint64_t a1)
>   {
> -    unsigned insn_start_words = 1 + TARGET_INSN_START_EXTRA_WORDS;
> +    unsigned insn_start_words = tcg_ctx->insn_start_words;
>       TCGOp *op = tcg_emit_op(INDEX_op_insn_start,
>                               insn_start_words * 64 / TCG_TARGET_REG_BITS);
>   
> @@ -44,7 +44,7 @@ static inline void tcg_gen_insn_start(uint64_t pc, uint64_t a1)
>   #elif TARGET_INSN_START_EXTRA_WORDS == 2
>   static inline void tcg_gen_insn_start(uint64_t pc, uint64_t a1, uint64_t a2)
>   {
> -    unsigned insn_start_words = 1 + TARGET_INSN_START_EXTRA_WORDS;
> +    unsigned insn_start_words = tcg_ctx->insn_start_words;
>       TCGOp *op = tcg_emit_op(INDEX_op_insn_start,
>                               insn_start_words * 64 / TCG_TARGET_REG_BITS);
>
diff mbox series

Patch

diff --git a/include/tcg/tcg-op.h b/include/tcg/tcg-op.h
index e0038e70a8d..1f0d3b95304 100644
--- a/include/tcg/tcg-op.h
+++ b/include/tcg/tcg-op.h
@@ -25,7 +25,7 @@ 
 #if TARGET_INSN_START_EXTRA_WORDS == 0
 static inline void tcg_gen_insn_start(uint64_t pc)
 {
-    unsigned insn_start_words = 1;
+    unsigned insn_start_words = tcg_ctx->insn_start_words;
     TCGOp *op = tcg_emit_op(INDEX_op_insn_start,
                             insn_start_words * 64 / TCG_TARGET_REG_BITS);
 
@@ -34,7 +34,7 @@  static inline void tcg_gen_insn_start(uint64_t pc)
 #elif TARGET_INSN_START_EXTRA_WORDS == 1
 static inline void tcg_gen_insn_start(uint64_t pc, uint64_t a1)
 {
-    unsigned insn_start_words = 1 + TARGET_INSN_START_EXTRA_WORDS;
+    unsigned insn_start_words = tcg_ctx->insn_start_words;
     TCGOp *op = tcg_emit_op(INDEX_op_insn_start,
                             insn_start_words * 64 / TCG_TARGET_REG_BITS);
 
@@ -44,7 +44,7 @@  static inline void tcg_gen_insn_start(uint64_t pc, uint64_t a1)
 #elif TARGET_INSN_START_EXTRA_WORDS == 2
 static inline void tcg_gen_insn_start(uint64_t pc, uint64_t a1, uint64_t a2)
 {
-    unsigned insn_start_words = 1 + TARGET_INSN_START_EXTRA_WORDS;
+    unsigned insn_start_words = tcg_ctx->insn_start_words;
     TCGOp *op = tcg_emit_op(INDEX_op_insn_start,
                             insn_start_words * 64 / TCG_TARGET_REG_BITS);