1; RUN: llc < %s -asm-verbose=false | FileCheck %s 2 3; Test that basic call operations assemble as expected. 4 5target datalayout = "e-p:32:32-i64:64-n32:64-S128" 6target triple = "wasm32-unknown-unknown" 7 8declare i32 @i32_nullary() 9declare i32 @i32_unary(i32) 10declare i32 @i32_binary(i32, i32) 11declare i64 @i64_nullary() 12declare float @float_nullary() 13declare double @double_nullary() 14declare void @void_nullary() 15 16; CHECK-LABEL: call_i32_nullary: 17; CHECK-NEXT: .result i32{{$}} 18; CHECK-NEXT: {{^}} i32.call $push[[NUM:[0-9]+]]=, i32_nullary{{$}} 19; CHECK-NEXT: return $pop[[NUM]]{{$}} 20define i32 @call_i32_nullary() { 21 %r = call i32 @i32_nullary() 22 ret i32 %r 23} 24 25; CHECK-LABEL: call_i64_nullary: 26; CHECK-NEXT: .result i64{{$}} 27; CHECK-NEXT: {{^}} i64.call $push[[NUM:[0-9]+]]=, i64_nullary{{$}} 28; CHECK-NEXT: return $pop[[NUM]]{{$}} 29define i64 @call_i64_nullary() { 30 %r = call i64 @i64_nullary() 31 ret i64 %r 32} 33 34; CHECK-LABEL: call_float_nullary: 35; CHECK-NEXT: .result f32{{$}} 36; CHECK-NEXT: {{^}} f32.call $push[[NUM:[0-9]+]]=, float_nullary{{$}} 37; CHECK-NEXT: return $pop[[NUM]]{{$}} 38define float @call_float_nullary() { 39 %r = call float @float_nullary() 40 ret float %r 41} 42 43; CHECK-LABEL: call_double_nullary: 44; CHECK-NEXT: .result f64{{$}} 45; CHECK-NEXT: {{^}} f64.call $push[[NUM:[0-9]+]]=, double_nullary{{$}} 46; CHECK-NEXT: return $pop[[NUM]]{{$}} 47define double @call_double_nullary() { 48 %r = call double @double_nullary() 49 ret double %r 50} 51 52; CHECK-LABEL: call_void_nullary: 53; CHECK-NEXT: {{^}} call void_nullary{{$}} 54; CHECK-NEXT: return{{$}} 55define void @call_void_nullary() { 56 call void @void_nullary() 57 ret void 58} 59 60; CHECK-LABEL: call_i32_unary: 61; CHECK-NEXT: .param i32{{$}} 62; CHECK-NEXT: .result i32{{$}} 63; CHECK-NEXT: {{^}} i32.call $push[[NUM:[0-9]+]]=, i32_unary, $0{{$}} 64; CHECK-NEXT: return $pop[[NUM]]{{$}} 65define i32 @call_i32_unary(i32 %a) { 66 %r = call i32 @i32_unary(i32 %a) 67 ret i32 %r 68} 69 70; CHECK-LABEL: call_i32_binary: 71; CHECK-NEXT: .param i32, i32{{$}} 72; CHECK-NEXT: .result i32{{$}} 73; CHECK-NEXT: {{^}} i32.call $push[[NUM:[0-9]+]]=, i32_binary, $0, $1{{$}} 74; CHECK-NEXT: return $pop[[NUM]]{{$}} 75define i32 @call_i32_binary(i32 %a, i32 %b) { 76 %r = call i32 @i32_binary(i32 %a, i32 %b) 77 ret i32 %r 78} 79 80; CHECK-LABEL: call_indirect_void: 81; CHECK-NEXT: .param i32{{$}} 82; CHECK-NEXT: {{^}} call_indirect $0{{$}} 83; CHECK-NEXT: return{{$}} 84define void @call_indirect_void(void ()* %callee) { 85 call void %callee() 86 ret void 87} 88 89; CHECK-LABEL: call_indirect_i32: 90; CHECK-NEXT: .param i32{{$}} 91; CHECK-NEXT: .result i32{{$}} 92; CHECK-NEXT: {{^}} i32.call_indirect $push[[NUM:[0-9]+]]=, $0{{$}} 93; CHECK-NEXT: return $pop[[NUM]]{{$}} 94define i32 @call_indirect_i32(i32 ()* %callee) { 95 %t = call i32 %callee() 96 ret i32 %t 97} 98 99; CHECK-LABEL: tail_call_void_nullary: 100; CHECK-NEXT: {{^}} call void_nullary{{$}} 101; CHECK-NEXT: return{{$}} 102define void @tail_call_void_nullary() { 103 tail call void @void_nullary() 104 ret void 105} 106 107; CHECK-LABEL: fastcc_tail_call_void_nullary: 108; CHECK-NEXT: {{^}} call void_nullary{{$}} 109; CHECK-NEXT: return{{$}} 110define void @fastcc_tail_call_void_nullary() { 111 tail call fastcc void @void_nullary() 112 ret void 113} 114 115; CHECK-LABEL: coldcc_tail_call_void_nullary: 116; CHECK-NEXT: {{^}} call void_nullary 117; CHECK-NEXT: return{{$}} 118define void @coldcc_tail_call_void_nullary() { 119 tail call coldcc void @void_nullary() 120 ret void 121} 122 123; FIXME test the following: 124; - More argument combinations. 125; - Tail call. 126; - Interesting returns (struct, multiple). 127; - Vararg. 128