Re: [PATCH] LoongArch: Add unaligned access support

From: Xi Ruoyao
Date: Sun Oct 16 2022 - 11:05:10 EST


On Sun, 2022-10-16 at 21:34 +0800, Huacai Chen wrote:

> Loongson-2 series (Loongson-2K500, Loongson-2K1000)

"2K1000LA"? "2K1000" is puzzling because of a name conflict with the
MIPS-based model.

/* snip */

> +static inline unsigned long read_fpr(unsigned int fd)
> +{
> +#define READ_FPR(fd, __value)          \
> +{                                      \

Unnecessary curly brace pair.

> +       __asm__ __volatile__(           \
> +       "movfr2gr.d\t%0, $f%1\n\t"      \
> +       : "=r"(__value) : "i"(fd));     \
> +}

I'm not sure if this is a correct use of "i" constraint. Maybe we
should just concatenate the string?

"movfr2gr.d\t%0, $f" #fd "\n\t"

> +
> +       unsigned long __value;
> +
> +       switch (fd) {

I don't like this "very long" switch statement, but it seems we have no
way to make it better...

> +       case 0:
> +               READ_FPR(0, __value);
> +               break;
> +       case 1:
> +               READ_FPR(1, __value);
> +               break;
> +       case 2:
> +               READ_FPR(2, __value);
> +               break;

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