diff options
Diffstat (limited to 'src/ir/ExpressionAnalyzer.cpp')
-rw-r--r-- | src/ir/ExpressionAnalyzer.cpp | 75 |
1 files changed, 68 insertions, 7 deletions
diff --git a/src/ir/ExpressionAnalyzer.cpp b/src/ir/ExpressionAnalyzer.cpp index 7788f7cde..0efc7b888 100644 --- a/src/ir/ExpressionAnalyzer.cpp +++ b/src/ir/ExpressionAnalyzer.cpp @@ -19,6 +19,7 @@ #include "ir/load-utils.h" namespace wasm { + // Given a stack of expressions, checks if the topmost is used as a result. // For example, if the parent is a block and the node is before the last position, // it is not used. @@ -248,6 +249,37 @@ bool ExpressionAnalyzer::flexibleEqual(Expression* left, Expression* right, Expr PUSH(AtomicWake, wakeCount); break; } + case Expression::Id::SIMDExtractId: { + CHECK(SIMDExtract, op); + CHECK(SIMDExtract, index); + PUSH(SIMDExtract, vec); + break; + } + case Expression::Id::SIMDReplaceId: { + CHECK(SIMDReplace, op); + CHECK(SIMDReplace, index); + PUSH(SIMDReplace, vec); + PUSH(SIMDReplace, value); + break; + } + case Expression::Id::SIMDShuffleId: { + CHECK(SIMDShuffle, mask); + PUSH(SIMDShuffle, left); + PUSH(SIMDShuffle, right); + break; + } + case Expression::Id::SIMDBitselectId: { + PUSH(SIMDBitselect, left); + PUSH(SIMDBitselect, right); + PUSH(SIMDBitselect, cond); + break; + } + case Expression::Id::SIMDShiftId: { + CHECK(SIMDShift, op); + PUSH(SIMDShift, vec); + PUSH(SIMDShift, shift); + break; + } case Expression::Id::ConstId: { if (left->cast<Const>()->value != right->cast<Const>()->value) { return false; @@ -356,7 +388,7 @@ HashType ExpressionAnalyzer::hash(Expression* curr) { hash(curr->_id); // we often don't need to hash the type, as it is tied to other values // we are hashing anyhow, but there are exceptions: for example, a - // get_local's type is determined by the function, so if we are + // local.get's type is determined by the function, so if we are // hashing only expression fragments, then two from different // functions may turn out the same even if the type differs. Likewise, // if we hash between modules, then we need to take int account @@ -496,15 +528,43 @@ HashType ExpressionAnalyzer::hash(Expression* curr) { PUSH(AtomicWake, wakeCount); break; } + case Expression::Id::SIMDExtractId: { + HASH(SIMDExtract, op); + HASH(SIMDExtract, index); + PUSH(SIMDExtract, vec); + break; + } + case Expression::Id::SIMDReplaceId: { + HASH(SIMDReplace, op); + HASH(SIMDReplace, index); + PUSH(SIMDReplace, vec); + PUSH(SIMDReplace, value); + break; + } + case Expression::Id::SIMDShuffleId: { + for (size_t i = 0; i < 16; ++i) { + HASH(SIMDShuffle, mask[i]); + } + PUSH(SIMDShuffle, left); + PUSH(SIMDShuffle, right); + break; + } + case Expression::Id::SIMDBitselectId: { + PUSH(SIMDBitselect, left); + PUSH(SIMDBitselect, right); + PUSH(SIMDBitselect, cond); + break; + } + case Expression::Id::SIMDShiftId: { + HASH(SIMDShift, op); + PUSH(SIMDShift, vec); + PUSH(SIMDShift, shift); + break; + } case Expression::Id::ConstId: { auto* c = curr->cast<Const>(); hash(c->type); - auto bits = c->value.getBits(); - if (getTypeSize(c->type) == 4) { - hash(HashType(bits)); - } else { - hash64(bits); - } + hash(std::hash<Literal>()(c->value)); break; } case Expression::Id::UnaryId: { @@ -557,4 +617,5 @@ HashType ExpressionAnalyzer::hash(Expression* curr) { } return digest; } + } // namespace wasm |