From b39c99661b3ad482bbd419c24991ed325b5738a9 Mon Sep 17 00:00:00 2001 From: jsmall-nvidia Date: Thu, 2 Jun 2022 14:13:35 -0400 Subject: COM interfaces with host callable (#2258) * #include an absolute path didn't work - because paths were taken to always be relative. * Use TerminatedUnownedStringSlice for literals in output C++. * Remove Escape/Unescape functions used in slang-token-reader.cpp Add target type of 'host-cpp' etc to map to the target types. * Fix some corner cases around string encoding. * Added unit test for string escaping. Fixed some assorted escaping bugs. * Updated test output. * Added decode test. * Stop using hex output, to get around 'greedy' aspect. Use octal instead. * Added HostHostCallable Small changes to use ArtifactDesc/Info instead of large switches. * Fix C++ emit to handle arbitrary function export. * Add options handling for callable without an output being specified. * Can compile with COM interface. Added example using com interface. * Use the IR Ptr type instead of hack in C++ emit for interfaces. * Fix issue with outputting the COM call when ptr is used. * Fix crash issue on compilation failure. --- source/compiler-core/slang-artifact-info.cpp | 6 ++++++ source/compiler-core/slang-artifact-info.h | 6 ++++++ source/compiler-core/slang-artifact.cpp | 1 + 3 files changed, 13 insertions(+) (limited to 'source/compiler-core') diff --git a/source/compiler-core/slang-artifact-info.cpp b/source/compiler-core/slang-artifact-info.cpp index 1b9209516..b67adb666 100644 --- a/source/compiler-core/slang-artifact-info.cpp +++ b/source/compiler-core/slang-artifact-info.cpp @@ -152,6 +152,12 @@ static const KindExtension g_cpuKindExts[] = return info.isSet(ArtifactPayloadInfo::Flag::IsGpuNative) && info.flavor == ArtifactPayloadInfo::Flavor::Binary; } +/* static */bool ArtifactInfoUtil::isPayloadCpuTarget(Payload payload) +{ + return isPayloadCpuBinary(payload) || + (payload == Payload::C || payload == Payload::CPP); +} + /* static */UnownedStringSlice ArtifactInfoUtil::getDefaultExtensionForPayload(Payload payload) { switch (payload) diff --git a/source/compiler-core/slang-artifact-info.h b/source/compiler-core/slang-artifact-info.h index 1db3712dc..e63349937 100644 --- a/source/compiler-core/slang-artifact-info.h +++ b/source/compiler-core/slang-artifact-info.h @@ -67,6 +67,12 @@ struct ArtifactInfoUtil /// Returns true if the payload type is applicable to the GPU static bool isPayloadGpuBinary(Payload payload); + /// True if is a CPU target + static bool isPayloadCpuTarget(Payload payload); + + /// True if is a CPU target - either + static bool isCpuTarget(const ArtifactDesc& desc) { return isPayloadCpuTarget(desc.payload); } + /// True if is a CPU binary static bool isCpuBinary(const ArtifactDesc& desc) { return isPayloadCpuBinary(desc.payload); } /// True if is a GPU binary diff --git a/source/compiler-core/slang-artifact.cpp b/source/compiler-core/slang-artifact.cpp index dfa9e645b..5e5b93578 100644 --- a/source/compiler-core/slang-artifact.cpp +++ b/source/compiler-core/slang-artifact.cpp @@ -38,6 +38,7 @@ namespace Slang { case SLANG_CUDA_SOURCE: return make(Kind::Text, Payload::CUDA, Style::Kernel, 0); case SLANG_PTX: return make(Kind::Executable, Payload::PTX, Style::Kernel, 0); case SLANG_OBJECT_CODE: return make(Kind::ObjectCode, Payload::HostCPU, Style::Kernel, 0); + case SLANG_HOST_HOST_CALLABLE: return make(Kind::Callable, Payload::HostCPU, Style::Host, 0); default: break; } -- cgit v1.2.3