[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [PATCH v2 09/36] tcg: Consolidate 3 bits into enum TCGTempKind
From: |
Alex Bennée |
Subject: |
Re: [PATCH v2 09/36] tcg: Consolidate 3 bits into enum TCGTempKind |
Date: |
Wed, 22 Apr 2020 12:25:27 +0100 |
User-agent: |
mu4e 1.4.1; emacs 28.0.50 |
Richard Henderson <address@hidden> writes:
> The temp_fixed, temp_global, temp_local bits are all related.
> Combine them into a single enumeration.
>
> Signed-off-by: Richard Henderson <address@hidden>
> ---
> include/tcg/tcg.h | 20 +++++---
> tcg/optimize.c | 8 +--
> tcg/tcg.c | 122 ++++++++++++++++++++++++++++------------------
> 3 files changed, 90 insertions(+), 60 deletions(-)
>
> diff --git a/include/tcg/tcg.h b/include/tcg/tcg.h
> index c48bd76b0a..3534dce77f 100644
> --- a/include/tcg/tcg.h
> +++ b/include/tcg/tcg.h
> @@ -480,23 +480,27 @@ typedef enum TCGTempVal {
> TEMP_VAL_CONST,
> } TCGTempVal;
>
> +typedef enum TCGTempKind {
> + /* Temp is dead at the end of all basic blocks. */
> + TEMP_NORMAL,
> + /* Temp is saved across basic blocks but dead at the end of TBs. */
> + TEMP_LOCAL,
> + /* Temp is saved across both basic blocks and translation blocks. */
> + TEMP_GLOBAL,
> + /* Temp is in a fixed register. */
> + TEMP_FIXED,
> +} TCGTempKind;
> +
<snip>
> --- a/tcg/optimize.c
> +++ b/tcg/optimize.c
> @@ -116,21 +116,21 @@ static TCGTemp *find_better_copy(TCGContext *s, TCGTemp
> *ts)
> TCGTemp *i;
>
> /* If this is already a global, we can't do better. */
> - if (ts->temp_global) {
> + if (ts->kind >= TEMP_GLOBAL) {
> return ts;
> }
>
> /* Search for a global first. */
> for (i = ts_info(ts)->next_copy; i != ts; i = ts_info(i)->next_copy) {
> - if (i->temp_global) {
> + if (i->kind >= TEMP_GLOBAL) {
> return i;
> }
> }
>
> /* If it is a temp, search for a temp local. */
> - if (!ts->temp_local) {
> + if (ts->kind == TEMP_NORMAL) {
> for (i = ts_info(ts)->next_copy; i != ts; i = ts_info(i)->next_copy)
> {
> - if (ts->temp_local) {
> + if (i->kind >= TEMP_LOCAL) {
> return i;
> }
I was confused as to why these were not equality tests as being of one
type does not imply the properties of another? But I see the logic is
simplified even more in later patches.
<snip>
>
> memset(s->reg_to_temp, 0, sizeof(s->reg_to_temp));
> @@ -1885,12 +1896,17 @@ static char *tcg_get_arg_str_ptr(TCGContext *s, char
> *buf, int buf_size,
> {
> int idx = temp_idx(ts);
>
> - if (ts->temp_global) {
> + switch (ts->kind) {
> + case TEMP_FIXED:
> + case TEMP_GLOBAL:
> pstrcpy(buf, buf_size, ts->name);
> - } else if (ts->temp_local) {
> + break;
> + case TEMP_LOCAL:
> snprintf(buf, buf_size, "loc%d", idx - s->nb_globals);
> - } else {
> + break;
> + case TEMP_NORMAL:
> snprintf(buf, buf_size, "tmp%d", idx - s->nb_globals);
> + break;
> }
> return buf;
Random aside - if tcg is firmly staying part of qemu we should consider
modernising some of the string handling here.
Anyway:
Reviewed-by: Alex Bennée <address@hidden>
--
Alex Bennée
- [PATCH v2 00/36] tcg 5.1 omnibus patch set, Richard Henderson, 2020/04/21
- [PATCH v2 01/36] tcg: Add tcg_gen_gvec_dup_imm, Richard Henderson, 2020/04/21
- [PATCH v2 02/36] target/s390x: Use tcg_gen_gvec_dup_imm, Richard Henderson, 2020/04/21
- [PATCH v2 03/36] target/ppc: Use tcg_gen_gvec_dup_imm, Richard Henderson, 2020/04/21
- [PATCH v2 04/36] target/arm: Use tcg_gen_gvec_dup_imm, Richard Henderson, 2020/04/21
- [PATCH v2 05/36] tcg: Use tcg_gen_gvec_dup_imm in logical simplifications, Richard Henderson, 2020/04/21
- [PATCH v2 07/36] tcg: Add tcg_gen_gvec_dup_tl, Richard Henderson, 2020/04/21
- [PATCH v2 06/36] tcg: Remove tcg_gen_gvec_dup{8,16,32,64}i, Richard Henderson, 2020/04/21
- [PATCH v2 08/36] tcg: Improve vector tail clearing, Richard Henderson, 2020/04/21
- [PATCH v2 09/36] tcg: Consolidate 3 bits into enum TCGTempKind, Richard Henderson, 2020/04/21
- Re: [PATCH v2 09/36] tcg: Consolidate 3 bits into enum TCGTempKind,
Alex Bennée <=
- Re: [PATCH v2 09/36] tcg: Consolidate 3 bits into enum TCGTempKind, Aleksandar Markovic, 2020/04/22
- Re: [PATCH v2 09/36] tcg: Consolidate 3 bits into enum TCGTempKind, Philippe Mathieu-Daudé, 2020/04/23
- Re: [PATCH v2 09/36] tcg: Consolidate 3 bits into enum TCGTempKind, Richard Henderson, 2020/04/23
- Re: [PATCH v2 09/36] tcg: Consolidate 3 bits into enum TCGTempKind, Daniel P . Berrangé, 2020/04/23
- Re: [PATCH v2 09/36] tcg: Consolidate 3 bits into enum TCGTempKind, Richard Henderson, 2020/04/23
- Re: [PATCH v2 09/36] tcg: Consolidate 3 bits into enum TCGTempKind, Daniel P . Berrangé, 2020/04/24
[PATCH v2 12/36] tcg: Use tcg_constant_i32 with icount expander, Richard Henderson, 2020/04/21
[PATCH v2 11/36] tcg: Introduce TYPE_CONST temporaries, Richard Henderson, 2020/04/21