Files
clang-p2996/llvm/test/CodeGen/WebAssembly/ref-null.ll
Paulo Matos a96d828510 [WebAssembly] Implementation of intrinsic for ref.null and HeapType removal
This patch implements the intrinsic for ref.null.
In the process of implementing int_wasm_ref_null_func() and
int_wasm_ref_null_extern() intrinsics, it removes the redundant
HeapType.

This also causes the textual assembler syntax for ref.null to
change. Instead of receiving an argument: `func` or `extern`, the
instruction mnemonic is either ref.null_func or ref.null_extern,
without the need for a further operand.

Reviewed By: tlively

Differential Revision: https://reviews.llvm.org/D114979
2021-12-06 09:46:15 +01:00

27 lines
917 B
LLVM

; RUN: llc --mtriple=wasm32-unknown-unknown -asm-verbose=false -mattr=+reference-types < %s | FileCheck %s
%extern = type opaque
%externref = type %extern addrspace(10)* ;; addrspace 10 is nonintegral
%funcref = type i8 addrspace(20)* ;; addrspace 20 is nonintegral
declare %externref @llvm.wasm.ref.null.extern() nounwind
declare %funcref @llvm.wasm.ref.null.func() nounwind
define %externref @get_null_extern() {
; CHECK-LABEL: get_null_extern:
; CHECK-NEXT: .functype get_null_extern () -> (externref)
; CHECK-NEXT: ref.null_extern
; CHECK-NEXT: end_function
%null = call %externref @llvm.wasm.ref.null.extern()
ret %externref %null
}
define %funcref @get_null_func() {
; CHECK-LABEL: get_null_func:
; CHECK-NEXT: .functype get_null_func () -> (funcref)
; CHECK-NEXT: ref.null_func
; CHECK-NEXT: end_function
%null = call %funcref @llvm.wasm.ref.null.func()
ret %funcref %null
}