2015-06-30 07:51:55 +08:00
|
|
|
//==- WebAssemblyMCTargetDesc.h - WebAssembly Target Descriptions -*- C++ -*-=//
|
|
|
|
//
|
2019-01-19 16:50:56 +08:00
|
|
|
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
|
|
|
|
// See https://llvm.org/LICENSE.txt for license information.
|
|
|
|
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
|
2015-06-30 07:51:55 +08:00
|
|
|
//
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
///
|
|
|
|
/// \file
|
2018-05-01 23:54:18 +08:00
|
|
|
/// This file provides WebAssembly-specific target descriptions.
|
2015-06-30 07:51:55 +08:00
|
|
|
///
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
|
|
|
|
#ifndef LLVM_LIB_TARGET_WEBASSEMBLY_MCTARGETDESC_WEBASSEMBLYMCTARGETDESC_H
|
|
|
|
#define LLVM_LIB_TARGET_WEBASSEMBLY_MCTARGETDESC_WEBASSEMBLYMCTARGETDESC_H
|
|
|
|
|
[WebAssembly] Merge used feature sets, update atomics linkage policy
Summary:
It does not currently make sense to use WebAssembly features in some functions
but not others, so this CL adds an IR pass that takes the union of all used
feature sets and applies it to each function in the module. This allows us to
prevent atomics from being lowered away if some function has opted in to using
them. When atomics is not enabled anywhere, we detect whether there exists any
atomic operations or thread local storage that would be stripped and disallow
linking with objects that contain atomics if and only if atomics or tls are
stripped. When atomics is enabled, mark it as used but do not require it of
other objects in the link. These changes allow libraries that do not use atomics
to be built once and linked into both single-threaded and multithreaded
binaries.
Reviewers: aheejin, sbc100, dschuff
Subscribers: jgravelle-google, hiraditya, sunfish, jfb, llvm-commits
Tags: #llvm
Differential Revision: https://reviews.llvm.org/D59625
llvm-svn: 357226
2019-03-29 08:14:01 +08:00
|
|
|
#include "../WebAssemblySubtarget.h"
|
2017-06-07 11:48:56 +08:00
|
|
|
#include "llvm/BinaryFormat/Wasm.h"
|
2016-01-12 11:09:16 +08:00
|
|
|
#include "llvm/MC/MCInstrDesc.h"
|
2015-06-30 07:51:55 +08:00
|
|
|
#include "llvm/Support/DataTypes.h"
|
2017-10-11 01:31:43 +08:00
|
|
|
#include <memory>
|
2015-06-30 07:51:55 +08:00
|
|
|
|
|
|
|
namespace llvm {
|
|
|
|
|
|
|
|
class MCAsmBackend;
|
|
|
|
class MCCodeEmitter;
|
|
|
|
class MCContext;
|
|
|
|
class MCInstrInfo;
|
2018-05-22 03:20:29 +08:00
|
|
|
class MCObjectTargetWriter;
|
2015-06-30 07:51:55 +08:00
|
|
|
class MCSubtargetInfo;
|
2016-10-25 07:27:49 +08:00
|
|
|
class MVT;
|
2015-06-30 07:51:55 +08:00
|
|
|
class Target;
|
|
|
|
class Triple;
|
2015-11-24 00:50:18 +08:00
|
|
|
class raw_pwrite_stream;
|
2015-06-30 07:51:55 +08:00
|
|
|
|
2016-10-10 07:00:34 +08:00
|
|
|
Target &getTheWebAssemblyTarget32();
|
|
|
|
Target &getTheWebAssemblyTarget64();
|
2015-06-30 07:51:55 +08:00
|
|
|
|
2017-06-17 07:59:10 +08:00
|
|
|
MCCodeEmitter *createWebAssemblyMCCodeEmitter(const MCInstrInfo &MCII);
|
2015-11-24 00:50:18 +08:00
|
|
|
|
2016-01-08 08:43:54 +08:00
|
|
|
MCAsmBackend *createWebAssemblyAsmBackend(const Triple &TT);
|
2015-06-30 07:51:55 +08:00
|
|
|
|
2018-05-22 03:20:29 +08:00
|
|
|
std::unique_ptr<MCObjectTargetWriter>
|
|
|
|
createWebAssemblyWasmObjectWriter(bool Is64Bit);
|
2017-02-22 09:23:18 +08:00
|
|
|
|
2016-01-12 11:09:16 +08:00
|
|
|
namespace WebAssembly {
|
|
|
|
enum OperandType {
|
|
|
|
/// Basic block label in a branch construct.
|
|
|
|
OPERAND_BASIC_BLOCK = MCOI::OPERAND_FIRST_TARGET,
|
2016-10-25 03:49:43 +08:00
|
|
|
/// Local index.
|
|
|
|
OPERAND_LOCAL,
|
2017-02-03 03:29:44 +08:00
|
|
|
/// Global index.
|
|
|
|
OPERAND_GLOBAL,
|
2016-10-06 05:24:08 +08:00
|
|
|
/// 32-bit integer immediates.
|
|
|
|
OPERAND_I32IMM,
|
|
|
|
/// 64-bit integer immediates.
|
|
|
|
OPERAND_I64IMM,
|
2016-02-16 23:14:23 +08:00
|
|
|
/// 32-bit floating-point immediates.
|
2016-10-04 05:31:31 +08:00
|
|
|
OPERAND_F32IMM,
|
2016-02-16 23:14:23 +08:00
|
|
|
/// 64-bit floating-point immediates.
|
2016-10-04 05:31:31 +08:00
|
|
|
OPERAND_F64IMM,
|
2018-08-22 05:03:18 +08:00
|
|
|
/// 8-bit vector lane immediate
|
|
|
|
OPERAND_VEC_I8IMM,
|
|
|
|
/// 16-bit vector lane immediate
|
|
|
|
OPERAND_VEC_I16IMM,
|
|
|
|
/// 32-bit vector lane immediate
|
|
|
|
OPERAND_VEC_I32IMM,
|
|
|
|
/// 64-bit vector lane immediate
|
|
|
|
OPERAND_VEC_I64IMM,
|
2016-12-23 11:23:52 +08:00
|
|
|
/// 32-bit unsigned function indices.
|
|
|
|
OPERAND_FUNCTION32,
|
|
|
|
/// 32-bit unsigned memory offsets.
|
|
|
|
OPERAND_OFFSET32,
|
2016-01-26 11:39:31 +08:00
|
|
|
/// p2align immediate for load and store address alignment.
|
2016-10-07 06:29:32 +08:00
|
|
|
OPERAND_P2ALIGN,
|
|
|
|
/// signature immediate for block/loop.
|
2017-02-25 07:18:00 +08:00
|
|
|
OPERAND_SIGNATURE,
|
|
|
|
/// type signature immediate for call_indirect.
|
|
|
|
OPERAND_TYPEINDEX,
|
2018-11-14 10:46:21 +08:00
|
|
|
/// Event index.
|
|
|
|
OPERAND_EVENT,
|
2019-01-04 07:01:30 +08:00
|
|
|
/// A list of branch targets for br_list.
|
|
|
|
OPERAND_BRLIST,
|
2016-01-12 11:09:16 +08:00
|
|
|
};
|
|
|
|
} // end namespace WebAssembly
|
|
|
|
|
|
|
|
namespace WebAssemblyII {
|
2018-08-03 22:33:37 +08:00
|
|
|
|
|
|
|
/// Target Operand Flag enum.
|
|
|
|
enum TOF {
|
|
|
|
MO_NO_FLAG = 0,
|
|
|
|
|
2019-04-05 01:43:50 +08:00
|
|
|
// On a symbol operand this indicates that the immediate is a wasm global
|
|
|
|
// index. The value of the wasm global will be set to the symbol address at
|
|
|
|
// runtime. This adds a level of indirection similar to the GOT on native
|
|
|
|
// platforms.
|
2019-04-03 08:17:29 +08:00
|
|
|
MO_GOT,
|
2019-04-05 01:43:50 +08:00
|
|
|
|
|
|
|
// On a symbol operand this indicates that the immediate is the symbol
|
|
|
|
// address relative the __memory_base wasm global.
|
|
|
|
// Only applicable to data symbols.
|
|
|
|
MO_MEMORY_BASE_REL,
|
|
|
|
|
|
|
|
// On a symbol operand this indicates that the immediate is the symbol
|
|
|
|
// address relative the __table_base wasm global.
|
|
|
|
// Only applicable to function symbols.
|
|
|
|
MO_TABLE_BASE_REL,
|
2018-08-03 22:33:37 +08:00
|
|
|
};
|
2019-03-27 03:46:15 +08:00
|
|
|
|
2016-01-12 11:09:16 +08:00
|
|
|
} // end namespace WebAssemblyII
|
|
|
|
|
2015-06-30 07:51:55 +08:00
|
|
|
} // end namespace llvm
|
|
|
|
|
|
|
|
// Defines symbolic names for WebAssembly registers. This defines a mapping from
|
|
|
|
// register name to register number.
|
|
|
|
//
|
2015-07-11 02:23:10 +08:00
|
|
|
#define GET_REGINFO_ENUM
|
|
|
|
#include "WebAssemblyGenRegisterInfo.inc"
|
|
|
|
|
2015-07-23 05:28:15 +08:00
|
|
|
// Defines symbolic names for the WebAssembly instructions.
|
|
|
|
//
|
|
|
|
#define GET_INSTRINFO_ENUM
|
|
|
|
#include "WebAssemblyGenInstrInfo.inc"
|
|
|
|
|
2016-01-26 11:39:31 +08:00
|
|
|
namespace llvm {
|
|
|
|
namespace WebAssembly {
|
|
|
|
|
|
|
|
/// Return the default p2align value for a load or store with the given opcode.
|
|
|
|
inline unsigned GetDefaultP2Align(unsigned Opcode) {
|
|
|
|
switch (Opcode) {
|
|
|
|
case WebAssembly::LOAD8_S_I32:
|
2018-06-19 05:22:44 +08:00
|
|
|
case WebAssembly::LOAD8_S_I32_S:
|
2016-01-26 11:39:31 +08:00
|
|
|
case WebAssembly::LOAD8_U_I32:
|
2018-06-19 05:22:44 +08:00
|
|
|
case WebAssembly::LOAD8_U_I32_S:
|
2016-01-26 11:39:31 +08:00
|
|
|
case WebAssembly::LOAD8_S_I64:
|
2018-06-19 05:22:44 +08:00
|
|
|
case WebAssembly::LOAD8_S_I64_S:
|
2016-01-26 11:39:31 +08:00
|
|
|
case WebAssembly::LOAD8_U_I64:
|
2018-06-19 05:22:44 +08:00
|
|
|
case WebAssembly::LOAD8_U_I64_S:
|
2017-10-06 05:18:42 +08:00
|
|
|
case WebAssembly::ATOMIC_LOAD8_U_I32:
|
2018-06-19 05:22:44 +08:00
|
|
|
case WebAssembly::ATOMIC_LOAD8_U_I32_S:
|
2017-10-06 05:18:42 +08:00
|
|
|
case WebAssembly::ATOMIC_LOAD8_U_I64:
|
2018-06-19 05:22:44 +08:00
|
|
|
case WebAssembly::ATOMIC_LOAD8_U_I64_S:
|
2016-01-26 11:39:31 +08:00
|
|
|
case WebAssembly::STORE8_I32:
|
2018-06-19 05:22:44 +08:00
|
|
|
case WebAssembly::STORE8_I32_S:
|
2016-01-26 11:39:31 +08:00
|
|
|
case WebAssembly::STORE8_I64:
|
2018-06-19 05:22:44 +08:00
|
|
|
case WebAssembly::STORE8_I64_S:
|
2018-07-03 05:22:59 +08:00
|
|
|
case WebAssembly::ATOMIC_STORE8_I32:
|
2018-07-06 05:27:09 +08:00
|
|
|
case WebAssembly::ATOMIC_STORE8_I32_S:
|
2018-07-03 05:22:59 +08:00
|
|
|
case WebAssembly::ATOMIC_STORE8_I64:
|
2018-07-06 05:27:09 +08:00
|
|
|
case WebAssembly::ATOMIC_STORE8_I64_S:
|
[WebAssembly] Support for binary atomic RMW instructions
Summary:
This adds support for binary atomic read-modify-write instructions:
add, sub, and, or, xor, and xchg.
This does not yet support translations of some of LLVM IR atomicrmw
instructions (nand, max, min, umax, and umin) that do not have a direct
counterpart in wasm instructions.
Reviewers: dschuff
Subscribers: sbc100, jgravelle-google, sunfish, llvm-commits
Differential Revision: https://reviews.llvm.org/D49088
llvm-svn: 336615
2018-07-10 06:30:51 +08:00
|
|
|
case WebAssembly::ATOMIC_RMW8_U_ADD_I32:
|
|
|
|
case WebAssembly::ATOMIC_RMW8_U_ADD_I32_S:
|
|
|
|
case WebAssembly::ATOMIC_RMW8_U_ADD_I64:
|
|
|
|
case WebAssembly::ATOMIC_RMW8_U_ADD_I64_S:
|
|
|
|
case WebAssembly::ATOMIC_RMW8_U_SUB_I32:
|
|
|
|
case WebAssembly::ATOMIC_RMW8_U_SUB_I32_S:
|
|
|
|
case WebAssembly::ATOMIC_RMW8_U_SUB_I64:
|
|
|
|
case WebAssembly::ATOMIC_RMW8_U_SUB_I64_S:
|
|
|
|
case WebAssembly::ATOMIC_RMW8_U_AND_I32:
|
|
|
|
case WebAssembly::ATOMIC_RMW8_U_AND_I32_S:
|
|
|
|
case WebAssembly::ATOMIC_RMW8_U_AND_I64:
|
|
|
|
case WebAssembly::ATOMIC_RMW8_U_AND_I64_S:
|
|
|
|
case WebAssembly::ATOMIC_RMW8_U_OR_I32:
|
|
|
|
case WebAssembly::ATOMIC_RMW8_U_OR_I32_S:
|
|
|
|
case WebAssembly::ATOMIC_RMW8_U_OR_I64:
|
|
|
|
case WebAssembly::ATOMIC_RMW8_U_OR_I64_S:
|
|
|
|
case WebAssembly::ATOMIC_RMW8_U_XOR_I32:
|
|
|
|
case WebAssembly::ATOMIC_RMW8_U_XOR_I32_S:
|
|
|
|
case WebAssembly::ATOMIC_RMW8_U_XOR_I64:
|
|
|
|
case WebAssembly::ATOMIC_RMW8_U_XOR_I64_S:
|
|
|
|
case WebAssembly::ATOMIC_RMW8_U_XCHG_I32:
|
|
|
|
case WebAssembly::ATOMIC_RMW8_U_XCHG_I32_S:
|
|
|
|
case WebAssembly::ATOMIC_RMW8_U_XCHG_I64:
|
|
|
|
case WebAssembly::ATOMIC_RMW8_U_XCHG_I64_S:
|
2018-08-02 03:40:28 +08:00
|
|
|
case WebAssembly::ATOMIC_RMW8_U_CMPXCHG_I32:
|
|
|
|
case WebAssembly::ATOMIC_RMW8_U_CMPXCHG_I32_S:
|
|
|
|
case WebAssembly::ATOMIC_RMW8_U_CMPXCHG_I64:
|
|
|
|
case WebAssembly::ATOMIC_RMW8_U_CMPXCHG_I64_S:
|
2016-01-26 11:39:31 +08:00
|
|
|
return 0;
|
|
|
|
case WebAssembly::LOAD16_S_I32:
|
2018-06-19 05:22:44 +08:00
|
|
|
case WebAssembly::LOAD16_S_I32_S:
|
2016-01-26 11:39:31 +08:00
|
|
|
case WebAssembly::LOAD16_U_I32:
|
2018-06-19 05:22:44 +08:00
|
|
|
case WebAssembly::LOAD16_U_I32_S:
|
2016-01-26 11:39:31 +08:00
|
|
|
case WebAssembly::LOAD16_S_I64:
|
2018-06-19 05:22:44 +08:00
|
|
|
case WebAssembly::LOAD16_S_I64_S:
|
2016-01-26 11:39:31 +08:00
|
|
|
case WebAssembly::LOAD16_U_I64:
|
2018-06-19 05:22:44 +08:00
|
|
|
case WebAssembly::LOAD16_U_I64_S:
|
2017-10-06 05:18:42 +08:00
|
|
|
case WebAssembly::ATOMIC_LOAD16_U_I32:
|
2018-06-19 05:22:44 +08:00
|
|
|
case WebAssembly::ATOMIC_LOAD16_U_I32_S:
|
2017-10-06 05:18:42 +08:00
|
|
|
case WebAssembly::ATOMIC_LOAD16_U_I64:
|
2018-06-19 05:22:44 +08:00
|
|
|
case WebAssembly::ATOMIC_LOAD16_U_I64_S:
|
2016-01-26 11:39:31 +08:00
|
|
|
case WebAssembly::STORE16_I32:
|
2018-06-19 05:22:44 +08:00
|
|
|
case WebAssembly::STORE16_I32_S:
|
2016-01-26 11:39:31 +08:00
|
|
|
case WebAssembly::STORE16_I64:
|
2018-06-19 05:22:44 +08:00
|
|
|
case WebAssembly::STORE16_I64_S:
|
2018-07-03 05:22:59 +08:00
|
|
|
case WebAssembly::ATOMIC_STORE16_I32:
|
2018-07-06 05:27:09 +08:00
|
|
|
case WebAssembly::ATOMIC_STORE16_I32_S:
|
2018-07-03 05:22:59 +08:00
|
|
|
case WebAssembly::ATOMIC_STORE16_I64:
|
2018-07-06 05:27:09 +08:00
|
|
|
case WebAssembly::ATOMIC_STORE16_I64_S:
|
[WebAssembly] Support for binary atomic RMW instructions
Summary:
This adds support for binary atomic read-modify-write instructions:
add, sub, and, or, xor, and xchg.
This does not yet support translations of some of LLVM IR atomicrmw
instructions (nand, max, min, umax, and umin) that do not have a direct
counterpart in wasm instructions.
Reviewers: dschuff
Subscribers: sbc100, jgravelle-google, sunfish, llvm-commits
Differential Revision: https://reviews.llvm.org/D49088
llvm-svn: 336615
2018-07-10 06:30:51 +08:00
|
|
|
case WebAssembly::ATOMIC_RMW16_U_ADD_I32:
|
|
|
|
case WebAssembly::ATOMIC_RMW16_U_ADD_I32_S:
|
|
|
|
case WebAssembly::ATOMIC_RMW16_U_ADD_I64:
|
|
|
|
case WebAssembly::ATOMIC_RMW16_U_ADD_I64_S:
|
|
|
|
case WebAssembly::ATOMIC_RMW16_U_SUB_I32:
|
|
|
|
case WebAssembly::ATOMIC_RMW16_U_SUB_I32_S:
|
|
|
|
case WebAssembly::ATOMIC_RMW16_U_SUB_I64:
|
|
|
|
case WebAssembly::ATOMIC_RMW16_U_SUB_I64_S:
|
|
|
|
case WebAssembly::ATOMIC_RMW16_U_AND_I32:
|
|
|
|
case WebAssembly::ATOMIC_RMW16_U_AND_I32_S:
|
|
|
|
case WebAssembly::ATOMIC_RMW16_U_AND_I64:
|
|
|
|
case WebAssembly::ATOMIC_RMW16_U_AND_I64_S:
|
|
|
|
case WebAssembly::ATOMIC_RMW16_U_OR_I32:
|
|
|
|
case WebAssembly::ATOMIC_RMW16_U_OR_I32_S:
|
|
|
|
case WebAssembly::ATOMIC_RMW16_U_OR_I64:
|
|
|
|
case WebAssembly::ATOMIC_RMW16_U_OR_I64_S:
|
|
|
|
case WebAssembly::ATOMIC_RMW16_U_XOR_I32:
|
|
|
|
case WebAssembly::ATOMIC_RMW16_U_XOR_I32_S:
|
|
|
|
case WebAssembly::ATOMIC_RMW16_U_XOR_I64:
|
|
|
|
case WebAssembly::ATOMIC_RMW16_U_XOR_I64_S:
|
|
|
|
case WebAssembly::ATOMIC_RMW16_U_XCHG_I32:
|
|
|
|
case WebAssembly::ATOMIC_RMW16_U_XCHG_I32_S:
|
|
|
|
case WebAssembly::ATOMIC_RMW16_U_XCHG_I64:
|
|
|
|
case WebAssembly::ATOMIC_RMW16_U_XCHG_I64_S:
|
2018-08-02 03:40:28 +08:00
|
|
|
case WebAssembly::ATOMIC_RMW16_U_CMPXCHG_I32:
|
|
|
|
case WebAssembly::ATOMIC_RMW16_U_CMPXCHG_I32_S:
|
|
|
|
case WebAssembly::ATOMIC_RMW16_U_CMPXCHG_I64:
|
|
|
|
case WebAssembly::ATOMIC_RMW16_U_CMPXCHG_I64_S:
|
2016-01-26 11:39:31 +08:00
|
|
|
return 1;
|
|
|
|
case WebAssembly::LOAD_I32:
|
2018-06-19 05:22:44 +08:00
|
|
|
case WebAssembly::LOAD_I32_S:
|
2016-01-26 11:39:31 +08:00
|
|
|
case WebAssembly::LOAD_F32:
|
2018-06-19 05:22:44 +08:00
|
|
|
case WebAssembly::LOAD_F32_S:
|
2016-01-26 11:39:31 +08:00
|
|
|
case WebAssembly::STORE_I32:
|
2018-06-19 05:22:44 +08:00
|
|
|
case WebAssembly::STORE_I32_S:
|
2016-01-26 11:39:31 +08:00
|
|
|
case WebAssembly::STORE_F32:
|
2018-06-19 05:22:44 +08:00
|
|
|
case WebAssembly::STORE_F32_S:
|
2016-01-26 11:39:31 +08:00
|
|
|
case WebAssembly::LOAD32_S_I64:
|
2018-06-19 05:22:44 +08:00
|
|
|
case WebAssembly::LOAD32_S_I64_S:
|
2016-01-26 11:39:31 +08:00
|
|
|
case WebAssembly::LOAD32_U_I64:
|
2018-06-19 05:22:44 +08:00
|
|
|
case WebAssembly::LOAD32_U_I64_S:
|
2016-01-26 11:39:31 +08:00
|
|
|
case WebAssembly::STORE32_I64:
|
2018-06-19 05:22:44 +08:00
|
|
|
case WebAssembly::STORE32_I64_S:
|
2017-08-31 02:07:45 +08:00
|
|
|
case WebAssembly::ATOMIC_LOAD_I32:
|
2018-06-19 05:22:44 +08:00
|
|
|
case WebAssembly::ATOMIC_LOAD_I32_S:
|
2017-10-06 05:18:42 +08:00
|
|
|
case WebAssembly::ATOMIC_LOAD32_U_I64:
|
2018-06-19 05:22:44 +08:00
|
|
|
case WebAssembly::ATOMIC_LOAD32_U_I64_S:
|
2018-07-03 05:22:59 +08:00
|
|
|
case WebAssembly::ATOMIC_STORE_I32:
|
2018-07-06 05:27:09 +08:00
|
|
|
case WebAssembly::ATOMIC_STORE_I32_S:
|
2018-07-03 05:22:59 +08:00
|
|
|
case WebAssembly::ATOMIC_STORE32_I64:
|
2018-07-06 05:27:09 +08:00
|
|
|
case WebAssembly::ATOMIC_STORE32_I64_S:
|
[WebAssembly] Support for binary atomic RMW instructions
Summary:
This adds support for binary atomic read-modify-write instructions:
add, sub, and, or, xor, and xchg.
This does not yet support translations of some of LLVM IR atomicrmw
instructions (nand, max, min, umax, and umin) that do not have a direct
counterpart in wasm instructions.
Reviewers: dschuff
Subscribers: sbc100, jgravelle-google, sunfish, llvm-commits
Differential Revision: https://reviews.llvm.org/D49088
llvm-svn: 336615
2018-07-10 06:30:51 +08:00
|
|
|
case WebAssembly::ATOMIC_RMW_ADD_I32:
|
|
|
|
case WebAssembly::ATOMIC_RMW_ADD_I32_S:
|
|
|
|
case WebAssembly::ATOMIC_RMW32_U_ADD_I64:
|
|
|
|
case WebAssembly::ATOMIC_RMW32_U_ADD_I64_S:
|
|
|
|
case WebAssembly::ATOMIC_RMW_SUB_I32:
|
|
|
|
case WebAssembly::ATOMIC_RMW_SUB_I32_S:
|
|
|
|
case WebAssembly::ATOMIC_RMW32_U_SUB_I64:
|
|
|
|
case WebAssembly::ATOMIC_RMW32_U_SUB_I64_S:
|
|
|
|
case WebAssembly::ATOMIC_RMW_AND_I32:
|
|
|
|
case WebAssembly::ATOMIC_RMW_AND_I32_S:
|
|
|
|
case WebAssembly::ATOMIC_RMW32_U_AND_I64:
|
|
|
|
case WebAssembly::ATOMIC_RMW32_U_AND_I64_S:
|
|
|
|
case WebAssembly::ATOMIC_RMW_OR_I32:
|
|
|
|
case WebAssembly::ATOMIC_RMW_OR_I32_S:
|
|
|
|
case WebAssembly::ATOMIC_RMW32_U_OR_I64:
|
|
|
|
case WebAssembly::ATOMIC_RMW32_U_OR_I64_S:
|
|
|
|
case WebAssembly::ATOMIC_RMW_XOR_I32:
|
|
|
|
case WebAssembly::ATOMIC_RMW_XOR_I32_S:
|
|
|
|
case WebAssembly::ATOMIC_RMW32_U_XOR_I64:
|
|
|
|
case WebAssembly::ATOMIC_RMW32_U_XOR_I64_S:
|
|
|
|
case WebAssembly::ATOMIC_RMW_XCHG_I32:
|
|
|
|
case WebAssembly::ATOMIC_RMW_XCHG_I32_S:
|
|
|
|
case WebAssembly::ATOMIC_RMW32_U_XCHG_I64:
|
|
|
|
case WebAssembly::ATOMIC_RMW32_U_XCHG_I64_S:
|
2018-08-02 03:40:28 +08:00
|
|
|
case WebAssembly::ATOMIC_RMW_CMPXCHG_I32:
|
|
|
|
case WebAssembly::ATOMIC_RMW_CMPXCHG_I32_S:
|
|
|
|
case WebAssembly::ATOMIC_RMW32_U_CMPXCHG_I64:
|
|
|
|
case WebAssembly::ATOMIC_RMW32_U_CMPXCHG_I64_S:
|
2018-08-03 05:44:24 +08:00
|
|
|
case WebAssembly::ATOMIC_NOTIFY:
|
|
|
|
case WebAssembly::ATOMIC_NOTIFY_S:
|
|
|
|
case WebAssembly::ATOMIC_WAIT_I32:
|
|
|
|
case WebAssembly::ATOMIC_WAIT_I32_S:
|
2016-01-26 11:39:31 +08:00
|
|
|
return 2;
|
|
|
|
case WebAssembly::LOAD_I64:
|
2018-06-19 05:22:44 +08:00
|
|
|
case WebAssembly::LOAD_I64_S:
|
2016-01-26 11:39:31 +08:00
|
|
|
case WebAssembly::LOAD_F64:
|
2018-06-19 05:22:44 +08:00
|
|
|
case WebAssembly::LOAD_F64_S:
|
2016-01-26 11:39:31 +08:00
|
|
|
case WebAssembly::STORE_I64:
|
2018-06-19 05:22:44 +08:00
|
|
|
case WebAssembly::STORE_I64_S:
|
2016-01-26 11:39:31 +08:00
|
|
|
case WebAssembly::STORE_F64:
|
2018-06-19 05:22:44 +08:00
|
|
|
case WebAssembly::STORE_F64_S:
|
2017-10-06 05:18:42 +08:00
|
|
|
case WebAssembly::ATOMIC_LOAD_I64:
|
2018-06-19 05:22:44 +08:00
|
|
|
case WebAssembly::ATOMIC_LOAD_I64_S:
|
2018-07-03 05:22:59 +08:00
|
|
|
case WebAssembly::ATOMIC_STORE_I64:
|
2018-07-06 05:27:09 +08:00
|
|
|
case WebAssembly::ATOMIC_STORE_I64_S:
|
[WebAssembly] Support for binary atomic RMW instructions
Summary:
This adds support for binary atomic read-modify-write instructions:
add, sub, and, or, xor, and xchg.
This does not yet support translations of some of LLVM IR atomicrmw
instructions (nand, max, min, umax, and umin) that do not have a direct
counterpart in wasm instructions.
Reviewers: dschuff
Subscribers: sbc100, jgravelle-google, sunfish, llvm-commits
Differential Revision: https://reviews.llvm.org/D49088
llvm-svn: 336615
2018-07-10 06:30:51 +08:00
|
|
|
case WebAssembly::ATOMIC_RMW_ADD_I64:
|
|
|
|
case WebAssembly::ATOMIC_RMW_ADD_I64_S:
|
|
|
|
case WebAssembly::ATOMIC_RMW_SUB_I64:
|
|
|
|
case WebAssembly::ATOMIC_RMW_SUB_I64_S:
|
|
|
|
case WebAssembly::ATOMIC_RMW_AND_I64:
|
|
|
|
case WebAssembly::ATOMIC_RMW_AND_I64_S:
|
|
|
|
case WebAssembly::ATOMIC_RMW_OR_I64:
|
|
|
|
case WebAssembly::ATOMIC_RMW_OR_I64_S:
|
|
|
|
case WebAssembly::ATOMIC_RMW_XOR_I64:
|
|
|
|
case WebAssembly::ATOMIC_RMW_XOR_I64_S:
|
|
|
|
case WebAssembly::ATOMIC_RMW_XCHG_I64:
|
|
|
|
case WebAssembly::ATOMIC_RMW_XCHG_I64_S:
|
2018-08-02 03:40:28 +08:00
|
|
|
case WebAssembly::ATOMIC_RMW_CMPXCHG_I64:
|
|
|
|
case WebAssembly::ATOMIC_RMW_CMPXCHG_I64_S:
|
2018-08-03 05:44:24 +08:00
|
|
|
case WebAssembly::ATOMIC_WAIT_I64:
|
|
|
|
case WebAssembly::ATOMIC_WAIT_I64_S:
|
2016-01-26 11:39:31 +08:00
|
|
|
return 3;
|
2018-08-31 05:36:48 +08:00
|
|
|
case WebAssembly::LOAD_v16i8:
|
|
|
|
case WebAssembly::LOAD_v16i8_S:
|
|
|
|
case WebAssembly::LOAD_v8i16:
|
|
|
|
case WebAssembly::LOAD_v8i16_S:
|
|
|
|
case WebAssembly::LOAD_v4i32:
|
|
|
|
case WebAssembly::LOAD_v4i32_S:
|
|
|
|
case WebAssembly::LOAD_v2i64:
|
|
|
|
case WebAssembly::LOAD_v2i64_S:
|
|
|
|
case WebAssembly::LOAD_v4f32:
|
|
|
|
case WebAssembly::LOAD_v4f32_S:
|
|
|
|
case WebAssembly::LOAD_v2f64:
|
|
|
|
case WebAssembly::LOAD_v2f64_S:
|
|
|
|
case WebAssembly::STORE_v16i8:
|
|
|
|
case WebAssembly::STORE_v16i8_S:
|
|
|
|
case WebAssembly::STORE_v8i16:
|
|
|
|
case WebAssembly::STORE_v8i16_S:
|
|
|
|
case WebAssembly::STORE_v4i32:
|
|
|
|
case WebAssembly::STORE_v4i32_S:
|
|
|
|
case WebAssembly::STORE_v2i64:
|
|
|
|
case WebAssembly::STORE_v2i64_S:
|
|
|
|
case WebAssembly::STORE_v4f32:
|
|
|
|
case WebAssembly::STORE_v4f32_S:
|
|
|
|
case WebAssembly::STORE_v2f64:
|
|
|
|
case WebAssembly::STORE_v2f64_S:
|
|
|
|
return 4;
|
2016-08-02 06:25:02 +08:00
|
|
|
default:
|
|
|
|
llvm_unreachable("Only loads and stores have p2align values");
|
2016-01-26 11:39:31 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2016-10-07 06:29:32 +08:00
|
|
|
/// This is used to indicate block signatures.
|
2018-03-03 04:52:59 +08:00
|
|
|
enum class ExprType : unsigned {
|
2018-08-07 07:16:50 +08:00
|
|
|
Void = 0x40,
|
|
|
|
I32 = 0x7F,
|
|
|
|
I64 = 0x7E,
|
|
|
|
F32 = 0x7D,
|
|
|
|
F64 = 0x7C,
|
|
|
|
V128 = 0x7B,
|
2019-01-03 07:23:51 +08:00
|
|
|
ExceptRef = 0x68,
|
|
|
|
Invalid = 0x00
|
2016-10-25 03:49:43 +08:00
|
|
|
};
|
|
|
|
|
2016-10-25 07:27:49 +08:00
|
|
|
/// Instruction opcodes emitted via means other than CodeGen.
|
|
|
|
static const unsigned Nop = 0x01;
|
|
|
|
static const unsigned End = 0x0b;
|
|
|
|
|
2017-03-15 04:23:22 +08:00
|
|
|
wasm::ValType toValType(const MVT &Ty);
|
2016-10-25 07:27:49 +08:00
|
|
|
|
2016-01-26 11:39:31 +08:00
|
|
|
} // end namespace WebAssembly
|
|
|
|
} // end namespace llvm
|
|
|
|
|
2015-06-30 07:51:55 +08:00
|
|
|
#endif
|