Recommit [NFC] Better encapsulation of llvm::Optional Storage
[llvm-complete.git] / include / llvm / IR / IntrinsicsWebAssembly.td
blobbfeb7063ced58ba667d399ef5444be3bfe3d77c0
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 //===----------------------------------------------------------------------===//
14 let TargetPrefix = "wasm" in {  // All intrinsics start with "llvm.wasm.".
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.
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                                      []>;
26 //===----------------------------------------------------------------------===//
27 // Saturating float-to-int conversions
28 //===----------------------------------------------------------------------===//
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]>;
37 //===----------------------------------------------------------------------===//
38 // Exception handling intrinsics
39 //===----------------------------------------------------------------------===//
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]>;
46 // Since wasm does not use landingpad instructions, these instructions return
47 // exception pointer and selector values until we lower them in WasmEHPrepare.
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],
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.
54 def int_wasm_extract_exception : Intrinsic<[llvm_ptr_ty], [],
55                                            [IntrHasSideEffects]>;
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.
60 def int_wasm_landingpad_index: Intrinsic<[], [llvm_token_ty, llvm_i32_ty],
61                                          [IntrNoMem]>;
63 // Returns LSDA address of the current function.
64 def int_wasm_lsda : Intrinsic<[llvm_ptr_ty], [], [IntrNoMem]>;
66 //===----------------------------------------------------------------------===//
67 // Atomic intrinsics
68 //===----------------------------------------------------------------------===//
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:
84   Intrinsic<[llvm_i32_ty], [LLVMPointerType<llvm_i32_ty>, llvm_i32_ty],
85             [IntrInaccessibleMemOnly, NoCapture<0>, IntrHasSideEffects], "",
86             [SDNPMemOperand]>;
88 //===----------------------------------------------------------------------===//
89 // SIMD intrinsics
90 //===----------------------------------------------------------------------===//
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]>;
113 //===----------------------------------------------------------------------===//
114 // Bulk memory intrinsics
115 //===----------------------------------------------------------------------===//
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]>;
127 } // TargetPrefix = "wasm"