blob: 40d49af0ccc7ab660e9c5df6fa8c896711269e3c [file] [log] [blame]
Dan Gohman8ad045c2015-11-14 23:15:41 +00001; RUN: llc < %s -asm-verbose=false | FileCheck %s
2
3; Test zeroext and signext ABI keywords
4
5target datalayout = "e-p:32:32-i64:64-n32:64-S128"
6target triple = "wasm32-unknown-unknown"
7
8; CHECK-LABEL: z2s_func:
9; CHECK-NEXT: .param i32{{$}}
10; CHECK-NEXT: .result i32{{$}}
Dan Gohman4ba48162015-11-18 16:12:01 +000011; CHECK-NEXT: .local i32{{$}}
Dan Gohman700515f2015-11-23 21:55:57 +000012; CHECK-NEXT: i32.const $[[NUM0:[0-9]+]]=, 24{{$}}
13; CHECK-NEXT: i32.shl $push[[NUM2:[0-9]+]]=, $0, $[[NUM0]]{{$}}
14; CHECK-NEXT: i32.shr_s $push[[NUM3:[0-9]+]]=, $pop[[NUM2]], $[[NUM0]]{{$}}
Dan Gohman4ba48162015-11-18 16:12:01 +000015; CHECK-NEXT: return $pop[[NUM3]]{{$}}
Dan Gohman8ad045c2015-11-14 23:15:41 +000016define signext i8 @z2s_func(i8 zeroext %t) {
17 ret i8 %t
18}
19
20; CHECK-LABEL: s2z_func:
21; CHECK-NEXT: .param i32{{$}}
22; CHECK-NEXT: .result i32{{$}}
Dan Gohman700515f2015-11-23 21:55:57 +000023; CHECK-NEXT: i32.const $push[[NUM0:[0-9]+]]=, 255{{$}}
24; CHECK-NEXT: i32.and $push[[NUM1:[0-9]+]]=, $0, $pop[[NUM0]]{{$}}
Dan Gohman4ba48162015-11-18 16:12:01 +000025; CHECK-NEXT: return $pop[[NUM1]]{{$}}
Dan Gohman8ad045c2015-11-14 23:15:41 +000026define zeroext i8 @s2z_func(i8 signext %t) {
27 ret i8 %t
28}
29
30; CHECK-LABEL: z2s_call:
Dan Gohman1270b0a2015-11-25 17:33:15 +000031; CHECK-NEXT: .param i32{{$}}
32; CHECK-NEXT: .result i32{{$}}
Dan Gohman700515f2015-11-23 21:55:57 +000033; CHECK-NEXT: i32.const $push[[NUM0:[0-9]+]]=, 255{{$}}
34; CHECK-NEXT: i32.and $push[[NUM1:[0-9]+]]=, $0, $pop[[NUM0]]{{$}}
Dan Gohman2f16f252015-11-23 22:04:06 +000035; CHECK-NEXT: call $push[[NUM2:[0-9]+]]=, z2s_func, $pop[[NUM1]]{{$}}
Dan Gohman4ba48162015-11-18 16:12:01 +000036; CHECK-NEXT: return $pop[[NUM2]]{{$}}
Dan Gohman8ad045c2015-11-14 23:15:41 +000037define i32 @z2s_call(i32 %t) {
38 %s = trunc i32 %t to i8
39 %u = call signext i8 @z2s_func(i8 zeroext %s)
40 %v = sext i8 %u to i32
41 ret i32 %v
42}
43
44; CHECK-LABEL: s2z_call:
Dan Gohman1270b0a2015-11-25 17:33:15 +000045; CHECK-NEXT: .param i32{{$}}
46; CHECK-NEXT: .result i32{{$}}
Dan Gohman4ba48162015-11-18 16:12:01 +000047; CHECK-NEXT: .local i32{{$}}
Dan Gohman700515f2015-11-23 21:55:57 +000048; CHECK-NEXT: i32.const $[[NUM0:[0-9]+]]=, 24{{$}}
49; CHECK-NEXT: i32.shl $push[[NUM1:[0-9]+]]=, $0, $[[NUM0]]{{$}}
50; CHECK-NEXT: i32.shr_s $push[[NUM2:[0-9]+]]=, $pop[[NUM1]], $[[NUM0]]{{$}}
Dan Gohman2f16f252015-11-23 22:04:06 +000051; CHECK-NEXT: call $push[[NUM3:[0-9]]]=, s2z_func, $pop[[NUM2]]{{$}}
Dan Gohman700515f2015-11-23 21:55:57 +000052; CHECK-NEXT: i32.shl $push[[NUM4:[0-9]+]]=, $pop[[NUM3]], $[[NUM0]]{{$}}
53; CHECK-NEXT: i32.shr_s $push[[NUM5:[0-9]+]]=, $pop[[NUM4]], $[[NUM0]]{{$}}
Dan Gohman4ba48162015-11-18 16:12:01 +000054; CHECK-NEXT: return $pop[[NUM5]]{{$}}
Dan Gohman8ad045c2015-11-14 23:15:41 +000055define i32 @s2z_call(i32 %t) {
56 %s = trunc i32 %t to i8
57 %u = call zeroext i8 @s2z_func(i8 signext %s)
58 %v = sext i8 %u to i32
59 ret i32 %v
60}