[clang] [llvm] RFC: Implementing new mechanism for hard register operands to inline asm as a constraint. (PR #85846)

James Y Knight via cfe-commits cfe-commits at lists.llvm.org
Thu Mar 28 10:01:11 PDT 2024


================
@@ -1760,6 +1760,50 @@ references can be used instead of numeric references.
       return -1;
   }
 
+Hard Register Operands for ASM Constraints
+==========================================
+
+Clang supports the ability to specify specific hardware registers in inline
+assembly constraints via the use of curly braces ``{}``.
+
+Prior to clang-19, the only way to associate an inline assembly constraint
+with a specific register is via the local register variable feature (`GCC
+Specifying Registers for Local Variables <https://gcc.gnu.org/onlinedocs/gcc-6.5.0/gcc/Local-Register-Variables.html>`_). However, the local register variable association lasts for the entire
+scope of the variable.
+
+Hard register operands will instead only apply to the specific inline ASM
+statement which improves readability and solves a few other issues experienced
+by local register variables, such as:
+
+* function calls might clobber register variables
----------------
jyknight wrote:

This isn't actually an issue (at least in LLVM), since local register variables are _not_ actually assigned to the named register except when passed/returned from inline-asm statements.

https://github.com/llvm/llvm-project/pull/85846


More information about the cfe-commits mailing list