[libc-commits] [PATCH] D118099: [libc][NFC] Fix GCC inline asm compilation problems + workaround clang assertion

Siva Chandra via Phabricator via libc-commits libc-commits at lists.llvm.org
Tue Jan 25 14:33:13 PST 2022


sivachandra added a comment.

In D118099#3270766 <https://reviews.llvm.org/D118099#3270766>, @mcgrathr wrote:

> In the case of "f" vs "t" I think this is a misuse of the constraint semantics, which are specified by GCC.  The "t" constraint for x86 is a specific register, not a class of registers.  In GCC, when two operands must actually be the same thing exactly then this must be specified directly by using a matching constraint (just digits).  So here, you need to use "=t" in the output and then "0" in the input to say that the input operand must be identical to the output operand.  Otherwise you're saying they should be two separate operands that both meet the "t" constraint.  Since that constraint is only met by a single register, that's impossible.  Using the "f" constraint tells it to use some other x87 register, which won't be the actual input to the machine instruction.

Thanks for explaining. I verified that using the `"0"` modifier for the input argument fixes the GCC problem. Without that, the error GCC was giving was:

  error: output operand 0 must use '&' constraint
      3 |     __asm__ __volatile__("fsqrt" : "=t"(out) : "t"(in));

Which got me to add `=&` constraint to the output operand and GCC promptly complained about the "impossible constraint" that you have explained.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D118099/new/

https://reviews.llvm.org/D118099



More information about the libc-commits mailing list