summaryrefslogtreecommitdiff
path: root/source/slang/slang-emit.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'source/slang/slang-emit.cpp')
-rw-r--r--source/slang/slang-emit.cpp18
1 files changed, 18 insertions, 0 deletions
diff --git a/source/slang/slang-emit.cpp b/source/slang/slang-emit.cpp
index 2476f79e5..065a30672 100644
--- a/source/slang/slang-emit.cpp
+++ b/source/slang/slang-emit.cpp
@@ -53,6 +53,8 @@
#include "slang-ir-wrap-structured-buffers.h"
#include "slang-ir-liveness.h"
#include "slang-ir-glsl-liveness.h"
+#include "slang-ir-string-hash.h"
+
#include "slang-legalize-types.h"
#include "slang-lower-to-ir.h"
#include "slang-mangle.h"
@@ -383,6 +385,16 @@ Result linkAndOptimizeIR(
break;
}
+ // If we have a target that is GPU like we use the string hashing mechanism
+ // but for that to work we need to inline such that calls (or returns) of strings
+ // boil down into getStringHash(stringLiteral)
+ if (!ArtifactDescUtil::isCpuLikeTarget(artifactDesc))
+ {
+ // We could fail because
+ // 1) It's not inlinable for some reason (for example if it's recursive)
+ SLANG_RETURN_ON_FAIL(performStringInlining(irModule, sink));
+ }
+
finalizeAutoDiffPass(irModule);
lowerReinterpret(targetRequest, irModule, sink);
@@ -391,6 +403,12 @@ Result linkAndOptimizeIR(
simplifyIR(irModule);
+ if (!ArtifactDescUtil::isCpuLikeTarget(artifactDesc))
+ {
+ // We could fail because (perhaps, somehow) end up with getStringHash that the operand is not a string literal
+ SLANG_RETURN_ON_FAIL(checkGetStringHashInsts(irModule, sink));
+ }
+
// For targets that supports dynamic dispatch, we need to lower the
// generics / interface types to ordinary functions and types using
// function pointers.