1 //===- IntrinsicsWebAssembly.td - Defines wasm intrinsics --*- tablegen -*-===//
3 // The LLVM Compiler Infrastructure
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
8 //===----------------------------------------------------------------------===//
11 /// This file defines all of the WebAssembly-specific intrinsics.
13 //===----------------------------------------------------------------------===//
15 let TargetPrefix = "wasm" in { // All intrinsics start with "llvm.wasm.".
17 // Query the current memory size, and increase the current memory size.
18 // Note that memory.size is not IntrNoMem because it must be sequenced with
19 // respect to memory.grow calls.
20 def int_wasm_memory_size : Intrinsic<[llvm_anyint_ty],
23 def int_wasm_memory_grow : Intrinsic<[llvm_anyint_ty],
24 [llvm_i32_ty, LLVMMatchType<0>],
27 //===----------------------------------------------------------------------===//
28 // Saturating float-to-int conversions
29 //===----------------------------------------------------------------------===//
31 def int_wasm_trunc_saturate_signed : Intrinsic<[llvm_anyint_ty],
33 [IntrNoMem, IntrSpeculatable]>;
34 def int_wasm_trunc_saturate_unsigned : Intrinsic<[llvm_anyint_ty],
36 [IntrNoMem, IntrSpeculatable]>;
38 //===----------------------------------------------------------------------===//
39 // Exception handling intrinsics
40 //===----------------------------------------------------------------------===//
43 def int_wasm_throw : Intrinsic<[], [llvm_i32_ty, llvm_ptr_ty],
44 [Throws, IntrNoReturn]>;
45 def int_wasm_rethrow : Intrinsic<[], [], [Throws, IntrNoReturn]>;
47 // Since wasm does not use landingpad instructions, these instructions return
48 // exception pointer and selector values until we lower them in WasmEHPrepare.
49 def int_wasm_get_exception : Intrinsic<[llvm_ptr_ty], [llvm_token_ty],
50 [IntrHasSideEffects]>;
51 def int_wasm_get_ehselector : Intrinsic<[llvm_i32_ty], [llvm_token_ty],
52 [IntrHasSideEffects]>;
54 // wasm.catch returns the pointer to the exception object caught by wasm 'catch'
56 def int_wasm_catch : Intrinsic<[llvm_ptr_ty], [llvm_i32_ty],
57 [IntrHasSideEffects]>;
59 // WebAssembly EH must maintain the landingpads in the order assigned to them
60 // by WasmEHPrepare pass to generate landingpad table in EHStreamer. This is
61 // used in order to give them the indices in WasmEHPrepare.
62 def int_wasm_landingpad_index: Intrinsic<[], [llvm_token_ty, llvm_i32_ty],
65 // Returns LSDA address of the current function.
66 def int_wasm_lsda : Intrinsic<[llvm_ptr_ty], [], [IntrNoMem]>;
68 //===----------------------------------------------------------------------===//
70 //===----------------------------------------------------------------------===//
73 def int_wasm_atomic_wait_i32 :
74 Intrinsic<[llvm_i32_ty],
75 [LLVMPointerType<llvm_i32_ty>, llvm_i32_ty, llvm_i64_ty],
76 [IntrInaccessibleMemOrArgMemOnly, ReadOnly<0>, NoCapture<0>,
78 "", [SDNPMemOperand]>;
79 def int_wasm_atomic_wait_i64 :
80 Intrinsic<[llvm_i32_ty],
81 [LLVMPointerType<llvm_i64_ty>, llvm_i64_ty, llvm_i64_ty],
82 [IntrInaccessibleMemOrArgMemOnly, ReadOnly<0>, NoCapture<0>,
84 "", [SDNPMemOperand]>;
85 def int_wasm_atomic_notify:
86 Intrinsic<[llvm_i32_ty], [LLVMPointerType<llvm_i32_ty>, llvm_i32_ty],
87 [IntrInaccessibleMemOnly, NoCapture<0>, IntrHasSideEffects], "",
90 //===----------------------------------------------------------------------===//
92 //===----------------------------------------------------------------------===//
94 def int_wasm_sub_saturate_signed :
95 Intrinsic<[llvm_anyvector_ty],
96 [LLVMMatchType<0>, LLVMMatchType<0>],
97 [IntrNoMem, IntrSpeculatable]>;
98 def int_wasm_sub_saturate_unsigned :
99 Intrinsic<[llvm_anyvector_ty],
100 [LLVMMatchType<0>, LLVMMatchType<0>],
101 [IntrNoMem, IntrSpeculatable]>;
102 def int_wasm_bitselect :
103 Intrinsic<[llvm_anyvector_ty],
104 [LLVMMatchType<0>, LLVMMatchType<0>, LLVMMatchType<0>],
105 [IntrNoMem, IntrSpeculatable]>;
106 def int_wasm_anytrue :
107 Intrinsic<[llvm_i32_ty],
109 [IntrNoMem, IntrSpeculatable]>;
110 def int_wasm_alltrue :
111 Intrinsic<[llvm_i32_ty],
113 [IntrNoMem, IntrSpeculatable]>;
115 } // TargetPrefix = "wasm"