diff options
author | Richard Henderson <rth@twiddle.net> | 2016-11-02 11:20:15 -0600 |
---|---|---|
committer | Richard Henderson <richard.henderson@linaro.org> | 2017-10-24 21:43:50 +0200 |
commit | fa477d25470187030614288d35bc734edffa41ee (patch) | |
tree | a4e21c764fff7a6fa3f4c48d3ac2c95eb1c73bf1 /tcg/tcg.c | |
parent | 434391390ba99996af1591b427a73b3f5c05065e (diff) |
tcg: Add temp_global bit to TCGTemp
This avoids needing to test the index of a temp against nb_globals.
Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
Reviewed-by: Emilio G. Cota <cota@braap.org>
Signed-off-by: Richard Henderson <rth@twiddle.net>
Diffstat (limited to 'tcg/tcg.c')
-rw-r--r-- | tcg/tcg.c | 11 |
1 files changed, 8 insertions, 3 deletions
@@ -489,9 +489,14 @@ static inline TCGTemp *tcg_temp_alloc(TCGContext *s) static inline TCGTemp *tcg_global_alloc(TCGContext *s) { + TCGTemp *ts; + tcg_debug_assert(s->nb_globals == s->nb_temps); s->nb_globals++; - return tcg_temp_alloc(s); + ts = tcg_temp_alloc(s); + ts->temp_global = 1; + + return ts; } static int tcg_global_reg_new_internal(TCGContext *s, TCGType type, @@ -1190,7 +1195,7 @@ static char *tcg_get_arg_str_ptr(TCGContext *s, char *buf, int buf_size, { int idx = temp_idx(s, ts); - if (idx < s->nb_globals) { + if (ts->temp_global) { pstrcpy(buf, buf_size, ts->name); } else if (ts->temp_local) { snprintf(buf, buf_size, "loc%d", idx - s->nb_globals); @@ -2128,7 +2133,7 @@ static void temp_free_or_dead(TCGContext *s, TCGTemp *ts, int free_or_dead) } ts->val_type = (free_or_dead < 0 || ts->temp_local - || temp_idx(s, ts) < s->nb_globals + || ts->temp_global ? TEMP_VAL_MEM : TEMP_VAL_DEAD); } |