summaryrefslogtreecommitdiff
path: root/source/slang/slang-lower-to-ir.cpp
diff options
context:
space:
mode:
authorYong He <yonghe@outlook.com>2023-01-25 14:48:01 -0800
committerGitHub <noreply@github.com>2023-01-25 14:48:01 -0800
commitaa6814be1f7dea20597ae34d477e79e53d4a543f (patch)
tree15b8ad69e2c4169e12a0ad6e970fe511daa4beb7 /source/slang/slang-lower-to-ir.cpp
parentae11538f5d667b11d3b3191a827093f3727eed1b (diff)
Cleanup IR representation of interface member derivative. (#2610)
Co-authored-by: Yong He <yhe@nvidia.com>
Diffstat (limited to 'source/slang/slang-lower-to-ir.cpp')
-rw-r--r--source/slang/slang-lower-to-ir.cpp32
1 files changed, 13 insertions, 19 deletions
diff --git a/source/slang/slang-lower-to-ir.cpp b/source/slang/slang-lower-to-ir.cpp
index d0527eef8..605ac62db 100644
--- a/source/slang/slang-lower-to-ir.cpp
+++ b/source/slang/slang-lower-to-ir.cpp
@@ -6846,36 +6846,30 @@ struct DeclLoweringVisitor : DeclVisitor<DeclLoweringVisitor, LoweredValInfo>
return LoweredValInfo::simple(assocType);
}
- void insertRequirementKeyAssociation(IRInterfaceType* interfaceType, Decl* requirementDecl, IRInst* originalKey, IRInst* associatedKey)
+ void insertRequirementKeyAssociation(Decl* requirementDecl, IRInst* originalKey, IRInst* associatedKey)
{
- auto decor = interfaceType->findDecoration<IRDifferentiableMethodRequirementDictionaryDecoration>();
- if (!decor)
- {
- decor =
- (IRDifferentiableMethodRequirementDictionaryDecoration*)
- context->irBuilder->addDecoration(
- interfaceType, kIROp_DifferentiableMethodRequirementDictionaryDecoration);
- }
- IROp op = kIROp_ForwardDifferentiableMethodRequirementDictionaryItem;
+ IROp op = kIROp_Nop;
if (as<BackwardDerivativeRequirementDecl>(requirementDecl))
{
- op = kIROp_BackwardDifferentiableMethodRequirementDictionaryItem;
+ op = kIROp_BackwardDerivativeDecoration;
}
else if (as<BackwardDerivativePropagateRequirementDecl>(requirementDecl))
{
- op = kIROp_BackwardDifferentiablePropagateMethodRequirementDictionaryItem;
+ op = kIROp_BackwardDerivativePropagateDecoration;
}
else if (as<BackwardDerivativePrimalRequirementDecl>(requirementDecl))
{
- op = kIROp_BackwardDifferentiablePrimalMethodRequirementDictionaryItem;
+ op = kIROp_BackwardDerivativePrimalDecoration;
+ }
+ else if (as<ForwardDerivativeRequirementDecl>(requirementDecl))
+ {
+ op = kIROp_ForwardDerivativeDecoration;
}
- else if (as<BackwardDerivativeIntermediateTypeRequirementDecl>(requirementDecl))
+ else
{
- op = kIROp_BackwardDifferentiableIntermediateTypeRequirementDictionaryItem;
+ return;
}
- IRInst* args[] = {originalKey, associatedKey};
- auto assoc = context->irBuilder->emitIntrinsicInst(nullptr, op, 2, args);
- assoc->insertAtEnd(decor);
+ context->irBuilder->addDecoration(originalKey, op, associatedKey);
}
LoweredValInfo visitInterfaceDecl(InterfaceDecl* decl)
@@ -7005,7 +6999,7 @@ struct DeclLoweringVisitor : DeclVisitor<DeclLoweringVisitor, LoweredValInfo>
for (auto diffDecl : callableDecl->getMembersOfType<DerivativeRequirementReferenceDecl>())
{
auto diffKey = getInterfaceRequirementKey(diffDecl->referencedDecl);
- insertRequirementKeyAssociation(irInterface, diffDecl->referencedDecl, requirementKey, diffKey);
+ insertRequirementKeyAssociation(diffDecl->referencedDecl, requirementKey, diffKey);
}
}
// Add lowered requirement entry to current decl mapping to prevent