Merge remote-tracking branch 'rth/tcg-temp-order' into staging
# By Richard Henderson # Via Richard Henderson * rth/tcg-temp-order: tcg: Use bitmaps for free temporaries Message-id: 1386698065-6661-1-git-send-email-rth@twiddle.net Signed-off-by: Anthony Liguori <aliguori@amazon.com>
This commit is contained in:
commit
6747f6456f
32
tcg/tcg.c
32
tcg/tcg.c
|
@ -357,11 +357,12 @@ void tcg_set_frame(TCGContext *s, int reg, intptr_t start, intptr_t size)
|
||||||
|
|
||||||
void tcg_func_start(TCGContext *s)
|
void tcg_func_start(TCGContext *s)
|
||||||
{
|
{
|
||||||
int i;
|
|
||||||
tcg_pool_reset(s);
|
tcg_pool_reset(s);
|
||||||
s->nb_temps = s->nb_globals;
|
s->nb_temps = s->nb_globals;
|
||||||
for(i = 0; i < (TCG_TYPE_COUNT * 2); i++)
|
|
||||||
s->first_free_temp[i] = -1;
|
/* No temps have been previously allocated for size or locality. */
|
||||||
|
memset(s->free_temps, 0, sizeof(s->free_temps));
|
||||||
|
|
||||||
s->labels = tcg_malloc(sizeof(TCGLabel) * TCG_MAX_LABELS);
|
s->labels = tcg_malloc(sizeof(TCGLabel) * TCG_MAX_LABELS);
|
||||||
s->nb_labels = 0;
|
s->nb_labels = 0;
|
||||||
s->current_frame_offset = s->frame_start;
|
s->current_frame_offset = s->frame_start;
|
||||||
|
@ -503,16 +504,15 @@ static inline int tcg_temp_new_internal(TCGType type, int temp_local)
|
||||||
TCGTemp *ts;
|
TCGTemp *ts;
|
||||||
int idx, k;
|
int idx, k;
|
||||||
|
|
||||||
k = type;
|
k = type + (temp_local ? TCG_TYPE_COUNT : 0);
|
||||||
if (temp_local)
|
idx = find_first_bit(s->free_temps[k].l, TCG_MAX_TEMPS);
|
||||||
k += TCG_TYPE_COUNT;
|
if (idx < TCG_MAX_TEMPS) {
|
||||||
idx = s->first_free_temp[k];
|
/* There is already an available temp with the right type. */
|
||||||
if (idx != -1) {
|
clear_bit(idx, s->free_temps[k].l);
|
||||||
/* There is already an available temp with the
|
|
||||||
right type */
|
|
||||||
ts = &s->temps[idx];
|
ts = &s->temps[idx];
|
||||||
s->first_free_temp[k] = ts->next_free_temp;
|
|
||||||
ts->temp_allocated = 1;
|
ts->temp_allocated = 1;
|
||||||
|
assert(ts->base_type == type);
|
||||||
assert(ts->temp_local == temp_local);
|
assert(ts->temp_local == temp_local);
|
||||||
} else {
|
} else {
|
||||||
idx = s->nb_temps;
|
idx = s->nb_temps;
|
||||||
|
@ -568,7 +568,7 @@ TCGv_i64 tcg_temp_new_internal_i64(int temp_local)
|
||||||
return MAKE_TCGV_I64(idx);
|
return MAKE_TCGV_I64(idx);
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline void tcg_temp_free_internal(int idx)
|
static void tcg_temp_free_internal(int idx)
|
||||||
{
|
{
|
||||||
TCGContext *s = &tcg_ctx;
|
TCGContext *s = &tcg_ctx;
|
||||||
TCGTemp *ts;
|
TCGTemp *ts;
|
||||||
|
@ -585,11 +585,9 @@ static inline void tcg_temp_free_internal(int idx)
|
||||||
ts = &s->temps[idx];
|
ts = &s->temps[idx];
|
||||||
assert(ts->temp_allocated != 0);
|
assert(ts->temp_allocated != 0);
|
||||||
ts->temp_allocated = 0;
|
ts->temp_allocated = 0;
|
||||||
k = ts->base_type;
|
|
||||||
if (ts->temp_local)
|
k = ts->type + (ts->temp_local ? TCG_TYPE_COUNT : 0);
|
||||||
k += TCG_TYPE_COUNT;
|
set_bit(idx, s->free_temps[k].l);
|
||||||
ts->next_free_temp = s->first_free_temp[k];
|
|
||||||
s->first_free_temp[k] = idx;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void tcg_temp_free_i32(TCGv_i32 arg)
|
void tcg_temp_free_i32(TCGv_i32 arg)
|
||||||
|
|
11
tcg/tcg.h
11
tcg/tcg.h
|
@ -26,7 +26,7 @@
|
||||||
#define TCG_H
|
#define TCG_H
|
||||||
|
|
||||||
#include "qemu-common.h"
|
#include "qemu-common.h"
|
||||||
|
#include "qemu/bitops.h"
|
||||||
#include "tcg-target.h"
|
#include "tcg-target.h"
|
||||||
|
|
||||||
/* Default target word size to pointer size. */
|
/* Default target word size to pointer size. */
|
||||||
|
@ -436,13 +436,15 @@ typedef struct TCGTemp {
|
||||||
basic blocks. Otherwise, it is not
|
basic blocks. Otherwise, it is not
|
||||||
preserved across basic blocks. */
|
preserved across basic blocks. */
|
||||||
unsigned int temp_allocated:1; /* never used for code gen */
|
unsigned int temp_allocated:1; /* never used for code gen */
|
||||||
/* index of next free temp of same base type, -1 if end */
|
|
||||||
int next_free_temp;
|
|
||||||
const char *name;
|
const char *name;
|
||||||
} TCGTemp;
|
} TCGTemp;
|
||||||
|
|
||||||
typedef struct TCGContext TCGContext;
|
typedef struct TCGContext TCGContext;
|
||||||
|
|
||||||
|
typedef struct TCGTempSet {
|
||||||
|
unsigned long l[BITS_TO_LONGS(TCG_MAX_TEMPS)];
|
||||||
|
} TCGTempSet;
|
||||||
|
|
||||||
struct TCGContext {
|
struct TCGContext {
|
||||||
uint8_t *pool_cur, *pool_end;
|
uint8_t *pool_cur, *pool_end;
|
||||||
TCGPool *pool_first, *pool_current, *pool_first_large;
|
TCGPool *pool_first, *pool_current, *pool_first_large;
|
||||||
|
@ -450,8 +452,6 @@ struct TCGContext {
|
||||||
int nb_labels;
|
int nb_labels;
|
||||||
int nb_globals;
|
int nb_globals;
|
||||||
int nb_temps;
|
int nb_temps;
|
||||||
/* index of free temps, -1 if none */
|
|
||||||
int first_free_temp[TCG_TYPE_COUNT * 2];
|
|
||||||
|
|
||||||
/* goto_tb support */
|
/* goto_tb support */
|
||||||
uint8_t *code_buf;
|
uint8_t *code_buf;
|
||||||
|
@ -477,6 +477,7 @@ struct TCGContext {
|
||||||
|
|
||||||
uint8_t *code_ptr;
|
uint8_t *code_ptr;
|
||||||
TCGTemp temps[TCG_MAX_TEMPS]; /* globals first, temps after */
|
TCGTemp temps[TCG_MAX_TEMPS]; /* globals first, temps after */
|
||||||
|
TCGTempSet free_temps[TCG_TYPE_COUNT * 2];
|
||||||
|
|
||||||
GHashTable *helpers;
|
GHashTable *helpers;
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue