1//===- IntrinsicsWebAssembly.td - Defines wasm intrinsics --*- tablegen -*-===// 2// 3// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. 4// See https://llvm.org/LICENSE.txt for license information. 5// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception 6// 7//===----------------------------------------------------------------------===// 8/// 9/// \file 10/// This file defines all of the WebAssembly-specific intrinsics. 11/// 12//===----------------------------------------------------------------------===// 13 14let TargetPrefix = "wasm" in { // All intrinsics start with "llvm.wasm.". 15 16// Query the current memory size, and increase the current memory size. 17// Note that memory.size is not IntrNoMem because it must be sequenced with 18// respect to memory.grow calls. 19def int_wasm_memory_size : Intrinsic<[llvm_anyint_ty], 20 [llvm_i32_ty], 21 [IntrReadMem]>; 22def int_wasm_memory_grow : Intrinsic<[llvm_anyint_ty], 23 [llvm_i32_ty, LLVMMatchType<0>], 24 []>; 25 26//===----------------------------------------------------------------------===// 27// Saturating float-to-int conversions 28//===----------------------------------------------------------------------===// 29 30def int_wasm_trunc_saturate_signed : Intrinsic<[llvm_anyint_ty], 31 [llvm_anyfloat_ty], 32 [IntrNoMem, IntrSpeculatable]>; 33def int_wasm_trunc_saturate_unsigned : Intrinsic<[llvm_anyint_ty], 34 [llvm_anyfloat_ty], 35 [IntrNoMem, IntrSpeculatable]>; 36 37//===----------------------------------------------------------------------===// 38// Exception handling intrinsics 39//===----------------------------------------------------------------------===// 40 41// throw / rethrow 42def int_wasm_throw : Intrinsic<[], [llvm_i32_ty, llvm_ptr_ty], 43 [Throws, IntrNoReturn, ImmArg<0>]>; 44def int_wasm_rethrow_in_catch : Intrinsic<[], [], [Throws, IntrNoReturn]>; 45 46// Since wasm does not use landingpad instructions, these instructions return 47// exception pointer and selector values until we lower them in WasmEHPrepare. 48def int_wasm_get_exception : Intrinsic<[llvm_ptr_ty], [llvm_token_ty], 49 [IntrHasSideEffects]>; 50def int_wasm_get_ehselector : Intrinsic<[llvm_i32_ty], [llvm_token_ty], 51 [IntrHasSideEffects]>; 52// This is the same as llvm.wasm.get.exception except that it does not take a 53// token operand. This is only for instruction selection purpose. 54def int_wasm_extract_exception : Intrinsic<[llvm_ptr_ty], [], 55 [IntrHasSideEffects]>; 56 57// WebAssembly EH must maintain the landingpads in the order assigned to them 58// by WasmEHPrepare pass to generate landingpad table in EHStreamer. This is 59// used in order to give them the indices in WasmEHPrepare. 60def int_wasm_landingpad_index: Intrinsic<[], [llvm_token_ty, llvm_i32_ty], 61 [IntrNoMem, ImmArg<1>]>; 62 63// Returns LSDA address of the current function. 64def int_wasm_lsda : Intrinsic<[llvm_ptr_ty], [], [IntrNoMem]>; 65 66//===----------------------------------------------------------------------===// 67// Atomic intrinsics 68//===----------------------------------------------------------------------===// 69 70// wait / notify 71def int_wasm_atomic_wait_i32 : 72 Intrinsic<[llvm_i32_ty], 73 [LLVMPointerType<llvm_i32_ty>, llvm_i32_ty, llvm_i64_ty], 74 [IntrInaccessibleMemOrArgMemOnly, ReadOnly<0>, NoCapture<0>, 75 IntrHasSideEffects], 76 "", [SDNPMemOperand]>; 77def int_wasm_atomic_wait_i64 : 78 Intrinsic<[llvm_i32_ty], 79 [LLVMPointerType<llvm_i64_ty>, llvm_i64_ty, llvm_i64_ty], 80 [IntrInaccessibleMemOrArgMemOnly, ReadOnly<0>, NoCapture<0>, 81 IntrHasSideEffects], 82 "", [SDNPMemOperand]>; 83def int_wasm_atomic_notify: 84 Intrinsic<[llvm_i32_ty], [LLVMPointerType<llvm_i32_ty>, llvm_i32_ty], 85 [IntrInaccessibleMemOnly, NoCapture<0>, IntrHasSideEffects], "", 86 [SDNPMemOperand]>; 87 88//===----------------------------------------------------------------------===// 89// SIMD intrinsics 90//===----------------------------------------------------------------------===// 91 92def int_wasm_sub_saturate_signed : 93 Intrinsic<[llvm_anyvector_ty], 94 [LLVMMatchType<0>, LLVMMatchType<0>], 95 [IntrNoMem, IntrSpeculatable]>; 96def int_wasm_sub_saturate_unsigned : 97 Intrinsic<[llvm_anyvector_ty], 98 [LLVMMatchType<0>, LLVMMatchType<0>], 99 [IntrNoMem, IntrSpeculatable]>; 100def int_wasm_bitselect : 101 Intrinsic<[llvm_anyvector_ty], 102 [LLVMMatchType<0>, LLVMMatchType<0>, LLVMMatchType<0>], 103 [IntrNoMem, IntrSpeculatable]>; 104def int_wasm_anytrue : 105 Intrinsic<[llvm_i32_ty], 106 [llvm_anyvector_ty], 107 [IntrNoMem, IntrSpeculatable]>; 108def int_wasm_alltrue : 109 Intrinsic<[llvm_i32_ty], 110 [llvm_anyvector_ty], 111 [IntrNoMem, IntrSpeculatable]>; 112 113//===----------------------------------------------------------------------===// 114// Bulk memory intrinsics 115//===----------------------------------------------------------------------===// 116 117def int_wasm_memory_init : 118 Intrinsic<[], 119 [llvm_i32_ty, llvm_i32_ty, llvm_ptr_ty, llvm_i32_ty, llvm_i32_ty], 120 [IntrWriteMem, IntrInaccessibleMemOrArgMemOnly, WriteOnly<2>, 121 IntrHasSideEffects, ImmArg<0>, ImmArg<1>]>; 122def int_wasm_data_drop : 123 Intrinsic<[], 124 [llvm_i32_ty], 125 [IntrNoDuplicate, IntrHasSideEffects, ImmArg<0>]>; 126 127//===----------------------------------------------------------------------===// 128// Thread-local storage intrinsics 129//===----------------------------------------------------------------------===// 130 131def int_wasm_tls_size : 132 Intrinsic<[llvm_anyint_ty], 133 [], 134 [IntrNoMem, IntrSpeculatable]>; 135 136} // TargetPrefix = "wasm" 137