[ARM] Allow 64- and 128-bit types with 't' inline asm constraint
authorPablo Barrio <pablo.barrio@arm.com>
Thu, 15 Feb 2018 14:44:22 +0000 (14:44 +0000)
committerPablo Barrio <pablo.barrio@arm.com>
Thu, 15 Feb 2018 14:44:22 +0000 (14:44 +0000)
commite28cb8399a057bbe97002d7da78af18a6d56e4ff
treea568971e61fb9d574badba82616570de65037ecb
parent17bb6f0755876354428e0b88926905ad6e631c1a
[ARM] Allow 64- and 128-bit types with 't' inline asm constraint

Summary:
In LLVM, 't' selects a floating-point/SIMD register and only supports
32-bit values. This is appropriately documented in the LLVM Language
Reference Manual. However, this behaviour diverges from that of GCC, where
't' selects the s0-s31 registers and its qX and dX variants depending on
additional operand modifiers (q/P).

For example, the following C code:

#include <arm_neon.h>
float32x4_t a, b, x;
asm("vadd.f32 %0, %1, %2" : "=t" (x) : "t" (a), "t" (b))

results in the following assembly if compiled with GCC:

vadd.f32 s0, s0, s1

whereas LLVM will show "error: couldn't allocate output register for
constraint 't'", since a, b, x are 128-bit variables, not 32-bit.

This patch extends the use of 't' to mean that of GCC, thus allowing
selection of the lower Q vector regs and their D/S variants. For example,
the earlier code will now compile as:

vadd.f32 q0, q0, q1

This behaviour still differs from that of GCC but I think it is actually
more correct, since LLVM picks up the right register type based on the
datatype of x, while GCC would need an extra operand modifier to achieve
the same result, as follows:

asm("vadd.f32 %q0, %q1, %q2" : "=t" (x) : "t" (a), "t" (b))

Since this is only an extension of functionality, existing code should not
be affected by this change. Note that operand modifiers q/P are already
supported by LLVM, so this patch should suffice to support inline
assembly with constraint 't' originally built for GCC.

Reviewers: grosbach, rengolin

Reviewed By: rengolin

Subscribers: rogfer01, efriedma, olista01, aemerson, javed.absar, eraman, kristof.beyls, llvm-commits

Differential Revision: https://reviews.llvm.org/D42962

llvm-svn: 325244
llvm/docs/LangRef.rst
llvm/lib/Target/ARM/ARMISelLowering.cpp
llvm/test/CodeGen/ARM/inlineasm-error-t-toofewregs.ll [new file with mode: 0644]
llvm/test/CodeGen/ARM/inlineasm.ll