2018-08-27 23:45:51 +08:00
|
|
|
; RUN: llc < %s -asm-verbose=false -disable-wasm-fallthrough-return-opt -wasm-disable-explicit-locals -wasm-keep-registers | FileCheck %s
|
2015-11-15 07:15:41 +08:00
|
|
|
|
|
|
|
; Test zeroext and signext ABI keywords
|
|
|
|
|
2016-01-07 11:19:23 +08:00
|
|
|
target datalayout = "e-m:e-p:32:32-i64:64-n32:64-S128"
|
2018-05-11 01:49:11 +08:00
|
|
|
target triple = "wasm32-unknown-unknown"
|
2015-11-15 07:15:41 +08:00
|
|
|
|
|
|
|
; CHECK-LABEL: z2s_func:
|
2018-11-20 01:10:36 +08:00
|
|
|
; CHECK-NEXT: .functype z2s_func (i32) -> (i32){{$}}
|
2016-01-20 00:59:23 +08:00
|
|
|
; CHECK-NEXT: i32.const $push[[NUM0:[0-9]+]]=, 24{{$}}
|
|
|
|
; CHECK-NEXT: i32.shl $push[[NUM2:[0-9]+]]=, $0, $pop[[NUM0]]{{$}}
|
|
|
|
; CHECK-NEXT: i32.const $push[[NUM1:[0-9]+]]=, 24{{$}}
|
|
|
|
; CHECK-NEXT: i32.shr_s $push[[NUM3:[0-9]+]]=, $pop[[NUM2]], $pop[[NUM1]]{{$}}
|
2015-11-19 00:12:01 +08:00
|
|
|
; CHECK-NEXT: return $pop[[NUM3]]{{$}}
|
2015-11-15 07:15:41 +08:00
|
|
|
define signext i8 @z2s_func(i8 zeroext %t) {
|
|
|
|
ret i8 %t
|
|
|
|
}
|
|
|
|
|
|
|
|
; CHECK-LABEL: s2z_func:
|
2018-11-20 01:10:36 +08:00
|
|
|
; CHECK-NEXT: .functype s2z_func (i32) -> (i32){{$}}
|
2015-11-24 05:55:57 +08:00
|
|
|
; CHECK-NEXT: i32.const $push[[NUM0:[0-9]+]]=, 255{{$}}
|
|
|
|
; CHECK-NEXT: i32.and $push[[NUM1:[0-9]+]]=, $0, $pop[[NUM0]]{{$}}
|
2015-11-19 00:12:01 +08:00
|
|
|
; CHECK-NEXT: return $pop[[NUM1]]{{$}}
|
2015-11-15 07:15:41 +08:00
|
|
|
define zeroext i8 @s2z_func(i8 signext %t) {
|
|
|
|
ret i8 %t
|
|
|
|
}
|
|
|
|
|
|
|
|
; CHECK-LABEL: z2s_call:
|
2018-11-20 01:10:36 +08:00
|
|
|
; CHECK-NEXT: .functype z2s_call (i32) -> (i32){{$}}
|
2015-11-24 05:55:57 +08:00
|
|
|
; CHECK-NEXT: i32.const $push[[NUM0:[0-9]+]]=, 255{{$}}
|
|
|
|
; CHECK-NEXT: i32.and $push[[NUM1:[0-9]+]]=, $0, $pop[[NUM0]]{{$}}
|
2019-02-23 08:07:39 +08:00
|
|
|
; CHECK-NEXT: call $push[[NUM2:[0-9]+]]=, z2s_func, $pop[[NUM1]]{{$}}
|
2015-11-19 00:12:01 +08:00
|
|
|
; CHECK-NEXT: return $pop[[NUM2]]{{$}}
|
2015-11-15 07:15:41 +08:00
|
|
|
define i32 @z2s_call(i32 %t) {
|
|
|
|
%s = trunc i32 %t to i8
|
|
|
|
%u = call signext i8 @z2s_func(i8 zeroext %s)
|
|
|
|
%v = sext i8 %u to i32
|
|
|
|
ret i32 %v
|
|
|
|
}
|
|
|
|
|
|
|
|
; CHECK-LABEL: s2z_call:
|
2018-11-20 01:10:36 +08:00
|
|
|
; CHECK-NEXT: .functype s2z_call (i32) -> (i32){{$}}
|
2016-01-20 00:59:23 +08:00
|
|
|
; CHECK-NEXT: i32.const $push[[NUM0:[0-9]+]]=, 24{{$}}
|
|
|
|
; CHECK-NEXT: i32.shl $push[[NUM1:[0-9]+]]=, $0, $pop[[NUM0]]{{$}}
|
|
|
|
; CHECK-NEXT: i32.const $push[[NUM6:[0-9]+]]=, 24{{$}}
|
|
|
|
; CHECK-NEXT: i32.shr_s $push[[NUM2:[0-9]+]]=, $pop[[NUM1]], $pop[[NUM6]]{{$}}
|
2019-02-23 08:07:39 +08:00
|
|
|
; CHECK-NEXT: call $push[[NUM3:[0-9]]]=, s2z_func, $pop[[NUM2]]{{$}}
|
2016-01-20 00:59:23 +08:00
|
|
|
; CHECK-NEXT: i32.const $push[[NUM7:[0-9]+]]=, 24{{$}}
|
|
|
|
; CHECK-NEXT: i32.shl $push[[NUM4:[0-9]+]]=, $pop[[NUM3]], $pop[[NUM7]]{{$}}
|
|
|
|
; CHECK-NEXT: i32.const $push[[NUM8:[0-9]+]]=, 24{{$}}
|
|
|
|
; CHECK-NEXT: i32.shr_s $push[[NUM5:[0-9]+]]=, $pop[[NUM4]], $pop[[NUM8]]{{$}}
|
2015-11-19 00:12:01 +08:00
|
|
|
; CHECK-NEXT: return $pop[[NUM5]]{{$}}
|
2015-11-15 07:15:41 +08:00
|
|
|
define i32 @s2z_call(i32 %t) {
|
|
|
|
%s = trunc i32 %t to i8
|
|
|
|
%u = call zeroext i8 @s2z_func(i8 signext %s)
|
|
|
|
%v = sext i8 %u to i32
|
|
|
|
ret i32 %v
|
|
|
|
}
|