diff options
| author | jsmall-nvidia <jsmall@nvidia.com> | 2022-05-17 17:27:12 -0400 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2022-05-17 17:27:12 -0400 |
| commit | 05c4c2679ae979cfcb61e4c2acdb432c34384ddb (patch) | |
| tree | da146d2f90a28319a32bcb27ea33acec21537265 /source/slang/slang-emit-cpp.cpp | |
| parent | 39fb45484996f9d71b6551239dbf55eaaaf8db1f (diff) | |
Refactor prelude emit (#2236)
* #include an absolute path didn't work - because paths were taken to always be relative.
* Refactor how prelude output works in emit.
* Small improvement to emit output.
* Move around comment on target specific language directives based on review.
Co-authored-by: Theresa Foley <10618364+tangent-vector@users.noreply.github.com>
Diffstat (limited to 'source/slang/slang-emit-cpp.cpp')
| -rw-r--r-- | source/slang/slang-emit-cpp.cpp | 15 |
1 files changed, 7 insertions, 8 deletions
diff --git a/source/slang/slang-emit-cpp.cpp b/source/slang/slang-emit-cpp.cpp index 81d32c297..9887f1ba6 100644 --- a/source/slang/slang-emit-cpp.cpp +++ b/source/slang/slang-emit-cpp.cpp @@ -2459,15 +2459,13 @@ static Index _calcTypeOrder(IRType* a) } } -void CPPSourceEmitter::emitPreprocessorDirectivesImpl() +void CPPSourceEmitter::emitPreModuleImpl() { - SourceWriter* writer = getSourceWriter(); - - writer->emit("\n"); - - if (m_target == CodeGenTarget::CPPSource) { + // NOTE, that this opens an anonymous scope. + // The scope is closed in `emitModuleImpl` + // When generating kernel code in C++, put all into an anonymous namespace // This includes any generated types, and generated intrinsics. m_writer->emit("namespace { // anonymous \n\n"); @@ -2476,6 +2474,8 @@ void CPPSourceEmitter::emitPreprocessorDirectivesImpl() m_writer->emit("#endif\n\n"); } + // Emit generated functions and types + if (m_target == CodeGenTarget::CSource) { // For C output we need to emit type definitions. @@ -2507,7 +2507,7 @@ void CPPSourceEmitter::emitPreprocessorDirectivesImpl() m_intrinsicSet.getIntrinsics(intrinsics); // Emit all the intrinsics that were used - for (auto intrinsic: intrinsics) + for (auto intrinsic : intrinsics) { _maybeEmitSpecializedOperationDefinition(intrinsic); } @@ -2757,7 +2757,6 @@ void CPPSourceEmitter::emitModuleImpl(IRModule* module, DiagnosticSink* sink) _emitForwardDeclarations(actions); - { // Output all the thread locals for (auto action : actions) |
