summaryrefslogtreecommitdiffstats
path: root/source/slang/slang-options.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'source/slang/slang-options.cpp')
-rw-r--r--source/slang/slang-options.cpp84
1 files changed, 61 insertions, 23 deletions
diff --git a/source/slang/slang-options.cpp b/source/slang/slang-options.cpp
index b1e1b93d2..a8ac88f81 100644
--- a/source/slang/slang-options.cpp
+++ b/source/slang/slang-options.cpp
@@ -332,9 +332,24 @@ struct OptionsParser
String path = String(inPath);
String ext = Path::getPathExt(path);
- if (ext == "slang-module" || ext == "slang-lib" || ext == "dir" || ext == "zip")
+ if (ext == toSlice("slang-module") ||
+ ext == toSlice("slang-lib") ||
+ ext == toSlice("dir") ||
+ ext == toSlice("zip"))
{
- compileRequest->setOutputContainerFormat(SLANG_CONTAINER_FORMAT_SLANG_MODULE);
+ // These extensions don't indicate a artifact container, just that we want to emit IR
+ if (ext == toSlice("slang-module") ||
+ ext == toSlice("slang-lib"))
+ {
+ // We want to emit IR
+ requestImpl->m_emitIr = true;
+ }
+ else
+ {
+ // We want to write out in an artfact "container", that can hold multiple artifacts.
+ compileRequest->setOutputContainerFormat(SLANG_CONTAINER_FORMAT_SLANG_MODULE);
+ }
+
requestImpl->m_containerOutputPath = path;
}
else
@@ -591,6 +606,8 @@ struct OptionsParser
" -line-directive-mode <mode>: Sets how the `#line` directives should be\n"
" produced. Available options are:\n"
" none : Don't emit `#line` directives at all\n"
+ " source-map : Use source map to track line associations (doen't emit #line)\n"
+ " default : Default behavior\n"
" If not specified, default behavior is to use C-style `#line` directives\n"
" for HLSL and C/C++ output, and traditional GLSL-style `#line` directives\n"
" for GLSL output.\n"
@@ -890,6 +907,11 @@ struct OptionsParser
{
flags |= SLANG_COMPILE_FLAG_NO_MANGLING;
}
+ else if (argValue == toSlice("-emit-ir"))
+ {
+ // Enable emitting IR
+ requestImpl->m_emitIr = true;
+ }
else if (argValue == "-load-stdlib")
{
CommandLineArg fileName;
@@ -1178,10 +1200,6 @@ struct OptionsParser
{
getCurrentTarget()->targetFlags |= SLANG_TARGET_FLAG_PARAMETER_BLOCKS_USE_REGISTER_SPACES;
}
- else if(argValue == "-source-map")
- {
- requestImpl->getLinkage()->m_generateSourceMap = true;
- }
else if (argValue == "-ir-compression")
{
CommandLineArg name;
@@ -1448,10 +1466,19 @@ struct OptionsParser
SLANG_RETURN_ON_FAIL(reader.expectArg(name));
SlangLineDirectiveMode mode = SLANG_LINE_DIRECTIVE_MODE_DEFAULT;
- if(name.value == "none")
+
+ if(name.value == toSlice("none"))
{
mode = SLANG_LINE_DIRECTIVE_MODE_NONE;
}
+ else if (name.value == toSlice("source-map"))
+ {
+ mode = SLANG_LINE_DIRECTIVE_MODE_SOURCE_MAP;
+ }
+ else if (name.value == toSlice("default"))
+ {
+ mode = SLANG_LINE_DIRECTIVE_MODE_DEFAULT;
+ }
else
{
sink->diagnose(name.loc, Diagnostics::unknownLineDirectiveMode, name.value);
@@ -1459,7 +1486,6 @@ struct OptionsParser
}
compileRequest->setLineDirectiveMode(mode);
-
}
else if( argValue == "-fp-mode" || argValue == "-floating-point-mode" )
{
@@ -1954,26 +1980,38 @@ struct OptionsParser
//
if(rawTargets.getCount() == 0)
{
- for(auto& rawOutput : rawOutputs)
+ // If there are no targets and no outputs
+ if (rawOutputs.getCount() == 0)
{
- // Some outputs don't imply a target format, and we shouldn't use those for inference.
- auto impliedFormat = rawOutput.impliedFormat;
- if( impliedFormat == CodeGenTarget::Unknown )
- continue;
-
- int targetIndex = 0;
- if( !mapFormatToTargetIndex.TryGetValue(impliedFormat, targetIndex) )
+ // And we have a container for output, then enable emitting SlangIR module
+ if (requestImpl->m_containerFormat != ContainerFormat::None)
+ {
+ requestImpl->m_emitIr = true;
+ }
+ }
+ else
+ {
+ for(auto& rawOutput : rawOutputs)
{
- targetIndex = (int) rawTargets.getCount();
+ // Some outputs don't imply a target format, and we shouldn't use those for inference.
+ auto impliedFormat = rawOutput.impliedFormat;
+ if( impliedFormat == CodeGenTarget::Unknown )
+ continue;
- RawTarget rawTarget;
- rawTarget.format = impliedFormat;
- rawTargets.add(rawTarget);
+ int targetIndex = 0;
+ if( !mapFormatToTargetIndex.TryGetValue(impliedFormat, targetIndex) )
+ {
+ targetIndex = (int) rawTargets.getCount();
- mapFormatToTargetIndex[impliedFormat] = targetIndex;
- }
+ RawTarget rawTarget;
+ rawTarget.format = impliedFormat;
+ rawTargets.add(rawTarget);
- rawOutput.targetIndex = targetIndex;
+ mapFormatToTargetIndex[impliedFormat] = targetIndex;
+ }
+
+ rawOutput.targetIndex = targetIndex;
+ }
}
}
else