summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorjsmall-nvidia <jsmall@nvidia.com>2019-12-05 14:54:21 -0500
committerGitHub <noreply@github.com>2019-12-05 14:54:21 -0500
commit4e2cfc95fb02fb47f02b8702494929e7cca3bec7 (patch)
tree305a5efb0decc8248bf04832c4a3f527311be607
parent138a0c90d7a2d04c58569e1a8f6afa114d3e77e1 (diff)
Added -dump-intermediate-prefix option (#1146)
* * Added ability to name the prefix for intermediates * Allowed paramters after -load-repro - as pretty useful if somewhat risky thing to do (depending on parameters) * Fix issue around setting arbitrary state outside of load-repro.
-rw-r--r--slang.h4
-rw-r--r--source/slang/slang-compiler.cpp4
-rw-r--r--source/slang/slang-compiler.h2
-rw-r--r--source/slang/slang-diagnostic-defs.h1
-rw-r--r--source/slang/slang-options.cpp25
-rw-r--r--source/slang/slang.cpp8
6 files changed, 34 insertions, 10 deletions
diff --git a/slang.h b/slang.h
index c4ee39f6d..7c53b292e 100644
--- a/slang.h
+++ b/slang.h
@@ -1198,6 +1198,10 @@ extern "C"
SlangCompileRequest* request,
int enable);
+ SLANG_API void spSetDumpIntermediatePrefix(
+ SlangCompileRequest* request,
+ const char* prefix);
+
/*!
@brief Set whether (and how) `#line` directives should be output.
*/
diff --git a/source/slang/slang-compiler.cpp b/source/slang/slang-compiler.cpp
index 1385118fc..cc60f18f4 100644
--- a/source/slang/slang-compiler.cpp
+++ b/source/slang/slang-compiler.cpp
@@ -2472,7 +2472,7 @@ SlangResult dissassembleDXILUsingDXC(
//
void dumpIntermediate(
- BackEndCompileRequest*,
+ BackEndCompileRequest* request,
void const* data,
size_t size,
char const* ext,
@@ -2494,7 +2494,7 @@ SlangResult dissassembleDXILUsingDXC(
#endif
String path;
- path.append("slang-dump-");
+ path.append(request->m_dumpIntermediatePrefix);
path.append(id);
path.append(ext);
diff --git a/source/slang/slang-compiler.h b/source/slang/slang-compiler.h
index f125a4730..17da14c14 100644
--- a/source/slang/slang-compiler.h
+++ b/source/slang/slang-compiler.h
@@ -1703,6 +1703,8 @@ namespace Slang
/// Should SPIR-V be generated directly from Slang IR rather than via translation to GLSL?
bool shouldEmitSPIRVDirectly = false;
+ String m_dumpIntermediatePrefix;
+
private:
RefPtr<ComponentType> m_program;
};
diff --git a/source/slang/slang-diagnostic-defs.h b/source/slang/slang-diagnostic-defs.h
index 15d8b6fcd..ff9b14972 100644
--- a/source/slang/slang-diagnostic-defs.h
+++ b/source/slang/slang-diagnostic-defs.h
@@ -109,7 +109,6 @@ DIAGNOSTIC( 70, Error, cannotMatchOutputFileToEntryPoint, "the output path '$
DIAGNOSTIC( 80, Error, duplicateOutputPathsForEntryPointAndTarget, "multiple output paths have been specified entry point '$0' on target '$1'")
-DIAGNOSTIC( 81, Error, parametersAfterLoadReproIgnored, "parameters after -load-repro [file] are ignored")
DIAGNOSTIC( 82, Error, unableToWriteReproFile, "unable to write repro file '%0'");
DIAGNOSTIC( 83, Error, unableToWriteModuleContainer, "unable to write module container '%0'");
DIAGNOSTIC( 84, Error, unableToReadModuleContainer, "unable to read module container '%0'");
diff --git a/source/slang/slang-options.cpp b/source/slang/slang-options.cpp
index 1523170cf..c7ede8d93 100644
--- a/source/slang/slang-options.cpp
+++ b/source/slang/slang-options.cpp
@@ -512,6 +512,8 @@ struct OptionsParser
SlangMatrixLayoutMode defaultMatrixLayoutMode = SLANG_MATRIX_LAYOUT_MODE_UNKNOWN;
+ bool hasLoadedRepro = false;
+
char const* const* argCursor = &argv[0];
char const* const* argEnd = &argv[argc];
while (argCursor != argEnd)
@@ -533,6 +535,12 @@ struct OptionsParser
{
spSetDumpIntermediates(compileRequest, true);
}
+ else if (argStr == "-dump-intermediate-prefix")
+ {
+ String prefix;
+ SLANG_RETURN_ON_FAIL(tryReadCommandLineArgument(sink, arg, &argCursor, argEnd, prefix));
+ requestImpl->getBackEndReq()->m_dumpIntermediatePrefix = prefix;
+ }
else if(argStr == "-dump-ir" )
{
requestImpl->getFrontEndReq()->shouldDumpIR = true;
@@ -587,13 +595,7 @@ struct OptionsParser
SLANG_RETURN_ON_FAIL(StateSerializeUtil::load(base, requestState, fileSystem, requestImpl));
- if (argCursor < argEnd)
- {
- sink->diagnose(SourceLoc(), Diagnostics::parametersAfterLoadReproIgnored);
- return SLANG_FAIL;
- }
-
- return SLANG_OK;
+ hasLoadedRepro = true;
}
else if (argStr == "-repro-file-system")
{
@@ -1055,6 +1057,15 @@ struct OptionsParser
}
}
+ // TODO(JS): This is a restriction because of how setting of state works for load repro
+ // If a repro has been loaded, then many of the following options will overwrite
+ // what was set up. So for now they are ignored, and only parameters set as part
+ // of the loop work if they are after -load-repro
+ if (hasLoadedRepro)
+ {
+ return SLANG_OK;
+ }
+
spSetCompileFlags(compileRequest, flags);
// As a compatability feature, if the user didn't list any explicit entry
diff --git a/source/slang/slang.cpp b/source/slang/slang.cpp
index 72014ef77..28e0a358d 100644
--- a/source/slang/slang.cpp
+++ b/source/slang/slang.cpp
@@ -1265,6 +1265,7 @@ BackEndCompileRequest::BackEndCompileRequest(
ComponentType* program)
: CompileRequestBase(linkage, sink)
, m_program(program)
+ , m_dumpIntermediatePrefix("slang-dump-")
{}
EndToEndCompileRequest::EndToEndCompileRequest(
@@ -2880,6 +2881,13 @@ SLANG_API void spSetDumpIntermediates(
Slang::asInternal(request)->getBackEndReq()->shouldDumpIntermediates = enable != 0;
}
+SLANG_API void spSetDumpIntermediatePrefix(
+ SlangCompileRequest* request,
+ const char* prefix)
+{
+ Slang::asInternal(request)->getBackEndReq()->m_dumpIntermediatePrefix = prefix;
+}
+
SLANG_API void spSetLineDirectiveMode(
SlangCompileRequest* request,
SlangLineDirectiveMode mode)