1 ; RUN: llc < %s -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 datalayout = "e-m:e-p:32:32-i64:64-n32:64-S128"
6 target triple = "wasm32-unknown-unknown"
8 ; CHECK-LABEL: z2s_func:
9 ; CHECK-NEXT: .functype z2s_func (i32) -> (i32){{$}}
10 ; CHECK-NEXT: i32.const $push[[NUM0:[0-9]+]]=, 24{{$}}
11 ; CHECK-NEXT: i32.shl $push[[NUM2:[0-9]+]]=, $0, $pop[[NUM0]]{{$}}
12 ; CHECK-NEXT: i32.const $push[[NUM1:[0-9]+]]=, 24{{$}}
13 ; CHECK-NEXT: i32.shr_s $push[[NUM3:[0-9]+]]=, $pop[[NUM2]], $pop[[NUM1]]{{$}}
14 ; CHECK-NEXT: return $pop[[NUM3]]{{$}}
15 define signext i8 @z2s_func(i8 zeroext %t) {
19 ; CHECK-LABEL: s2z_func:
20 ; CHECK-NEXT: .functype s2z_func (i32) -> (i32){{$}}
21 ; CHECK-NEXT: i32.const $push[[NUM0:[0-9]+]]=, 255{{$}}
22 ; CHECK-NEXT: i32.and $push[[NUM1:[0-9]+]]=, $0, $pop[[NUM0]]{{$}}
23 ; CHECK-NEXT: return $pop[[NUM1]]{{$}}
24 define zeroext i8 @s2z_func(i8 signext %t) {
28 ; CHECK-LABEL: z2s_call:
29 ; CHECK-NEXT: .functype z2s_call (i32) -> (i32){{$}}
30 ; CHECK-NEXT: i32.const $push[[NUM0:[0-9]+]]=, 255{{$}}
31 ; CHECK-NEXT: i32.and $push[[NUM1:[0-9]+]]=, $0, $pop[[NUM0]]{{$}}
32 ; CHECK-NEXT: call $push[[NUM2:[0-9]+]]=, z2s_func, $pop[[NUM1]]{{$}}
33 ; CHECK-NEXT: return $pop[[NUM2]]{{$}}
34 define i32 @z2s_call(i32 %t) {
35 %s = trunc i32 %t to i8
36 %u = call signext i8 @z2s_func(i8 zeroext %s)
37 %v = sext i8 %u to i32
41 ; CHECK-LABEL: s2z_call:
42 ; CHECK-NEXT: .functype s2z_call (i32) -> (i32){{$}}
43 ; CHECK-NEXT: i32.const $push[[NUM0:[0-9]+]]=, 24{{$}}
44 ; CHECK-NEXT: i32.shl $push[[NUM1:[0-9]+]]=, $0, $pop[[NUM0]]{{$}}
45 ; CHECK-NEXT: i32.const $push[[NUM6:[0-9]+]]=, 24{{$}}
46 ; CHECK-NEXT: i32.shr_s $push[[NUM2:[0-9]+]]=, $pop[[NUM1]], $pop[[NUM6]]{{$}}
47 ; CHECK-NEXT: call $push[[NUM3:[0-9]]]=, s2z_func, $pop[[NUM2]]{{$}}
48 ; CHECK-NEXT: i32.const $push[[NUM7:[0-9]+]]=, 24{{$}}
49 ; CHECK-NEXT: i32.shl $push[[NUM4:[0-9]+]]=, $pop[[NUM3]], $pop[[NUM7]]{{$}}
50 ; CHECK-NEXT: i32.const $push[[NUM8:[0-9]+]]=, 24{{$}}
51 ; CHECK-NEXT: i32.shr_s $push[[NUM5:[0-9]+]]=, $pop[[NUM4]], $pop[[NUM8]]{{$}}
52 ; CHECK-NEXT: return $pop[[NUM5]]{{$}}
53 define i32 @s2z_call(i32 %t) {
54 %s = trunc i32 %t to i8
55 %u = call zeroext i8 @s2z_func(i8 signext %s)
56 %v = sext i8 %u to i32