1 ; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py
2 ; RUN: llc --mtriple=wasm32-unknown-unknown -mattr=+reference-types < %s | FileCheck %s
4 %externref = type ptr addrspace(10) ;; addrspace 10 is nonintegral
5 %funcref = type ptr addrspace(20) ;; addrspace 20 is nonintegral
7 declare %externref @llvm.wasm.ref.null.extern() nounwind
8 declare %funcref @llvm.wasm.ref.null.func() nounwind
9 declare i32 @llvm.wasm.ref.is_null.extern(%externref) nounwind
10 declare i32 @llvm.wasm.ref.is_null.func(%funcref) nounwind
12 define %externref @get_null_extern() {
13 ; CHECK-LABEL: get_null_extern:
14 ; CHECK: .functype get_null_extern () -> (externref)
15 ; CHECK-NEXT: # %bb.0:
16 ; CHECK-NEXT: ref.null_extern
17 ; CHECK-NEXT: # fallthrough-return
18 %null = call %externref @llvm.wasm.ref.null.extern()
22 define %funcref @get_null_func() {
23 ; CHECK-LABEL: get_null_func:
24 ; CHECK: .functype get_null_func () -> (funcref)
25 ; CHECK-NEXT: # %bb.0:
26 ; CHECK-NEXT: ref.null_func
27 ; CHECK-NEXT: # fallthrough-return
28 %null = call %funcref @llvm.wasm.ref.null.func()
32 define i32 @ref_is_null_extern(%externref %eref) {
33 ; CHECK-LABEL: ref_is_null_extern:
34 ; CHECK: .functype ref_is_null_extern (externref) -> (i32)
35 ; CHECK-NEXT: # %bb.0:
36 ; CHECK-NEXT: ref.null_extern
37 ; CHECK-NEXT: ref.is_null
38 ; CHECK-NEXT: local.get 0
39 ; CHECK-NEXT: ref.is_null
41 ; CHECK-NEXT: # fallthrough-return
42 %null = call %externref @llvm.wasm.ref.null.extern()
43 %is_null = call i32 @llvm.wasm.ref.is_null.extern(%externref %null)
44 %arg_is_null = call i32 @llvm.wasm.ref.is_null.extern(%externref %eref)
45 %res = add i32 %is_null, %arg_is_null
49 define i32 @ref_is_null_func(%funcref %fref) {
50 ; CHECK-LABEL: ref_is_null_func:
51 ; CHECK: .functype ref_is_null_func (funcref) -> (i32)
52 ; CHECK-NEXT: # %bb.0:
53 ; CHECK-NEXT: ref.null_func
54 ; CHECK-NEXT: ref.is_null
55 ; CHECK-NEXT: local.get 0
56 ; CHECK-NEXT: ref.is_null
58 ; CHECK-NEXT: # fallthrough-return
59 %null = call %funcref @llvm.wasm.ref.null.func()
60 %is_null = call i32 @llvm.wasm.ref.is_null.func(%funcref %null)
61 %arg_is_null = call i32 @llvm.wasm.ref.is_null.func(%funcref %fref)
62 %res = add i32 %is_null, %arg_is_null