Skip to content
This repository has been archived by the owner on Jul 16, 2024. It is now read-only.

Commit

Permalink
Use updated IDownstreamCompiler::CompileOptions (#63)
Browse files Browse the repository at this point in the history
* Upgrade slang.
Use the new IDownstreamCompiler interface.
Handle different CompileOptions versions.
Attempt to support __chkstk.

* Small fix around _chkstk.

* Use __ prefix.

* Change name based on processor target for chkstk.

* Update slang submodule.

* Fix __chkstk lookup name.
  • Loading branch information
jsmall-zzz authored Mar 27, 2023
1 parent 00028d4 commit 7586799
Show file tree
Hide file tree
Showing 3 changed files with 39 additions and 2 deletions.
2 changes: 1 addition & 1 deletion external/slang
Submodule slang updated 223 files
2 changes: 2 additions & 0 deletions premake5.lua
Original file line number Diff line number Diff line change
Expand Up @@ -217,6 +217,8 @@ workspace "slang-llvm"
platforms {"aarch64" }
end

flags "MultiProcessorCompile"

--
-- Make slang-test the startup project.
--
Expand Down
37 changes: 36 additions & 1 deletion source/slang-llvm/slang-llvm.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,23 @@
# include <string.h>
#endif

#if SLANG_WINDOWS_FAMILY

/*
It's not clear if this function is needed for ARM WIN targets, but we'll assume it does for now.
https://learn.microsoft.com/en-us/windows/win32/devnotes/-win32-chkstk
https://www.betaarchive.com/wiki/index.php/Microsoft_KB_Archive/100775
https://codywu2010.wordpress.com/2010/10/04/__chkstk-and-stack-overflow/
*/

# if SLANG_PROCESSOR_X86
extern "C" void /* __declspec(naked)*/ __cdecl _chkstk();
# else
extern "C" void /* __declspec(naked)*/ __cdecl __chkstk();
# endif
#endif

// Predeclare. We'll use this symbol to lookup timestamp, if we don't have a hash.
extern "C" SLANG_DLL_EXPORT SlangResult createLLVMDownstreamCompiler_V3(const SlangUUID& intfGuid, Slang::IDownstreamCompiler** out);

Expand Down Expand Up @@ -463,6 +480,16 @@ static uint64_t __stdcall _aulldiv(uint64_t a, uint64_t b)
x(__bzero, OSXSpecific::bzero, void, (void*, size_t))
#endif

#if SLANG_WINDOWS_FAMILY
# if SLANG_PROCESSOR_X86
# define SLANG_PLATFORM_FUNCS(x) \
x(_chkstk, _chkstk, void, ())
# else
# define SLANG_PLATFORM_FUNCS(x) \
x(__chkstk, __chkstk, void, ())
# endif
#endif

#ifndef SLANG_PLATFORM_FUNCS
# define SLANG_PLATFORM_FUNCS(x)
#endif
Expand Down Expand Up @@ -562,8 +589,16 @@ void* LLVMDownstreamCompiler::getObject(const Guid& guid)
return nullptr;
}

SlangResult LLVMDownstreamCompiler::compile(const CompileOptions& options, IArtifact** outArtifact)
SlangResult LLVMDownstreamCompiler::compile(const CompileOptions& inOptions, IArtifact** outArtifact)
{
if (!isVersionCompatible(inOptions))
{
// Not possible to compile with this version of the interface.
return SLANG_E_NOT_IMPLEMENTED;
}

CompileOptions options = getCompatibleVersion(&inOptions);

// Currently supports single source file
if (options.sourceArtifacts.count != 1)
{
Expand Down

0 comments on commit 7586799

Please sign in to comment.