Skip to content

Commit 9ca4c1b

Browse files
committed
RISC-V: Add tests for constraints "i" and "s"
The constraints "i" and "s" can be used with a symbol that binds externally, e.g. ``` namespace ns { extern int var, a[4]; } void foo() { asm(".pushsection .xxx,\"aw\"; .dc.a %0; .popsection" :: "s"(&ns::var)); asm(".reloc ., BFD_RELOC_NONE, %0" :: "s"(&ns::a[3])); } ``` gcc/testsuite/ChangeLog: * gcc.target/riscv/asm-raw-symbol.c: New test.
1 parent 98004ca commit 9ca4c1b

File tree

1 file changed

+14
-0
lines changed

1 file changed

+14
-0
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
/* { dg-do compile } */
2+
/* { dg-options "-fpic" } */
3+
4+
extern int var, arr[2][2];
5+
6+
void
7+
test (void)
8+
{
9+
__asm__ ("@ %0" : : "i"(&var));
10+
__asm__ ("@ %0 %1 %2" : : "s"(&var), "s"(&arr[1][1]), "s"(test));
11+
}
12+
13+
/* { dg-final { scan-assembler "@ var arr\\+12 test" } } */
14+
/* { dg-final { scan-assembler "@ var" } } */

0 commit comments

Comments
 (0)