llvm / llvm-project

The LLVM Project is a collection of modular and reusable compiler and toolchain technologies.
http://llvm.org
Other
28.06k stars 11.59k forks source link

Allow reserving CPU registers at block level #64239

Open KOLANICH opened 1 year ago

KOLANICH commented 1 year ago

Related: #64232

According to GCC docs

register uint64_t a asm ("%rax");

syntax doesn't reserve a register, it just allows to pass info to and from asm blocks.

It'd be nice to have some syntax allowing to guide a compiler into avoiding cloberring a register for anything else, and restore it before the places it is used if any places where the compiler couldn't proove it is unused had happenned.

llvmbot commented 11 months ago

@llvm/issue-subscribers-backend-x86

Related: #64232 [According to GCC docs](https://gcc.gnu.org/onlinedocs/gcc/extensions-to-the-c-language-family/how-to-use-inline-assembly-language-in-c-code.html#local-register-variables) ```c++ register uint64_t a asm ("%rax"); ``` syntax doesn't reserve a register, it just allows to pass info to and from `asm` blocks. It'd be nice to have some syntax allowing to guide a compiler into avoiding cloberring a register for anything else, and restore it before the places it is used if any places where the compiler couldn't proove it is unused had happenned.