diff options
| author | jsmall-nvidia <jsmall@nvidia.com> | 2022-12-02 09:29:38 -0500 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2022-12-02 09:29:38 -0500 |
| commit | 92ae4949fe1af28ef31331fd4116c8111c057420 (patch) | |
| tree | be4ea011fb7bcd891223a94b3bbd235382afbe5f /source/slang/slang-emit.cpp | |
| parent | 30b5335fed9524101d980618b0749dcaf546c319 (diff) | |
Inline functions with string param/return for GPU targets (#2544)
* #include an absolute path didn't work - because paths were taken to always be relative.
* WIP inlining of functions that take or return string related types on GPU targets.
* Small fixes.
* Added a test.
* Add checking for any getStringHash insts are valid.
* Support getStringHash on CUDA.
* Tweak diagnostic.
Diffstat (limited to 'source/slang/slang-emit.cpp')
| -rw-r--r-- | source/slang/slang-emit.cpp | 18 |
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. |
