[Alignment][NFC] Remove dependency on GlobalObject::setAlignment(unsigned)
[llvm-core.git] / include / llvm / IR / IntrinsicsWebAssembly.td
blob810979b999343c93a5468ca66ca9fc4b1207bfcf
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 // Trapping float-to-int conversions
28 //===----------------------------------------------------------------------===//
30 def int_wasm_trunc_signed : Intrinsic<[llvm_anyint_ty],
31                                       [llvm_anyfloat_ty],
32                                       [IntrNoMem]>;
33 def int_wasm_trunc_unsigned : Intrinsic<[llvm_anyint_ty],
34                                         [llvm_anyfloat_ty],
35                                         [IntrNoMem]>;
37 //===----------------------------------------------------------------------===//
38 // Saturating float-to-int conversions
39 //===----------------------------------------------------------------------===//
41 def int_wasm_trunc_saturate_signed : Intrinsic<[llvm_anyint_ty],
42                                                [llvm_anyfloat_ty],
43                                                [IntrNoMem, IntrSpeculatable]>;
44 def int_wasm_trunc_saturate_unsigned : Intrinsic<[llvm_anyint_ty],
45                                                  [llvm_anyfloat_ty],
46                                                  [IntrNoMem, IntrSpeculatable]>;
48 //===----------------------------------------------------------------------===//
49 // Exception handling intrinsics
50 //===----------------------------------------------------------------------===//
52 // throw / rethrow
53 def int_wasm_throw : Intrinsic<[], [llvm_i32_ty, llvm_ptr_ty],
54                                [Throws, IntrNoReturn, ImmArg<0>]>;
55 def int_wasm_rethrow_in_catch : Intrinsic<[], [], [Throws, IntrNoReturn]>;
57 // Since wasm does not use landingpad instructions, these instructions return
58 // exception pointer and selector values until we lower them in WasmEHPrepare.
59 def int_wasm_get_exception : Intrinsic<[llvm_ptr_ty], [llvm_token_ty],
60                                        [IntrHasSideEffects]>;
61 def 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.
65 def int_wasm_extract_exception : Intrinsic<[llvm_ptr_ty], [],
66                                            [IntrHasSideEffects]>;
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.
71 def int_wasm_landingpad_index: Intrinsic<[], [llvm_token_ty, llvm_i32_ty],
72                                          [IntrNoMem, ImmArg<1>]>;
74 // Returns LSDA address of the current function.
75 def int_wasm_lsda : Intrinsic<[llvm_ptr_ty], [], [IntrNoMem]>;
77 //===----------------------------------------------------------------------===//
78 // Atomic intrinsics
79 //===----------------------------------------------------------------------===//
81 // wait / notify
82 def 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]>;
88 def 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]>;
94 def int_wasm_atomic_notify:
95   Intrinsic<[llvm_i32_ty], [LLVMPointerType<llvm_i32_ty>, llvm_i32_ty],
96             [IntrInaccessibleMemOnly, NoCapture<0>, IntrHasSideEffects], "",
97             [SDNPMemOperand]>;
99 //===----------------------------------------------------------------------===//
100 // SIMD intrinsics
101 //===----------------------------------------------------------------------===//
103 def int_wasm_swizzle :
104   Intrinsic<[llvm_v16i8_ty],
105             [llvm_v16i8_ty, llvm_v16i8_ty],
106             [IntrNoMem, IntrSpeculatable]>;
107 def int_wasm_sub_saturate_signed :
108   Intrinsic<[llvm_anyvector_ty],
109             [LLVMMatchType<0>, LLVMMatchType<0>],
110             [IntrNoMem, IntrSpeculatable]>;
111 def int_wasm_sub_saturate_unsigned :
112   Intrinsic<[llvm_anyvector_ty],
113             [LLVMMatchType<0>, LLVMMatchType<0>],
114             [IntrNoMem, IntrSpeculatable]>;
115 def int_wasm_bitselect :
116   Intrinsic<[llvm_anyvector_ty],
117             [LLVMMatchType<0>, LLVMMatchType<0>, LLVMMatchType<0>],
118             [IntrNoMem, IntrSpeculatable]>;
119 def int_wasm_anytrue :
120   Intrinsic<[llvm_i32_ty],
121             [llvm_anyvector_ty],
122             [IntrNoMem, IntrSpeculatable]>;
123 def int_wasm_alltrue :
124   Intrinsic<[llvm_i32_ty],
125             [llvm_anyvector_ty],
126             [IntrNoMem, IntrSpeculatable]>;
127 def int_wasm_qfma :
128   Intrinsic<[llvm_anyvector_ty],
129             [LLVMMatchType<0>, LLVMMatchType<0>, LLVMMatchType<0>],
130             [IntrNoMem, IntrSpeculatable]>;
131 def int_wasm_qfms :
132   Intrinsic<[llvm_anyvector_ty],
133             [LLVMMatchType<0>, LLVMMatchType<0>, LLVMMatchType<0>],
134             [IntrNoMem, IntrSpeculatable]>;
135 def int_wasm_narrow_signed :
136   Intrinsic<[llvm_anyvector_ty],
137             [llvm_anyvector_ty, LLVMMatchType<1>],
138             [IntrNoMem, IntrSpeculatable]>;
139 def int_wasm_narrow_unsigned :
140   Intrinsic<[llvm_anyvector_ty],
141             [llvm_anyvector_ty, LLVMMatchType<1>],
142             [IntrNoMem, IntrSpeculatable]>;
143 def int_wasm_widen_low_signed :
144   Intrinsic<[llvm_anyvector_ty],
145             [llvm_anyvector_ty],
146             [IntrNoMem, IntrSpeculatable]>;
147 def int_wasm_widen_high_signed :
148   Intrinsic<[llvm_anyvector_ty],
149             [llvm_anyvector_ty],
150             [IntrNoMem, IntrSpeculatable]>;
151 def int_wasm_widen_low_unsigned :
152   Intrinsic<[llvm_anyvector_ty],
153             [llvm_anyvector_ty],
154             [IntrNoMem, IntrSpeculatable]>;
155 def int_wasm_widen_high_unsigned :
156   Intrinsic<[llvm_anyvector_ty],
157             [llvm_anyvector_ty],
158             [IntrNoMem, IntrSpeculatable]>;
161 //===----------------------------------------------------------------------===//
162 // Bulk memory intrinsics
163 //===----------------------------------------------------------------------===//
165 def int_wasm_memory_init :
166   Intrinsic<[],
167             [llvm_i32_ty, llvm_i32_ty, llvm_ptr_ty, llvm_i32_ty, llvm_i32_ty],
168             [IntrWriteMem, IntrInaccessibleMemOrArgMemOnly, WriteOnly<2>,
169              IntrHasSideEffects, ImmArg<0>, ImmArg<1>]>;
170 def int_wasm_data_drop :
171   Intrinsic<[],
172             [llvm_i32_ty],
173             [IntrNoDuplicate, IntrHasSideEffects, ImmArg<0>]>;
175 //===----------------------------------------------------------------------===//
176 // Thread-local storage intrinsics
177 //===----------------------------------------------------------------------===//
179 def int_wasm_tls_size :
180   Intrinsic<[llvm_anyint_ty],
181             [],
182             [IntrNoMem, IntrSpeculatable]>;
184 def int_wasm_tls_align :
185   Intrinsic<[llvm_anyint_ty],
186             [],
187             [IntrNoMem, IntrSpeculatable]>;
189 def int_wasm_tls_base :
190   Intrinsic<[llvm_ptr_ty],
191             [],
192             [IntrReadMem]>;
194 } // TargetPrefix = "wasm"