All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] tcg: Introduce tcg_remove_ops_after
@ 2021-06-04 21:27 Richard Henderson
  2021-06-07 13:51 ` Peter Maydell
  0 siblings, 1 reply; 3+ messages in thread
From: Richard Henderson @ 2021-06-04 21:27 UTC (permalink / raw)
  To: qemu-devel; +Cc: Peter Maydell

Introduce a function to remove everything emitted
since a given point.

Cc: Peter Maydell <peter.maydell@linaro.org>
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
---
 include/tcg/tcg.h |  1 +
 tcg/tcg.c         | 13 +++++++++++++
 2 files changed, 14 insertions(+)

diff --git a/include/tcg/tcg.h b/include/tcg/tcg.h
index 74cb345308..6895246fab 100644
--- a/include/tcg/tcg.h
+++ b/include/tcg/tcg.h
@@ -1081,6 +1081,7 @@ TCGOp *tcg_emit_op(TCGOpcode opc);
 void tcg_op_remove(TCGContext *s, TCGOp *op);
 TCGOp *tcg_op_insert_before(TCGContext *s, TCGOp *op, TCGOpcode opc);
 TCGOp *tcg_op_insert_after(TCGContext *s, TCGOp *op, TCGOpcode opc);
+void tcg_remove_ops_after(TCGOp *op);
 
 void tcg_optimize(TCGContext *s);
 
diff --git a/tcg/tcg.c b/tcg/tcg.c
index 0dc271aac9..262dbba1fd 100644
--- a/tcg/tcg.c
+++ b/tcg/tcg.c
@@ -2649,6 +2649,19 @@ void tcg_op_remove(TCGContext *s, TCGOp *op)
 #endif
 }
 
+void tcg_remove_ops_after(TCGOp *op)
+{
+    TCGContext *s = tcg_ctx;
+
+    while (true) {
+        TCGOp *last = tcg_last_op();
+        if (last == op) {
+            return;
+        }
+        tcg_op_remove(s, last);
+    }
+}
+
 static TCGOp *tcg_op_alloc(TCGOpcode opc)
 {
     TCGContext *s = tcg_ctx;
-- 
2.25.1



^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH] tcg: Introduce tcg_remove_ops_after
  2021-06-04 21:27 [PATCH] tcg: Introduce tcg_remove_ops_after Richard Henderson
@ 2021-06-07 13:51 ` Peter Maydell
  2021-06-07 15:22   ` Richard Henderson
  0 siblings, 1 reply; 3+ messages in thread
From: Peter Maydell @ 2021-06-07 13:51 UTC (permalink / raw)
  To: Richard Henderson; +Cc: Alex Bennée, QEMU Developers

On Fri, 4 Jun 2021 at 22:27, Richard Henderson
<richard.henderson@linaro.org> wrote:
>
> Introduce a function to remove everything emitted
> since a given point.
>
> Cc: Peter Maydell <peter.maydell@linaro.org>
> Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
> ---
>  include/tcg/tcg.h |  1 +
>  tcg/tcg.c         | 13 +++++++++++++
>  2 files changed, 14 insertions(+)
>
> diff --git a/include/tcg/tcg.h b/include/tcg/tcg.h
> index 74cb345308..6895246fab 100644
> --- a/include/tcg/tcg.h
> +++ b/include/tcg/tcg.h
> @@ -1081,6 +1081,7 @@ TCGOp *tcg_emit_op(TCGOpcode opc);
>  void tcg_op_remove(TCGContext *s, TCGOp *op);
>  TCGOp *tcg_op_insert_before(TCGContext *s, TCGOp *op, TCGOpcode opc);
>  TCGOp *tcg_op_insert_after(TCGContext *s, TCGOp *op, TCGOpcode opc);
> +void tcg_remove_ops_after(TCGOp *op);

A doc comment would be nice.

>  void tcg_optimize(TCGContext *s);
>
> diff --git a/tcg/tcg.c b/tcg/tcg.c
> index 0dc271aac9..262dbba1fd 100644
> --- a/tcg/tcg.c
> +++ b/tcg/tcg.c
> @@ -2649,6 +2649,19 @@ void tcg_op_remove(TCGContext *s, TCGOp *op)
>  #endif
>  }
>
> +void tcg_remove_ops_after(TCGOp *op)
> +{
> +    TCGContext *s = tcg_ctx;
> +
> +    while (true) {
> +        TCGOp *last = tcg_last_op();
> +        if (last == op) {
> +            return;
> +        }
> +        tcg_op_remove(s, last);
> +    }
> +}

This looks OK as far as TCG proper goes, but is it going to confuse
the TCG plugin infrastructure if a frontend generates a bunch of
TCG IR and then winds back the insn stream and generates something
else instead ? I see some calls from tcg/ into plugin related
functions, so I'm not sure...

thanks
-- PMM


^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] tcg: Introduce tcg_remove_ops_after
  2021-06-07 13:51 ` Peter Maydell
@ 2021-06-07 15:22   ` Richard Henderson
  0 siblings, 0 replies; 3+ messages in thread
From: Richard Henderson @ 2021-06-07 15:22 UTC (permalink / raw)
  To: Peter Maydell; +Cc: Alex Bennée, QEMU Developers

On 6/7/21 6:51 AM, Peter Maydell wrote:
>> +void tcg_remove_ops_after(TCGOp *op);
> 
> A doc comment would be nice.

Fair enough.

> This looks OK as far as TCG proper goes, but is it going to confuse
> the TCG plugin infrastructure if a frontend generates a bunch of
> TCG IR and then winds back the insn stream and generates something
> else instead ? I see some calls from tcg/ into plugin related
> functions, so I'm not sure...

Mm.  Didn't think about that Friday.  But looking now, if you wind back to 
dc->insn_start, everything will be fine.

The plugin stuff will put stuff in the stream, and then go back and 
post-process it.  But it does not record anything on the side, so if the stuff 
is no longer in the stream all's well.


r~


^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2021-06-07 15:23 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-06-04 21:27 [PATCH] tcg: Introduce tcg_remove_ops_after Richard Henderson
2021-06-07 13:51 ` Peter Maydell
2021-06-07 15:22   ` Richard Henderson

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.