[Alignment][NFC] Migrate Instructions to Align
[llvm-core.git] / include / llvm / IR / IntrinsicsWebAssembly.td
blob6b5d0cbf799abb794a53189e0594a9b6baa74cc1
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, ImmArg<0>]>;
44 def int_wasm_rethrow_in_catch : 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, ImmArg<1>]>;
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]>;
112 def int_wasm_qfma :
113   Intrinsic<[llvm_anyvector_ty],
114             [LLVMMatchType<0>, LLVMMatchType<0>, LLVMMatchType<0>],
115             [IntrNoMem, IntrSpeculatable]>;
116 def int_wasm_qfms :
117   Intrinsic<[llvm_anyvector_ty],
118             [LLVMMatchType<0>, LLVMMatchType<0>, LLVMMatchType<0>],
119             [IntrNoMem, IntrSpeculatable]>;
120 def int_wasm_narrow_signed :
121   Intrinsic<[llvm_anyvector_ty],
122             [llvm_anyvector_ty, LLVMMatchType<1>],
123             [IntrNoMem, IntrSpeculatable]>;
124 def int_wasm_narrow_unsigned :
125   Intrinsic<[llvm_anyvector_ty],
126             [llvm_anyvector_ty, LLVMMatchType<1>],
127             [IntrNoMem, IntrSpeculatable]>;
128 def int_wasm_widen_low_signed :
129   Intrinsic<[llvm_anyvector_ty],
130             [llvm_anyvector_ty],
131             [IntrNoMem, IntrSpeculatable]>;
132 def int_wasm_widen_high_signed :
133   Intrinsic<[llvm_anyvector_ty],
134             [llvm_anyvector_ty],
135             [IntrNoMem, IntrSpeculatable]>;
136 def int_wasm_widen_low_unsigned :
137   Intrinsic<[llvm_anyvector_ty],
138             [llvm_anyvector_ty],
139             [IntrNoMem, IntrSpeculatable]>;
140 def int_wasm_widen_high_unsigned :
141   Intrinsic<[llvm_anyvector_ty],
142             [llvm_anyvector_ty],
143             [IntrNoMem, IntrSpeculatable]>;
146 //===----------------------------------------------------------------------===//
147 // Bulk memory intrinsics
148 //===----------------------------------------------------------------------===//
150 def int_wasm_memory_init :
151   Intrinsic<[],
152             [llvm_i32_ty, llvm_i32_ty, llvm_ptr_ty, llvm_i32_ty, llvm_i32_ty],
153             [IntrWriteMem, IntrInaccessibleMemOrArgMemOnly, WriteOnly<2>,
154              IntrHasSideEffects, ImmArg<0>, ImmArg<1>]>;
155 def int_wasm_data_drop :
156   Intrinsic<[],
157             [llvm_i32_ty],
158             [IntrNoDuplicate, IntrHasSideEffects, ImmArg<0>]>;
160 //===----------------------------------------------------------------------===//
161 // Thread-local storage intrinsics
162 //===----------------------------------------------------------------------===//
164 def int_wasm_tls_size :
165   Intrinsic<[llvm_anyint_ty],
166             [],
167             [IntrNoMem, IntrSpeculatable]>;
169 def int_wasm_tls_align :
170   Intrinsic<[llvm_anyint_ty],
171             [],
172             [IntrNoMem, IntrSpeculatable]>;
174 def int_wasm_tls_base :
175   Intrinsic<[llvm_ptr_ty],
176             [],
177             [IntrReadMem]>;
179 } // TargetPrefix = "wasm"