summaryrefslogtreecommitdiff
path: root/source/slang/slang-ir-link.cpp
diff options
context:
space:
mode:
authorjsmall-nvidia <jsmall@nvidia.com>2022-05-05 15:53:29 -0400
committerGitHub <noreply@github.com>2022-05-05 15:53:29 -0400
commitb915ae662b2e4bcaaeb6da62eb964356d0a978b4 (patch)
tree94aa29d7c112bde36557371bed906411f22a7adc /source/slang/slang-ir-link.cpp
parent3088d901fee6447b6d80fa67f258626ece4408dc (diff)
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.
Diffstat (limited to 'source/slang/slang-ir-link.cpp')
-rw-r--r--source/slang/slang-ir-link.cpp29
1 files changed, 22 insertions, 7 deletions
diff --git a/source/slang/slang-ir-link.cpp b/source/slang/slang-ir-link.cpp
index 8c1edc032..80ba0b610 100644
--- a/source/slang/slang-ir-link.cpp
+++ b/source/slang/slang-ir-link.cpp
@@ -441,6 +441,7 @@ static void cloneExtraDecorations(
default:
break;
+ case kIROp_HLSLExportDecoration:
case kIROp_BindExistentialSlotsDecoration:
case kIROp_LayoutDecoration:
case kIROp_PublicDecoration:
@@ -1348,6 +1349,20 @@ struct IRSpecializationState
}
};
+static bool _isPublicOrHLSLExported(IRInst* inst)
+{
+ for (auto decoration : inst->getDecorations())
+ {
+ const auto op = decoration->getOp();
+ if (op == kIROp_PublicDecoration ||
+ op == kIROp_HLSLExportDecoration)
+ {
+ return true;
+ }
+ }
+ return false;
+}
+
LinkedIR linkIR(
CodeGenContext* codeGenContext)
{
@@ -1495,14 +1510,14 @@ LinkedIR linkIR(
{
for (auto inst : irModule->getGlobalInsts())
{
- auto hasPublic = inst->findDecoration<IRPublicDecoration>();
- if (!hasPublic)
- continue;
-
- auto cloned = cloneValue(context, inst);
- if (!cloned->findDecorationImpl(kIROp_KeepAliveDecoration))
+ // Is it `public` or (HLSL) `export` clone
+ if (_isPublicOrHLSLExported(inst))
{
- context->builder->addKeepAliveDecoration(cloned);
+ auto cloned = cloneValue(context, inst);
+ if (!cloned->findDecorationImpl(kIROp_KeepAliveDecoration))
+ {
+ context->builder->addKeepAliveDecoration(cloned);
+ }
}
}
}