blob: f9561da5363d56a5bc4627ceeee92c2bc510d246 [file] [log] [blame]
Dan Gohmanb7c24002016-05-21 00:21:56 +00001; RUN: llc < %s -asm-verbose=false -disable-wasm-fallthrough-return-opt | FileCheck %s
Dan Gohman8ad045c2015-11-14 23:15:41 +00002
3; Test zeroext and signext ABI keywords
4
Dan Gohman0c6f5ac2016-01-07 03:19:23 +00005target datalayout = "e-m:e-p:32:32-i64:64-n32:64-S128"
Dan Gohman8ad045c2015-11-14 23:15:41 +00006target triple = "wasm32-unknown-unknown"
7
8; CHECK-LABEL: z2s_func:
9; CHECK-NEXT: .param i32{{$}}
10; CHECK-NEXT: .result i32{{$}}
Dan Gohmanb6fd39a2016-01-19 16:59:23 +000011; CHECK-NEXT: i32.const $push[[NUM0:[0-9]+]]=, 24{{$}}
12; CHECK-NEXT: i32.shl $push[[NUM2:[0-9]+]]=, $0, $pop[[NUM0]]{{$}}
13; CHECK-NEXT: i32.const $push[[NUM1:[0-9]+]]=, 24{{$}}
14; CHECK-NEXT: i32.shr_s $push[[NUM3:[0-9]+]]=, $pop[[NUM2]], $pop[[NUM1]]{{$}}
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 Gohman26c67652016-01-11 23:38:05 +000035; CHECK-NEXT: call $push[[NUM2:[0-9]+]]=, z2s_func@FUNCTION, $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 Gohmanb6fd39a2016-01-19 16:59:23 +000047; CHECK-NEXT: i32.const $push[[NUM0:[0-9]+]]=, 24{{$}}
48; CHECK-NEXT: i32.shl $push[[NUM1:[0-9]+]]=, $0, $pop[[NUM0]]{{$}}
49; CHECK-NEXT: i32.const $push[[NUM6:[0-9]+]]=, 24{{$}}
50; CHECK-NEXT: i32.shr_s $push[[NUM2:[0-9]+]]=, $pop[[NUM1]], $pop[[NUM6]]{{$}}
Dan Gohman26c67652016-01-11 23:38:05 +000051; CHECK-NEXT: call $push[[NUM3:[0-9]]]=, s2z_func@FUNCTION, $pop[[NUM2]]{{$}}
Dan Gohmanb6fd39a2016-01-19 16:59:23 +000052; CHECK-NEXT: i32.const $push[[NUM7:[0-9]+]]=, 24{{$}}
53; CHECK-NEXT: i32.shl $push[[NUM4:[0-9]+]]=, $pop[[NUM3]], $pop[[NUM7]]{{$}}
54; CHECK-NEXT: i32.const $push[[NUM8:[0-9]+]]=, 24{{$}}
55; CHECK-NEXT: i32.shr_s $push[[NUM5:[0-9]+]]=, $pop[[NUM4]], $pop[[NUM8]]{{$}}
Dan Gohman4ba48162015-11-18 16:12:01 +000056; CHECK-NEXT: return $pop[[NUM5]]{{$}}
Dan Gohman8ad045c2015-11-14 23:15:41 +000057define i32 @s2z_call(i32 %t) {
58 %s = trunc i32 %t to i8
59 %u = call zeroext i8 @s2z_func(i8 signext %s)
60 %v = sext i8 %u to i32
61 ret i32 %v
62}