2018-08-27 23:45:51 +08:00
|
|
|
; RUN: llc < %s -asm-verbose=false -disable-wasm-fallthrough-return-opt -wasm-keep-registers | FileCheck %s
|
2018-01-20 01:45:54 +08:00
|
|
|
|
|
|
|
; Test a subset of compiler-rt/libm libcalls expected to be emitted by the wasm backend
|
|
|
|
|
|
|
|
target datalayout = "e-m:e-p:32:32-i64:64-n32:64-S128"
|
2018-05-11 01:49:11 +08:00
|
|
|
target triple = "wasm32-unknown-unknown"
|
2018-01-20 01:45:54 +08:00
|
|
|
|
|
|
|
declare fp128 @llvm.sqrt.f128(fp128)
|
|
|
|
declare fp128 @llvm.floor.f128(fp128)
|
|
|
|
declare fp128 @llvm.trunc.f128(fp128)
|
|
|
|
declare fp128 @llvm.nearbyint.f128(fp128)
|
|
|
|
declare fp128 @llvm.pow.f128(fp128, fp128)
|
2020-02-08 10:20:03 +08:00
|
|
|
declare fp128 @llvm.powi.f128(fp128, i32)
|
2018-01-20 01:45:54 +08:00
|
|
|
|
|
|
|
declare double @llvm.cos.f64(double)
|
|
|
|
declare double @llvm.log10.f64(double)
|
2019-05-24 08:15:04 +08:00
|
|
|
declare double @llvm.pow.f64(double, double)
|
2020-02-08 10:20:03 +08:00
|
|
|
declare double @llvm.powi.f64(double, i32)
|
2019-05-24 08:15:04 +08:00
|
|
|
declare double @llvm.log.f64(double)
|
|
|
|
declare double @llvm.exp.f64(double)
|
|
|
|
declare i32 @llvm.lround(double)
|
|
|
|
|
2018-01-20 01:45:54 +08:00
|
|
|
|
|
|
|
|
|
|
|
; CHECK-LABEL: fp128libcalls:
|
2020-02-08 10:20:03 +08:00
|
|
|
define fp128 @fp128libcalls(fp128 %x, fp128 %y, i32 %z) {
|
2018-01-20 01:45:54 +08:00
|
|
|
; compiler-rt call
|
|
|
|
; CHECK: call __addtf3
|
|
|
|
%a = fadd fp128 %x, %y
|
|
|
|
; CHECK: call __multf3
|
|
|
|
%b = fmul fp128 %a, %y
|
|
|
|
; CHECK: call __divtf3
|
|
|
|
%c = fdiv fp128 %b, %y
|
|
|
|
; libm calls
|
|
|
|
; CHECK: call sqrtl
|
|
|
|
%d = call fp128 @llvm.sqrt.f128(fp128 %c)
|
|
|
|
; CHECK: call floorl
|
|
|
|
%e = call fp128 @llvm.floor.f128(fp128 %d)
|
|
|
|
; CHECK: call powl
|
|
|
|
%f = call fp128 @llvm.pow.f128(fp128 %e, fp128 %y)
|
2020-02-08 10:20:03 +08:00
|
|
|
; CHECK: call __powitf2
|
|
|
|
%g = call fp128 @llvm.powi.f128(fp128 %f, i32 %z)
|
2018-01-20 01:45:54 +08:00
|
|
|
; CHECK: call truncl
|
2020-02-08 10:20:03 +08:00
|
|
|
%h = call fp128 @llvm.trunc.f128(fp128 %g)
|
2018-01-20 01:45:54 +08:00
|
|
|
; CHECK: call nearbyintl
|
2020-02-08 10:20:03 +08:00
|
|
|
%i = call fp128 @llvm.nearbyint.f128(fp128 %h)
|
|
|
|
ret fp128 %i
|
2018-01-20 01:45:54 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
; CHECK-LABEL: i128libcalls:
|
|
|
|
define i128 @i128libcalls(i128 %x, i128 %y) {
|
|
|
|
; Basic ops should be expanded
|
|
|
|
; CHECK_NOT: call
|
|
|
|
%a = add i128 %x, %y
|
|
|
|
; CHECK: call __multi3
|
|
|
|
%b = mul i128 %a, %y
|
|
|
|
; CHECK: call __umodti3
|
|
|
|
%c = urem i128 %b, %y
|
|
|
|
ret i128 %c
|
|
|
|
}
|
|
|
|
|
|
|
|
; CHECK-LABEL: f64libcalls:
|
2020-02-08 10:20:03 +08:00
|
|
|
define i32 @f64libcalls(double %x, double %y, i32 %z) {
|
[WebAssembly] Replace all calls with generalized multivalue calls
Summary:
Extends the multivalue call infrastructure to tail calls, removes all
legacy calls specialized for particular result types, and removes the
CallIndirectFixup pass, since all indirect call arguments are now
fixed up directly in the post-insertion hook.
In order to keep supporting pretty-printed defs and uses in test
expectations, MCInstLower now inserts an immediate containing the
number of defs for each call and call_indirect. The InstPrinter is
updated to query this immediate if it is present and determine which
MCOperands are defs and uses accordingly.
Depends on D72902.
Reviewers: aheejin
Subscribers: dschuff, mgorny, sbc100, jgravelle-google, hiraditya, sunfish, llvm-commits
Tags: #llvm
Differential Revision: https://reviews.llvm.org/D74192
2020-02-07 08:29:59 +08:00
|
|
|
; CHECK: call $push{{[0-9]}}=, cos
|
2018-01-20 01:45:54 +08:00
|
|
|
%a = call double @llvm.cos.f64(double %x)
|
[WebAssembly] Replace all calls with generalized multivalue calls
Summary:
Extends the multivalue call infrastructure to tail calls, removes all
legacy calls specialized for particular result types, and removes the
CallIndirectFixup pass, since all indirect call arguments are now
fixed up directly in the post-insertion hook.
In order to keep supporting pretty-printed defs and uses in test
expectations, MCInstLower now inserts an immediate containing the
number of defs for each call and call_indirect. The InstPrinter is
updated to query this immediate if it is present and determine which
MCOperands are defs and uses accordingly.
Depends on D72902.
Reviewers: aheejin
Subscribers: dschuff, mgorny, sbc100, jgravelle-google, hiraditya, sunfish, llvm-commits
Tags: #llvm
Differential Revision: https://reviews.llvm.org/D74192
2020-02-07 08:29:59 +08:00
|
|
|
; CHECK: call $push{{[0-9]}}=, log10
|
2018-01-20 01:45:54 +08:00
|
|
|
%b = call double @llvm.log10.f64(double %a)
|
[WebAssembly] Replace all calls with generalized multivalue calls
Summary:
Extends the multivalue call infrastructure to tail calls, removes all
legacy calls specialized for particular result types, and removes the
CallIndirectFixup pass, since all indirect call arguments are now
fixed up directly in the post-insertion hook.
In order to keep supporting pretty-printed defs and uses in test
expectations, MCInstLower now inserts an immediate containing the
number of defs for each call and call_indirect. The InstPrinter is
updated to query this immediate if it is present and determine which
MCOperands are defs and uses accordingly.
Depends on D72902.
Reviewers: aheejin
Subscribers: dschuff, mgorny, sbc100, jgravelle-google, hiraditya, sunfish, llvm-commits
Tags: #llvm
Differential Revision: https://reviews.llvm.org/D74192
2020-02-07 08:29:59 +08:00
|
|
|
; CHECK: call $push{{[0-9]}}=, pow
|
2019-05-24 08:15:04 +08:00
|
|
|
%c = call double @llvm.pow.f64(double %b, double %y)
|
[WebAssembly] Replace all calls with generalized multivalue calls
Summary:
Extends the multivalue call infrastructure to tail calls, removes all
legacy calls specialized for particular result types, and removes the
CallIndirectFixup pass, since all indirect call arguments are now
fixed up directly in the post-insertion hook.
In order to keep supporting pretty-printed defs and uses in test
expectations, MCInstLower now inserts an immediate containing the
number of defs for each call and call_indirect. The InstPrinter is
updated to query this immediate if it is present and determine which
MCOperands are defs and uses accordingly.
Depends on D72902.
Reviewers: aheejin
Subscribers: dschuff, mgorny, sbc100, jgravelle-google, hiraditya, sunfish, llvm-commits
Tags: #llvm
Differential Revision: https://reviews.llvm.org/D74192
2020-02-07 08:29:59 +08:00
|
|
|
; CHECK: call $push{{[0-9]}}=, __powidf2
|
2020-02-08 10:20:03 +08:00
|
|
|
%d = call double @llvm.powi.f64(double %c, i32 %z)
|
[WebAssembly] Replace all calls with generalized multivalue calls
Summary:
Extends the multivalue call infrastructure to tail calls, removes all
legacy calls specialized for particular result types, and removes the
CallIndirectFixup pass, since all indirect call arguments are now
fixed up directly in the post-insertion hook.
In order to keep supporting pretty-printed defs and uses in test
expectations, MCInstLower now inserts an immediate containing the
number of defs for each call and call_indirect. The InstPrinter is
updated to query this immediate if it is present and determine which
MCOperands are defs and uses accordingly.
Depends on D72902.
Reviewers: aheejin
Subscribers: dschuff, mgorny, sbc100, jgravelle-google, hiraditya, sunfish, llvm-commits
Tags: #llvm
Differential Revision: https://reviews.llvm.org/D74192
2020-02-07 08:29:59 +08:00
|
|
|
; CHECK: call $push{{[0-9]}}=, log
|
2020-02-08 10:20:03 +08:00
|
|
|
%e = call double @llvm.log.f64(double %d)
|
[WebAssembly] Replace all calls with generalized multivalue calls
Summary:
Extends the multivalue call infrastructure to tail calls, removes all
legacy calls specialized for particular result types, and removes the
CallIndirectFixup pass, since all indirect call arguments are now
fixed up directly in the post-insertion hook.
In order to keep supporting pretty-printed defs and uses in test
expectations, MCInstLower now inserts an immediate containing the
number of defs for each call and call_indirect. The InstPrinter is
updated to query this immediate if it is present and determine which
MCOperands are defs and uses accordingly.
Depends on D72902.
Reviewers: aheejin
Subscribers: dschuff, mgorny, sbc100, jgravelle-google, hiraditya, sunfish, llvm-commits
Tags: #llvm
Differential Revision: https://reviews.llvm.org/D74192
2020-02-07 08:29:59 +08:00
|
|
|
; CHECK: call $push{{[0-9]}}=, exp
|
2020-02-08 10:20:03 +08:00
|
|
|
%f = call double @llvm.exp.f64(double %e)
|
[WebAssembly] Replace all calls with generalized multivalue calls
Summary:
Extends the multivalue call infrastructure to tail calls, removes all
legacy calls specialized for particular result types, and removes the
CallIndirectFixup pass, since all indirect call arguments are now
fixed up directly in the post-insertion hook.
In order to keep supporting pretty-printed defs and uses in test
expectations, MCInstLower now inserts an immediate containing the
number of defs for each call and call_indirect. The InstPrinter is
updated to query this immediate if it is present and determine which
MCOperands are defs and uses accordingly.
Depends on D72902.
Reviewers: aheejin
Subscribers: dschuff, mgorny, sbc100, jgravelle-google, hiraditya, sunfish, llvm-commits
Tags: #llvm
Differential Revision: https://reviews.llvm.org/D74192
2020-02-07 08:29:59 +08:00
|
|
|
; CHECK: call $push{{[0-9]}}=, cbrt
|
2020-02-08 07:01:34 +08:00
|
|
|
%g = call fast double @llvm.pow.f64(double %f, double 0x3FD5555555555555)
|
[WebAssembly] Replace all calls with generalized multivalue calls
Summary:
Extends the multivalue call infrastructure to tail calls, removes all
legacy calls specialized for particular result types, and removes the
CallIndirectFixup pass, since all indirect call arguments are now
fixed up directly in the post-insertion hook.
In order to keep supporting pretty-printed defs and uses in test
expectations, MCInstLower now inserts an immediate containing the
number of defs for each call and call_indirect. The InstPrinter is
updated to query this immediate if it is present and determine which
MCOperands are defs and uses accordingly.
Depends on D72902.
Reviewers: aheejin
Subscribers: dschuff, mgorny, sbc100, jgravelle-google, hiraditya, sunfish, llvm-commits
Tags: #llvm
Differential Revision: https://reviews.llvm.org/D74192
2020-02-07 08:29:59 +08:00
|
|
|
; CHECK: call $push{{[0-9]}}=, lround
|
2020-02-08 07:01:34 +08:00
|
|
|
%h = call i32 @llvm.lround(double %g)
|
|
|
|
ret i32 %h
|
2018-01-20 01:45:54 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
; fcmp ord and unord (RTLIB::O_F32 / RTLIB::UO_F32 etc) are a special case (see
|
|
|
|
; comment in WebAssemblyRunimeLibcallSignatures.cpp) so check them separately.
|
|
|
|
; no libcalls are needed for f32 and f64
|
|
|
|
|
|
|
|
; CHECK-LABEL: unordd:
|
|
|
|
define i1 @unordd(double %x, double %y) {
|
|
|
|
; CHECK-NOT: call
|
|
|
|
; CHECK: f64.ne
|
|
|
|
%a = fcmp uno double %x, %y
|
|
|
|
; CHECK-NOT: call
|
|
|
|
; CHECK: f64.eq
|
|
|
|
%b = fcmp ord double %x, %y
|
|
|
|
; CHECK: i32.xor
|
|
|
|
%c = xor i1 %a, %b
|
|
|
|
ret i1 %c
|
|
|
|
}
|
|
|
|
|
|
|
|
; CHECK-LABEL: unordf:
|
|
|
|
define i1 @unordf(float %x, float %y) {
|
|
|
|
; CHECK-NOT: call
|
|
|
|
; CHECK: f32.ne
|
|
|
|
%a = fcmp uno float %x, %y
|
|
|
|
; CHECK-NOT: call
|
|
|
|
; CHECK: f32.eq
|
|
|
|
%b = fcmp ord float %x, %y
|
|
|
|
; CHECK: i32.xor
|
|
|
|
%c = xor i1 %a, %b
|
|
|
|
ret i1 %c
|
|
|
|
}
|
|
|
|
|
|
|
|
; CHECK-LABEL: unordt:
|
|
|
|
define i1 @unordt(fp128 %x, fp128 %y) {
|
[WebAssembly] Replace all calls with generalized multivalue calls
Summary:
Extends the multivalue call infrastructure to tail calls, removes all
legacy calls specialized for particular result types, and removes the
CallIndirectFixup pass, since all indirect call arguments are now
fixed up directly in the post-insertion hook.
In order to keep supporting pretty-printed defs and uses in test
expectations, MCInstLower now inserts an immediate containing the
number of defs for each call and call_indirect. The InstPrinter is
updated to query this immediate if it is present and determine which
MCOperands are defs and uses accordingly.
Depends on D72902.
Reviewers: aheejin
Subscribers: dschuff, mgorny, sbc100, jgravelle-google, hiraditya, sunfish, llvm-commits
Tags: #llvm
Differential Revision: https://reviews.llvm.org/D74192
2020-02-07 08:29:59 +08:00
|
|
|
; CHECK: call $push[[CALL:[0-9]]]=, __unordtf2
|
2018-01-20 01:45:54 +08:00
|
|
|
; CHECK-NEXT: i32.const $push[[ZERO:[0-9]+]]=, 0
|
|
|
|
; CHECK-NEXT: i32.ne $push{{[0-9]}}=, $pop[[CALL]], $pop[[ZERO]]
|
|
|
|
%a = fcmp uno fp128 %x, %y
|
|
|
|
ret i1 %a
|
|
|
|
}
|
|
|
|
|
|
|
|
; CHECK-LABEL: ordt:
|
|
|
|
define i1 @ordt(fp128 %x, fp128 %y) {
|
[WebAssembly] Replace all calls with generalized multivalue calls
Summary:
Extends the multivalue call infrastructure to tail calls, removes all
legacy calls specialized for particular result types, and removes the
CallIndirectFixup pass, since all indirect call arguments are now
fixed up directly in the post-insertion hook.
In order to keep supporting pretty-printed defs and uses in test
expectations, MCInstLower now inserts an immediate containing the
number of defs for each call and call_indirect. The InstPrinter is
updated to query this immediate if it is present and determine which
MCOperands are defs and uses accordingly.
Depends on D72902.
Reviewers: aheejin
Subscribers: dschuff, mgorny, sbc100, jgravelle-google, hiraditya, sunfish, llvm-commits
Tags: #llvm
Differential Revision: https://reviews.llvm.org/D74192
2020-02-07 08:29:59 +08:00
|
|
|
; CHECK: call $push[[CALL:[0-9]]]=, __unordtf2
|
2018-01-20 01:45:54 +08:00
|
|
|
; CHECK-NEXT: i32.eqz $push{{[0-9]}}=, $pop[[CALL]]
|
|
|
|
%a = fcmp ord fp128 %x, %y
|
|
|
|
ret i1 %a
|
|
|
|
}
|