summaryrefslogtreecommitdiff
path: root/source/slang/slang-ast-builder.h
diff options
context:
space:
mode:
authorYong He <yonghe@outlook.com>2023-07-12 16:00:05 -0700
committerGitHub <noreply@github.com>2023-07-12 16:00:05 -0700
commit261b2f1f2bc13ccf7db5ec68c825ffc7b0781f7f (patch)
tree4953e376e705a8110cb8164dda5b239c04f2768b /source/slang/slang-ast-builder.h
parentbbd9c2e6d7b57f5acc3238083ab2f7c7b140df5e (diff)
Use scratchData on `IRInst` to replace HashSets. (#2978)
* Use scratchData on `IRInst` to replace HashSets. * Update test results. * Initialize scratchData. * Update autodiff documentation. * Use enum instead of bool. --------- Co-authored-by: Yong He <yhe@nvidia.com>
Diffstat (limited to 'source/slang/slang-ast-builder.h')
-rw-r--r--source/slang/slang-ast-builder.h11
1 files changed, 10 insertions, 1 deletions
diff --git a/source/slang/slang-ast-builder.h b/source/slang/slang-ast-builder.h
index 618636417..a2543ab1e 100644
--- a/source/slang/slang-ast-builder.h
+++ b/source/slang/slang-ast-builder.h
@@ -143,7 +143,10 @@ public:
ShortList<NodeOperand, 4> operands;
bool operator==(NodeDesc const& that) const;
- HashCode getHashCode() const;
+ HashCode getHashCode() const { return hashCode; }
+ void init();
+ private:
+ HashCode hashCode = 0;
};
template<typename NodeCreateFunc>
@@ -217,6 +220,7 @@ public:
NodeDesc desc;
desc.type = T::kType;
addOrAppendToNodeList(desc.operands, args...);
+ desc.init();
return (T*)_getOrCreateImpl(desc, [&]()
{
return create<T>(args...);
@@ -230,6 +234,7 @@ public:
NodeDesc desc;
desc.type = T::kType;
+ desc.init();
return (T*)_getOrCreateImpl(desc, [this]() { return create<T>(); });
}
@@ -240,6 +245,7 @@ public:
NodeDesc desc;
desc.type = T::kType;
addOrAppendToNodeList(desc.operands, args...);
+ desc.init();
return (T*)_getOrCreateImpl(desc, [&]()
{
return create<T>();
@@ -253,6 +259,7 @@ public:
NodeDesc desc;
desc.type = T::kType;
desc.operands.addRange(operands);
+ desc.init();
return (T*)_getOrCreateImpl(desc, [&]()
{
return create<T>();
@@ -305,6 +312,7 @@ public:
{
desc.operands.add(outer);
}
+ desc.init();
auto result = (GenericSubstitution*)_getOrCreateImpl(desc, [this]() {return create<GenericSubstitution>(); });
if (result->args.getCount() != args.getCount())
{
@@ -326,6 +334,7 @@ public:
{
desc.operands.add(outer);
}
+ desc.init();
auto result = (ThisTypeSubstitution*)_getOrCreateImpl(desc, [this]() {return create<ThisTypeSubstitution>(); });
result->interfaceDecl = interfaceDecl;
result->witness = subtypeWitness;