From e9f0544aa4737d5cba8424f95485811b4839d76e Mon Sep 17 00:00:00 2001 From: jsmall-nvidia Date: Mon, 23 Sep 2019 15:42:06 -0400 Subject: Fix for preprocessor defines for C++ / C (#1063) * First pass support for performance profiling * Test across all elements * Fix bug - sourceContents is not used, should use rawSource. * * Add ability to get prelude from API. * Allow specifying source language for render-test * Made it possible to compile a test input file as C++ * Special handling for reflection * Added C++ impl to performance-profile.slang * Remove some clang warnings. * Output profile timings on appveyor and other TC. * Remove passing around of StdWriters (can use global). Small comment improvements. * Fix defines being passed through to Visual Studio. * Fix bug handling preprocessor definitions in Gcc/Clang targets. --- source/core/slang-gcc-compiler-util.cpp | 2 ++ source/core/slang-visual-studio-compiler-util.cpp | 1 + source/slang/slang-compiler.cpp | 7 +++++++ source/slang/slang-emit-cpp.cpp | 2 +- 4 files changed, 11 insertions(+), 1 deletion(-) (limited to 'source') diff --git a/source/core/slang-gcc-compiler-util.cpp b/source/core/slang-gcc-compiler-util.cpp index 3c4c4ec15..7838ca25b 100644 --- a/source/core/slang-gcc-compiler-util.cpp +++ b/source/core/slang-gcc-compiler-util.cpp @@ -511,6 +511,8 @@ static SlangResult _parseGCCFamilyLine(const UnownedStringSlice& line, LineParse for (const auto& define : options.defines) { StringBuilder builder; + + builder << "-D"; builder << define.nameWithSig; if (define.value.getLength()) { diff --git a/source/core/slang-visual-studio-compiler-util.cpp b/source/core/slang-visual-studio-compiler-util.cpp index 3d0cfdc61..8b4598b43 100644 --- a/source/core/slang-visual-studio-compiler-util.cpp +++ b/source/core/slang-visual-studio-compiler-util.cpp @@ -204,6 +204,7 @@ namespace Slang for (const auto& define : options.defines) { StringBuilder builder; + builder << "/D"; builder << define.nameWithSig; if (define.value.getLength()) { diff --git a/source/slang/slang-compiler.cpp b/source/slang/slang-compiler.cpp index 0860a339c..a24289d22 100644 --- a/source/slang/slang-compiler.cpp +++ b/source/slang/slang-compiler.cpp @@ -1243,6 +1243,13 @@ SlangResult dissassembleDXILUsingDXC( { preprocessorDefinitions.Add(define.Key, define.Value); } + { + auto linkage = targetReq->getLinkage(); + for (auto& define : linkage->preprocessorDefinitions) + { + preprocessorDefinitions.Add(define.Key, define.Value); + } + } { /* TODO(JS): Not totally clear what options should be set here. If we are using the pass through - then using say the defines/includes diff --git a/source/slang/slang-emit-cpp.cpp b/source/slang/slang-emit-cpp.cpp index dfc07aecf..1628c6770 100644 --- a/source/slang/slang-emit-cpp.cpp +++ b/source/slang/slang-emit-cpp.cpp @@ -2774,7 +2774,7 @@ void CPPSourceEmitter::emitModuleImpl(IRModule* module) m_writer->emit("uint3 calcGroupThreadID() const \n{\n"); m_writer->indent(); // groupThreadID = dispatchThreadID - groupDispatchThreadID - m_writer->emit("uint3 v = { dispatchThreadID.x - groupDispatchThreadID.x, dispatchThreadID.y - groupDispatchThreadID.y, dispatchThreadID.z - groupDispatchThreadID.z }; "); + m_writer->emit("uint3 v = { dispatchThreadID.x - groupDispatchThreadID.x, dispatchThreadID.y - groupDispatchThreadID.y, dispatchThreadID.z - groupDispatchThreadID.z };\n"); m_writer->emit("return v;\n"); m_writer->dedent(); m_writer->emit("}\n"); -- cgit v1.2.3