@@ -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)
@@ -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)
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(-) -- 2.25.1