From: Richard Henderson <richard.henderson@linaro.org>
To: qemu-devel@nongnu.org
Cc: lvivier@redhat.com, alistair23@gmail.com
Subject: [PATCH 1/5] tcg: Add an index to TCGTemp
Date: Tue, 19 Jan 2021 08:34:24 -1000 [thread overview]
Message-ID: <20210119183428.556706-2-richard.henderson@linaro.org> (raw)
In-Reply-To: <20210119183428.556706-1-richard.henderson@linaro.org>
This allows to break the tie between the memory location
of TCGTemp and TCGContext->temps[]. Which is the first
step to allowing the array to be reallocated.
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
---
include/tcg/tcg.h | 5 ++---
tcg/tcg.c | 10 ++++++++--
2 files changed, 10 insertions(+), 5 deletions(-)
diff --git a/include/tcg/tcg.h b/include/tcg/tcg.h
index 504c5e9bb0..5ef644ceae 100644
--- a/include/tcg/tcg.h
+++ b/include/tcg/tcg.h
@@ -497,6 +497,7 @@ typedef enum TCGTempKind {
} TCGTempKind;
typedef struct TCGTemp {
+ unsigned int index:16;
TCGReg reg:8;
TCGTempVal val_type:8;
TCGType base_type:8;
@@ -721,9 +722,7 @@ static inline void *tcg_splitwx_to_rw(const void *rx)
static inline size_t temp_idx(TCGTemp *ts)
{
- ptrdiff_t n = ts - tcg_ctx->temps;
- tcg_debug_assert(n >= 0 && n < tcg_ctx->nb_temps);
- return n;
+ return ts->index;
}
static inline TCGArg temp_arg(TCGTemp *ts)
diff --git a/tcg/tcg.c b/tcg/tcg.c
index 8f8badb61c..4a8dfb8f67 100644
--- a/tcg/tcg.c
+++ b/tcg/tcg.c
@@ -1204,11 +1204,17 @@ void tcg_func_start(TCGContext *s)
QSIMPLEQ_INIT(&s->labels);
}
-static inline TCGTemp *tcg_temp_alloc(TCGContext *s)
+static TCGTemp *tcg_temp_alloc(TCGContext *s)
{
int n = s->nb_temps++;
+ TCGTemp *ret;
+
tcg_debug_assert(n < TCG_MAX_TEMPS);
- return memset(&s->temps[n], 0, sizeof(TCGTemp));
+ ret = &s->temps[n];
+ memset(ret, 0, sizeof(TCGTemp));
+ ret->index = n;
+
+ return ret;
}
static inline TCGTemp *tcg_global_alloc(TCGContext *s)
--
2.25.1
next prev parent reply other threads:[~2021-01-19 19:36 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-01-19 18:34 [PATCH 0/5] tcg: Dynamically allocate temporaries Richard Henderson
2021-01-19 18:34 ` Richard Henderson [this message]
2021-01-19 18:34 ` [PATCH 2/5] tcg: Introduce and use tcg_temp Richard Henderson
2021-01-19 18:34 ` [PATCH 3/5] tcg: Make TCGTempSet expandable Richard Henderson
2021-01-19 18:34 ` [PATCH 4/5] tcg: Adjust tcgv_*_temp/temp_tcgv_* Richard Henderson
2021-01-19 18:34 ` [PATCH 5/5] tcg: Dynamically allocate temporaries Richard Henderson
2021-01-19 23:06 ` [PATCH 0/5] " BALATON Zoltan
2021-01-19 23:33 ` Philippe Mathieu-Daudé
2021-01-20 9:03 ` BALATON Zoltan
2021-01-21 20:09 ` BALATON Zoltan
2021-01-21 20:17 ` Richard Henderson
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20210119183428.556706-2-richard.henderson@linaro.org \
--to=richard.henderson@linaro.org \
--cc=alistair23@gmail.com \
--cc=lvivier@redhat.com \
--cc=qemu-devel@nongnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).