From 19c0866b050a022406867aa650302f4efbf8e010 Mon Sep 17 00:00:00 2001 From: jsmall-nvidia Date: Sat, 29 Apr 2023 09:24:26 -0400 Subject: CommandOptions (#2856) * WIP CommandOptions * Fix some output issues. * Simplify word wrapping. * Add file extensions. * Change how lookup takes place. Add appendSplit functions to StringUtil. Make Categories hold the index range of their options. * Small improvement. * Lookup with partial option names. * Associate user values. * Encoding flags in the name. * Refactor setting up of command options. * Use CommandOptions in slang-options. * Remove old help text. * Cache the CommandOptions on the Session. * Range checking. Fix bug in the Options handling. * Extra checks for validity. * Get categories directly. * Slight improvements over output. * Added NameValue types. * Fix typo. Remove some now unused diagnostics. Fix diagnostic in testing, as output has changed. * Add minimal usage message. * Remove platform executable extension from diagnostics output. * Some improvements around getting names from NameValue types. * Improve some option descriptions. * Small fixes. --- source/slang/slang-options.cpp | 1223 ++++++++++++++++++++++++---------------- 1 file changed, 752 insertions(+), 471 deletions(-) (limited to 'source/slang/slang-options.cpp') diff --git a/source/slang/slang-options.cpp b/source/slang/slang-options.cpp index 8817095df..6cb53496f 100644 --- a/source/slang/slang-options.cpp +++ b/source/slang/slang-options.cpp @@ -29,12 +29,494 @@ #include "../compiler-core/slang-artifact-desc-util.h" #include "../compiler-core/slang-core-diagnostics.h" +#include "../core/slang-string-slice-pool.h" #include "../core/slang-char-util.h" +#include "../core/slang-command-options.h" + #include namespace Slang { +namespace { // anonymous + +// All of the options are given an unique enum +enum class OptionKind +{ + // General + + MacroDefine, + DepFile, + EntryPointName, + Help, + Include, + Language, + MatrixLayoutColumn, + MatrixLayoutRow, + ModuleName, + Output, + Profile, + Stage, + Target, + Version, + WarningsAsErrors, + DisableWarnings, + EnableWarning, + DisableWarning, + DumpWarningDiagnostics, + InputFilesRemain, + EmitIr, + + // Target + + Capability, + DefaultImageFormatUnknown, + DisableDynamicDispatch, + DisableSpecialization, + FloatingPointMode, + DebugInformation, + LineDirectiveMode, + Optimization, + Obfuscate, + + // Downstream + + CompilerPath, + DefaultDownstreamCompiler, + DownstreamArgs, + PassThrough, + + // Debugging + + DumpAst, + DumpIntermediatePrefix, + DumpIntermediates, + DumpIr, + DumpIrIds, + DumpRepro, + DumpReproOnError, + PreprocessorOutput, + ExtractRepro, + LoadRepro, + LoadReproDirectory, + NoCodeGen, + OutputIncludes, + ReproFileSystem, + SerialIr, + SkipCodeGen, + ValidateIr, + VerbosePaths, + VerifyDebugSerialIr, + + // Experimental + + EmitSpirvDirectly, + FileSystem, + Heterogeneous, + NoMangle, + + // Internal + + ArchiveType, + CompileStdLib, + Doc, + IrCompression, + LoadStdLib, + ReferenceModule, + SaveStdLib, + SaveStdLibBinSource, + TrackLiveness, + + // Depreciated + ParameterBlocksUseRegisterSpaces, + + CountOf, +}; + +struct Option +{ + OptionKind optionKind; + const char* name; + const char* usage = nullptr; + const char* description = nullptr; +}; + +enum class ValueCategory +{ + Compiler, + Target, + Language, + FloatingPointMode, + ArchiveType, + Stage, + LineDirectiveMode, + DebugInfoFormat, + + CountOf, +}; + +} // anonymous + +static void _addOptions(const ConstArrayView