Skip to content

Commit

Permalink
[AArch64][Inline-Asm] Return the 32-bit floating point register class
Browse files Browse the repository at this point in the history
when constraint "w" is used on a 32-bit operand.

This enables compiling the following code, which used to error out in
the backend:

void foo1(int a) {
  asm volatile ("sqxtn h0, %s0\n" : : "w"(a):);
}

Fixes PR28633.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@276344 91177308-0d34-0410-b5e6-96231b3b80d8
  • Loading branch information
ahatanaka committed Jul 21, 2016
1 parent f517b9f commit 477502e
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 1 deletion.
2 changes: 1 addition & 1 deletion lib/Target/AArch64/AArch64ISelLowering.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4703,7 +4703,7 @@ AArch64TargetLowering::getRegForInlineAsmConstraint(
return std::make_pair(0U, &AArch64::GPR64commonRegClass);
return std::make_pair(0U, &AArch64::GPR32commonRegClass);
case 'w':
if (VT == MVT::f32)
if (VT.getSizeInBits() == 32)
return std::make_pair(0U, &AArch64::FPR32RegClass);
if (VT.getSizeInBits() == 64)
return std::make_pair(0U, &AArch64::FPR64RegClass);
Expand Down
8 changes: 8 additions & 0 deletions test/CodeGen/AArch64/arm64-inline-asm.ll
Original file line number Diff line number Diff line change
Expand Up @@ -246,3 +246,11 @@ define <4 x float> @test_vreg_128bit(<4 x float> %in) nounwind {
; CHECK fadd v14.4s, v0.4s, v0.4s:
ret <4 x float> %1
}

define void @test_constraint_w(i32 %a) {
; CHECK: fmov [[SREG:s[0-9]+]], {{w[0-9]+}}
; CHECK: sqxtn h0, [[SREG]]

tail call void asm sideeffect "sqxtn h0, ${0:s}\0A", "w"(i32 %a)
ret void
}

0 comments on commit 477502e

Please sign in to comment.