1 ; RUN: llc < %s -mcpu=mvp -asm-verbose=false -disable-wasm-fallthrough-return-opt -wasm-disable-explicit-locals -wasm-keep-registers | FileCheck %s
3 ; Test zeroext and signext ABI keywords
5 target triple = "wasm32-unknown-unknown"
7 ; CHECK-LABEL: z2s_func:
8 ; CHECK-NEXT: .functype z2s_func (i32) -> (i32){{$}}
9 ; CHECK-NEXT: i32.const $push[[NUM0:[0-9]+]]=, 24{{$}}
10 ; CHECK-NEXT: i32.shl $push[[NUM2:[0-9]+]]=, $0, $pop[[NUM0]]{{$}}
11 ; CHECK-NEXT: i32.const $push[[NUM1:[0-9]+]]=, 24{{$}}
12 ; CHECK-NEXT: i32.shr_s $push[[NUM3:[0-9]+]]=, $pop[[NUM2]], $pop[[NUM1]]{{$}}
13 ; CHECK-NEXT: return $pop[[NUM3]]{{$}}
14 define signext i8 @z2s_func(i8 zeroext %t) {
18 ; CHECK-LABEL: s2z_func:
19 ; CHECK-NEXT: .functype s2z_func (i32) -> (i32){{$}}
20 ; CHECK-NEXT: i32.const $push[[NUM0:[0-9]+]]=, 255{{$}}
21 ; CHECK-NEXT: i32.and $push[[NUM1:[0-9]+]]=, $0, $pop[[NUM0]]{{$}}
22 ; CHECK-NEXT: return $pop[[NUM1]]{{$}}
23 define zeroext i8 @s2z_func(i8 signext %t) {
27 ; CHECK-LABEL: z2s_call:
28 ; CHECK-NEXT: .functype z2s_call (i32) -> (i32){{$}}
29 ; CHECK-NEXT: i32.const $push[[NUM0:[0-9]+]]=, 255{{$}}
30 ; CHECK-NEXT: i32.and $push[[NUM1:[0-9]+]]=, $0, $pop[[NUM0]]{{$}}
31 ; CHECK-NEXT: call $push[[NUM2:[0-9]+]]=, z2s_func, $pop[[NUM1]]{{$}}
32 ; CHECK-NEXT: return $pop[[NUM2]]{{$}}
33 define i32 @z2s_call(i32 %t) {
34 %s = trunc i32 %t to i8
35 %u = call signext i8 @z2s_func(i8 zeroext %s)
36 %v = sext i8 %u to i32
40 ; CHECK-LABEL: s2z_call:
41 ; CHECK-NEXT: .functype s2z_call (i32) -> (i32){{$}}
42 ; CHECK-NEXT: i32.const $push[[NUM0:[0-9]+]]=, 24{{$}}
43 ; CHECK-NEXT: i32.shl $push[[NUM1:[0-9]+]]=, $0, $pop[[NUM0]]{{$}}
44 ; CHECK-NEXT: i32.const $push[[NUM6:[0-9]+]]=, 24{{$}}
45 ; CHECK-NEXT: i32.shr_s $push[[NUM2:[0-9]+]]=, $pop[[NUM1]], $pop[[NUM6]]{{$}}
46 ; CHECK-NEXT: call $push[[NUM3:[0-9]]]=, s2z_func, $pop[[NUM2]]{{$}}
47 ; CHECK-NEXT: i32.const $push[[NUM7:[0-9]+]]=, 24{{$}}
48 ; CHECK-NEXT: i32.shl $push[[NUM4:[0-9]+]]=, $pop[[NUM3]], $pop[[NUM7]]{{$}}
49 ; CHECK-NEXT: i32.const $push[[NUM8:[0-9]+]]=, 24{{$}}
50 ; CHECK-NEXT: i32.shr_s $push[[NUM5:[0-9]+]]=, $pop[[NUM4]], $pop[[NUM8]]{{$}}
51 ; CHECK-NEXT: return $pop[[NUM5]]{{$}}
52 define i32 @s2z_call(i32 %t) {
53 %s = trunc i32 %t to i8
54 %u = call zeroext i8 @s2z_func(i8 signext %s)
55 %v = sext i8 %u to i32