Skip to content

Commit

Permalink
[WebAssembly] Support fp reg class in r constraint (#83)
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 Nov 19, 2020
1 parent ee16174 commit 7ade8dc
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
Original file line number Diff line number Diff line change
Expand Up @@ -542,6 +542,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
Original file line number Diff line number Diff line change
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 7ade8dc

Please sign in to comment.