diff options
author | Alon Zakai <azakai@google.com> | 2022-09-26 13:49:50 -0700 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-09-26 20:49:50 +0000 |
commit | b23b47d54a2fb02b048e7eb8de8043358599ec8b (patch) | |
tree | a0df6c52cae239318893b069172674145903598f /src/ir/possible-contents.h | |
parent | b40fa4a885f219d8f317f125880aa0ee9f46b62f (diff) | |
download | binaryen-b23b47d54a2fb02b048e7eb8de8043358599ec8b.tar.gz binaryen-b23b47d54a2fb02b048e7eb8de8043358599ec8b.tar.bz2 binaryen-b23b47d54a2fb02b048e7eb8de8043358599ec8b.zip |
[GUFA] Infer a RefEq value of 0 when possible (#5081)
If the PossibleContents for the two sides have no possible intersection then the
result must be 0.
Diffstat (limited to 'src/ir/possible-contents.h')
-rw-r--r-- | src/ir/possible-contents.h | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/src/ir/possible-contents.h b/src/ir/possible-contents.h index 38bc263e9..f3ad37d92 100644 --- a/src/ir/possible-contents.h +++ b/src/ir/possible-contents.h @@ -167,6 +167,13 @@ public: // This returns false for None and Many, for whom it is not well-defined. bool hasExactType() const { return isExactType() || isLiteral(); } + // Returns whether the given contents have any intersection, that is, whether + // some value exists that can appear in both |a| and |b|. For example, if + // either is None, or if they are both ExactTypes but of different types, then + // they have no intersection. + static bool haveIntersection(const PossibleContents& a, + const PossibleContents& b); + // Whether we can make an Expression* for this containing the proper contents. // We can do that for a Literal (emitting a Const or RefFunc etc.) or a // Global (emitting a GlobalGet), but not for anything else yet. @@ -529,6 +536,13 @@ public: return iter->second; } + // Helper for the common case of an expression location that is not a + // multivalue. + PossibleContents getContents(Expression* curr) { + assert(curr->type.size() == 1); + return getContents(ExpressionLocation{curr, 0}); + } + private: std::unordered_map<Location, PossibleContents> locationContents; }; |