blob: bfeb7063ced58ba667d399ef5444be3bfe3d77c0 [file] [log] [blame]
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01001//===- IntrinsicsWebAssembly.td - Defines wasm intrinsics --*- tablegen -*-===//
2//
Andrew Walbran16937d02019-10-22 13:54:20 +01003// 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 Scull5e1ddfa2018-08-14 10:06:54 +01006//
7//===----------------------------------------------------------------------===//
8///
9/// \file
Andrew Scullcdfcccc2018-10-05 20:58:37 +010010/// This file defines all of the WebAssembly-specific intrinsics.
Andrew Scull5e1ddfa2018-08-14 10:06:54 +010011///
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.
Andrew Scullcdfcccc2018-10-05 20:58:37 +010017// 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
Andrew Walbran16937d02019-10-22 13:54:20 +010026//===----------------------------------------------------------------------===//
27// Saturating float-to-int conversions
28//===----------------------------------------------------------------------===//
Andrew Scull5e1ddfa2018-08-14 10:06:54 +010029
Andrew Walbran16937d02019-10-22 13:54:20 +010030def int_wasm_trunc_saturate_signed : Intrinsic<[llvm_anyint_ty],
31 [llvm_anyfloat_ty],
32 [IntrNoMem, IntrSpeculatable]>;
33def int_wasm_trunc_saturate_unsigned : Intrinsic<[llvm_anyint_ty],
34 [llvm_anyfloat_ty],
35 [IntrNoMem, IntrSpeculatable]>;
Andrew Scull5e1ddfa2018-08-14 10:06:54 +010036
37//===----------------------------------------------------------------------===//
38// Exception handling intrinsics
39//===----------------------------------------------------------------------===//
40
41// throw / rethrow
42def int_wasm_throw : Intrinsic<[], [llvm_i32_ty, llvm_ptr_ty],
43 [Throws, IntrNoReturn]>;
44def 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 Scullcdfcccc2018-10-05 20:58:37 +010048def int_wasm_get_exception : Intrinsic<[llvm_ptr_ty], [llvm_token_ty],
49 [IntrHasSideEffects]>;
50def int_wasm_get_ehselector : Intrinsic<[llvm_i32_ty], [llvm_token_ty],
Andrew Scull5e1ddfa2018-08-14 10:06:54 +010051 [IntrHasSideEffects]>;
Andrew Walbran16937d02019-10-22 13:54:20 +010052// 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.
54def int_wasm_extract_exception : Intrinsic<[llvm_ptr_ty], [],
55 [IntrHasSideEffects]>;
Andrew Scullcdfcccc2018-10-05 20:58:37 +010056
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 Walbran16937d02019-10-22 13:54:20 +010060def int_wasm_landingpad_index: Intrinsic<[], [llvm_token_ty, llvm_i32_ty],
61 [IntrNoMem]>;
Andrew Scullcdfcccc2018-10-05 20:58:37 +010062
63// Returns LSDA address of the current function.
64def int_wasm_lsda : Intrinsic<[llvm_ptr_ty], [], [IntrNoMem]>;
65
66//===----------------------------------------------------------------------===//
67// Atomic intrinsics
68//===----------------------------------------------------------------------===//
69
70// wait / notify
71def 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]>;
77def 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]>;
83def int_wasm_atomic_notify:
Andrew Scull0372a572018-11-16 15:47:06 +000084 Intrinsic<[llvm_i32_ty], [LLVMPointerType<llvm_i32_ty>, llvm_i32_ty],
Andrew Scullcdfcccc2018-10-05 20:58:37 +010085 [IntrInaccessibleMemOnly, NoCapture<0>, IntrHasSideEffects], "",
86 [SDNPMemOperand]>;
87
Andrew Scull0372a572018-11-16 15:47:06 +000088//===----------------------------------------------------------------------===//
89// SIMD intrinsics
90//===----------------------------------------------------------------------===//
91
Andrew Scull0372a572018-11-16 15:47:06 +000092def int_wasm_sub_saturate_signed :
93 Intrinsic<[llvm_anyvector_ty],
94 [LLVMMatchType<0>, LLVMMatchType<0>],
95 [IntrNoMem, IntrSpeculatable]>;
96def int_wasm_sub_saturate_unsigned :
97 Intrinsic<[llvm_anyvector_ty],
98 [LLVMMatchType<0>, LLVMMatchType<0>],
99 [IntrNoMem, IntrSpeculatable]>;
100def int_wasm_bitselect :
101 Intrinsic<[llvm_anyvector_ty],
102 [LLVMMatchType<0>, LLVMMatchType<0>, LLVMMatchType<0>],
103 [IntrNoMem, IntrSpeculatable]>;
104def int_wasm_anytrue :
105 Intrinsic<[llvm_i32_ty],
106 [llvm_anyvector_ty],
107 [IntrNoMem, IntrSpeculatable]>;
108def int_wasm_alltrue :
109 Intrinsic<[llvm_i32_ty],
110 [llvm_anyvector_ty],
111 [IntrNoMem, IntrSpeculatable]>;
112
Andrew Walbran16937d02019-10-22 13:54:20 +0100113//===----------------------------------------------------------------------===//
114// Bulk memory intrinsics
115//===----------------------------------------------------------------------===//
116
117def 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]>;
122def int_wasm_data_drop :
123 Intrinsic<[],
124 [llvm_i32_ty],
125 [IntrNoDuplicate, IntrHasSideEffects]>;
126
Andrew Scull0372a572018-11-16 15:47:06 +0000127} // TargetPrefix = "wasm"