Home | History | Annotate | Download | only in WebAssembly
      1 ; RUN: llc < %s -asm-verbose=false | FileCheck %s
      2 
      3 ; Test zeroext and signext ABI keywords
      4 
      5 target datalayout = "e-p:32:32-i64:64-n32:64-S128"
      6 target triple = "wasm32-unknown-unknown"
      7 
      8 ; CHECK-LABEL: z2s_func:
      9 ; CHECK-NEXT: .param i32{{$}}
     10 ; CHECK-NEXT: .result i32{{$}}
     11 ; CHECK-NEXT: .local i32{{$}}
     12 ; 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]]{{$}}
     15 ; CHECK-NEXT: return $pop[[NUM3]]{{$}}
     16 define 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{{$}}
     23 ; CHECK-NEXT: i32.const $push[[NUM0:[0-9]+]]=, 255{{$}}
     24 ; CHECK-NEXT: i32.and $push[[NUM1:[0-9]+]]=, $0, $pop[[NUM0]]{{$}}
     25 ; CHECK-NEXT: return $pop[[NUM1]]{{$}}
     26 define zeroext i8 @s2z_func(i8 signext %t) {
     27   ret i8 %t
     28 }
     29 
     30 ; CHECK-LABEL: z2s_call:
     31 ; CHECK-NEXT: .param i32{{$}}
     32 ; CHECK-NEXT: .result i32{{$}}
     33 ; CHECK-NEXT: i32.const $push[[NUM0:[0-9]+]]=, 255{{$}}
     34 ; CHECK-NEXT: i32.and $push[[NUM1:[0-9]+]]=, $0, $pop[[NUM0]]{{$}}
     35 ; CHECK-NEXT: call $push[[NUM2:[0-9]+]]=, z2s_func, $pop[[NUM1]]{{$}}
     36 ; CHECK-NEXT: return $pop[[NUM2]]{{$}}
     37 define 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:
     45 ; CHECK-NEXT: .param i32{{$}}
     46 ; CHECK-NEXT: .result i32{{$}}
     47 ; CHECK-NEXT: .local i32{{$}}
     48 ; 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]]{{$}}
     51 ; CHECK-NEXT: call $push[[NUM3:[0-9]]]=, s2z_func, $pop[[NUM2]]{{$}}
     52 ; CHECK-NEXT: i32.shl $push[[NUM4:[0-9]+]]=, $pop[[NUM3]], $[[NUM0]]{{$}}
     53 ; CHECK-NEXT: i32.shr_s $push[[NUM5:[0-9]+]]=, $pop[[NUM4]], $[[NUM0]]{{$}}
     54 ; CHECK-NEXT: return $pop[[NUM5]]{{$}}
     55 define 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 }
     61