llvm / llvm/llvm-project

Support extended inline assembler statements outside of functions

Open
#210,218 3 comments 0 reactions 0 assignees View on GitHub
inline-asm
Dominant language
LLVM
Stars
40.5k
Forks
18.7k
PR merge metrics
PR metrics pending

Description

[GCC 15](https://gcc.gnu.org/gcc-15/changes.html#c-family) introduced support for using extended inline assembler statements outside of functions (with some limitations). New constraints have been added for defining symbols or using symbols inside of inline assembler, and a new generic operand modifier has been added to allow printing those regardless of PIC. For example:

```c++
struct S { int a, b, c; };
extern foo(void);
extern char var;
int var2;
asm (".text; %cc0: mov %cc2, %%r0; .previous;"
".rodata: %cc1: .byte %3; .previous" : :
":" (foo), /* Tell compiler asm defines foo function. */
":" (&var), /* Tell compiler asm defines var variable. */
"-s" (var2), /* Tell compiler asm uses var2 variable. */
/* "s" would work too but might not work with -fpic. */
"i" (sizeof(struct S))); /* It is possible to pass constants to toplevel asm. */
```

Having this support in Clang would be beneficial even within LLVM, see https://github.com/llvm/llvm-project/pull/208330 and https://github.com/llvm/llvm-project/pull/209928.

Contributor guide

Open the contributing guide

Research direction

Start by reading the GCC 15 changes entry and the two linked LLVM pull requests to understand the proposed extended inline assembler behavior and limitations. Compare that behavior with Clang's existing inline assembler support. Done means Clang supports extended inline assembler statements outside functions, including the described symbol constraints and generic operand modifier.

Written by the indexing model from the issue text.

Assessment

Tech stack
cpp
Domain
compilers
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Quiet
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.