[PATCH] LoongArch: Add fcsr register names support

Xi Ruoyao xry111@xry111.site
Fri Jun 16 09:30:34 GMT 2023


On Fri, 2023-06-16 at 17:20 +0800, WANG Xuerui wrote:
> Hi,
> 
> On 6/14/23 12:27, Feiyang Chen wrote:
> > On Tue, Jun 13, 2023 at 5:49 PM WANG Xuerui <i.swmail@xen0n.name> wrote:
> > > 
> > > 
> > > On 2023/6/12 16:36, Feiyang Chen wrote:
> > > [snip]
> > > > @@ -142,7 +144,19 @@ dis_one_arg (char esc1, char esc2, const char *bit_field,
> > > >          info->fprintf_func (info->stream, "%s", loongarch_r_disname[u_imm]);
> > > >          break;
> > > >        case 'f':
> > > > -      info->fprintf_func (info->stream, "%s", loongarch_f_disname[u_imm]);
> > > > +      switch (esc2)
> > > > +     {
> > > > +     case 'c':
> > > > +       if (u_imm < 4)
> > > > +         info->fprintf_func (info->stream, "%s", loongarch_fc_disname[u_imm]);
> > > > +       else
> > > > +         /* For backward compatibility.  Display using general purpose
> > > > +            register names if out of range.  */
> > > > +         info->fprintf_func (info->stream, "%s", loongarch_r_normal_name[u_imm]);
> > > I don't think it's proper to call *any* of the FCSRs "GPR" (or actually,
> > > aliases to FCSR0, but that doesn't matter). What concrete scenario are
> > > you trying to keep compatible with? A test case may explain it.
> > > 
> > I agree with you, but the previous method of decoding treated "fcsr"
> > as "gr." Therefore, to ensure proper compilation of the possible old
> > code, I also need to consider "gr" as "fcsr." If you have a better
> > solution, please inform me.
> > For example, we may encounter the instruction "movgr2fcsr $r0, $r0,"
> > and it is essential to parse it correctly. On another note, I am not
> > experienced in creating test cases. Could you please assist me with
> > that?
> Sorry for the late reply. I meant not disallowing the old forms when 
> assembling, but rather removing the workaround when disassembling -- I
> can't see a reason why FCSR0 ~ FCSR3 could be displayed as-is, but other 
> unassigned but possible FCSR numbers still get displayed as GPRs; is it 
> that you're following the ISA manual's exact wording that says there are 
> only 4 FCSRs? In any case I find the special treatment a surprise and 
> not very pleasant.

To me we should display them as "FCSR4, FCSR5, ..." even we don't have
these FCSRs now.  A future LoongArch ISA revision may provide more
FCSRs, so showing FCSR{4,5,...} should be more future-proof.

-- 
Xi Ruoyao <xry111@xry111.site>
School of Aerospace Science and Technology, Xidian University


More information about the Binutils mailing list