qemu-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [RFC PATCH 04/10] target/hexagon: introduce new helper functions


From: Philippe Mathieu-Daudé
Subject: Re: [RFC PATCH 04/10] target/hexagon: introduce new helper functions
Date: Fri, 12 Feb 2021 00:22:15 +0100
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101 Thunderbird/78.6.0

On 2/11/21 10:50 PM, Alessandro Di Federico via wrote:
> From: Niccolò Izzo <nizzo@rev.ng>
> 
> These helpers will be employed by the idef-parser generated code.
> 

Shouldn't this be signed by Niccolò too?

> Signed-off-by: Alessandro Di Federico <ale@rev.ng>
> ---
>  target/hexagon/genptr.c | 224 ++++++++++++++++++++++++++++++++++++++++
>  target/hexagon/genptr.h |  19 ++++
>  2 files changed, 243 insertions(+)
> 
> diff --git a/target/hexagon/genptr.c b/target/hexagon/genptr.c
> index 97de669f38..33446bd713 100644
> --- a/target/hexagon/genptr.c
> +++ b/target/hexagon/genptr.c
> @@ -334,5 +334,229 @@ static inline void 
> gen_store_conditional8(CPUHexagonState *env,
>      tcg_gen_movi_tl(hex_llsc_addr, ~0);
>  }
>  
> +void gen_fbrev(TCGv result, TCGv src)
> +{
> +    TCGv lo = tcg_temp_new();
> +    TCGv tmp1 = tcg_temp_new();
> +    TCGv tmp2 = tcg_temp_new();
> +
> +    /* Bit reversal of low 16 bits */
> +    tcg_gen_andi_tl(lo, src, 0xffff);
> +    tcg_gen_andi_tl(tmp1, lo, 0xaaaa);
> +    tcg_gen_shri_tl(tmp1, tmp1, 1);
> +    tcg_gen_andi_tl(tmp2, lo, 0x5555);
> +    tcg_gen_shli_tl(tmp2, tmp2, 1);
> +    tcg_gen_or_tl(lo, tmp1, tmp2);
> +    tcg_gen_andi_tl(tmp1, lo, 0xcccc);
> +    tcg_gen_shri_tl(tmp1, tmp1, 2);
> +    tcg_gen_andi_tl(tmp2, lo, 0x3333);
> +    tcg_gen_shli_tl(tmp2, tmp2, 2);
> +    tcg_gen_or_tl(lo, tmp1, tmp2);
> +    tcg_gen_andi_tl(tmp1, lo, 0xf0f0);
> +    tcg_gen_shri_tl(tmp1, tmp1, 4);
> +    tcg_gen_andi_tl(tmp2, lo, 0x0f0f);
> +    tcg_gen_shli_tl(tmp2, tmp2, 4);
> +    tcg_gen_or_tl(lo, tmp1, tmp2);
> +    tcg_gen_bswap16_tl(lo, lo);
> +
> +    /* Final tweaks */
> +    tcg_gen_andi_tl(result, src, 0xffff0000);
> +    tcg_gen_ori_tl(result, lo, 8);

Maybe use tcg_gen_extract_tl() here?

> +
> +    tcg_temp_free(lo);
> +    tcg_temp_free(tmp1);
> +    tcg_temp_free(tmp2);
> +}
> +
> +TCGv gen_set_bit(int i, TCGv result, TCGv src)
> +{

I wonder if i should be tcg_target_long.

> +    TCGv mask = tcg_const_tl(~(1 << i));
> +    TCGv bit = tcg_temp_new();

> +    tcg_gen_shli_tl(bit, src, i);
> +    tcg_gen_and_tl(result, result, mask);
> +    tcg_gen_or_tl(result, result, bit);

Maybe optimize with tcg_gen_deposit_tl()?

> +    tcg_temp_free(mask);
> +    tcg_temp_free(bit);
> +
> +    return result;
> +}
> +
> +void gen_cancel(TCGv slot)
> +{
> +    TCGv one = tcg_const_tl(1);
> +    TCGv mask = tcg_temp_new();

> +    tcg_gen_shl_tl(mask, one, slot);

Similarly this looks like a deposit.

> +    tcg_gen_or_tl(hex_slot_cancelled, hex_slot_cancelled, mask);
> +    tcg_temp_free(one);
> +    tcg_temp_free(mask);
> +}
> +
> +void gen_store32(TCGv vaddr, TCGv src, int width, int slot)

tcg_target_long width?

unsigned slot (various).

> +{
> +    tcg_gen_mov_tl(hex_store_addr[slot], vaddr);
> +    tcg_gen_movi_tl(hex_store_width[slot], width);
> +    tcg_gen_mov_tl(hex_store_val32[slot], src);
> +}



reply via email to

[Prev in Thread] Current Thread [Next in Thread]