xref: /llvm-project/llvm/test/CodeGen/WebAssembly/functype-emission.ll (revision 94830bf56cb660feb3ee7ead39cc0fbb70e0c0b5)
1; RUN: llc -mtriple=wasm32 -verify-machineinstrs < %s | FileCheck %s
2
3; Demonstrates that appropriate .functype directives are emitted for defined
4; functions, declared functions, and any libcalls.
5
6; CHECK: .functype __multi3 (i32, i64, i64, i64, i64) -> ()
7; CHECK: .functype __unordtf2 (i64, i64, i64, i64) -> (i32)
8; CHECK: .functype defined_fun_1 (f64) -> (i64)
9; CHECK: .functype defined_fun_2 (f64, i32) -> (i64)
10; CHECK: .functype declared_fun (i32, f32, i64) -> (i32)
11
12define i64 @defined_fun_1(double %a) {
13; CHECK-LABEL: defined_fun_1:
14; CHECK:         .functype defined_fun_1 (f64) -> (i64)
15  %1 = call i64 @defined_fun_2(double %a, i32 1)
16  ret i64 %1
17}
18
19define i64 @defined_fun_2(double %a, i32 %b) {
20; CHECK-LABEL: defined_fun_2:
21; CHECK:         .functype defined_fun_2 (f64, i32) -> (i64)
22  %1 = call i64 @defined_fun_1(double %a)
23  ret i64 %1
24}
25
26declare i8 @declared_fun(i32, float, i64)
27
28define i128 @libcalls(fp128 %a, fp128 %b, i128 %c, i128 %d) {
29; CHECK-LABEL: libcalls:
30; CHECK:         .functype libcalls (i32, i64, i64, i64, i64, i64, i64, i64, i64) -> ()
31 %1 = fcmp uno fp128 %a, %b
32 %2 = zext i1 %1 to i128
33 %3 = mul i128 %c, %d
34 %4 = add i128 %2, %3
35 ret i128 %4
36}
37