blob: 54408d317d273dd0e1e50a9c8ee9f13e28575797 [file] [log] [blame]
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01001//===- IntrinsicsWebAssembly.td - Defines wasm intrinsics --*- tablegen -*-===//
2//
3// The LLVM Compiler Infrastructure
4//
5// This file is distributed under the University of Illinois Open Source
6// License. See LICENSE.TXT for details.
7//
8//===----------------------------------------------------------------------===//
9///
10/// \file
Andrew Scullcdfcccc2018-10-05 20:58:37 +010011/// This file defines all of the WebAssembly-specific intrinsics.
Andrew Scull5e1ddfa2018-08-14 10:06:54 +010012///
13//===----------------------------------------------------------------------===//
14
15let TargetPrefix = "wasm" in { // All intrinsics start with "llvm.wasm.".
16
17// Query the current memory size, and increase the current memory size.
Andrew Scullcdfcccc2018-10-05 20:58:37 +010018// Note that memory.size is not IntrNoMem because it must be sequenced with
19// respect to memory.grow calls.
20def int_wasm_memory_size : Intrinsic<[llvm_anyint_ty],
21 [llvm_i32_ty],
22 [IntrReadMem]>;
23def int_wasm_memory_grow : Intrinsic<[llvm_anyint_ty],
24 [llvm_i32_ty, LLVMMatchType<0>],
25 []>;
26
27// These are the old names.
Andrew Scull5e1ddfa2018-08-14 10:06:54 +010028def int_wasm_mem_size : Intrinsic<[llvm_anyint_ty],
29 [llvm_i32_ty],
30 [IntrReadMem]>;
31def int_wasm_mem_grow : Intrinsic<[llvm_anyint_ty],
32 [llvm_i32_ty, LLVMMatchType<0>],
33 []>;
34
Andrew Scullcdfcccc2018-10-05 20:58:37 +010035// These are the old old names. They also lack the immediate field.
Andrew Scull5e1ddfa2018-08-14 10:06:54 +010036def int_wasm_current_memory : Intrinsic<[llvm_anyint_ty], [], [IntrReadMem]>;
37def int_wasm_grow_memory : Intrinsic<[llvm_anyint_ty], [LLVMMatchType<0>], []>;
38
39//===----------------------------------------------------------------------===//
40// Exception handling intrinsics
41//===----------------------------------------------------------------------===//
42
43// throw / rethrow
44def int_wasm_throw : Intrinsic<[], [llvm_i32_ty, llvm_ptr_ty],
45 [Throws, IntrNoReturn]>;
46def int_wasm_rethrow : Intrinsic<[], [], [Throws, IntrNoReturn]>;
47
48// Since wasm does not use landingpad instructions, these instructions return
49// exception pointer and selector values until we lower them in WasmEHPrepare.
Andrew Scullcdfcccc2018-10-05 20:58:37 +010050def int_wasm_get_exception : Intrinsic<[llvm_ptr_ty], [llvm_token_ty],
51 [IntrHasSideEffects]>;
52def int_wasm_get_ehselector : Intrinsic<[llvm_i32_ty], [llvm_token_ty],
Andrew Scull5e1ddfa2018-08-14 10:06:54 +010053 [IntrHasSideEffects]>;
Andrew Scullcdfcccc2018-10-05 20:58:37 +010054
55// wasm.catch returns the pointer to the exception object caught by wasm 'catch'
56// instruction.
57def int_wasm_catch : Intrinsic<[llvm_ptr_ty], [llvm_i32_ty],
58 [IntrHasSideEffects]>;
59
60// WebAssembly EH must maintain the landingpads in the order assigned to them
61// by WasmEHPrepare pass to generate landingpad table in EHStreamer. This is
62// used in order to give them the indices in WasmEHPrepare.
63def int_wasm_landingpad_index: Intrinsic<[], [llvm_i32_ty], [IntrNoMem]>;
64
65// Returns LSDA address of the current function.
66def int_wasm_lsda : Intrinsic<[llvm_ptr_ty], [], [IntrNoMem]>;
67
68//===----------------------------------------------------------------------===//
69// Atomic intrinsics
70//===----------------------------------------------------------------------===//
71
72// wait / notify
73def 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>,
77 IntrHasSideEffects],
78 "", [SDNPMemOperand]>;
79def 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>,
83 IntrHasSideEffects],
84 "", [SDNPMemOperand]>;
85def int_wasm_atomic_notify:
Andrew Scull0372a572018-11-16 15:47:06 +000086 Intrinsic<[llvm_i32_ty], [LLVMPointerType<llvm_i32_ty>, llvm_i32_ty],
Andrew Scullcdfcccc2018-10-05 20:58:37 +010087 [IntrInaccessibleMemOnly, NoCapture<0>, IntrHasSideEffects], "",
88 [SDNPMemOperand]>;
89
Andrew Scull0372a572018-11-16 15:47:06 +000090//===----------------------------------------------------------------------===//
91// SIMD intrinsics
92//===----------------------------------------------------------------------===//
93
94def int_wasm_add_saturate_signed :
95 Intrinsic<[llvm_anyvector_ty],
96 [LLVMMatchType<0>, LLVMMatchType<0>],
97 [IntrNoMem, IntrSpeculatable]>;
98def int_wasm_add_saturate_unsigned :
99 Intrinsic<[llvm_anyvector_ty],
100 [LLVMMatchType<0>, LLVMMatchType<0>],
101 [IntrNoMem, IntrSpeculatable]>;
102def int_wasm_sub_saturate_signed :
103 Intrinsic<[llvm_anyvector_ty],
104 [LLVMMatchType<0>, LLVMMatchType<0>],
105 [IntrNoMem, IntrSpeculatable]>;
106def int_wasm_sub_saturate_unsigned :
107 Intrinsic<[llvm_anyvector_ty],
108 [LLVMMatchType<0>, LLVMMatchType<0>],
109 [IntrNoMem, IntrSpeculatable]>;
110def int_wasm_bitselect :
111 Intrinsic<[llvm_anyvector_ty],
112 [LLVMMatchType<0>, LLVMMatchType<0>, LLVMMatchType<0>],
113 [IntrNoMem, IntrSpeculatable]>;
114def int_wasm_anytrue :
115 Intrinsic<[llvm_i32_ty],
116 [llvm_anyvector_ty],
117 [IntrNoMem, IntrSpeculatable]>;
118def int_wasm_alltrue :
119 Intrinsic<[llvm_i32_ty],
120 [llvm_anyvector_ty],
121 [IntrNoMem, IntrSpeculatable]>;
122
123} // TargetPrefix = "wasm"