public inbox for gcc-cvs@sourceware.org
help / color / mirror / Atom feed
* [gcc r14-9127] RISC-V: Add tests for constraints "i" and "s"
@ 2024-02-22  1:20 Fangrui Song
  0 siblings, 0 replies; only message in thread
From: Fangrui Song @ 2024-02-22  1:20 UTC (permalink / raw)
  To: gcc-cvs

https://gcc.gnu.org/g:9ca4c1bf082a4691482ca9f4814fea68f04e2cb3

commit r14-9127-g9ca4c1bf082a4691482ca9f4814fea68f04e2cb3
Author: Fangrui Song <maskray@gcc.gnu.org>
Date:   Tue Jan 30 20:41:12 2024 -0800

    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.

Diff:
---
 gcc/testsuite/gcc.target/riscv/asm-raw-symbol.c | 14 ++++++++++++++
 1 file changed, 14 insertions(+)

diff --git a/gcc/testsuite/gcc.target/riscv/asm-raw-symbol.c b/gcc/testsuite/gcc.target/riscv/asm-raw-symbol.c
new file mode 100644
index 000000000000..28305a8b1f0f
--- /dev/null
+++ b/gcc/testsuite/gcc.target/riscv/asm-raw-symbol.c
@@ -0,0 +1,14 @@
+/* { dg-do compile } */
+/* { dg-options "-fpic" } */
+
+extern int var, arr[2][2];
+
+void
+test (void)
+{
+  __asm__ ("@ %0" : : "i"(&var));
+  __asm__ ("@ %0 %1 %2" : : "s"(&var), "s"(&arr[1][1]), "s"(test));
+}
+
+/* { dg-final { scan-assembler "@ var arr\\+12 test" } } */
+/* { dg-final { scan-assembler "@ var" } } */

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2024-02-22  1:20 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-02-22  1:20 [gcc r14-9127] RISC-V: Add tests for constraints "i" and "s" Fangrui Song

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).