Andrew Scull | 5e1ddfa | 2018-08-14 10:06:54 +0100 | [diff] [blame] | 1 | //===- IntrinsicsWebAssembly.td - Defines wasm intrinsics --*- tablegen -*-===// |
| 2 | // |
Andrew Walbran | 16937d0 | 2019-10-22 13:54:20 +0100 | [diff] [blame] | 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 |
Andrew Scull | 5e1ddfa | 2018-08-14 10:06:54 +0100 | [diff] [blame] | 6 | // |
| 7 | //===----------------------------------------------------------------------===// |
| 8 | /// |
| 9 | /// \file |
Andrew Scull | cdfcccc | 2018-10-05 20:58:37 +0100 | [diff] [blame] | 10 | /// This file defines all of the WebAssembly-specific intrinsics. |
Andrew Scull | 5e1ddfa | 2018-08-14 10:06:54 +0100 | [diff] [blame] | 11 | /// |
| 12 | //===----------------------------------------------------------------------===// |
| 13 | |
| 14 | let TargetPrefix = "wasm" in { // All intrinsics start with "llvm.wasm.". |
| 15 | |
| 16 | // Query the current memory size, and increase the current memory size. |
Andrew Scull | cdfcccc | 2018-10-05 20:58:37 +0100 | [diff] [blame] | 17 | // Note that memory.size is not IntrNoMem because it must be sequenced with |
| 18 | // respect to memory.grow calls. |
| 19 | def int_wasm_memory_size : Intrinsic<[llvm_anyint_ty], |
| 20 | [llvm_i32_ty], |
| 21 | [IntrReadMem]>; |
| 22 | def int_wasm_memory_grow : Intrinsic<[llvm_anyint_ty], |
| 23 | [llvm_i32_ty, LLVMMatchType<0>], |
| 24 | []>; |
| 25 | |
Andrew Walbran | 16937d0 | 2019-10-22 13:54:20 +0100 | [diff] [blame] | 26 | //===----------------------------------------------------------------------===// |
| 27 | // Saturating float-to-int conversions |
| 28 | //===----------------------------------------------------------------------===// |
Andrew Scull | 5e1ddfa | 2018-08-14 10:06:54 +0100 | [diff] [blame] | 29 | |
Andrew Walbran | 16937d0 | 2019-10-22 13:54:20 +0100 | [diff] [blame] | 30 | def int_wasm_trunc_saturate_signed : Intrinsic<[llvm_anyint_ty], |
| 31 | [llvm_anyfloat_ty], |
| 32 | [IntrNoMem, IntrSpeculatable]>; |
| 33 | def int_wasm_trunc_saturate_unsigned : Intrinsic<[llvm_anyint_ty], |
| 34 | [llvm_anyfloat_ty], |
| 35 | [IntrNoMem, IntrSpeculatable]>; |
Andrew Scull | 5e1ddfa | 2018-08-14 10:06:54 +0100 | [diff] [blame] | 36 | |
| 37 | //===----------------------------------------------------------------------===// |
| 38 | // Exception handling intrinsics |
| 39 | //===----------------------------------------------------------------------===// |
| 40 | |
| 41 | // throw / rethrow |
| 42 | def int_wasm_throw : Intrinsic<[], [llvm_i32_ty, llvm_ptr_ty], |
| 43 | [Throws, IntrNoReturn]>; |
| 44 | def int_wasm_rethrow : 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. |
Andrew Scull | cdfcccc | 2018-10-05 20:58:37 +0100 | [diff] [blame] | 48 | def int_wasm_get_exception : Intrinsic<[llvm_ptr_ty], [llvm_token_ty], |
| 49 | [IntrHasSideEffects]>; |
| 50 | def int_wasm_get_ehselector : Intrinsic<[llvm_i32_ty], [llvm_token_ty], |
Andrew Scull | 5e1ddfa | 2018-08-14 10:06:54 +0100 | [diff] [blame] | 51 | [IntrHasSideEffects]>; |
Andrew Walbran | 16937d0 | 2019-10-22 13:54:20 +0100 | [diff] [blame] | 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. |
| 54 | def int_wasm_extract_exception : Intrinsic<[llvm_ptr_ty], [], |
| 55 | [IntrHasSideEffects]>; |
Andrew Scull | cdfcccc | 2018-10-05 20:58:37 +0100 | [diff] [blame] | 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. |
Andrew Walbran | 16937d0 | 2019-10-22 13:54:20 +0100 | [diff] [blame] | 60 | def int_wasm_landingpad_index: Intrinsic<[], [llvm_token_ty, llvm_i32_ty], |
| 61 | [IntrNoMem]>; |
Andrew Scull | cdfcccc | 2018-10-05 20:58:37 +0100 | [diff] [blame] | 62 | |
| 63 | // Returns LSDA address of the current function. |
| 64 | def int_wasm_lsda : Intrinsic<[llvm_ptr_ty], [], [IntrNoMem]>; |
| 65 | |
| 66 | //===----------------------------------------------------------------------===// |
| 67 | // Atomic intrinsics |
| 68 | //===----------------------------------------------------------------------===// |
| 69 | |
| 70 | // wait / notify |
| 71 | def 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]>; |
| 77 | def 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]>; |
| 83 | def int_wasm_atomic_notify: |
Andrew Scull | 0372a57 | 2018-11-16 15:47:06 +0000 | [diff] [blame] | 84 | Intrinsic<[llvm_i32_ty], [LLVMPointerType<llvm_i32_ty>, llvm_i32_ty], |
Andrew Scull | cdfcccc | 2018-10-05 20:58:37 +0100 | [diff] [blame] | 85 | [IntrInaccessibleMemOnly, NoCapture<0>, IntrHasSideEffects], "", |
| 86 | [SDNPMemOperand]>; |
| 87 | |
Andrew Scull | 0372a57 | 2018-11-16 15:47:06 +0000 | [diff] [blame] | 88 | //===----------------------------------------------------------------------===// |
| 89 | // SIMD intrinsics |
| 90 | //===----------------------------------------------------------------------===// |
| 91 | |
Andrew Scull | 0372a57 | 2018-11-16 15:47:06 +0000 | [diff] [blame] | 92 | def int_wasm_sub_saturate_signed : |
| 93 | Intrinsic<[llvm_anyvector_ty], |
| 94 | [LLVMMatchType<0>, LLVMMatchType<0>], |
| 95 | [IntrNoMem, IntrSpeculatable]>; |
| 96 | def int_wasm_sub_saturate_unsigned : |
| 97 | Intrinsic<[llvm_anyvector_ty], |
| 98 | [LLVMMatchType<0>, LLVMMatchType<0>], |
| 99 | [IntrNoMem, IntrSpeculatable]>; |
| 100 | def int_wasm_bitselect : |
| 101 | Intrinsic<[llvm_anyvector_ty], |
| 102 | [LLVMMatchType<0>, LLVMMatchType<0>, LLVMMatchType<0>], |
| 103 | [IntrNoMem, IntrSpeculatable]>; |
| 104 | def int_wasm_anytrue : |
| 105 | Intrinsic<[llvm_i32_ty], |
| 106 | [llvm_anyvector_ty], |
| 107 | [IntrNoMem, IntrSpeculatable]>; |
| 108 | def int_wasm_alltrue : |
| 109 | Intrinsic<[llvm_i32_ty], |
| 110 | [llvm_anyvector_ty], |
| 111 | [IntrNoMem, IntrSpeculatable]>; |
| 112 | |
Andrew Walbran | 16937d0 | 2019-10-22 13:54:20 +0100 | [diff] [blame] | 113 | //===----------------------------------------------------------------------===// |
| 114 | // Bulk memory intrinsics |
| 115 | //===----------------------------------------------------------------------===// |
| 116 | |
| 117 | def 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]>; |
| 122 | def int_wasm_data_drop : |
| 123 | Intrinsic<[], |
| 124 | [llvm_i32_ty], |
| 125 | [IntrNoDuplicate, IntrHasSideEffects]>; |
| 126 | |
Andrew Scull | 0372a57 | 2018-11-16 15:47:06 +0000 | [diff] [blame] | 127 | } // TargetPrefix = "wasm" |