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// Trapping float-to-int conversions 28//===----------------------------------------------------------------------===// 29 30def int_wasm_trunc_signed : Intrinsic<[llvm_anyint_ty], 31 [llvm_anyfloat_ty], 32 [IntrNoMem]>; 33def int_wasm_trunc_unsigned : Intrinsic<[llvm_anyint_ty], 34 [llvm_anyfloat_ty], 35 [IntrNoMem]>; 36 37//===----------------------------------------------------------------------===// 38// Saturating float-to-int conversions 39//===----------------------------------------------------------------------===// 40 41def int_wasm_trunc_saturate_signed : Intrinsic<[llvm_anyint_ty], 42 [llvm_anyfloat_ty], 43 [IntrNoMem, IntrSpeculatable]>; 44def int_wasm_trunc_saturate_unsigned : Intrinsic<[llvm_anyint_ty], 45 [llvm_anyfloat_ty], 46 [IntrNoMem, IntrSpeculatable]>; 47 48//===----------------------------------------------------------------------===// 49// Exception handling intrinsics 50//===----------------------------------------------------------------------===// 51 52// throw / rethrow 53def int_wasm_throw : Intrinsic<[], [llvm_i32_ty, llvm_ptr_ty], 54 [Throws, IntrNoReturn, ImmArg<0>]>; 55def int_wasm_rethrow_in_catch : Intrinsic<[], [], [Throws, IntrNoReturn]>; 56 57// Since wasm does not use landingpad instructions, these instructions return 58// exception pointer and selector values until we lower them in WasmEHPrepare. 59def int_wasm_get_exception : Intrinsic<[llvm_ptr_ty], [llvm_token_ty], 60 [IntrHasSideEffects]>; 61def int_wasm_get_ehselector : Intrinsic<[llvm_i32_ty], [llvm_token_ty], 62 [IntrHasSideEffects]>; 63// This is the same as llvm.wasm.get.exception except that it does not take a 64// token operand. This is only for instruction selection purpose. 65def int_wasm_extract_exception : Intrinsic<[llvm_ptr_ty], [], 66 [IntrHasSideEffects]>; 67 68// WebAssembly EH must maintain the landingpads in the order assigned to them 69// by WasmEHPrepare pass to generate landingpad table in EHStreamer. This is 70// used in order to give them the indices in WasmEHPrepare. 71def int_wasm_landingpad_index: Intrinsic<[], [llvm_token_ty, llvm_i32_ty], 72 [IntrNoMem, ImmArg<1>]>; 73 74// Returns LSDA address of the current function. 75def int_wasm_lsda : Intrinsic<[llvm_ptr_ty], [], [IntrNoMem]>; 76 77//===----------------------------------------------------------------------===// 78// Atomic intrinsics 79//===----------------------------------------------------------------------===// 80 81// wait / notify 82def int_wasm_atomic_wait_i32 : 83 Intrinsic<[llvm_i32_ty], 84 [LLVMPointerType<llvm_i32_ty>, llvm_i32_ty, llvm_i64_ty], 85 [IntrInaccessibleMemOrArgMemOnly, ReadOnly<0>, NoCapture<0>, 86 IntrHasSideEffects], 87 "", [SDNPMemOperand]>; 88def int_wasm_atomic_wait_i64 : 89 Intrinsic<[llvm_i32_ty], 90 [LLVMPointerType<llvm_i64_ty>, llvm_i64_ty, llvm_i64_ty], 91 [IntrInaccessibleMemOrArgMemOnly, ReadOnly<0>, NoCapture<0>, 92 IntrHasSideEffects], 93 "", [SDNPMemOperand]>; 94def int_wasm_atomic_notify: 95 Intrinsic<[llvm_i32_ty], [LLVMPointerType<llvm_i32_ty>, llvm_i32_ty], 96 [IntrInaccessibleMemOnly, NoCapture<0>, IntrHasSideEffects], "", 97 [SDNPMemOperand]>; 98 99//===----------------------------------------------------------------------===// 100// SIMD intrinsics 101//===----------------------------------------------------------------------===// 102 103def int_wasm_swizzle : 104 Intrinsic<[llvm_v16i8_ty], 105 [llvm_v16i8_ty, llvm_v16i8_ty], 106 [IntrNoMem, IntrSpeculatable]>; 107def int_wasm_sub_saturate_signed : 108 Intrinsic<[llvm_anyvector_ty], 109 [LLVMMatchType<0>, LLVMMatchType<0>], 110 [IntrNoMem, IntrSpeculatable]>; 111def int_wasm_sub_saturate_unsigned : 112 Intrinsic<[llvm_anyvector_ty], 113 [LLVMMatchType<0>, LLVMMatchType<0>], 114 [IntrNoMem, IntrSpeculatable]>; 115def int_wasm_avgr_unsigned : 116 Intrinsic<[llvm_anyvector_ty], 117 [LLVMMatchType<0>, LLVMMatchType<0>], 118 [IntrNoMem, IntrSpeculatable]>; 119 120def int_wasm_bitselect : 121 Intrinsic<[llvm_anyvector_ty], 122 [LLVMMatchType<0>, LLVMMatchType<0>, LLVMMatchType<0>], 123 [IntrNoMem, IntrSpeculatable]>; 124def int_wasm_anytrue : 125 Intrinsic<[llvm_i32_ty], 126 [llvm_anyvector_ty], 127 [IntrNoMem, IntrSpeculatable]>; 128def int_wasm_alltrue : 129 Intrinsic<[llvm_i32_ty], 130 [llvm_anyvector_ty], 131 [IntrNoMem, IntrSpeculatable]>; 132def int_wasm_qfma : 133 Intrinsic<[llvm_anyvector_ty], 134 [LLVMMatchType<0>, LLVMMatchType<0>, LLVMMatchType<0>], 135 [IntrNoMem, IntrSpeculatable]>; 136def int_wasm_qfms : 137 Intrinsic<[llvm_anyvector_ty], 138 [LLVMMatchType<0>, LLVMMatchType<0>, LLVMMatchType<0>], 139 [IntrNoMem, IntrSpeculatable]>; 140def int_wasm_dot : 141 Intrinsic<[llvm_v4i32_ty], 142 [llvm_v8i16_ty, llvm_v8i16_ty], 143 [IntrNoMem, IntrSpeculatable]>; 144def int_wasm_narrow_signed : 145 Intrinsic<[llvm_anyvector_ty], 146 [llvm_anyvector_ty, LLVMMatchType<1>], 147 [IntrNoMem, IntrSpeculatable]>; 148def int_wasm_narrow_unsigned : 149 Intrinsic<[llvm_anyvector_ty], 150 [llvm_anyvector_ty, LLVMMatchType<1>], 151 [IntrNoMem, IntrSpeculatable]>; 152def int_wasm_widen_low_signed : 153 Intrinsic<[llvm_anyvector_ty], 154 [llvm_anyvector_ty], 155 [IntrNoMem, IntrSpeculatable]>; 156def int_wasm_widen_high_signed : 157 Intrinsic<[llvm_anyvector_ty], 158 [llvm_anyvector_ty], 159 [IntrNoMem, IntrSpeculatable]>; 160def int_wasm_widen_low_unsigned : 161 Intrinsic<[llvm_anyvector_ty], 162 [llvm_anyvector_ty], 163 [IntrNoMem, IntrSpeculatable]>; 164def int_wasm_widen_high_unsigned : 165 Intrinsic<[llvm_anyvector_ty], 166 [llvm_anyvector_ty], 167 [IntrNoMem, IntrSpeculatable]>; 168 169 170//===----------------------------------------------------------------------===// 171// Bulk memory intrinsics 172//===----------------------------------------------------------------------===// 173 174def int_wasm_memory_init : 175 Intrinsic<[], 176 [llvm_i32_ty, llvm_i32_ty, llvm_ptr_ty, llvm_i32_ty, llvm_i32_ty], 177 [IntrWriteMem, IntrInaccessibleMemOrArgMemOnly, WriteOnly<2>, 178 IntrHasSideEffects, ImmArg<0>, ImmArg<1>]>; 179def int_wasm_data_drop : 180 Intrinsic<[], 181 [llvm_i32_ty], 182 [IntrNoDuplicate, IntrHasSideEffects, ImmArg<0>]>; 183 184//===----------------------------------------------------------------------===// 185// Thread-local storage intrinsics 186//===----------------------------------------------------------------------===// 187 188def int_wasm_tls_size : 189 Intrinsic<[llvm_anyint_ty], 190 [], 191 [IntrNoMem, IntrSpeculatable]>; 192 193def int_wasm_tls_align : 194 Intrinsic<[llvm_anyint_ty], 195 [], 196 [IntrNoMem, IntrSpeculatable]>; 197 198def int_wasm_tls_base : 199 Intrinsic<[llvm_ptr_ty], 200 [], 201 [IntrReadMem]>; 202 203} // TargetPrefix = "wasm" 204