From b915ae662b2e4bcaaeb6da62eb964356d0a978b4 Mon Sep 17 00:00:00 2001 From: jsmall-nvidia Date: Thu, 5 May 2022 15:53:29 -0400 Subject: Support for HLSL `export` (#2223) * #include an absolute path didn't work - because paths were taken to always be relative. * Add support for HLSL `export`. * Test for using `export` keyword. --- source/slang/slang-lower-to-ir.cpp | 29 +++++++++++++++++++---------- 1 file changed, 19 insertions(+), 10 deletions(-) (limited to 'source/slang/slang-lower-to-ir.cpp') diff --git a/source/slang/slang-lower-to-ir.cpp b/source/slang/slang-lower-to-ir.cpp index 7a99faa58..a185efba9 100644 --- a/source/slang/slang-lower-to-ir.cpp +++ b/source/slang/slang-lower-to-ir.cpp @@ -1047,6 +1047,11 @@ static void addLinkageDecoration( builder->addPublicDecoration(inst); builder->addKeepAliveDecoration(inst); } + if (decl->findModifier()) + { + builder->addHLSLExportDecoration(inst); + builder->addKeepAliveDecoration(inst); + } if (decl->findModifier()) { builder->addExternCppDecoration(inst, mangledName); @@ -5408,6 +5413,10 @@ struct DeclLoweringVisitor : DeclVisitor bool isPublicType(Type* type) { + // TODO(JS): + // Not clear how should handle HLSLExportModifier here. + // In the HLSL spec 'export' is only applicable to functions. So for now we ignore. + if (auto declRefType = as(type)) { if (declRefType->declRef.getDecl()->findModifier()) @@ -5595,6 +5604,11 @@ struct DeclLoweringVisitor : DeclVisitor irWitnessTable->setOperand(0, irSubType); addLinkageDecoration(context, irWitnessTable, inheritanceDecl, mangledName.getUnownedSlice()); + + // TODO(JS): + // Not clear what to do here around HLSLExportModifier. + // In HLSL it only (currently) applies to functions, so perhaps do nothing is reasonable. + if (parentDecl->findModifier()) { subBuilder->addPublicDecoration(irWitnessTable); @@ -6340,7 +6354,11 @@ struct DeclLoweringVisitor : DeclVisitor SLANG_UNREACHABLE("associatedtype should have been handled by visitAssocTypeDecl."); } - bool isPublicType = decl->findModifier() != nullptr; + // TODO(JS): + // Not clear what to do around HLSLExportModifier. + // The HLSL spec says it only applies to functions, so we ignore for now. + + const bool isPublicType = decl->findModifier() != nullptr; // Given a declaration of a type, we need to make sure // to output "witness tables" for any interfaces this @@ -7424,15 +7442,6 @@ struct DeclLoweringVisitor : DeclVisitor getBuilder()->addSimpleDecoration(irFunc); } -#if 0 - // Not needed as added as part of adding linkage decoration. - // Ie in call to addLinkageDecoration - if (decl->findModifier()) - { - getBuilder()->addSimpleDecoration(irFunc); - } -#endif - if (auto attr = decl->findModifier()) { IRIntLit* intLit = _getIntLitFromAttribute(getBuilder(), attr); -- cgit v1.2.3