blob: 4ca921481dcff3869b8390350c4822ed4750e0dc [file] [log] [blame]
Dan Gohman10e730a2015-06-29 23:51:55 +00001//==- WebAssemblyMCTargetDesc.h - WebAssembly Target Descriptions -*- C++ -*-=//
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
Adrian Prantl5f8f34e42018-05-01 15:54:18 +000011/// This file provides WebAssembly-specific target descriptions.
Dan Gohman10e730a2015-06-29 23:51:55 +000012///
13//===----------------------------------------------------------------------===//
14
15#ifndef LLVM_LIB_TARGET_WEBASSEMBLY_MCTARGETDESC_WEBASSEMBLYMCTARGETDESC_H
16#define LLVM_LIB_TARGET_WEBASSEMBLY_MCTARGETDESC_WEBASSEMBLYMCTARGETDESC_H
17
Zachary Turner264b5d92017-06-07 03:48:56 +000018#include "llvm/BinaryFormat/Wasm.h"
Dan Gohmana11fb232016-01-12 03:09:16 +000019#include "llvm/MC/MCInstrDesc.h"
Dan Gohman10e730a2015-06-29 23:51:55 +000020#include "llvm/Support/DataTypes.h"
Derek Schuff669300d2017-10-10 17:31:43 +000021#include <memory>
Dan Gohman10e730a2015-06-29 23:51:55 +000022
23namespace llvm {
24
Dan Gohman10e730a2015-06-29 23:51:55 +000025class MCAsmBackend;
26class MCCodeEmitter;
27class MCContext;
28class MCInstrInfo;
Peter Collingbournedcd7d6c2018-05-21 19:20:29 +000029class MCObjectTargetWriter;
Dan Gohman10e730a2015-06-29 23:51:55 +000030class MCSubtargetInfo;
Dan Gohman3acb1872016-10-24 23:27:49 +000031class MVT;
Dan Gohman10e730a2015-06-29 23:51:55 +000032class Target;
33class Triple;
Dan Gohman53828fd2015-11-23 16:50:18 +000034class raw_pwrite_stream;
Dan Gohman10e730a2015-06-29 23:51:55 +000035
Mehdi Aminif42454b2016-10-09 23:00:34 +000036Target &getTheWebAssemblyTarget32();
37Target &getTheWebAssemblyTarget64();
Dan Gohman10e730a2015-06-29 23:51:55 +000038
Sam Clegg9d24fb72017-06-16 23:59:10 +000039MCCodeEmitter *createWebAssemblyMCCodeEmitter(const MCInstrInfo &MCII);
Dan Gohman53828fd2015-11-23 16:50:18 +000040
Dan Gohmancceedf72016-01-08 00:43:54 +000041MCAsmBackend *createWebAssemblyAsmBackend(const Triple &TT);
Dan Gohman10e730a2015-06-29 23:51:55 +000042
Peter Collingbournedcd7d6c2018-05-21 19:20:29 +000043std::unique_ptr<MCObjectTargetWriter>
Peter Collingbournedcd7d6c2018-05-21 19:20:29 +000044createWebAssemblyWasmObjectWriter(bool Is64Bit);
Dan Gohman18eafb62017-02-22 01:23:18 +000045
Dan Gohmana11fb232016-01-12 03:09:16 +000046namespace WebAssembly {
47enum OperandType {
48 /// Basic block label in a branch construct.
49 OPERAND_BASIC_BLOCK = MCOI::OPERAND_FIRST_TARGET,
Dan Gohman4fc4e422016-10-24 19:49:43 +000050 /// Local index.
51 OPERAND_LOCAL,
Dan Gohmanb89f2d32017-02-02 19:29:44 +000052 /// Global index.
53 OPERAND_GLOBAL,
Dan Gohman5a68ec72016-10-05 21:24:08 +000054 /// 32-bit integer immediates.
55 OPERAND_I32IMM,
56 /// 64-bit integer immediates.
57 OPERAND_I64IMM,
Dan Gohmanaa742912016-02-16 15:14:23 +000058 /// 32-bit floating-point immediates.
Dan Gohman4b8e8be2016-10-03 21:31:31 +000059 OPERAND_F32IMM,
Dan Gohmanaa742912016-02-16 15:14:23 +000060 /// 64-bit floating-point immediates.
Dan Gohman4b8e8be2016-10-03 21:31:31 +000061 OPERAND_F64IMM,
Thomas Lively22442922018-08-21 21:03:18 +000062 /// 8-bit vector lane immediate
63 OPERAND_VEC_I8IMM,
64 /// 16-bit vector lane immediate
65 OPERAND_VEC_I16IMM,
66 /// 32-bit vector lane immediate
67 OPERAND_VEC_I32IMM,
68 /// 64-bit vector lane immediate
69 OPERAND_VEC_I64IMM,
Dan Gohman00d734d2016-12-23 03:23:52 +000070 /// 32-bit unsigned function indices.
71 OPERAND_FUNCTION32,
72 /// 32-bit unsigned memory offsets.
73 OPERAND_OFFSET32,
Dan Gohmanbb372242016-01-26 03:39:31 +000074 /// p2align immediate for load and store address alignment.
Dan Gohman2726b882016-10-06 22:29:32 +000075 OPERAND_P2ALIGN,
76 /// signature immediate for block/loop.
Dan Gohmand934cb82017-02-24 23:18:00 +000077 OPERAND_SIGNATURE,
78 /// type signature immediate for call_indirect.
79 OPERAND_TYPEINDEX,
Dan Gohmana11fb232016-01-12 03:09:16 +000080};
81} // end namespace WebAssembly
82
83namespace WebAssemblyII {
84enum {
85 // For variadic instructions, this flag indicates whether an operand
86 // in the variable_ops range is an immediate value.
Dan Gohman3469ee12016-01-12 20:30:51 +000087 VariableOpIsImmediate = (1 << 0),
Dan Gohman1d68e80f2016-01-12 19:14:46 +000088 // For immediate values in the variable_ops range, this flag indicates
89 // whether the value represents a control-flow label.
Dan Gohman3acb1872016-10-24 23:27:49 +000090 VariableOpImmediateIsLabel = (1 << 1)
Dan Gohmana11fb232016-01-12 03:09:16 +000091};
Nicholas Wilsone408a892018-08-03 14:33:37 +000092
93/// Target Operand Flag enum.
94enum TOF {
95 MO_NO_FLAG = 0,
96
97 // Flags to indicate the type of the symbol being referenced
98 MO_SYMBOL_FUNCTION = 0x1,
99 MO_SYMBOL_GLOBAL = 0x2,
100 MO_SYMBOL_MASK = 0x3,
101};
Dan Gohmana11fb232016-01-12 03:09:16 +0000102} // end namespace WebAssemblyII
103
Dan Gohman10e730a2015-06-29 23:51:55 +0000104} // end namespace llvm
105
106// Defines symbolic names for WebAssembly registers. This defines a mapping from
107// register name to register number.
108//
JF Bastien5ca0bac2015-07-10 18:23:10 +0000109#define GET_REGINFO_ENUM
110#include "WebAssemblyGenRegisterInfo.inc"
111
JF Bastienb9073fb2015-07-22 21:28:15 +0000112// Defines symbolic names for the WebAssembly instructions.
113//
114#define GET_INSTRINFO_ENUM
115#include "WebAssemblyGenInstrInfo.inc"
116
Dan Gohman10e730a2015-06-29 23:51:55 +0000117#define GET_SUBTARGETINFO_ENUM
118#include "WebAssemblyGenSubtargetInfo.inc"
119
Dan Gohmanbb372242016-01-26 03:39:31 +0000120namespace llvm {
121namespace WebAssembly {
122
123/// Return the default p2align value for a load or store with the given opcode.
124inline unsigned GetDefaultP2Align(unsigned Opcode) {
125 switch (Opcode) {
126 case WebAssembly::LOAD8_S_I32:
Wouter van Oortmerssen48dac312018-06-18 21:22:44 +0000127 case WebAssembly::LOAD8_S_I32_S:
Dan Gohmanbb372242016-01-26 03:39:31 +0000128 case WebAssembly::LOAD8_U_I32:
Wouter van Oortmerssen48dac312018-06-18 21:22:44 +0000129 case WebAssembly::LOAD8_U_I32_S:
Dan Gohmanbb372242016-01-26 03:39:31 +0000130 case WebAssembly::LOAD8_S_I64:
Wouter van Oortmerssen48dac312018-06-18 21:22:44 +0000131 case WebAssembly::LOAD8_S_I64_S:
Dan Gohmanbb372242016-01-26 03:39:31 +0000132 case WebAssembly::LOAD8_U_I64:
Wouter van Oortmerssen48dac312018-06-18 21:22:44 +0000133 case WebAssembly::LOAD8_U_I64_S:
Derek Schuff885dc592017-10-05 21:18:42 +0000134 case WebAssembly::ATOMIC_LOAD8_U_I32:
Wouter van Oortmerssen48dac312018-06-18 21:22:44 +0000135 case WebAssembly::ATOMIC_LOAD8_U_I32_S:
Derek Schuff885dc592017-10-05 21:18:42 +0000136 case WebAssembly::ATOMIC_LOAD8_U_I64:
Wouter van Oortmerssen48dac312018-06-18 21:22:44 +0000137 case WebAssembly::ATOMIC_LOAD8_U_I64_S:
Dan Gohmanbb372242016-01-26 03:39:31 +0000138 case WebAssembly::STORE8_I32:
Wouter van Oortmerssen48dac312018-06-18 21:22:44 +0000139 case WebAssembly::STORE8_I32_S:
Dan Gohmanbb372242016-01-26 03:39:31 +0000140 case WebAssembly::STORE8_I64:
Wouter van Oortmerssen48dac312018-06-18 21:22:44 +0000141 case WebAssembly::STORE8_I64_S:
Heejin Ahn402b4902018-07-02 21:22:59 +0000142 case WebAssembly::ATOMIC_STORE8_I32:
Heejin Ahn80d9f172018-07-05 21:27:09 +0000143 case WebAssembly::ATOMIC_STORE8_I32_S:
Heejin Ahn402b4902018-07-02 21:22:59 +0000144 case WebAssembly::ATOMIC_STORE8_I64:
Heejin Ahn80d9f172018-07-05 21:27:09 +0000145 case WebAssembly::ATOMIC_STORE8_I64_S:
Heejin Ahnfed73822018-07-09 22:30:51 +0000146 case WebAssembly::ATOMIC_RMW8_U_ADD_I32:
147 case WebAssembly::ATOMIC_RMW8_U_ADD_I32_S:
148 case WebAssembly::ATOMIC_RMW8_U_ADD_I64:
149 case WebAssembly::ATOMIC_RMW8_U_ADD_I64_S:
150 case WebAssembly::ATOMIC_RMW8_U_SUB_I32:
151 case WebAssembly::ATOMIC_RMW8_U_SUB_I32_S:
152 case WebAssembly::ATOMIC_RMW8_U_SUB_I64:
153 case WebAssembly::ATOMIC_RMW8_U_SUB_I64_S:
154 case WebAssembly::ATOMIC_RMW8_U_AND_I32:
155 case WebAssembly::ATOMIC_RMW8_U_AND_I32_S:
156 case WebAssembly::ATOMIC_RMW8_U_AND_I64:
157 case WebAssembly::ATOMIC_RMW8_U_AND_I64_S:
158 case WebAssembly::ATOMIC_RMW8_U_OR_I32:
159 case WebAssembly::ATOMIC_RMW8_U_OR_I32_S:
160 case WebAssembly::ATOMIC_RMW8_U_OR_I64:
161 case WebAssembly::ATOMIC_RMW8_U_OR_I64_S:
162 case WebAssembly::ATOMIC_RMW8_U_XOR_I32:
163 case WebAssembly::ATOMIC_RMW8_U_XOR_I32_S:
164 case WebAssembly::ATOMIC_RMW8_U_XOR_I64:
165 case WebAssembly::ATOMIC_RMW8_U_XOR_I64_S:
166 case WebAssembly::ATOMIC_RMW8_U_XCHG_I32:
167 case WebAssembly::ATOMIC_RMW8_U_XCHG_I32_S:
168 case WebAssembly::ATOMIC_RMW8_U_XCHG_I64:
169 case WebAssembly::ATOMIC_RMW8_U_XCHG_I64_S:
Heejin Ahnb3724b72018-08-01 19:40:28 +0000170 case WebAssembly::ATOMIC_RMW8_U_CMPXCHG_I32:
171 case WebAssembly::ATOMIC_RMW8_U_CMPXCHG_I32_S:
172 case WebAssembly::ATOMIC_RMW8_U_CMPXCHG_I64:
173 case WebAssembly::ATOMIC_RMW8_U_CMPXCHG_I64_S:
Dan Gohmanbb372242016-01-26 03:39:31 +0000174 return 0;
175 case WebAssembly::LOAD16_S_I32:
Wouter van Oortmerssen48dac312018-06-18 21:22:44 +0000176 case WebAssembly::LOAD16_S_I32_S:
Dan Gohmanbb372242016-01-26 03:39:31 +0000177 case WebAssembly::LOAD16_U_I32:
Wouter van Oortmerssen48dac312018-06-18 21:22:44 +0000178 case WebAssembly::LOAD16_U_I32_S:
Dan Gohmanbb372242016-01-26 03:39:31 +0000179 case WebAssembly::LOAD16_S_I64:
Wouter van Oortmerssen48dac312018-06-18 21:22:44 +0000180 case WebAssembly::LOAD16_S_I64_S:
Dan Gohmanbb372242016-01-26 03:39:31 +0000181 case WebAssembly::LOAD16_U_I64:
Wouter van Oortmerssen48dac312018-06-18 21:22:44 +0000182 case WebAssembly::LOAD16_U_I64_S:
Derek Schuff885dc592017-10-05 21:18:42 +0000183 case WebAssembly::ATOMIC_LOAD16_U_I32:
Wouter van Oortmerssen48dac312018-06-18 21:22:44 +0000184 case WebAssembly::ATOMIC_LOAD16_U_I32_S:
Derek Schuff885dc592017-10-05 21:18:42 +0000185 case WebAssembly::ATOMIC_LOAD16_U_I64:
Wouter van Oortmerssen48dac312018-06-18 21:22:44 +0000186 case WebAssembly::ATOMIC_LOAD16_U_I64_S:
Dan Gohmanbb372242016-01-26 03:39:31 +0000187 case WebAssembly::STORE16_I32:
Wouter van Oortmerssen48dac312018-06-18 21:22:44 +0000188 case WebAssembly::STORE16_I32_S:
Dan Gohmanbb372242016-01-26 03:39:31 +0000189 case WebAssembly::STORE16_I64:
Wouter van Oortmerssen48dac312018-06-18 21:22:44 +0000190 case WebAssembly::STORE16_I64_S:
Heejin Ahn402b4902018-07-02 21:22:59 +0000191 case WebAssembly::ATOMIC_STORE16_I32:
Heejin Ahn80d9f172018-07-05 21:27:09 +0000192 case WebAssembly::ATOMIC_STORE16_I32_S:
Heejin Ahn402b4902018-07-02 21:22:59 +0000193 case WebAssembly::ATOMIC_STORE16_I64:
Heejin Ahn80d9f172018-07-05 21:27:09 +0000194 case WebAssembly::ATOMIC_STORE16_I64_S:
Heejin Ahnfed73822018-07-09 22:30:51 +0000195 case WebAssembly::ATOMIC_RMW16_U_ADD_I32:
196 case WebAssembly::ATOMIC_RMW16_U_ADD_I32_S:
197 case WebAssembly::ATOMIC_RMW16_U_ADD_I64:
198 case WebAssembly::ATOMIC_RMW16_U_ADD_I64_S:
199 case WebAssembly::ATOMIC_RMW16_U_SUB_I32:
200 case WebAssembly::ATOMIC_RMW16_U_SUB_I32_S:
201 case WebAssembly::ATOMIC_RMW16_U_SUB_I64:
202 case WebAssembly::ATOMIC_RMW16_U_SUB_I64_S:
203 case WebAssembly::ATOMIC_RMW16_U_AND_I32:
204 case WebAssembly::ATOMIC_RMW16_U_AND_I32_S:
205 case WebAssembly::ATOMIC_RMW16_U_AND_I64:
206 case WebAssembly::ATOMIC_RMW16_U_AND_I64_S:
207 case WebAssembly::ATOMIC_RMW16_U_OR_I32:
208 case WebAssembly::ATOMIC_RMW16_U_OR_I32_S:
209 case WebAssembly::ATOMIC_RMW16_U_OR_I64:
210 case WebAssembly::ATOMIC_RMW16_U_OR_I64_S:
211 case WebAssembly::ATOMIC_RMW16_U_XOR_I32:
212 case WebAssembly::ATOMIC_RMW16_U_XOR_I32_S:
213 case WebAssembly::ATOMIC_RMW16_U_XOR_I64:
214 case WebAssembly::ATOMIC_RMW16_U_XOR_I64_S:
215 case WebAssembly::ATOMIC_RMW16_U_XCHG_I32:
216 case WebAssembly::ATOMIC_RMW16_U_XCHG_I32_S:
217 case WebAssembly::ATOMIC_RMW16_U_XCHG_I64:
218 case WebAssembly::ATOMIC_RMW16_U_XCHG_I64_S:
Heejin Ahnb3724b72018-08-01 19:40:28 +0000219 case WebAssembly::ATOMIC_RMW16_U_CMPXCHG_I32:
220 case WebAssembly::ATOMIC_RMW16_U_CMPXCHG_I32_S:
221 case WebAssembly::ATOMIC_RMW16_U_CMPXCHG_I64:
222 case WebAssembly::ATOMIC_RMW16_U_CMPXCHG_I64_S:
Dan Gohmanbb372242016-01-26 03:39:31 +0000223 return 1;
224 case WebAssembly::LOAD_I32:
Wouter van Oortmerssen48dac312018-06-18 21:22:44 +0000225 case WebAssembly::LOAD_I32_S:
Dan Gohmanbb372242016-01-26 03:39:31 +0000226 case WebAssembly::LOAD_F32:
Wouter van Oortmerssen48dac312018-06-18 21:22:44 +0000227 case WebAssembly::LOAD_F32_S:
Dan Gohmanbb372242016-01-26 03:39:31 +0000228 case WebAssembly::STORE_I32:
Wouter van Oortmerssen48dac312018-06-18 21:22:44 +0000229 case WebAssembly::STORE_I32_S:
Dan Gohmanbb372242016-01-26 03:39:31 +0000230 case WebAssembly::STORE_F32:
Wouter van Oortmerssen48dac312018-06-18 21:22:44 +0000231 case WebAssembly::STORE_F32_S:
Dan Gohmanbb372242016-01-26 03:39:31 +0000232 case WebAssembly::LOAD32_S_I64:
Wouter van Oortmerssen48dac312018-06-18 21:22:44 +0000233 case WebAssembly::LOAD32_S_I64_S:
Dan Gohmanbb372242016-01-26 03:39:31 +0000234 case WebAssembly::LOAD32_U_I64:
Wouter van Oortmerssen48dac312018-06-18 21:22:44 +0000235 case WebAssembly::LOAD32_U_I64_S:
Dan Gohmanbb372242016-01-26 03:39:31 +0000236 case WebAssembly::STORE32_I64:
Wouter van Oortmerssen48dac312018-06-18 21:22:44 +0000237 case WebAssembly::STORE32_I64_S:
Derek Schuff18ba1922017-08-30 18:07:45 +0000238 case WebAssembly::ATOMIC_LOAD_I32:
Wouter van Oortmerssen48dac312018-06-18 21:22:44 +0000239 case WebAssembly::ATOMIC_LOAD_I32_S:
Derek Schuff885dc592017-10-05 21:18:42 +0000240 case WebAssembly::ATOMIC_LOAD32_U_I64:
Wouter van Oortmerssen48dac312018-06-18 21:22:44 +0000241 case WebAssembly::ATOMIC_LOAD32_U_I64_S:
Heejin Ahn402b4902018-07-02 21:22:59 +0000242 case WebAssembly::ATOMIC_STORE_I32:
Heejin Ahn80d9f172018-07-05 21:27:09 +0000243 case WebAssembly::ATOMIC_STORE_I32_S:
Heejin Ahn402b4902018-07-02 21:22:59 +0000244 case WebAssembly::ATOMIC_STORE32_I64:
Heejin Ahn80d9f172018-07-05 21:27:09 +0000245 case WebAssembly::ATOMIC_STORE32_I64_S:
Heejin Ahnfed73822018-07-09 22:30:51 +0000246 case WebAssembly::ATOMIC_RMW_ADD_I32:
247 case WebAssembly::ATOMIC_RMW_ADD_I32_S:
248 case WebAssembly::ATOMIC_RMW32_U_ADD_I64:
249 case WebAssembly::ATOMIC_RMW32_U_ADD_I64_S:
250 case WebAssembly::ATOMIC_RMW_SUB_I32:
251 case WebAssembly::ATOMIC_RMW_SUB_I32_S:
252 case WebAssembly::ATOMIC_RMW32_U_SUB_I64:
253 case WebAssembly::ATOMIC_RMW32_U_SUB_I64_S:
254 case WebAssembly::ATOMIC_RMW_AND_I32:
255 case WebAssembly::ATOMIC_RMW_AND_I32_S:
256 case WebAssembly::ATOMIC_RMW32_U_AND_I64:
257 case WebAssembly::ATOMIC_RMW32_U_AND_I64_S:
258 case WebAssembly::ATOMIC_RMW_OR_I32:
259 case WebAssembly::ATOMIC_RMW_OR_I32_S:
260 case WebAssembly::ATOMIC_RMW32_U_OR_I64:
261 case WebAssembly::ATOMIC_RMW32_U_OR_I64_S:
262 case WebAssembly::ATOMIC_RMW_XOR_I32:
263 case WebAssembly::ATOMIC_RMW_XOR_I32_S:
264 case WebAssembly::ATOMIC_RMW32_U_XOR_I64:
265 case WebAssembly::ATOMIC_RMW32_U_XOR_I64_S:
266 case WebAssembly::ATOMIC_RMW_XCHG_I32:
267 case WebAssembly::ATOMIC_RMW_XCHG_I32_S:
268 case WebAssembly::ATOMIC_RMW32_U_XCHG_I64:
269 case WebAssembly::ATOMIC_RMW32_U_XCHG_I64_S:
Heejin Ahnb3724b72018-08-01 19:40:28 +0000270 case WebAssembly::ATOMIC_RMW_CMPXCHG_I32:
271 case WebAssembly::ATOMIC_RMW_CMPXCHG_I32_S:
272 case WebAssembly::ATOMIC_RMW32_U_CMPXCHG_I64:
273 case WebAssembly::ATOMIC_RMW32_U_CMPXCHG_I64_S:
Heejin Ahn4128cb02018-08-02 21:44:24 +0000274 case WebAssembly::ATOMIC_NOTIFY:
275 case WebAssembly::ATOMIC_NOTIFY_S:
276 case WebAssembly::ATOMIC_WAIT_I32:
277 case WebAssembly::ATOMIC_WAIT_I32_S:
Dan Gohmanbb372242016-01-26 03:39:31 +0000278 return 2;
279 case WebAssembly::LOAD_I64:
Wouter van Oortmerssen48dac312018-06-18 21:22:44 +0000280 case WebAssembly::LOAD_I64_S:
Dan Gohmanbb372242016-01-26 03:39:31 +0000281 case WebAssembly::LOAD_F64:
Wouter van Oortmerssen48dac312018-06-18 21:22:44 +0000282 case WebAssembly::LOAD_F64_S:
Dan Gohmanbb372242016-01-26 03:39:31 +0000283 case WebAssembly::STORE_I64:
Wouter van Oortmerssen48dac312018-06-18 21:22:44 +0000284 case WebAssembly::STORE_I64_S:
Dan Gohmanbb372242016-01-26 03:39:31 +0000285 case WebAssembly::STORE_F64:
Wouter van Oortmerssen48dac312018-06-18 21:22:44 +0000286 case WebAssembly::STORE_F64_S:
Derek Schuff885dc592017-10-05 21:18:42 +0000287 case WebAssembly::ATOMIC_LOAD_I64:
Wouter van Oortmerssen48dac312018-06-18 21:22:44 +0000288 case WebAssembly::ATOMIC_LOAD_I64_S:
Heejin Ahn402b4902018-07-02 21:22:59 +0000289 case WebAssembly::ATOMIC_STORE_I64:
Heejin Ahn80d9f172018-07-05 21:27:09 +0000290 case WebAssembly::ATOMIC_STORE_I64_S:
Heejin Ahnfed73822018-07-09 22:30:51 +0000291 case WebAssembly::ATOMIC_RMW_ADD_I64:
292 case WebAssembly::ATOMIC_RMW_ADD_I64_S:
293 case WebAssembly::ATOMIC_RMW_SUB_I64:
294 case WebAssembly::ATOMIC_RMW_SUB_I64_S:
295 case WebAssembly::ATOMIC_RMW_AND_I64:
296 case WebAssembly::ATOMIC_RMW_AND_I64_S:
297 case WebAssembly::ATOMIC_RMW_OR_I64:
298 case WebAssembly::ATOMIC_RMW_OR_I64_S:
299 case WebAssembly::ATOMIC_RMW_XOR_I64:
300 case WebAssembly::ATOMIC_RMW_XOR_I64_S:
301 case WebAssembly::ATOMIC_RMW_XCHG_I64:
302 case WebAssembly::ATOMIC_RMW_XCHG_I64_S:
Heejin Ahnb3724b72018-08-01 19:40:28 +0000303 case WebAssembly::ATOMIC_RMW_CMPXCHG_I64:
304 case WebAssembly::ATOMIC_RMW_CMPXCHG_I64_S:
Heejin Ahn4128cb02018-08-02 21:44:24 +0000305 case WebAssembly::ATOMIC_WAIT_I64:
306 case WebAssembly::ATOMIC_WAIT_I64_S:
Dan Gohmanbb372242016-01-26 03:39:31 +0000307 return 3;
Derek Schuffc64d7652016-08-01 22:25:02 +0000308 default:
309 llvm_unreachable("Only loads and stores have p2align values");
Dan Gohmanbb372242016-01-26 03:39:31 +0000310 }
311}
312
Derek Schuffc97ba932016-01-30 21:43:08 +0000313/// The operand number of the load or store address in load/store instructions.
Dan Gohman48abaa92016-10-25 00:17:11 +0000314static const unsigned LoadAddressOperandNo = 3;
315static const unsigned StoreAddressOperandNo = 2;
Dan Gohman7f1bdb22016-10-06 22:08:28 +0000316
317/// The operand number of the load or store p2align in load/store instructions.
Dan Gohman48abaa92016-10-25 00:17:11 +0000318static const unsigned LoadP2AlignOperandNo = 1;
319static const unsigned StoreP2AlignOperandNo = 0;
Dan Gohmanbb372242016-01-26 03:39:31 +0000320
Dan Gohman2726b882016-10-06 22:29:32 +0000321/// This is used to indicate block signatures.
Heejin Ahn0c69a3e2018-03-02 20:52:59 +0000322enum class ExprType : unsigned {
Derek Schuff2c783852018-08-06 23:16:50 +0000323 Void = 0x40,
324 I32 = 0x7F,
325 I64 = 0x7E,
326 F32 = 0x7D,
327 F64 = 0x7C,
328 V128 = 0x7B,
Heejin Ahn0de58722018-03-08 04:05:37 +0000329 ExceptRef = 0x68
Dan Gohman4fc4e422016-10-24 19:49:43 +0000330};
331
Dan Gohman3acb1872016-10-24 23:27:49 +0000332/// Instruction opcodes emitted via means other than CodeGen.
333static const unsigned Nop = 0x01;
334static const unsigned End = 0x0b;
335
Derek Schuffe2688c42017-03-14 20:23:22 +0000336wasm::ValType toValType(const MVT &Ty);
Dan Gohman3acb1872016-10-24 23:27:49 +0000337
Dan Gohmanbb372242016-01-26 03:39:31 +0000338} // end namespace WebAssembly
339} // end namespace llvm
340
Dan Gohman10e730a2015-06-29 23:51:55 +0000341#endif