================
@@ -16303,6 +16303,56 @@ Example:
         call void @llvm.call.preallocated.teardown(token %cs)
         ret void
 
+.. _int_asm_constraint_br:
+
+'``llvm.asm.constraint.br``'
+^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+
+Syntax:
+"""""""
+
+::
+
+      declare void @llvm.asm.constraint.br()
+
+Overview:
+"""""""""
+
+The '``llvm.asm.constraint.br``' intrinsic is used when an inline asm
+constraint allows for either register or memory, e.g., '``"rm"``'.
+
+Semantics:
+""""""""""
+
+The '``llvm.asm.constraint.br``' allows the back-end to choose the best
+constraint rather than restricting the preferred constraint to one that may
+produce substandard code or cannot be handled by the register allocators.
+
+It can be called only by the '``callbr``' instruction. The default destination
+of the ``callbr`` contains a call to the preferred inline asm, while the single
+indirect destination contains a call to the pessimal inline asm.
+
+Example:
+""""""""
+
+.. code-block:: llvm
+
+      %out = alloca i64, align 8
+      callbr void @llvm.asm.constraint.br()
+              to label %asm.pref.reg [label %asm.pref.mem]
+
+    asm.pref.reg:
+      %0 = tail call i64 asm sideeffect "pushf ; pop $0", 
"=rm,~{dirflag},~{fpsr},~{flags}"()
+      br label %asm.merge
+
+    asm.pref.mem:
+      call void asm sideeffect "pushf ; pop $0", 
"=*rm,~{dirflag},~{fpsr},~{flags}"(ptr nonnull elementtype(i64) %out)
----------------
nickdesaulniers wrote:

I feel like it might be worth noting in this case that we _could_ remove the 
`r` from the constraint in this Instruction, but then we wouldn't have a simple 
reuse of codegen from the front end.  Not sure where that comment best belongs, 
perhaps where we do the clang/lib/CodeGen/* ?

https://github.com/llvm/llvm-project/pull/197798
_______________________________________________
cfe-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to