diff options
| author | jsmall-nvidia <jsmall@nvidia.com> | 2019-06-06 17:48:39 -0400 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2019-06-06 17:48:39 -0400 |
| commit | fc083a75b94ac4b4e735b4a7ff566191b9123f74 (patch) | |
| tree | ac1168718ac36099374373fdb55b9be178a0a9fa /source/slang/slang-compiler.cpp | |
| parent | 0d9071bd1511ee2cb7d6ba6ce9e250d25613ddca (diff) | |
Split out target code generation from CLikeSourceEmitter (#976)
* * Added SourceStyle to CLikeSourceEmitter, to limit cases to actual target types.
* Made Impl methods _ prefixed
* Small tidyup
* * SourceStream -> SourceWriter
* use slang-emit- prefix on SourceWriter file
* * Remove EmitContext -> merge into CLikeSourceEmitter
* slang-c-like-source-emitter -> slang-emit-source.cpp
* ExtensionUsageTracker -> GLSLExtensionTracker
slang-extension-usage-tracker.cpp/.h -> slang-emit-glsl-extension-tracker.cpp/.h
* emit-source.cpp.h -> emit-c-like.cpp/.h
* Small fix to move where some _ prefixed functions are declared in CLikeSourceEmitter.
* * CLikeSourceEmitter::CInfo -> Desc
* Functions to get and find CodeGenTarget by name
* Split out empty language impls
* Create an impl based on SourceStyle
* * CodeGenTarget conversion to and from string
* Move HLSL specific functions to HLSLEmitSource.
* Emitting texture and image types.
* Move move GLSL specific functionality to GLSLSourceEmitter
* Split more out of slang-emit-c-like
* Refactor more out of slang-emit-c-like
* * tryEmitIRInstExprImpl(IRInst* inst, IREmitMode mode, const EmitOpInfo& inOuterPrec)
* Fix bug around output of uintBitsToFloat
* More work refactoring out target specifics from slang-emit-c-like
* Move functions that are only implemented once in GLSL impl into their Impl method.
* Move rate qualification out of slang-emit-c-like
* * Added getEmitOpForOp - allows for table usage so different ops can be dealt with the same way
* Moved vector comparison to slang-emit-glsl
*
* * Use EmitOpInfo to control output in slang-emit-c-like.cpp for unary ops
* Move more functionality from CLikeSourceEmitter to HLSLSourceEmitter
* Make output of parameters implementaion specific.
* Extracted interpolation modifiers.
* Remove IR from methods that don't need them.
* Remove IR from method names.
* Refactor handling of output of types - to make the impls implement the full path without lots of cases for specific impls
* Add variable declaration modifiers and matrix layout to larget specific in slang-emit.
* Make target specific internal functions _ prefixed.
Diffstat (limited to 'source/slang/slang-compiler.cpp')
| -rw-r--r-- | source/slang/slang-compiler.cpp | 50 |
1 files changed, 50 insertions, 0 deletions
diff --git a/source/slang/slang-compiler.cpp b/source/slang/slang-compiler.cpp index 94f350ce3..99caed8f0 100644 --- a/source/slang/slang-compiler.cpp +++ b/source/slang/slang-compiler.cpp @@ -70,6 +70,56 @@ namespace Slang { +#define SLANG_CODE_GEN_TARGETS(x) \ + x("unknown", Unknown) \ + x("none", None) \ + x("glsl", GLSL) \ + x("glsl-vulkan", GLSL_Vulkan) \ + x("glsl-vulkan-one-desc", GLSL_Vulkan_OneDesc) \ + x("hlsl", HLSL) \ + x("spirv", SPIRV) \ + x("spirv-asm,spirv-assembly", SPIRVAssembly) \ + x("dxbc", DXBytecode) \ + x("dxbc-asm,dxbc-assembly", DXBytecodeAssembly) \ + x("dxil", DXIL) \ + x("dxil-asm,dxil-assembly", DXILAssembly) \ + x("c", CSource) \ + x("cpp", CPPSource) + +#define SLANG_CODE_GEN_INFO(names, e) \ + { CodeGenTarget::e, UnownedStringSlice::fromLiteral(names) }, + + struct CodeGenTargetInfo + { + CodeGenTarget target; + UnownedStringSlice names; + }; + + static const CodeGenTargetInfo s_codeGenTargetInfos[] = + { + SLANG_CODE_GEN_TARGETS(SLANG_CODE_GEN_INFO) + }; + + CodeGenTarget calcCodeGenTargetFromName(const UnownedStringSlice& name) + { + for (int i = 0; i < SLANG_COUNT_OF(s_codeGenTargetInfos); ++i) + { + const auto& info = s_codeGenTargetInfos[i]; + + SLANG_ASSERT(i == int(info.target)); + + if (StringUtil::indexOfInSplit(info.names, ',', name) >= 0) + { + return info.target; + } + } + return CodeGenTarget::Unknown; + } + UnownedStringSlice getCodeGenTargetName(CodeGenTarget target) + { + // Return the first name + return StringUtil::getAtInSplit(s_codeGenTargetInfos[int(target)].names, ',', 0); + } // CompileResult |
