diff options
author | Alon Zakai <alonzakai@gmail.com> | 2016-03-19 15:56:55 -0700 |
---|---|---|
committer | Alon Zakai <alonzakai@gmail.com> | 2016-03-19 15:56:55 -0700 |
commit | eb135274e30454715fca36e6b0db640778982018 (patch) | |
tree | 8d057857f9ae610744813354a4c50561aba11b5c /src | |
parent | c8faff5ddbc7e93134763a845371b66bc2be56a4 (diff) | |
download | binaryen-eb135274e30454715fca36e6b0db640778982018.tar.gz binaryen-eb135274e30454715fca36e6b0db640778982018.tar.bz2 binaryen-eb135274e30454715fca36e6b0db640778982018.zip |
update spec tests and support eqz
Diffstat (limited to 'src')
-rw-r--r-- | src/passes/Print.cpp | 1 | ||||
-rw-r--r-- | src/wasm-binary.h | 5 | ||||
-rw-r--r-- | src/wasm-interpreter.h | 2 | ||||
-rw-r--r-- | src/wasm-s-parser.h | 5 | ||||
-rw-r--r-- | src/wasm.h | 2 |
5 files changed, 13 insertions, 2 deletions
diff --git a/src/passes/Print.cpp b/src/passes/Print.cpp index e3663e164..0fdb4255f 100644 --- a/src/passes/Print.cpp +++ b/src/passes/Print.cpp @@ -264,6 +264,7 @@ struct PrintSExpression : public WasmVisitor<PrintSExpression, void> { case Clz: o << "clz"; break; case Ctz: o << "ctz"; break; case Popcnt: o << "popcnt"; break; + case EqZ: o << "eqz"; break; case Neg: o << "neg"; break; case Abs: o << "abs"; break; case Ceil: o << "ceil"; break; diff --git a/src/wasm-binary.h b/src/wasm-binary.h index 2a1fb76a7..21438f616 100644 --- a/src/wasm-binary.h +++ b/src/wasm-binary.h @@ -263,6 +263,7 @@ enum ASTNodes { I32Clz = 0x57, I32Ctz = 0x58, I32Popcnt = 0x59, + I32EqZ = 0xc0, // XXX BoolNot = 0x5a, I64Add = 0x5b, I64Sub = 0x5c, @@ -290,6 +291,7 @@ enum ASTNodes { I64Clz = 0x72, I64Ctz = 0x73, I64Popcnt = 0x74, + I64EqZ = 0xc1, // XXX F32Add = 0x75, F32Sub = 0x76, F32Mul = 0x77, @@ -966,6 +968,7 @@ public: case Clz: o << int8_t(curr->type == i32 ? BinaryConsts::I32Clz : BinaryConsts::I64Clz); break; case Ctz: o << int8_t(curr->type == i32 ? BinaryConsts::I32Ctz : BinaryConsts::I64Ctz); break; case Popcnt: o << int8_t(curr->type == i32 ? BinaryConsts::I32Popcnt : BinaryConsts::I64Popcnt); break; + case EqZ: o << int8_t(curr->type == i32 ? BinaryConsts::I32EqZ : BinaryConsts::I64EqZ); break; case Neg: o << int8_t(curr->type == f32 ? BinaryConsts::F32Neg : BinaryConsts::F64Neg); break; case Abs: o << int8_t(curr->type == f32 ? BinaryConsts::F32Abs : BinaryConsts::F64Abs); break; case Ceil: o << int8_t(curr->type == f32 ? BinaryConsts::F32Ceil : BinaryConsts::F64Ceil); break; @@ -1798,6 +1801,8 @@ public: case BinaryConsts::I64Ctz: curr->op = Ctz; curr->type = i64; break; case BinaryConsts::I32Popcnt: curr->op = Popcnt; curr->type = i32; break; case BinaryConsts::I64Popcnt: curr->op = Popcnt; curr->type = i64; break; + case BinaryConsts::I32EqZ: curr->op = EqZ; curr->type = i32; break; + case BinaryConsts::I64EqZ: curr->op = EqZ; curr->type = i64; break; case BinaryConsts::F32Neg: curr->op = Neg; curr->type = f32; break; case BinaryConsts::F64Neg: curr->op = Neg; curr->type = f64; break; case BinaryConsts::F32Abs: curr->op = Abs; curr->type = f32; break; diff --git a/src/wasm-interpreter.h b/src/wasm-interpreter.h index fb860627c..eca91fc82 100644 --- a/src/wasm-interpreter.h +++ b/src/wasm-interpreter.h @@ -391,6 +391,7 @@ private: case Clz: return value.countLeadingZeroes(); case Ctz: return value.countTrailingZeroes(); case Popcnt: return value.popCount(); + case EqZ: return Literal(int32_t(value == Literal(int32_t(0)))); case ReinterpretInt: return value.castToF32(); case ExtendSInt32: return value.extendToSI64(); case ExtendUInt32: return value.extendToUI64(); @@ -404,6 +405,7 @@ private: case Clz: return value.countLeadingZeroes(); case Ctz: return value.countTrailingZeroes(); case Popcnt: return value.popCount(); + case EqZ: return Literal(int32_t(value == Literal(int64_t(0)))); case WrapInt64: return value.truncateToI32(); case ReinterpretInt: return value.castToF64(); case ConvertUInt64: return curr->type == f32 ? value.convertUToF32() : value.convertUToF64(); diff --git a/src/wasm-s-parser.h b/src/wasm-s-parser.h index 30ddd786e..5bb2b44ee 100644 --- a/src/wasm-s-parser.h +++ b/src/wasm-s-parser.h @@ -487,7 +487,10 @@ public: abort_on(op); } case 'e': { - if (op[1] == 'q') return makeBinary(s, BinaryOp::Eq, type); + if (op[1] == 'q') { + if (op[2] == 0) return makeBinary(s, BinaryOp::Eq, type); + if (op[2] == 'z') return makeUnary(s, UnaryOp::EqZ, type); + } if (op[1] == 'x') return makeUnary(s, op[7] == 'u' ? UnaryOp::ExtendUInt32 : UnaryOp::ExtendSInt32, type); abort_on(op); } diff --git a/src/wasm.h b/src/wasm.h index ed07bf371..2fcc3cddc 100644 --- a/src/wasm.h +++ b/src/wasm.h @@ -681,7 +681,7 @@ public: // Operators enum UnaryOp { - Clz, Ctz, Popcnt, // int + Clz, Ctz, Popcnt, EqZ, // int Neg, Abs, Ceil, Floor, Trunc, Nearest, Sqrt, // float // conversions ExtendSInt32, ExtendUInt32, WrapInt64, TruncSFloat32, TruncUFloat32, TruncSFloat64, TruncUFloat64, ReinterpretFloat, // int |