// slang-options.cpp // Implementation of options parsing for `slangc` command line, // and also for API interface that takes command-line argument strings. #include "slang-options.h" #include "../../slang.h" #include "slang-compiler.h" #include "slang-profile.h" #include "../compiler-core/slang-artifact-desc-util.h" #include "../compiler-core/slang-artifact-impl.h" #include "../compiler-core/slang-artifact-representation-impl.h" #include "../compiler-core/slang-name-convention-util.h" #include "slang-repro.h" #include "slang-serialize-ir.h" #include "../core/slang-castable.h" #include "../core/slang-file-system.h" #include "../core/slang-type-text-util.h" #include "../core/slang-hex-dump-util.h" #include "../compiler-core/slang-command-line-args.h" #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-name-value.h" #include "../core/slang-command-options-writer.h" #include namespace Slang { namespace { // anonymous // All of the options are given an unique enum enum class OptionKind { // General MacroDefine, DepFile, EntryPointName, Help, HelpStyle, 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, GLSLForceScalarLayout, EnableEffectAnnotations, // 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, HelpStyle, OptimizationLevel, DebugLevel, FileSystemType, CountOf, }; } // anonymous static void _addOptions(const ConstArrayView