Re: [PATCH 0/6] target/mips: Convert Loongson LEXT opcodes to decodetree

2021-01-24 Thread Jiaxun Yang

在 2021/1/22 上午4:07, Richard Henderson 写道:

On 1/12/21 11:54 AM, Philippe Mathieu-Daudé wrote:

Based-on: <20210112184156.2014305-1-f4...@amsat.org>
   "decodetree: Allow 'dot' in opcode names"

I'm still unconvinced about this.  I've reviewed the code without regard to the
spelling in the decodetree files.


Should we use '_' in decodetree to replace dot?

Thanks.

- Jiaxun




r~





Re: [PATCH 0/6] target/mips: Convert Loongson LEXT opcodes to decodetree

2021-01-21 Thread Philippe Mathieu-Daudé
On 1/21/21 9:07 PM, Richard Henderson wrote:
> On 1/12/21 11:54 AM, Philippe Mathieu-Daudé wrote:
>> Based-on: <20210112184156.2014305-1-f4...@amsat.org>
>>   "decodetree: Allow 'dot' in opcode names"
> 
> I'm still unconvinced about this.  I've reviewed the code without regard to 
> the
> spelling in the decodetree files.

Understood.

Thanks for your review!

Phil.



Re: [PATCH 0/6] target/mips: Convert Loongson LEXT opcodes to decodetree

2021-01-21 Thread Richard Henderson
On 1/12/21 11:54 AM, Philippe Mathieu-Daudé wrote:
> Based-on: <20210112184156.2014305-1-f4...@amsat.org>
>   "decodetree: Allow 'dot' in opcode names"

I'm still unconvinced about this.  I've reviewed the code without regard to the
spelling in the decodetree files.


r~



Re: [PATCH 0/6] target/mips: Convert Loongson LEXT opcodes to decodetree

2021-01-13 Thread Jiaxun Yang



On Wed, Jan 13, 2021, at 4:06 PM, Philippe Mathieu-Daudé wrote:
> On 1/13/21 3:15 AM, Jiaxun Yang wrote:
> > 在 2021/1/13 上午5:54, Philippe Mathieu-Daudé 写道:
> >> Loongson is next step in the "MIPS decodetree conversion" epic.
> >> Start with the simplest extension.
> >>
> >> The diffstat addition comes from the TCG functions expanded.
> >> The code is easier to review now.
> >> IMO this is also a good template to show how easy a decodetree
> >> conversion can be (and how nice the .decode file is to review) :P
> >>
> >> Please review,
> >>
> >> Phil.
> >>
> >> Based-on: <20210112184156.2014305-1-f4...@amsat.org>
> >>    "decodetree: Allow 'dot' in opcode names"
> >>
> >> Philippe Mathieu-Daudé (6):
> >>    target/mips: Re-introduce OPC_ADDUH_QB_DSP and OPC_MUL_PH_DSP
> >>    target/mips: Convert Loongson DDIV.G opcodes to decodetree
> >>    target/mips: Convert Loongson DIV.G opcodes to decodetree
> >>    target/mips: Convert Loongson [D]DIVU.G opcodes to decodetree
> >>    target/mips: Convert Loongson [D]MOD[U].G opcodes to decodetree
> >>    target/mips: Convert Loongson [D]MULT[U].G opcodes to decodetree
> >>
> >>   target/mips/translate.h   |   1 +
> >>   target/mips/godson2.decode    |  29 +++
> >>   target/mips/loong-ext.decode  |  30 +++
> > 
> > Hi Philippe,
> > 
> > Thanks for the template!
> > 
> > Just a small question, where should we perform ISA availability check?
> > Before calling generated decoder or after decoded?
> 
> The check is done before in decode_loongson:
> 
>  bool decode_loongson(DisasContext *ctx, uint32_t insn)
>  {
>  if ((ctx->insn_flags & INSN_LOONGSON2E)
>  // if ISA available ...
>  && decode_godson2(ctx, ctx->opcode)) {
>  // and opcode supported
>  // return success
>  return true;
>  }
>  // else keep going ...
> 
>  if ((ctx->insn_flags & ASE_LEXT)
>  && decode_loong_ext(ctx, ctx->opcode)) {
>  return true;
>  }
> 
>  // finally return false, if nothing else decoded
>  // gen_reserved_instruction will be called in the
>  // main decode loop.
>  return false;
>  }
> 
> > 
> > Loong-EXT is a super set of Loongson2F's Godson2 and MMI instructions,
> > how could we tell it?
> 
> MMI instructions are currently handled by the ASE_LMMI flag,
> a different decoder (which will also be handled by this function,
> similarly to ASE_LEXT).

SWC2/LWC2/SDC2/LDC2 family of LEXT instructions do exist on LEXT but not 
Loongson-2F.

Thanks.

> 
> Regards,
> 
> Phil.
>

-- 
- Jiaxun



Re: [PATCH 0/6] target/mips: Convert Loongson LEXT opcodes to decodetree

2021-01-13 Thread Philippe Mathieu-Daudé
On Wed, Jan 13, 2021 at 9:06 AM Philippe Mathieu-Daudé  wrote:
> On 1/13/21 3:15 AM, Jiaxun Yang wrote:
> > Loong-EXT is a super set of Loongson2F's Godson2 and MMI instructions,
> > how could we tell it?
>
> MMI instructions are currently handled by the ASE_LMMI flag,
> a different decoder (which will also be handled by this function,
> similarly to ASE_LEXT).

(BTW no need to spend time converting ASE_LMMI, I already did it, I'm waiting
for the review outcome of this series before posting it).



Re: [PATCH 0/6] target/mips: Convert Loongson LEXT opcodes to decodetree

2021-01-13 Thread Philippe Mathieu-Daudé
On 1/13/21 3:15 AM, Jiaxun Yang wrote:
> 在 2021/1/13 上午5:54, Philippe Mathieu-Daudé 写道:
>> Loongson is next step in the "MIPS decodetree conversion" epic.
>> Start with the simplest extension.
>>
>> The diffstat addition comes from the TCG functions expanded.
>> The code is easier to review now.
>> IMO this is also a good template to show how easy a decodetree
>> conversion can be (and how nice the .decode file is to review) :P
>>
>> Please review,
>>
>> Phil.
>>
>> Based-on: <20210112184156.2014305-1-f4...@amsat.org>
>>    "decodetree: Allow 'dot' in opcode names"
>>
>> Philippe Mathieu-Daudé (6):
>>    target/mips: Re-introduce OPC_ADDUH_QB_DSP and OPC_MUL_PH_DSP
>>    target/mips: Convert Loongson DDIV.G opcodes to decodetree
>>    target/mips: Convert Loongson DIV.G opcodes to decodetree
>>    target/mips: Convert Loongson [D]DIVU.G opcodes to decodetree
>>    target/mips: Convert Loongson [D]MOD[U].G opcodes to decodetree
>>    target/mips: Convert Loongson [D]MULT[U].G opcodes to decodetree
>>
>>   target/mips/translate.h   |   1 +
>>   target/mips/godson2.decode    |  29 +++
>>   target/mips/loong-ext.decode  |  30 +++
> 
> Hi Philippe,
> 
> Thanks for the template!
> 
> Just a small question, where should we perform ISA availability check?
> Before calling generated decoder or after decoded?

The check is done before in decode_loongson:

 bool decode_loongson(DisasContext *ctx, uint32_t insn)
 {
 if ((ctx->insn_flags & INSN_LOONGSON2E)
 // if ISA available ...
 && decode_godson2(ctx, ctx->opcode)) {
 // and opcode supported
 // return success
 return true;
 }
 // else keep going ...

 if ((ctx->insn_flags & ASE_LEXT)
 && decode_loong_ext(ctx, ctx->opcode)) {
 return true;
 }

 // finally return false, if nothing else decoded
 // gen_reserved_instruction will be called in the
 // main decode loop.
 return false;
 }

> 
> Loong-EXT is a super set of Loongson2F's Godson2 and MMI instructions,
> how could we tell it?

MMI instructions are currently handled by the ASE_LMMI flag,
a different decoder (which will also be handled by this function,
similarly to ASE_LEXT).

Regards,

Phil.



Re: [PATCH 0/6] target/mips: Convert Loongson LEXT opcodes to decodetree

2021-01-12 Thread Jiaxun Yang

在 2021/1/13 上午5:54, Philippe Mathieu-Daudé 写道:

Loongson is next step in the "MIPS decodetree conversion" epic.
Start with the simplest extension.

The diffstat addition comes from the TCG functions expanded.
The code is easier to review now.
IMO this is also a good template to show how easy a decodetree
conversion can be (and how nice the .decode file is to review) :P

Please review,

Phil.

Based-on: <20210112184156.2014305-1-f4...@amsat.org>
   "decodetree: Allow 'dot' in opcode names"

Philippe Mathieu-Daudé (6):
   target/mips: Re-introduce OPC_ADDUH_QB_DSP and OPC_MUL_PH_DSP
   target/mips: Convert Loongson DDIV.G opcodes to decodetree
   target/mips: Convert Loongson DIV.G opcodes to decodetree
   target/mips: Convert Loongson [D]DIVU.G opcodes to decodetree
   target/mips: Convert Loongson [D]MOD[U].G opcodes to decodetree
   target/mips: Convert Loongson [D]MULT[U].G opcodes to decodetree

  target/mips/translate.h   |   1 +
  target/mips/godson2.decode|  29 +++
  target/mips/loong-ext.decode  |  30 +++


Hi Philippe,

Thanks for the template!

Just a small question, where should we perform ISA availability check?
Before calling generated decoder or after decoded?

Loong-EXT is a super set of Loongson2F's Godson2 and MMI instructions,
how could we tell it?

Thanks.

- Jiaxun


  target/mips/loong_translate.c | 334 ++
  target/mips/translate.c   | 287 ++---
  target/mips/meson.build   |   3 +
  6 files changed, 409 insertions(+), 275 deletions(-)
  create mode 100644 target/mips/godson2.decode
  create mode 100644 target/mips/loong-ext.decode
  create mode 100644 target/mips/loong_translate.c