public inbox for gcc-cvs@sourceware.org
help / color / mirror / Atom feed
From: Fangrui Song <maskray@gcc.gnu.org>
To: gcc-cvs@gcc.gnu.org
Subject: [gcc r14-9127] RISC-V: Add tests for constraints "i" and "s"
Date: Thu, 22 Feb 2024 01:20:39 +0000 (GMT)	[thread overview]
Message-ID: <20240222012039.368503858D1E@sourceware.org> (raw)

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" } } */

                 reply	other threads:[~2024-02-22  1:20 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20240222012039.368503858D1E@sourceware.org \
    --to=maskray@gcc.gnu.org \
    --cc=gcc-cvs@gcc.gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).