summaryrefslogtreecommitdiff
path: root/source/slang/slang-check-shader.cpp
diff options
context:
space:
mode:
authorYong He <yonghe@outlook.com>2023-08-04 15:47:39 -0700
committerGitHub <noreply@github.com>2023-08-04 15:47:39 -0700
commita2d90fb275962da84611160f8ddd74d934a68dbd (patch)
tree066084537b9f4fe1f367de100ed6638a88a028c1 /source/slang/slang-check-shader.cpp
parent17da4f0dec2b86ba3a4bdaf8a2ae112047d23623 (diff)
Redesign `DeclRef` and systematic `Val` deduplication (#3049)
* Redesign DeclRef + Deduplicate Val. * Update project files * Fix warning. * Fix. * Fix. * Remove `Val::_equalsImplOverride`. * Rmove `Val::_getHashCodeOverride`. * Remove `semanticVisitor` param from `resolve`. * Cleanups. --------- Co-authored-by: Yong He <yhe@nvidia.com>
Diffstat (limited to 'source/slang/slang-check-shader.cpp')
-rw-r--r--source/slang/slang-check-shader.cpp42
1 files changed, 17 insertions, 25 deletions
diff --git a/source/slang/slang-check-shader.cpp b/source/slang/slang-check-shader.cpp
index 657438222..d9bb11548 100644
--- a/source/slang/slang-check-shader.cpp
+++ b/source/slang/slang-check-shader.cpp
@@ -17,7 +17,7 @@ namespace Slang
auto basicType = as<BasicExpressionType>(type);
if (basicType)
{
- return (basicType->baseType == BaseType::Int || basicType->baseType == BaseType::UInt);
+ return (basicType->getBaseType() == BaseType::Int || basicType->getBaseType() == BaseType::UInt);
}
}
// Can be an int/uint vector from size 1 to 3
@@ -27,20 +27,21 @@ namespace Slang
{
return false;
}
- auto elemCount = as<ConstantIntVal>(vectorType->elementCount);
- if (elemCount->value < 1 || elemCount->value > 3)
+ auto elemCount = as<ConstantIntVal>(vectorType->getElementCount());
+ if (elemCount->getValue() < 1 || elemCount->getValue() > 3)
{
return false;
}
// Must be a basic type
- auto basicType = as<BasicExpressionType>(vectorType->elementType);
+ auto basicType = as<BasicExpressionType>(vectorType->getElementType());
if (!basicType)
{
return false;
}
// Must be integral
- return (basicType->baseType == BaseType::Int || basicType->baseType == BaseType::UInt);
+ auto baseType = basicType->getBaseType();
+ return (baseType == BaseType::Int || baseType == BaseType::UInt);
}
}
@@ -83,7 +84,7 @@ namespace Slang
if( auto declRefType = as<DeclRefType>(type) )
{
- auto typeDeclRef = declRefType->declRef;
+ auto typeDeclRef = declRefType->getDeclRef();
if( auto interfaceDeclRef = typeDeclRef.as<InterfaceDecl>() )
{
// Each leaf parameter of interface type adds a specialization
@@ -792,6 +793,8 @@ namespace Slang
void FrontEndCompileRequest::checkEntryPoints()
{
auto linkage = getLinkage();
+ SLANG_AST_BUILDER_RAII(linkage->getASTBuilder());
+
auto sink = getSink();
// The validation of entry points here will be modal, and controlled
@@ -1025,7 +1028,7 @@ namespace Slang
//
if( auto argDeclRefType = as<DeclRefType>(argType) )
{
- auto argDeclRef = argDeclRefType->declRef;
+ auto argDeclRef = argDeclRefType->getDeclRef();
if(auto argGenericParamDeclRef = argDeclRef.as<GlobalGenericParamDecl>())
{
if(argGenericParamDeclRef.getDecl() == genericTypeParamDecl)
@@ -1193,7 +1196,7 @@ namespace Slang
// the semantic checking machinery to expand out
// the rest of the arguments via inference...
- auto genericDeclRef = m_funcDeclRef.getParent(getLinkage()->getASTBuilder()).as<GenericDecl>();
+ auto genericDeclRef = m_funcDeclRef.getParent().as<GenericDecl>();
SLANG_ASSERT(genericDeclRef); // otherwise we wouldn't have generic parameters
List<Val*> genericArgs;
@@ -1203,19 +1206,13 @@ namespace Slang
auto specializationArg = args[ii];
genericArgs.add(specializationArg.val);
}
- GenericSubstitution* genericSubst =
- getLinkage()->getASTBuilder()->getOrCreateGenericSubstitution(
- genericDeclRef.getSubst(),
- genericDeclRef.getDecl(),
- genericArgs.getArrayView());
+ auto genericInnerDeclRef = getLinkage()->getASTBuilder()->getGenericAppDeclRef(genericDeclRef, genericArgs.getArrayView());
ASTBuilder* astBuilder = getLinkage()->getASTBuilder();
for (auto constraintDecl : getMembersOfType<GenericTypeConstraintDecl>(
getLinkage()->getASTBuilder(), DeclRef<ContainerDecl>(genericDeclRef)))
{
- DeclRef<GenericTypeConstraintDecl> constraintDeclRef = astBuilder->getSpecializedDeclRef(
- constraintDecl.getDecl(), genericSubst);
-
+ DeclRef<GenericTypeConstraintDecl> constraintDeclRef = astBuilder->getDirectDeclRef(constraintDecl.getDecl());
auto sub = getSub(astBuilder, constraintDeclRef);
auto sup = getSup(astBuilder, constraintDeclRef);
@@ -1233,12 +1230,8 @@ namespace Slang
}
}
- genericSubst =
- getLinkage()->getASTBuilder()->getOrCreateGenericSubstitution(
- genericDeclRef.getSubst(),
- genericDeclRef.getDecl(),
- genericArgs);
- specializedFuncDeclRef = astBuilder->getSpecializedDeclRef(specializedFuncDeclRef.getDecl(), genericSubst);
+ specializedFuncDeclRef = getLinkage()->getASTBuilder()->getGenericAppDeclRef(genericDeclRef, genericArgs.getArrayView()).as<FuncDecl>();
+ SLANG_ASSERT(specializedFuncDeclRef);
}
info->specializedFuncDeclRef = specializedFuncDeclRef;
@@ -1418,9 +1411,8 @@ namespace Slang
specializationArgs.add(arg);
}
- ExistentialSpecializedType* specializedType = m_astBuilder->create<ExistentialSpecializedType>();
- specializedType->baseType = unspecializedType;
- specializedType->args = specializationArgs;
+ ExistentialSpecializedType* specializedType = m_astBuilder->getOrCreate<ExistentialSpecializedType>(
+ unspecializedType, specializationArgs);
m_specializedTypes.add(specializedType);