summaryrefslogtreecommitdiff
path: root/source/slang/slang-compiler.h
diff options
context:
space:
mode:
authorjsmall-nvidia <jsmall@nvidia.com>2019-12-10 10:02:19 -0500
committerGitHub <noreply@github.com>2019-12-10 10:02:19 -0500
commit79ec0cfdb5f3461c763e0bf712cf42eb87fccb90 (patch)
treecf0c3c0b6e7f10d3a29930cd3aeef586298d4234 /source/slang/slang-compiler.h
parent2e52217cb870b4101c1639fed78224f89bf119b3 (diff)
DownstreamCompiler abstraction (#1149)
* CPPCompiler -> DownstreamCompiler * Added DownstreamCompileResult to start abstraction such that we don't need files. * * Split out slang-blob.cpp * Made CompileResult hold a DownstreamCompileResult - for access to binary or ISlangSharedLibrary * Keep temporary files in scope. * Add a hash to the hex dump stream. * Move all file tracking into DownstreamCompiler.
Diffstat (limited to 'source/slang/slang-compiler.h')
-rw-r--r--source/slang/slang-compiler.h55
1 files changed, 20 insertions, 35 deletions
diff --git a/source/slang/slang-compiler.h b/source/slang/slang-compiler.h
index 9950764e4..c33b2cf28 100644
--- a/source/slang/slang-compiler.h
+++ b/source/slang/slang-compiler.h
@@ -4,7 +4,7 @@
#include "../core/slang-basic.h"
#include "../core/slang-shared-library.h"
-#include "../core/slang-cpp-compiler.h"
+#include "../core/slang-downstream-compiler.h"
#include "../../slang-com-ptr.h"
@@ -92,7 +92,6 @@ namespace Slang
None,
Text,
Binary,
- SharedLibrary,
};
// When storing the layout for a matrix-type
@@ -135,21 +134,20 @@ namespace Slang
{
public:
CompileResult() = default;
- CompileResult(String const& str) : format(ResultFormat::Text), outputString(str) {}
- CompileResult(List<uint8_t> const& buffer) : format(ResultFormat::Binary), outputBinary(buffer) {}
- CompileResult(ISlangSharedLibrary* inSharedLibrary) : format(ResultFormat::SharedLibrary), sharedLibrary(inSharedLibrary) {}
+ explicit CompileResult(String const& str) : format(ResultFormat::Text), outputString(str) {}
+ explicit CompileResult(ISlangBlob* inBlob) : format(ResultFormat::Binary), blob(inBlob) {}
+ explicit CompileResult(DownstreamCompileResult* inDownstreamResult): format(ResultFormat::Binary), downstreamResult(inDownstreamResult) {}
+ explicit CompileResult(const UnownedStringSlice& slice ) : format(ResultFormat::Text), outputString(slice) {}
- void append(CompileResult const& result);
-
- SlangResult getBlob(ComPtr<ISlangBlob>& outBlob);
+ SlangResult getBlob(ComPtr<ISlangBlob>& outBlob) const;
SlangResult getSharedLibrary(ComPtr<ISlangSharedLibrary>& outSharedLibrary);
ResultFormat format = ResultFormat::None;
- String outputString;
- List<uint8_t> outputBinary;
+ String outputString; ///< Only set if result type is ResultFormat::Text
+
+ mutable ComPtr<ISlangBlob> blob;
- ComPtr<ISlangSharedLibrary> sharedLibrary;
- ComPtr<ISlangBlob> blob;
+ RefPtr<DownstreamCompileResult> downstreamResult;
};
/// Information collected about global or entry-point shader parameters
@@ -1073,15 +1071,10 @@ namespace Slang
List<SearchDirectory> searchDirectories;
};
- /// Create a blob that will retain (a copy of) raw data.
- ///
- ComPtr<ISlangBlob> createRawBlob(void const* data, size_t size);
-
-
/// Given a target returns the required downstream compiler
PassThroughMode getDownstreamCompilerRequiredForTarget(CodeGenTarget target);
- PassThroughMode getPassThroughModeForCPPCompiler(CPPCompiler::CompilerType type);
+ PassThroughMode getPassThroughModeForCPPCompiler(DownstreamCompiler::CompilerType type);
/// A context for loading and re-using code modules.
@@ -1777,6 +1770,11 @@ namespace Slang
char const* text,
CodeGenTarget target);
+ void maybeDumpIntermediate(
+ BackEndCompileRequest* compileRequest,
+ DownstreamCompileResult* compileResult,
+ CodeGenTarget target);
+
/* Returns SLANG_OK if a codeGen target is available. */
SlangResult checkCompileTargetSupport(Session* session, CodeGenTarget target);
/* Returns SLANG_OK if pass through support is available */
@@ -1836,9 +1834,9 @@ namespace Slang
SLANG_NO_THROW SlangPassThrough SLANG_MCALL getDefaultDownstreamCompiler(SlangSourceLanguage sourceLanguage) override;
/// Get the specified compiler
- CPPCompiler* getCPPCompiler(PassThroughMode downstreamCompiler);
+ DownstreamCompiler* getDownstreamCompiler(PassThroughMode downstreamCompiler);
/// Get the default cpp compiler for a language
- CPPCompiler* getDefaultCPPCompiler(SourceLanguage sourceLanguage);
+ DownstreamCompiler* getDefaultCPPCompiler(SourceLanguage sourceLanguage);
enum class SharedLibraryFuncType
{
@@ -1894,7 +1892,7 @@ namespace Slang
RefPtr<Type> stringType;
RefPtr<Type> enumTypeType;
- RefPtr<CPPCompilerSet> cppCompilerSet; ///< Information about available C/C++ compilers. null unless information is requested (because slow)
+ RefPtr<DownstreamCompilerSet> cppCompilerSet; ///< Information about available C/C++ compilers. null unless information is requested (because slow)
ComPtr<ISlangSharedLibraryLoader> sharedLibraryLoader; ///< The shared library loader (never null)
ComPtr<ISlangSharedLibrary> sharedLibraries[int(SharedLibraryType::CountOf)]; ///< The loaded shared libraries
@@ -1976,7 +1974,7 @@ namespace Slang
const String& getDownstreamCompilerPrelude(PassThroughMode mode) { return m_downstreamCompilerPreludes[int(mode)]; }
/// Finds out what compilers are present and caches the result
- CPPCompilerSet* requireCPPCompilerSet();
+ DownstreamCompilerSet* requireCPPCompilerSet();
Session();
@@ -2095,20 +2093,7 @@ SLANG_FORCE_INLINE EndToEndCompileRequest* asInternal(SlangCompileRequest* reque
return reinterpret_cast<EndToEndCompileRequest*>(request);
}
-class ListBlob : public ISlangBlob, public RefObject
-{
-public:
- SLANG_REF_OBJECT_IUNKNOWN_ALL
-
- // ISlangBlob
- SLANG_NO_THROW void const* SLANG_MCALL getBufferPointer() SLANG_OVERRIDE { return m_data.getBuffer(); }
- SLANG_NO_THROW size_t SLANG_MCALL getBufferSize() SLANG_OVERRIDE { return m_data.getCount(); }
-
- List<uint8_t> m_data;
-protected:
- ISlangUnknown* getInterface(const Guid& guid);
-};
}