Commit ba4e3163 authored by titzer's avatar titzer Committed by Commit bot

[wasm] Use the official opcode names everywhere.

R=clemensh@chromium.org
BUG=

Review-Url: https://codereview.chromium.org/2644323002
Cr-Commit-Position: refs/heads/master@{#42557}
parent 1b690f43
......@@ -3351,10 +3351,10 @@ Node* WasmGraphBuilder::SimdOp(wasm::WasmOpcode opcode,
case wasm::kExprF32x4Splat:
return graph()->NewNode(jsgraph()->machine()->CreateFloat32x4(),
inputs[0], inputs[0], inputs[0], inputs[0]);
case wasm::kExprF32x4FromInt32x4:
case wasm::kExprF32x4SConvertI32x4:
return graph()->NewNode(jsgraph()->machine()->Float32x4FromInt32x4(),
inputs[0]);
case wasm::kExprF32x4FromUint32x4:
case wasm::kExprF32x4UConvertI32x4:
return graph()->NewNode(jsgraph()->machine()->Float32x4FromUint32x4(),
inputs[0]);
case wasm::kExprF32x4Abs:
......@@ -3376,10 +3376,10 @@ Node* WasmGraphBuilder::SimdOp(wasm::WasmOpcode opcode,
case wasm::kExprI32x4Splat:
return graph()->NewNode(jsgraph()->machine()->CreateInt32x4(), inputs[0],
inputs[0], inputs[0], inputs[0]);
case wasm::kExprI32x4FromFloat32x4:
case wasm::kExprI32x4SConvertF32x4:
return graph()->NewNode(jsgraph()->machine()->Int32x4FromFloat32x4(),
inputs[0]);
case wasm::kExprUi32x4FromFloat32x4:
case wasm::kExprI32x4UConvertF32x4:
return graph()->NewNode(jsgraph()->machine()->Uint32x4FromFloat32x4(),
inputs[0]);
case wasm::kExprI32x4Add:
......
......@@ -659,7 +659,7 @@ class WasmFullDecoder : public WasmDecoder {
WasmOpcode opcode = static_cast<WasmOpcode>(*pc_);
if (!WasmOpcodes::IsPrefixOpcode(opcode)) {
TRACE(" @%-8d #%02x:%-20s|", startrel(pc_), opcode,
WasmOpcodes::ShortOpcodeName(opcode));
WasmOpcodes::OpcodeName(opcode));
}
FunctionSig* sig = WasmOpcodes::Signature(opcode);
......@@ -852,7 +852,7 @@ class WasmFullDecoder : public WasmDecoder {
last_end_found_ = true;
if (ssa_env_->go()) {
// The result of the block is the return value.
TRACE(" @%-8d #xx:%-20s|", startrel(pc_), "ImplicitReturn");
TRACE(" @%-8d #xx:%-20s|", startrel(pc_), "(implicit) return");
DoReturn();
TRACE("\n");
}
......@@ -1164,7 +1164,7 @@ class WasmFullDecoder : public WasmDecoder {
byte simd_index = checked_read_u8(pc_, 1, "simd index");
opcode = static_cast<WasmOpcode>(opcode << 8 | simd_index);
TRACE(" @%-4d #%02x #%02x:%-20s|", startrel(pc_), kSimdPrefix,
simd_index, WasmOpcodes::ShortOpcodeName(opcode));
simd_index, WasmOpcodes::OpcodeName(opcode));
len += DecodeSimdOpcode(opcode);
break;
}
......@@ -1211,7 +1211,7 @@ class WasmFullDecoder : public WasmDecoder {
}
PrintF(" %c@%d:%s", WasmOpcodes::ShortNameOf(val.type),
static_cast<int>(val.pc - start_),
WasmOpcodes::ShortOpcodeName(opcode));
WasmOpcodes::OpcodeName(opcode));
switch (opcode) {
case kExprI32Const: {
ImmI32Operand operand(this, val.pc);
......@@ -1423,7 +1423,7 @@ class WasmFullDecoder : public WasmDecoder {
const char* SafeOpcodeNameAt(const byte* pc) {
if (pc >= end_) return "<end>";
return WasmOpcodes::ShortOpcodeName(static_cast<WasmOpcode>(*pc));
return WasmOpcodes::OpcodeName(static_cast<WasmOpcode>(*pc));
}
Value Pop(int index, ValueType expected) {
......
......@@ -630,9 +630,9 @@ class LocalDeclEncoder {
#define WASM_SIMD_F32x4_REPLACE_LANE(lane, x, y) \
x, y, kSimdPrefix, kExprF32x4ReplaceLane & 0xff, static_cast<byte>(lane)
#define WASM_SIMD_F32x4_FROM_I32x4(x) \
x, kSimdPrefix, kExprF32x4FromInt32x4 & 0xff
x, kSimdPrefix, kExprF32x4SConvertI32x4 & 0xff
#define WASM_SIMD_F32x4_FROM_U32x4(x) \
x, kSimdPrefix, kExprF32x4FromUint32x4 & 0xff
x, kSimdPrefix, kExprF32x4UConvertI32x4 & 0xff
#define WASM_SIMD_F32x4_ADD(x, y) x, y, kSimdPrefix, kExprF32x4Add & 0xff
#define WASM_SIMD_F32x4_SUB(x, y) x, y, kSimdPrefix, kExprF32x4Sub & 0xff
......@@ -642,9 +642,9 @@ class LocalDeclEncoder {
#define WASM_SIMD_I32x4_REPLACE_LANE(lane, x, y) \
x, y, kSimdPrefix, kExprI32x4ReplaceLane & 0xff, static_cast<byte>(lane)
#define WASM_SIMD_I32x4_FROM_F32x4(x) \
x, kSimdPrefix, kExprI32x4FromFloat32x4 & 0xff
x, kSimdPrefix, kExprI32x4SConvertF32x4 & 0xff
#define WASM_SIMD_U32x4_FROM_F32x4(x) \
x, kSimdPrefix, kExprUi32x4FromFloat32x4 & 0xff
x, kSimdPrefix, kExprI32x4UConvertF32x4 & 0xff
#define WASM_SIMD_S32x4_SELECT(x, y, z) \
x, y, z, kSimdPrefix, kExprS32x4Select & 0xff
#define WASM_SIMD_I32x4_ADD(x, y) x, y, kSimdPrefix, kExprI32x4Add & 0xff
......
......@@ -13,30 +13,216 @@ namespace wasm {
typedef Signature<ValueType> FunctionSig;
#define CASE_OP(name, str) \
case kExpr##name: \
return str;
#define CASE_I32_OP(name, str) CASE_OP(I32##name, "i32." str)
#define CASE_I64_OP(name, str) CASE_OP(I64##name, "i64." str)
#define CASE_F32_OP(name, str) CASE_OP(F32##name, "f32." str)
#define CASE_F64_OP(name, str) CASE_OP(F64##name, "f64." str)
#define CASE_S128_OP(name, str) CASE_OP(S128##name, "s128." str)
#define CASE_F32x4_OP(name, str) CASE_OP(F32x4##name, "f32x4." str)
#define CASE_I32x4_OP(name, str) CASE_OP(I32x4##name, "i32x4." str)
#define CASE_I16x8_OP(name, str) CASE_OP(I16x8##name, "i16x8." str)
#define CASE_I8x16_OP(name, str) CASE_OP(I8x16##name, "i8x16." str)
#define CASE_S32x4_OP(name, str) CASE_OP(S32x4##name, "s32x4." str)
#define CASE_INT_OP(name, str) CASE_I32_OP(name, str) CASE_I64_OP(name, str)
#define CASE_FLOAT_OP(name, str) CASE_F32_OP(name, str) CASE_F64_OP(name, str)
#define CASE_ALL_OP(name, str) CASE_FLOAT_OP(name, str) CASE_INT_OP(name, str)
#define CASE_SIMD_OP(name, str) \
CASE_F32x4_OP(name, str) CASE_I32x4_OP(name, str) CASE_I16x8_OP(name, str) \
CASE_I8x16_OP(name, str)
#define CASE_SIMDI_OP(name, str) \
CASE_I32x4_OP(name, str) CASE_I16x8_OP(name, str) CASE_I8x16_OP(name, str)
#define CASE_SIGN_OP(TYPE, name, str) \
CASE_##TYPE##_OP(name##S, str "_s") CASE_##TYPE##_OP(name##U, str "_u")
#define CASE_ALL_SIGN_OP(name, str) \
CASE_FLOAT_OP(name, str) CASE_SIGN_OP(INT, name, str)
#define CASE_CONVERT_OP(name, RES, SRC, src_suffix, str) \
CASE_##RES##_OP(U##name##SRC, str "_u/" src_suffix) \
CASE_##RES##_OP(S##name##SRC, str "_s/" src_suffix)
#define CASE_L32_OP(name, str) \
CASE_SIGN_OP(I32, name##8, str "8") \
CASE_SIGN_OP(I32, name##16, str "16") \
CASE_I32_OP(name, str "32")
const char* WasmOpcodes::OpcodeName(WasmOpcode opcode) {
switch (opcode) {
#define DECLARE_NAME_CASE(name, opcode, sig) \
case kExpr##name: \
return "Expr" #name;
FOREACH_OPCODE(DECLARE_NAME_CASE)
#undef DECLARE_NAME_CASE
default:
break;
}
return "Unknown";
}
// clang-format off
const char* WasmOpcodes::ShortOpcodeName(WasmOpcode opcode) {
switch (opcode) {
#define DECLARE_NAME_CASE(name, opcode, sig) \
case kExpr##name: \
return #name;
FOREACH_OPCODE(DECLARE_NAME_CASE)
#undef DECLARE_NAME_CASE
default:
break;
// Standard opcodes
CASE_INT_OP(Eqz, "eqz")
CASE_ALL_OP(Eq, "eq")
CASE_ALL_OP(Ne, "ne")
CASE_ALL_OP(Add, "add")
CASE_ALL_OP(Sub, "sub")
CASE_ALL_OP(Mul, "mul")
CASE_ALL_SIGN_OP(Lt, "lt")
CASE_ALL_SIGN_OP(Gt, "gt")
CASE_ALL_SIGN_OP(Le, "le")
CASE_ALL_SIGN_OP(Ge, "ge")
CASE_INT_OP(Clz, "clz")
CASE_INT_OP(Ctz, "ctz")
CASE_INT_OP(Popcnt, "popcnt")
CASE_ALL_SIGN_OP(Div, "div")
CASE_SIGN_OP(INT, Rem, "rem")
CASE_INT_OP(And, "and")
CASE_INT_OP(Ior, "or")
CASE_INT_OP(Xor, "xor")
CASE_INT_OP(Shl, "shl")
CASE_SIGN_OP(INT, Shr, "shr")
CASE_INT_OP(Rol, "rol")
CASE_INT_OP(Ror, "ror")
CASE_FLOAT_OP(Abs, "abs")
CASE_FLOAT_OP(Neg, "neg")
CASE_FLOAT_OP(Ceil, "ceil")
CASE_FLOAT_OP(Floor, "floor")
CASE_FLOAT_OP(Trunc, "trunc")
CASE_FLOAT_OP(NearestInt, "nearest")
CASE_FLOAT_OP(Sqrt, "sqrt")
CASE_FLOAT_OP(Min, "min")
CASE_FLOAT_OP(Max, "max")
CASE_FLOAT_OP(CopySign, "copysign")
CASE_I32_OP(ConvertI64, "wrap/i64")
CASE_CONVERT_OP(Convert, INT, F32, "f32", "trunc")
CASE_CONVERT_OP(Convert, INT, F64, "f64", "trunc")
CASE_CONVERT_OP(Convert, I64, I32, "i32", "extend")
CASE_CONVERT_OP(Convert, F32, I32, "i32", "convert")
CASE_CONVERT_OP(Convert, F32, I64, "i64", "convert")
CASE_F32_OP(ConvertF64, "demote/f64")
CASE_CONVERT_OP(Convert, F64, I32, "i32", "convert")
CASE_CONVERT_OP(Convert, F64, I64, "i64", "convert")
CASE_F64_OP(ConvertF32, "promote/f32")
CASE_I32_OP(ReinterpretF32, "reinterpret/f32")
CASE_I64_OP(ReinterpretF64, "reinterpret/f64")
CASE_F32_OP(ReinterpretI32, "reinterpret/i32")
CASE_F64_OP(ReinterpretI64, "reinterpret/i64")
CASE_OP(Unreachable, "unreachable")
CASE_OP(Nop, "nop")
CASE_OP(Block, "block")
CASE_OP(Loop, "loop")
CASE_OP(If, "if")
CASE_OP(Else, "else")
CASE_OP(End, "end")
CASE_OP(Br, "br")
CASE_OP(BrIf, "br_if")
CASE_OP(BrTable, "br_table")
CASE_OP(Return, "return")
CASE_OP(CallFunction, "call")
CASE_OP(CallIndirect, "call_indirect")
CASE_OP(Drop, "drop")
CASE_OP(Select, "select")
CASE_OP(GetLocal, "get_local")
CASE_OP(SetLocal, "set_local")
CASE_OP(TeeLocal, "tee_local")
CASE_OP(GetGlobal, "get_global")
CASE_OP(SetGlobal, "set_global")
CASE_ALL_OP(Const, "const")
CASE_OP(MemorySize, "current_memory")
CASE_OP(GrowMemory, "grow_memory")
CASE_ALL_OP(LoadMem, "load")
CASE_SIGN_OP(INT, LoadMem8, "load8")
CASE_SIGN_OP(INT, LoadMem16, "load16")
CASE_SIGN_OP(I64, LoadMem32, "load32")
CASE_ALL_OP(StoreMem, "store")
CASE_INT_OP(StoreMem8, "store8")
CASE_INT_OP(StoreMem16, "store16")
CASE_I64_OP(StoreMem32, "store32")
// Non-standard opcodes.
CASE_OP(Try, "try")
CASE_OP(Throw, "throw")
CASE_OP(Catch, "catch")
// asm.js-only opcodes.
CASE_F64_OP(Acos, "acos")
CASE_F64_OP(Asin, "asin")
CASE_F64_OP(Atan, "atan")
CASE_F64_OP(Cos, "cos")
CASE_F64_OP(Sin, "sin")
CASE_F64_OP(Tan, "tan")
CASE_F64_OP(Exp, "exp")
CASE_F64_OP(Log, "log")
CASE_F64_OP(Atan2, "atan2")
CASE_F64_OP(Pow, "pow")
CASE_F64_OP(Mod, "mod")
CASE_F32_OP(AsmjsLoadMem, "asmjs_load")
CASE_F64_OP(AsmjsLoadMem, "asmjs_load")
CASE_L32_OP(AsmjsLoadMem, "asmjs_load")
CASE_I32_OP(AsmjsStoreMem, "asmjs_store")
CASE_F32_OP(AsmjsStoreMem, "asmjs_store")
CASE_F64_OP(AsmjsStoreMem, "asmjs_store")
CASE_I32_OP(AsmjsStoreMem8, "asmjs_store8")
CASE_I32_OP(AsmjsStoreMem16, "asmjs_store16")
CASE_SIGN_OP(I32, AsmjsDiv, "asmjs_div")
CASE_SIGN_OP(I32, AsmjsRem, "asmjs_rem")
CASE_I32_OP(AsmjsSConvertF32, "asmjs_convert_s/f32")
CASE_I32_OP(AsmjsUConvertF32, "asmjs_convert_u/f32")
CASE_I32_OP(AsmjsSConvertF64, "asmjs_convert_s/f64")
CASE_I32_OP(AsmjsUConvertF64, "asmjs_convert_u/f64")
// SIMD opcodes.
CASE_SIMD_OP(Splat, "splat")
CASE_SIMD_OP(Neg, "neg")
CASE_SIMD_OP(Eq, "eq")
CASE_SIMD_OP(Ne, "ne")
CASE_SIMD_OP(Add, "add")
CASE_SIMD_OP(Sub, "sub")
CASE_SIMD_OP(Mul, "mul")
CASE_F32x4_OP(Abs, "abs")
CASE_F32x4_OP(Sqrt, "sqrt")
CASE_F32x4_OP(Div, "div")
CASE_F32x4_OP(RecipApprox, "recip_approx")
CASE_F32x4_OP(SqrtApprox, "sqrt_approx")
CASE_F32x4_OP(Min, "min")
CASE_F32x4_OP(Max, "max")
CASE_F32x4_OP(MinNum, "min_num")
CASE_F32x4_OP(MaxNum, "max_num")
CASE_F32x4_OP(Lt, "lt")
CASE_F32x4_OP(Le, "le")
CASE_F32x4_OP(Gt, "gt")
CASE_F32x4_OP(Ge, "ge")
CASE_CONVERT_OP(Convert, F32x4, I32x4, "i32", "convert")
CASE_F32x4_OP(ExtractLane, "extract_lane")
CASE_F32x4_OP(ReplaceLane, "replace_lane")
CASE_SIMDI_OP(ExtractLane, "extract_lane")
CASE_SIMDI_OP(ReplaceLane, "replace_lane")
CASE_SIGN_OP(SIMDI, Min, "min")
CASE_SIGN_OP(SIMDI, Max, "max")
CASE_SIGN_OP(SIMDI, Lt, "lt")
CASE_SIGN_OP(SIMDI, Le, "le")
CASE_SIGN_OP(SIMDI, Gt, "gt")
CASE_SIGN_OP(SIMDI, Ge, "ge")
CASE_SIGN_OP(SIMDI, Shr, "shr")
CASE_SIMDI_OP(Shl, "shl")
CASE_SIMDI_OP(Swizzle, "swizzle")
CASE_SIMDI_OP(Shuffle, "shuffle")
CASE_SIMDI_OP(Select, "select")
CASE_S128_OP(Ior, "or")
CASE_S128_OP(Xor, "xor")
CASE_S128_OP(And, "and")
CASE_S128_OP(Not, "not")
CASE_S32x4_OP(Select, "select")
CASE_S32x4_OP(Swizzle, "swizzle")
CASE_S32x4_OP(Shuffle, "shuffle")
CASE_CONVERT_OP(Convert, I32x4, F32x4, "f32", "convert")
CASE_SIGN_OP(I16x8, AddSaturate, "add_saturate")
CASE_SIGN_OP(I8x16, AddSaturate, "add_saturate")
CASE_SIGN_OP(I16x8, SubSaturate, "sub_saturate")
CASE_SIGN_OP(I8x16, SubSaturate, "sub_saturate")
// Atomic operations.
CASE_L32_OP(AtomicAdd, "atomic_add")
CASE_L32_OP(AtomicAnd, "atomic_and")
CASE_L32_OP(AtomicCompareExchange, "atomic_cmpxchng")
CASE_L32_OP(AtomicExchange, "atomic_xchng")
CASE_L32_OP(AtomicOr, "atomic_or")
CASE_L32_OP(AtomicSub, "atomic_sub")
CASE_L32_OP(AtomicXor, "atomic_xor")
default : return "unknown";
// clang-format on
}
return "Unknown";
}
bool WasmOpcodes::IsPrefixOpcode(WasmOpcode opcode) {
......
......@@ -295,93 +295,93 @@ const WasmCodePosition kNoCodePosition = -1;
V(F32x4Le, 0xe513, s_ss) \
V(F32x4Gt, 0xe514, s_ss) \
V(F32x4Ge, 0xe515, s_ss) \
V(F32x4FromInt32x4, 0xe519, s_s) \
V(F32x4FromUint32x4, 0xe51a, s_s) \
V(F32x4SConvertI32x4, 0xe519, s_s) \
V(F32x4UConvertI32x4, 0xe51a, s_s) \
V(I32x4Splat, 0xe51b, s_i) \
V(I32x4Neg, 0xe51e, s_s) \
V(I32x4Add, 0xe51f, s_ss) \
V(I32x4Sub, 0xe520, s_ss) \
V(I32x4Mul, 0xe521, s_ss) \
V(I32x4Min_s, 0xe522, s_ss) \
V(I32x4Max_s, 0xe523, s_ss) \
V(I32x4MinS, 0xe522, s_ss) \
V(I32x4MaxS, 0xe523, s_ss) \
V(I32x4Shl, 0xe524, s_si) \
V(I32x4Shr_s, 0xe525, s_si) \
V(I32x4ShrS, 0xe525, s_si) \
V(I32x4Eq, 0xe526, s_ss) \
V(I32x4Ne, 0xe527, s_ss) \
V(I32x4Lt_s, 0xe528, s_ss) \
V(I32x4Le_s, 0xe529, s_ss) \
V(I32x4Gt_s, 0xe52a, s_ss) \
V(I32x4Ge_s, 0xe52b, s_ss) \
V(I32x4LtS, 0xe528, s_ss) \
V(I32x4LeS, 0xe529, s_ss) \
V(I32x4GtS, 0xe52a, s_ss) \
V(I32x4GeS, 0xe52b, s_ss) \
V(I32x4Select, 0xe52c, s_sss) \
V(I32x4Swizzle, 0xe52d, s_s) \
V(I32x4Shuffle, 0xe52e, s_ss) \
V(I32x4FromFloat32x4, 0xe52f, s_s) \
V(I32x4Min_u, 0xe530, s_ss) \
V(I32x4Max_u, 0xe531, s_ss) \
V(I32x4Shr_u, 0xe532, s_ss) \
V(I32x4Lt_u, 0xe533, s_ss) \
V(I32x4Le_u, 0xe534, s_ss) \
V(I32x4Gt_u, 0xe535, s_ss) \
V(I32x4Ge_u, 0xe536, s_ss) \
V(Ui32x4FromFloat32x4, 0xe537, s_s) \
V(I32x4SConvertF32x4, 0xe52f, s_s) \
V(I32x4MinU, 0xe530, s_ss) \
V(I32x4MaxU, 0xe531, s_ss) \
V(I32x4ShrU, 0xe532, s_ss) \
V(I32x4LtU, 0xe533, s_ss) \
V(I32x4LeU, 0xe534, s_ss) \
V(I32x4GtU, 0xe535, s_ss) \
V(I32x4GeU, 0xe536, s_ss) \
V(I32x4UConvertF32x4, 0xe537, s_s) \
V(I16x8Splat, 0xe538, s_i) \
V(I16x8Neg, 0xe53b, s_s) \
V(I16x8Add, 0xe53c, s_ss) \
V(I16x8AddSaturate_s, 0xe53d, s_ss) \
V(I16x8AddSaturateS, 0xe53d, s_ss) \
V(I16x8Sub, 0xe53e, s_ss) \
V(I16x8SubSaturate_s, 0xe53f, s_ss) \
V(I16x8SubSaturateS, 0xe53f, s_ss) \
V(I16x8Mul, 0xe540, s_ss) \
V(I16x8Min_s, 0xe541, s_ss) \
V(I16x8Max_s, 0xe542, s_ss) \
V(I16x8MinS, 0xe541, s_ss) \
V(I16x8MaxS, 0xe542, s_ss) \
V(I16x8Shl, 0xe543, s_si) \
V(I16x8Shr_s, 0xe544, s_si) \
V(I16x8ShrS, 0xe544, s_si) \
V(I16x8Eq, 0xe545, s_ss) \
V(I16x8Ne, 0xe546, s_ss) \
V(I16x8Lt_s, 0xe547, s_ss) \
V(I16x8Le_s, 0xe548, s_ss) \
V(I16x8Gt_s, 0xe549, s_ss) \
V(I16x8Ge_s, 0xe54a, s_ss) \
V(I16x8LtS, 0xe547, s_ss) \
V(I16x8LeS, 0xe548, s_ss) \
V(I16x8GtS, 0xe549, s_ss) \
V(I16x8GeS, 0xe54a, s_ss) \
V(I16x8Select, 0xe54b, s_sss) \
V(I16x8Swizzle, 0xe54c, s_s) \
V(I16x8Shuffle, 0xe54d, s_ss) \
V(I16x8AddSaturate_u, 0xe54e, s_ss) \
V(I16x8SubSaturate_u, 0xe54f, s_ss) \
V(I16x8Min_u, 0xe550, s_ss) \
V(I16x8Max_u, 0xe551, s_ss) \
V(I16x8Shr_u, 0xe552, s_si) \
V(I16x8Lt_u, 0xe553, s_ss) \
V(I16x8Le_u, 0xe554, s_ss) \
V(I16x8Gt_u, 0xe555, s_ss) \
V(I16x8Ge_u, 0xe556, s_ss) \
V(I16x8AddSaturateU, 0xe54e, s_ss) \
V(I16x8SubSaturateU, 0xe54f, s_ss) \
V(I16x8MinU, 0xe550, s_ss) \
V(I16x8MaxU, 0xe551, s_ss) \
V(I16x8ShrU, 0xe552, s_si) \
V(I16x8LtU, 0xe553, s_ss) \
V(I16x8LeU, 0xe554, s_ss) \
V(I16x8GtU, 0xe555, s_ss) \
V(I16x8GeU, 0xe556, s_ss) \
V(I8x16Splat, 0xe557, s_i) \
V(I8x16Neg, 0xe55a, s_s) \
V(I8x16Add, 0xe55b, s_ss) \
V(I8x16AddSaturate_s, 0xe55c, s_ss) \
V(I8x16AddSaturateS, 0xe55c, s_ss) \
V(I8x16Sub, 0xe55d, s_ss) \
V(I8x16SubSaturate_s, 0xe55e, s_ss) \
V(I8x16SubSaturateS, 0xe55e, s_ss) \
V(I8x16Mul, 0xe55f, s_ss) \
V(I8x16Min_s, 0xe560, s_ss) \
V(I8x16Max_s, 0xe561, s_ss) \
V(I8x16MinS, 0xe560, s_ss) \
V(I8x16MaxS, 0xe561, s_ss) \
V(I8x16Shl, 0xe562, s_si) \
V(I8x16Shr_s, 0xe563, s_si) \
V(I8x16ShrS, 0xe563, s_si) \
V(I8x16Eq, 0xe564, s_ss) \
V(I8x16Neq, 0xe565, s_ss) \
V(I8x16Lt_s, 0xe566, s_ss) \
V(I8x16Le_s, 0xe567, s_ss) \
V(I8x16Gt_s, 0xe568, s_ss) \
V(I8x16Ge_s, 0xe569, s_ss) \
V(I8x16Ne, 0xe565, s_ss) \
V(I8x16LtS, 0xe566, s_ss) \
V(I8x16LeS, 0xe567, s_ss) \
V(I8x16GtS, 0xe568, s_ss) \
V(I8x16GeS, 0xe569, s_ss) \
V(I8x16Select, 0xe56a, s_sss) \
V(I8x16Swizzle, 0xe56b, s_s) \
V(I8x16Shuffle, 0xe56c, s_ss) \
V(I8x16AddSaturate_u, 0xe56d, s_ss) \
V(I8x16Sub_saturate_u, 0xe56e, s_ss) \
V(I8x16Min_u, 0xe56f, s_ss) \
V(I8x16Max_u, 0xe570, s_ss) \
V(I8x16Shr_u, 0xe571, s_ss) \
V(I8x16Lt_u, 0xe572, s_ss) \
V(I8x16Le_u, 0xe573, s_ss) \
V(I8x16Gt_u, 0xe574, s_ss) \
V(I8x16Ge_u, 0xe575, s_ss) \
V(I8x16AddSaturateU, 0xe56d, s_ss) \
V(I8x16SubSaturateU, 0xe56e, s_ss) \
V(I8x16MinU, 0xe56f, s_ss) \
V(I8x16MaxU, 0xe570, s_ss) \
V(I8x16ShrU, 0xe571, s_ss) \
V(I8x16LtU, 0xe572, s_ss) \
V(I8x16LeU, 0xe573, s_ss) \
V(I8x16GtU, 0xe574, s_ss) \
V(I8x16GeU, 0xe575, s_ss) \
V(S128And, 0xe576, s_ss) \
V(S128Ior, 0xe577, s_ss) \
V(S128Xor, 0xe578, s_ss) \
......@@ -405,37 +405,37 @@ const WasmCodePosition kNoCodePosition = -1;
V(I32AtomicAdd8U, 0xe602, i_ii) \
V(I32AtomicAdd16S, 0xe603, i_ii) \
V(I32AtomicAdd16U, 0xe604, i_ii) \
V(I32AtomicAdd32, 0xe605, i_ii) \
V(I32AtomicAdd, 0xe605, i_ii) \
V(I32AtomicAnd8S, 0xe606, i_ii) \
V(I32AtomicAnd8U, 0xe607, i_ii) \
V(I32AtomicAnd16S, 0xe608, i_ii) \
V(I32AtomicAnd16U, 0xe609, i_ii) \
V(I32AtomicAnd32, 0xe60a, i_ii) \
V(I32AtomicAnd, 0xe60a, i_ii) \
V(I32AtomicCompareExchange8S, 0xe60b, i_ii) \
V(I32AtomicCompareExchange8U, 0xe60c, i_ii) \
V(I32AtomicCompareExchange16S, 0xe60d, i_ii) \
V(I32AtomicCompareExchange16U, 0xe60e, i_ii) \
V(I32AtomicCompareExchange32, 0xe60f, i_ii) \
V(I32AtomicCompareExchange, 0xe60f, i_ii) \
V(I32AtomicExchange8S, 0xe610, i_ii) \
V(I32AtomicExchange8U, 0xe611, i_ii) \
V(I32AtomicExchange16S, 0xe612, i_ii) \
V(I32AtomicExchange16U, 0xe613, i_ii) \
V(I32AtomicExchange32, 0xe614, i_ii) \
V(I32AtomicExchange, 0xe614, i_ii) \
V(I32AtomicOr8S, 0xe615, i_ii) \
V(I32AtomicOr8U, 0xe616, i_ii) \
V(I32AtomicOr16S, 0xe617, i_ii) \
V(I32AtomicOr16U, 0xe618, i_ii) \
V(I32AtomicOr32, 0xe619, i_ii) \
V(I32AtomicOr, 0xe619, i_ii) \
V(I32AtomicSub8S, 0xe61a, i_ii) \
V(I32AtomicSub8U, 0xe61b, i_ii) \
V(I32AtomicSub16S, 0xe61c, i_ii) \
V(I32AtomicSub16U, 0xe61d, i_ii) \
V(I32AtomicSub32, 0xe61e, i_ii) \
V(I32AtomicSub, 0xe61e, i_ii) \
V(I32AtomicXor8S, 0xe61f, i_ii) \
V(I32AtomicXor8U, 0xe620, i_ii) \
V(I32AtomicXor16S, 0xe621, i_ii) \
V(I32AtomicXor16U, 0xe622, i_ii) \
V(I32AtomicXor32, 0xe623, i_ii)
V(I32AtomicXor, 0xe623, i_ii)
// All opcodes.
#define FOREACH_OPCODE(V) \
......@@ -525,7 +525,6 @@ enum TrapReason {
class V8_EXPORT_PRIVATE WasmOpcodes {
public:
static const char* OpcodeName(WasmOpcode opcode);
static const char* ShortOpcodeName(WasmOpcode opcode);
static FunctionSig* Signature(WasmOpcode opcode);
static FunctionSig* AsmjsSignature(WasmOpcode opcode);
static FunctionSig* AtomicSignature(WasmOpcode opcode);
......
......@@ -17,106 +17,6 @@ using namespace v8::internal;
using namespace v8::internal::wasm;
namespace {
const char *GetOpName(WasmOpcode opcode) {
#define CASE_OP(name, str) \
case kExpr##name: \
return str;
#define CASE_I32_OP(name, str) CASE_OP(I32##name, "i32." str)
#define CASE_I64_OP(name, str) CASE_OP(I64##name, "i64." str)
#define CASE_F32_OP(name, str) CASE_OP(F32##name, "f32." str)
#define CASE_F64_OP(name, str) CASE_OP(F64##name, "f64." str)
#define CASE_INT_OP(name, str) CASE_I32_OP(name, str) CASE_I64_OP(name, str)
#define CASE_FLOAT_OP(name, str) CASE_F32_OP(name, str) CASE_F64_OP(name, str)
#define CASE_ALL_OP(name, str) CASE_FLOAT_OP(name, str) CASE_INT_OP(name, str)
#define CASE_SIGN_OP(TYPE, name, str) \
CASE_##TYPE##_OP(name##S, str "_s") CASE_##TYPE##_OP(name##U, str "_u")
#define CASE_ALL_SIGN_OP(name, str) \
CASE_FLOAT_OP(name, str) CASE_SIGN_OP(INT, name, str)
#define CASE_CONVERT_OP(name, RES, SRC, src_suffix, str) \
CASE_##RES##_OP(U##name##SRC, str "_u/" src_suffix) \
CASE_##RES##_OP(S##name##SRC, str "_s/" src_suffix)
switch (opcode) {
CASE_INT_OP(Eqz, "eqz")
CASE_ALL_OP(Eq, "eq")
CASE_ALL_OP(Ne, "ne")
CASE_ALL_OP(Add, "add")
CASE_ALL_OP(Sub, "sub")
CASE_ALL_OP(Mul, "mul")
CASE_ALL_SIGN_OP(Lt, "lt")
CASE_ALL_SIGN_OP(Gt, "gt")
CASE_ALL_SIGN_OP(Le, "le")
CASE_ALL_SIGN_OP(Ge, "ge")
CASE_INT_OP(Clz, "clz")
CASE_INT_OP(Ctz, "ctz")
CASE_INT_OP(Popcnt, "popcnt")
CASE_ALL_SIGN_OP(Div, "div")
CASE_SIGN_OP(INT, Rem, "rem")
CASE_INT_OP(And, "and")
CASE_INT_OP(Ior, "or")
CASE_INT_OP(Xor, "xor")
CASE_INT_OP(Shl, "shl")
CASE_SIGN_OP(INT, Shr, "shr")
CASE_INT_OP(Rol, "rol")
CASE_INT_OP(Ror, "ror")
CASE_FLOAT_OP(Abs, "abs")
CASE_FLOAT_OP(Neg, "neg")
CASE_FLOAT_OP(Ceil, "ceil")
CASE_FLOAT_OP(Floor, "floor")
CASE_FLOAT_OP(Trunc, "trunc")
CASE_FLOAT_OP(NearestInt, "nearest")
CASE_FLOAT_OP(Sqrt, "sqrt")
CASE_FLOAT_OP(Min, "min")
CASE_FLOAT_OP(Max, "max")
CASE_FLOAT_OP(CopySign, "copysign")
CASE_I32_OP(ConvertI64, "wrap/i64")
CASE_CONVERT_OP(Convert, INT, F32, "f32", "trunc")
CASE_CONVERT_OP(Convert, INT, F64, "f64", "trunc")
CASE_CONVERT_OP(Convert, I64, I32, "i32", "extend")
CASE_CONVERT_OP(Convert, F32, I32, "i32", "convert")
CASE_CONVERT_OP(Convert, F32, I64, "i64", "convert")
CASE_F32_OP(ConvertF64, "demote/f64")
CASE_CONVERT_OP(Convert, F64, I32, "i32", "convert")
CASE_CONVERT_OP(Convert, F64, I64, "i64", "convert")
CASE_F64_OP(ConvertF32, "promote/f32")
CASE_I32_OP(ReinterpretF32, "reinterpret/f32")
CASE_I64_OP(ReinterpretF64, "reinterpret/f64")
CASE_F32_OP(ReinterpretI32, "reinterpret/i32")
CASE_F64_OP(ReinterpretI64, "reinterpret/i64")
CASE_OP(Unreachable, "unreachable")
CASE_OP(Nop, "nop")
CASE_OP(Return, "return")
CASE_OP(MemorySize, "current_memory")
CASE_OP(GrowMemory, "grow_memory")
CASE_OP(Loop, "loop")
CASE_OP(If, "if")
CASE_OP(Block, "block")
CASE_OP(Try, "try")
CASE_OP(Throw, "throw")
CASE_OP(Catch, "catch")
CASE_OP(Drop, "drop")
CASE_OP(Select, "select")
CASE_ALL_OP(LoadMem, "load")
CASE_SIGN_OP(INT, LoadMem8, "load8")
CASE_SIGN_OP(INT, LoadMem16, "load16")
CASE_SIGN_OP(I64, LoadMem32, "load32")
CASE_ALL_OP(StoreMem, "store")
CASE_INT_OP(StoreMem8, "store8")
CASE_INT_OP(StoreMem16, "store16")
CASE_I64_OP(StoreMem32, "store32")
CASE_OP(SetLocal, "set_local")
CASE_OP(GetLocal, "get_local")
CASE_OP(TeeLocal, "tee_local")
CASE_OP(GetGlobal, "get_global")
CASE_OP(SetGlobal, "set_global")
CASE_OP(Br, "br")
CASE_OP(BrIf, "br_if")
default:
UNREACHABLE();
return "";
}
}
bool IsValidFunctionName(const Vector<const char> &name) {
if (name.is_empty()) return false;
const char *special_chars = "_.+-*/\\^~=<>!?@#$%&|:'`";
......@@ -205,7 +105,7 @@ void wasm::PrintWasmText(const WasmModule *module,
case kExprBlock:
case kExprTry: {
BlockTypeOperand operand(&i, i.pc());
os << GetOpName(opcode);
os << WasmOpcodes::OpcodeName(opcode);
for (unsigned i = 0; i < operand.arity; i++) {
os << " " << WasmOpcodes::TypeName(operand.read_entry(i));
}
......@@ -215,7 +115,7 @@ void wasm::PrintWasmText(const WasmModule *module,
case kExprBr:
case kExprBrIf: {
BreakDepthOperand operand(&i, i.pc());
os << GetOpName(opcode) << ' ' << operand.depth;
os << WasmOpcodes::OpcodeName(opcode) << ' ' << operand.depth;
break;
}
case kExprElse:
......@@ -248,13 +148,13 @@ void wasm::PrintWasmText(const WasmModule *module,
case kExprTeeLocal:
case kExprCatch: {
LocalIndexOperand operand(&i, i.pc());
os << GetOpName(opcode) << ' ' << operand.index;
os << WasmOpcodes::OpcodeName(opcode) << ' ' << operand.index;
break;
}
case kExprGetGlobal:
case kExprSetGlobal: {
GlobalIndexOperand operand(&i, i.pc());
os << GetOpName(opcode) << ' ' << operand.index;
os << WasmOpcodes::OpcodeName(opcode) << ' ' << operand.index;
break;
}
#define CASE_CONST(type, str, cast_type) \
......@@ -272,7 +172,7 @@ void wasm::PrintWasmText(const WasmModule *module,
FOREACH_LOAD_MEM_OPCODE(CASE_OPCODE)
FOREACH_STORE_MEM_OPCODE(CASE_OPCODE) {
MemoryAccessOperand operand(&i, i.pc(), kMaxUInt32);
os << GetOpName(opcode) << " offset=" << operand.offset
os << WasmOpcodes::OpcodeName(opcode) << " offset=" << operand.offset
<< " align=" << (1ULL << operand.alignment);
break;
}
......@@ -286,7 +186,7 @@ void wasm::PrintWasmText(const WasmModule *module,
case kExprDrop:
case kExprSelect:
case kExprThrow:
os << GetOpName(opcode);
os << WasmOpcodes::OpcodeName(opcode);
break;
// This group is just printed by their internal opcode name, as they
......
......@@ -139,6 +139,7 @@ v8_executable("unittests") {
"wasm/switch-logic-unittest.cc",
"wasm/wasm-macro-gen-unittest.cc",
"wasm/wasm-module-builder-unittest.cc",
"wasm/wasm-opcodes-unittest.cc",
"zone/segmentpool-unittest.cc",
"zone/zone-chunk-list-unittest.cc",
]
......
......@@ -139,6 +139,7 @@
'wasm/switch-logic-unittest.cc',
'wasm/wasm-macro-gen-unittest.cc',
'wasm/wasm-module-builder-unittest.cc',
'wasm/wasm-opcodes-unittest.cc',
],
'unittests_sources_arm': [ ### gcmole(arch:arm) ###
'compiler/arm/instruction-selector-arm-unittest.cc',
......
// Copyright 2017 the V8 project authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "test/unittests/test-utils.h"
#include "src/wasm/wasm-opcodes.h"
namespace v8 {
namespace internal {
namespace wasm {
class WasmOpcodesTest : public TestWithZone {};
TEST_F(WasmOpcodesTest, EveryOpcodeHasAName) {
static const struct {
WasmOpcode opcode;
const char* debug_name;
} kValues[] = {
#define DECLARE_ELEMENT(name, opcode, sig) {kExpr##name, "kExpr" #name},
FOREACH_OPCODE(DECLARE_ELEMENT)};
for (size_t i = 0; i < arraysize(kValues); i++) {
const char* result = WasmOpcodes::OpcodeName(kValues[i].opcode);
if (strcmp("unknown", result) == 0) {
EXPECT_TRUE(false) << "WasmOpcodes::OpcodeName(" << kValues[i].debug_name
<< ") == \"unknown\";"
" plazz halp in src/wasm/wasm-opcodes.cc";
}
}
}
} // namespace wasm
} // namespace internal
} // namespace v8
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment