在 2022/3/15 下午10:35, Xi Ruoyao 写道:
On Fri, 2022-03-04 at 15:17 +0800, xucheng...@loongson.cn wrote:
v7 -> v8
1. Add new addressing type ADDRESS_REG_REG support.
2. Modify documentation.
3. Eliminate compile-time warnings.
Hi,
The v8 series does not build LoongArch Linux kernel tree
(https://github.com/loongson/linux, loongarch-next branch) successfully.
This is a regression: the v7 series built the kernel fine.
A testcase reduced from the __get_data_asm macro in uaccess.h:
$ cat t1.c
char *ptr;
int offset;
struct m
{
char a[2];
};
char
x (void)
{
char t;
asm volatile("ld.b %0, %1" : "=r"(t) : "o"(*(struct m *)(ptr + offset)));
return t;
}
$ ./gcc/cc1 t1.c -nostdinc -O
t1.c: In function ‘x’:
t1.c:12:3: error: impossible constraint in ‘asm’
12 | asm volatile("ld.b %0, %1" : "=r"(t) : "o"(*(struct m *)(ptr +
offset)));
| ^~~
It seems changing the constraint "o" to "m" can work around this issue.
I'm not sure if this is a compiler bug or a kernel bug.
Hi,
LoongArch supports memory modes as follows:
mode memory constraint
1. base + index "k"
2. base + imm12 "m"
3. base + imm16 (immediate 4-byte alignment) "ZC"
4. base + 0 "ZB"
so, this constraint should be "m".