public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c/105576] New: x86: Support a machine constraint to get raw symbol name
@ 2022-05-12  5:30 i at maskray dot me
  2022-05-12  6:00 ` [Bug target/105576] " pinskia at gcc dot gnu.org
                   ` (13 more replies)
  0 siblings, 14 replies; 15+ messages in thread
From: i at maskray dot me @ 2022-05-12  5:30 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=105576

            Bug ID: 105576
           Summary: x86: Support a machine constraint to get raw symbol
                    name
           Product: gcc
           Version: 11.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c
          Assignee: unassigned at gcc dot gnu.org
          Reporter: i at maskray dot me
  Target Milestone: ---

An raw symbolic operand is useful in inline asm (e.g. in C++ to get the mangled
name, or in C to let the compiler do some asm checking). In aarch64 and riscv,
there is a documented (supported) approach.
documented on
https://gcc.gnu.org/onlinedocs/gcc/Machine-Constraints.html#Machine-Constraints

extern int var;
void *addr(void) { return &var; }
void addr_via_asm(void) {
  asm (".pushsection .xxx,\"aw\"; .dc.a %0; .popsection" :: "S"(addr)); //
supported on aarch64 and riscv
  asm (".pushsection .xxx,\"aw\"; .dc.a %0; .popsection" :: "S"(&var)); //
supported on aarch64
}

On x86, it is unclear which should be preferred. It seems that the operand
modifier 'p' can be used for a function,
but not a variable.

asm (".pushsection .xxx,\"aw\"; .dc.a %p0; .popsection" :: "m"(addr));

^ permalink raw reply	[flat|nested] 15+ messages in thread

end of thread, other threads:[~2024-05-28  5:29 UTC | newest]

Thread overview: 15+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-05-12  5:30 [Bug c/105576] New: x86: Support a machine constraint to get raw symbol name i at maskray dot me
2022-05-12  6:00 ` [Bug target/105576] " pinskia at gcc dot gnu.org
2022-05-12  6:00 ` pinskia at gcc dot gnu.org
2022-05-12  6:03 ` pinskia at gcc dot gnu.org
2022-05-12  6:36 ` crazylht at gmail dot com
2022-05-13 17:08 ` i at maskray dot me
2023-05-05  4:53 ` i at maskray dot me
2023-12-07  2:49 ` tanksherman27 at gmail dot com
2024-01-11  4:00 ` i at maskray dot me
2024-01-30 23:05 ` pinskia at gcc dot gnu.org
2024-01-30 23:21 ` cvs-commit at gcc dot gnu.org
2024-01-30 23:56 ` i at maskray dot me
2024-01-31  0:15 ` pinskia at gcc dot gnu.org
2024-05-21 16:48 ` pinskia at gcc dot gnu.org
2024-05-28  5:29 ` i at maskray dot me

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).