summaryrefslogtreecommitdiff
path: root/source/slang/slang-ast-builder.cpp
diff options
context:
space:
mode:
authorYong He <yonghe@outlook.com>2023-07-18 08:08:11 -0700
committerGitHub <noreply@github.com>2023-07-18 15:08:11 +0000
commit4cb3eeb832b5fb29a61f2934b3daa5e42a3d6cde (patch)
tree89713b5d83b4fee0dad6aa52b72d5ca695f4e8f1 /source/slang/slang-ast-builder.cpp
parent138a44ef272841cb555fa0eb5c49cc889bf1d64a (diff)
Simplify Lookup and improve compiler performance. (#2996)
* Simplify lookup. * Various bug fixes. * Report type dictionary size in perf benchmark. * Remove type duplication. * increase initial dict size. * Bug fix. * Fix bugs. * Fixup. * Revert type legalization looping. * Fix specialization pass. --------- Co-authored-by: Yong He <yhe@nvidia.com>
Diffstat (limited to 'source/slang/slang-ast-builder.cpp')
-rw-r--r--source/slang/slang-ast-builder.cpp17
1 files changed, 12 insertions, 5 deletions
diff --git a/source/slang/slang-ast-builder.cpp b/source/slang/slang-ast-builder.cpp
index 7f1b90837..72cb647d5 100644
--- a/source/slang/slang-ast-builder.cpp
+++ b/source/slang/slang-ast-builder.cpp
@@ -298,7 +298,7 @@ ArrayExpressionType* ASTBuilder::getArrayType(Type* elementType, IntVal* element
{
auto arrayGenericDecl = as<GenericDecl>(m_sharedASTBuilder->findMagicDecl("ArrayType"));
auto arrayTypeDecl = arrayGenericDecl->inner;
- auto substitutions = getOrCreate<GenericSubstitution>(arrayGenericDecl, elementType, elementCount);
+ auto substitutions = getOrCreateGenericSubstitution(nullptr, arrayGenericDecl, elementType, elementCount);
result->declRef = getSpecializedDeclRef<Decl>(arrayTypeDecl, substitutions);
}
return result;
@@ -313,7 +313,7 @@ VectorExpressionType* ASTBuilder::getVectorType(
{
auto vectorGenericDecl = as<GenericDecl>(m_sharedASTBuilder->findMagicDecl("Vector"));
auto vectorTypeDecl = vectorGenericDecl->inner;
- auto substitutions = getOrCreate<GenericSubstitution>(vectorGenericDecl, elementType, elementCount);
+ auto substitutions = getOrCreateGenericSubstitution(nullptr, vectorGenericDecl, elementType, elementCount);
result->declRef = getSpecializedDeclRef<Decl>(vectorTypeDecl, substitutions);
}
return result;
@@ -327,7 +327,8 @@ DifferentialPairType* ASTBuilder::getDifferentialPairType(
auto typeDecl = genericDecl->inner;
- auto substitutions = getOrCreate<GenericSubstitution>(
+ auto substitutions = getOrCreateGenericSubstitution(
+ nullptr,
genericDecl,
valueType,
primalIsDifferentialWitness);
@@ -367,7 +368,8 @@ MeshOutputType* ASTBuilder::getMeshOutputTypeFromModifier(
auto typeDecl = genericDecl->inner;
- auto substitutions = getOrCreate<GenericSubstitution>(
+ auto substitutions = getOrCreateGenericSubstitution(
+ nullptr,
genericDecl,
elementType,
maxElementCount);
@@ -392,7 +394,7 @@ DeclRef<Decl> ASTBuilder::getBuiltinDeclRef(const char* builtinMagicTypeName, Va
Substitutions* subst = nullptr;
if (genericArg)
{
- subst = getOrCreate<GenericSubstitution>(genericDecl, genericArg);
+ subst = getOrCreateGenericSubstitution(nullptr, genericDecl, genericArg);
}
return getSpecializedDeclRef(decl, subst);
}
@@ -589,6 +591,11 @@ top:
return transitiveWitness;
}
+ThisTypeSubtypeWitness* ASTBuilder::getThisTypeSubtypeWitness(Type* subType, Type* superType)
+{
+ return getOrCreate<ThisTypeSubtypeWitness>(subType, superType);
+}
+
SubtypeWitness* ASTBuilder::getExtractFromConjunctionSubtypeWitness(
Type* subType,
Type* superType,