diff mbox series

[2/7] tcg/tcg-op: Document bswap32() byte pattern

Message ID 20230822093712.38922-3-philmd@linaro.org
State New
Headers show
Series tcg: Document *swap/deposit helpers | expand

Commit Message

Philippe Mathieu-Daudé Aug. 22, 2023, 9:37 a.m. UTC
Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
---
 tcg/tcg-op.c | 12 ++++++++++++
 1 file changed, 12 insertions(+)

Comments

Richard Henderson Aug. 22, 2023, 4 p.m. UTC | #1
On 8/22/23 02:37, Philippe Mathieu-Daudé wrote:
> Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
> ---
>   tcg/tcg-op.c | 12 ++++++++++++
>   1 file changed, 12 insertions(+)
> 
> diff --git a/tcg/tcg-op.c b/tcg/tcg-op.c
> index f164ddc95e..e6b0d74a46 100644
> --- a/tcg/tcg-op.c
> +++ b/tcg/tcg-op.c
> @@ -1061,6 +1061,11 @@ void tcg_gen_bswap16_i32(TCGv_i32 ret, TCGv_i32 arg, int flags)
>       }
>   }
>   
> +/*
> + * bswap32_i32: 32-bit byte swap on a 32-bit value.
> + *
> + * Byte pattern:  bswap32_i32(abcd) -> dcba
> + */

Ok.

>   void tcg_gen_bswap32_i32(TCGv_i32 ret, TCGv_i32 arg)
>   {
>       if (TCG_TARGET_HAS_bswap32_i32) {
> @@ -1776,6 +1781,13 @@ void tcg_gen_bswap16_i64(TCGv_i64 ret, TCGv_i64 arg, int flags)
>       }
>   }
>   
> +/*
> + * bswap32_i64: 32-bit byte swap on the low bits of a 64-bit value.
> + *
> + * Byte pattern:  bswap32_i64(xxxxabcd) -> ....dcba     (TCG_BSWAP_OZ)
> + *                bswap32_i64(xxxxabcd) -> ssssdcba     (TCG_BSWAP_OS)
> + *                bswap32_i64(xxxxabcd) -> xxxxdcba
> + */

Again, TCG_BSWAP_IZ.

r~
Philippe Mathieu-Daudé Aug. 23, 2023, 1:14 p.m. UTC | #2
On 22/8/23 18:00, Richard Henderson wrote:
> On 8/22/23 02:37, Philippe Mathieu-Daudé wrote:
>> Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
>> ---
>>   tcg/tcg-op.c | 12 ++++++++++++
>>   1 file changed, 12 insertions(+)


>> +/*
>> + * bswap32_i64: 32-bit byte swap on the low bits of a 64-bit value.
>> + *
>> + * Byte pattern:  bswap32_i64(xxxxabcd) -> ....dcba     (TCG_BSWAP_OZ)
>> + *                bswap32_i64(xxxxabcd) -> ssssdcba     (TCG_BSWAP_OS)
>> + *                bswap32_i64(xxxxabcd) -> xxxxdcba
>> + */
> 
> Again, TCG_BSWAP_IZ.

Whether TCG_BSWAP_IZ is set or not doesn't change the result, at the
end we have:

   bswap32_i64(xxxxabcd) -> ....dcba     (TCG_BSWAP_OS not set)
   bswap32_i64(xxxxabcd) -> ssssdcba     (TCG_BSWAP_OS set)
Richard Henderson Aug. 23, 2023, 3:54 p.m. UTC | #3
On 8/23/23 06:14, Philippe Mathieu-Daudé wrote:
> On 22/8/23 18:00, Richard Henderson wrote:
>> On 8/22/23 02:37, Philippe Mathieu-Daudé wrote:
>>> Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
>>> ---
>>>   tcg/tcg-op.c | 12 ++++++++++++
>>>   1 file changed, 12 insertions(+)
> 
> 
>>> +/*
>>> + * bswap32_i64: 32-bit byte swap on the low bits of a 64-bit value.
>>> + *
>>> + * Byte pattern:  bswap32_i64(xxxxabcd) -> ....dcba     (TCG_BSWAP_OZ)
>>> + *                bswap32_i64(xxxxabcd) -> ssssdcba     (TCG_BSWAP_OS)
>>> + *                bswap32_i64(xxxxabcd) -> xxxxdcba
>>> + */
>>
>> Again, TCG_BSWAP_IZ.
> 
> Whether TCG_BSWAP_IZ is set or not doesn't change the result, at the
> end we have:
> 
>    bswap32_i64(xxxxabcd) -> ....dcba     (TCG_BSWAP_OS not set)
>    bswap32_i64(xxxxabcd) -> ssssdcba     (TCG_BSWAP_OS set)

It changes the input: not 'x' but '.'.


r~
diff mbox series

Patch

diff --git a/tcg/tcg-op.c b/tcg/tcg-op.c
index f164ddc95e..e6b0d74a46 100644
--- a/tcg/tcg-op.c
+++ b/tcg/tcg-op.c
@@ -1061,6 +1061,11 @@  void tcg_gen_bswap16_i32(TCGv_i32 ret, TCGv_i32 arg, int flags)
     }
 }
 
+/*
+ * bswap32_i32: 32-bit byte swap on a 32-bit value.
+ *
+ * Byte pattern:  bswap32_i32(abcd) -> dcba
+ */
 void tcg_gen_bswap32_i32(TCGv_i32 ret, TCGv_i32 arg)
 {
     if (TCG_TARGET_HAS_bswap32_i32) {
@@ -1776,6 +1781,13 @@  void tcg_gen_bswap16_i64(TCGv_i64 ret, TCGv_i64 arg, int flags)
     }
 }
 
+/*
+ * bswap32_i64: 32-bit byte swap on the low bits of a 64-bit value.
+ *
+ * Byte pattern:  bswap32_i64(xxxxabcd) -> ....dcba     (TCG_BSWAP_OZ)
+ *                bswap32_i64(xxxxabcd) -> ssssdcba     (TCG_BSWAP_OS)
+ *                bswap32_i64(xxxxabcd) -> xxxxdcba
+ */
 void tcg_gen_bswap32_i64(TCGv_i64 ret, TCGv_i64 arg, int flags)
 {
     /* Only one extension flag may be present. */