Skip to content

Commit

Permalink
[WebAssembly] Support fp reg class in r constraint
Browse files Browse the repository at this point in the history
Patch by snek

Reviewed By: aheejin

Differential Revision: https://reviews.llvm.org/D90978
  • Loading branch information
devsnek authored and aheejin committed Nov 19, 2020
1 parent 5747380 commit 803af31
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 0 deletions.
10 changes: 10 additions & 0 deletions llvm/lib/Target/WebAssembly/WebAssemblyISelLowering.cpp
Expand Up @@ -563,6 +563,16 @@ WebAssemblyTargetLowering::getRegForInlineAsmConstraint(
if (VT.getSizeInBits() <= 64)
return std::make_pair(0U, &WebAssembly::I64RegClass);
}
if (VT.isFloatingPoint() && !VT.isVector()) {
switch (VT.getSizeInBits()) {
case 32:
return std::make_pair(0U, &WebAssembly::F32RegClass);
case 64:
return std::make_pair(0U, &WebAssembly::F64RegClass);
default:
break;
}
}
break;
default:
break;
Expand Down
26 changes: 26 additions & 0 deletions llvm/test/CodeGen/WebAssembly/inline-asm.ll
Expand Up @@ -46,6 +46,32 @@ entry:
ret i64 %0
}

; CHECK-LABEL: foo_float:
; CHECK-NEXT: .functype foo_float (f32) -> (f32){{$}}
; CHECK-NEXT: #APP{{$}}
; CHECK-NEXT: # 0 = aaa(0){{$}}
; CHECK-NEXT: #NO_APP{{$}}
; CHECK-NEXT: local.get $push0=, 0{{$}}
; CHECK-NEXT: return $pop0{{$}}
define float @foo_float(float %r) {
entry:
%0 = tail call float asm sideeffect "# $0 = aaa($1)", "=r,r"(float %r) #0, !srcloc !0
ret float %0
}

; CHECK-LABEL: foo_double:
; CHECK-NEXT: .functype foo_double (f64) -> (f64){{$}}
; CHECK-NEXT: #APP{{$}}
; CHECK-NEXT: # 0 = aaa(0){{$}}
; CHECK-NEXT: #NO_APP{{$}}
; CHECK-NEXT: local.get $push0=, 0{{$}}
; CHECK-NEXT: return $pop0{{$}}
define double @foo_double(double %r) {
entry:
%0 = tail call double asm sideeffect "# $0 = aaa($1)", "=r,r"(double %r) #0, !srcloc !0
ret double %0
}

; CHECK-LABEL: X_i16:
; CHECK: foo 1{{$}}
; CHECK: local.get $push[[S0:[0-9]+]]=, 0{{$}}
Expand Down

0 comments on commit 803af31

Please sign in to comment.