[PATCH v2 5/8] target/alpha: Factor mo_endian() helper out

Philippe Mathieu-Daudé posted 8 patches 1 month ago
Maintainers: Laurent Vivier <laurent@vivier.eu>, Richard Henderson <richard.henderson@linaro.org>
[PATCH v2 5/8] target/alpha: Factor mo_endian() helper out
Posted by Philippe Mathieu-Daudé 1 month ago
Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
---
 target/alpha/translate.c | 7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)

diff --git a/target/alpha/translate.c b/target/alpha/translate.c
index 3be97057465..4f918cbfe63 100644
--- a/target/alpha/translate.c
+++ b/target/alpha/translate.c
@@ -96,6 +96,11 @@ static TCGv cpu_lock_value;
 static TCGv cpu_pal_ir[31];
 #endif
 
+static inline MemOp mo_endian(DisasContext *dc)
+{
+    return MO_TE;
+}
+
 void alpha_translate_init(void)
 {
 #define DEF_VAR(V)  { &cpu_##V, #V, offsetof(CPUAlphaState, V) }
@@ -2905,7 +2910,7 @@ static void alpha_tr_translate_insn(DisasContextBase *dcbase, CPUState *cpu)
 {
     DisasContext *ctx = container_of(dcbase, DisasContext, base);
     uint32_t insn = translator_ldl_end(cpu_env(cpu), &ctx->base,
-                                       ctx->base.pc_next, MO_TE);
+                                       ctx->base.pc_next, mo_endian(ctx));
 
     ctx->base.pc_next += 4;
     ctx->base.is_jmp = translate_one(ctx, insn);
-- 
2.52.0


Re: [PATCH v2 5/8] target/alpha: Factor mo_endian() helper out
Posted by Richard Henderson 1 month ago
On 1/7/26 02:57, Philippe Mathieu-Daudé wrote:
> Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
> ---
>   target/alpha/translate.c | 7 ++++++-
>   1 file changed, 6 insertions(+), 1 deletion(-)
> 
> diff --git a/target/alpha/translate.c b/target/alpha/translate.c
> index 3be97057465..4f918cbfe63 100644
> --- a/target/alpha/translate.c
> +++ b/target/alpha/translate.c
> @@ -96,6 +96,11 @@ static TCGv cpu_lock_value;
>   static TCGv cpu_pal_ir[31];
>   #endif
>   
> +static inline MemOp mo_endian(DisasContext *dc)
> +{
> +    return MO_TE;
> +}
> +
>   void alpha_translate_init(void)
>   {
>   #define DEF_VAR(V)  { &cpu_##V, #V, offsetof(CPUAlphaState, V) }
> @@ -2905,7 +2910,7 @@ static void alpha_tr_translate_insn(DisasContextBase *dcbase, CPUState *cpu)
>   {
>       DisasContext *ctx = container_of(dcbase, DisasContext, base);
>       uint32_t insn = translator_ldl_end(cpu_env(cpu), &ctx->base,
> -                                       ctx->base.pc_next, MO_TE);
> +                                       ctx->base.pc_next, mo_endian(ctx));
>   
>       ctx->base.pc_next += 4;
>       ctx->base.is_jmp = translate_one(ctx, insn);

I don't think we need this or the next.
The note about big-endian cray alpha was a mere curiosity.

r~

Re: [PATCH v2 5/8] target/alpha: Factor mo_endian() helper out
Posted by Philippe Mathieu-Daudé 1 month ago
On 6/1/26 20:00, Richard Henderson wrote:
> On 1/7/26 02:57, Philippe Mathieu-Daudé wrote:
>> Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
>> ---
>>   target/alpha/translate.c | 7 ++++++-
>>   1 file changed, 6 insertions(+), 1 deletion(-)
>>
>> diff --git a/target/alpha/translate.c b/target/alpha/translate.c
>> index 3be97057465..4f918cbfe63 100644
>> --- a/target/alpha/translate.c
>> +++ b/target/alpha/translate.c
>> @@ -96,6 +96,11 @@ static TCGv cpu_lock_value;
>>   static TCGv cpu_pal_ir[31];
>>   #endif
>> +static inline MemOp mo_endian(DisasContext *dc)
>> +{
>> +    return MO_TE;
>> +}
>> +
>>   void alpha_translate_init(void)
>>   {
>>   #define DEF_VAR(V)  { &cpu_##V, #V, offsetof(CPUAlphaState, V) }
>> @@ -2905,7 +2910,7 @@ static void 
>> alpha_tr_translate_insn(DisasContextBase *dcbase, CPUState *cpu)
>>   {
>>       DisasContext *ctx = container_of(dcbase, DisasContext, base);
>>       uint32_t insn = translator_ldl_end(cpu_env(cpu), &ctx->base,
>> -                                       ctx->base.pc_next, MO_TE);
>> +                                       ctx->base.pc_next, 
>> mo_endian(ctx));
>>       ctx->base.pc_next += 4;
>>       ctx->base.is_jmp = translate_one(ctx, insn);
> 
> I don't think we need this or the next.

Shouldn't we define mo_endian() for each target for consistency?

> The note about big-endian cray alpha was a mere curiosity.

Well, I like it and it doesn't hurt :)

Re: [PATCH v2 5/8] target/alpha: Factor mo_endian() helper out
Posted by Richard Henderson 1 month ago
On 1/7/26 07:05, Philippe Mathieu-Daudé wrote:
> On 6/1/26 20:00, Richard Henderson wrote:
>> On 1/7/26 02:57, Philippe Mathieu-Daudé wrote:
>>> Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
>>> ---
>>>   target/alpha/translate.c | 7 ++++++-
>>>   1 file changed, 6 insertions(+), 1 deletion(-)
>>>
>>> diff --git a/target/alpha/translate.c b/target/alpha/translate.c
>>> index 3be97057465..4f918cbfe63 100644
>>> --- a/target/alpha/translate.c
>>> +++ b/target/alpha/translate.c
>>> @@ -96,6 +96,11 @@ static TCGv cpu_lock_value;
>>>   static TCGv cpu_pal_ir[31];
>>>   #endif
>>> +static inline MemOp mo_endian(DisasContext *dc)
>>> +{
>>> +    return MO_TE;
>>> +}
>>> +
>>>   void alpha_translate_init(void)
>>>   {
>>>   #define DEF_VAR(V)  { &cpu_##V, #V, offsetof(CPUAlphaState, V) }
>>> @@ -2905,7 +2910,7 @@ static void alpha_tr_translate_insn(DisasContextBase *dcbase, 
>>> CPUState *cpu)
>>>   {
>>>       DisasContext *ctx = container_of(dcbase, DisasContext, base);
>>>       uint32_t insn = translator_ldl_end(cpu_env(cpu), &ctx->base,
>>> -                                       ctx->base.pc_next, MO_TE);
>>> +                                       ctx->base.pc_next, mo_endian(ctx));
>>>       ctx->base.pc_next += 4;
>>>       ctx->base.is_jmp = translate_one(ctx, insn);
>>
>> I don't think we need this or the next.
> 
> Shouldn't we define mo_endian() for each target for consistency?

Eh.  You wouldn't suggest this for x86, surely?


r~