diff options
Diffstat (limited to 'source/slang/compiler.h')
| -rw-r--r-- | source/slang/compiler.h | 69 |
1 files changed, 53 insertions, 16 deletions
diff --git a/source/slang/compiler.h b/source/slang/compiler.h index 9de74e2cd..b7ab980fc 100644 --- a/source/slang/compiler.h +++ b/source/slang/compiler.h @@ -47,7 +47,12 @@ namespace Slang SPIRVAssembly = SLANG_SPIRV_ASM, DXBytecode = SLANG_DXBC, DXBytecodeAssembly = SLANG_DXBC_ASM, - SlangIR = SLANG_IR, + }; + + enum class ContainerFormat + { + None = SLANG_CONTAINER_FORMAT_NONE, + SlangModule = SLANG_CONTAINER_FORMAT_SLANG_MODULE, }; enum class LineDirectiveMode : SlangLineDirectiveMode @@ -108,13 +113,14 @@ namespace Slang // (only used when compiling from the command line) String outputPath; - // The resulting output for the enry point - // - // TODO: low-level code generation should be a distinct step - CompileResult result; - // The translation unit that this entry point came from TranslationUnitRequest* getTranslationUnit(); + + // The declaration of the entry-point function itself. + // This will be filled in as part of semantic analysis; + // it should not be assumed to be available in cases + // where any errors were diagnosed. + RefPtr<FuncDecl> decl; }; enum class PassThroughMode : SlangPassThrough @@ -156,10 +162,27 @@ namespace Slang // The parsed syntax for the translation unit RefPtr<ModuleDecl> SyntaxNode; - // The resulting output for the translation unit - // - // TODO: low-level code generation should be a distinct step - CompileResult result; + // The IR-level code for this translation unit. + // This will only be valid/non-null after semantic + // checking and IR generation are complete, so it + // is not safe to use this field without testing for NULL. + IRModule* irModule; + }; + + // A request to generate output in some target format + class TargetRequest : public RefObject + { + public: + CompileRequest* compileRequest; + CodeGenTarget target; + + // The resulting reflection layout information + RefPtr<ProgramLayout> layout; + + // Generated compile results for each entry point + // in the parent compile request (indexing matches + // the order they are given in the compile request) + List<CompileResult> entryPointResults; }; // A directory to be searched when looking for files (e.g., `#include`) @@ -182,8 +205,15 @@ namespace Slang // Pointer to parent session Session* mSession; - // What target language are we compiling to? - CodeGenTarget Target = CodeGenTarget::Unknown; + // Information on the targets we are being asked to + // generate code for. + List<RefPtr<TargetRequest>> targets; + + // What container format are we being asked to generate? + ContainerFormat containerFormat = ContainerFormat::None; + + // Path to output container to + String containerOutputPath; // Directories to search for `#include` files or `import`ed modules List<SearchDirectory> searchDirectories; @@ -235,18 +265,18 @@ namespace Slang // Files that compilation depended on List<String> mDependencyFilePaths; - // The resulting reflection layout information - RefPtr<ProgramLayout> layout; + // Generated bytecode representation of all the code + List<uint8_t> generatedBytecode; // Modules that have been dynamically loaded via `import` // // This is a list of unique modules loaded, in the order they were encountered. List<RefPtr<ModuleDecl> > loadedModulesList; - // Map from the logical name of a module to its definition + // Map from the path of a module file to its definition Dictionary<String, RefPtr<ModuleDecl>> mapPathToLoadedModule; - // Map from the path of a module file to its definition + // Map from the logical name of a module to its definition Dictionary<Name*, RefPtr<ModuleDecl>> mapNameToLoadedModules; @@ -257,8 +287,12 @@ namespace Slang void parseTranslationUnit( TranslationUnitRequest* translationUnit); + // Perform primary semantic checking on all + // of the translation units in the program void checkAllTranslationUnits(); + void generateIR(); + int executeActionsInner(); int executeActions(); @@ -282,6 +316,9 @@ namespace Slang String const& name, Profile profile); + UInt addTarget( + CodeGenTarget target); + RefPtr<ModuleDecl> loadModule( Name* name, String const& path, |
