From 92ae4949fe1af28ef31331fd4116c8111c057420 Mon Sep 17 00:00:00 2001 From: jsmall-nvidia Date: Fri, 2 Dec 2022 09:29:38 -0500 Subject: 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. --- source/slang/slang-emit.cpp | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) (limited to 'source/slang/slang-emit.cpp') 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. -- cgit v1.2.3